Fix: specific item api & customer api

This commit is contained in:
elforjani3
2020-10-22 18:05:24 +02:00
parent 274bd2ea48
commit 099fa63245
7 changed files with 52 additions and 18 deletions

View File

@@ -17,6 +17,7 @@ function Customer({
formik,
//#withCustomersActions
requestFetchCustomers,
requestFetchCustomer,
}) {
const { id } = useParams();
const history = useHistory();
@@ -26,11 +27,12 @@ function Customer({
requestFetchCustomers({}),
);
// Handle fetch customer details.
const fetchCustomer= useQuery(['customer', id], () =>
requestFetchCustomers(),
{ enabled: !!id },
const fetchCustomer = useQuery(
['customer', id],
(key, customerId) => requestFetchCustomer(customerId),
{ enabled: id && id },
);
const handleFormSubmit = useCallback(
(payload) => {
payload.redirect && history.push('/customers');