mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
feat(checkout-data-access): add LogisticianDTO and SupplierDTO schemas for entity management
This commit is contained in:
@@ -181,6 +181,29 @@ export const ProductDTOSchema = z
|
||||
})
|
||||
.optional();
|
||||
|
||||
export const LogisticianDTOSchema = z
|
||||
.object({
|
||||
id: z.number().optional(),
|
||||
createdAt: z.string().optional(),
|
||||
modifiedAt: z.string().optional(),
|
||||
gln: z.string().optional(),
|
||||
logisticianNumber: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
})
|
||||
.optional();
|
||||
|
||||
export const SupplierDTOSchema = z
|
||||
.object({
|
||||
id: z.number().optional(),
|
||||
createdAt: z.string().optional(),
|
||||
modifiedAt: z.string().optional(),
|
||||
key: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
supplierNumber: z.string().optional(),
|
||||
supplierType: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(4)]).optional(),
|
||||
})
|
||||
.optional();
|
||||
|
||||
export const AvailabilityDTOSchema = z
|
||||
.object({
|
||||
id: z.number().optional(),
|
||||
@@ -192,10 +215,12 @@ export const AvailabilityDTOSchema = z
|
||||
inStock: z.number().optional(),
|
||||
isPrebooked: z.boolean().optional(),
|
||||
lastRequest: z.string().optional(),
|
||||
logistician: EntityContainerSchema(LogisticianDTOSchema).optional(),
|
||||
price: PriceDTOSchema,
|
||||
requestReference: z.string().optional(),
|
||||
ssc: z.string().optional(),
|
||||
sscText: z.string().optional(),
|
||||
supplier: EntityContainerSchema(SupplierDTOSchema).optional(),
|
||||
supplierInfo: z.string().optional(),
|
||||
supplierProductNumber: z.string().optional(),
|
||||
supplierSSC: z.string().optional(),
|
||||
@@ -252,8 +277,22 @@ export const DestinationDTOSchema = z
|
||||
organisation: OrganisationSchema,
|
||||
title: z.string().optional(),
|
||||
target: ShippingTargetSchema,
|
||||
targetBranch: EntityContainerSchema(BranchSchema),
|
||||
targetBranch: EntityContainerSchema(BranchSchema).optional(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
// targetBranch is only optional if target is 2 (Delivery)
|
||||
// For other targets (like Branch = 1), targetBranch should be required
|
||||
if (data?.target !== undefined && data.target !== 2) {
|
||||
return data?.targetBranch !== undefined;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{
|
||||
message: 'targetBranch is required when target is not Delivery (2)',
|
||||
path: ['targetBranch'],
|
||||
},
|
||||
)
|
||||
.optional();
|
||||
|
||||
export const EntityDTOContainerOfDestinationDTOSchema = z
|
||||
|
||||
Reference in New Issue
Block a user