Fix form template labels and guard admin auth tables
This commit is contained in:
parent
003d068c56
commit
7fb6c65d9a
2 changed files with 113 additions and 65 deletions
|
|
@ -80,6 +80,21 @@ function plainTextLength(html: string): number {
|
|||
}
|
||||
}
|
||||
|
||||
function resolveFormTemplateLabel(
|
||||
templateKey: string | null | undefined,
|
||||
storedLabel: string | null | undefined
|
||||
): string | null {
|
||||
if (storedLabel && storedLabel.trim().length > 0) {
|
||||
return storedLabel.trim();
|
||||
}
|
||||
const normalizedKey = templateKey?.trim();
|
||||
if (!normalizedKey) {
|
||||
return null;
|
||||
}
|
||||
const fallback = TICKET_FORM_CONFIG.find((entry) => entry.key === normalizedKey);
|
||||
return fallback ? fallback.label : null;
|
||||
}
|
||||
|
||||
function escapeHtml(input: string): string {
|
||||
return input
|
||||
.replace(/&/g, "&")
|
||||
|
|
@ -1281,8 +1296,8 @@ export const list = query({
|
|||
csatComment: typeof t.csatComment === "string" && t.csatComment.trim().length > 0 ? t.csatComment.trim() : null,
|
||||
csatRatedAt: t.csatRatedAt ?? null,
|
||||
csatRatedBy: t.csatRatedBy ? String(t.csatRatedBy) : null,
|
||||
formTemplate: t.formTemplate ?? null,
|
||||
formTemplateLabel: t.formTemplateLabel ?? null,
|
||||
formTemplate: t.formTemplate ?? null,
|
||||
formTemplateLabel: resolveFormTemplateLabel(t.formTemplate ?? null, t.formTemplateLabel ?? null),
|
||||
company: company
|
||||
? { id: company._id, name: company.name, isAvulso: company.isAvulso ?? false }
|
||||
: t.companyId || t.companySnapshot
|
||||
|
|
@ -1592,7 +1607,7 @@ export const getById = query({
|
|||
})),
|
||||
},
|
||||
formTemplate: t.formTemplate ?? null,
|
||||
formTemplateLabel: t.formTemplateLabel ?? null,
|
||||
formTemplateLabel: resolveFormTemplateLabel(t.formTemplate ?? null, t.formTemplateLabel ?? null),
|
||||
chatEnabled: Boolean(t.chatEnabled),
|
||||
relatedTicketIds: Array.isArray(t.relatedTicketIds) ? t.relatedTicketIds.map((id) => String(id)) : [],
|
||||
resolvedWithTicketId: t.resolvedWithTicketId ? String(t.resolvedWithTicketId) : null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue