Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+134
@@ -0,0 +1,134 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const adminBookingWorkspaceVMSchema = z.object({
|
||||
stats: z.object({
|
||||
upcoming: z.number().int().nonnegative(),
|
||||
publishedPages: z.number().int().nonnegative(),
|
||||
activeMeetingTypes: z.number().int().nonnegative(),
|
||||
connectedCalendars: z.number().int().nonnegative(),
|
||||
}),
|
||||
meetingTypes: z.array(
|
||||
z.object({
|
||||
id: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
durationMinutes: z.number().int().positive(),
|
||||
hostCount: z.number().int().nonnegative(),
|
||||
active: z.boolean(),
|
||||
})
|
||||
),
|
||||
pages: z.array(
|
||||
z.object({
|
||||
id: z.string().min(1),
|
||||
title: z.string().min(1),
|
||||
slug: z.string().min(1),
|
||||
meetingTypeName: z.string().min(1),
|
||||
published: z.boolean(),
|
||||
bookingUrl: z.string().min(1),
|
||||
})
|
||||
),
|
||||
bookings: z.array(
|
||||
z.object({
|
||||
id: z.string().min(1),
|
||||
contactName: z.string().min(1),
|
||||
meetingTypeName: z.string().min(1),
|
||||
startsAt: z.string().datetime(),
|
||||
endsAt: z.string().datetime(),
|
||||
status: z.enum([
|
||||
"reserved",
|
||||
"confirmed",
|
||||
"cancelled",
|
||||
"rescheduled",
|
||||
"completed",
|
||||
"no_show",
|
||||
"provider_sync_failed",
|
||||
]),
|
||||
providerSynced: z.boolean(),
|
||||
})
|
||||
),
|
||||
externalProviderProofPending: z.boolean(),
|
||||
});
|
||||
|
||||
export type AdminBookingWorkspaceVM = z.infer<
|
||||
typeof adminBookingWorkspaceVMSchema
|
||||
>;
|
||||
|
||||
export function buildAdminBookingWorkspaceVM(input: {
|
||||
readonly meetingTypes: readonly {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly durationMinutes: number;
|
||||
readonly hostAdminUserIds: readonly string[];
|
||||
readonly active: boolean;
|
||||
}[];
|
||||
readonly pages: readonly {
|
||||
readonly id: string;
|
||||
readonly title: string;
|
||||
readonly slug: string;
|
||||
readonly published: boolean;
|
||||
readonly meetingType: { readonly name: string };
|
||||
}[];
|
||||
readonly bookings: readonly {
|
||||
readonly id: string;
|
||||
readonly startsAt: Date;
|
||||
readonly endsAt: Date;
|
||||
readonly status:
|
||||
| "reserved"
|
||||
| "confirmed"
|
||||
| "cancelled"
|
||||
| "rescheduled"
|
||||
| "completed"
|
||||
| "no_show"
|
||||
| "provider_sync_failed";
|
||||
readonly providerSyncedAt: Date | null;
|
||||
readonly contact: {
|
||||
readonly firstName: string;
|
||||
readonly lastName: string;
|
||||
};
|
||||
readonly meetingType: { readonly name: string };
|
||||
}[];
|
||||
readonly connectedCalendars: number;
|
||||
readonly bookingOrigin: string;
|
||||
readonly externalProviderProofPending?: boolean;
|
||||
}): AdminBookingWorkspaceVM {
|
||||
const now = Date.now();
|
||||
return adminBookingWorkspaceVMSchema.parse({
|
||||
stats: {
|
||||
upcoming: input.bookings.filter(
|
||||
(booking) =>
|
||||
booking.startsAt.getTime() >= now &&
|
||||
!["cancelled", "rescheduled"].includes(booking.status)
|
||||
).length,
|
||||
publishedPages: input.pages.filter((page) => page.published).length,
|
||||
activeMeetingTypes: input.meetingTypes.filter((type) => type.active)
|
||||
.length,
|
||||
connectedCalendars: input.connectedCalendars,
|
||||
},
|
||||
meetingTypes: input.meetingTypes.map((type) => ({
|
||||
id: type.id,
|
||||
name: type.name,
|
||||
durationMinutes: type.durationMinutes,
|
||||
hostCount: new Set(type.hostAdminUserIds).size,
|
||||
active: type.active,
|
||||
})),
|
||||
pages: input.pages.map((page) => ({
|
||||
id: page.id,
|
||||
title: page.title,
|
||||
slug: page.slug,
|
||||
meetingTypeName: page.meetingType.name,
|
||||
published: page.published,
|
||||
bookingUrl: `${input.bookingOrigin.replace(/\/$/u, "")}/${encodeURIComponent(page.slug)}`,
|
||||
})),
|
||||
bookings: input.bookings.map((booking) => ({
|
||||
id: booking.id,
|
||||
contactName:
|
||||
`${booking.contact.firstName} ${booking.contact.lastName}`.trim(),
|
||||
meetingTypeName: booking.meetingType.name,
|
||||
startsAt: booking.startsAt.toISOString(),
|
||||
endsAt: booking.endsAt.toISOString(),
|
||||
status: booking.status,
|
||||
providerSynced: Boolean(booking.providerSyncedAt),
|
||||
})),
|
||||
externalProviderProofPending:
|
||||
input.externalProviderProofPending ?? true,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user