From cbeeb646fb45a533ad6c4f72303fbd8e84324ac9 Mon Sep 17 00:00:00 2001 From: hsanjay <1ds22cy017@dsce.edu.in> Date: Sat, 4 Jan 2025 15:50:11 +0530 Subject: [PATCH] Deleted errors.tsx and input-with-error.tsx, and updated PatientRegistration.tsx, FacilityOrganizationSelector.tsx, and OrganizationSelector.tsx to replace InputWithError and InputError with Shadcn components accordingly. --- package-lock.json | 4 +- .../Patient/PatientRegistration.tsx | 420 ++++++++++++++---- src/components/ui/errors.tsx | 11 - src/components/ui/input-with-error.tsx | 24 - .../FacilityOrganizationSelector.tsx | 21 +- .../components/OrganizationSelector.tsx | 43 +- 6 files changed, 390 insertions(+), 133 deletions(-) delete mode 100644 src/components/ui/errors.tsx delete mode 100644 src/components/ui/input-with-error.tsx diff --git a/package-lock.json b/package-lock.json index 83d8318e57d..8ef501b93e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -146,8 +146,8 @@ "node": ">=22.8.0" }, "optionalDependencies": { - "@esbuild/linux-arm64": "*", - "@esbuild/linux-x64": "*", + "@esbuild/linux-arm64": "latest", + "@esbuild/linux-x64": "latest", "@rollup/rollup-linux-arm64-gnu": "4.29.1", "@rollup/rollup-linux-x64-gnu": "4.29.1" } diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 1dc236f5fb3..b2a9ca2a910 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -8,7 +8,6 @@ import SectionNavigator from "@/CAREUI/misc/SectionNavigator"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; -import { InputErrors } from "@/components/ui/errors"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; @@ -49,7 +48,6 @@ import OrganizationSelector from "@/pages/Organization/components/OrganizationSe import { PatientModel, validatePatient } from "@/types/emr/patient"; import Autocomplete from "../ui/autocomplete"; -import InputWithError from "../ui/input-with-error"; interface PatientRegistrationPageProps { facilityId: string; @@ -316,19 +314,38 @@ export default function PatientRegistration(
{t("general_info_detail")}

- +
+ - + {errors.name && + errors.name.map((error, index) => ( + + {error} + + ))} +

- +
+ { if (e.target.value.length > 13) return; @@ -340,10 +357,20 @@ export default function PatientRegistration( : f.emergency_phone_number, })); }} + className={`mt-1 block w-full border ${ + errors.phone_number ? "border-red-500" : "border-gray-300" + } rounded-md shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200`} /> - + {errors.phone_number && + errors.phone_number.map((error, index) => ( + + {error} + + ))} +
+
- +
{ @@ -357,19 +384,23 @@ export default function PatientRegistration( } }} id="same-phone-number" + className="" /> -

- +
+ { if (e.target.value.length > 13) return; @@ -379,8 +410,23 @@ export default function PatientRegistration( })); }} disabled={samePhoneNumber} + className={`mt-1 block w-full border ${ + errors.emergency_phone_number + ? "border-red-500" + : "border-gray-300" + } rounded-md shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200`} /> - + {errors.emergency_phone_number && ( + + {errors.emergency_phone_number.map((error, index) => ( + + {error} + + ))} + + )} +
+ {/*
*/}
- +
+ setForm((f) => ({ ...f, gender: value })) } - className="flex items-center gap-4" + className={`mt-1 flex items-center gap-4 ${ + errors.gender ? "border-red-500" : "" + }`} > {GENDER_TYPES.map((g) => ( - ))} - + {errors.gender && ( + + {errors.gender.map((error, index) => ( + + {error} + + ))} + + )} +
+
- +
+ - + {errors.blood_group && ( + + {errors.blood_group.map((error, index) => ( + + {error} + + ))} + + )} +
+
- +
+ setForm((f) => ({ ...f, - date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`, + date_of_birth: `${ + form.date_of_birth?.split("-")[0] || "" + }-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`, })) } + className={`mt-1 block w-full border ${ + errors.date_of_birth + ? "border-red-500" + : "border-gray-300" + } rounded-md shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200`} /> - + {errors.date_of_birth && ( + + {errors.date_of_birth.map((error, index) => ( + + {error} + + ))} + + )} +
- +
+ setForm((f) => ({ ...f, - date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${e.target.value}-${form.date_of_birth?.split("-")[2] || ""}`, + date_of_birth: `${ + form.date_of_birth?.split("-")[0] || "" + }-${e.target.value}-${form.date_of_birth?.split("-")[2] || ""}`, })) } + className={`mt-1 block w-full border ${ + errors.date_of_birth + ? "border-red-500" + : "border-gray-300" + } rounded-md shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200`} /> - + {errors.date_of_birth && ( + + {errors.date_of_birth.map((error, index) => ( + + {error} + + ))} + + )} +
- +
+ - + {errors.date_of_birth && ( + + {errors.date_of_birth.map((error, index) => ( + + {error} + + ))} + + )} +
{errors["date_of_birth"] && ( - + + {errors["date_of_birth"].map((error, index) => ( + + {error} + + ))} + )} @@ -512,13 +671,16 @@ export default function PatientRegistration( {t("age_input_warning_bold")}
- +
+ setForm((f) => ({ ...f, @@ -529,8 +691,27 @@ export default function PatientRegistration( })) } type="number" + required + className={`mt-1 block w-full border ${ + errors["year_of_birth"] + ? "border-red-500" + : "border-gray-300" + } rounded-md shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200`} /> - + {errors["year_of_birth"] && ( + + {errors["year_of_birth"].map((error, index) => ( + + {error} + + ))} + + )} +
+ {form.year_of_birth && (
{t("year_of_birth")} : {form.year_of_birth} @@ -540,13 +721,17 @@ export default function PatientRegistration(
- +
+