Skip to content

Commit

Permalink
Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
RoanPaulus committed Dec 13, 2024
1 parent 341f38f commit 07c7e9f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/server/services/parkeren/parkeren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export async function fetchParkeren(
authProfileAndToken: AuthProfileAndToken
) {
const brpData = await fetchBRP(requestID, authProfileAndToken);
const livesInAmsterdam = isMokum(brpData?.content);
const isCommercial = authProfileAndToken.profile.profileType === 'commercial';

let isKnown = false;
if (!FeatureToggle.parkerenCheckForProductAndPermitsActive) {
isKnown = true;
} else if (isCommercial) {
isKnown = true;
} else if (livesInAmsterdam) {
isKnown = true;
} else {
const livesOutsideAmsterdam = !isMokum(brpData?.content);
const isDigidUser = authProfileAndToken.profile.profileType === 'private';

const shouldCheckForPermitsOrPermitRequests =
isDigidUser &&
livesOutsideAmsterdam &&
FeatureToggle.parkerenCheckForProductAndPermitsActive;

let isKnown = true;

if (shouldCheckForPermitsOrPermitRequests) {
isKnown = await hasPermitsOrPermitRequests(requestID, authProfileAndToken);
}

Expand Down Expand Up @@ -80,6 +80,9 @@ async function fetchJWEToken(

/**
* This function checks whether the user has a parkeren products or permit requests (Vergunning aanvragen).
*
* We always return true when something goes wrong as to not deny the user a -
* potentially useful tile in the frontend.
*/
async function hasPermitsOrPermitRequests(
requestID: RequestID,
Expand Down

0 comments on commit 07c7e9f

Please sign in to comment.