/* * 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 { Transport } from "./../../../Interfaces/interfaces" interface Props { setVisibility: Dispatch> // this component's visibility currentTransporter: Transport setTransporter: Dispatch> } const TransportForm: React.FC = (props) => { // read values from already existing transporter const [transporterName, setTransporterName] = useState(props.currentTransporter.Name); const [vehicleNum, setVehicleNum] = useState(props.currentTransporter.VehicleNum); const [transportMethod, setTransportMethod] = useState(props.currentTransporter.Method); const [transporterGSTIN, setTransporterGSTIN] = useState(props.currentTransporter.GSTIN); const [builtyNumber, setBuiltyNumber] = useState(props.currentTransporter.Builty); 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 } props.setTransporter(newTransport); hideSelf(); } return (
); } export default TransportForm;