{typesArray.length > 0 ? (
typesArray.map((type, index) => {
- const label = typeof type === 'string'
- ? type
- : type?.name || type?.type || String(type);
-
+ const label =
+ typeof type === "string"
+ ? type
+ : type?.name || type?.type || String(type);
+
return (
);
@@ -276,12 +251,12 @@ function Users() {
label={NOT_AVAILABLE_TEXT}
size="small"
variant="outlined"
- sx={{
- margin: '2px',
- borderRadius: '16px',
- backgroundColor: '#f0f0f0',
- color: '#757575',
- '& .MuiChip-label': { fontSize: '0.75rem' }
+ sx={{
+ margin: "2px",
+ borderRadius: "16px",
+ backgroundColor: "#f0f0f0",
+ color: "#757575",
+ "& .MuiChip-label": { fontSize: "0.75rem" },
}}
/>
)}
@@ -290,135 +265,31 @@ function Users() {
},
},
{
- accessorKey: "createdAt",
+ size: 150,
+ accessorKey: "create_time",
Cell: ({ row }) => (
- {format(new Date(row?.original?.createdAt), "dd MMM, yyyy")}
+ {format(new Date(row?.original?.create_time), "dd MMM, yyyy")}
),
header: "Added On",
},
{
- accessorFn: ({ email }) => email || NOT_AVAILABLE_TEXT,
+ size: 100,
+ accessorFn: ({ status }) => status || NOT_AVAILABLE_TEXT,
accessorKey: "status",
header: "Status",
},
- {
- size: 30,
- accessorKey: "actions",
- header: "Actions",
- enableSorting: false,
- Cell: ({ row }) => (
-
- handleToggleButton(row?.original)}
- inputProps={{ "aria-label": "Status toggle" }}
- color="primary"
- />
-
- ),
- }
],
- []
+ [classes.dateStyle]
);
- const formik = useFormik({
- initialValues: defaultFormData.current,
- validationSchema,
- onSubmit: (values) => handleSubmit(values, formik),
- });
-
- /* ----------------- Handle Cancel ----------------- */
- const handleCancel = () => {
- toggle();
- formik.resetForm();
- };
-
- const deleteUserToggle = (row) => {
- setDeleteModal(!deleteModal);
- setSelectedUserData(row?.original);
- };
-
- const makeMasterAdminToggle = (row) => {
- setMasterAdminModal((prev) => !prev);
- setSelectedUserData(row?.original);
- };
-
- /* ----------------- Transfer Master Admin Access to User ----------------- */
- const handleTransferMasterAdminAccess = async () => {
- setButtonLoading(true);
- try {
- const response = await transferMasterAdminAccess(seletedUserData?.id);
- if (response.status === 200) {
- pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
- ref.current.resetPage(true);
- makeMasterAdminToggle();
- }
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error(error?.response?.data?.message);
- } finally {
- ref.current.reFetchData();
- setButtonLoading(false);
- }
- };
-
- /* ----------------- Delete User ----------------- */
- const deleteUser = async () => {
- setButtonLoading(true);
- try {
- const response = await deleteUserById(seletedUserData?.id);
- if (response.status === 200) {
- pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
- ref.current.resetPage(true);
- deleteUserToggle();
- }
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error(error?.response?.data?.message);
- } finally {
- ref.current.reFetchData();
- setButtonLoading(false);
- }
- };
-
- const handleuserAccessCancel = () => {
- setCheckboxError(false);
- setShowUserAccessModal(false);
- };
-
const getRowStyle = (row) =>
row?.original?.isAdmin ? { backgroundColor: "#E7F4EE !important" } : {};
- const handleSubmitClick = async () => {
- const formikErrors = await formik.validateForm();
- const errors = Object.keys(formikErrors);
-
- if (errors.length) {
- // Find the first invalid field and focus it
- const firstErrorField = errors[0];
- const firstErrorRef = fieldRefs[firstErrorField]?.current;
-
- if (firstErrorRef) {
- // Scroll to the first invalid field smoothly
- if (typeof firstErrorRef?.scrollIntoView === "function") {
- firstErrorRef?.scrollIntoView({
- behavior: "smooth",
- block: "center",
- });
- }
-
- // Focus the field after a slight delay (to ensure scrolling completes first)
- setTimeout(() => firstErrorRef.focus(), 300);
- }
-
- // Show error notification
- if (formik?.touched[firstErrorField])
- pushNotification(formikErrors[firstErrorField], NOTIFICATION.ERROR);
- }
-
- formik.handleSubmit();
+ // Function to get option label for MultiSelect
+ const getAppointmentTypeLabel = (option) => {
+ return option?.name || option?.type || option?.label || String(option);
};
return (
@@ -426,10 +297,8 @@ function Users() {
}
- addButtonDisabled={userTotalCount === 10}
- // permissionName={'CREATE_USERS'}
infiniteDropdown
/>
@@ -439,7 +308,7 @@ function Users() {
getData={getData}
options={{ enableRowSelection: false }}
showAction={true}
- hideShowPerPage={true}
+ hideShowPerPage={false}
showSearchBox={true}
ref={ref}
searchText={"user"}
@@ -447,285 +316,183 @@ function Users() {
actions={[
{
onClick: editUser,
- text: 'Edit',
- icon: (
-
- ),
- // permissionName: "CREATE_USERS",
+ text: "Edit",
+ icon: ,
+ },
+ {
+ onClick: (row) => deleteUserToggle(row.original.id),
+ text: "Delete",
+ icon: ,
},
]}
/>
- {/* --------------- ADD User Modal --------------- */}
- {showModal && !showUserAccessModal && (
-