Skip to content

Commit

Permalink
[MDS-5606] Typescript conversions within Summary and Variance sections (
Browse files Browse the repository at this point in the history
#2808)

* some javascript to typescript conversions for summary and variance sections

* adjustments based on pr comments

* removing vc actionType from pr as Henry's pr contains this already

* scratch the last commit, just adding it back anyways

* adjustment to fix test error

* removing comment

* removing property in permit interface
  • Loading branch information
asinn134 authored Nov 21, 2023
1 parent d23af90 commit 91c257a
Show file tree
Hide file tree
Showing 23 changed files with 999 additions and 881 deletions.
9 changes: 9 additions & 0 deletions services/common/src/interfaces/complianceOrder.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface IComplianceOrder {
overdue: boolean;
due_date: string;
order_no: string;
violation: string;
report_no: number | string;
inspector: string;
order_status: string;
}
3 changes: 3 additions & 0 deletions services/common/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ export * from "./noticeOfWork.interface";
export * from "./noticeOfWorkDraftPermit.interface";
export * from "./search/searchResult.interface";
export * from "./verifiableCredentials";
export * from "./mineComplianceInfo.interface";
export * from "./complianceOrder.interface";
export * from "./variance";
12 changes: 12 additions & 0 deletions services/common/src/interfaces/mineComplianceInfo.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IComplianceOrder } from "./complianceOrder.interface";

