diff options
-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[] = [ |