From 062f10a25d43b875d187cf582b2ecf96d075ec26 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 25 Mar 2021 23:09:49 +0300
Subject: refactor: move services to separate folder

---
 src/containers/WaybillForm.tsx | 86 ------------------------------------------
 1 file changed, 86 deletions(-)
 delete mode 100644 src/containers/WaybillForm.tsx

(limited to 'src/containers/WaybillForm.tsx')

diff --git a/src/containers/WaybillForm.tsx b/src/containers/WaybillForm.tsx
deleted file mode 100644
index a924cc5..0000000
--- a/src/containers/WaybillForm.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import React from 'react';
-import { Form, FormikProps } from 'formik';
-import _ from 'lodash';
-import moment from 'moment';
-import Input from '../components/Input';
-import Button from '../components/Button';
-import Select from '../components/Select';
-import Paper from '../components/Paper';
-import hooks from '../hooks/useAPIClient';
-
-
-const mapper = (item: any) => ({ key: item._id, label: item.name });
-
-
-const WaybillForm: React.FC<FormikProps> = ({ setFieldValue, values }) => {
-  const { data: products } = hooks.products.useList();
-  const { data: contractors } = hooks.contractors.useList();
-
-  if (!values.date) setFieldValue('date', moment().format('YYYY-MM-DD'));
-  if (!values.contractorId && contractors?.length) setFieldValue('contractorId', contractors[0]._id);
-
-  const handleAddRecord = () => setFieldValue('records', [...values.records, {
-    productId: _.map(products, '_id').reduce((acc, id) => {
-      return acc || (!_.map(values.records, 'productId').includes(id) && id);
-    }, false),
-    price: '',
-    quantity: 1,
-  }]);
-
-  const handleRemoveRecord = (index: number) => () => {
-    const records = [...values.records];
-    records.splice(index, 1);
-    setFieldValue('records', records);
-  };
-
-  return (
-    <Form id="form">
-      <Select
-        name="contractorId"
-        label="Контрагент"
-        options={contractors?.map(mapper)}
-      />
-      <div className="grid grid-cols-2">
-        <Select
-          name="operation"
-          label="Операция"
-          options={[
-            { key: 'in', label: 'Приход' },
-            { key: 'out', label: 'Расход' },
-          ]}
-        />
-        <Input name="date" type="date" label="Дата" />
-      </div>
-      {values.records.map((record, index) => (
-        <Paper variant="outlined" className="my-4 md:mx-4" key={`${index}-${record.productId}`}>
-          <Select
-            name={`records.${index}.productId`}
-            label="Товар"
-            options={products?.map(mapper)}
-            required
-          />
-          <div className="grid grid-cols-3">
-            <Input
-              name={`records.${index}.price`}
-              type="number"
-              label="Цена"
-              required
-            />
-            <Input
-              name={`records.${index}.quantity`}
-              type="number"
-              label="Количество"
-              required
-            />
-            <div className="flex justify-end items-end">
-              <Button onClick={handleRemoveRecord(index)} size="sm" variant="outlined">Удалить</Button>
-            </div>
-          </div>
-        </Paper>
-      ))}
-      <Button onClick={handleAddRecord} variant="outlined" size="sm">Добавить товар</Button>
-    </Form>
-  );
-};
-
-export default WaybillForm;
-- 
cgit v1.2.3

