Skip to content

Commit

Permalink
Improved Nursing Care UI; fixes #8521
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Sep 11, 2024
1 parent d1bc4c8 commit 542f41f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 58 deletions.
106 changes: 51 additions & 55 deletions src/Components/LogUpdate/Sections/NursingCare.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,65 @@
import { useTranslation } from "react-i18next";
import { NURSING_CARE_PROCEDURES } from "../../../Common/constants";
import { classNames } from "../../../Utils/utils";
import CheckBoxFormField from "../../Form/FormFields/CheckBoxFormField";
import TextAreaFormField from "../../Form/FormFields/TextAreaFormField";
import { LogUpdateSectionMeta, LogUpdateSectionProps } from "../utils";
import { MultiSelectFormField } from "../../Form/FormFields/SelectFormField";

const NursingCare = ({ log, onChange }: LogUpdateSectionProps) => {
const { t } = useTranslation();
const nursing = log.nursing || [];

return (
<div className="flex flex-col">
{NURSING_CARE_PROCEDURES.map((procedure, i) => {
const obj = nursing.find((n) => n.procedure === procedure);

return (
<div
key={i}
className={classNames(
"overflow-hidden rounded-lg shadow-none transition-all duration-200 ease-in-out",
obj &&
"border border-secondary-400 bg-secondary-100 focus-within:shadow-md",
)}
>
<div className="px-4 pt-4">
<CheckBoxFormField
label={t(`NURSING_CARE_PROCEDURE__${procedure}`)}
name={`${procedure}__enabled`}
value={!!obj}
onChange={(e) => {
if (e.value) {
onChange({
nursing: [...nursing, { procedure, description: "" }],
});
} else {
onChange({
nursing: nursing.filter((n) => n.procedure !== procedure),
});
}
}}
errorClassName="hidden"
/>
</div>
{obj && (
<div className="p-4">
<TextAreaFormField
name={`${procedure}__description`}
value={obj.description}
onChange={(val) =>
onChange({
nursing: nursing.map((n) =>
n.procedure === procedure
? { ...n, description: val.value }
: n,
),
})
}
placeholder="Description"
errorClassName="hidden"
/>
</div>
)}
</div>
);
})}
<MultiSelectFormField
name="procedures"
placeholder={t("procedures_select_placeholder")}
value={nursing.map((p) => p.procedure)}
onChange={({ value }) => {
onChange({
nursing: value.map((procedure) => ({
procedure,
description:
nursing.find((p) => p.procedure === procedure)?.description ??
"",
})),
});
}}
options={NURSING_CARE_PROCEDURES}

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (8)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (5)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (7)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.

Check failure on line 27 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (6)

The type 'readonly ["personal_hygiene", "positioning", "suctioning", "ryles_tube_care", "iv_sitecare", "nubulisation", "dressing", "dvt_pump_stocking", "restrain", "chest_tube_care", "tracheostomy_care", "stoma_care", "catheter_care"]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.
optionLabel={(procedure) => t(`NURSING_CARE_PROCEDURE__${procedure}`)}
optionValue={(o) => o}

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (8)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (5)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (7)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.

Check failure on line 29 in src/Components/LogUpdate/Sections/NursingCare.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (6)

Type '(o: unknown) => unknown' is not assignable to type 'OptionCallback<unknown, "personal_hygiene" | "positioning" | "suctioning" | "ryles_tube_care" | "iv_sitecare" | "nubulisation" | "dressing" | "dvt_pump_stocking" | "restrain" | "chest_tube_care" | "tracheostomy_care" | "stoma_care" | "catheter_care">'.
errorClassName="hidden"
/>
{!!nursing.length && (
<table className="mb-8 w-full border-collapse">
<tbody>
{nursing.map((obj) => (
<tr>
<td className="whitespace-nowrap border border-secondary-400 p-2 pr-16 text-left text-sm font-semibold">
{t(`NURSING_CARE_PROCEDURE__${obj.procedure}`)}
</td>
<td className="w-full border border-secondary-400">
<TextAreaFormField
name={`${obj.procedure}__description`}
value={obj.description}
onChange={(val) =>
onChange({
nursing: nursing.map((n) =>
n.procedure === obj.procedure
? { ...n, description: val.value }
: n,
),
})
}
rows={2}
placeholder={t("add_remarks")}
errorClassName="hidden"
/>
</td>
</tr>
))}
</tbody>
</table>
)}
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/Locale/en/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@
"deleted_successfully": "{{name}} deleted successfully",
"delete_item": "Delete {{name}}",
"unsupported_browser": "Unsupported Browser",
"unsupported_browser_description": "Your browser ({{name}} version {{version}}) is not supported. Please update your browser to the latest version or switch to a supported browser for the best experience."

"unsupported_browser_description": "Your browser ({{name}} version {{version}}) is not supported. Please update your browser to the latest version or switch to a supported browser for the best experience.",
"add_remarks": "Add remarks"
}
3 changes: 2 additions & 1 deletion src/Locale/en/LogUpdate.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
"pulse": "Pulse",
"bradycardia": "Bradycardia",
"tachycardia": "Tachycardia",
"spo2": "SpO₂"
"spo2": "SpO₂",
"procedures_select_placeholder": "Select procedures to add details"
}

0 comments on commit 542f41f

Please sign in to comment.