This commit is contained in:
David Arranz 2026-04-05 18:04:43 +02:00
parent 3ed41010f9
commit f96830c3d0
3 changed files with 21 additions and 3 deletions

View File

@ -24,7 +24,13 @@ export const useProformaCreateMutation = () => {
return useMutation<Proforma, DefaultError, CreateProformaParams, CreateProformaContext>({
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));
}

View File

@ -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));
}

View File

@ -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));
}