Skip to content

Commit 7e82642

Browse files
zgong-govcberg-aotkrishnan-aot
authored
Hotfix: Prevent cart count query if user details not present in OnRouteBCContext (#1798)
Co-authored-by: Chris Berg <[email protected]> Co-authored-by: Krishnan Subramanian <[email protected]>
1 parent e199376 commit 7e82642

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
id: release-name
3333
run: |
3434
echo release-name=$(curl https://api.github.com/repos/bcgov/onroutebc/releases/latest | jq -r .tag_name) >> $GITHUB_OUTPUT
35-
echo release-num=V$(curl https://api.github.com/repos/bcgov/onroutebc/releases/latest | jq -r .tag_name | sed 's/[^0-9]//g') >> $GITHUB_OUTPUT
35+
echo release-num=V$(curl https://api.github.com/repos/bcgov/onroutebc/releases/latest | jq -r .tag_name | sed 's/[^0-9.]//g') >> $GITHUB_OUTPUT
3636
promote-images-release:
3737
name: Promote Images - Release
3838
needs: [vars]

frontend/src/common/authentication/auth-walls/NewBCeIDAuthWall.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IDPS } from "../../types/idp";
77
import { LoadBCeIDUserContext } from "../LoadBCeIDUserContext";
88
import OnRouteBCContext from "../OnRouteBCContext";
99

10-
const isBCeID = (identityProvider: string) => identityProvider === IDPS.BCEID;
10+
const isBCeID = (identityProvider: string) => identityProvider === IDPS.BUSINESS_BCEID;
1111

1212
/**
1313
* This component ensures that a page is only available to new BCeID users.

frontend/src/features/permits/context/CartContextProvider.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ export const CartContextProvider = ({
1010
}: {
1111
children?: React.ReactNode;
1212
}) => {
13-
const { companyId } = useContext(OnRouteBCContext);
13+
const { companyId, userDetails, idirUserDetails } = useContext(OnRouteBCContext);
14+
const doesUserDetailsExist = Boolean(userDetails) || Boolean(idirUserDetails);
1415

1516
// Set cart count for company
1617
const cartCountQuery = useGetCartCount(
1718
getDefaultRequiredVal(0, companyId),
19+
doesUserDetailsExist,
1820
);
1921

2022
const { data: fetchedCartCount } = cartCountQuery;

frontend/src/features/permits/hooks/cart.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,17 @@ export const useRemoveFromCart = () => {
8080
/**
8181
* Hook used to get the number of items in the cart.
8282
* @param companyId id of company to get cart item count for
83+
* @param doesUserDetailsExist Does the user details exist in the OnRouteBCContext
8384
* @returns Query object used for getting cart item count
8485
*/
85-
export const useGetCartCount = (companyId: number) => {
86+
export const useGetCartCount = (
87+
companyId: number,
88+
doesUserDetailsExist: boolean,
89+
) => {
8690
return useQuery({
8791
queryKey: [CART_COUNT_KEY, companyId],
8892
queryFn: () => getCartCount(companyId),
89-
enabled: Boolean(companyId),
93+
enabled: Boolean(companyId) && doesUserDetailsExist,
9094
retry: false,
9195
refetchOnMount: "always",
9296
refetchOnWindowFocus: false,

0 commit comments

Comments
 (0)