diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-15 14:34:22 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-15 14:34:22 +0300 |
commit | 207dd8a47b69113f1013d7508a14d3048b3747d1 (patch) | |
tree | 95c3618fea927e4ae4a99bfd34692c5cf894a593 | |
parent | 823f26a2f735256e88620496a84ca4c21a2f2b68 (diff) | |
download | commercel-ui-207dd8a47b69113f1013d7508a14d3048b3747d1.tar.gz |
fix: update item correctly
-rw-r--r-- | src/containers/Service/ServiceForm.tsx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/containers/Service/ServiceForm.tsx b/src/containers/Service/ServiceForm.tsx index 69cc3c8..0c02cbd 100644 --- a/src/containers/Service/ServiceForm.tsx +++ b/src/containers/Service/ServiceForm.tsx @@ -15,7 +15,7 @@ const ServiceForm: React.FC = () => { const service = useContext(ServiceContext); const history = useHistory(); const { id } = useParams<Params>(); - const { data: item } = hooks[service.route].useItem(id); + const { data: item, mutate } = hooks[service.route].useItem(id); const handleDelete = () => del(`/${service.route}/${id}`) .then(() => history.push(`/${service.route}`)); @@ -24,7 +24,10 @@ const ServiceForm: React.FC = () => { const promise = id ? patch(`/${service.route}/${id}`, values) : post(`/${service.route}`, values); - return promise.then(() => history.push(`/${service.route}`)); + return promise.then(response => { + mutate(response.data); + history.push(`/${service.route}`); + }); }; const actions: Action[] = [ |