feat: portal reopen, reports, templates and remote access
This commit is contained in:
parent
6a75a0a9ed
commit
52c03ff1cf
16 changed files with 1387 additions and 16 deletions
|
|
@ -75,6 +75,7 @@ const MAX_SUMMARY_CHARS = 600;
|
|||
const MAX_COMMENT_CHARS = 20000;
|
||||
const DEFAULT_REOPEN_DAYS = 7;
|
||||
const MAX_REOPEN_DAYS = 14;
|
||||
const VISIT_QUEUE_KEYWORDS = ["visita", "visitas", "in loco", "laboratório", "laboratorio", "lab"];
|
||||
|
||||
type AnyCtx = QueryCtx | MutationCtx;
|
||||
|
||||
|
|
@ -2013,6 +2014,7 @@ export const create = mutation({
|
|||
),
|
||||
formTemplate: v.optional(v.string()),
|
||||
chatEnabled: v.optional(v.boolean()),
|
||||
visitDate: v.optional(v.number()),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const { user: actorUser, role } = await requireUser(ctx, args.actorId, args.tenantId)
|
||||
|
|
@ -2151,6 +2153,23 @@ export const create = mutation({
|
|||
}
|
||||
|
||||
const slaFields = applySlaSnapshot(slaSnapshot, now)
|
||||
|
||||
let resolvedQueueDoc: Doc<"queues"> | null = null
|
||||
if (resolvedQueueId) {
|
||||
const queueDoc = await ctx.db.get(resolvedQueueId)
|
||||
if (queueDoc && queueDoc.tenantId === args.tenantId) {
|
||||
resolvedQueueDoc = queueDoc as Doc<"queues">
|
||||
}
|
||||
}
|
||||
|
||||
const queueLabel = (resolvedQueueDoc?.slug ?? resolvedQueueDoc?.name ?? "").toLowerCase()
|
||||
const isVisitQueue = VISIT_QUEUE_KEYWORDS.some((keyword) => queueLabel.includes(keyword))
|
||||
const visitDueAt =
|
||||
typeof args.visitDate === "number" && Number.isFinite(args.visitDate) ? args.visitDate : null
|
||||
|
||||
if (isVisitQueue && !visitDueAt) {
|
||||
throw new ConvexError("Informe a data da visita para tickets da fila de visitas")
|
||||
}
|
||||
const id = await ctx.db.insert("tickets", {
|
||||
tenantId: args.tenantId,
|
||||
reference: nextRef,
|
||||
|
|
@ -2191,7 +2210,7 @@ export const create = mutation({
|
|||
closedAt: undefined,
|
||||
tags: [],
|
||||
slaPolicyId: undefined,
|
||||
dueAt: undefined,
|
||||
dueAt: visitDueAt && isVisitQueue ? visitDueAt : undefined,
|
||||
customFields: normalizedCustomFields.length ? normalizedCustomFields : undefined,
|
||||
...slaFields,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue