feat: conditionally render team selection based on user sign-in status#8668
feat: conditionally render team selection based on user sign-in status#8668thomastayler wants to merge 1 commit intomainfrom
Conversation
- Updated LanguageScreen component to display team selection prompts only when the user is signed in. - Ensured that both desktop and mobile views show the appropriate team selection text based on the sign-in state.
WalkthroughConditional rendering logic is added to hide team selection UI elements when a user is not signed in. Typography labels and the JourneyCustomizeTeamSelect component now display exclusively for authenticated users. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit c27688c
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
apps/journeys-admin/src/components/TemplateCustomization/MultiStepForm/Screens/LanguageScreen/LanguageScreen.tsx (2)
96-98:⚠️ Potential issue | 🟠 MajorValidation schema requires
teamSelecteven when hidden.The
validationSchemarequiresteamSelectto be a non-empty string, but whenisSignedInis false, the team selection field is not rendered. This could prevent form submission for non-authenticated users if the initial value is empty.Consider making the validation conditional:
🔧 Suggested fix
- const validationSchema = object({ - teamSelect: string().required() - }) + const validationSchema = object({ + teamSelect: isSignedIn ? string().required() : string() + })
113-149:⚠️ Potential issue | 🟠 MajorLoading state not reset when user is not signed in.
If
isSignedInis false butjourneyis not null,setLoading(true)is called on line 114 but never reset to false, leaving the "Next" button permanently disabled.🐛 Suggested fix
async function handleSubmit(values: FormikValues) { setLoading(true) if (journey == null) { setLoading(false) return } if (isSignedIn) { // ... existing logic } + setLoading(false) }Alternatively, if non-signed-in users should not reach this flow, consider adding an early return or handling this case explicitly.
🧹 Nitpick comments (1)
apps/journeys-admin/src/components/TemplateCustomization/MultiStepForm/Screens/LanguageScreen/LanguageScreen.tsx (1)
219-237: Consolidate repeated conditional checks into a single block.The two separate
{isSignedIn && ...}blocks can be combined into a single conditional with a fragment, reducing duplication and improving readability.♻️ Suggested refactor
- {isSignedIn && ( - <Typography - variant="h6" - display={{ xs: 'none', sm: 'block' }} - sx={{ mt: 4 }} - > - {t('Select a team')} - </Typography> - )} - {isSignedIn && ( - <Typography - variant="body2" - display={{ xs: 'block', sm: 'none' }} - sx={{ mt: 4 }} - > - {t('Select a team')} - </Typography> - )} - {isSignedIn && <JourneyCustomizeTeamSelect />} + {isSignedIn && ( + <> + <Typography + variant="h6" + display={{ xs: 'none', sm: 'block' }} + sx={{ mt: 4 }} + > + {t('Select a team')} + </Typography> + <Typography + variant="body2" + display={{ xs: 'block', sm: 'none' }} + sx={{ mt: 4 }} + > + {t('Select a team')} + </Typography> + <JourneyCustomizeTeamSelect /> + </> + )}
|
The latest updates on your projects.
|
| > | ||
| {t('Select a team')} | ||
| </Typography> | ||
| {isSignedIn && ( |
There was a problem hiding this comment.
Just combine these so the isSignedIn comparison is only called once instead of 3 times. You will probably need to wrap it in a fragment
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.