feat: implement invite onboarding and dynamic ticket fields
This commit is contained in:
parent
29a647f6c6
commit
f24a7f68ca
34 changed files with 2240 additions and 97 deletions
|
|
@ -86,9 +86,16 @@ const serverEventSchema = z.object({
|
|||
createdAt: z.number(),
|
||||
});
|
||||
|
||||
const serverCustomFieldValueSchema = z.object({
|
||||
label: z.string(),
|
||||
type: z.string(),
|
||||
value: z.any().optional(),
|
||||
displayValue: z.string().optional(),
|
||||
});
|
||||
|
||||
const serverTicketWithDetailsSchema = serverTicketSchema.extend({
|
||||
description: z.string().optional().nullable(),
|
||||
customFields: z.record(z.string(), z.any()).optional(),
|
||||
customFields: z.record(z.string(), serverCustomFieldValueSchema).optional(),
|
||||
timeline: z.array(serverEventSchema),
|
||||
comments: z.array(serverCommentSchema),
|
||||
});
|
||||
|
|
@ -126,9 +133,27 @@ export function mapTicketsFromServerList(arr: unknown[]) {
|
|||
|
||||
export function mapTicketWithDetailsFromServer(input: unknown) {
|
||||
const s = serverTicketWithDetailsSchema.parse(input);
|
||||
const customFields = Object.entries(s.customFields ?? {}).reduce<
|
||||
Record<string, { label: string; type: string; value?: unknown; displayValue?: string }>
|
||||
>(
|
||||
(acc, [key, value]) => {
|
||||
let parsedValue: unknown = value.value;
|
||||
if (value.type === "date" && typeof value.value === "number") {
|
||||
parsedValue = new Date(value.value);
|
||||
}
|
||||
acc[key] = {
|
||||
label: value.label,
|
||||
type: value.type,
|
||||
value: parsedValue,
|
||||
displayValue: value.displayValue,
|
||||
};
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
const ui = {
|
||||
...s,
|
||||
customFields: (s.customFields ?? {}) as Record<string, unknown>,
|
||||
customFields,
|
||||
category: s.category ?? undefined,
|
||||
subcategory: s.subcategory ?? undefined,
|
||||
lastTimelineEntry: s.lastTimelineEntry ?? undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue