From 9ca1864b79ede841e71836132effc2e260b4e758 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Fri, 11 Nov 2022 23:28:13 +0530 Subject: added very basic functionality to generate and list invoices --- src/components/editors/invoice-headers-editor.js | 52 ++++++++++++----- src/components/tables/invoice-summary.js | 3 +- src/components/tables/invoice-table.js | 74 ++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 16 deletions(-) create mode 100644 src/components/tables/invoice-table.js (limited to 'src/components') diff --git a/src/components/editors/invoice-headers-editor.js b/src/components/editors/invoice-headers-editor.js index 4ab2dcc..d099e59 100644 --- a/src/components/editors/invoice-headers-editor.js +++ b/src/components/editors/invoice-headers-editor.js @@ -19,21 +19,25 @@ import './scss/invoice-headers.scss'; import { useState, useEffect } from 'react'; -const InvoiceHeadersEditor = ({roundOff, setRoundOff, transport, setTransport, transporter, setTransporter}) => { - const handleTransportInput = e => { +const InvoiceHeadersEditor = ({roundOff, setRoundOff, transport, setTransport}) => { + const handleInput = e => { const { name, value } = e.target; - setTransport(prev => ({ - ...prev, - [name]: value - })); - } - const handleTransporterInput = e => { - const { name, value } = e.target; - setTransporter(prev => ({ - ...prev, - [name]: value - })); + if (name.includes("Transporter.")) { + const n = name.split(".")[1]; + const transporter = transport.Transporter; + transporter[n] = value; + + setTransport(prev => ({ + ...prev, + Transporter: transporter, + })); + } else { + setTransport(prev => ({ + ...prev, + [name]: value + })); + } } return ( @@ -63,36 +67,54 @@ const InvoiceHeadersEditor = ({roundOff, setRoundOff, transport, setTransport, t