mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 04:42:03 +00:00
46 lines
1.4 KiB
TypeScript
46 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>;
|