-
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.
New WasteRowActions component that contains the actions a user can ta…
…ke on a waste line, currently delete and edit
- Loading branch information
1 parent
a02cd19
commit a2ef0b8
Showing
3 changed files
with
65 additions
and
19 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 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
48 changes: 48 additions & 0 deletions
48
client/src/components/Manifest/WasteLine/WasteLineTable/WasteRowActions.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,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<Manifest, 'wastes'>; | ||
toggleWLModal: () => void; | ||
setEditWasteLine: (index: number) => void; | ||
} | ||
|
||
/** | ||
* WasteRowActions - actions for controlling waste lines on a manifest | ||
* @constructor | ||
*/ | ||
function WasteRowActions({ | ||
index, | ||
wasteArrayMethods, | ||
setEditWasteLine, | ||
toggleWLModal, | ||
}: WasteRowActionProps) { | ||
return ( | ||
<div className="d-flex justify-content-between mx-0"> | ||
<Button | ||
title={`remove-waste-${index}-button`} | ||
variant="danger" | ||
onClick={() => { | ||
wasteArrayMethods.remove(index); | ||
}} | ||
> | ||
<FontAwesomeIcon icon={faTimes} /> | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
setEditWasteLine(index); | ||
toggleWLModal(); | ||
}} | ||
> | ||
<FontAwesomeIcon icon={faTools} className="text-light" /> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
export { WasteRowActions }; |