From a2ef0b8d274884f3eb96291c7fa0870bfe851350 Mon Sep 17 00:00:00 2001 From: David Paul Graham Date: Wed, 30 Aug 2023 12:32:57 -0400 Subject: [PATCH] New WasteRowActions component that contains the actions a user can take on a waste line, currently delete and edit --- .../src/components/Manifest/ManifestForm.tsx | 6 ++- .../WasteLineTable/WasteLineTable.tsx | 30 +++++------- .../WasteLineTable/WasteRowActions.tsx | 48 +++++++++++++++++++ 3 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 client/src/components/Manifest/WasteLine/WasteLineTable/WasteRowActions.tsx diff --git a/client/src/components/Manifest/ManifestForm.tsx b/client/src/components/Manifest/ManifestForm.tsx index 324d13697..2b8c44216 100644 --- a/client/src/components/Manifest/ManifestForm.tsx +++ b/client/src/components/Manifest/ManifestForm.tsx @@ -476,7 +476,11 @@ export function ManifestForm({ {/* Table Showing current Waste Lines included on the manifest */} - + {readOnly ? ( <> ) : ( diff --git a/client/src/components/Manifest/WasteLine/WasteLineTable/WasteLineTable.tsx b/client/src/components/Manifest/WasteLine/WasteLineTable/WasteLineTable.tsx index 8eef8bb2a..3b7c0868a 100644 --- a/client/src/components/Manifest/WasteLine/WasteLineTable/WasteLineTable.tsx +++ b/client/src/components/Manifest/WasteLine/WasteLineTable/WasteLineTable.tsx @@ -4,25 +4,21 @@ import React, { useContext } from 'react'; import { Button, Table } from 'react-bootstrap'; import { WasteLine } from 'components/Manifest/WasteLine/wasteLineSchema'; import { ManifestContext, ManifestContextType } from 'components/Manifest/ManifestForm'; +import { WasteRowActions } from 'components/Manifest/WasteLine/WasteLineTable/WasteRowActions'; +import { UseFieldArrayReturn } from 'react-hook-form'; +import { Manifest } from 'components/Manifest'; interface WasteLineTableProps { wastes: Array; toggleWLModal: () => void; + wasteArrayMethods: UseFieldArrayReturn; } -export function WasteLineTable({ wastes, toggleWLModal }: WasteLineTableProps) { +export function WasteLineTable({ wastes, toggleWLModal, wasteArrayMethods }: WasteLineTableProps) { const { editWasteLine, setEditWasteLine } = useContext(ManifestContext); if (!wastes || wastes.length < 1) { return <>; } - // if (wastes) { - // for (let i = 0; i < wastes?.length; i++) { - // console.log('waste', wastes[i]); - // wastes[i].lineNumber = i + 1; - // } - // } - console.log('waste line desc', wastes[0].wasteDescription); - console.log('waste line dot', wastes[0].dotInformation?.printedDotInformation); return ( @@ -39,7 +35,7 @@ export function WasteLineTable({ wastes, toggleWLModal }: WasteLineTableProps) { {wastes.map((wasteLine, index) => { return ( - + ); diff --git a/client/src/components/Manifest/WasteLine/WasteLineTable/WasteRowActions.tsx b/client/src/components/Manifest/WasteLine/WasteLineTable/WasteRowActions.tsx new file mode 100644 index 000000000..2f283f1e9 --- /dev/null +++ b/client/src/components/Manifest/WasteLine/WasteLineTable/WasteRowActions.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import { Button } from 'react-bootstrap'; +import { UseFieldArrayReturn } from 'react-hook-form'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faTimes, faTools } from '@fortawesome/free-solid-svg-icons'; +import { Manifest } from 'components/Manifest'; + +interface WasteRowActionProps { + index: number; + wasteArrayMethods: UseFieldArrayReturn; + toggleWLModal: () => void; + setEditWasteLine: (index: number) => void; +} + +/** + * WasteRowActions - actions for controlling waste lines on a manifest + * @constructor + */ +function WasteRowActions({ + index, + wasteArrayMethods, + setEditWasteLine, + toggleWLModal, +}: WasteRowActionProps) { + return ( +
+ + +
+ ); +} + +export { WasteRowActions };
{wasteLine.lineNumber}{wasteLine.lineNumber + 1} - +