From a7965136d75c97bb6e2696c46a7d4a27dc33996c Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Wed, 7 Jul 2021 12:46:08 +0530 Subject: create basic menu for adding transport info --- src/components/Form/Form.scss | 9 +++ src/components/Form/Transport/TransportForm.tsx | 84 +++++++++++++++++++++++++ src/components/Menu/InvoiceInfoMenu.tsx | 23 +++---- src/components/Pages/BillingPage.tsx | 13 +++- 4 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 src/components/Form/Transport/TransportForm.tsx (limited to 'src/components') diff --git a/src/components/Form/Form.scss b/src/components/Form/Form.scss index 91ba8b1..06d15ea 100644 --- a/src/components/Form/Form.scss +++ b/src/components/Form/Form.scss @@ -159,6 +159,15 @@ input { text-align: left; } +.TransportForm { + padding: 2rem; + + display: flex; + flex-direction: column; + justify-content: center /*space-between*/; + align-items: center; +} + /*.ClientInfoDisplay { font-size: $fontSize1; }*/ diff --git a/src/components/Form/Transport/TransportForm.tsx b/src/components/Form/Transport/TransportForm.tsx new file mode 100644 index 0000000..0611cc1 --- /dev/null +++ b/src/components/Form/Transport/TransportForm.tsx @@ -0,0 +1,84 @@ +/* + * 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 } from "react"; +import { Transport } from "./../../../interfaces" + +interface Props { + setVisibility: any // this component's visibility +} + +const TransportForm: React.FC = (props) => { + const [transporterName, setTransporterName] = useState(""); + const [vehicleNum, setVehicleNum] = useState(""); + const [transportMethod, setTransportMethod] = useState(""); + const [transporterGSTIN, setTransporterGSTIN] = useState(""); + const [builtyNumber, setBuiltyNumber] = useState(""); + + const hideSelf = () => + props.setVisibility(false); + + + const closeOnBGClicked = (event: any) => + event.target.className === "floatingMenuBG" && hideSelf(); + + const handleSubmit = (event: any) => { + event.preventDefault(); + + const newTransport: Transport = { + Name: transporterName, + VehicleNum: vehicleNum, + Method: transportMethod, + GSTIN: transporterGSTIN, + Builty: builtyNumber + } + console.log(newTransport); + + hideSelf(); + } + + return ( +
+
+ + + + + + + + + + + +
+
+ ); +} + +export default TransportForm; diff --git a/src/components/Menu/InvoiceInfoMenu.tsx b/src/components/Menu/InvoiceInfoMenu.tsx index 2c56f7e..ce61858 100644 --- a/src/components/Menu/InvoiceInfoMenu.tsx +++ b/src/components/Menu/InvoiceInfoMenu.tsx @@ -9,20 +9,17 @@ import React from "react"; //import "./../Form.scss"; -const InvoiceInfoMenu: React.FC = () => { +interface Props { + setShowTransportForm: any +} + +const InvoiceInfoMenu: React.FC = (props) => { return ( -
- c - o - m - i - n - g - s - o - o - n -
+ <> +
+ props.setShowTransportForm(true)}/> +
+ ); } diff --git a/src/components/Pages/BillingPage.tsx b/src/components/Pages/BillingPage.tsx index c88435b..9f98cb9 100644 --- a/src/components/Pages/BillingPage.tsx +++ b/src/components/Pages/BillingPage.tsx @@ -22,6 +22,8 @@ import InvoiceInfoMenu from "./../Menu/InvoiceInfoMenu"; import ItemsDisplay from "./../Display/ItemsDisplay"; import SummaryDisplay from "./../Display/SummaryDisplay"; +import TransportForm from "./../Form/Transport/TransportForm"; + const BillingPage: React.FC = () => { const [savedItems, getSavedItems] = useState([]); const [savedPeople, getSavedPeople] = useState([]); @@ -29,6 +31,7 @@ const BillingPage: React.FC = () => { const [registerPersonFormVisibility, setRegisterPersonFormVisibility] = useState(false); const [items, setItems] = useState([]); const [invoiceNumber, setInvoiceNumber] = useState(1234); // get data from backend + const [showTransportForm, setShowTransportForm] = useState(false); const getRegisteredItems = () => axios.get(`/api/items/get-all`) @@ -69,6 +72,12 @@ const BillingPage: React.FC = () => { /> } + {showTransportForm && + + } + { />
- +
-- cgit v1.2.3