Story/am 849 toegangscode alleen voor bepaalde schermen zetten - #538
Story/am 849 toegangscode alleen voor bepaalde schermen zetten#538WouterAms wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the access-code gating flow so the access code is enforced only for specific screens (opt-in per screen), instead of always gating an entire module stack.
Changes:
- Introduces a per-screen
accessCodeGateoption viaAppStackNavigationOptions. - Refactors
useAccessCodeGateto support wrapping individualStack.Screenelements with a proxy gate flow. - Applies the per-screen access-code gate to selected Boat Charging screens and updates Parking stack configuration.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/parking/Stack.tsx | Passes screenOptions into useAccessCodeGate configuration for the Parking module. |
| src/modules/boat-charging/Stack.tsx | Wraps Boat Charging stack screens with useAccessCodeGate so gating can be applied per screen. |
| src/modules/boat-charging/screenConfig.ts | Flags specific Boat Charging routes with accessCodeGate: true. |
| src/modules/access-code/types.ts | Adds stack element typing helpers used by the updated gate implementation. |
| src/modules/access-code/screens/ForgotAccessCode.screen.tsx | Adds a fallback Forgot Access Code wrapper screen. |
| src/modules/access-code/routes.ts | Adds forgotAccessCode route to access-code routing types. |
| src/modules/access-code/hooks/useAccessCodeGateState.ts | Introduces centralized access-code gate state derivation. |
| src/modules/access-code/hooks/useAccessCodeGate.tsx | Refactors gating logic to support per-screen protection via proxy screens. |
| src/modules/access-code/constants/forgotAccessCodeScreenConfig.ts | Adds default forgot-code screen configuration constant. |
| src/modules/access-code/constants/accessCodeScreenMap.ts | Centralizes mapping from gate state to stack screen configs. |
| src/modules/access-code/components/AccessCodeGateProxyScreen.tsx | Adds nested navigator that renders access-code flow or protected screen depending on gate state. |
| src/app/navigation/types.ts | Introduces AppStackNavigationOptions and the accessCodeGate option on screen configs. |
Comments suppressed due to low confidence (1)
src/modules/access-code/components/AccessCodeGateProxyScreen.tsx:96
AccessCodeGateStateName.fallbackis a possible state (e.g. whenattemptsLeftbecomes negative), but this navigator renders no screens for it. Rendering a stack navigator with zero screens can crash at runtime; add an explicit fallback screen.
<AccessCodeGateStack.Screen {...ACCESS_CODE_SCREEN_MAP.setup} />
<AccessCodeGateStack.Screen {...ACCESS_CODE_SCREEN_MAP.confirm} />
</AccessCodeGateStack.Group>
)}
</AccessCodeGateStack.Navigator>
|
Als ik bij boot laden inlog krijg ik niet direct de toegangscode aanmaak stappen. Die stappen verschijnen pas wanneer ik naar de laadgeschiedenis navigeer. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 29 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/modules/access-code/hooks/useAccessCodeGate.tsx:113
- When
additionalGateConditionis omitted,meetsAdditionalConditionsbecomesundefined, which makesaccessCodeGate: truescreens not gated. Default the condition totruewhen it’s not provided.
const meetsAdditionalConditions =
typeof additionalGateCondition === 'boolean'
? additionalGateCondition
: additionalGateCondition?.(entry)
if (entry.props.options?.accessCodeGate && meetsAdditionalConditions) {
return (
src/modules/access-code/hooks/useIsInAccessCodeGate.ts:12
- The thrown error message here is not actionable, and the boolean type-check is redundant because the context is typed as
booleanand always defaults tofalseoutside the provider.
if (typeof isInsideGate !== 'boolean') {
throw new Error('Something is wrong here...')
}
…access code gate keeping
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1ccb1a0 to
25489ab
Compare
| onPress={() => | ||
| navigate(ModuleSlug['boat-charging'], { | ||
| screen: BoatChargingRouteName.login, | ||
| params: {shouldNavigateBack: false}, |
There was a problem hiding this comment.
deze mag op true :)
| params: {shouldNavigateBack: false}, | |
| params: {shouldNavigateBack: true}, |
Changes
Test instructions
Other notes
GitHub Copilot was used in writing the code