feat: bank details update for clinic admin
fix: clinic doc status refactor: minor code changes
This commit is contained in:
parent
25f1043e90
commit
f8b0ba54ba
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
|
||||
// material-ui
|
||||
import {
|
||||
|
|
@ -11,20 +11,24 @@ import {
|
|||
ListItemText,
|
||||
Paper,
|
||||
Popper,
|
||||
} from '@mui/material';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
} from "@mui/material";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
|
||||
// assets
|
||||
import signoutImg from '../../../assets/images/icon/signout.svg';
|
||||
import phoneImg from '../../../assets/images/icon/phone.svg';
|
||||
import signoutImg from "../../../assets/images/icon/signout.svg";
|
||||
import phoneImg from "../../../assets/images/icon/phone.svg";
|
||||
import settingsImg from "../../../assets/images/icon/settings.svg";
|
||||
|
||||
import { useStyles } from '../mainLayoutStyles';
|
||||
import MainCard from './MainCard';
|
||||
import Transitions from './Transitions';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { commonLogoutFunc } from '../../../utils/share';
|
||||
import defaultProfilePicture from '../../../assets/images/icon/defaultProfileIcon.svg';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useStyles } from "../mainLayoutStyles";
|
||||
import MainCard from "./MainCard";
|
||||
import Transitions from "./Transitions";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { commonLogoutFunc } from "../../../utils/share";
|
||||
import defaultProfilePicture from "../../../assets/images/icon/defaultProfileIcon.svg";
|
||||
import { useSelector } from "react-redux";
|
||||
import { getStripeAccountLink } from "../../../services/users.service";
|
||||
import { pushNotification } from "../../../utils/notification";
|
||||
import { NOTIFICATION, USER_ROLES } from "../../../constants";
|
||||
|
||||
// ==============================|| PROFILE MENU ||============================== //
|
||||
|
||||
|
|
@ -35,15 +39,25 @@ const ProfileSection = () => {
|
|||
const [open, setOpen] = useState(false);
|
||||
const [showPopup, setShowPopup] = useState(false);
|
||||
// const [showTransactionHistoryPopup, setShowTransactionHistoryPopup] =
|
||||
useState(false);
|
||||
useState(false);
|
||||
const anchorRef = useRef(null);
|
||||
|
||||
const user = useSelector((state) => state?.login?.user);
|
||||
const isSuperAdmin = user?.isSuperAdmin;
|
||||
|
||||
const companyStatus = useSelector(
|
||||
(state) => state?.login?.user?.company?.status
|
||||
);
|
||||
const getAccountLink = async () => {
|
||||
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) => {
|
||||
if (anchorRef.current && anchorRef.current.contains(event.target)) {
|
||||
|
|
@ -66,16 +80,23 @@ const ProfileSection = () => {
|
|||
}, [open]);
|
||||
|
||||
const menuItems = [
|
||||
|
||||
{ id: 1, img: phoneImg, text: 'Contact Us', alt: 'contactUsImg' },
|
||||
{ id: 2, img: signoutImg, text: 'Sign Out', alt: 'signoutImg' },
|
||||
{ id: 1, img: phoneImg, text: "Contact Us", alt: "contactUsImg" },
|
||||
// Only show Bank Details for clinic admin users
|
||||
...(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);
|
||||
|
||||
const renderProfile = (item, index) => (
|
||||
<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}>
|
||||
<img
|
||||
style={{ width: "20px", height: "20px" }}
|
||||
|
|
@ -86,9 +107,6 @@ const ProfileSection = () => {
|
|||
</Box>
|
||||
<ListItemText className={classes.listText} primary={item.text} />
|
||||
</ListItem>
|
||||
{index === menuItems.length - 2 && (
|
||||
<Divider component="li" key={`divider-${item.id}`} className={classes.dividerDiv} />
|
||||
)}
|
||||
</>
|
||||
}
|
||||
</React.Fragment>
|
||||
|
|
@ -100,16 +118,15 @@ const ProfileSection = () => {
|
|||
// navigate('/contact-us');
|
||||
break;
|
||||
case 2:
|
||||
commonLogoutFunc();
|
||||
getAccountLink();
|
||||
break;
|
||||
case 3:
|
||||
// setShowTransactionHistoryPopup(true);
|
||||
commonLogoutFunc();
|
||||
break;
|
||||
case 4:
|
||||
setShowPopup(true);
|
||||
break;
|
||||
case 5:
|
||||
commonLogoutFunc();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -125,7 +142,7 @@ const ProfileSection = () => {
|
|||
<Box
|
||||
className={classes.profileSection}
|
||||
ref={anchorRef}
|
||||
aria-controls={open ? 'menu-list-grow' : undefined}
|
||||
aria-controls={open ? "menu-list-grow" : undefined}
|
||||
onClick={handleToggle}
|
||||
aria-haspopup="true"
|
||||
>
|
||||
|
|
@ -145,7 +162,7 @@ const ProfileSection = () => {
|
|||
transition
|
||||
disablePortal
|
||||
popperOptions={{
|
||||
modifiers: [{ name: 'offset', options: { offset: [0, 14] } }],
|
||||
modifiers: [{ name: "offset", options: { offset: [0, 14] } }],
|
||||
}}
|
||||
>
|
||||
{({ TransitionProps }) => (
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export const getUsers = (params) => {
|
|||
|
||||
export const getUserById = (id) => {
|
||||
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) => {
|
||||
|
|
@ -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) => {
|
||||
const url = "/users";
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -169,30 +112,8 @@ export const changePassword = (data) => {
|
|||
.catch((err) => reject(err));
|
||||
});
|
||||
};
|
||||
export const updateMailersSettings = (data) => {
|
||||
const url = "/users/me/mail-notification";
|
||||
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";
|
||||
|
||||
export const getStripeAccountLink = () => {
|
||||
const url = "/stripe/create-stripe-account-link";
|
||||
return new Promise((resolve, reject) => {
|
||||
axiosInstance
|
||||
.get(url)
|
||||
|
|
@ -200,60 +121,3 @@ export const companyMe = () => {
|
|||
.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));
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ function YourDetailsForm() {
|
|||
.matches(passwordNumberRegex, "Password must contain at least one number")
|
||||
.matches(
|
||||
passwordSpacesRegex,
|
||||
"Password must not start or end with a space"
|
||||
"Password must not start or end with a space",
|
||||
)
|
||||
.required("Password is required"),
|
||||
confirmPassword: Yup.string()
|
||||
|
|
@ -249,7 +249,7 @@ function YourDetailsForm() {
|
|||
.min(10, "Business Phone number should have 10 digits only.")
|
||||
.max(10, "Business Phone number should have 10 digits only."),
|
||||
businessPhonePrefix: Yup.string().required(
|
||||
"Business Phone Prefix is required"
|
||||
"Business Phone Prefix is required",
|
||||
),
|
||||
emergencyBusinessPhone: Yup.string()
|
||||
.required("Emergency Business Phone is required")
|
||||
|
|
@ -257,7 +257,7 @@ function YourDetailsForm() {
|
|||
.min(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(
|
||||
"Emergency Business Phone Prefix is required"
|
||||
"Emergency Business Phone Prefix is required",
|
||||
),
|
||||
businessEmail: Yup.string()
|
||||
.required("Business Email is required")
|
||||
|
|
@ -279,7 +279,7 @@ function YourDetailsForm() {
|
|||
.required("ABN number is required")
|
||||
.matches(
|
||||
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"),
|
||||
companyABNImage: Yup.string().required("Clinic ABN document is required"),
|
||||
|
|
@ -300,11 +300,11 @@ function YourDetailsForm() {
|
|||
const countryShort =
|
||||
formik.values.country === "Australia" ? "au" : "in";
|
||||
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);
|
||||
setLocalityOption(
|
||||
resp?.data?.places?.map((object) => object["place name"])
|
||||
resp?.data?.places?.map((object) => object["place name"]),
|
||||
);
|
||||
formik.setFieldValue("locality", selectedLocalityRef.current);
|
||||
} catch (error) {
|
||||
|
|
@ -315,9 +315,9 @@ function YourDetailsForm() {
|
|||
pushNotification("Invalid pincode", NOTIFICATION.ERROR);
|
||||
}
|
||||
},
|
||||
1000
|
||||
1000,
|
||||
),
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
const handleTogglePasswordVisibility = (field) => {
|
||||
|
|
@ -325,7 +325,7 @@ function YourDetailsForm() {
|
|||
setShowPassword((prevShowPassword) => !prevShowPassword);
|
||||
} else if (field === "confirmPassword") {
|
||||
setShowConfirmPassword(
|
||||
(prevShowConfirmPassword) => !prevShowConfirmPassword
|
||||
(prevShowConfirmPassword) => !prevShowConfirmPassword,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
@ -348,7 +348,7 @@ function YourDetailsForm() {
|
|||
}
|
||||
pushNotification(
|
||||
"OTP sent successfully to your email",
|
||||
NOTIFICATION.SUCCESS
|
||||
NOTIFICATION.SUCCESS,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -398,8 +398,16 @@ function YourDetailsForm() {
|
|||
pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
|
||||
localStorage.setItem("temp_signup_token", response?.data?.data?.token);
|
||||
// open new page for stripe payment from url
|
||||
let newWindow = window.open(response?.data?.data?.url, "_blank", "noopener,noreferrer");
|
||||
if (!newWindow || newWindow.closed || typeof newWindow.closed === 'undefined') {
|
||||
let newWindow = window.open(
|
||||
response?.data?.data?.url,
|
||||
"_blank",
|
||||
"noopener,noreferrer",
|
||||
);
|
||||
if (
|
||||
!newWindow ||
|
||||
newWindow.closed ||
|
||||
typeof newWindow.closed === "undefined"
|
||||
) {
|
||||
// Fallback in case popup is blocked
|
||||
window.location.href = response?.data?.data?.url;
|
||||
}
|
||||
|
|
@ -434,7 +442,7 @@ function YourDetailsForm() {
|
|||
event.target.value,
|
||||
formik,
|
||||
setLocalityOption,
|
||||
selectedLocalityRef
|
||||
selectedLocalityRef,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -477,12 +485,12 @@ function YourDetailsForm() {
|
|||
|
||||
await uploadToS3(
|
||||
value,
|
||||
presignedUrlResponseClinicLogo?.data?.data?.api_url
|
||||
presignedUrlResponseClinicLogo?.data?.data?.api_url,
|
||||
);
|
||||
|
||||
formik.setFieldValue(
|
||||
"clinicLogo",
|
||||
presignedUrlResponseClinicLogo?.data?.data?.key
|
||||
presignedUrlResponseClinicLogo?.data?.data?.key,
|
||||
);
|
||||
|
||||
// Return a temporary local URL for preview purposes
|
||||
|
|
@ -515,7 +523,7 @@ function YourDetailsForm() {
|
|||
rejectedFiles.forEach((rejection) => {
|
||||
pushNotification(
|
||||
`${rejection?.file?.name} : ${rejection?.errors?.[0]?.message}`,
|
||||
NOTIFICATION.ERROR
|
||||
NOTIFICATION.ERROR,
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
@ -558,7 +566,7 @@ function YourDetailsForm() {
|
|||
0,
|
||||
0,
|
||||
crop.width,
|
||||
crop.height
|
||||
crop.height,
|
||||
);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -613,7 +621,7 @@ function YourDetailsForm() {
|
|||
phone: `${
|
||||
inputData.businessPhonePrefix ?? mobilePrefixOptions[0].name
|
||||
} ${inputData.businessPhone}`,
|
||||
emergencyPhone: `${
|
||||
emergency_phone: `${
|
||||
inputData.emergencyBusinessPhonePrefix ?? mobilePrefixOptions[0].name
|
||||
} ${inputData.emergencyBusinessPhone}`,
|
||||
fax: inputData.businessFax,
|
||||
|
|
@ -750,20 +758,20 @@ function YourDetailsForm() {
|
|||
value={formik.values.name}
|
||||
onChange={(e) => {
|
||||
e.target.value = capitalizeFirstLetter(
|
||||
e.target.value
|
||||
e.target.value,
|
||||
);
|
||||
formik.handleChange(e);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
formik.setFieldValue(
|
||||
"name",
|
||||
e.target.value.trim()
|
||||
e.target.value.trim(),
|
||||
);
|
||||
formik.handleBlur(e);
|
||||
}}
|
||||
inputRef={fieldRefs.name}
|
||||
error={Boolean(
|
||||
formik.errors.name && formik.touched.name
|
||||
formik.errors.name && formik.touched.name,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.name && formik.touched.name
|
||||
|
|
@ -792,7 +800,7 @@ function YourDetailsForm() {
|
|||
e.target.value?.match(/\d+/g) || "";
|
||||
formik.setFieldValue(
|
||||
"mobileNumber",
|
||||
value?.toString()
|
||||
value?.toString(),
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
|
@ -830,7 +838,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.mobileNumber}
|
||||
error={Boolean(
|
||||
formik.errors.mobileNumber &&
|
||||
formik.touched.mobileNumber
|
||||
formik.touched.mobileNumber,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.mobileNumber &&
|
||||
|
|
@ -858,7 +866,7 @@ function YourDetailsForm() {
|
|||
disabled={otpVerified}
|
||||
inputRef={fieldRefs.email}
|
||||
error={Boolean(
|
||||
formik.errors.email && formik.touched.email
|
||||
formik.errors.email && formik.touched.email,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.email && formik.touched.email
|
||||
|
|
@ -929,7 +937,7 @@ function YourDetailsForm() {
|
|||
}}
|
||||
inputRef={fieldRefs.otp}
|
||||
error={Boolean(
|
||||
formik.errors.otp && formik.touched.otp
|
||||
formik.errors.otp && formik.touched.otp,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.otp && formik.touched.otp
|
||||
|
|
@ -962,7 +970,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.password}
|
||||
error={Boolean(
|
||||
formik.errors.password &&
|
||||
formik.touched.password
|
||||
formik.touched.password,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.password &&
|
||||
|
|
@ -998,25 +1006,25 @@ function YourDetailsForm() {
|
|||
<Box className={classes.passwordCheckList}>
|
||||
<PasswordValidation
|
||||
isValid={passwordLengthRegex.test(
|
||||
formik.values.password
|
||||
formik.values.password,
|
||||
)}
|
||||
text="at least 8 characters"
|
||||
/>
|
||||
<PasswordValidation
|
||||
isValid={passwordLetterRegex.test(
|
||||
formik.values.password
|
||||
formik.values.password,
|
||||
)}
|
||||
text="at least 1 letter"
|
||||
/>
|
||||
<PasswordValidation
|
||||
isValid={passwordNumberRegex.test(
|
||||
formik.values.password
|
||||
formik.values.password,
|
||||
)}
|
||||
text="at least 1 number"
|
||||
/>
|
||||
<PasswordValidation
|
||||
isValid={passwordSpacesRegex.test(
|
||||
formik.values.password
|
||||
formik.values.password,
|
||||
)}
|
||||
text="with no spaces at the beginning/end"
|
||||
/>
|
||||
|
|
@ -1047,7 +1055,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.confirmPassword}
|
||||
error={Boolean(
|
||||
formik.errors.confirmPassword &&
|
||||
formik.touched.confirmPassword
|
||||
formik.touched.confirmPassword,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.confirmPassword &&
|
||||
|
|
@ -1060,7 +1068,7 @@ function YourDetailsForm() {
|
|||
<IconButton
|
||||
onClick={() =>
|
||||
handleTogglePasswordVisibility(
|
||||
"confirmPassword"
|
||||
"confirmPassword",
|
||||
)
|
||||
}
|
||||
edge="end"
|
||||
|
|
@ -1100,21 +1108,21 @@ function YourDetailsForm() {
|
|||
value={formik.values.companyName}
|
||||
onChange={(e) => {
|
||||
e.target.value = capitalizeFirstLetter(
|
||||
e.target.value
|
||||
e.target.value,
|
||||
);
|
||||
formik.handleChange(e);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
formik.setFieldValue(
|
||||
"companyName",
|
||||
e.target.value.trim()
|
||||
e.target.value.trim(),
|
||||
);
|
||||
formik.handleBlur(e);
|
||||
}}
|
||||
inputRef={fieldRefs.companyName}
|
||||
error={Boolean(
|
||||
formik.errors.companyName &&
|
||||
formik.touched.companyName
|
||||
formik.touched.companyName,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.companyName &&
|
||||
|
|
@ -1139,7 +1147,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.designation}
|
||||
error={Boolean(
|
||||
formik.errors.designation &&
|
||||
formik.touched.designation
|
||||
formik.touched.designation,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.designation &&
|
||||
|
|
@ -1175,7 +1183,7 @@ function YourDetailsForm() {
|
|||
e.target.value?.match(/\d+/g) || "";
|
||||
formik.setFieldValue(
|
||||
"businessPhone",
|
||||
value?.toString()
|
||||
value?.toString(),
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
|
@ -1215,7 +1223,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.businessPhone}
|
||||
error={Boolean(
|
||||
formik.errors.businessPhone &&
|
||||
formik.touched.businessPhone
|
||||
formik.touched.businessPhone,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.businessPhone &&
|
||||
|
|
@ -1245,7 +1253,7 @@ function YourDetailsForm() {
|
|||
e.target.value?.match(/\d+/g) || "";
|
||||
formik.setFieldValue(
|
||||
"emergencyBusinessPhone",
|
||||
value?.toString()
|
||||
value?.toString(),
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
|
@ -1288,7 +1296,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.emergencyBusinessPhone}
|
||||
error={Boolean(
|
||||
formik.errors.emergencyBusinessPhone &&
|
||||
formik.touched.emergencyBusinessPhone
|
||||
formik.touched.emergencyBusinessPhone,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.emergencyBusinessPhone &&
|
||||
|
|
@ -1318,7 +1326,7 @@ function YourDetailsForm() {
|
|||
e.target.value?.match(/\d+/g) || "";
|
||||
formik.setFieldValue(
|
||||
"businessFax",
|
||||
value?.toString()
|
||||
value?.toString(),
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
|
@ -1330,7 +1338,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.businessFax}
|
||||
error={Boolean(
|
||||
formik.errors.businessFax &&
|
||||
formik.touched.businessFax
|
||||
formik.touched.businessFax,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.businessFax &&
|
||||
|
|
@ -1362,7 +1370,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.businessEmail}
|
||||
error={Boolean(
|
||||
formik.errors.businessEmail &&
|
||||
formik.touched.businessEmail
|
||||
formik.touched.businessEmail,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.businessEmail &&
|
||||
|
|
@ -1389,7 +1397,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.practiceManagementSystem}
|
||||
error={Boolean(
|
||||
formik.errors.practiceManagementSystem &&
|
||||
formik.touched.practiceManagementSystem
|
||||
formik.touched.practiceManagementSystem,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.practiceManagementSystem &&
|
||||
|
|
@ -1652,7 +1660,7 @@ function YourDetailsForm() {
|
|||
displayEmpty
|
||||
inputRef={fieldRefs.country}
|
||||
error={Boolean(
|
||||
formik.errors.country && formik.touched.country
|
||||
formik.errors.country && formik.touched.country,
|
||||
)}
|
||||
helperText={formik.errors.country}
|
||||
>
|
||||
|
|
@ -1695,7 +1703,7 @@ function YourDetailsForm() {
|
|||
onBlur={formik.handleBlur}
|
||||
inputRef={fieldRefs.pincode}
|
||||
error={Boolean(
|
||||
formik.errors.pincode && formik.touched.pincode
|
||||
formik.errors.pincode && formik.touched.pincode,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.pincode && formik.touched.pincode
|
||||
|
|
@ -1746,7 +1754,7 @@ function YourDetailsForm() {
|
|||
inputRef={fieldRefs.locality}
|
||||
error={Boolean(
|
||||
formik.errors.locality &&
|
||||
formik.touched.locality
|
||||
formik.touched.locality,
|
||||
)}
|
||||
helperText={formik.errors.locality}
|
||||
>
|
||||
|
|
@ -1787,14 +1795,14 @@ function YourDetailsForm() {
|
|||
onBlur={(e) => {
|
||||
formik.setFieldValue(
|
||||
"fullAddress",
|
||||
e.target.value.trim()
|
||||
e.target.value.trim(),
|
||||
);
|
||||
formik.handleBlur(e);
|
||||
}}
|
||||
inputRef={fieldRefs.fullAddress}
|
||||
error={Boolean(
|
||||
formik.errors.fullAddress &&
|
||||
formik.touched.fullAddress
|
||||
formik.touched.fullAddress,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.fullAddress &&
|
||||
|
|
@ -1837,7 +1845,7 @@ function YourDetailsForm() {
|
|||
e.target.value.length <= ABN_NUMBER_LENGTH
|
||||
) {
|
||||
e.target.value = capitalizeAllLetters(
|
||||
e.target.value
|
||||
e.target.value,
|
||||
);
|
||||
formik.handleChange(e);
|
||||
}
|
||||
|
|
@ -1845,14 +1853,14 @@ function YourDetailsForm() {
|
|||
onBlur={(e) => {
|
||||
formik.setFieldValue(
|
||||
"companyABNImageNumber",
|
||||
e.target.value.trim()
|
||||
e.target.value.trim(),
|
||||
);
|
||||
formik.handleBlur(e);
|
||||
}}
|
||||
inputRef={fieldRefs.companyABNImageNumber}
|
||||
error={Boolean(
|
||||
formik.errors.companyABNImageNumber &&
|
||||
formik.touched.companyABNImageNumber
|
||||
formik.touched.companyABNImageNumber,
|
||||
)}
|
||||
helperText={
|
||||
formik.errors.companyABNImageNumber &&
|
||||
|
|
@ -1938,7 +1946,7 @@ function YourDetailsForm() {
|
|||
"termsAccepted",
|
||||
formik.values.termsAccepted === "true"
|
||||
? "false"
|
||||
: "true"
|
||||
: "true",
|
||||
)
|
||||
}
|
||||
name="termsAccepted"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import React, { useMemo, useRef, useState } from "react";
|
|||
import * as Yup from "yup";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
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";
|
||||
|
||||
/* ----------------- Custom Imports ----------------- */
|
||||
|
|
@ -46,7 +48,7 @@ const validationSchema = Yup.object().shape({
|
|||
userType: Yup.string().required("User Type is required"),
|
||||
appointmentType: Yup.array().min(
|
||||
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" },
|
||||
];
|
||||
|
||||
const userStatus = [
|
||||
{ id: "active", name: "Active" },
|
||||
{ id: "inactive", name: "Inactive" },
|
||||
];
|
||||
|
||||
/* ----------------- State Variables ----------------- */
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
const [userTotalCount, setUserTotalCount] = useState(0);
|
||||
|
|
@ -72,6 +79,7 @@ function Users() {
|
|||
userType: userTypes[0].id,
|
||||
appointmentType: [],
|
||||
appointmentTypeObject: {},
|
||||
status: "active",
|
||||
};
|
||||
|
||||
/* ----------------- Get Users ----------------- */
|
||||
|
|
@ -92,17 +100,18 @@ function Users() {
|
|||
};
|
||||
|
||||
const editUser = async (row) => {
|
||||
const { id, name, role, appointmentTypes } = row.original;
|
||||
|
||||
const { id, name, role, appointmentTypes, status } = row.original;
|
||||
|
||||
// Set form values for editing
|
||||
formik.setValues({
|
||||
id,
|
||||
userName: name || '',
|
||||
userType: role || userTypes[0]?.id || '',
|
||||
userName: name || "",
|
||||
userType: role || userTypes[0]?.id || "",
|
||||
appointmentType: Array.isArray(appointmentTypes) ? appointmentTypes : [],
|
||||
appointmentTypeObject: {}
|
||||
appointmentTypeObject: {},
|
||||
status: status || "active",
|
||||
});
|
||||
|
||||
|
||||
setIsEditUser(true);
|
||||
setDialogOpen(true);
|
||||
};
|
||||
|
|
@ -119,6 +128,7 @@ function Users() {
|
|||
name: values.userName,
|
||||
role: values.userType,
|
||||
appointmentTypes: values.appointmentType.map((type) => type.id),
|
||||
status: values.status,
|
||||
};
|
||||
|
||||
let resp;
|
||||
|
|
@ -136,7 +146,7 @@ function Users() {
|
|||
|
||||
pushNotification(
|
||||
`${isEditUser ? "User updated" : "User added"} successfully`,
|
||||
NOTIFICATION.SUCCESS
|
||||
NOTIFICATION.SUCCESS,
|
||||
);
|
||||
|
||||
await ref.current?.reFetchData();
|
||||
|
|
@ -196,14 +206,20 @@ function Users() {
|
|||
},
|
||||
{
|
||||
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",
|
||||
header: "Doctor/Nurse Name",
|
||||
isBold: true,
|
||||
},
|
||||
{
|
||||
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",
|
||||
header: "User Type",
|
||||
},
|
||||
|
|
@ -218,9 +234,9 @@ function Users() {
|
|||
Array.isArray(appointmentTypes) && appointmentTypes.length > 0
|
||||
? appointmentTypes
|
||||
: typeof appointmentTypes === "string" &&
|
||||
appointmentTypes.trim() !== ""
|
||||
? appointmentTypes.split(",").map((type) => type.trim())
|
||||
: [];
|
||||
appointmentTypes.trim() !== ""
|
||||
? appointmentTypes.split(",").map((type) => type.trim())
|
||||
: [];
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "wrap", gap: 0.5 }}>
|
||||
|
|
@ -276,12 +292,15 @@ function Users() {
|
|||
},
|
||||
{
|
||||
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",
|
||||
header: "Status",
|
||||
},
|
||||
],
|
||||
[classes.dateStyle]
|
||||
[classes.dateStyle],
|
||||
);
|
||||
|
||||
const getRowStyle = (row) =>
|
||||
|
|
@ -408,6 +427,27 @@ function Users() {
|
|||
))}
|
||||
</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 }}>
|
||||
Appointment Types
|
||||
</Typography>
|
||||
|
|
@ -462,7 +502,7 @@ function Users() {
|
|||
Confirm Deletion
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() =>setDeleteModal(false) }
|
||||
onClick={() => setDeleteModal(false)}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
|
|
|
|||
Loading…
Reference in New Issue