feat: bank details update for clinic admin

fix: clinic doc status
refactor: minor code changes
This commit is contained in:
deepvasoya 2025-06-05 19:24:44 +05:30
parent 25f1043e90
commit f8b0ba54ba
4 changed files with 166 additions and 237 deletions

View File

@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from "react";
// material-ui // material-ui
import { import {
@ -11,20 +11,24 @@ import {
ListItemText, ListItemText,
Paper, Paper,
Popper, Popper,
} from '@mui/material'; } from "@mui/material";
import { useTheme } from '@mui/material/styles'; import { useTheme } from "@mui/material/styles";
// assets // assets
import signoutImg from '../../../assets/images/icon/signout.svg'; import signoutImg from "../../../assets/images/icon/signout.svg";
import phoneImg from '../../../assets/images/icon/phone.svg'; import phoneImg from "../../../assets/images/icon/phone.svg";
import settingsImg from "../../../assets/images/icon/settings.svg";
import { useStyles } from '../mainLayoutStyles'; import { useStyles } from "../mainLayoutStyles";
import MainCard from './MainCard'; import MainCard from "./MainCard";
import Transitions from './Transitions'; import Transitions from "./Transitions";
import { useNavigate } from 'react-router-dom'; import { useNavigate } from "react-router-dom";
import { commonLogoutFunc } from '../../../utils/share'; import { commonLogoutFunc } from "../../../utils/share";
import defaultProfilePicture from '../../../assets/images/icon/defaultProfileIcon.svg'; import defaultProfilePicture from "../../../assets/images/icon/defaultProfileIcon.svg";
import { useSelector } from 'react-redux'; import { useSelector } from "react-redux";
import { getStripeAccountLink } from "../../../services/users.service";
import { pushNotification } from "../../../utils/notification";
import { NOTIFICATION, USER_ROLES } from "../../../constants";
// ==============================|| PROFILE MENU ||============================== // // ==============================|| PROFILE MENU ||============================== //
@ -39,11 +43,21 @@ const ProfileSection = () => {
const anchorRef = useRef(null); const anchorRef = useRef(null);
const user = useSelector((state) => state?.login?.user); const user = useSelector((state) => state?.login?.user);
const isSuperAdmin = user?.isSuperAdmin;
const companyStatus = useSelector( const getAccountLink = async () => {
(state) => state?.login?.user?.company?.status try {
); const response = await getStripeAccountLink();
if (response.data?.error) {
pushNotification(response.data?.error, NOTIFICATION.ERROR);
return;
}
// open link
window.location.href = response.data?.data;
} catch (error) {
console.error("Error creating Stripe account link:", error);
pushNotification("Error while getting stripe link", NOTIFICATION.ERROR);
}
};
const handleClose = (event) => { const handleClose = (event) => {
if (anchorRef.current && anchorRef.current.contains(event.target)) { if (anchorRef.current && anchorRef.current.contains(event.target)) {
@ -66,16 +80,23 @@ const ProfileSection = () => {
}, [open]); }, [open]);
const menuItems = [ const menuItems = [
{ id: 1, img: phoneImg, text: "Contact Us", alt: "contactUsImg" },
{ id: 1, img: phoneImg, text: 'Contact Us', alt: 'contactUsImg' }, // Only show Bank Details for clinic admin users
{ id: 2, img: signoutImg, text: 'Sign Out', alt: 'signoutImg' }, ...(user?.userType == USER_ROLES.CLINIC_ADMIN.toLowerCase()
? [{ id: 2, img: settingsImg, text: "Bank Details", alt: "bankDetails" }]
: []),
{ id: 3, img: signoutImg, text: "Sign Out", alt: "signoutImg" },
].filter(Boolean); ].filter(Boolean);
const renderProfile = (item, index) => ( const renderProfile = (item, index) => (
<React.Fragment key={`profile-item-${item.id}`}> <React.Fragment key={`profile-item-${item.id}`}>
{ {
<> <>
<ListItem button key={`menu-item-${item.id}`} onClick={() => handleMenuItemClick(item)}> <ListItem
button
key={`menu-item-${item.id}`}
onClick={() => handleMenuItemClick(item)}
>
<Box className={classes.listIcon}> <Box className={classes.listIcon}>
<img <img
style={{ width: "20px", height: "20px" }} style={{ width: "20px", height: "20px" }}
@ -86,9 +107,6 @@ const ProfileSection = () => {
</Box> </Box>
<ListItemText className={classes.listText} primary={item.text} /> <ListItemText className={classes.listText} primary={item.text} />
</ListItem> </ListItem>
{index === menuItems.length - 2 && (
<Divider component="li" key={`divider-${item.id}`} className={classes.dividerDiv} />
)}
</> </>
} }
</React.Fragment> </React.Fragment>
@ -100,16 +118,15 @@ const ProfileSection = () => {
// navigate('/contact-us'); // navigate('/contact-us');
break; break;
case 2: case 2:
commonLogoutFunc(); getAccountLink();
break; break;
case 3: case 3:
// setShowTransactionHistoryPopup(true); commonLogoutFunc();
break; break;
case 4: case 4:
setShowPopup(true); setShowPopup(true);
break; break;
case 5: case 5:
commonLogoutFunc();
break; break;
default: default:
break; break;
@ -125,7 +142,7 @@ const ProfileSection = () => {
<Box <Box
className={classes.profileSection} className={classes.profileSection}
ref={anchorRef} ref={anchorRef}
aria-controls={open ? 'menu-list-grow' : undefined} aria-controls={open ? "menu-list-grow" : undefined}
onClick={handleToggle} onClick={handleToggle}
aria-haspopup="true" aria-haspopup="true"
> >
@ -145,7 +162,7 @@ const ProfileSection = () => {
transition transition
disablePortal disablePortal
popperOptions={{ popperOptions={{
modifiers: [{ name: 'offset', options: { offset: [0, 14] } }], modifiers: [{ name: "offset", options: { offset: [0, 14] } }],
}} }}
> >
{({ TransitionProps }) => ( {({ TransitionProps }) => (

View File

@ -29,7 +29,7 @@ export const getUsers = (params) => {
export const getUserById = (id) => { export const getUserById = (id) => {
const data = userDataMock; const data = userDataMock;
return data.data.records.find((item) => item.id === id) return data.data.records.find((item) => item.id === id);
}; };
// export const getUserById = (id) => { // export const getUserById = (id) => {
@ -42,63 +42,6 @@ export const getUserById = (id) => {
// }); // });
// }; // };
export const getRoles = ({ page }) =>
page == 0
? {
// data: {
data: [
{
id: 1,
name: "Adult Immunisation",
},
{
id: 2,
name: "Allied health",
},
{
id: 3,
name: "Assist",
},
{
id: 4,
name: "Care plan",
},
{
id: 5,
name: "Care plan reviews",
},
{
id: 6,
name: "Cervical Screening",
},
{
id: 7,
name: "Child Immunisation",
},
{
id: 8,
name: "Health assessments",
},
{
id: 9,
name: "Mental Health Care Plans (MHCP)",
},
{
id: 10,
name: "Travel Immunisation",
},
],
// },
}
: { data: [] };
// const url = '/roles';
// return new Promise((resolve, reject) => {
// axiosInstance
// .get(url)
// .then((response) => resolve(response))
// .catch((err) => reject(err));
// });
export const addUser = (data) => { export const addUser = (data) => {
const url = "/users"; const url = "/users";
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -169,30 +112,8 @@ export const changePassword = (data) => {
.catch((err) => reject(err)); .catch((err) => reject(err));
}); });
}; };
export const updateMailersSettings = (data) => { export const getStripeAccountLink = () => {
const url = "/users/me/mail-notification"; const url = "/stripe/create-stripe-account-link";
return new Promise((resolve, reject) => {
axiosInstance
.put(url, data)
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};
export const updateUser = (imageUrl, isProfileDelete = false) => {
let url = "/users/me";
const data = { profilePhoto: imageUrl, isProfileDelete };
return new Promise((resolve, reject) => {
axiosInstance
.put(url, data)
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};
export const companyMe = () => {
let url = "/companies/me";
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axiosInstance axiosInstance
.get(url) .get(url)
@ -200,60 +121,3 @@ export const companyMe = () => {
.catch((err) => reject(err)); .catch((err) => reject(err));
}); });
}; };
export const updateCompanyDetails = (data) => {
let url = "/companies/me";
return new Promise((resolve, reject) => {
axiosInstance
.put(url, data)
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};
export const bsAdminLogin = (token) => {
const url = "/auth/admin/login";
return new Promise((resolve, reject) => {
axiosInstance
.post(url, {
token,
})
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};
export const resendPasswordMailer = (data) => {
const url = "/users/remind-password-setup";
return new Promise((resolve, reject) => {
axiosInstance
.patch(url, {
email: data,
})
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};
export const updateUserEmailAndContact = (data) => {
let url = "/users/me";
return new Promise((resolve, reject) => {
axiosInstance
.put(url, data)
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};
export const transferMasterAdminAccess = (id) => {
if (!id) throw new Error("User id is required");
const url = `/users/${id}/transfer-master-admin-access`;
return new Promise((resolve, reject) => {
axiosInstance
.put(url)
.then((response) => resolve(response))
.catch((err) => reject(err));
});
};

View File

@ -234,7 +234,7 @@ function YourDetailsForm() {
.matches(passwordNumberRegex, "Password must contain at least one number") .matches(passwordNumberRegex, "Password must contain at least one number")
.matches( .matches(
passwordSpacesRegex, passwordSpacesRegex,
"Password must not start or end with a space" "Password must not start or end with a space",
) )
.required("Password is required"), .required("Password is required"),
confirmPassword: Yup.string() confirmPassword: Yup.string()
@ -249,7 +249,7 @@ function YourDetailsForm() {
.min(10, "Business Phone number should have 10 digits only.") .min(10, "Business Phone number should have 10 digits only.")
.max(10, "Business Phone number should have 10 digits only."), .max(10, "Business Phone number should have 10 digits only."),
businessPhonePrefix: Yup.string().required( businessPhonePrefix: Yup.string().required(
"Business Phone Prefix is required" "Business Phone Prefix is required",
), ),
emergencyBusinessPhone: Yup.string() emergencyBusinessPhone: Yup.string()
.required("Emergency Business Phone is required") .required("Emergency Business Phone is required")
@ -257,7 +257,7 @@ function YourDetailsForm() {
.min(10, "Emergency Business Phone number should have 10 digits only.") .min(10, "Emergency Business Phone number should have 10 digits only.")
.max(10, "Emergency Business Phone number should have 10 digits only."), .max(10, "Emergency Business Phone number should have 10 digits only."),
emergencyBusinessPhonePrefix: Yup.string().required( emergencyBusinessPhonePrefix: Yup.string().required(
"Emergency Business Phone Prefix is required" "Emergency Business Phone Prefix is required",
), ),
businessEmail: Yup.string() businessEmail: Yup.string()
.required("Business Email is required") .required("Business Email is required")
@ -279,7 +279,7 @@ function YourDetailsForm() {
.required("ABN number is required") .required("ABN number is required")
.matches( .matches(
ONLY_ALPHA_NUMERIC_ACCEPT_REGEX, ONLY_ALPHA_NUMERIC_ACCEPT_REGEX,
"ABN Number must only contain numbers and letters" "ABN Number must only contain numbers and letters",
) )
.length(ABN_NUMBER_LENGTH, "Enter valid ABN Number"), .length(ABN_NUMBER_LENGTH, "Enter valid ABN Number"),
companyABNImage: Yup.string().required("Clinic ABN document is required"), companyABNImage: Yup.string().required("Clinic ABN document is required"),
@ -300,11 +300,11 @@ function YourDetailsForm() {
const countryShort = const countryShort =
formik.values.country === "Australia" ? "au" : "in"; formik.values.country === "Australia" ? "au" : "in";
const resp = await axios.get( const resp = await axios.get(
`https://api.zippopotam.us/${countryShort}/${pincode}` `https://api.zippopotam.us/${countryShort}/${pincode}`,
); );
formik.setFieldValue("state", resp?.data?.places[0]?.state); formik.setFieldValue("state", resp?.data?.places[0]?.state);
setLocalityOption( setLocalityOption(
resp?.data?.places?.map((object) => object["place name"]) resp?.data?.places?.map((object) => object["place name"]),
); );
formik.setFieldValue("locality", selectedLocalityRef.current); formik.setFieldValue("locality", selectedLocalityRef.current);
} catch (error) { } catch (error) {
@ -315,9 +315,9 @@ function YourDetailsForm() {
pushNotification("Invalid pincode", NOTIFICATION.ERROR); pushNotification("Invalid pincode", NOTIFICATION.ERROR);
} }
}, },
1000 1000,
), ),
[] [],
); );
const handleTogglePasswordVisibility = (field) => { const handleTogglePasswordVisibility = (field) => {
@ -325,7 +325,7 @@ function YourDetailsForm() {
setShowPassword((prevShowPassword) => !prevShowPassword); setShowPassword((prevShowPassword) => !prevShowPassword);
} else if (field === "confirmPassword") { } else if (field === "confirmPassword") {
setShowConfirmPassword( setShowConfirmPassword(
(prevShowConfirmPassword) => !prevShowConfirmPassword (prevShowConfirmPassword) => !prevShowConfirmPassword,
); );
} }
}; };
@ -348,7 +348,7 @@ function YourDetailsForm() {
} }
pushNotification( pushNotification(
"OTP sent successfully to your email", "OTP sent successfully to your email",
NOTIFICATION.SUCCESS NOTIFICATION.SUCCESS,
); );
}; };
@ -398,8 +398,16 @@ function YourDetailsForm() {
pushNotification(response?.data?.message, NOTIFICATION.SUCCESS); pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
localStorage.setItem("temp_signup_token", response?.data?.data?.token); localStorage.setItem("temp_signup_token", response?.data?.data?.token);
// open new page for stripe payment from url // open new page for stripe payment from url
let newWindow = window.open(response?.data?.data?.url, "_blank", "noopener,noreferrer"); let newWindow = window.open(
if (!newWindow || newWindow.closed || typeof newWindow.closed === 'undefined') { response?.data?.data?.url,
"_blank",
"noopener,noreferrer",
);
if (
!newWindow ||
newWindow.closed ||
typeof newWindow.closed === "undefined"
) {
// Fallback in case popup is blocked // Fallback in case popup is blocked
window.location.href = response?.data?.data?.url; window.location.href = response?.data?.data?.url;
} }
@ -434,7 +442,7 @@ function YourDetailsForm() {
event.target.value, event.target.value,
formik, formik,
setLocalityOption, setLocalityOption,
selectedLocalityRef selectedLocalityRef,
); );
}; };
@ -477,12 +485,12 @@ function YourDetailsForm() {
await uploadToS3( await uploadToS3(
value, value,
presignedUrlResponseClinicLogo?.data?.data?.api_url presignedUrlResponseClinicLogo?.data?.data?.api_url,
); );
formik.setFieldValue( formik.setFieldValue(
"clinicLogo", "clinicLogo",
presignedUrlResponseClinicLogo?.data?.data?.key presignedUrlResponseClinicLogo?.data?.data?.key,
); );
// Return a temporary local URL for preview purposes // Return a temporary local URL for preview purposes
@ -515,7 +523,7 @@ function YourDetailsForm() {
rejectedFiles.forEach((rejection) => { rejectedFiles.forEach((rejection) => {
pushNotification( pushNotification(
`${rejection?.file?.name} : ${rejection?.errors?.[0]?.message}`, `${rejection?.file?.name} : ${rejection?.errors?.[0]?.message}`,
NOTIFICATION.ERROR NOTIFICATION.ERROR,
); );
}); });
}; };
@ -558,7 +566,7 @@ function YourDetailsForm() {
0, 0,
0, 0,
crop.width, crop.width,
crop.height crop.height,
); );
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -613,7 +621,7 @@ function YourDetailsForm() {
phone: `${ phone: `${
inputData.businessPhonePrefix ?? mobilePrefixOptions[0].name inputData.businessPhonePrefix ?? mobilePrefixOptions[0].name
} ${inputData.businessPhone}`, } ${inputData.businessPhone}`,
emergencyPhone: `${ emergency_phone: `${
inputData.emergencyBusinessPhonePrefix ?? mobilePrefixOptions[0].name inputData.emergencyBusinessPhonePrefix ?? mobilePrefixOptions[0].name
} ${inputData.emergencyBusinessPhone}`, } ${inputData.emergencyBusinessPhone}`,
fax: inputData.businessFax, fax: inputData.businessFax,
@ -750,20 +758,20 @@ function YourDetailsForm() {
value={formik.values.name} value={formik.values.name}
onChange={(e) => { onChange={(e) => {
e.target.value = capitalizeFirstLetter( e.target.value = capitalizeFirstLetter(
e.target.value e.target.value,
); );
formik.handleChange(e); formik.handleChange(e);
}} }}
onBlur={(e) => { onBlur={(e) => {
formik.setFieldValue( formik.setFieldValue(
"name", "name",
e.target.value.trim() e.target.value.trim(),
); );
formik.handleBlur(e); formik.handleBlur(e);
}} }}
inputRef={fieldRefs.name} inputRef={fieldRefs.name}
error={Boolean( error={Boolean(
formik.errors.name && formik.touched.name formik.errors.name && formik.touched.name,
)} )}
helperText={ helperText={
formik.errors.name && formik.touched.name formik.errors.name && formik.touched.name
@ -792,7 +800,7 @@ function YourDetailsForm() {
e.target.value?.match(/\d+/g) || ""; e.target.value?.match(/\d+/g) || "";
formik.setFieldValue( formik.setFieldValue(
"mobileNumber", "mobileNumber",
value?.toString() value?.toString(),
); );
} }
}} }}
@ -830,7 +838,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.mobileNumber} inputRef={fieldRefs.mobileNumber}
error={Boolean( error={Boolean(
formik.errors.mobileNumber && formik.errors.mobileNumber &&
formik.touched.mobileNumber formik.touched.mobileNumber,
)} )}
helperText={ helperText={
formik.errors.mobileNumber && formik.errors.mobileNumber &&
@ -858,7 +866,7 @@ function YourDetailsForm() {
disabled={otpVerified} disabled={otpVerified}
inputRef={fieldRefs.email} inputRef={fieldRefs.email}
error={Boolean( error={Boolean(
formik.errors.email && formik.touched.email formik.errors.email && formik.touched.email,
)} )}
helperText={ helperText={
formik.errors.email && formik.touched.email formik.errors.email && formik.touched.email
@ -929,7 +937,7 @@ function YourDetailsForm() {
}} }}
inputRef={fieldRefs.otp} inputRef={fieldRefs.otp}
error={Boolean( error={Boolean(
formik.errors.otp && formik.touched.otp formik.errors.otp && formik.touched.otp,
)} )}
helperText={ helperText={
formik.errors.otp && formik.touched.otp formik.errors.otp && formik.touched.otp
@ -962,7 +970,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.password} inputRef={fieldRefs.password}
error={Boolean( error={Boolean(
formik.errors.password && formik.errors.password &&
formik.touched.password formik.touched.password,
)} )}
helperText={ helperText={
formik.errors.password && formik.errors.password &&
@ -998,25 +1006,25 @@ function YourDetailsForm() {
<Box className={classes.passwordCheckList}> <Box className={classes.passwordCheckList}>
<PasswordValidation <PasswordValidation
isValid={passwordLengthRegex.test( isValid={passwordLengthRegex.test(
formik.values.password formik.values.password,
)} )}
text="at least 8 characters" text="at least 8 characters"
/> />
<PasswordValidation <PasswordValidation
isValid={passwordLetterRegex.test( isValid={passwordLetterRegex.test(
formik.values.password formik.values.password,
)} )}
text="at least 1 letter" text="at least 1 letter"
/> />
<PasswordValidation <PasswordValidation
isValid={passwordNumberRegex.test( isValid={passwordNumberRegex.test(
formik.values.password formik.values.password,
)} )}
text="at least 1 number" text="at least 1 number"
/> />
<PasswordValidation <PasswordValidation
isValid={passwordSpacesRegex.test( isValid={passwordSpacesRegex.test(
formik.values.password formik.values.password,
)} )}
text="with no spaces at the beginning/end" text="with no spaces at the beginning/end"
/> />
@ -1047,7 +1055,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.confirmPassword} inputRef={fieldRefs.confirmPassword}
error={Boolean( error={Boolean(
formik.errors.confirmPassword && formik.errors.confirmPassword &&
formik.touched.confirmPassword formik.touched.confirmPassword,
)} )}
helperText={ helperText={
formik.errors.confirmPassword && formik.errors.confirmPassword &&
@ -1060,7 +1068,7 @@ function YourDetailsForm() {
<IconButton <IconButton
onClick={() => onClick={() =>
handleTogglePasswordVisibility( handleTogglePasswordVisibility(
"confirmPassword" "confirmPassword",
) )
} }
edge="end" edge="end"
@ -1100,21 +1108,21 @@ function YourDetailsForm() {
value={formik.values.companyName} value={formik.values.companyName}
onChange={(e) => { onChange={(e) => {
e.target.value = capitalizeFirstLetter( e.target.value = capitalizeFirstLetter(
e.target.value e.target.value,
); );
formik.handleChange(e); formik.handleChange(e);
}} }}
onBlur={(e) => { onBlur={(e) => {
formik.setFieldValue( formik.setFieldValue(
"companyName", "companyName",
e.target.value.trim() e.target.value.trim(),
); );
formik.handleBlur(e); formik.handleBlur(e);
}} }}
inputRef={fieldRefs.companyName} inputRef={fieldRefs.companyName}
error={Boolean( error={Boolean(
formik.errors.companyName && formik.errors.companyName &&
formik.touched.companyName formik.touched.companyName,
)} )}
helperText={ helperText={
formik.errors.companyName && formik.errors.companyName &&
@ -1139,7 +1147,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.designation} inputRef={fieldRefs.designation}
error={Boolean( error={Boolean(
formik.errors.designation && formik.errors.designation &&
formik.touched.designation formik.touched.designation,
)} )}
helperText={ helperText={
formik.errors.designation && formik.errors.designation &&
@ -1175,7 +1183,7 @@ function YourDetailsForm() {
e.target.value?.match(/\d+/g) || ""; e.target.value?.match(/\d+/g) || "";
formik.setFieldValue( formik.setFieldValue(
"businessPhone", "businessPhone",
value?.toString() value?.toString(),
); );
} }
}} }}
@ -1215,7 +1223,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.businessPhone} inputRef={fieldRefs.businessPhone}
error={Boolean( error={Boolean(
formik.errors.businessPhone && formik.errors.businessPhone &&
formik.touched.businessPhone formik.touched.businessPhone,
)} )}
helperText={ helperText={
formik.errors.businessPhone && formik.errors.businessPhone &&
@ -1245,7 +1253,7 @@ function YourDetailsForm() {
e.target.value?.match(/\d+/g) || ""; e.target.value?.match(/\d+/g) || "";
formik.setFieldValue( formik.setFieldValue(
"emergencyBusinessPhone", "emergencyBusinessPhone",
value?.toString() value?.toString(),
); );
} }
}} }}
@ -1288,7 +1296,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.emergencyBusinessPhone} inputRef={fieldRefs.emergencyBusinessPhone}
error={Boolean( error={Boolean(
formik.errors.emergencyBusinessPhone && formik.errors.emergencyBusinessPhone &&
formik.touched.emergencyBusinessPhone formik.touched.emergencyBusinessPhone,
)} )}
helperText={ helperText={
formik.errors.emergencyBusinessPhone && formik.errors.emergencyBusinessPhone &&
@ -1318,7 +1326,7 @@ function YourDetailsForm() {
e.target.value?.match(/\d+/g) || ""; e.target.value?.match(/\d+/g) || "";
formik.setFieldValue( formik.setFieldValue(
"businessFax", "businessFax",
value?.toString() value?.toString(),
); );
} }
}} }}
@ -1330,7 +1338,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.businessFax} inputRef={fieldRefs.businessFax}
error={Boolean( error={Boolean(
formik.errors.businessFax && formik.errors.businessFax &&
formik.touched.businessFax formik.touched.businessFax,
)} )}
helperText={ helperText={
formik.errors.businessFax && formik.errors.businessFax &&
@ -1362,7 +1370,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.businessEmail} inputRef={fieldRefs.businessEmail}
error={Boolean( error={Boolean(
formik.errors.businessEmail && formik.errors.businessEmail &&
formik.touched.businessEmail formik.touched.businessEmail,
)} )}
helperText={ helperText={
formik.errors.businessEmail && formik.errors.businessEmail &&
@ -1389,7 +1397,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.practiceManagementSystem} inputRef={fieldRefs.practiceManagementSystem}
error={Boolean( error={Boolean(
formik.errors.practiceManagementSystem && formik.errors.practiceManagementSystem &&
formik.touched.practiceManagementSystem formik.touched.practiceManagementSystem,
)} )}
helperText={ helperText={
formik.errors.practiceManagementSystem && formik.errors.practiceManagementSystem &&
@ -1652,7 +1660,7 @@ function YourDetailsForm() {
displayEmpty displayEmpty
inputRef={fieldRefs.country} inputRef={fieldRefs.country}
error={Boolean( error={Boolean(
formik.errors.country && formik.touched.country formik.errors.country && formik.touched.country,
)} )}
helperText={formik.errors.country} helperText={formik.errors.country}
> >
@ -1695,7 +1703,7 @@ function YourDetailsForm() {
onBlur={formik.handleBlur} onBlur={formik.handleBlur}
inputRef={fieldRefs.pincode} inputRef={fieldRefs.pincode}
error={Boolean( error={Boolean(
formik.errors.pincode && formik.touched.pincode formik.errors.pincode && formik.touched.pincode,
)} )}
helperText={ helperText={
formik.errors.pincode && formik.touched.pincode formik.errors.pincode && formik.touched.pincode
@ -1746,7 +1754,7 @@ function YourDetailsForm() {
inputRef={fieldRefs.locality} inputRef={fieldRefs.locality}
error={Boolean( error={Boolean(
formik.errors.locality && formik.errors.locality &&
formik.touched.locality formik.touched.locality,
)} )}
helperText={formik.errors.locality} helperText={formik.errors.locality}
> >
@ -1787,14 +1795,14 @@ function YourDetailsForm() {
onBlur={(e) => { onBlur={(e) => {
formik.setFieldValue( formik.setFieldValue(
"fullAddress", "fullAddress",
e.target.value.trim() e.target.value.trim(),
); );
formik.handleBlur(e); formik.handleBlur(e);
}} }}
inputRef={fieldRefs.fullAddress} inputRef={fieldRefs.fullAddress}
error={Boolean( error={Boolean(
formik.errors.fullAddress && formik.errors.fullAddress &&
formik.touched.fullAddress formik.touched.fullAddress,
)} )}
helperText={ helperText={
formik.errors.fullAddress && formik.errors.fullAddress &&
@ -1837,7 +1845,7 @@ function YourDetailsForm() {
e.target.value.length <= ABN_NUMBER_LENGTH e.target.value.length <= ABN_NUMBER_LENGTH
) { ) {
e.target.value = capitalizeAllLetters( e.target.value = capitalizeAllLetters(
e.target.value e.target.value,
); );
formik.handleChange(e); formik.handleChange(e);
} }
@ -1845,14 +1853,14 @@ function YourDetailsForm() {
onBlur={(e) => { onBlur={(e) => {
formik.setFieldValue( formik.setFieldValue(
"companyABNImageNumber", "companyABNImageNumber",
e.target.value.trim() e.target.value.trim(),
); );
formik.handleBlur(e); formik.handleBlur(e);
}} }}
inputRef={fieldRefs.companyABNImageNumber} inputRef={fieldRefs.companyABNImageNumber}
error={Boolean( error={Boolean(
formik.errors.companyABNImageNumber && formik.errors.companyABNImageNumber &&
formik.touched.companyABNImageNumber formik.touched.companyABNImageNumber,
)} )}
helperText={ helperText={
formik.errors.companyABNImageNumber && formik.errors.companyABNImageNumber &&
@ -1938,7 +1946,7 @@ function YourDetailsForm() {
"termsAccepted", "termsAccepted",
formik.values.termsAccepted === "true" formik.values.termsAccepted === "true"
? "false" ? "false"
: "true" : "true",
) )
} }
name="termsAccepted" name="termsAccepted"

View File

@ -17,6 +17,8 @@ import React, { useMemo, useRef, useState } from "react";
import * as Yup from "yup"; import * as Yup from "yup";
import EditIcon from "@mui/icons-material/Edit"; import EditIcon from "@mui/icons-material/Edit";
import CloseIcon from "@mui/icons-material/Close"; import CloseIcon from "@mui/icons-material/Close";
import VisibilityIcon from "@mui/icons-material/Visibility";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
import MultiSelect from "../../components/MultiSelect"; import MultiSelect from "../../components/MultiSelect";
/* ----------------- Custom Imports ----------------- */ /* ----------------- Custom Imports ----------------- */
@ -46,7 +48,7 @@ const validationSchema = Yup.object().shape({
userType: Yup.string().required("User Type is required"), userType: Yup.string().required("User Type is required"),
appointmentType: Yup.array().min( appointmentType: Yup.array().min(
1, 1,
"At least one appointment type is required" "At least one appointment type is required",
), ),
}); });
@ -59,6 +61,11 @@ function Users() {
{ id: "nurse", name: "Nurse" }, { id: "nurse", name: "Nurse" },
]; ];
const userStatus = [
{ id: "active", name: "Active" },
{ id: "inactive", name: "Inactive" },
];
/* ----------------- State Variables ----------------- */ /* ----------------- State Variables ----------------- */
const [deleteModal, setDeleteModal] = useState(false); const [deleteModal, setDeleteModal] = useState(false);
const [userTotalCount, setUserTotalCount] = useState(0); const [userTotalCount, setUserTotalCount] = useState(0);
@ -72,6 +79,7 @@ function Users() {
userType: userTypes[0].id, userType: userTypes[0].id,
appointmentType: [], appointmentType: [],
appointmentTypeObject: {}, appointmentTypeObject: {},
status: "active",
}; };
/* ----------------- Get Users ----------------- */ /* ----------------- Get Users ----------------- */
@ -92,15 +100,16 @@ function Users() {
}; };
const editUser = async (row) => { const editUser = async (row) => {
const { id, name, role, appointmentTypes } = row.original; const { id, name, role, appointmentTypes, status } = row.original;
// Set form values for editing // Set form values for editing
formik.setValues({ formik.setValues({
id, id,
userName: name || '', userName: name || "",
userType: role || userTypes[0]?.id || '', userType: role || userTypes[0]?.id || "",
appointmentType: Array.isArray(appointmentTypes) ? appointmentTypes : [], appointmentType: Array.isArray(appointmentTypes) ? appointmentTypes : [],
appointmentTypeObject: {} appointmentTypeObject: {},
status: status || "active",
}); });
setIsEditUser(true); setIsEditUser(true);
@ -119,6 +128,7 @@ function Users() {
name: values.userName, name: values.userName,
role: values.userType, role: values.userType,
appointmentTypes: values.appointmentType.map((type) => type.id), appointmentTypes: values.appointmentType.map((type) => type.id),
status: values.status,
}; };
let resp; let resp;
@ -136,7 +146,7 @@ function Users() {
pushNotification( pushNotification(
`${isEditUser ? "User updated" : "User added"} successfully`, `${isEditUser ? "User updated" : "User added"} successfully`,
NOTIFICATION.SUCCESS NOTIFICATION.SUCCESS,
); );
await ref.current?.reFetchData(); await ref.current?.reFetchData();
@ -196,14 +206,20 @@ function Users() {
}, },
{ {
size: 100, size: 100,
accessorFn: ({ name }) => (name ? name.charAt(0).toUpperCase() + name.slice(1) : NOT_AVAILABLE_TEXT), accessorFn: ({ name }) =>
name
? name.charAt(0).toUpperCase() + name.slice(1)
: NOT_AVAILABLE_TEXT,
accessorKey: "name", accessorKey: "name",
header: "Doctor/Nurse Name", header: "Doctor/Nurse Name",
isBold: true, isBold: true,
}, },
{ {
size: 100, size: 100,
accessorFn: ({ role }) => (role ? role.charAt(0).toUpperCase() + role.slice(1) : NOT_AVAILABLE_TEXT), accessorFn: ({ role }) =>
role
? role.charAt(0).toUpperCase() + role.slice(1)
: NOT_AVAILABLE_TEXT,
accessorKey: "role", accessorKey: "role",
header: "User Type", header: "User Type",
}, },
@ -276,12 +292,15 @@ function Users() {
}, },
{ {
size: 100, size: 100,
accessorFn: ({ status }) => (status ? status[0].toUpperCase() + status.slice(1) : NOT_AVAILABLE_TEXT), accessorFn: ({ status }) =>
status
? status[0].toUpperCase() + status.slice(1)
: NOT_AVAILABLE_TEXT,
accessorKey: "status", accessorKey: "status",
header: "Status", header: "Status",
}, },
], ],
[classes.dateStyle] [classes.dateStyle],
); );
const getRowStyle = (row) => const getRowStyle = (row) =>
@ -408,6 +427,27 @@ function Users() {
))} ))}
</Select> </Select>
<Typography variant="subtitle2" gutterBottom sx={{ mb: 1 }}>
User Status
</Typography>
<Select
name="status"
label="User Status"
value={formik.values.status}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
fullWidth
error={formik.touched.status && Boolean(formik.errors.status)}
sx={{ mb: 3 }}
>
{userStatus.map((status) => (
<MenuItem key={status.id} value={status.id}>
{status.name}
</MenuItem>
))}
</Select>
<Typography variant="subtitle2" gutterBottom sx={{ mb: 1 }}> <Typography variant="subtitle2" gutterBottom sx={{ mb: 1 }}>
Appointment Types Appointment Types
</Typography> </Typography>