Skip to content

Commit

Permalink
Update "Back to Reports" link in Core view report to return to mine r…
Browse files Browse the repository at this point in the history
…eports instead of all reports.
  • Loading branch information
matbusby committed Mar 22, 2024
1 parent d994afd commit ca8699f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions services/common/src/constants/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,9 @@ export enum MineReportType {
"permit-required-reports" = "PRR",
"tailings-reports" = "TAR",
}

export enum MineReportTypeUrlParam {
"CRR" = "code-required-reports",
"PRR" = "permit-required-reports",
"TAR" = "tailings-reports",
}
13 changes: 11 additions & 2 deletions services/core-web/src/components/mine/Reports/ReportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
IMineReportSubmission,
MINE_REPORT_STATUS_HASH,
MINE_REPORT_SUBMISSION_CODES,
MineReportTypeUrlParam,
} from "@mds/common";
import { getMineById } from "@mds/common/redux/selectors/mineSelectors";
import { fetchMineRecordById } from "@mds/common/redux/actionCreators/mineActionCreator";
Expand All @@ -37,7 +38,9 @@ const ReportPage: FC = () => {
const { mineGuid, reportGuid } = useParams<{ mineGuid: string; reportGuid: string }>();
const mine = useSelector((state) => getMineById(state, mineGuid));
const mineReportStatusOptions = useSelector(getDropdownMineReportStatusOptions);
const latestSubmission = useSelector((state) => getLatestReportSubmission(state, reportGuid));
const latestSubmission: IMineReportSubmission = useSelector((state) =>
getLatestReportSubmission(state, reportGuid)
);

const [selectedStatus, setSelectedStatus] = useState<MINE_REPORT_SUBMISSION_CODES>(
latestSubmission?.mine_report_submission_status_code
Expand Down Expand Up @@ -181,7 +184,13 @@ const ReportPage: FC = () => {
</Row>
</Typography.Title>
</Row>
<Link to={routes.REPORTS_DASHBOARD.route}>
<Link
to={routes.MINE_REPORTS.dynamicRoute(
mineGuid,
MineReportTypeUrlParam[latestSubmission?.report_type],
{}
)}
>
<ArrowLeftOutlined />
Back to: Reports
</Link>
Expand Down

0 comments on commit ca8699f

Please sign in to comment.