diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 22e40053b14..3810bcb9315 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -1,20 +1,15 @@ -import { - Dialog, - DialogActions, - DialogContent, - DialogTitle, - InputLabel, -} from "@material-ui/core"; import { navigate } from "raviger"; import moment from "moment"; -import React, { useReducer, useState } from "react"; +import { useReducer, useState } from "react"; import { useDispatch } from "react-redux"; import { transferPatient } from "../../Redux/actions"; import * as Notification from "../../Utils/Notifications.js"; -import { DateInputField, SelectField } from "../Common/HelperInputFields"; import { DupPatientModel } from "./models"; import { OptionsType } from "../../Common/constants"; import { Cancel, Submit } from "../Common/components/ButtonV2"; +import DateFormField from "../Form/FormFields/DateFormField"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import { FieldLabel } from "../Form/FormFields/FormField"; interface Props { patientList: Array; @@ -38,6 +33,9 @@ const initialState = { errors: { ...initError }, }; +const getDate = (value: any) => + value && moment(value).isValid() && moment(value).toDate(); + const patientFormReducer = (state = initialState, action: any) => { switch (action.type) { case "set_form": { @@ -71,14 +69,14 @@ const TransferPatientDialog = (props: Props) => { const handleChange = (e: any) => { const form = { ...state.form }; - form[e.target.name] = e.target.value; + form[e.name] = e.value; dispatch({ type: "set_form", form }); }; - const handleDateChange = (date: any, field: string) => { - if (moment(date).isValid()) { + const handleDateChange = (e: any) => { + if (moment(e.value).isValid()) { const form = { ...state.form }; - form[field] = date; + form[e.name] = moment(e.value).format("YYYY-MM-DD"); dispatch({ type: "set_form", form }); } }; @@ -141,9 +139,8 @@ const TransferPatientDialog = (props: Props) => { }; return ( - - Patient Transfer Form - +
+

@@ -153,43 +150,47 @@ const TransferPatientDialog = (props: Props) => {

- Patient* - + Patient + + patient.text} + optionValue={(patient) => patient.id} + value={state.form.patient} onChange={handleChange} - errors={state.errors.patient} + error={state.errors.patient} />
- Date of birth* - handleDateChange(date, "date_of_birth")} - errors={state.errors.date_of_birth} - inputVariant="outlined" - margin="dense" - openTo="year" - disableFuture={true} +
- - +
+
- -
+ + ); }; diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index ec6484972d7..2948ca22d59 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -75,7 +75,7 @@ import { HCXPolicyModel } from "../HCX/models"; import HCXPolicyValidator from "../HCX/validators"; import { FieldError } from "../Form/FieldValidators"; import useAppHistory from "../../Common/hooks/useAppHistory"; - +import DialogModal from "../Common/Dialog"; // const debounce = require("lodash.debounce"); interface PatientRegisterProps extends PatientModel { @@ -1097,12 +1097,19 @@ export const PatientRegister = (props: PatientRegisterProps) => { /> )} {statusDialog.transfer && ( - handleDialogClose("close")} - handleCancel={() => handleDialogClose("back")} - facilityId={facilityId} - /> + handleDialogClose("back")} + title="Patient Transfer Form" + className="max-w-md md:min-w-[600px]" + > + handleDialogClose("close")} + handleCancel={() => handleDialogClose("back")} + facilityId={facilityId} + /> + )}