-
Notifications
You must be signed in to change notification settings - Fork 514
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
Fixes UI Bug Issue in Symptom Editor #9270
Fixes UI Bug Issue in Symptom Editor #9270
Conversation
WalkthroughThe pull request introduces several modifications across multiple components, primarily focusing on enhancing the user interface and accessibility. The Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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: 2
🧹 Outside diff range and nitpick comments (4)
src/components/Form/FormFields/DateFormField.tsx (2)
40-43
: LGTM! The styling changes address the UI alignment issues.The addition of margin and text ellipsis classes aligns with the PR objectives to fix the UI bugs in the date input field.
Consider these improvements:
- Use a CSS variable for the margin to make it configurable:
-"mr-9 text-ellipsis" +"mr-[var(--date-input-margin,2.25rem)] text-ellipsis"
- Add a comment explaining the purpose of these specific classes for future maintainability:
className={classNames( field.error && "border-red-500", - "mr-9 text-ellipsis", + // Right margin for dropdown icon alignment, ellipsis for overflow handling + "mr-[var(--date-input-margin,2.25rem)] text-ellipsis", )}
Line range hint
39-58
: Consider forwarding the title prop for accessibility.The AI summary mentions that
DateInputV2
now supports atitle
property for accessibility, but it's not being passed through fromDateFormField
. Consider adding this capability to improve accessibility.Add the title prop to the Props type and forward it:
type Props = FormFieldBaseProps<Date> & { containerClassName?: string; placeholder?: string; max?: Date; min?: Date; disableFuture?: boolean; disablePast?: boolean; allowTime?: boolean; popOverClassName?: string; + title?: string; // For accessibility tooltip }; // In the component render <DateInputV2 // ... other props + title={props.title} />src/components/Symptoms/SymptomsBuilder.tsx (2)
201-208
: Remove redundant block statements to simplify the codeThe block statements around the conditional expression in lines 201-208 are unnecessary and can be safely removed to simplify the code, as indicated by static analysis tools.
Apply this diff to remove the redundant block:
- { "id" in item ? setItem({ onset_date: dateQueryString(value), id: item.id, }) : setItem({ ...item, onset_date: dateQueryString(value) }); - } + "id" in item + ? setItem({ + onset_date: dateQueryString(value), + id: item.id, + }) + : setItem({ ...item, onset_date: dateQueryString(value) });🧰 Tools
🪛 Biome (1.9.4)
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
225-235
: Remove redundant block statements to simplify the codeSimilarly, the block statements in lines 225-235 are unnecessary and can be removed to clean up the code.
Apply this diff:
- { "id" in item ? setItem({ cure_date: dateQueryString(value), id: item.id, }) : setItem({ ...(item as EncounterSymptom), cure_date: dateQueryString(value), }); - } + "id" in item + ? setItem({ + cure_date: dateQueryString(value), + id: item.id, + }) + : setItem({ + ...(item as EncounterSymptom), + cure_date: dateQueryString(value), + });🧰 Tools
🪛 Biome (1.9.4)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (6)
src/components/Common/DateInputV2.tsx
(1 hunks)src/components/Form/FormFields/AutocompleteMultiselect.tsx
(1 hunks)src/components/Form/FormFields/DateFormField.tsx
(1 hunks)src/components/Form/ModelCrudEditor.tsx
(2 hunks)src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)src/components/Symptoms/types.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/components/Common/DateInputV2.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (2)
src/components/Form/ModelCrudEditor.tsx (1)
Line range hint 103-124
: LGTM
The adjustments to the layout enhance the component's responsiveness without affecting functionality.
src/components/Form/FormFields/AutocompleteMultiselect.tsx (1)
174-185
: Improve alignment and positioning of the dropdown icon
The modifications to the ComboboxButton
and associated classes enhance the visual alignment of the dropdown icon, providing a better user experience.
…issues/8998/symptoms-editor-fix
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
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
🧹 Outside diff range and nitpick comments (3)
src/components/Symptoms/SymptomsBuilder.tsx (3)
101-138
: Enhance error handling in createSymptom functionThe function should handle API errors more gracefully and provide more specific success messages.
Consider applying these improvements:
const createSymptom = async (body: EncounterSymptomRequest) => { if (Array.isArray(body.symptom)) { const { symptom, onset_date, other_symptom } = body; const objects = symptom.map((symptom: EncounterSymptom["symptom"]) => ({ symptom, onset_date: dateQueryString(onset_date), other_symptom: symptom === OTHER_SYMPTOM_CHOICE.id ? other_symptom : undefined, })); if (consultationId) { try { const responses = await Promise.all( objects.map((body) => request(SymptomsApi.add, { body, pathParams: { consultationId: consultationId! }, }), ), ); if (responses.every(({ res }) => !!res?.ok)) { - Success({ msg: "Symptoms records updated successfully" }); + Success({ msg: `Successfully added ${objects.length} symptom(s)` }); } else { + throw new Error("Failed to add some symptoms"); } } catch (error) { + console.error("Failed to create symptoms:", error); + throw error; } } } else { try { const { res } = await request(SymptomsApi.add, { pathParams: { consultationId }, body, }); if (res?.ok) { - Success({ msg: "Symptom added successfully" }); + Success({ msg: `Successfully added ${SYMPTOM_CHOICES.find(s => s.id === body.symptom)?.text || 'symptom'}` }); } else { + throw new Error("Failed to add symptom"); } } catch (error) { + console.error("Failed to create symptom:", error); + throw error; } } refetch(); };
183-185
: Review the debounce delay durationThe current debounce delay of 5000ms (5 seconds) seems excessive and might affect user experience.
Consider reducing the delay:
const debouncedSetItem = debounce((value: string) => { setItem({ other_symptom: value, symptom: item.symptom }); -}, 5000); +}, 1000);
199-209
: Remove redundant block statementThe block statement is unnecessary and can be simplified.
Apply this change:
if (!dayjs(onsetDate).isSame(dayjs(value), "second")) { setOnsetDate(value); - { - "id" in item - ? setItem({ - onset_date: dateQueryString(value), - id: item.id, - }) - : setItem({ ...item, onset_date: dateQueryString(value) }); - } + "id" in item + ? setItem({ + onset_date: dateQueryString(value), + id: item.id, + }) + : setItem({ ...item, onset_date: dateQueryString(value) }); }🧰 Tools
🪛 Biome (1.9.4)
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)src/components/Symptoms/types.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Symptoms/types.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (1)
src/components/Symptoms/SymptomsBuilder.tsx (1)
354-358
:
Fix the allowCreate condition logic
The current condition incorrectly disables the create button even when symptoms are selected.
Apply this fix:
-allowCreate={(item) =>
- !item.onset_date && Array.isArray(item.symptom)
- ? !item.symptom.length
- : !item.symptom
-}
+allowCreate={(item) =>
+ !(Array.isArray(item.symptom) && item.symptom.length > 0)
+}
Hey @shivankacker, it seems that when we update fields like |
I don't think the tests are failing because of that. Go through test screenshots and see if you can find what is causing the failure |
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
…issues/8998/symptoms-editor-fix
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: 1
🧹 Outside diff range and nitpick comments (3)
src/components/Symptoms/SymptomsBuilder.tsx (3)
1-1
: Consider adding timezone handling for medical recordsWhen dealing with medical records, it's crucial to handle timezones correctly. Consider using dayjs with timezone plugin to ensure consistent date handling across different regions.
+import timezone from "dayjs/plugin/timezone"; +import utc from "dayjs/plugin/utc"; + +dayjs.extend(utc); +dayjs.extend(timezone);
201-208
: Remove redundant block statementsThe code contains unnecessary block statements that can be simplified.
- { "id" in item ? setItem({ onset_date: dateQueryString(value), id: item.id, }) : setItem({ ...item, onset_date: dateQueryString(value) }); - } - { "id" in item ? setItem({ cure_date: dateQueryString(value), id: item.id, }) : setItem({ ...(item as EncounterSymptom), cure_date: dateQueryString(value), }); - }Also applies to: 225-235
🧰 Tools
🪛 Biome (1.9.4)
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
169-181
: Consider using useReducer for complex state managementThe component uses multiple useState hooks for related state variables. Consider using useReducer to simplify state management and ensure consistent updates.
type SymptomState = { selected: EncounterSymptom["symptom"] | EncounterSymptom["symptom"][]; otherSymptom: string; onsetDate?: Date; onCureDate?: Date; }; type SymptomAction = | { type: 'SET_SELECTED'; payload: EncounterSymptom["symptom"] | EncounterSymptom["symptom"][] } | { type: 'SET_OTHER_SYMPTOM'; payload: string } | { type: 'SET_ONSET_DATE'; payload?: Date } | { type: 'SET_CURE_DATE'; payload?: Date }; const symptomReducer = (state: SymptomState, action: SymptomAction): SymptomState => { switch (action.type) { case 'SET_SELECTED': return { ...state, selected: action.payload }; case 'SET_OTHER_SYMPTOM': return { ...state, otherSymptom: action.payload }; case 'SET_ONSET_DATE': return { ...state, onsetDate: action.payload }; case 'SET_CURE_DATE': return { ...state, onCureDate: action.payload }; default: return state; } };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/components/Common/DateInputV2.tsx
(1 hunks)src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Common/DateInputV2.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (1)
src/components/Symptoms/SymptomsBuilder.tsx (1)
354-358
: Correct the condition in allowCreate
prop to enable symptom creation
The current condition in the allowCreate
prop incorrectly disables the create button even when symptoms are selected. It should be updated to properly reflect when creation is allowed.
@JavidSumra Can you please share the current status of the PR? Otherwise, the PR will be closed in the next 48 hours, and you will be unassigned from the issue due to inactivity. |
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
@nihal467 need your review. |
@JavidSumra Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Bug Fixes