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