-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add remove TSDF from manifest button * put all TSDF related section into new component * useReadOnly hook used to read/write whether a manifest is readOnly or not * useUserSiteIds hook for retrieving a list of the EPA site IDs the user has access to in their profile. The array contains a list of objects containing the site IDs and the site permissions * implement useReadOnly custom hook in remaining components and update test suite to use new custom useReadOnly hook
- Loading branch information
1 parent
fc2ae37
commit efc377a
Showing
29 changed files
with
365 additions
and
154 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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { ErrorMessage } from '@hookform/error-message'; | ||
import { Handler, Manifest } from 'components/Manifest/manifestSchema'; | ||
import { QuickSignBtn } from 'components/Manifest/QuickerSign'; | ||
import { RcraSiteDetails } from 'components/RcraSite'; | ||
import { HtButton } from 'components/UI'; | ||
import { useReadOnly } from 'hooks/manifest'; | ||
import React from 'react'; | ||
import { Alert, Col } from 'react-bootstrap'; | ||
import { useFormContext } from 'react-hook-form'; | ||
|
||
interface TsdfSectionProps { | ||
tsdf?: Handler; | ||
setupSign: () => void; | ||
signAble: boolean; | ||
toggleTsdfFormShow: () => void; | ||
} | ||
|
||
export function TsdfSection({ tsdf, signAble, setupSign, toggleTsdfFormShow }: TsdfSectionProps) { | ||
const { | ||
formState: { errors }, | ||
...manifestForm | ||
} = useFormContext<Manifest>(); | ||
const [readOnly] = useReadOnly(); | ||
|
||
return ( | ||
<> | ||
{tsdf ? ( | ||
<> | ||
<RcraSiteDetails handler={tsdf} /> | ||
<div className="d-flex justify-content-between"> | ||
{/* Button to bring up the Quicker Sign modal*/} | ||
<Col className="text-end"> | ||
<QuickSignBtn | ||
siteType={'Tsdf'} | ||
mtnHandler={tsdf} | ||
onClick={setupSign} | ||
disabled={tsdf.signed || !signAble} | ||
/> | ||
</Col> | ||
</div> | ||
</> | ||
) : ( | ||
<></> | ||
)} | ||
|
||
{tsdf && !readOnly && ( | ||
<HtButton | ||
onClick={() => { | ||
manifestForm.setValue('designatedFacility', undefined); | ||
}} | ||
children={'Remove TSDF'} | ||
variant="outline-danger" | ||
horizontalAlign | ||
/> | ||
)} | ||
{!tsdf && ( | ||
<HtButton | ||
onClick={toggleTsdfFormShow} | ||
children={'Add TSDF'} | ||
variant="outline-primary" | ||
horizontalAlign | ||
/> | ||
)} | ||
<ErrorMessage | ||
errors={errors} | ||
name={'designatedFacility'} | ||
render={({ message }) => { | ||
if (!message) return null; | ||
return ( | ||
<Alert variant="danger" className="text-center m-3"> | ||
{message} | ||
</Alert> | ||
); | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
Oops, something went wrong.