export interface IMineComplianceInfo {
advisories: number;
last_inspector: string;
last_inspection: string;
num_open_orders: number;
num_overdue_orders: number;
orders: IComplianceOrder[];
section_35_orders: number;
warnings: number;
}
1 change: 1 addition & 0 deletions services/common/src/interfaces/party/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from "./addRelationshipDocument";
export * from "./createPartyOrgBook.interface";
export * from "./addPartyFormState.interface";
export * from "./mergeParties.interface";
export * from "./partyRelationshipType.interface";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface IPartyRelationshipType {
active_ind: boolean;
description: string;
display_order: number;
grouping_level: number;
mine_party_appt_type_code: string;
organization: boolean;
person: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IAddDocumentToVariancePayload {
document_manager_guid: string;
document_name: string;
variance_document_category_code: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface ICreateVariancePayload {
received_date: string;
compliance_article_id: number;
variance_application_status_code: string;
note?: string;
variance_document_category_code?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface IFetchVariancesPayload {
page: string;
per_page: string;
variance_application_status_code: string;
compliance_codes: string;
major: string;
region: string;
sort_field: string;
sort_dir: string;
issue_date_before: string;
issue_date_after: string;
expiry_date_before: string;
expiry_date_after: string;
}
5 changes: 5 additions & 0 deletions services/common/src/interfaces/variance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./variance.interface";
export * from "./createVariancePayload.interface";
export * from "./varianceDocument.interface";
export * from "./addDocumentToVariancePayload.interface";
export * from "./fetchVariancesPayload.interface";
23 changes: 23 additions & 0 deletions services/common/src/interfaces/variance/variance.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IMineDocument } from "../mineDocument.interface";
import { IVarianceDocument } from "./varianceDocument.interface";

export interface IVariance {
variance_guid: string;
variance_no?: number;
mine_guid?: string;
parties_notified_ind?: boolean;
created_by?: string;
created_timestamp?: string;
updated_by?: string;
updated_timestamp?: string;
variance_document_category_code?: string;
compliance_article_id: number;
variance_application_status_code: string;
applicant_guid: string;
inspector_party_guid: string;
expiry_date: string;
issue_date: string;
note: string;
received_date: string;
documents: Partial<IMineDocument>[] | Partial<IVarianceDocument>[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IMineDocument } from "../mineDocument.interface";

export interface IVarianceDocument extends IMineDocument {
created_at: string;
variance_document_category_code: string;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { notification } from "antd";
import { showLoading, hideLoading } from "react-redux-loading-bar";
import { ENVIRONMENT } from "@mds/common";
import { request, success, error } from "../actions/genericActions";
import { request, success, error, IDispatchError } from "../actions/genericActions";
import * as reducerTypes from "@mds/common/constants/reducerTypes";
import * as Strings from "@mds/common/constants/strings";
import * as varianceActions from "../actions/varianceActions";
import * as API from "@mds/common/constants/API";
import { createRequestHeader } from "../utils/RequestHeaders";
import CustomAxios from "../customAxios";
import { AxiosResponse } from "axios";
import { AppThunk } from "@mds/common/interfaces/appThunk.type";
import {
ICreateVariancePayload,
IVariance,
IAddDocumentToVariancePayload,
IFetchVariancesPayload,
} from "@mds/common";

export const createVariance = ({ mineGuid }, payload) => (dispatch) => {
export const createVariance = (
{ mineGuid },
payload: ICreateVariancePayload
): AppThunk<Promise<AxiosResponse<IVariance>>> => (dispatch): Promise<AxiosResponse<IVariance>> => {
const message =
payload.variance_application_status_code === Strings.VARIANCE_APPLICATION_CODE
? "Successfully applied for a new variance"
Expand All @@ -18,7 +29,7 @@ export const createVariance = ({ mineGuid }, payload) => (dispatch) => {
dispatch(showLoading("modal"));
return CustomAxios()
.post(ENVIRONMENT.apiUrl + API.MINE_VARIANCES(mineGuid), payload, createRequestHeader())
.then((response) => {
.then((response: AxiosResponse<IVariance>) => {
notification.success({ message, duration: 10 });
dispatch(success(reducerTypes.CREATE_MINE_VARIANCE));
return response;
Expand All @@ -30,12 +41,15 @@ export const createVariance = ({ mineGuid }, payload) => (dispatch) => {
.finally(() => dispatch(hideLoading("modal")));
};

export const updateVariance = ({ mineGuid, varianceGuid, codeLabel }, payload) => (dispatch) => {
export const updateVariance = (
{ mineGuid, varianceGuid, codeLabel },
payload: IVariance
): AppThunk<Promise<AxiosResponse<IVariance>>> => (dispatch): Promise<AxiosResponse<IVariance>> => {
dispatch(request(reducerTypes.UPDATE_MINE_VARIANCE));
dispatch(showLoading("modal"));
return CustomAxios()
.put(ENVIRONMENT.apiUrl + API.VARIANCE(mineGuid, varianceGuid), payload, createRequestHeader())
.then((response) => {
.then((response: AxiosResponse<IVariance>) => {
notification.success({
message: `Successfully updated the variance application for: ${codeLabel}`,
duration: 10,
Expand All @@ -50,7 +64,9 @@ export const updateVariance = ({ mineGuid, varianceGuid, codeLabel }, payload) =
.finally(() => dispatch(hideLoading("modal")));
};

export const fetchVariancesByMine = ({ mineGuid }) => (dispatch) => {
export const fetchVariancesByMine = ({ mineGuid }): AppThunk<Promise<void | IDispatchError>> => (
dispatch
) => {
dispatch(request(reducerTypes.GET_VARIANCES));
dispatch(showLoading());
return CustomAxios({ errorToastMessage: Strings.ERROR })
Expand All @@ -63,7 +79,10 @@ export const fetchVariancesByMine = ({ mineGuid }) => (dispatch) => {
.finally(() => dispatch(hideLoading()));
};

export const fetchVarianceById = (mineGuid, varianceGuid) => (dispatch) => {
export const fetchVarianceById = (
mineGuid: string,
varianceGuid: string
): AppThunk<Promise<void | IDispatchError>> => (dispatch) => {
dispatch(request(reducerTypes.GET_VARIANCE));
dispatch(showLoading("modal"));
return CustomAxios({ errorToastMessage: Strings.ERROR })
Expand All @@ -76,7 +95,10 @@ export const fetchVarianceById = (mineGuid, varianceGuid) => (dispatch) => {
.finally(() => dispatch(hideLoading("modal")));
};

export const addDocumentToVariance = ({ mineGuid, varianceGuid }, payload) => (dispatch) => {
export const addDocumentToVariance = (
{ mineGuid, varianceGuid },
payload: IAddDocumentToVariancePayload
): AppThunk<Promise<AxiosResponse<IVariance>>> => (dispatch): Promise<AxiosResponse<IVariance>> => {
dispatch(showLoading("modal"));
dispatch(request(reducerTypes.ADD_DOCUMENT_TO_VARIANCE));
return CustomAxios()
Expand All @@ -85,7 +107,7 @@ export const addDocumentToVariance = ({ mineGuid, varianceGuid }, payload) => (d
payload,
createRequestHeader()
)
.then((response) => {
.then((response: AxiosResponse<IVariance>) => {
dispatch(success(reducerTypes.ADD_DOCUMENT_TO_VARIANCE));
return response;
})
Expand All @@ -96,17 +118,19 @@ export const addDocumentToVariance = ({ mineGuid, varianceGuid }, payload) => (d
.finally(() => dispatch(hideLoading("modal")));
};

export const removeDocumentFromVariance = (mineGuid, varianceGuid, mineDocumentGuid) => (
dispatch
) => {
export const removeDocumentFromVariance = (
mineGuid: string,
varianceGuid: string,
mineDocumentGuid: string
): AppThunk<Promise<AxiosResponse<string>>> => (dispatch): Promise<AxiosResponse<string>> => {
dispatch(showLoading("modal"));
dispatch(request(reducerTypes.REMOVE_DOCUMENT_FROM_VARIANCE));
return CustomAxios()
.delete(
ENVIRONMENT.apiUrl + API.VARIANCE_DOCUMENT(mineGuid, varianceGuid, mineDocumentGuid),
createRequestHeader()
)
.then((response) => {
.then((response: AxiosResponse<string>) => {
dispatch(success(reducerTypes.REMOVE_DOCUMENT_FROM_VARIANCE));
return response;
})
Expand All @@ -117,7 +141,9 @@ export const removeDocumentFromVariance = (mineGuid, varianceGuid, mineDocumentG
.finally(() => dispatch(hideLoading("modal")));
};

export const fetchVariances = (payload) => (dispatch) => {
export const fetchVariances = (
payload: Partial<IFetchVariancesPayload>
): AppThunk<Promise<void | IDispatchError>> => (dispatch) => {
dispatch(request(reducerTypes.GET_VARIANCES));
dispatch(showLoading());
return CustomAxios({ errorToastMessage: Strings.ERROR })
Expand All @@ -130,12 +156,15 @@ export const fetchVariances = (payload) => (dispatch) => {
.finally(() => dispatch(hideLoading()));
};

export const deleteVariance = (mineGuid, varianceGuid) => (dispatch) => {
export const deleteVariance = (
mineGuid: string,
varianceGuid: string
): AppThunk<Promise<AxiosResponse<string>>> => (dispatch): Promise<AxiosResponse<string>> => {
dispatch(request(reducerTypes.DELETE_VARIANCE));
dispatch(showLoading());
return CustomAxios()
.delete(`${ENVIRONMENT.apiUrl}${API.VARIANCE(mineGuid, varianceGuid)}`, createRequestHeader())
.then((response) => {
.then((response: AxiosResponse<string>) => {
notification.success({
message: "Successfully deleted variance.",
duration: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ import * as workInformationActions from "../actions/workInformationActions";
import * as API from "@mds/common/constants/API";
import { createRequestHeader } from "../utils/RequestHeaders";
import CustomAxios from "../customAxios";
import { AxiosResponse } from "axios";
import { AppThunk } from "@mds/common/interfaces/appThunk.type";
import { IMineWorkInformation } from "@mds/common";

export const createMineWorkInformation = (mineGuid, payload) => (dispatch) => {
export const createMineWorkInformation = (
mineGuid: string,
payload: Partial<IMineWorkInformation>
): AppThunk<Promise<AxiosResponse<IMineWorkInformation>>> => (
dispatch
): Promise<AxiosResponse<IMineWorkInformation>> => {
dispatch(request(reducerTypes.CREATE_MINE_WORK_INFORMATION));
dispatch(showLoading("modal"));
return CustomAxios()
Expand All @@ -17,7 +25,7 @@ export const createMineWorkInformation = (mineGuid, payload) => (dispatch) => {
payload,
createRequestHeader()
)
.then((response) => {
.then((response: AxiosResponse<IMineWorkInformation>) => {
notification.success({
message: "Successfully created work information.",
duration: 10,
Expand All @@ -32,12 +40,16 @@ export const createMineWorkInformation = (mineGuid, payload) => (dispatch) => {
.finally(() => dispatch(hideLoading("modal")));
};

export const fetchMineWorkInformations = (mineGuid) => (dispatch) => {
export const fetchMineWorkInformations = (
mineGuid: string
): AppThunk<Promise<AxiosResponse<IMineWorkInformation>>> => (
dispatch
): Promise<AxiosResponse<IMineWorkInformation>> => {
dispatch(request(reducerTypes.GET_MINE_WORK_INFORMATIONS));
dispatch(showLoading());
return CustomAxios()
.get(`${ENVIRONMENT.apiUrl}${API.MINE_WORK_INFORMATIONS(mineGuid)}`, createRequestHeader())
.then((response) => {
.then((response: AxiosResponse<IMineWorkInformation>) => {
dispatch(success(reducerTypes.GET_MINE_WORK_INFORMATIONS));
dispatch(workInformationActions.storeMineWorkInformations(response.data));
return response;
Expand All @@ -49,9 +61,13 @@ export const fetchMineWorkInformations = (mineGuid) => (dispatch) => {
.finally(() => dispatch(hideLoading()));
};

export const updateMineWorkInformation = (mineGuid, mineWorkInformationGuid, payload) => (
export const updateMineWorkInformation = (
mineGuid: string,
mineWorkInformationGuid: string,
payload: Partial<IMineWorkInformation>
): AppThunk<Promise<AxiosResponse<IMineWorkInformation>>> => (
dispatch
) => {
): Promise<AxiosResponse<IMineWorkInformation>> => {
dispatch(request(reducerTypes.UPDATE_MINE_WORK_INFORMATION));
dispatch(showLoading("modal"));
return CustomAxios()
Expand All @@ -60,7 +76,7 @@ export const updateMineWorkInformation = (mineGuid, mineWorkInformationGuid, pay
payload,
createRequestHeader()
)
.then((response) => {
.then((response: AxiosResponse<IMineWorkInformation>) => {
notification.success({
message: "Successfully updated work information.",
duration: 10,
Expand All @@ -75,15 +91,18 @@ export const updateMineWorkInformation = (mineGuid, mineWorkInformationGuid, pay
.finally(() => dispatch(hideLoading("modal")));
};

export const deleteMineWorkInformation = (mineGuid, mineWorkInformationGuid) => (dispatch) => {
export const deleteMineWorkInformation = (
mineGuid: string,
mineWorkInformationGuid: string
): AppThunk<Promise<AxiosResponse<string>>> => (dispatch): Promise<AxiosResponse<string>> => {
dispatch(request(reducerTypes.DELETE_MINE_WORK_INFORMATION));
dispatch(showLoading());
return CustomAxios()
.delete(
`${ENVIRONMENT.apiUrl}${API.MINE_WORK_INFORMATION(mineGuid, mineWorkInformationGuid)}`,
createRequestHeader()
)
.then((response) => {
.then((response: AxiosResponse<string>) => {
notification.success({
message: "Successfully deleted work information.",
duration: 10,
Expand Down
4 changes: 2 additions & 2 deletions services/core-web/src/components/common/CoreTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { FC } from "react";
import React, { FC, ReactNode } from "react";
import { Tooltip } from "antd";
import { COLOR } from "@/constants/styles";
import { WarningOutlined, InfoCircleOutlined, QuestionCircleOutlined } from "@ant-design/icons";

interface CoreTooltipProps {
title: string;
title: string | ReactNode;
iconColor?: string;
icon?: "exclamation" | "question";
}
Expand Down
Loading

0 comments on commit 91c257a

Please sign in to comment.