mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 21:42:06 +00:00
Add the Completion Docs page under Data Management: a searchable template table, a read-only detail panel, add and edit with a live document preview, and delete behind a confirmation that counts the open work orders still using the template and links to them. Add, edit and delete are hidden for users whose role lacks the matching template permission. The preview shares the work-order completion document's page frame, header, safety bullets and procedure heading so the two stay identical.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { z } from "zod";
|
|
import { COMPLETION_TEMPLATE_COPY } from "@/domain/completion-templates/constants/completion-template-constants";
|
|
|
|
const procedureDtoSchema = z.object({
|
|
name: z.string().nullish(),
|
|
description: z.string().nullish(),
|
|
sortOrder: z.number().nullish(),
|
|
});
|
|
|
|
export const completionTemplateDtoSchema = z.object({
|
|
id: z.number(),
|
|
name: z.string().nullish(),
|
|
extraSafetyNote: z.string().nullish(),
|
|
procedures: z.array(procedureDtoSchema).nullish(),
|
|
createdAt: z.string().nullish(),
|
|
updatedAt: z.string().nullish(),
|
|
createdByName: z.string().nullish(),
|
|
serviceKey: z.string().nullish(),
|
|
workOrderType: z.number().nullish(),
|
|
templateUrl: z.string().nullish(),
|
|
isActive: z.boolean().nullish(),
|
|
});
|
|
|
|
export const completionTemplateListDtoSchema = z.array(completionTemplateDtoSchema);
|
|
|
|
export const linkedWorkOrdersDtoSchema = z.object({
|
|
count: z.number(),
|
|
workOrderIds: z.array(z.number()),
|
|
});
|
|
|
|
export type CompletionTemplateDto = z.infer<typeof completionTemplateDtoSchema>;
|
|
|
|
const procedureFormSchema = z.object({
|
|
name: z.string(),
|
|
description: z.string(),
|
|
});
|
|
|
|
export const completionTemplateFormSchema = z.object({
|
|
name: z.string().trim().min(1, COMPLETION_TEMPLATE_COPY.titleRequired),
|
|
/** `null` until the author adds the optional note. */
|
|
extraSafetyNote: z.string().nullable(),
|
|
procedures: z.array(procedureFormSchema),
|
|
});
|
|
|
|
export type CompletionTemplateFormValues = z.infer<typeof completionTemplateFormSchema>;
|