Skip to content

[FIX] Core typescript errors #3453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion services/common/src/interfaces/common/option.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export interface IOption {
label: string;
value: string | number;
tooltip?: string;
isActive?: boolean;
subType?: any;
}

export interface IRadioOption {
Expand All @@ -12,4 +14,4 @@ export interface IRadioOption {
export interface IGroupedDropdownList {
groupName: string | number;
opt: IOption[];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IMineIncident {
reported_timestamp: string;
verbal_notification_provided: boolean;
reported_to_inspector_party_guid: string;
reported_to_inspector_contacted: boolean;
responsible_inspector_party_guid: string;
mms_inspector_initials: string;
determination_inspector_party_guid: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IMineIncident } from "./mineIncident.interface";
import { IMineIncidentDocument } from "./mineIncidentDocument.interface";

export interface IMineIncidentForm extends IMineIncident {
initial_incident_documents: IMineIncidentDocument[],
final_report_documents: IMineIncidentDocument[],
internal_ministry_documents: IMineIncidentDocument[]
}
1 change: 1 addition & 0 deletions services/common/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from "./mineVerifiedStatus.interface";
export * from "./mineWorkInformation.interface";
export * from "./incidents/mineIncident.interface";
export * from "./incidents/mineIncidentDocument.interface";
export * from "./incidents/mineIncidentForm.interface";
export * from "./mineTenureType.interface";
export * from "./party";
export * from "./tailingsStorageFacility";
Expand Down
26 changes: 21 additions & 5 deletions services/common/src/interfaces/search/searchResult.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
export interface ISearchResult {
result: {
id: string;
value: string;
};
import { IDocument } from "../document";
import { IMine } from "../mine.interface";
import { IMineDocument } from "../mineDocument.interface";
import { IParty } from "../party";
import { IPermit, IPermitAmendmentDocument } from "../permits";

export interface ISearchResult<T> {
result: T;
score: number;
type: string;
}

export interface ISimpleSearchResult {
id: string;
value: string;
}

export interface ISearchResultList {
mine: ISearchResult<IMine>[],
mine_documents: ISearchResult<IMineDocument>[],
party: ISearchResult<IParty>[],
permit: ISearchResult<IPermit>[],
permit_documents: ISearchResult<IPermitAmendmentDocument>[],
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as actionTypes from "@mds/common/constants/actionTypes";
import { SEARCH } from "@mds/common/constants/reducerTypes";
import { ISearchResult, ISearchResultList, ISimpleSearchResult } from "@mds/common/interfaces";

/**
* @file mineReducer.js
Expand Down Expand Up @@ -54,8 +55,8 @@ const searchReducerObject = {
};

export const getSearchOptions = (state) => state[SEARCH].searchOptions;
export const getSearchResults = (state) => state[SEARCH].searchResults;
export const getSearchBarResults = (state) => state[SEARCH].searchBarResults;
export const getSearchResults = (state): ISearchResultList => state[SEARCH].searchResults;
export const getSearchBarResults = (state): ISearchResult<ISimpleSearchResult>[] => state[SEARCH].searchBarResults;
export const getSearchTerms = (state) => state[SEARCH].searchTerms;
export const getSearchSubsetResults = (state) => state[SEARCH].searchSubsetResults;

Expand Down
44 changes: 21 additions & 23 deletions services/common/src/redux/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
IComplianceArticle,
IMineReportDefinition,
IMineReportSubmission,
IOption,
ItemMap,
} from "@mds/common/interfaces";
import { MINE_REPORT_SUBMISSION_CODES } from "@mds/common/constants/enums";
Expand Down Expand Up @@ -58,7 +59,7 @@ export const createDropDownList = (
subType = null,
labelFormatter = null,
orderByAlphabetically = true
) => {
): IOption[] => {
const options = array?.map((item) => ({
value: item[valueField],
label: labelFormatter ? labelFormatter(item[labelField]) : item[labelField],
Expand Down Expand Up @@ -165,19 +166,19 @@ export const isDateRangeValid = (start, end) => {

export const dateSorter =
(key: string, ascending = true) =>
(a: any, b: any) => {
if (a[key] === b[key]) {
return 0;
}
if (!a[key]) {
return 1;
}
if (!b[key]) {
return -1;
}
(a: any, b: any) => {
if (a[key] === b[key]) {
return 0;
}
if (!a[key]) {
return 1;
}
if (!b[key]) {
return -1;
}

return ascending ? moment(a[key]).diff(moment(b[key])) : moment(b[key]).diff(moment(a[key]));
};
return ascending ? moment(a[key]).diff(moment(b[key])) : moment(b[key]).diff(moment(a[key]));
};

export const nullableStringSorter = (path) => (a, b) => {
const aObj = get(a, path, null);
Expand Down Expand Up @@ -658,7 +659,7 @@ export const getHighestConsequence = (tsf) => {

const highestRankedDam = tsf.dams.reduce((prev, current) =>
CONSEQUENCE_CLASSIFICATION_RANK_HASH[prev.consequence_classification] >
CONSEQUENCE_CLASSIFICATION_RANK_HASH[current.consequence_classification]
CONSEQUENCE_CLASSIFICATION_RANK_HASH[current.consequence_classification]
? prev
: current
);
Expand All @@ -675,20 +676,17 @@ export const getMineReportStatusDescription = (
const update_timestamp = latestSubmission?.update_timestamp;
const updatedDate = moment(update_timestamp).format("YYYY-MM-DD");
const MINE_REPORT_STATUS_DESCRIPTION_HASH = {
[MINE_REPORT_SUBMISSION_CODES.NON]: `The ministry has requested for the report from the proponent through MineSpace. Requested by ${
latestSubmission?.update_user
} on ${formatDate(updatedDate)}`,
[MINE_REPORT_SUBMISSION_CODES.NON]: `The ministry has requested for the report from the proponent through MineSpace. Requested by ${latestSubmission?.update_user
} on ${formatDate(updatedDate)}`,
[MINE_REPORT_SUBMISSION_CODES.ACC]:
"The Ministry has reviewed the report, no more revision is required",
[MINE_REPORT_SUBMISSION_CODES.REC]:
"Ministry has received changes after requesting for more information. The revised information has not been reviewed.",
[MINE_REPORT_SUBMISSION_CODES.REQ]: `Requesting more information from the proponent through MineSpace. Requested by ${
latestSubmission?.update_user
} on ${formatDate(updatedDate)}`,
[MINE_REPORT_SUBMISSION_CODES.REQ]: `Requesting more information from the proponent through MineSpace. Requested by ${latestSubmission?.update_user
} on ${formatDate(updatedDate)}`,
[MINE_REPORT_SUBMISSION_CODES.INI]: "The report has been submitted successfully",
[MINE_REPORT_SUBMISSION_CODES.WTD]: `The report has been withdrawn. Withdrew by ${
latestSubmission?.update_user
} on ${formatDate(updatedDate)}`,
[MINE_REPORT_SUBMISSION_CODES.WTD]: `The report has been withdrawn. Withdrew by ${latestSubmission?.update_user
} on ${formatDate(updatedDate)}`,
[MINE_REPORT_SUBMISSION_CODES.NRQ]: "This report is not requested",
};
return MINE_REPORT_STATUS_DESCRIPTION_HASH[statusCode] || "";
Expand Down
1 change: 1 addition & 0 deletions services/common/src/tests/mocks/dataMocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3110,6 +3110,7 @@ export const INCIDENT: IMineIncident = {
reported_by_phone_no: "250-360-9494",
reported_timestamp: "2019-07-04 14:05",
reported_to_inspector_party_guid: "c002cc91-555a-4edd-9a9c-fcfee8357b00",
reported_to_inspector_contacted: false,
responsible_inspector_party_guid: "eda69201-b283-44ed-92b9-bcbcb5b83e69",
status_code: "CLD",
mine_name: "Test Mine",
Expand Down
2 changes: 1 addition & 1 deletion services/core-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"react-sortable-hoc": "2.0.0",
"redux": "5.0.0",
"redux-form": "8.2.6",
"redux-form-input-masks": "2.0.1",
"redux-form-input-masks": "2.0.2",
"redux-mock-store": "1.5.4",
"redux-thunk": "3.1.0",
"regenerator-runtime": "0.13.3",
Expand Down
3 changes: 2 additions & 1 deletion services/core-web/src/components/Forms/AddPermitForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import RenderRadioButtons from "@mds/common/components/forms/RenderRadioButtons"
import FormWrapper from "@mds/common/components/forms/FormWrapper";
import RenderSubmitButton from "@mds/common/components/forms/RenderSubmitButton";
import RenderCancelButton from "@mds/common/components/forms/RenderCancelButton";
import { ICreatePermitPayload } from "@mds/common/interfaces";

interface AddPermitFormProps {
onSubmit: (values) => void | Promise<void>;
Expand Down Expand Up @@ -84,7 +85,7 @@ export const AddPermitForm: FC<AddPermitFormProps> = (props) => {
const exemptionFeeStatusDropDownOptions = useSelector(getExemptionFeeStatusDropDownOptions);
const [uploadedFiles, setUploadedFiles] = useState([]);
const formName = FORM.ADD_PERMIT;
const formValues = useSelector(getFormValues(formName));
const formValues = useSelector(getFormValues(formName)) as ICreatePermitPayload;
const { site_properties, permit_type = "", permit_status_code = "", is_exploration = false, security_not_required } = formValues ?? {};
const { mine_tenure_type_code, mine_disturbance_code } = site_properties ?? {};

Expand Down
6 changes: 3 additions & 3 deletions services/core-web/src/components/Forms/EditPermitForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EditPermitForm: FC<EditPermitFormProps> = ({
const dispatch = useDispatch();
const permitStatusOptions = useSelector(getDropdownPermitStatusOptions);
const exemptionFeeStatusDropDownOptions = useSelector(getExemptionFeeStatusDropDownOptions);
const formValues = useSelector(getFormValues(FORM.EDIT_PERMIT)) ?? {};
const formValues = useSelector(getFormValues(FORM.EDIT_PERMIT)) as IPermit;

useEffect(() => {
const isExploration = initialValues.permit_no.charAt(1) === "X";
Expand Down Expand Up @@ -68,8 +68,8 @@ export const EditPermitForm: FC<EditPermitFormProps> = ({
required
validate={[required]}
/>
{(formValues.permit_status_code === "C" ||
formValues.remaining_static_liability !== null) && (
{(formValues?.permit_status_code === "C" ||
formValues?.remaining_static_liability !== null) && (
<Field
id="remaining_static_liability"
name="remaining_static_liability"
Expand Down
31 changes: 15 additions & 16 deletions services/core-web/src/components/Forms/incidents/IncidentForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { FC, useState } from "react";
import { useParams } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { change, formValueSelector, getFormValues } from "@mds/common/components/forms/form";
import { change, getFormValues, isPristine } from "@mds/common/components/forms/form";
import { Col, Row } from "antd";
import { IMineIncident } from "@mds/common/interfaces";
import { getDropdownInspectors } from "@mds/common/redux/selectors/partiesSelectors";
Expand All @@ -27,6 +26,7 @@ import IncidentFormMinistryFollowup from "@/components/Forms/incidents/IncidentF
import { removeDocumentFromMineIncident } from "@mds/common/redux/actionCreators/incidentActionCreator";
import FormWrapper from "@mds/common/components/forms/FormWrapper";
import RenderSubmitButton from "@mds/common/components/forms/RenderSubmitButton";
import { useAppDispatch, useAppSelector } from "@mds/common/redux/rootState";

export const INITIAL_INCIDENT_DOCUMENTS_FORM_FIELD = "initial_incident_documents";
export const FINAL_REPORT_DOCUMENTS_FORM_FIELD = "final_report_documents";
Expand Down Expand Up @@ -56,20 +56,19 @@ export const IncidentForm: FC<IncidentFormProps> = (props) => {
const { isEditMode, handlers: parentHandlers } = props;
const isNewIncident = Boolean(!mineIncidentGuid);

const dispatch = useDispatch();
const dispatch = useAppDispatch();

const incidentDeterminationOptions = useSelector(getDropdownIncidentDeterminationOptions);
const incidentStatusCodeHash = useSelector(getIncidentStatusCodeHash);
const dangerousOccurenceSubparagraphOptions = useSelector(
const incidentDeterminationOptions = useAppSelector(getDropdownIncidentDeterminationOptions);
const incidentStatusCodeHash = useAppSelector(getIncidentStatusCodeHash);
const dangerousOccurenceSubparagraphOptions = useAppSelector(
getDangerousOccurrenceSubparagraphOptions
);
const incidentFollowUpActionOptions = useSelector(getDropdownIncidentFollowupActionOptions);
const inspectorOptions = useSelector(getDropdownInspectors) || [];
const selector = formValueSelector(FORM.ADD_EDIT_INCIDENT);
const documents = useSelector((state) => selector(state, "documents")) || [];
const formValues = useSelector((state) => getFormValues(FORM.ADD_EDIT_INCIDENT)(state)) || {};
const dropdownIncidentStatusCodeOptions = useSelector(getDropdownIncidentStatusCodeOptions);
const isPristine = useSelector((state) => state.form[FORM.ADD_EDIT_INCIDENT]?.pristine);
const incidentFollowUpActionOptions = useAppSelector(getDropdownIncidentFollowupActionOptions);
const inspectorOptions = useAppSelector(getDropdownInspectors) || [];

const formValues = useAppSelector(getFormValues(FORM.ADD_EDIT_INCIDENT)) as Partial<IMineIncident>;
const dropdownIncidentStatusCodeOptions = useAppSelector(getDropdownIncidentStatusCodeOptions);
const pristine = useAppSelector(isPristine(FORM.ADD_EDIT_INCIDENT));

const [uploadedFiles, setUploadedFiles] = useState([]);

Expand Down Expand Up @@ -135,7 +134,7 @@ export const IncidentForm: FC<IncidentFormProps> = (props) => {
incidentStatusCodeHash={incidentStatusCodeHash}
isEditMode={isEditMode}
formValues={formValues}
pristine={isPristine}
pristine={pristine}
/>
</Col>
<Row>
Expand All @@ -148,7 +147,7 @@ export const IncidentForm: FC<IncidentFormProps> = (props) => {
/>
<br />
<IncidentFormDocuments
documents={documents}
documents={formValues?.documents ?? []}
isEditMode={isEditMode}
onFileLoad={onFileLoad}
onDeleteDocument={handleDeleteDocument}
Expand All @@ -164,7 +163,7 @@ export const IncidentForm: FC<IncidentFormProps> = (props) => {
/>
<br />
<IncidentFormInternalDocumentComments
documents={documents}
documents={formValues?.documents ?? []}
incident={props.incident}
isEditMode={isEditMode}
onFileLoad={onFileLoad}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const IncidentFormInitialReport: FC<IncidentFormInitialReportProps> = ({
incident,
inspectorOptions,
}) => {
const formValues = useSelector((state) => getFormValues(ADD_EDIT_INCIDENT)(state));
const formValues = useSelector((state) => getFormValues(ADD_EDIT_INCIDENT)(state)) as IMineIncident;
const showUnspecified = incident.mine_incident_guid && !incident.incident_location;

const locationOptions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
requiredList,
} from "@mds/common/redux/utils/Validate";
import { PlusOutlined } from "@ant-design/icons";
import { IMineIncident } from "@mds/common/interfaces";

interface IncidentFormMinistryFollowupProps {
isEditMode: boolean;
Expand All @@ -33,7 +34,7 @@ const IncidentFormMinistryFollowup: FC<IncidentFormMinistryFollowupProps> = ({
dangerousOccurenceSubparagraphOptions,
inspectorOptions,
}) => {
const formValues = useSelector((state) => getFormValues(ADD_EDIT_INCIDENT)(state));
const formValues = useSelector((state) => getFormValues(ADD_EDIT_INCIDENT)(state)) as IMineIncident;

const filteredFollowUpActions = incidentFollowUpActionOptions.filter(
(act) => act.mine_incident_followup_investigation_type !== INCIDENT_FOLLOWUP_ACTIONS.unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import RenderCheckbox from "@mds/common/components/forms/RenderCheckbox";
import RenderField from "@mds/common/components/forms/RenderField";
import RenderDate from "@mds/common/components/forms/RenderDate";
import RenderFileUpload from "@mds/common/components/forms/RenderFileUpload";
import { IMineDocument } from "@mds/common/interfaces";
import { IMineDocument, INoWDocument } from "@mds/common/interfaces";

export interface EditNoticeOfWorkDocumentFormProps {
onSubmit: (values) => void | Promise<void>;
Expand All @@ -38,7 +38,7 @@ const EditNoticeOfWorkDocumentForm: FC<EditNoticeOfWorkDocumentFormProps> = ({
initialValues,
}) => {
const dispatch = useDispatch();
const formValues = useSelector(getFormValues(FORM.EDIT_NOTICE_OF_WORK_DOCUMENT_FORM)) ?? {};
const formValues = useSelector(getFormValues(FORM.EDIT_NOTICE_OF_WORK_DOCUMENT_FORM)) as INoWDocument ?? { is_final_package: false};
const { is_final_package } = formValues;
const dropdownNoticeOfWorkApplicationDocumentTypeOptions = useSelector(
getDropdownNoticeOfWorkApplicationDocumentTypeOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { resetForm, normalizePhone, upperCase } from "@common/utils/helpers";
import * as FORM from "@/constants/forms";
import { renderConfig } from "@/components/common/config";
import FormWrapper from "@mds/common/components/forms/FormWrapper";
import { IPartyAddress } from "@mds/common/interfaces";

interface AddQuickPartyFormProps {
onSubmit: (values) => void | Promise<void>;
Expand All @@ -26,7 +27,7 @@ const AddQuickPartyForm: FC<AddQuickPartyFormProps> = (props) => {
const dispatch = useDispatch();
const submitting = useSelector(isSubmitting(FORM.ADD_QUICK_PARTY));
const formValues = useSelector(getFormValues(FORM.ADD_QUICK_PARTY));
const { sub_division_code = "", address_type_code = "" } = formValues ?? {};
const { sub_division_code = "", address_type_code = "" } = formValues as IPartyAddress ?? {};

useEffect(() => {
const provinceOption = props.provinceOptions.find((prov) => prov.value === sub_division_code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ReportFilterForm: FC<ReportFilterFormProps> = ({
const {
report_type: selectedMineReportCategory,
report_name: selectedMineReportDefinitionGuid,
} = useSelector(getFormValues(FORM.FILTER_REPORTS)) ?? {};
} = useSelector(getFormValues(FORM.FILTER_REPORTS)) as MineReportParams ?? {};

const updateMineReportDefinitionOptions = (
mineReportDefinitionOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, useState, useEffect } from "react";
import { connect } from "react-redux";
import { ConnectedProps, connect } from "react-redux";
import { bindActionCreators } from "redux";
import { Link, useHistory } from "react-router-dom";
import { Row, Col, Typography, Divider, Skeleton } from "antd";
Expand Down Expand Up @@ -74,7 +74,7 @@ const GlobalMineAlert = ({ alert }) => {
);
};

const HomeMineActivity: FC<HomeMineActivityProps> = ({
const HomeMineActivity: FC<HomeMineActivityProps & PropsFromRedux> = ({
subscribedMines,
subscribedMinesLoaded,
mines,
Expand Down Expand Up @@ -188,4 +188,7 @@ const mapDispatchToProps = (dispatch) =>
dispatch
);

export default connect(mapStateToProps, mapDispatchToProps)(HomeMineActivity);
const connector = connect(mapStateToProps, mapDispatchToProps);
type PropsFromRedux = ConnectedProps<typeof connector>;

export default connector(HomeMineActivity);
Loading
Loading