-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add editWasteLine to ManifestContext * Use ManifestContext to pull up current wasteline information for editing * reset ManifestContext editWasteLine value on handler close * Render waste description or dotInfromation.printedDotInforation depending on what's present * New WasteRowActions component that contains the actions a user can take on a waste line, currently delete and edit
- Loading branch information
1 parent
dc7c88d
commit 266e742
Showing
8 changed files
with
196 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
client/src/components/Manifest/WasteLine/EditWasteModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { useContext } from 'react'; | ||
import { Col, Row } from 'react-bootstrap'; | ||
import { WasteLineForm } from './WasteLineForm'; | ||
import { UseFieldArrayReturn } from 'react-hook-form'; | ||
import { Manifest } from 'components/Manifest/manifestSchema'; | ||
import { WasteLine } from 'components/Manifest/WasteLine/wasteLineSchema'; | ||
import { HtModal } from 'components/Ht'; | ||
import { ManifestContext, ManifestContextType } from 'components/Manifest/ManifestForm'; | ||
|
||
interface Props { | ||
handleClose: () => void; | ||
show: boolean | undefined; | ||
currentWastes: Array<WasteLine>; | ||
wasteArrayMethods: UseFieldArrayReturn<Manifest, 'wastes'>; | ||
} | ||
|
||
/** | ||
* WasteLine is solely responsible for displaying the WasteLineForm in a | ||
* pleasant to look at modal. | ||
* @constructor | ||
*/ | ||
export function EditWasteModal({ show, handleClose, currentWastes, wasteArrayMethods }: Props) { | ||
const { editWasteLine, setEditWasteLine } = useContext<ManifestContextType>(ManifestContext); | ||
let waste: WasteLine | undefined = undefined; | ||
if (editWasteLine !== undefined) { | ||
waste = currentWastes[editWasteLine]; | ||
} | ||
let lineNumber = undefined; | ||
if (editWasteLine !== undefined) { | ||
lineNumber = editWasteLine; | ||
} else { | ||
lineNumber = currentWastes.length; | ||
} | ||
|
||
const handleCloseAndReset = () => { | ||
setEditWasteLine(undefined); | ||
handleClose(); | ||
}; | ||
|
||
return ( | ||
<HtModal | ||
showModal={show ? show : false} | ||
handleClose={handleCloseAndReset} | ||
dialogClassName="modal-90w" | ||
> | ||
<HtModal.Header closeButton> | ||
<Col> | ||
<Row> | ||
<HtModal.Title title="Add Waste Line" /> | ||
</Row> | ||
<Row> | ||
<i> | ||
<small>A waste line should be added for each unique waste stream.</small> | ||
</i> | ||
</Row> | ||
</Col> | ||
</HtModal.Header> | ||
<HtModal.Body> | ||
<WasteLineForm | ||
wasteArrayMethods={wasteArrayMethods} | ||
lineNumber={lineNumber} | ||
waste={waste} | ||
handleClose={handleCloseAndReset} | ||
/> | ||
</HtModal.Body> | ||
</HtModal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.