From 207dd8a47b69113f1013d7508a14d3048b3747d1 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Mon, 15 Mar 2021 14:34:22 +0300
Subject: fix: update item correctly

---
 src/containers/Service/ServiceForm.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/containers/Service/ServiceForm.tsx')

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[] = [
-- 
cgit v1.2.3

