From 5ac1a56a157dc116fd61712ac47c29e6d02f4c0c Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 18 Mar 2021 01:21:41 +0300
Subject: feat: add print button

---
 src/containers/WaybillPanel.tsx | 7 ++++++-
 src/requests.ts                 | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

(limited to 'src')

diff --git a/src/containers/WaybillPanel.tsx b/src/containers/WaybillPanel.tsx
index a978ad3..386d8bb 100644
--- a/src/containers/WaybillPanel.tsx
+++ b/src/containers/WaybillPanel.tsx
@@ -3,7 +3,7 @@ import { useHistory } from 'react-router-dom';
 import Input from '../components/Input';
 import Button from '../components/Button';
 import Paper from '../components/Paper';
-import { patch } from '../requests';
+import { patch, get, baseURL } from '../requests';
 import { PanelProps } from './Service/ServiceContext';
 
 
@@ -16,6 +16,8 @@ const WaybillPanel: React.FC<PanelProps> = ({ item, mutate }) => {
       mutate({ ...item, status });
     });
 
+  const handlePrint = () => window.open(`${baseURL}/spreadsheets/${item._id}`, '_blank');
+
   const handleExecute = () => handleChangeStatus('executed');
   const handleCancel = () => handleChangeStatus('cancelled');
 
@@ -29,6 +31,9 @@ const WaybillPanel: React.FC<PanelProps> = ({ item, mutate }) => {
       <Button route={`/contractors/${item.contractorId}`} variant="outlined">
         Перейти к контрагенту
       </Button>
+      <Button onClick={handlePrint}>
+        Печать
+      </Button>
       {
         executed
           ? <Button onClick={handleCancel}>Откатить</Button>
diff --git a/src/requests.ts b/src/requests.ts
index af77d89..16570cc 100644
--- a/src/requests.ts
+++ b/src/requests.ts
@@ -1,6 +1,6 @@
 import axios from 'axios';
 
-const baseURL = process.env.NODE_ENV === 'production'
+export const baseURL = process.env.NODE_ENV === 'production'
   ? 'https://commercel-api.herokuapp.com'
   : 'http://localhost:3030';
 
-- 
cgit v1.2.3