20 lines
609 B
TypeScript
20 lines
609 B
TypeScript
import { requireStaff } from '../../../utils/guard';
|
|
import { adminListServices } from '../../../utils/booking';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
await requireStaff(event);
|
|
const rows = await adminListServices();
|
|
const services = rows.map((s) => ({
|
|
id: s.id,
|
|
slug: s.slug,
|
|
name: s.name,
|
|
description: s.description,
|
|
durationMin: s.durationMin,
|
|
priceCents: s.priceCents,
|
|
active: s.active,
|
|
staff: s.staff.map((r) => ({ id: r.staff.id, name: r.staff.name, title: r.staff.title })),
|
|
bookingsCount: s._count.bookings,
|
|
}));
|
|
return { services };
|
|
});
|