- Implemented CatalogTemplateForm for creating and managing asset templates. - Added inventory management components including AssetInventoryPage and related forms. - Introduced internationalization support for asset and inventory components in English and Spanish. - Created tests for catalog and inventory functionalities to ensure proper rendering and behavior. - Established API interactions for inventory management and asset catalog retrieval. - Enhanced user experience with form dialogs for quick creation of sites and persons within company inventory.
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { z } from "zod/v4";
|
|
|
|
import { FieldTypeSchema } from "./asset-definition";
|
|
|
|
export const AssetStatusSchema = z.enum(["available", "in_use", "maintenance", "retired"]);
|
|
export const AssetCharacteristicSchema = z.strictObject({
|
|
fieldId: z.uuid(),
|
|
name: z.string().min(1).max(100),
|
|
type: FieldTypeSchema,
|
|
unit: z.string().max(30),
|
|
choices: z.array(z.string().min(1).max(100)),
|
|
required: z.boolean(),
|
|
});
|
|
export const AssetValueSchema = z.union([z.string().max(10000), z.number().finite(), z.boolean()]);
|
|
export const AssetInputSchema = z.strictObject({
|
|
name: z.string().min(1).max(100),
|
|
templateId: z.uuid(),
|
|
siteId: z.uuid().nullable(),
|
|
personId: z.uuid().nullable(),
|
|
status: AssetStatusSchema,
|
|
notes: z.string().max(10000),
|
|
characteristics: z.record(z.uuid(), AssetValueSchema),
|
|
});
|
|
export const AssetSpecificationSchema = z.strictObject({
|
|
templateId: z.uuid(),
|
|
templateName: z.string().min(1).max(100),
|
|
fields: z.array(AssetCharacteristicSchema).min(1).max(100),
|
|
});
|
|
export type AssetInput = z.infer<typeof AssetInputSchema>;
|
|
export type AssetSpecificationData = z.infer<typeof AssetSpecificationSchema>;
|
|
export type AssetCharacteristic = z.infer<typeof AssetCharacteristicSchema>;
|