From 49a44a5762a2863566267689002834ee88d06abb Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 16 Mar 2021 01:38:54 +0300
Subject: feat: add WaybillPanel

---
 src/containers/Service/ServiceForm.tsx | 52 ----------------------------------
 1 file changed, 52 deletions(-)
 delete mode 100644 src/containers/Service/ServiceForm.tsx

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

diff --git a/src/containers/Service/ServiceForm.tsx b/src/containers/Service/ServiceForm.tsx
deleted file mode 100644
index 0c02cbd..0000000
--- a/src/containers/Service/ServiceForm.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React, { useContext } from 'react';
-import { useParams, useHistory } from 'react-router-dom';
-import { Formik } from 'formik';
-import _ from 'lodash';
-import Page, { Action } from '../Page';
-import hooks from '../../hooks/useAPIClient';
-import { post, patch, del } from '../../requests';
-import ServiceContext from './ServiceContext';
-
-interface Params {
-  id: string;
-}
-
-const ServiceForm: React.FC = () => {
-  const service = useContext(ServiceContext);
-  const history = useHistory();
-  const { id } = useParams<Params>();
-  const { data: item, mutate } = hooks[service.route].useItem(id);
-
-  const handleDelete = () => del(`/${service.route}/${id}`)
-    .then(() => history.push(`/${service.route}`));
-
-  const onSubmit = (values: any) => {
-    const promise = id
-      ? patch(`/${service.route}/${id}`, values)
-      : post(`/${service.route}`, values);
-    return promise.then(response => {
-      mutate(response.data);
-      history.push(`/${service.route}`);
-    });
-  };
-
-  const actions: Action[] = [
-    { name: 'Назад', variant: 'outlined', route: '..' },
-    { name: 'Удалить', variant: 'outlined', onClick: handleDelete },
-    { name: 'Сохранить', type: 'submit', form: 'form' },
-  ];
-
-  return (
-    <Page title={id ? item?.name : `Новый ${service.nameSingular}`} actions={actions}>
-      {(!id || item) && (
-        <Formik
-          initialValues={_.defaults(item, service.default)}
-          onSubmit={onSubmit}
-          children={service.Form}
-        />
-      )}
-    </Page>
-  );
-};
-
-export default ServiceForm;
-- 
cgit v1.2.3

