Add Business Logo
{(logoImage || formik.values.companyLogo) && (
diff --git a/src/views/Signup/signupReducer.js b/src/views/Signup/signupReducer.js
index df8b818..26d073c 100644
--- a/src/views/Signup/signupReducer.js
+++ b/src/views/Signup/signupReducer.js
@@ -14,7 +14,7 @@ const initialState = {
currentEmail: '',
companyName: '',
designation: '',
- companyWebsite: '',
+ businessPhone: '',
companyAbout: '',
companyLogo: '',
companyIndustry: '',
diff --git a/src/views/User/index.jsx b/src/views/User/index.jsx
index a68965e..6a2b06b 100644
--- a/src/views/User/index.jsx
+++ b/src/views/User/index.jsx
@@ -1,60 +1,61 @@
-import { LoadingButton } from '@mui/lab';
-import { Box, Grid, MenuItem, Select, TextField } from '@mui/material';
-import { useFormik } from 'formik';
-import React, { useMemo, useRef, useState } from 'react';
-import { useSelector } from 'react-redux';
-import * as Yup from 'yup';
+import { LoadingButton } from "@mui/lab";
+import { Box, Button, Grid, MenuItem, Select, Switch, TextField } from "@mui/material";
+import { useFormik } from "formik";
+import React, { useMemo, useRef, useState } from "react";
+import { useSelector } from "react-redux";
+import * as Yup from "yup";
/* ----------------- Custom Imports ----------------- */
-import PageHeader from '../../components/PageHeader';
-import Table from '../../components/Table';
-import ConfirmationModal from '../Modal/ConfirmationModal';
-import CustomModal from '../Modal/Modal';
-import { useStyles } from './userStyles';
+import PageHeader from "../../components/PageHeader";
+import Table from "../../components/Table";
+import ConfirmationModal from "../Modal/ConfirmationModal";
+import CustomModal from "../Modal/Modal";
+import { useStyles } from "./userStyles";
/* ----------------- Assets ----------------- */
-import SendIcon from '@mui/icons-material/Send';
-import AddIcon from '@mui/icons-material/Add';
-import DeleteIcon from '@mui/icons-material/Delete';
-import EditIcon from '@mui/icons-material/Edit';
-import RemoveIcon from '@mui/icons-material/Remove';
+import SendIcon from "@mui/icons-material/Send";
+import AddIcon from "@mui/icons-material/Add";
+import DeleteIcon from "@mui/icons-material/Delete";
+import EditIcon from "@mui/icons-material/Edit";
+import RemoveIcon from "@mui/icons-material/Remove";
import {
+ getUsers,
deleteUserById,
getRoles,
getUserById,
resendPasswordMailer,
revokeAdminTransferAccess,
transferMasterAdminAccess,
-} from '../../services/users.services';
+} from "../../services/users.service";
/* ----------------- Utils ----------------- */
-import { format } from 'date-fns';
-import MultiSelect from '../../components/MultiSelect';
-import { NOTIFICATION, NOT_AVAILABLE_TEXT } from '../../constants';
-import { pushNotification } from '../../utils/notification';
+import { format } from "date-fns";
+import MultiSelect from "../../components/MultiSelect";
+import { NOTIFICATION, NOT_AVAILABLE_TEXT } from "../../constants";
+import { pushNotification } from "../../utils/notification";
/* ----------------- Validation Schema ----------------- */
const validationSchema = Yup.object().shape({
- userName: Yup.string().required('User Name is required'),
+ userName: Yup.string().required("User Name is required"),
email: Yup.string()
- .email('Invalid Email Address')
- .required('Email is required'),
+ .email("Invalid Email Address")
+ .required("Email is required"),
mobile: Yup.string()
- .matches(/^\d{10}$/, 'Mobile Number must be exactly 10 digits')
- .required('Mobile Number is required'),
+ .matches(/^\d{10}$/, "Mobile Number must be exactly 10 digits")
+ .required("Mobile Number is required"),
});
function Users() {
const ref = useRef(null);
const defaultFormData = useRef({
- userName: '',
- email: 'q@gmail.com',
- mobile: '1234567890',
+ userName: "",
+ email: "q@gmail.com",
+ mobile: "1234567890",
isEditUser: false,
- lastName: '',
- userType: '',
+ lastName: "",
+ userType: "",
appointmentType: [],
- appointmentTypeObject: '',
+ appointmentTypeObject: "",
});
const fieldRefs = {
@@ -74,9 +75,6 @@ function Users() {
const [isEditUser, setIsEditUser] = useState(false);
const [deleteModal, setDeleteModal] = useState(false);
const [masterAdminModal, setMasterAdminModal] = useState(false);
- const [revokeAdminAccessRequestModal, setRevokeAdminAccessRequestModal] =
- useState(false);
- const [seletedUserData, setSelectedUserData] = useState();
const [buttonLoading, setButtonLoading] = useState(false);
const [userId, setUserId] = useState();
const [userTotalCount, setUserTotalCount] = useState(0);
@@ -84,28 +82,41 @@ function Users() {
const [checkboxError, setCheckboxError] = useState(false);
const [roles, setRoles] = useState();
const [isAdmin, setIsAdmin] = useState();
- const [hasProfileCompleted, setHasProfileCompleted] = useState(false);
- const [
- requestRaisedForTransferMasterAdminAccess,
- setRequestRaisedForTransferMasterAdminAccess,
- ] = useState(false);
const isBsAdmin = useSelector((state) => state?.login?.user?.isBsAdmin);
/* ----------------- Get Users ----------------- */
const getData = async (filters) => {
const resp = await getUsers(filters);
+ console.log(resp);
+ console.log(resp?.data?.totalCount);
setUserTotalCount(resp?.data?.totalCount);
- setRequestRaisedForTransferMasterAdminAccess(
- resp.data?.requestRaisedForTransferMasterAdminAccess
- );
- const role = await getRoles();
- setRoles(role?.data?.data);
+ const role = await getRoles({ page: 0 });
+ setRoles(role?.data);
return { data: resp?.data?.records, rowCount: resp?.data?.totalCount };
};
+ const handleToggleButton = async (row) => {
+ try {
+ // Replace this with your actual API call to update user status
+ // Example: await updateUserStatus(row.id, !row.isActive);
+
+ // For now, just show a notification
+ pushNotification(
+ `${row.name}'s status has been ${row.isActive ? 'deactivated' : 'activated'}`,
+ NOTIFICATION.SUCCESS
+ );
+
+ // Refresh the table data
+ ref.current.reFetchData();
+ } catch (error) {
+ console.error(error);
+ pushNotification('Failed to update status', NOTIFICATION.ERROR);
+ }
+ };
+
/* ----------------- Handle Submit ----------------- */
const handleSubmit = async (values, formik) => {
try {
@@ -143,7 +154,7 @@ function Users() {
// if (response.status === 200) {
// pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
- pushNotification('Doctor added successfully', NOTIFICATION.SUCCESS);
+ pushNotification("Doctor added successfully", NOTIFICATION.SUCCESS);
// ref.current.reFetchData();
toggle();
formik.resetForm();
@@ -162,60 +173,6 @@ function Users() {
setShowModal(!showModal);
};
- /* ----------------- Edit User ----------------- */
- const editUser = async (row) => {
- try {
- const { data: { data: userData } = {} } = await getUserById(
- row?.original?.id
- );
- const formData = {
- userName: userData?.name,
- email: userData?.email,
- mobile: userData?.mobile,
- password: userData?.password,
- transferMasterAdminAccess: false,
- isEditUser: true,
- };
- setIsAdmin(userData?.isAdmin);
- setHasProfileCompleted(userData?.hasProfileCompleted);
- const updatedCheckboxes = roles.reduce(
- (acc, role) => ({
- ...acc,
- [role?.id]: userData?.roles.some(
- (roleData) => roleData?.id === role?.id
- ),
- }),
- {}
- );
-
- setSelectedCheckboxes(updatedCheckboxes);
- formik.setValues(formData);
- toggle();
- setIsEditUser(true);
- setUserId(row?.original?.id);
- } catch ({ resp }) {
- // eslint-disable-next-line no-console
- console.error(resp?.data?.message);
- }
- };
-
- const resendPasswordSetupMailer = (row) => {
- try {
- const response = resendPasswordMailer(row?.original?.email);
- if (response.status === 200) {
- pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
- }
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error(error);
- }
- };
-
- /* ----------------- Revoke Admin Access Request ----------------- */
- const revokeAdminAccessRequest = async () => {
- setRevokeAdminAccessRequestModal(true);
- };
-
/* ----------------- Handle Checkbox Change ----------------- */
const handleCheckboxChange = (id, isChecked) => {
setSelectedCheckboxes({ ...selectedCheckboxes, [id]: isChecked });
@@ -226,7 +183,7 @@ function Users() {
() => [
{
size: 30,
- header: 'S.no.',
+ header: "S.no.",
Cell: (props) => {
const tableState = props?.table?.getState();
const serialNumber = (
@@ -235,59 +192,57 @@ function Users() {
tableState?.pagination?.pageIndex * tableState?.pagination?.pageSize
)
?.toString()
- ?.padStart(1, '0');
+ ?.padStart(1, "0");
return {serialNumber}.;
},
enableSorting: false,
},
{
accessorFn: ({ name }) => name || NOT_AVAILABLE_TEXT,
- accessorKey: 'name',
- header: 'Doctor/Nurse Name',
+ accessorKey: "name",
+ header: "Doctor/Nurse Name",
isBold: true,
},
- // {
- // accessorKey: 'roles',
- // header: 'User Access',
- // enableSorting: false,
- // Cell: ({ row }) => (
- //
- // {row.original.roles && row.original.roles.length > 0
- // ? row.original.roles.map((role, index) => (
- //
- // {role.name}
- // {index !== row.original.roles.length - 1 ? ', ' : ''}
- //
- // ))
- // : NOT_AVAILABLE_TEXT}
- // {row.original.isAdmin && ', Master Admin'}
- //
- // ),
- // },
{
accessorFn: ({ mobile }) => mobile || NOT_AVAILABLE_TEXT,
- accessorKey: 'mobile',
- header: 'User Type',
+ accessorKey: "userType",
+ header: "User Type",
},
{
accessorFn: ({ email }) => email || NOT_AVAILABLE_TEXT,
- accessorKey: 'email',
- header: 'Specialties',
+ accessorKey: "specialities",
+ header: "Specialties",
},
{
- accessorKey: 'createdAt',
+ accessorKey: "createdAt",
Cell: ({ row }) => (
- {format(new Date(row?.original?.createdAt), 'dd MMM, yyyy')}
+ {format(new Date(row?.original?.createdAt), "dd MMM, yyyy")}
),
- header: 'Added On',
+ header: "Added On",
},
{
accessorFn: ({ email }) => email || NOT_AVAILABLE_TEXT,
- accessorKey: 'email',
- header: 'Status',
+ accessorKey: "status",
+ header: "Status",
},
+ {
+ size: 30,
+ accessorKey: "actions",
+ header: "Actions",
+ enableSorting: false,
+ Cell: ({ row }) => (
+
+ handleToggleButton(row?.original)}
+ inputProps={{ "aria-label": "Status toggle" }}
+ color="primary"
+ />
+
+ ),
+ }
],
[]
);
@@ -314,10 +269,6 @@ function Users() {
setSelectedUserData(row?.original);
};
- const revokeAdminAccessToggle = () => {
- setRevokeAdminAccessRequestModal(!revokeAdminAccessRequestModal);
- };
-
/* ----------------- Transfer Master Admin Access to User ----------------- */
const handleTransferMasterAdminAccess = async () => {
setButtonLoading(true);
@@ -355,24 +306,6 @@ function Users() {
setButtonLoading(false);
}
};
- /* ----------------- Revoke Admin Access ----------------- */
- const handleRevokeAdminAccessRequest = async () => {
- setButtonLoading(true);
- try {
- const response = await revokeAdminTransferAccess();
- if (response.status === 200) {
- pushNotification(response?.data?.message, NOTIFICATION.SUCCESS);
- ref.current.resetPage(true);
- setRevokeAdminAccessRequestModal(false);
- }
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error(error?.response?.data?.message);
- } finally {
- ref.current.reFetchData();
- setButtonLoading(false);
- }
- };
const handleuserAccessCancel = () => {
setCheckboxError(false);
@@ -380,7 +313,7 @@ function Users() {
};
const getRowStyle = (row) =>
- row?.original?.isAdmin ? { backgroundColor: '#E7F4EE !important' } : {};
+ row?.original?.isAdmin ? { backgroundColor: "#E7F4EE !important" } : {};
const handleSubmitClick = async () => {
const formikErrors = await formik.validateForm();
@@ -393,10 +326,10 @@ function Users() {
if (firstErrorRef) {
// Scroll to the first invalid field smoothly
- if (typeof firstErrorRef?.scrollIntoView === 'function') {
+ if (typeof firstErrorRef?.scrollIntoView === "function") {
firstErrorRef?.scrollIntoView({
- behavior: 'smooth',
- block: 'center',
+ behavior: "smooth",
+ block: "center",
});
}
@@ -429,49 +362,26 @@ function Users() {
columns={columns}
getData={getData}
options={{ enableRowSelection: false }}
- showAction={true}
+ // showAction={true}
hideShowPerPage={true}
showSearchBox={true}
ref={ref}
- searchText={'user'}
+ searchText={"user"}
getRowStyle={getRowStyle}
- actions={[
- {
- onClick: makeMasterAdminToggle,
- text: 'Make User Master Admin',
- icon: ,
- renderAction: (row) => isBsAdmin && !row?.original?.isAdmin,
- },
- {
- onClick: revokeAdminAccessRequest,
- text: 'Revoke Admin Access Request',
- icon: ,
- // permissionName: "CREATE_USERS",
- renderAction: (row) => row?.original?.transferMasterAdminAccess,
- },
- {
- onClick: editUser,
- text: 'Edit',
- icon: ,
- // permissionName: "CREATE_USERS",
- },
- {
- onClick: (row) => resendPasswordSetupMailer(row),
- text: 'Resend password setup mailer',
- icon: ,
- renderAction: (row) => !row?.original?.hasProfileCompleted,
- // permissionName: "CREATE_USERS",
- },
- {
- onClick: deleteUserToggle,
- text: 'Delete',
- icon: ,
- renderAction: (row) => !row?.original?.isAdmin,
- // permissionName: 'DELETE_USERS',
- // isDisabledValue: user?.id,
- rowKey: 'id',
- },
- ].filter(Boolean)}
+ // actions={[
+ // {
+ // title: "Action",
+ // field: "isActive",
+ // render: (rowData) => (
+ // handleToggleButton(rowData)}
+ // inputProps={{ "aria-label": "Status toggle" }}
+ // color="primary"
+ // />
+ // ),
+ // },
+ // ]}
/>