diff --git a/modules/customer-invoices/src/web/proformas/shared/hooks/use-proforma-create-mutation.ts b/modules/customer-invoices/src/web/proformas/shared/hooks/use-proforma-create-mutation.ts index 7621e51a..36f69fc6 100644 --- a/modules/customer-invoices/src/web/proformas/shared/hooks/use-proforma-create-mutation.ts +++ b/modules/customer-invoices/src/web/proformas/shared/hooks/use-proforma-create-mutation.ts @@ -24,7 +24,13 @@ export const useProformaCreateMutation = () => { return useMutation({ mutationKey: CREATE_PROFORMA_MUTATION_KEY, mutationFn: async (params) => { - const result = schema.safeParse(params); + const { id: proformaId, data } = params; + + if (!proformaId) { + throw new Error("proformaId is required"); + } + + const result = schema.safeParse(data); if (!result.success) { throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error)); } diff --git a/modules/customers/src/web/shared/hooks/use-customer-create-mutation.ts b/modules/customers/src/web/shared/hooks/use-customer-create-mutation.ts index 038cec82..0257fcca 100644 --- a/modules/customers/src/web/shared/hooks/use-customer-create-mutation.ts +++ b/modules/customers/src/web/shared/hooks/use-customer-create-mutation.ts @@ -25,7 +25,13 @@ export const useCustomerCreateMutation = () => { mutationKey: CUSTOMER_CREATE_KEY, mutationFn: async (params) => { - const result = schema.safeParse(params); + const { id: customerId, data } = params; + + if (!customerId) { + throw new Error("customerId is required"); + } + + const result = schema.safeParse(data); if (!result.success) { throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error)); } diff --git a/modules/supplier/src/web/shared/hooks/use-supplier-create-mutation.ts b/modules/supplier/src/web/shared/hooks/use-supplier-create-mutation.ts index 7b2bc6ab..bfae5bc0 100644 --- a/modules/supplier/src/web/shared/hooks/use-supplier-create-mutation.ts +++ b/modules/supplier/src/web/shared/hooks/use-supplier-create-mutation.ts @@ -25,7 +25,13 @@ export const useSupplierCreateMutation = () => { mutationKey: SUPPLIER_CREATE_KEY, mutationFn: async (params) => { - const result = schema.safeParse(params); + const { id: supplierId, data } = params; + + if (!supplierId) { + throw new Error("supplierId is required"); + } + + const result = schema.safeParse(data); if (!result.success) { throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error)); }