From bc3d2ca73c2a1f54c4ec0c80b881a5e70d44a3a8 Mon Sep 17 00:00:00 2001 From: Ashutosh Rai Date: Fri, 23 Feb 2024 18:10:06 +0530 Subject: [PATCH 1/9] fixes responsive design in patient details --- src/Components/Common/RelativeDateUserMention.tsx | 2 +- src/Components/Patient/SampleTestCard.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Common/RelativeDateUserMention.tsx b/src/Components/Common/RelativeDateUserMention.tsx index 6c5a78c7f09..2af92268987 100644 --- a/src/Components/Common/RelativeDateUserMention.tsx +++ b/src/Components/Common/RelativeDateUserMention.tsx @@ -9,7 +9,7 @@ function RelativeDateUserMention(props: { withoutSuffix?: boolean; }) { return ( -
+
{
-
+
@@ -157,7 +157,7 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
-
+
Created:{" "} { tooltipPosition="left" />
-
+
Last Modified:{" "} Date: Thu, 29 Feb 2024 02:29:29 +0530 Subject: [PATCH 2/9] fixes username validation --- src/Components/Facility/ConsultationCard.tsx | 4 +- .../Facility/ConsultationDetails/index.tsx | 2 + src/Components/Users/UserAdd.tsx | 96 ++++++++++--------- 3 files changed, 54 insertions(+), 48 deletions(-) diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index 1c6ec77afde..c1f94735235 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -163,7 +163,9 @@ export const ConsultationCard = (props: ConsultationProps) => { `/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/daily-rounds` ) } - disabled={itemData.discharge_date} + disabled={ + (itemData.discharge_date as string | undefined) !== undefined + } authorizeFor={NonReadOnlyUsers} > Add Consultation Updates diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 808a2c90de9..024f5df8d7d 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -127,6 +127,8 @@ export const ConsultationDetails = (props: any) => { ); } setConsultationData(data); + console.log(consultationData); + const assetRes = data?.current_bed?.bed_object?.id ? await dispatch( listAssetBeds({ diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index b4d9e9fbca6..595931f866e 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -141,9 +141,6 @@ const user_create_reducer = (state = initialState, action: any) => { } }; -const getDate = (value: any) => - value && dayjs(value).isValid() && dayjs(value).toDate(); - export const validateRule = ( condition: boolean, content: JSX.Element | string @@ -164,6 +161,9 @@ export const validateRule = ( ); }; +const getDate = (value: any) => + value && dayjs(value).isValid() && dayjs(value).toDate(); + export const UserAdd = (props: UserProps) => { const { goBack } = useAppHistory(); const { userId } = props; @@ -183,7 +183,7 @@ export const UserAdd = (props: UserProps) => { const [passwordInputInFocus, setPasswordInputInFocus] = useState(false); const [confirmPasswordInputInFocus, setConfirmPasswordInputInFocus] = useState(false); - const [usernameInput, setUsernameInput] = useState(""); + const [usernameInput, setUsernameInput] = useState(null); const userExistsEnums = { idle: 0, @@ -326,7 +326,7 @@ export const UserAdd = (props: UserProps) => { const setFacility = (selected: FacilityModel | FacilityModel[] | null) => { setSelectedFacility(selected as FacilityModel[]); - const form = { ...state.form }; + const form: any = { ...state.form }; form.facilities = selected ? (selected as FacilityModel[]).map((i) => i.id ?? -1) : []; @@ -619,7 +619,7 @@ export const UserAdd = (props: UserProps) => { }} formData={state.form} /> -
+
Facilities { {usernameInputInFocus && (
- {usernameExists !== userExistsEnums.idle && ( - <> - {usernameExists === userExistsEnums.checking ? ( - - {" "} - checking... - - ) : ( - <> - {usernameExists === userExistsEnums.exists ? ( -
- {" "} - - Username is not available - -
- ) : ( -
- {" "} - - Username is available - -
- )} - - )} - - )} + {usernameInput && + usernameExists !== userExistsEnums.idle && ( + <> + {usernameExists === userExistsEnums.checking ? ( + + {" "} + checking... + + ) : ( + <> + {usernameExists === userExistsEnums.exists ? ( +
+ {" "} + + Username is not available + +
+ ) : ( +
+ {" "} + + Username is available + +
+ )} + + )} + + )}
{validateRule( - usernameInput.length >= 4 && usernameInput.length <= 16, + usernameInput?.length >= 4 && usernameInput?.length <= 16, "Username should be 4-16 characters long" )}
{validateRule( /^[a-z0-9._-]*$/.test(usernameInput), - "Username can only contain lowercase letters, numbers, and . _ -" + "Username can only contain lowercase letters, numbers, and . _ - " )}
{validateRule( - /^[a-z0-9].*[a-z0-9]$/i.test(usernameInput), + usernameInput && + /^[a-zA-Z0-9].*[a-zA-Z0-9]$/.test(usernameInput), "Username must start and end with a letter or number" )}
@@ -930,7 +932,7 @@ export const UserAdd = (props: UserProps) => { /> ))}
-
+
goBack()} />
From 6564585647b64c9c6df9e3873f552d1b28b7a874 Mon Sep 17 00:00:00 2001 From: Ashutosh Rai Date: Thu, 29 Feb 2024 15:58:52 +0530 Subject: [PATCH 3/9] fixes button resposive of user card --- src/Components/Common/components/Page.tsx | 2 +- src/Components/Users/ManageUsers.tsx | 36 +++++++++++------------ src/Routers/AppRouter.tsx | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Components/Common/components/Page.tsx b/src/Components/Common/components/Page.tsx index ce5e84deefe..031daa5aa44 100644 --- a/src/Components/Common/components/Page.tsx +++ b/src/Components/Common/components/Page.tsx @@ -32,7 +32,7 @@ export default function Page(props: PageProps) { if (!props.noImplicitPadding) { if (!props.hideBack || props.componentRight) padding = "md:px-6 px-3 py-3.5"; - else padding = "px-6 py-5"; + else padding = "md:px-6 md:py-5 sm:px-0"; } return ( diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index 1a39b57ec53..ac87b29f6ea 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -1,15 +1,15 @@ -import * as Notification from "../../Utils/Notifications.js"; import { lazy, useState } from "react"; +import * as Notification from "../../Utils/Notifications.js"; import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; import ButtonV2, { Submit } from "../Common/components/ButtonV2"; import CareIcon from "../../CAREUI/icons/CareIcon"; import ConfirmHomeFacilityUpdateDialog from "./ConfirmHomeFacilityUpdateDialog"; import CountBlock from "../../CAREUI/display/Count"; -import { FacilityModel } from "../Facility/models"; import { FacilitySelect } from "../Common/FacilitySelect"; +import { FacilityModel } from "../Facility/models"; import SearchInput from "../Form/SearchInput"; -import SkillsSlideOver from "./SkillsSlideOver"; import SlideOverCustom from "../../CAREUI/interactive/SlideOver"; +import SkillsSlideOver from "./SkillsSlideOver"; import { USER_TYPES } from "../../Common/constants"; import UnlinkFacilityDialog from "./UnlinkFacilityDialog"; import UserDeleteDialog from "./UserDeleteDialog"; @@ -141,6 +141,14 @@ export default function ManageUsers() { await refetchUserList(); }; + const handleDelete = (user: any) => { + setUserData({ + show: true, + username: user.username, + name: `${user.first_name} ${user.last_name} `, + }); + }; + const handleSubmit = async () => { const { res, error } = await request(routes.deleteUser, { pathParams: { username: userData.username }, @@ -159,14 +167,6 @@ export default function ManageUsers() { await refetchUserList(); }; - const handleDelete = (user: any) => { - setUserData({ - show: true, - username: user.username, - name: `${user.first_name} ${user.last_name}`, - }); - }; - let userList: any[] = []; userListData?.results && @@ -177,7 +177,7 @@ export default function ManageUsers() {
@@ -248,8 +248,8 @@ export default function ManageUsers() {
{user.user_type && ( @@ -328,9 +328,7 @@ export default function ManageUsers() { )}
{user.created_by && ( @@ -369,7 +367,7 @@ export default function ManageUsers() {
{user.username && ( -
+
{ setReplaceHomeFacility({ show: false, @@ -585,6 +584,7 @@ function UserFacilities(props: { user: any }) { newFacility: undefined, }); }; + const hideUnlinkFacilityModal = () => { setUnlinkFacilityData({ show: false, diff --git a/src/Routers/AppRouter.tsx b/src/Routers/AppRouter.tsx index 56d8b31573b..8d3048e464f 100644 --- a/src/Routers/AppRouter.tsx +++ b/src/Routers/AppRouter.tsx @@ -145,7 +145,7 @@ export default function AppRouter() { id="pages" className="flex-1 overflow-y-scroll pb-4 focus:outline-none md:py-0" > -
{pages}
+
{pages}
From d19d06a4ae665f77052d95a31cac15a87c16d4cb Mon Sep 17 00:00:00 2001 From: Ashutosh Rai Date: Sun, 3 Mar 2024 01:16:09 +0530 Subject: [PATCH 4/9] fix in searching user type --- src/Components/Users/UserAdd.tsx | 50 ++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 595931f866e..00a765181bb 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -41,6 +41,7 @@ import routes from "../../Redux/api"; import request from "../../Utils/request/request"; import useQuery from "../../Utils/request/useQuery"; import CareIcon from "../../CAREUI/icons/CareIcon"; +import AutocompleteFormField from "../Form/FormFields/Autocomplete"; const Loading = lazy(() => import("../Common/Loading")); @@ -266,6 +267,17 @@ export const UserAdd = (props: UserProps) => { }, }); + const { loading: isStateLoading } = useQuery(routes.statesList, { + onResponse: (result) => { + if (!result || !result.res || !result.data) return; + if (userIndex <= USER_TYPES.indexOf("StateAdmin")) { + setStates([authUser.state_object!]); + } else { + setStates(result.data.results); + } + }, + }); + const { loading: isLocalbodyLoading } = useQuery( routes.getAllLocalBodyByDistrict, { @@ -282,17 +294,6 @@ export const UserAdd = (props: UserProps) => { } ); - const { loading: isStateLoading } = useQuery(routes.statesList, { - onResponse: (result) => { - if (!result || !result.res || !result.data) return; - if (userIndex <= USER_TYPES.indexOf("StateAdmin")) { - setStates([authUser.state_object!]); - } else { - setStates(result.data.results); - } - }, - }); - const handleDateChange = (e: FieldChangeEvent) => { if (dayjs(e.value).isValid()) { dispatch({ @@ -583,10 +584,6 @@ export const UserAdd = (props: UserProps) => { } }; - if (isLoading) { - return ; - } - const field = (name: string) => { return { id: name, @@ -597,14 +594,18 @@ export const UserAdd = (props: UserProps) => { }; }; + if (isLoading) { + return ; + } + return (  Need Help? @@ -631,15 +632,26 @@ export const UserAdd = (props: UserProps) => { showAll={false} />
- o.role + (o.readOnly ? " (Read Only)" : "")} optionValue={(o) => o.id} - /> + /> */} + o.role + (o.readOnly ? " (Read Only)" : "")} + optionValue={(o) => o.id} + required + /> {state.form.user_type === "Doctor" && ( <> Date: Sun, 3 Mar 2024 23:31:56 +0530 Subject: [PATCH 5/9] Revert "fixes button resposive of user card" This reverts commit 6564585647b64c9c6df9e3873f552d1b28b7a874. --- src/Components/Common/components/Page.tsx | 2 +- src/Components/Users/ManageUsers.tsx | 36 +++++++++++------------ src/Routers/AppRouter.tsx | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Components/Common/components/Page.tsx b/src/Components/Common/components/Page.tsx index 031daa5aa44..ce5e84deefe 100644 --- a/src/Components/Common/components/Page.tsx +++ b/src/Components/Common/components/Page.tsx @@ -32,7 +32,7 @@ export default function Page(props: PageProps) { if (!props.noImplicitPadding) { if (!props.hideBack || props.componentRight) padding = "md:px-6 px-3 py-3.5"; - else padding = "md:px-6 md:py-5 sm:px-0"; + else padding = "px-6 py-5"; } return ( diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index ac87b29f6ea..1a39b57ec53 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -1,15 +1,15 @@ -import { lazy, useState } from "react"; import * as Notification from "../../Utils/Notifications.js"; +import { lazy, useState } from "react"; import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; import ButtonV2, { Submit } from "../Common/components/ButtonV2"; import CareIcon from "../../CAREUI/icons/CareIcon"; import ConfirmHomeFacilityUpdateDialog from "./ConfirmHomeFacilityUpdateDialog"; import CountBlock from "../../CAREUI/display/Count"; -import { FacilitySelect } from "../Common/FacilitySelect"; import { FacilityModel } from "../Facility/models"; +import { FacilitySelect } from "../Common/FacilitySelect"; import SearchInput from "../Form/SearchInput"; -import SlideOverCustom from "../../CAREUI/interactive/SlideOver"; import SkillsSlideOver from "./SkillsSlideOver"; +import SlideOverCustom from "../../CAREUI/interactive/SlideOver"; import { USER_TYPES } from "../../Common/constants"; import UnlinkFacilityDialog from "./UnlinkFacilityDialog"; import UserDeleteDialog from "./UserDeleteDialog"; @@ -141,14 +141,6 @@ export default function ManageUsers() { await refetchUserList(); }; - const handleDelete = (user: any) => { - setUserData({ - show: true, - username: user.username, - name: `${user.first_name} ${user.last_name} `, - }); - }; - const handleSubmit = async () => { const { res, error } = await request(routes.deleteUser, { pathParams: { username: userData.username }, @@ -167,6 +159,14 @@ export default function ManageUsers() { await refetchUserList(); }; + const handleDelete = (user: any) => { + setUserData({ + show: true, + username: user.username, + name: `${user.first_name} ${user.last_name}`, + }); + }; + let userList: any[] = []; userListData?.results && @@ -177,7 +177,7 @@ export default function ManageUsers() {
@@ -248,8 +248,8 @@ export default function ManageUsers() {
{user.user_type && ( @@ -328,7 +328,9 @@ export default function ManageUsers() { )}
{user.created_by && ( @@ -367,7 +369,7 @@ export default function ManageUsers() {
{user.username && ( -
+
{ setReplaceHomeFacility({ show: false, @@ -584,7 +585,6 @@ function UserFacilities(props: { user: any }) { newFacility: undefined, }); }; - const hideUnlinkFacilityModal = () => { setUnlinkFacilityData({ show: false, diff --git a/src/Routers/AppRouter.tsx b/src/Routers/AppRouter.tsx index 8d3048e464f..56d8b31573b 100644 --- a/src/Routers/AppRouter.tsx +++ b/src/Routers/AppRouter.tsx @@ -145,7 +145,7 @@ export default function AppRouter() { id="pages" className="flex-1 overflow-y-scroll pb-4 focus:outline-none md:py-0" > -
{pages}
+
{pages}
From cb71fc4535fe4c695c6833d9b18fa1567a4d617f Mon Sep 17 00:00:00 2001 From: Ashutosh Rai Date: Sun, 3 Mar 2024 23:32:27 +0530 Subject: [PATCH 6/9] Revert "fixes username validation" This reverts commit f67a927441aa180054cd264a788f352936481171. --- src/Components/Facility/ConsultationCard.tsx | 4 +- .../Facility/ConsultationDetails/index.tsx | 2 - src/Components/Users/UserAdd.tsx | 96 +++++++++---------- 3 files changed, 48 insertions(+), 54 deletions(-) diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index c1f94735235..1c6ec77afde 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -163,9 +163,7 @@ export const ConsultationCard = (props: ConsultationProps) => { `/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/daily-rounds` ) } - disabled={ - (itemData.discharge_date as string | undefined) !== undefined - } + disabled={itemData.discharge_date} authorizeFor={NonReadOnlyUsers} > Add Consultation Updates diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 024f5df8d7d..808a2c90de9 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -127,8 +127,6 @@ export const ConsultationDetails = (props: any) => { ); } setConsultationData(data); - console.log(consultationData); - const assetRes = data?.current_bed?.bed_object?.id ? await dispatch( listAssetBeds({ diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 00a765181bb..023985c1a90 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -142,6 +142,9 @@ const user_create_reducer = (state = initialState, action: any) => { } }; +const getDate = (value: any) => + value && dayjs(value).isValid() && dayjs(value).toDate(); + export const validateRule = ( condition: boolean, content: JSX.Element | string @@ -162,9 +165,6 @@ export const validateRule = ( ); }; -const getDate = (value: any) => - value && dayjs(value).isValid() && dayjs(value).toDate(); - export const UserAdd = (props: UserProps) => { const { goBack } = useAppHistory(); const { userId } = props; @@ -184,7 +184,7 @@ export const UserAdd = (props: UserProps) => { const [passwordInputInFocus, setPasswordInputInFocus] = useState(false); const [confirmPasswordInputInFocus, setConfirmPasswordInputInFocus] = useState(false); - const [usernameInput, setUsernameInput] = useState(null); + const [usernameInput, setUsernameInput] = useState(""); const userExistsEnums = { idle: 0, @@ -327,7 +327,7 @@ export const UserAdd = (props: UserProps) => { const setFacility = (selected: FacilityModel | FacilityModel[] | null) => { setSelectedFacility(selected as FacilityModel[]); - const form: any = { ...state.form }; + const form = { ...state.form }; form.facilities = selected ? (selected as FacilityModel[]).map((i) => i.id ?? -1) : []; @@ -620,7 +620,7 @@ export const UserAdd = (props: UserProps) => { }} formData={state.form} /> -
+
Facilities { {usernameInputInFocus && (
- {usernameInput && - usernameExists !== userExistsEnums.idle && ( - <> - {usernameExists === userExistsEnums.checking ? ( - - {" "} - checking... - - ) : ( - <> - {usernameExists === userExistsEnums.exists ? ( -
- {" "} - - Username is not available - -
- ) : ( -
- {" "} - - Username is available - -
- )} - - )} - - )} + {usernameExists !== userExistsEnums.idle && ( + <> + {usernameExists === userExistsEnums.checking ? ( + + {" "} + checking... + + ) : ( + <> + {usernameExists === userExistsEnums.exists ? ( +
+ {" "} + + Username is not available + +
+ ) : ( +
+ {" "} + + Username is available + +
+ )} + + )} + + )}
{validateRule( - usernameInput?.length >= 4 && usernameInput?.length <= 16, + usernameInput.length >= 4 && usernameInput.length <= 16, "Username should be 4-16 characters long" )}
{validateRule( /^[a-z0-9._-]*$/.test(usernameInput), - "Username can only contain lowercase letters, numbers, and . _ - " + "Username can only contain lowercase letters, numbers, and . _ -" )}
{validateRule( - usernameInput && - /^[a-zA-Z0-9].*[a-zA-Z0-9]$/.test(usernameInput), + /^[a-z0-9].*[a-z0-9]$/i.test(usernameInput), "Username must start and end with a letter or number" )}
@@ -944,7 +942,7 @@ export const UserAdd = (props: UserProps) => { /> ))}
-
+
goBack()} />
From b91541ee6063fefa06d956f697b44296bee97e7d Mon Sep 17 00:00:00 2001 From: Ashutosh Rai Date: Sun, 3 Mar 2024 23:32:55 +0530 Subject: [PATCH 7/9] Revert "fixes responsive design in patient details" This reverts commit bc3d2ca73c2a1f54c4ec0c80b881a5e70d44a3a8. --- src/Components/Common/RelativeDateUserMention.tsx | 2 +- src/Components/Patient/SampleTestCard.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Common/RelativeDateUserMention.tsx b/src/Components/Common/RelativeDateUserMention.tsx index 2af92268987..6c5a78c7f09 100644 --- a/src/Components/Common/RelativeDateUserMention.tsx +++ b/src/Components/Common/RelativeDateUserMention.tsx @@ -9,7 +9,7 @@ function RelativeDateUserMention(props: { withoutSuffix?: boolean; }) { return ( -
+
{
-
+
@@ -157,7 +157,7 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
-
+
Created:{" "} { tooltipPosition="left" />
-
+
Last Modified:{" "} Date: Mon, 4 Mar 2024 00:55:55 +0530 Subject: [PATCH 8/9] fixes searching user types --- src/Components/Users/UserAdd.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 023985c1a90..693567d0ba7 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -327,7 +327,7 @@ export const UserAdd = (props: UserProps) => { const setFacility = (selected: FacilityModel | FacilityModel[] | null) => { setSelectedFacility(selected as FacilityModel[]); - const form = { ...state.form }; + const form: any = { ...state.form }; form.facilities = selected ? (selected as FacilityModel[]).map((i) => i.id ?? -1) : []; From 217eee728db13e5c9825f6295a373b513ff23998 Mon Sep 17 00:00:00 2001 From: Ashutosh Rai Date: Thu, 7 Mar 2024 01:08:42 +0530 Subject: [PATCH 9/9] removed comment and any type --- src/Components/Users/UserAdd.tsx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 693567d0ba7..40e4e3af093 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -268,12 +268,15 @@ export const UserAdd = (props: UserProps) => { }); const { loading: isStateLoading } = useQuery(routes.statesList, { - onResponse: (result) => { - if (!result || !result.res || !result.data) return; + onResponse: ({ data }) => { + if (!data) { + return; + } + if (userIndex <= USER_TYPES.indexOf("StateAdmin")) { setStates([authUser.state_object!]); } else { - setStates(result.data.results); + setStates(data.results); } }, }); @@ -327,9 +330,9 @@ export const UserAdd = (props: UserProps) => { const setFacility = (selected: FacilityModel | FacilityModel[] | null) => { setSelectedFacility(selected as FacilityModel[]); - const form: any = { ...state.form }; + const form = { ...state.form }; form.facilities = selected - ? (selected as FacilityModel[]).map((i) => i.id ?? -1) + ? (selected as FacilityModel[]).map((i) => parseInt(i.id as string) ?? -1) : []; dispatch({ type: "set_form", form }); }; @@ -633,25 +636,16 @@ export const UserAdd = (props: UserProps) => { />
- {/* o.role + (o.readOnly ? " (Read Only)" : "")} - optionValue={(o) => o.id} - /> */} - o.role + (o.readOnly ? " (Read Only)" : "")} optionValue={(o) => o.id} required /> + {state.form.user_type === "Doctor" && ( <>