Skip to content

Commit 6e21bb1

Browse files
authoredJan 6, 2025··
ORV2-3166 Staff payment options behind feature flag (#1727)
1 parent 5303226 commit 6e21bb1

File tree

5 files changed

+66
-7
lines changed

5 files changed

+66
-7
lines changed
 

‎database/mssql/scripts/sampledata/dbo.ORBC_FEATURE_FLAG.Table.sql

+23
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,29 @@ VALUES
257257
GETUTCDATE()
258258
);
259259

260+
INSERT INTO
261+
[dbo].[ORBC_FEATURE_FLAG] (
262+
[FEATURE_ID],
263+
[FEATURE_KEY],
264+
[FEATURE_VALUE],
265+
[CONCURRENCY_CONTROL_NUMBER],
266+
[DB_CREATE_USERID],
267+
[DB_CREATE_TIMESTAMP],
268+
[DB_LAST_UPDATE_USERID],
269+
[DB_LAST_UPDATE_TIMESTAMP]
270+
)
271+
VALUES
272+
(
273+
'12',
274+
'STAFF-CAN-PAY',
275+
'DISABLED',
276+
NULL,
277+
N'dbo',
278+
GETUTCDATE(),
279+
N'dbo',
280+
GETUTCDATE()
281+
);
282+
260283
SET
261284
IDENTITY_INSERT [dbo].[ORBC_FEATURE_FLAG] OFF
262285
GO

‎frontend/src/features/permits/pages/Application/components/pay/ChoosePaymentMethod.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
DEFAULT_EMPTY_CARD_TYPE,
1010
DEFAULT_EMPTY_PAYMENT_TYPE,
1111
} from "./types/PaymentMethodData";
12+
import { useFeatureFlagsQuery } from "../../../../../../common/hooks/hooks";
1213

