Skip to content

Commit

Permalink
MDS-5350_Fix-type-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
simensma-fresh committed Oct 20, 2023
1 parent 3b892b4 commit b23e9c4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IMineDocument } from "./mineDocument.interface";

export interface IExplosivesPermitMagazine {
explosives_permit_magazine_id: number;
explosives_permit_id: number;
Expand All @@ -16,10 +18,9 @@ export interface IExplosivesPermitMagazine {
detonator_type: string;
}

export interface IExplosivesPermitDocument {
export interface IExplosivesPermitDocument extends IMineDocument {
explosives_permit_id: number;
explosives_permit_document_type_code: string;
document_manager_guid: string;
}

export interface IExplosivesPermit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const ExplosivesPermitDiffModal: FC<ExplosivesPermitDiffModalProps> = ({
const [differences, setDifferences] = useState<IPermitDifferencesByAmendment>({});

const getPermitDifferences = (permit: IExplosivesPermit): IPermitDifferencesByAmendment => {
const permitVersions = [permit, ...permit.explosives_permit_amendments].sort(
const comparablePermit = {
explosives_permit_amendment_id: undefined,
...permit,
};

const permitVersions = [comparablePermit, ...permit.explosives_permit_amendments].sort(
(a, b) => a.explosives_permit_amendment_id - b.explosives_permit_amendment_id
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@ant-design/compatible/assets/index.css";

import { Alert, Button, Col, Row, Table, Typography } from "antd";
import { IExplosivesPermit, IMine } from "@mds/common";
import { IExplosivesPermit, IExplosivesPermitAmendment, IMine } from "@mds/common";
import React, { FC, useEffect, useState } from "react";
import { connect } from "react-redux";
import ExplosivesPermitMap from "@/components/maps/ExplosivesPermitMap";
Expand Down Expand Up @@ -75,6 +75,12 @@ interface ExplosivesPermitViewModalProps {
openDocument: (document_manager_guid: string, mine_document_guid: string) => void;
}

const permitAmendmentLike = (permit: IExplosivesPermit): IExplosivesPermitAmendment => ({
explosives_permit_amendment_id: undefined,
explosives_permit_amendment_guid: undefined,
...permit,
});

export const ExplosivesPermitViewModal: FC<ExplosivesPermitViewModalProps> = (props) => {
const { explosivesPermit, parentPermit, mine, title } = props;
const amendmentsCount = parentPermit?.explosives_permit_amendments?.length || 0;
Expand Down Expand Up @@ -114,9 +120,12 @@ export const ExplosivesPermitViewModal: FC<ExplosivesPermitViewModalProps> = (pr
key: "action",
render: (text, record) => {
const recordGuid = record.explosives_permit_guid || record.explosives_permit_amendment_guid;

const currentPermitAsAmendment = permitAmendmentLike(currentPermit);

if (
recordGuid === currentPermit?.explosives_permit_guid ||
recordGuid === currentPermit?.explosives_permit_amendment_guid
recordGuid === currentPermitAsAmendment?.explosives_permit_guid ||
recordGuid === currentPermitAsAmendment?.explosives_permit_amendment_guid
)
return null;
return (
Expand Down Expand Up @@ -147,7 +156,7 @@ export const ExplosivesPermitViewModal: FC<ExplosivesPermitViewModalProps> = (pr
};
});
permitHistory.unshift({
...parentPermit,
...permitAmendmentLike(parentPermit),
issue_date: parentPermit.issue_date,
expiry_date: parentPermit.expiry_date,
is_closed: parentPermit.is_closed ? "Closed" : "Open",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const ExplosivesPermitDiffModal: FC<ExplosivesPermitDiffModalProps> = ({
const [differences, setDifferences] = useState<IPermitDifferencesByAmendment>({});

const getPermitDifferences = (permit: IExplosivesPermit): IPermitDifferencesByAmendment => {
const permitVersions = [permit, ...permit.explosives_permit_amendments].sort(
const comparablePermit = {
explosives_permit_amendment_id: undefined,
...permit,
};

const permitVersions = [comparablePermit, ...permit.explosives_permit_amendments].sort(
(a, b) => a.explosives_permit_amendment_id - b.explosives_permit_amendment_id
);

Expand Down

0 comments on commit b23e9c4

Please sign in to comment.