diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index fd22eddf470..5a2c580615c 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -1,4 +1,3 @@ -import { Card, CardContent, CircularProgress } from "@material-ui/core"; import loadable from "@loadable/component"; import { Link, navigate } from "raviger"; import { parsePhoneNumberFromString } from "libphonenumber-js/max"; @@ -39,9 +38,11 @@ import Checkbox from "../Common/components/CheckBox"; import DateFormField from "../Form/FormFields/DateFormField"; import { FieldLabel } from "../Form/FormFields/FormField"; import useAppHistory from "../../Common/hooks/useAppHistory"; +import Page from "../Common/components/Page"; +import Card from "../../CAREUI/display/Card"; +import CircularProgress from "../Common/components/CircularProgress"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); interface UserProps { userId?: number; @@ -632,322 +633,315 @@ export const UserAdd = (props: UserProps) => { }; return ( -
- -  Need Help? - - } - justifyContents="justify-between" - backUrl="/users" - /> - - - -
handleSubmit(e)}> -
-
- Facilities - -
- - o.role + ((o.readOnly && " (Read Only)") || "") - } - optionValue={(o) => o.id} - /> - - {state.form.user_type === "Doctor" && ( - <> - - - - - - - )} - - option.name} - optionValue={(option) => option.id} - onChange={handleFieldChange} + +  Need Help? + + } + backUrl="/users" + > + + handleSubmit(e)}> +
+
+ Facilities + - -
- + + o.role + ((o.readOnly && " (Read Only)") || "") + } + optionValue={(o) => o.id} + /> + + {state.form.user_type === "Doctor" && ( + <> + - -
+ + + )} + + option.name} + optionValue={(option) => option.id} + onChange={handleFieldChange} + /> + +
+ +
-
- { - handleFieldChange(e); - setUsernameInput(e.value); - }} - onFocus={() => setUsernameInputInFocus(true)} - onBlur={() => { - setUsernameInputInFocus(false); - }} - /> - {usernameInputInFocus && ( -
-
- {usernameExists !== userExistsEnums.idle && ( - <> - {usernameExists === userExistsEnums.checking ? ( - - checking... - - ) : ( - <> - {usernameExists === userExistsEnums.exists ? ( -
- {" "} - - Username is not available - -
- ) : ( -
- {" "} - - Username is available - -
- )} - - )} - - )} -
-
- {validateRule( - state.form.username?.length >= 2, - "Username should be atleast 2 characters long" - )} -
-
- {validateRule( - /[^.@+_-]/.test( - state.form.username[state.form.username?.length - 1] - ), - "Username can't end with ^ . @ + _ -" - )} -
-
- )} -
+ - + { + handleFieldChange(e); + setUsernameInput(e.value); + }} + onFocus={() => setUsernameInputInFocus(true)} + onBlur={() => { + setUsernameInputInFocus(false); + }} /> - -
- setPasswordInputInFocus(true)} - onBlur={() => setPasswordInputInFocus(false)} - /> - {passwordInputInFocus && ( -
- {validateRule( - state.form.password?.length >= 8, - "Password should be atleast 8 characters long" - )} - {validateRule( - state.form.password !== state.form.password.toUpperCase(), - "Password should contain at least 1 lowercase letter" + {usernameInputInFocus && ( +
+
+ {usernameExists !== userExistsEnums.idle && ( + <> + {usernameExists === userExistsEnums.checking ? ( + + checking... + + ) : ( + <> + {usernameExists === userExistsEnums.exists ? ( +
+ {" "} + + Username is not available + +
+ ) : ( +
+ {" "} + + Username is available + +
+ )} + + )} + )} +
+
{validateRule( - state.form.password !== state.form.password.toLowerCase(), - "Password should contain at least 1 uppercase letter" + state.form.username?.length >= 2, + "Username should be atleast 2 characters long" )} +
+
{validateRule( - /\d/.test(state.form.password), - "Password should contain at least 1 number" + /[^.@+_-]/.test( + state.form.username[state.form.username?.length - 1] + ), + "Username can't end with ^ . @ + _ -" )}
- )} -
-
- setConfirmPasswordInputInFocus(true)} - onBlur={() => setConfirmPasswordInputInFocus(false)} - /> - {confirmPasswordInputInFocus && - state.form.c_password.length > 0 && - validateRule( - state.form.c_password === state.form.password, - "Confirm password should match the entered password" - )} -
+
+ )} +
+ + + +
setPasswordInputInFocus(true)} + onBlur={() => setPasswordInputInFocus(false)} /> + {passwordInputInFocus && ( +
+ {validateRule( + state.form.password?.length >= 8, + "Password should be atleast 8 characters long" + )} + {validateRule( + state.form.password !== state.form.password.toUpperCase(), + "Password should contain at least 1 lowercase letter" + )} + {validateRule( + state.form.password !== state.form.password.toLowerCase(), + "Password should contain at least 1 uppercase letter" + )} + {validateRule( + /\d/.test(state.form.password), + "Password should contain at least 1 number" + )} +
+ )} +
+
setConfirmPasswordInputInFocus(true)} + onBlur={() => setConfirmPasswordInputInFocus(false)} /> - 0 && + validateRule( + state.form.c_password === state.form.password, + "Confirm password should match the entered password" + )} +
+ + + + o.text} + optionValue={(o) => o.text} + /> + + {isStateLoading ? ( + + ) : ( + o.name} + optionValue={(o) => o.id} + onChange={(e) => { + handleFieldChange(e); + if (e) fetchDistricts(e.value); + }} /> + )} + + {isDistrictLoading ? ( + + ) : ( o.text} - optionValue={(o) => o.text} + placeholder="Choose District" + options={districts} + optionLabel={(o) => o.name} + optionValue={(o) => o.id} + onChange={(e) => { + handleFieldChange(e); + if (e) fetchLocalBody(e.value); + }} /> + )} - {isStateLoading ? ( - - ) : ( - o.name} - optionValue={(o) => o.id} - onChange={(e) => { - handleFieldChange(e); - if (e) fetchDistricts(e.value); - }} - /> - )} - - {isDistrictLoading ? ( - + {showLocalbody && + (isLocalbodyLoading ? ( + ) : ( o.name} optionValue={(o) => o.id} - onChange={(e) => { - handleFieldChange(e); - if (e) fetchLocalBody(e.value); - }} /> - )} - - {showLocalbody && - (isLocalbodyLoading ? ( - - ) : ( - <> - o.name} - optionValue={(o) => o.id} - /> - - ))} -
-
- goBack()} /> - -
- - + ))} +
+
+ goBack()} /> + +
+
-
+ ); };