-
Notifications
You must be signed in to change notification settings - Fork 538
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
Fix: Same value can be selected multiple times in Questions Components #10288
Fix: Same value can be selected multiple times in Questions Components #10288
Conversation
WalkthroughThe pull request introduces a consistent approach to preventing duplicate entries across three questionnaire question components: AllergyQuestion, DiagnosisQuestion, and SymptomQuestion. In each component, a new conditional check is added to the respective Changes
Assessment against linked issues
Possibly related PRs
Suggested Labels
Suggested Reviewers
Poem
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
CodeRabbit Configuration File (
|
❌ Deploy Preview for care-ohc failed.
|
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 (3)
src/components/Questionnaire/QuestionTypes/SymptomQuestion.tsx (1)
313-313
: LGTM! Consider adding user feedback for duplicate attempts.The duplicate prevention logic is clean and efficient. However, it silently returns when a duplicate is found.
Consider showing a toast notification when attempting to add a duplicate symptom to improve user experience:
- if (symptoms.some((s) => s.code.code === code.code)) return; + if (symptoms.some((s) => s.code.code === code.code)) { + toast({ + title: t("duplicate_symptom"), + description: t("symptom_already_exists"), + variant: "warning", + }); + return; + }src/components/Questionnaire/QuestionTypes/DiagnosisQuestion.tsx (1)
119-119
: LGTM! Consider adding user feedback for duplicate attempts.The duplicate prevention logic is clean and consistent with other components. However, it silently returns when a duplicate is found.
Consider showing a toast notification when attempting to add a duplicate diagnosis to improve user experience:
- if (diagnoses.some((d) => d.code.code === code.code)) return; + if (diagnoses.some((d) => d.code.code === code.code)) { + toast({ + title: t("duplicate_diagnosis"), + description: t("diagnosis_already_exists"), + variant: "warning", + }); + return; + }src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx (1)
149-149
: LGTM! Consider adding user feedback for duplicate attempts.The duplicate prevention logic is clean and consistent with other components. However, it silently returns when a duplicate is found.
Consider showing a toast notification when attempting to add a duplicate allergy to improve user experience:
- if (allergies.some((a) => a.code.code === code.code)) return; + if (allergies.some((a) => a.code.code === code.code)) { + toast({ + title: t("duplicate_allergy"), + description: t("allergy_already_exists"), + variant: "warning", + }); + return; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx
(1 hunks)src/components/Questionnaire/QuestionTypes/DiagnosisQuestion.tsx
(1 hunks)src/components/Questionnaire/QuestionTypes/SymptomQuestion.tsx
(1 hunks)
🔇 Additional comments (1)
src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx (1)
Line range hint
313-313
: Verify implementation consistency across components.The duplicate prevention logic has been consistently implemented across all three components (Symptom, Diagnosis, and Allergy).
Let's verify the consistency of the implementation:
Also applies to: 119-119, 149-149
✅ Verification successful
Implementation consistency verified across components
The duplicate prevention logic is implemented consistently in all three components (Symptom, Allergy, and Diagnosis) using the same pattern and structure.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all three components implement the same duplicate prevention pattern # Test: Search for the duplicate prevention pattern in all components echo "Checking duplicate prevention pattern in all components..." rg -U 'if \((symptoms|diagnoses|allergies)\.some\(\([a-z]\) => \1\.code\.code === code\.code\)\) return;' # Test: Ensure no other duplicate prevention patterns exist echo "Checking for any other duplicate prevention patterns..." rg -U 'code\.code === code\.code'Length of output: 1362
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit