Skip to content

Commit 8284a66

Browse files
glen-aotpraju-aot
andauthored
ORV2-4849 - FE: Update: Only SA can complete an amending permit application that results in a refund (#2108)
Co-authored-by: GlenAOT <160973940+GlenAOT@users.noreply.github.com> Co-authored-by: praju-aot <praveen.raju@aot-technologies.com>
1 parent b1c5b1e commit 8284a66

File tree

5 files changed

+172
-6
lines changed

5 files changed

+172
-6
lines changed

frontend/src/common/authentication/PermissionMatrix.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ const MANAGE_PERMITS = {
138138
allowedBCeIDRoles: ALL_BCeID_ROLES,
139139
allowedIDIRRoles: [PC, SA, CTPO],
140140
},
141+
PROCESS_AMENDMENT_REFUND: {
142+
allowedIDIRRoles: [SA],
143+
},
141144
/**
142145
* Expired Permits tab
143146
*/

frontend/src/features/permits/pages/Amend/components/AmendPermitReview.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import { ApplicationFormData } from "../../../types/application";
3636
import { deserializeApplicationResponse } from "../../../helpers/serialize/deserializeApplication";
3737
import { isAxiosError } from "axios";
3838
import { PERMIT_ACTION_ORIGINS } from "../../../../idir/search/types/types";
39+
import { usePermissionMatrix } from "../../../../../common/authentication/PermissionMatrix";
40+
import { AuthorizationRequiredModal } from "./modal/AuthorizationRequiredModal";
3941

4042
export const AmendPermitReview = () => {
4143
const navigate = useNavigate();
@@ -89,6 +91,21 @@ export const AmendPermitReview = () => {
8991
const [allConfirmed, setAllConfirmed] = useState(false);
9092
const [hasAttemptedSubmission, setHasAttemptedSubmission] = useState(false);
9193

94+
const canProcessAmendmentRefund = usePermissionMatrix({
95+
permissionMatrixKeys: {
96+
permissionMatrixFeatureKey: "MANAGE_PERMITS",
97+
permissionMatrixFunctionKey: "PROCESS_AMENDMENT_REFUND",
98+
},
99+
});
100+
101+
const [showAuthorizationRequiredModal, setShowAuthorizationRequiredModal] =
102+
useState<boolean>(false);
103+
104+
const handleCloseAuthorizationRequiredModal = () => {
105+
setShowAuthorizationRequiredModal(false);
106+
goHome();
107+
};
108+
92109
const onSubmit = async () => {
93110
setHasAttemptedSubmission(true);
94111
if (!allConfirmed) return;
@@ -115,7 +132,12 @@ export const AmendPermitReview = () => {
115132

116133
if (savedApplication) {
117134
setAmendmentApplication(savedApplication);
118-
next();
135+
136+
if (canProcessAmendmentRefund) {
137+
next();
138+
} else {
139+
setShowAuthorizationRequiredModal(true);
140+
}
119141
} else {
120142
navigate(ERROR_ROUTES.UNEXPECTED);
121143
}
@@ -315,6 +337,13 @@ export const AmendPermitReview = () => {
315337
<ReviewReason reason={amendmentApplication.comment} />
316338
) : null}
317339
</PermitReview>
340+
341+
<AuthorizationRequiredModal
342+
isOpen={showAuthorizationRequiredModal}
343+
onCancel={() => setShowAuthorizationRequiredModal(false)}
344+
onConfirm={handleCloseAuthorizationRequiredModal}
345+
permitNumber={permit?.permitNumber}
346+
/>
318347
</div>
319348
);
320349
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
@import "../../../../../../themes/orbcStyles";
2+
3+
.authorization-required-modal {
4+
& &__container {
5+
width: 100%;
6+
display: flex;
7+
flex-direction: column;
8+
}
9+
10+
&__header, &__subheader {
11+
padding: 2rem 1.5rem;
12+
display: flex;
13+
flex-direction: row;
14+
align-items: center;
15+
border-bottom: 1px solid $bc-border-grey;
16+
}
17+
18+
&__header, .header {
19+
background-color: $bc-background-light-grey;
20+
&__text {
21+
font-weight: bold;
22+
font-size: 1.5rem;
23+
margin: 0;
24+
}
25+
}
26+
27+
&__banner {
28+
.bc-gov-alertbanner {
29+
width: auto;
30+
border-radius: 0;
31+
border-top: none;
32+
border-color: $bc-border-grey;
33+
}
34+
}
35+
36+
&__subheader, .subheader {
37+
&__text {
38+
font-weight: bold;
39+
font-size: 1.25rem;
40+
margin: 0;
41+
}
42+
}
43+
44+
&__body {
45+
padding: 1.5rem;
46+
}
47+
48+
&__text {
49+
font-size: 1rem;
50+
}
51+
52+
&__footer {
53+
display: flex;
54+
flex-direction: row;
55+
justify-content: flex-end;
56+
padding: 0 1.5rem 1.5rem 1.5rem;
57+
gap: 1.5rem;
58+
}
59+
60+
&__button {
61+
border: 2px solid $bc-background-light-grey;
62+
box-shadow: none;
63+
64+
&:hover {
65+
background-color: $bc-background-light-grey;
66+
border-color: $bc-text-box-border-grey;
67+
box-shadow: none;
68+
}
69+
}
70+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Button, Dialog } from "@mui/material";
2+
import "./AuthorizationRequiredModal.scss";
3+
import { SuccessBcGovBanner } from "../../../../../../common/components/banners/SuccessBcGovBanner";
4+
import { Nullable } from "../../../../../../common/types/common";
5+
6+
export const AuthorizationRequiredModal = ({
7+
isOpen,
8+
onCancel,
9+
onConfirm,
10+
permitNumber,
11+
}: {
12+
/**
13+
* Boolean to control the open and close state of Dialog box.
14+
*/
15+
isOpen: boolean;
16+
/**
17+
* A callback function on clicking cancel button.
18+
* @returns void
19+
*/
20+
onCancel: () => void;
21+
onConfirm: () => void;
22+
permitNumber: Nullable<string>;
23+
}) => {
24+
return (
25+
<Dialog
26+
open={isOpen}
27+
onClose={onCancel}
28+
className="authorization-required-modal"
29+
PaperProps={{
30+
className: "authorization-required-modal__container",
31+
}}
32+
>
33+
<div className="authorization-required-modal__header header">
34+
<h2 className="header__text">Authorization Required</h2>
35+
</div>
36+
<div className="authorization-required-modal__banner">
37+
<SuccessBcGovBanner
38+
className="authorization-required-modal__banner"
39+
msg="Your changes have been saved"
40+
/>
41+
</div>
42+
<div className="authorization-required-modal__subheader subheader">
43+
<h2 className="subheader__text">Amending Permit #: {permitNumber}</h2>
44+
</div>
45+
46+
<div className="authorization-required-modal__body">
47+
<p className="authorization-required-modal__text">
48+
This amendment results in a refund.
49+
<br></br>
50+
<br></br>
51+
Note the Amending Permit # and inform authorized staff to process the
52+
refund.
53+
</p>
54+
</div>
55+
56+
<div className="authorization-required-modal__footer">
57+
<Button
58+
className="authorization-required-modal__button"
59+
variant="contained"
60+
color="secondary"
61+
onClick={onConfirm}
62+
>
63+
Exit
64+
</Button>
65+
</div>
66+
</Dialog>
67+
);
68+
};

vehicles/src/modules/permit-application-payment/payment/payment.controller.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ export class PaymentController {
9797
type: ReadTransactionDto,
9898
})
9999
@Permissions({
100-
allowedIdirRoles: [
101-
IDIRUserRole.PPC_CLERK,
102-
IDIRUserRole.SYSTEM_ADMINISTRATOR,
103-
IDIRUserRole.CTPO,
104-
],
100+
allowedIdirRoles: [IDIRUserRole.SYSTEM_ADMINISTRATOR],
105101
})
106102
@Post('refund')
107103
async createRefundTransactionDetails(

0 commit comments

Comments
 (0)