Skip to content

Commit

Permalink
ORV-2748 - Voided permits showing as expired in global search (#1636)
Browse files Browse the repository at this point in the history
Co-authored-by: GlenAOT <[email protected]>
  • Loading branch information
glen-aot and glen-aot authored Oct 15, 2024
1 parent 0d6a1c3 commit 8872a39
Showing 1 changed file with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { MRT_ColumnDef } from "material-react-table";

import { CustomActionLink } from "../../../../common/components/links/CustomActionLink";
import { PermitListItem } from "../../../permits/types/permit";
import { PERMIT_EXPIRED } from "../../../permits/types/PermitStatus";
import {
PERMIT_EXPIRED,
PERMIT_STATUSES,
PermitStatus,
} from "../../../permits/types/PermitStatus";
import { PermitChip } from "../../../permits/components/permit-list/PermitChip";
import { viewPermitPdf } from "../../../permits/helpers/permitPDFHelper";
import { hasPermitExpired } from "../../../permits/helpers/permitState";
Expand All @@ -25,25 +29,33 @@ export const PermitSearchResultColumnDef = (
const permit = props.row.original as PermitListItem;
const { permitId, permitStatus, expiryDate, companyId } = permit;

const getDisplayedPermitStatus = (
permitStatus: PermitStatus,
expiryDate: string,
) => {
if (permitStatus === PERMIT_STATUSES.VOIDED) {
return PERMIT_STATUSES.VOIDED;
}

if (hasPermitExpired(expiryDate)) {
return PERMIT_EXPIRED;
}

return permitStatus;
};

return (
<>
<CustomActionLink
onClick={() =>{
viewPermitPdf(
companyId,
permitId,
() => onDocumentUnavailable(),
);
}
}
onClick={() => {
viewPermitPdf(companyId, permitId, () => onDocumentUnavailable());
}}
>
{props.cell.getValue()}
</CustomActionLink>
{hasPermitExpired(expiryDate) ? (
<PermitChip permitStatus={PERMIT_EXPIRED} />
) : (
<PermitChip permitStatus={permitStatus} />
)}
<PermitChip
permitStatus={getDisplayedPermitStatus(permitStatus, expiryDate)}
/>
</>
);
},
Expand All @@ -54,13 +66,13 @@ export const PermitSearchResultColumnDef = (
header: "Permit Type",
enableSorting: true,
sortingFn: "alphanumeric",
Cell: (props: { cell: any; }) => {
const permitTypeName = getPermitTypeName(props.cell.getValue())
return <Tooltip title={permitTypeName}>
<Box>
{props.cell.getValue()}
</Box>
</Tooltip>
Cell: (props: { cell: any }) => {
const permitTypeName = getPermitTypeName(props.cell.getValue());
return (
<Tooltip title={permitTypeName}>
<Box>{props.cell.getValue()}</Box>
</Tooltip>
);
},
size: 20,
},
Expand Down

0 comments on commit 8872a39

Please sign in to comment.