feat: enforce ticket ownership during work sessions
This commit is contained in:
parent
81657e52d8
commit
3972f66c92
6 changed files with 397 additions and 43 deletions
|
|
@ -83,6 +83,19 @@ const serverTicketSchema = z.object({
|
|||
startedAt: z.number(),
|
||||
})
|
||||
.nullable(),
|
||||
perAgentTotals: z
|
||||
.array(
|
||||
z.object({
|
||||
agentId: z.string(),
|
||||
agentName: z.string().nullable().optional(),
|
||||
agentEmail: z.string().nullable().optional(),
|
||||
avatarUrl: z.string().nullable().optional(),
|
||||
totalWorkedMs: z.number(),
|
||||
internalWorkedMs: z.number().optional(),
|
||||
externalWorkedMs: z.number().optional(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
.nullable()
|
||||
.optional(),
|
||||
|
|
@ -158,6 +171,15 @@ export function mapTicketFromServer(input: unknown) {
|
|||
startedAt: new Date(s.workSummary.activeSession.startedAt),
|
||||
}
|
||||
: null,
|
||||
perAgentTotals: (s.workSummary.perAgentTotals ?? []).map((item) => ({
|
||||
agentId: item.agentId,
|
||||
agentName: item.agentName ?? null,
|
||||
agentEmail: item.agentEmail ?? null,
|
||||
avatarUrl: item.avatarUrl ?? null,
|
||||
totalWorkedMs: item.totalWorkedMs,
|
||||
internalWorkedMs: item.internalWorkedMs ?? 0,
|
||||
externalWorkedMs: item.externalWorkedMs ?? 0,
|
||||
})),
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
|
@ -219,6 +241,15 @@ export function mapTicketWithDetailsFromServer(input: unknown) {
|
|||
startedAt: new Date(s.workSummary.activeSession.startedAt),
|
||||
}
|
||||
: null,
|
||||
perAgentTotals: (s.workSummary.perAgentTotals ?? []).map((item) => ({
|
||||
agentId: item.agentId,
|
||||
agentName: item.agentName ?? null,
|
||||
agentEmail: item.agentEmail ?? null,
|
||||
avatarUrl: item.avatarUrl ?? null,
|
||||
totalWorkedMs: item.totalWorkedMs,
|
||||
internalWorkedMs: item.internalWorkedMs ?? 0,
|
||||
externalWorkedMs: item.externalWorkedMs ?? 0,
|
||||
})),
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,11 +53,22 @@ export const ticketSubcategorySummarySchema = z.object({
|
|||
categoryId: z.string().optional(),
|
||||
})
|
||||
export type TicketSubcategorySummary = z.infer<typeof ticketSubcategorySummarySchema>
|
||||
|
||||
export const ticketCommentSchema = z.object({
|
||||
id: z.string(),
|
||||
author: userSummarySchema,
|
||||
visibility: commentVisibilitySchema,
|
||||
|
||||
export const ticketAgentWorkTotalSchema = z.object({
|
||||
agentId: z.string(),
|
||||
agentName: z.string().nullable().optional(),
|
||||
agentEmail: z.string().nullable().optional(),
|
||||
avatarUrl: z.string().nullable().optional(),
|
||||
totalWorkedMs: z.number(),
|
||||
internalWorkedMs: z.number().optional().default(0),
|
||||
externalWorkedMs: z.number().optional().default(0),
|
||||
})
|
||||
export type TicketAgentWorkTotal = z.infer<typeof ticketAgentWorkTotalSchema>
|
||||
|
||||
export const ticketCommentSchema = z.object({
|
||||
id: z.string(),
|
||||
author: userSummarySchema,
|
||||
visibility: commentVisibilitySchema,
|
||||
body: z.string(),
|
||||
attachments: z
|
||||
.array(
|
||||
|
|
@ -144,11 +155,12 @@ export const ticketSchema = z.object({
|
|||
workType: z.string().optional(),
|
||||
})
|
||||
.nullable(),
|
||||
perAgentTotals: z.array(ticketAgentWorkTotalSchema).optional(),
|
||||
})
|
||||
.nullable()
|
||||
.optional(),
|
||||
})
|
||||
export type Ticket = z.infer<typeof ticketSchema>
|
||||
})
|
||||
export type Ticket = z.infer<typeof ticketSchema>
|
||||
|
||||
export const ticketWithDetailsSchema = ticketSchema.extend({
|
||||
description: z.string().optional(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue