From 640739f3234dfe3392566e76fc950dde4b42af09 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Wed, 17 Mar 2021 03:25:28 +0300
Subject: feat: allow multiple products in a waybill

---
 src/containers/WaybillPanel.tsx | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

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

diff --git a/src/containers/WaybillPanel.tsx b/src/containers/WaybillPanel.tsx
index ca40169..397b16b 100644
--- a/src/containers/WaybillPanel.tsx
+++ b/src/containers/WaybillPanel.tsx
@@ -3,35 +3,29 @@ import { useHistory } from 'react-router-dom';
 import Input from '../components/Input';
 import Button from '../components/Button';
 import Paper from '../components/Paper';
-import { post } from '../requests';
+import { patch } from '../requests';
 import { PanelProps } from './Service/ServiceContext';
 
 
 const WaybillPanel: React.FC<PanelProps> = ({ item }) => {
   const history = useHistory();
 
-  const handleExecute = () => post(`/waybills/${item._id}/execute`)
+  const handleExecute = () => patch(`/waybills/${item._id}`, { status: 'executed' })
     .then(() => history.push('/waybills'));
 
-  const handleCancel = () => post(`/waybills/${item._id}/cancel`)
+  const handleCancel = () => patch(`/waybills/${item._id}`, { status: 'cancelled' })
     .then(() => history.push('/waybills'));
 
   const executed = item.status === 'executed';
-  const total = item.product.price * item.quantity;
 
   return (
     <div className="m-4 p-4 pl-16 border-l flex flex-col">
       <p className="text-lg">
-        Итоговая сумма: ${total}
+        Итоговая сумма: ${item.total}
       </p>
-      <div>
-        <Button route={`/contractors/${item.contractorId}`} variant="outlined">
-          Перейти к контрагенту
-        </Button>
-        <Button route={`/products/${item.productId}`} variant="outlined">
-          Перейти к продукту
-        </Button>
-      </div>
+      <Button route={`/contractors/${item.contractorId}`} variant="outlined">
+        Перейти к контрагенту
+      </Button>
       {
         executed
           ? <Button onClick={handleCancel}>Откатить</Button>
-- 
cgit v1.2.3

