aboutsummaryrefslogtreecommitdiff
path: root/src/components/Menu/SubmitMenu.tsx
blob: 599b1813d3f5dff8f65be90cd094b0d40b0f7784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * OpenBills - Self hosted browser app to generate and keep track of simple invoices
 * Version - 0
 * Licensed under the MIT license - https://opensource.org/licenses/MIT
 *
 * Copyright (c) 2021 Vidhu Kant Sharma
*/

import React, { useState, Dispatch, SetStateAction } from "react";
import { PDFViewer } from '@react-pdf/renderer';
import PrintableDoc from "./../Print/PrintableDoc";

interface Props {
  setVisibility: Dispatch<SetStateAction<boolean>> // this component's visibility
}

const TransportForm: React.FC<Props> = (props) => {
  const [showPDF, setShowPDF] = useState<boolean>(false);
  const hideSelf = () =>
    props.setVisibility(false);

  const closeOnBGClicked = (event: any) =>
    event.target.className === "floatingMenuBG" && hideSelf();

  return (
    <div className={"floatingMenuBG"} onClick={closeOnBGClicked}>
      {showPDF &&
        <PDFViewer className={"PDFViewer"}>
          <PrintableDoc/>
        </PDFViewer>
      }
      <div className={"smallFloatingMenu TransportForm"} /*onSubmit={handleSubmit}*/>
        <button onClick={() => setShowPDF(true)}>Generate PDF</button>
      </div>
    </div>
  );
}

export default TransportForm;