From 9088084ed70b89d151420b8d61f2bd53aa7ae749 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 27 Apr 2023 19:31:57 +0530 Subject: [PATCH] fixes #4999 --- src/Components/Facility/ConsultationForm.tsx | 2 +- .../Shifting/ShiftDetailsUpdate.tsx | 532 ++++++++---------- 2 files changed, 224 insertions(+), 310 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 9bc52331372..b295ff47412 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -876,7 +876,7 @@ export const ConsultationForm = (props: any) => { })}
-
+
import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); interface patientShiftProps { id: string; @@ -94,10 +85,6 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { errors: { ...initError }, }; - const shiftStatusOptions = wartime_shifting - ? SHIFTING_CHOICES_WARTIME - : SHIFTING_CHOICES_PEACETIME; - let requiredFields: any = { reason: { errorText: t("please_enter_a_reason_for_the_shift"), @@ -172,20 +159,6 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { return !isInvalidForm; }; - const handleChange = (e: any) => { - const form = { ...state.form }; - const { name, value } = e.target; - form[name] = value; - dispatch({ type: "set_form", form }); - }; - - const handleTextAreaChange = (e: any) => { - const form = { ...state.form }; - const { name, value } = e; - form[name] = value; - dispatch({ type: "set_form", form }); - }; - const handleOnSelect = (user: any) => { const form = { ...state.form }; form["assigned_to"] = user?.id; @@ -316,7 +289,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { } return ( -
+ setShowDischargeModal(false)} @@ -326,287 +299,228 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { handleSubmit(true); }} /> - -
- - -
-
- option.label || option.text} - optionValue={(option) => option.text} - optionSelectedLabel={(option) => option.label || option.text} - onChange={handleFormFieldChange} - className={classNames( - "bg-white", - wartime_shifting ? " h-14 " : " h-12 ", - "w-full shadow-sm md:text-sm md:leading-5 mt-2" - )} - /> -
- {wartime_shifting && ( -
- {t("assigned_to")} -
- {assignedUserLoading ? ( - - ) : ( - - )} -
-
- )} - {wartime_shifting && ( -
- - {t("name_of_shifting_approving_facility")} - - - setFacility(obj, "shifting_approving_facility_object") - } - errors={state.errors.shifting_approving_facility_object} - /> -
- )} - -
- - {t("what_facility_assign_the_patient_to")} - - +
+ option.text} + optionValue={(option) => option.text} + optionSelectedLabel={(option) => option.text} + onChange={handleFormFieldChange} + className={classNames( + wartime_shifting ? "h-14" : "h-12", + "bg-white w-full md:leading-5 mt-2 md:col-span-1" + )} + /> + + {wartime_shifting && ( +
+ {t("assigned_to")} + {assignedUserLoading ? ( + + ) : ( + - setFacility(obj, "assigned_facility_object") + selected={assignedUser} + setSelected={handleOnSelect} + errors={""} + facilityId={ + state.form?.shifting_approving_facility_object?.id } - errors={state.errors.assigned_facility} - /> -
- -
- {t("is_this_an_emergency")} - - - } - label={t("yes")} - /> - } - label={t("no")} - /> - - - -
- - {kasp_enabled && ( -
- - {t("is")} {kasp_full_string}? - - - - } - label={t("yes")} - /> - } - label={t("no")} - /> - - - -
- )} - -
- {t("is_this_an_upshift")} - - - } - label={t("yes")} - /> - } - label={t("no")} - /> - - - -
- -
- -
- - {wartime_shifting && ( - <> -
- {t("preferred_vehicle")} - -
-
- {t("preferred_facility_type")}* - -
-
- {t("severity_of_breathlessness")}* - -
{" "} - )} -
- -
- -
- -
- -
- { - handleFormFieldChange(event); - }} - error={state.errors.ambulance_phone_number} - /> -
- -
- -
- -
- -
- -
- goBack()} /> - handleSubmit()} /> -
- - -
-
+ )} + + {wartime_shifting && ( +
+ + {t("name_of_shifting_approving_facility")} + + + setFacility(obj, "shifting_approving_facility_object") + } + errors={state.errors.shifting_approving_facility_object} + /> +
+ )} + +
+ {t("what_facility_assign_the_patient_to")} + + setFacility(obj, "assigned_facility_object") + } + errors={state.errors.assigned_facility} + /> +
+ + option.label} + optionValue={(option) => option.value} + /> + + {kasp_enabled && ( + option.value} + optionDisplay={(option) => option.label} + onChange={handleFormFieldChange} + /> + )} + + option.value} + optionDisplay={(option) => option.label} + onChange={handleFormFieldChange} + /> + + + + {wartime_shifting && ( + <> + option} + optionValue={(option) => option} + onChange={handleFormFieldChange} + className="bg-white h-11 w-full mt-2 shadow-sm md:leading-5" + error={state.errors.preferred_vehicle_choice} + /> + option} + optionValue={(option) => option} + onChange={handleFormFieldChange} + className="bg-white h-11 w-full mt-2 shadow-sm md:leading-5 md:col-span-1" + error={state.errors.assigned_facility_type} + /> + option} + optionValue={(option) => option} + onChange={handleFormFieldChange} + className="bg-white h-11 w-full mt-2 shadow-sm md:leading-5 md:col-span-1" + /> + + )} + + + + + + { + handleFormFieldChange(event); + }} + error={state.errors.ambulance_phone_number} + /> + + + + + +
+ goBack()} /> + handleSubmit()} /> +
+
+ +
); };