1314
export const ChoosePaymentMethod = ({
1415
availablePaymentMethods,
@@ -19,6 +20,7 @@ export const ChoosePaymentMethod = ({
1920
}) => {
2021
const { control, watch, setValue, clearErrors } = useFormContext();
2122
const currPaymentMethod = watch("paymentMethod");
23+
const { data: featureFlags } = useFeatureFlagsQuery();
2224

2325
const handlePaymentMethodChange = (
2426
selectedPaymentMethod: PaymentMethodTypeCode,
@@ -71,8 +73,8 @@ export const ChoosePaymentMethod = ({
7173
handlePaymentMethodChange={handlePaymentMethodChange}
7274
/>
7375
))}
74-
75-
{showPayInPersonInfo ? (
76+
{showPayInPersonInfo &&
77+
featureFlags?.["STAFF-CAN-PAY"] === "ENABLED" ? (
7678
<CVPayInPersonInfo />
7779
) : null}
7880
</RadioGroup>

‎frontend/src/features/permits/pages/Application/components/pay/PermitPayFeeSummary.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { useEffect, useState } from "react";
1+
import { useContext, useEffect, useState } from "react";
22
import { Box, Button } from "@mui/material";
33

44
import "./PermitPayFeeSummary.scss";
55
import { PermitType } from "../../../../types/PermitType";
66
import { FeeSummary } from "../../../../components/feeSummary/FeeSummary";
7+
import OnRouteBCContext from "../../../../../../common/authentication/OnRouteBCContext";
8+
import { useFeatureFlagsQuery } from "../../../../../../common/hooks/hooks";
79

810
export const PermitPayFeeSummary = ({
911
calculatedFee,
@@ -20,6 +22,9 @@ export const PermitPayFeeSummary = ({
2022
}) => {
2123
const [showTooltip, setShowTooltip] = useState<boolean>(false);
2224
const disablePay = selectedItemsCount === 0;
25+
const { idirUserDetails } = useContext(OnRouteBCContext);
26+
const isStaffActingAsCompany = Boolean(idirUserDetails?.userRole);
27+
const { data: featureFlags } = useFeatureFlagsQuery();
2328

2429
const handlePayNow = () => {
2530
if (disablePay) {
@@ -57,7 +62,11 @@ export const PermitPayFeeSummary = ({
5762
className="permit-pay-fee-summary__btn"
5863
variant="contained"
5964
onClick={handlePayNow}
60-
disabled={transactionPending}
65+
disabled={
66+
transactionPending ||
67+
(isStaffActingAsCompany &&
68+
featureFlags?.["STAFF-CAN-PAY"] !== "ENABLED")
69+
}
6170
>
6271
Pay Now
6372
</Button>

‎frontend/src/features/permits/pages/ShoppingCart/ShoppingCartPage.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
TOLL_FREE_NUMBER,
5454
PPC_EMAIL,
5555
} from "../../../../common/constants/constants";
56+
import { useFeatureFlagsQuery } from "../../../../common/hooks/hooks";
5657

5758
const AVAILABLE_STAFF_PAYMENT_METHODS = [
5859
PAYMENT_METHOD_TYPE_CODE.ICEPAY,
@@ -66,7 +67,11 @@ const AVAILABLE_CV_PAYMENT_METHODS = [PAYMENT_METHOD_TYPE_CODE.WEB];
6667
export const ShoppingCartPage = () => {
6768
const navigate = useNavigate();
6869
const { idirUserDetails, userDetails } = useContext(OnRouteBCContext);
69-
const companyId: number = applyWhenNotNullable(id => Number(id), getCompanyIdFromSession(), 0);
70+
const companyId: number = applyWhenNotNullable(
71+
(id) => Number(id),
72+
getCompanyIdFromSession(),
73+
0,
74+
);
7075
const isStaffActingAsCompany = Boolean(idirUserDetails?.userRole);
7176
const isCompanyAdmin = Boolean(
7277
userDetails?.userRole === BCeID_USER_ROLE.COMPANY_ADMINISTRATOR,
@@ -116,6 +121,7 @@ export const ShoppingCartPage = () => {
116121
useStartTransaction();
117122

118123
const { mutation: issuePermitMutation, issueResults } = useIssuePermits();
124+
const { data: featureFlags } = useFeatureFlagsQuery();
119125

120126
const availablePaymentMethods = isStaffActingAsCompany
121127
? AVAILABLE_STAFF_PAYMENT_METHODS
@@ -405,7 +411,10 @@ export const ShoppingCartPage = () => {
405411

406412
<Box className="shopping-cart-page__right-container">
407413
<FormProvider {...formMethods}>
408-
{!isFeeZero ? (
414+
{!isFeeZero &&
415+
((isStaffActingAsCompany &&
416+
featureFlags?.["STAFF-CAN-PAY"] === "ENABLED") ||
417+
!isStaffActingAsCompany) ? (
409418
<ChoosePaymentMethod
410419
availablePaymentMethods={availablePaymentMethods}
411420
showPayInPersonInfo={!isStaffActingAsCompany}

‎vehicles/src/modules/permit-application-payment/payment/payment.service.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ import { isCfsPaymentMethodType } from 'src/common/helper/payment.helper';
5151
import { CACHE_MANAGER } from '@nestjs/cache-manager';
5252
import { Cache } from 'cache-manager';
5353
import { CacheKey } from 'src/common/enum/cache-key.enum';
54-
import { getFromCache } from '../../../common/helper/cache.helper';
54+
import {
55+
getFromCache,
56+
getMapFromCache,
57+
} from '../../../common/helper/cache.helper';
5558
import { doesUserHaveRole } from '../../../common/helper/auth.helper';
5659
import { IDIR_USER_ROLE_LIST } from '../../../common/enum/user-role.enum';
5760
import {
@@ -63,6 +66,7 @@ import {
6366
isFeatureEnabled,
6467
} from '../../../common/helper/common.helper';
6568
import { TIMEZONE_PACIFIC } from 'src/common/constants/api.constant';
69+
import { FeatureFlagValue } from '../../../common/enum/feature-flag-value.enum';
6670
import { PermitData } from 'src/common/interface/permit.template.interface';
6771
import { isValidLoa } from 'src/common/helper/validate-loa.helper';
6872
import { PermitHistoryDto } from '../permit/dto/response/permit-history.dto';
@@ -266,6 +270,18 @@ export class PaymentService {
266270
createTransactionDto: CreateTransactionDto,
267271
nestedQueryRunner?: QueryRunner,
268272
): Promise<ReadTransactionDto> {
273+
const featureFlags = await getMapFromCache(
274+
this.cacheManager,
275+
CacheKey.FEATURE_FLAG_TYPE,
276+
);
277+
if (
278+
doesUserHaveRole(currentUser.orbcUserRole, IDIR_USER_ROLE_LIST) &&
279+
featureFlags?.['STAFF-CAN-PAY'] &&
280+
(featureFlags['STAFF-CAN-PAY'] as FeatureFlagValue) !==
281+
FeatureFlagValue.ENABLED
282+
) {
283+
throwUnprocessableEntityException('Disabled feature');
284+
}
269285
if (
270286
!doesUserHaveRole(currentUser.orbcUserRole, IDIR_USER_ROLE_LIST) &&
271287
createTransactionDto?.paymentMethodTypeCode !==

0 commit comments

Comments
 (0)
Please sign in to comment.