-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from bcgov/MALS2-26
MALS2-26 - Dairy Farm Trailers & Trailer Inspections
- Loading branch information
Showing
50 changed files
with
3,249 additions
and
249 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
66 changes: 66 additions & 0 deletions
66
app/client/src/features/licences/GenerateDairyTrailerInspection.jsx
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,66 @@ | ||
import React, { useEffect } from "react"; | ||
import { useSelector, useDispatch } from "react-redux"; | ||
import { Row, Col, Form, Button } from "react-bootstrap"; | ||
|
||
import DocGenDownloadBar from "../../components/DocGenDownloadBar"; | ||
|
||
import { | ||
startDairyTrailerInspectionJob, | ||
generateReport, | ||
fetchReportJob, | ||
selectReportsJob, | ||
completeReportJob, | ||
} from "../reports/reportsSlice"; | ||
|
||
import { REPORTS } from "../../utilities/constants"; | ||
|
||
export default function GenerateDairyTrailerInspection({ licenceNumber }) { | ||
const dispatch = useDispatch(); | ||
|
||
const job = useSelector(selectReportsJob); | ||
const { pendingDocuments } = job; | ||
|
||
useEffect(() => { | ||
if (job.id && job.type === REPORTS.DAIRY_TRAILER_INSPECTION) { | ||
dispatch(fetchReportJob()); | ||
|
||
if (pendingDocuments?.length > 0) { | ||
dispatch(generateReport(pendingDocuments[0].documentId)); | ||
} else { | ||
dispatch(completeReportJob(job.id)); | ||
} | ||
} | ||
}, [pendingDocuments]); // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
const onGenerateReport = () => { | ||
dispatch( | ||
startDairyTrailerInspectionJob({ | ||
licenceNumber: licenceNumber, | ||
}) | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Row> | ||
<Col sm={3}> | ||
<Form.Label> </Form.Label> | ||
<Button | ||
variant="primary" | ||
type="button" | ||
onClick={() => onGenerateReport()} | ||
block | ||
disabled={!licenceNumber} | ||
> | ||
Generate Inspections Report | ||
</Button> | ||
</Col> | ||
</Row> | ||
<div className="mt-3"> | ||
<DocGenDownloadBar job={job} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
GenerateDairyTrailerInspection.propTypes = {}; |
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.