summaryrefslogtreecommitdiff
path: root/src/containers/WaybillPanel.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-16 01:38:54 +0300
committereug-vs <eug-vs@keemail.me>2021-03-16 01:38:54 +0300
commit49a44a5762a2863566267689002834ee88d06abb (patch)
treeb471b6ace58355f8d08e024e7546bf57057fe8fb /src/containers/WaybillPanel.tsx
parent6a200e57d4a0be0532587b9648ff8d58f97e91e8 (diff)
downloadcommercel-ui-49a44a5762a2863566267689002834ee88d06abb.tar.gz
feat: add WaybillPanel
Diffstat (limited to 'src/containers/WaybillPanel.tsx')
-rw-r--r--src/containers/WaybillPanel.tsx44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/containers/WaybillPanel.tsx b/src/containers/WaybillPanel.tsx
new file mode 100644
index 0000000..ca40169
--- /dev/null
+++ b/src/containers/WaybillPanel.tsx
@@ -0,0 +1,44 @@
+import React from 'react';
+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 { PanelProps } from './Service/ServiceContext';
+
+
+const WaybillPanel: React.FC<PanelProps> = ({ item }) => {
+ const history = useHistory();
+
+ const handleExecute = () => post(`/waybills/${item._id}/execute`)
+ .then(() => history.push('/waybills'));
+
+ const handleCancel = () => post(`/waybills/${item._id}/cancel`)
+ .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}
+ </p>
+ <div>
+ <Button route={`/contractors/${item.contractorId}`} variant="outlined">
+ Перейти к контрагенту
+ </Button>
+ <Button route={`/products/${item.productId}`} variant="outlined">
+ Перейти к продукту
+ </Button>
+ </div>
+ {
+ executed
+ ? <Button onClick={handleCancel}>Откатить</Button>
+ : <Button onClick={handleExecute}>Провести</Button>
+ }
+ </div>
+ );
+};
+
+export default WaybillPanel;