fix: add validation when creating facility for timezone field per ticket ID 648#1144
Conversation
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR enforces timezone as a required field across the facility management system. The model adds a ChangesTimezone Validation Enforcement
🚥 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 docstrings
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/components/forms/ChangePasswordForm.tsx`:
- Around line 27-31: Wrap the timezone detection in getDefaultTimezone with a
try-catch and defensive checks: call
Intl.DateTimeFormat().resolvedOptions().timeZone inside the try, ensure the
result is a non-empty string, and return it only if allowed.includes(browserTz);
on any exception or invalid value fall back to Timezones.CST. Keep the function
signature and use the existing Timezones and allowed variables
(getDefaultTimezone, Timezones.CST) so behavior is unchanged except for safe
error handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e14522b2-70d5-4980-8676-f960cc707b8a
📒 Files selected for processing (4)
backend/src/database/facilities.gobackend/src/handlers/auth.gobackend/src/models/facilities.gofrontend/src/components/forms/ChangePasswordForm.tsx
CK-7vn
left a comment
There was a problem hiding this comment.
Good work man! If you want to fix the nit, cool, i only even bothered posting it because i figured next junior we get may come across it and be like "Wait a second...", but thats low likelihood anyways.
| const hasNumber = /\d/.test(password); | ||
| const passwordsMatch = password === confirm; | ||
| const isValid = isLengthValid && hasNumber && passwordsMatch; | ||
| const validTimezone = !isFirstLogin || !!timezone; |
There was a problem hiding this comment.
Nit: probably just use timezone here instead of negating the negation, but, its the same thing so really doesn't matter either way.
Pre-Submission PR Checklist
Description of the change
Add timezone validation when creating facilities. Specifically for when adding SuperAdmin to system...it creates an initial facility.