From 3085b02e8463757e914e48186df8a0df34175935 Mon Sep 17 00:00:00 2001 From: Henry Oforeh Date: Fri, 19 Jan 2024 09:56:51 -0700 Subject: [PATCH] [MDS-5725] Add submission report (#2900) * wip * refactor code. * remove console.log statement. * add submission status --- .../common/src/components/reports/ReportDetailsForm.tsx | 6 ++++-- services/common/src/components/reports/ReportSteps.tsx | 3 ++- .../common/src/interfaces/reports/mineReport.interface.ts | 2 ++ services/minespace-web/public/notify-parent.js | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/services/common/src/components/reports/ReportDetailsForm.tsx b/services/common/src/components/reports/ReportDetailsForm.tsx index e7f25edbf4..91a765a444 100644 --- a/services/common/src/components/reports/ReportDetailsForm.tsx +++ b/services/common/src/components/reports/ReportDetailsForm.tsx @@ -19,6 +19,7 @@ import RenderField from "../forms/RenderField"; import { IMineReport, IMineReportDefinition, + IMineReportSubmission, IParty, IPartyAppt, MinePartyAppointmentTypeCodeEnum, @@ -99,10 +100,10 @@ const ReportDetailsForm: FC = ({ const dispatch = useDispatch(); const formValues: IMineReport = useSelector((state) => getFormValues(FORM.VIEW_EDIT_REPORT)(state)) ?? {}; - const { mine_report_category = "", mine_report_definition_guid = "" } = formValues; const [mineManager, setMineManager] = useState(); const [mineManagerGuid, setMineManagerGuid] = useState(""); const [selectedReportName, setSelectedReportName] = useState(""); + const { mine_report_category = "", mine_report_definition_guid = "" } = formValues; const [selectedReportCode, setSelectedReportCode] = useState(""); const [formattedMineReportDefinitionOptions, setFormatMineReportDefinitionOptions] = useState([]); const [mineReportSubmissions, setMineReportSubmissions] = useState([]); @@ -185,7 +186,8 @@ const ReportDetailsForm: FC = ({ } }, [mine_report_definition_guid]); - const updateMineReportSubmissions = (updatedSubmissions) => { + const updateMineReportSubmissions = (updatedSubmissions: IMineReportSubmission[]) => { + dispatch(change(FORM.VIEW_EDIT_REPORT, "mine_report_submissions", updatedSubmissions)); setMineReportSubmissions(updatedSubmissions); }; diff --git a/services/common/src/components/reports/ReportSteps.tsx b/services/common/src/components/reports/ReportSteps.tsx index dd2b14d1b9..cc5829f62b 100644 --- a/services/common/src/components/reports/ReportSteps.tsx +++ b/services/common/src/components/reports/ReportSteps.tsx @@ -10,6 +10,7 @@ import { fetchMineRecordById } from "@mds/common/redux/actionCreators/mineAction import moment from "moment-timezone"; import ReportDetailsForm from "@mds/common/components/reports/ReportDetailsForm"; import { createMineReport } from "@mds/common/redux/actionCreators/reportActionCreator"; +import { MINE_REPORT_SUBMISSION_CODES } from "../.."; const ReportSteps = () => { const history = useHistory(); @@ -98,7 +99,7 @@ const ReportSteps = () => { isEditMode={false} mineGuid={mineGuid} handleSubmit={(values) => { - const formValues = { received_date: moment().format("YYYY-MM-DD"), ...values }; + const formValues = { mine_report_submission_status: MINE_REPORT_SUBMISSION_CODES.REC, received_date: moment().format("YYYY-MM-DD"), ...values }; dispatch(createMineReport(mineGuid, formValues)).then((response) => { if (response.data) { const { mine_guid, mine_report_guid } = response.data; diff --git a/services/common/src/interfaces/reports/mineReport.interface.ts b/services/common/src/interfaces/reports/mineReport.interface.ts index 059c93ecbb..8dfc4a2df6 100644 --- a/services/common/src/interfaces/reports/mineReport.interface.ts +++ b/services/common/src/interfaces/reports/mineReport.interface.ts @@ -1,5 +1,6 @@ import { IMineReportSubmission } from "@mds/common/interfaces/reports/mineReportSubmission.interface"; import { IMineReportContact } from "./mineReportContact.interface"; +import { MINE_REPORT_SUBMISSION_CODES } from "../.."; export interface IMineReport { mine_report_id: string; @@ -18,4 +19,5 @@ export interface IMineReport { mine_name: string; submitter_name: string; submitter_email: string; + mine_report_submission_status?: MINE_REPORT_SUBMISSION_CODES; } diff --git a/services/minespace-web/public/notify-parent.js b/services/minespace-web/public/notify-parent.js index a81d4c44f8..9dbb5c7f9e 100644 --- a/services/minespace-web/public/notify-parent.js +++ b/services/minespace-web/public/notify-parent.js @@ -1,3 +1,3 @@ -// This script is used to notify the parent window of the current URL and is used +// This script is used to notify the parent window of the current URL and is used // by Keycloak in Minespace to seamlessly check if the user is logged in. parent.postMessage(location.href, location.origin);