-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(web): WHODAS - Allow for overwriting question text in CMS #17838
base: main
Are you sure you want to change the base?
feat(web): WHODAS - Allow for overwriting question text in CMS #17838
Conversation
WalkthroughThe changes introduce an optional Changes
Sequence Diagram(s)sequenceDiagram
participant WF as WHODASForm
participant AO as AnswerOption
participant FM as formatMessage
WF->>AO: Check if "text" property exists
alt Text is provided
AO-->>WF: Return text value
else Text is not provided
WF->>FM: Retrieve label via formatMessage
FM-->>WF: Return formatted label
end
WF->>WF: Render radio button with label
Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
View your CI Pipeline Execution ↗ for commit 5deb90e.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/components/connected/WHODAS/Calculator.tsx (1)
93-99
: Consider extracting label generation logic.The label generation logic could be extracted into a separate function for better maintainability and reusability.
+const getAnswerLabel = ( + option: { text?: string; score: number }, + answerIndex: number, + formatMessage: IntlFormatters['formatMessage'] +) => { + return ( + (option.text?.trim() || '') || + formatMessage( + m.answerLabel[String(answerIndex) as keyof typeof m.answerLabel] + ) + ) +} - const label = - option.text || - formatMessage( - m.answerLabel[ - String(answerIndex) as keyof typeof m.answerLabel - ], - ) + const label = getAnswerLabel(option, answerIndex, formatMessage)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/components/connected/WHODAS/Calculator.tsx
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`apps/**/*`: "Confirm that the code adheres to the following...
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/web/components/connected/WHODAS/Calculator.tsx
🔇 Additional comments (2)
apps/web/components/connected/WHODAS/Calculator.tsx (2)
34-40
: LGTM! Type-safe implementation of the text override feature.The optional
text
property is correctly typed and aligns with TypeScript best practices.
93-99
: Consider adding validation for empty text.While the implementation is correct, consider adding validation to handle empty strings in the
text
property to ensure consistent label display.- const label = - option.text || - formatMessage( - m.answerLabel[ - String(answerIndex) as keyof typeof m.answerLabel - ], - ) + const label = + (option.text?.trim() || '') || + formatMessage( + m.answerLabel[ + String(answerIndex) as keyof typeof m.answerLabel + ], + )✅ Verification successful
Error: No shell scripts or web queries found
Enhance Label Validation for Consistent UI Behavior
- The current logic returns
option.text
without checking for empty or whitespace strings, which may lead to unwanted UI behavior.- Using a trimmed check (e.g.,
option.text?.trim()
) ensures that even strings containing only spaces fall back to the formatted default fromm.answerLabel
.- Consider extracting this label-generation logic into a separate function for improved maintainability and reusability.
WHODAS - Allow for overwriting question text in CMS
Checklist:
Summary by CodeRabbit