From 6939644b4375780aafdf709f4ca17a91f81e6844 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 21 Jun 2023 12:06:11 +0530 Subject: [PATCH] Tailwinds Create Shift Form (#5661) * tailwinds #4987 * fix responsiveness issue --- src/Components/Patient/ShiftCreate.tsx | 435 +++++++++---------------- 1 file changed, 147 insertions(+), 288 deletions(-) diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index c4bb347cfcb..63dbefa21ff 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -6,19 +6,7 @@ import { PATIENT_CATEGORIES, SHIFTING_VEHICLE_CHOICES, } from "../../Common/constants"; -import { - Box, - Card, - CardContent, - FormControlLabel, - Radio, - RadioGroup, -} from "@material-ui/core"; import { Cancel, Submit } from "../Common/components/ButtonV2"; -import { - LegacyErrorHelperText, - LegacySelectField, -} from "../Common/HelperInputFields"; import { createShift, getPatient } from "../../Redux/actions"; import { useEffect, useReducer, useState } from "react"; @@ -37,8 +25,11 @@ import useAppHistory from "../../Common/hooks/useAppHistory"; import useConfig from "../../Common/hooks/useConfig"; import { useDispatch } from "react-redux"; import { useTranslation } from "react-i18next"; +import Page from "../Common/components/Page.js"; +import Card from "../../CAREUI/display/Card.js"; +import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField.js"; +import { SelectFormField } from "../Form/FormFields/SelectFormField.js"; -const PageTitle = loadable(() => import("../Common/PageTitle")); const Loading = loadable(() => import("../Common/Loading")); interface patientShiftProps { @@ -195,26 +186,6 @@ export const ShiftCreate = (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 handleTextFormFieldChange = (e: any) => { - const form = { ...state.form }; - const { name, value } = e; - form[name] = value; - dispatch({ type: "set_form", form }); - }; - - const handleValueChange = (value: any, name: string) => { - const form = { ...state.form }; - form[name] = value; - dispatch({ type: "set_form", form }); - }; - const handleFormFieldChange = (event: FieldChangeEvent) => { dispatch({ type: "set_form", @@ -277,266 +248,154 @@ export const ShiftCreate = (props: patientShiftProps) => { } } }; - const vehicleOptions = SHIFTING_VEHICLE_CHOICES.map((obj) => obj.text); - const facilityOptions = FACILITY_TYPES.map((obj) => obj.text); if (isLoading) { return ; } + const field = (name: string) => ({ + name, + value: state.form[name], + onChange: handleFormFieldChange, + error: state.errors[name], + }); + return ( -
- -
- - -
-
- -
- -
- -
- - {wartime_shifting && ( -
- - Name of shifting approving facility{" "} - * - - - handleValueChange(value, "shifting_approving_facility") - } - errors={state.errors.shifting_approving_facility} - /> -
- )} - -
- - {t("what_facility_assign_the_patient_to")} - - - handleValueChange(value, "assigned_facility") - } - freeText={true} - errors={state.errors.assigned_facility} - /> -
- -
- Is this an emergency? - - - } - label="Yes" - /> - } - label="No" - /> - - - -
- -
- Is this an upshift? - - - } - label="Yes" - /> - } - label="No" - /> - - - -
- -
- { - setPatientCategory(e.value); - }} - label="Patient Category" - /> -
- - {wartime_shifting && ( - <> -
- - Preferred Vehicle * - - -
-
- - Preferred Facility Type{" "} - * - - -
-
- - Severity of Breathlessness{" "} - * - - -
- - )} - -
- -
- -
- -
- -
- { - handleFormFieldChange(event); - }} - error={state.errors.ambulance_phone_number} - /> -
- -
- -
-
- -
- -
- goBack()} /> - -
-
-
-
-
-
+ + + + + + + {wartime_shifting && ( +
+ + Name of shifting approving facility + + + handleFormFieldChange({ + name: "shifting_approving_facility", + value, + }) + } + errors={state.errors.shifting_approving_facility} + /> +
+ )} + +
+ {t("what_facility_assign_the_patient_to")} + + handleFormFieldChange({ name: "assigned_facility", value }) + } + freeText={true} + errors={state.errors.assigned_facility} + /> +
+ + + + + + setPatientCategory(e.value)} + label="Patient Category" + /> + + {wartime_shifting && ( + <> + option.text} + optionValue={(option) => option.text} + /> + option.text} + optionValue={(option) => option.text} + /> + option} + optionValue={(option) => option} + /> + + )} + + + + + + + + + + +
+ goBack()} /> + +
+
+
); };