.
This commit is contained in:
parent
3ed41010f9
commit
f96830c3d0
@ -24,7 +24,13 @@ export const useProformaCreateMutation = () => {
|
|||||||
return useMutation<Proforma, DefaultError, CreateProformaParams, CreateProformaContext>({
|
return useMutation<Proforma, DefaultError, CreateProformaParams, CreateProformaContext>({
|
||||||
mutationKey: CREATE_PROFORMA_MUTATION_KEY,
|
mutationKey: CREATE_PROFORMA_MUTATION_KEY,
|
||||||
mutationFn: async (params) => {
|
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) {
|
if (!result.success) {
|
||||||
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,13 @@ export const useCustomerCreateMutation = () => {
|
|||||||
mutationKey: CUSTOMER_CREATE_KEY,
|
mutationKey: CUSTOMER_CREATE_KEY,
|
||||||
|
|
||||||
mutationFn: async (params) => {
|
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) {
|
if (!result.success) {
|
||||||
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,13 @@ export const useSupplierCreateMutation = () => {
|
|||||||
mutationKey: SUPPLIER_CREATE_KEY,
|
mutationKey: SUPPLIER_CREATE_KEY,
|
||||||
|
|
||||||
mutationFn: async (params) => {
|
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) {
|
if (!result.success) {
|
||||||
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user