Skip to content
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: 2 additions & 2 deletions frontend/src/common/authentication/PermissionMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const MANAGE_PERMITS = {
/**
* Active Permits tab
*/
VIEW_ACTIVE_PERMITS: {
VIEW_LIST_OF_ACTIVE_PERMITS: {
allowedBCeIDRoles: ALL_BCeID_ROLES,
allowedIDIRRoles: ALL_IDIR_ROLES,
},
Expand Down Expand Up @@ -410,7 +410,7 @@ const GLOBAL_SEARCH = {
AMEND_PERMIT: { allowedIDIRRoles: [PC, SA, CTPO] },
VOID_PERMIT: { allowedIDIRRoles: [SA] },
REVOKE_PERMIT: { allowedIDIRRoles: [SA] },
RESEND: { allowedIDIRRoles: [PC, SA, FIN, CTPO, HQA] },
RESEND_PERMIT: { allowedIDIRRoles: [PC, SA, FIN, CTPO, HQA] },

/** Search for Inactive Permit */
SEARCH_FOR_INACTIVE_PERMIT: { allowedIDIRRoles: [PC, SA, CTPO, EO] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { PermitListItem } from "../../../permits/types/permit";
import { getPermitDataBySearch } from "../api/idirSearch";
import { PermitSearchResultColumnDef } from "../table/PermitSearchResultColumnDef";
import { PERMIT_ACTION_ORIGINS, SearchFields } from "../types/types";
import { IDIRPermitSearchRowActions } from "./IDIRPermitSearchRowActions";
import {
defaultTableInitialStateOptions,
defaultTableOptions,
Expand All @@ -29,6 +28,8 @@ import { ERROR_ROUTES } from "../../../../routes/constants";
import { VEHICLES_URL } from "../../../../common/apiManager/endpoints/endpoints";
import { httpGETRequest } from "../../../../common/apiManager/httpRequestHandler";
import { useSetCompanyHandler } from "../helpers/useSetCompanyHandler";
import { PermitRowOptions } from "../../../permits/components/permit-list/PermitRowOptions";
import { usePermissionMatrix } from "../../../../common/authentication/PermissionMatrix";

/**
* Function to decide whether to show row actions icon or not.
Expand Down Expand Up @@ -148,6 +149,34 @@ export const IDIRPermitSearchResults = memo(
return initialData;
};

const canResendPermit = usePermissionMatrix({
permissionMatrixKeys: {
permissionMatrixFeatureKey: "GLOBAL_SEARCH",
permissionMatrixFunctionKey: "RESEND_PERMIT",
},
});

const canViewPermitReceipt = usePermissionMatrix({
permissionMatrixKeys: {
permissionMatrixFeatureKey: "MANAGE_PERMITS",
permissionMatrixFunctionKey: "VIEW_PERMIT_RECEIPT",
},
});

const canAmendPermit = usePermissionMatrix({
permissionMatrixKeys: {
permissionMatrixFeatureKey: "GLOBAL_SEARCH",
permissionMatrixFunctionKey: "AMEND_PERMIT",
},
});

const canVoidPermit = usePermissionMatrix({
permissionMatrixKeys: {
permissionMatrixFeatureKey: "GLOBAL_SEARCH",
permissionMatrixFunctionKey: "VOID_PERMIT",
},
});

const table = useMaterialReactTable({
...defaultTableOptions,
data: getFilteredData(data?.items ?? []),
Expand Down Expand Up @@ -205,13 +234,18 @@ export const IDIRPermitSearchResults = memo(
if (shouldShowRowActions(idirUserDetails?.userRole)) {
return (
<Box className="idir-search-results__row-actions">
<IDIRPermitSearchRowActions
<PermitRowOptions
isPermitInactive={isInactive}
permitNumber={row.original.permitNumber}
permitId={row.original.permitId}
userRole={idirUserDetails?.userRole}
companyId={row.original.companyId}
permitActionOrigin={PERMIT_ACTION_ORIGINS.GLOBAL_SEARCH}
permissions={{
canAmendPermit,
canResendPermit,
canViewPermitReceipt,
canVoidPermit,
}}
/>
</Box>
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,35 @@ export const PermitLists = React.memo(() => {
});
}

tabs.push(
{
const canViewListOfActivePermits = usePermissionMatrix({
permissionMatrixKeys: {
permissionMatrixFeatureKey: "MANAGE_PERMITS",
permissionMatrixFunctionKey: "VIEW_LIST_OF_ACTIVE_PERMITS",
},
});

if (canViewListOfActivePermits) {
tabs.push({
label: "Active Permits",
component: <ActivePermitList />,
componentKey: PERMIT_TABS.ACTIVE_PERMITS,
});
}

const canViewListOfExpiredPermits = usePermissionMatrix({
permissionMatrixKeys: {
permissionMatrixFeatureKey: "MANAGE_PERMITS",
permissionMatrixFunctionKey: "VIEW_LIST_OF_EXPIRED_PERMITS",
},
{
});

if (canViewListOfExpiredPermits) {
tabs.push({
label: "Expired Permits",
component: <ExpiredPermitList />,
componentKey: PERMIT_TABS.EXPIRED_PERMITS,
},
);
});
}

const { state: stateFromNavigation } = useLocation();

Expand Down
Loading
Loading