.
This commit is contained in:
parent
2403e1ca0a
commit
3ed41010f9
@ -9,10 +9,7 @@ import { updateProformaById } from "../api";
|
||||
import type { Proforma } from "../entities";
|
||||
|
||||
import { UPDATE_PROFORMA_MUTATION_KEY } from "./keys";
|
||||
import {
|
||||
invalidateProformaListQueries,
|
||||
syncUpdatedProformaCaches,
|
||||
} from "./proforma-cache-strategy";
|
||||
import { syncUpdatedProformaCaches } from "./proforma-cache-strategy";
|
||||
import { toValidationErrors } from "./to-validation-errors";
|
||||
|
||||
type UpdateProformaContext = {};
|
||||
@ -36,17 +33,11 @@ export const useProformaUpdateMutation = () => {
|
||||
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
||||
}
|
||||
|
||||
const dto: UpdateProformaByIdResult = await updateProformaById(
|
||||
dataSource,
|
||||
params as UpdateProformaByIdParams
|
||||
);
|
||||
const dto: UpdateProformaByIdResult = await updateProformaById(dataSource, params);
|
||||
return GetProformaByIdAdapter.fromDto(dto);
|
||||
},
|
||||
onSuccess: async (proforma) => {
|
||||
await syncUpdatedProformaCaches(queryClient, proforma);
|
||||
},
|
||||
onSettled: async () => {
|
||||
await invalidateProformaListQueries(queryClient);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -11,10 +11,7 @@ import {
|
||||
} from "../api";
|
||||
import type { Customer } from "../entities";
|
||||
|
||||
import {
|
||||
invalidateCustomerListQueries,
|
||||
syncUpdatedCustomerCaches,
|
||||
} from "./customer-cache-strategy";
|
||||
import { syncUpdatedCustomerCaches } from "./customer-cache-strategy";
|
||||
import { CUSTOMER_UPDATE_KEY } from "./keys";
|
||||
import { toValidationErrors } from "./to-validation-errors";
|
||||
|
||||
@ -39,18 +36,12 @@ export const useCustomerUpdateMutation = () => {
|
||||
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
||||
}
|
||||
|
||||
const dto: UpdateCustomerByIdResult = await updateCustomerById(
|
||||
dataSource,
|
||||
params as UpdateCustomerByIdParams
|
||||
);
|
||||
const dto: UpdateCustomerByIdResult = await updateCustomerById(dataSource, params);
|
||||
return GetCustomerByIdAdapter.fromDTO(dto);
|
||||
},
|
||||
|
||||
onSuccess: (updatedCustomer) => {
|
||||
syncUpdatedCustomerCaches(queryClient, updatedCustomer);
|
||||
},
|
||||
onSettled: async () => {
|
||||
await invalidateCustomerListQueries(queryClient);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -12,10 +12,7 @@ import {
|
||||
import type { Supplier } from "../entities";
|
||||
|
||||
import { SUPPLIER_UPDATE_KEY } from "./keys";
|
||||
import {
|
||||
invalidateSupplierListQueries,
|
||||
syncUpdatedSupplierCaches,
|
||||
} from "./supplier-cache-strategy";
|
||||
import { syncUpdatedSupplierCaches } from "./supplier-cache-strategy";
|
||||
import { toValidationErrors } from "./to-validation-errors";
|
||||
|
||||
type UpdateSupplierContext = {};
|
||||
@ -39,19 +36,12 @@ export const useSupplierUpdateMutation = () => {
|
||||
throw new ValidationErrorCollection("Validation failed", toValidationErrors(result.error));
|
||||
}
|
||||
|
||||
const dto: UpdateSupplierByIdResult = await updateSupplierById(
|
||||
dataSource,
|
||||
params as UpdateSupplierByIdParams
|
||||
);
|
||||
const dto: UpdateSupplierByIdResult = await updateSupplierById(dataSource, params);
|
||||
return GetSupplierByIdAdapter.fromDTO(dto);
|
||||
},
|
||||
|
||||
onSuccess: (updatedSupplier) => {
|
||||
syncUpdatedSupplierCaches(queryClient, updatedSupplier);
|
||||
},
|
||||
|
||||
onSettled: async () => {
|
||||
await invalidateSupplierListQueries(queryClient);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user