-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for searching user type in user creation form #7332
Changes from 8 commits
bc3d2ca
f67a927
6564585
d19d06a
6e85db4
cb71fc4
b91541e
61f7b6d
217eee7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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<Date>) => { | ||||||
if (dayjs(e.value).isValid()) { | ||||||
dispatch({ | ||||||
|
@@ -326,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 }; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Casting to
Suggested change
|
||||||
form.facilities = selected | ||||||
? (selected as FacilityModel[]).map((i) => i.id ?? -1) | ||||||
: []; | ||||||
|
@@ -583,10 +584,6 @@ export const UserAdd = (props: UserProps) => { | |||||
} | ||||||
}; | ||||||
|
||||||
if (isLoading) { | ||||||
return <Loading />; | ||||||
} | ||||||
|
||||||
const field = (name: string) => { | ||||||
return { | ||||||
id: name, | ||||||
|
@@ -597,14 +594,18 @@ export const UserAdd = (props: UserProps) => { | |||||
}; | ||||||
}; | ||||||
|
||||||
if (isLoading) { | ||||||
return <Loading />; | ||||||
} | ||||||
|
||||||
return ( | ||||||
<Page | ||||||
title={headerText} | ||||||
options={ | ||||||
<Link | ||||||
href="https://school.coronasafe.network/targets/12953" | ||||||
href="https://school.coronasafe.network/targets/12953 " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While saving the file extra space removed. |
||||||
className="inline-block rounded border border-gray-600 bg-gray-50 px-4 py-2 text-gray-600 transition hover:bg-gray-100" | ||||||
target="_blank" | ||||||
target="_blank " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed?
Suggested change
|
||||||
> | ||||||
<CareIcon icon="l-info-circle" className="text-lg" /> Need Help? | ||||||
</Link> | ||||||
|
@@ -631,15 +632,26 @@ export const UserAdd = (props: UserProps) => { | |||||
showAll={false} | ||||||
/> | ||||||
</div> | ||||||
<SelectFormField | ||||||
|
||||||
{/* <SelectFormField | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this instead of commenting it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was checking the everything was working properly I will remove and make new commit. |
||||||
{...field("user_type")} | ||||||
required | ||||||
label="User Type" | ||||||
options={userTypes} | ||||||
optionLabel={(o) => o.role + (o.readOnly ? " (Read Only)" : "")} | ||||||
optionValue={(o) => o.id} | ||||||
/> | ||||||
/> */} | ||||||
|
||||||
<AutocompleteFormField | ||||||
{...field("user_type")} | ||||||
label="User Type" | ||||||
placeholder="Search for a user type..." | ||||||
// value={userTypes} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
options={userTypes ?? []} | ||||||
optionLabel={(o) => o.role + (o.readOnly ? " (Read Only)" : "")} | ||||||
optionValue={(o) => o.id} | ||||||
required | ||||||
/> | ||||||
{state.form.user_type === "Doctor" && ( | ||||||
<> | ||||||
<TextFormField | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.