dev-jaanvi #1
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -11,7 +11,7 @@
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.14.0",
|
||||||
"@mui/icons-material": "^6.3.0",
|
"@mui/icons-material": "^6.3.0",
|
||||||
"@mui/material": "^6.4.4",
|
"@mui/material": "^6.3.0",
|
||||||
"@mui/x-charts": "^7.23.2",
|
"@mui/x-charts": "^7.23.2",
|
||||||
"@mui/x-data-grid": "^7.23.5",
|
"@mui/x-data-grid": "^7.23.5",
|
||||||
"@mui/x-date-pickers": "^7.23.3",
|
"@mui/x-date-pickers": "^7.23.3",
|
||||||
|
@ -41,6 +41,7 @@
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"react-toastify": "^11.0.2",
|
"react-toastify": "^11.0.2",
|
||||||
"RichTreeView": "file:@mui/x-tree-view/RichTreeView",
|
"RichTreeView": "file:@mui/x-tree-view/RichTreeView",
|
||||||
|
"sonner": "^1.7.4",
|
||||||
"Stack": "file:@mui/material/Stack",
|
"Stack": "file:@mui/material/Stack",
|
||||||
"styles": "file:@mui/material/styles",
|
"styles": "file:@mui/material/styles",
|
||||||
"Tabs": "file:@mui/material/Tabs",
|
"Tabs": "file:@mui/material/Tabs",
|
||||||
|
@ -16347,6 +16348,16 @@
|
||||||
"websocket-driver": "^0.7.4"
|
"websocket-driver": "^0.7.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/sonner": {
|
||||||
|
"version": "1.7.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/sonner/-/sonner-1.7.4.tgz",
|
||||||
|
"integrity": "sha512-DIS8z4PfJRbIyfVFDVnK9rO3eYDtse4Omcm6bt0oEr5/jtLgysmjuBl1frJ9E/EQZrFmKx2A8m/s5s9CRXIzhw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-list-map": {
|
"node_modules/source-list-map": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz",
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"react-toastify": "^11.0.2",
|
"react-toastify": "^11.0.2",
|
||||||
"RichTreeView": "file:@mui/x-tree-view/RichTreeView",
|
"RichTreeView": "file:@mui/x-tree-view/RichTreeView",
|
||||||
|
"sonner": "^1.7.4",
|
||||||
"Stack": "file:@mui/material/Stack",
|
"Stack": "file:@mui/material/Stack",
|
||||||
"styles": "file:@mui/material/styles",
|
"styles": "file:@mui/material/styles",
|
||||||
"Tabs": "file:@mui/material/Tabs",
|
"Tabs": "file:@mui/material/Tabs",
|
||||||
|
|
|
@ -75,27 +75,7 @@ const AddEditCategoryModal: React.FC<AddEditCategoryModalProps> = ({
|
||||||
>
|
>
|
||||||
<DialogTitle>{editRow ? "Edit" : "Add"} Category</DialogTitle>
|
<DialogTitle>{editRow ? "Edit" : "Add"} Category</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<Controller
|
|
||||||
name="category"
|
|
||||||
control={control}
|
|
||||||
rules={{
|
|
||||||
required: "Category Name is required",
|
|
||||||
}}
|
|
||||||
render={({ field }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
autoFocus
|
|
||||||
required
|
|
||||||
margin="dense"
|
|
||||||
label="Add Category Name"
|
|
||||||
type="text"
|
|
||||||
fullWidth
|
|
||||||
variant="standard"
|
|
||||||
error={!!errors.category}
|
|
||||||
helperText={errors.category?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Controller
|
<Controller
|
||||||
name="name"
|
name="name"
|
||||||
control={control}
|
control={control}
|
||||||
|
@ -134,6 +114,7 @@ const AddEditCategoryModal: React.FC<AddEditCategoryModalProps> = ({
|
||||||
variant="standard"
|
variant="standard"
|
||||||
error={!!errors.role}
|
error={!!errors.role}
|
||||||
helperText={errors.role?.message}
|
helperText={errors.role?.message}
|
||||||
|
disabled
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -44,7 +44,7 @@ type PropType = {
|
||||||
export default function MenuContent({ hidden }: PropType) {
|
export default function MenuContent({ hidden }: PropType) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const userRole = useSelector(
|
const userRole = useSelector(
|
||||||
(state: RootState) => state.profile.user?.role
|
(state: RootState) => state.profileReducer.user?.role
|
||||||
);
|
);
|
||||||
|
|
||||||
const mainListItems = [
|
const mainListItems = [
|
||||||
|
|
|
@ -12,6 +12,7 @@ import MoreVertRoundedIcon from "@mui/icons-material/MoreVertRounded";
|
||||||
import MenuButton from "../MenuButton";
|
import MenuButton from "../MenuButton";
|
||||||
import { Avatar } from "@mui/material";
|
import { Avatar } from "@mui/material";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
const MenuItem = styled(MuiMenuItem)({
|
const MenuItem = styled(MuiMenuItem)({
|
||||||
margin: "2px 0",
|
margin: "2px 0",
|
||||||
|
@ -40,6 +41,7 @@ export default function OptionsMenu({ avatar }: { avatar?: boolean }) {
|
||||||
const handlelogout = () => {
|
const handlelogout = () => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
navigate("/auth/login");
|
navigate("/auth/login");
|
||||||
|
toast.success("Logged out successfully");
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
|
|
@ -34,7 +34,7 @@ export default function SideMenu() {
|
||||||
//Dispatch is called with user from Authstate Interface
|
//Dispatch is called with user from Authstate Interface
|
||||||
|
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
const { user } = useSelector((state: RootState) => state?.profile);
|
const { user } = useSelector((state: RootState) => state?.profileReducer);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(fetchAdminProfile());
|
dispatch(fetchAdminProfile());
|
||||||
|
|
|
@ -5,20 +5,14 @@ import reportWebVitals from "./reportWebVitals";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
import store from "./redux/store/store.ts";
|
import store from "./redux/store/store.ts";
|
||||||
import { Slide, ToastContainer } from "react-toastify";
|
import { Toaster } from "sonner";
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(document.getElementById("root"));
|
const root = ReactDOM.createRoot(document.getElementById("root"));
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<App />
|
<App />
|
||||||
<ToastContainer
|
<Toaster position="top-right" richColors />
|
||||||
autoClose={2000}
|
|
||||||
hideProgressBar
|
|
||||||
theme="dark"
|
|
||||||
transition={Slide}
|
|
||||||
toastStyle={{ border: "1px solid dimgray" }}
|
|
||||||
/>
|
|
||||||
</Provider>
|
</Provider>
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default function AdminList() {
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
|
|
||||||
// Fetching admin data from the Redux store
|
// Fetching admin data from the Redux store
|
||||||
const admins = useSelector((state: RootState) => state.admin.admins);
|
const admins = useSelector((state: RootState) => state.adminReducer.admins);
|
||||||
|
|
||||||
// Dispatching the API call when the component mounts
|
// Dispatching the API call when the component mounts
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { loginUser } from '../../../redux/slices/authSlice.ts';
|
||||||
import ColorModeSelect from '../../../shared-theme/ColorModeSelect.tsx';
|
import ColorModeSelect from '../../../shared-theme/ColorModeSelect.tsx';
|
||||||
import AppTheme from '../../../shared-theme/AppTheme.tsx';
|
import AppTheme from '../../../shared-theme/AppTheme.tsx';
|
||||||
import ForgotPassword from './ForgotPassword.tsx';
|
import ForgotPassword from './ForgotPassword.tsx';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'sonner';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
const Card = styled(MuiCard)(({ theme }) => ({
|
const Card = styled(MuiCard)(({ theme }) => ({
|
||||||
|
|
|
@ -20,7 +20,7 @@ import ColorModeSelect from "../../../shared-theme/ColorModeSelect.tsx";
|
||||||
import MuiPhoneNumber from "mui-phone-number";
|
import MuiPhoneNumber from "mui-phone-number";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { registerUser } from "../../../redux/slices/authSlice.ts";
|
import { registerUser } from "../../../redux/slices/authSlice.ts";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "sonner";
|
||||||
import { InputLabel, MenuItem, Select } from "@mui/material";
|
import { InputLabel, MenuItem, Select } from "@mui/material";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ const ProfilePage = () => {
|
||||||
//date:- 12-Feb-2025
|
//date:- 12-Feb-2025
|
||||||
//Dispatch is called and user, isLoading, and error from Authstate Interface
|
//Dispatch is called and user, isLoading, and error from Authstate Interface
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
const { user, isLoading, error } = useSelector(
|
const { user, isLoading } = useSelector(
|
||||||
(state: RootState) => state?.profile
|
(state: RootState) => state?.profileReducer
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -46,16 +46,6 @@ const ProfilePage = () => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<Typography variant="h5" color="error" gutterBottom>
|
|
||||||
<h2>An error occurred while loading profile</h2>
|
|
||||||
</Typography>
|
|
||||||
</Container>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container sx={{ py: 4 }}>
|
<Container sx={{ py: 4 }}>
|
||||||
<Typography variant="h4" gutterBottom>
|
<Typography variant="h4" gutterBottom>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
|
||||||
import http from "../../lib/https";
|
import http from "../../lib/https";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
// Interfaces
|
// Interfaces
|
||||||
interface User {
|
interface User {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
|
||||||
import http from "../../lib/https";
|
import http from "../../lib/https";
|
||||||
import { toast } from "react-toastify";
|
// import { toast } from "react-toastify";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
// Define types for state
|
// Define types for state
|
||||||
//Eknoor singh
|
//Eknoor singh
|
||||||
|
@ -9,12 +10,6 @@ import { toast } from "react-toastify";
|
||||||
interface User {
|
interface User {
|
||||||
data: any;
|
data: any;
|
||||||
token: string | null;
|
token: string | null;
|
||||||
map(
|
|
||||||
arg0: (
|
|
||||||
admin: { name: any; role: any; email: any; phone: any },
|
|
||||||
index: number
|
|
||||||
) => { srno: number; name: any; role: any; email: any; phone: any }
|
|
||||||
): unknown;
|
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
@ -72,7 +67,7 @@ export const registerUser = createAsyncThunk<
|
||||||
role: string;
|
role: string;
|
||||||
},
|
},
|
||||||
{ rejectValue: string }
|
{ rejectValue: string }
|
||||||
>("auth/signup", async (data, { rejectWithValue }) => {
|
>("SignUpUser", async (data, { rejectWithValue }) => {
|
||||||
try {
|
try {
|
||||||
const response = await http.post("auth/signup", data);
|
const response = await http.post("auth/signup", data);
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||||
import http from "../../lib/https";
|
import http from "../../lib/https";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
token: string | null;
|
token: string | null;
|
||||||
|
@ -34,6 +35,7 @@ export const fetchAdminProfile = createAsyncThunk<
|
||||||
|
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
toast.error("Error fetching Profile");
|
||||||
return rejectWithValue(
|
return rejectWithValue(
|
||||||
error?.response?.data?.message || "An error occurred"
|
error?.response?.data?.message || "An error occurred"
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
import { configureStore } from '@reduxjs/toolkit';
|
import { configureStore } from "@reduxjs/toolkit";
|
||||||
import authReducer from '../slices/authSlice.ts'
|
import rootReducer from "../reducers.ts";
|
||||||
import adminReducer from "../slices/adminSlice.ts"
|
|
||||||
import profileReducer from "../slices/profileSlice.ts"
|
|
||||||
const store = configureStore({
|
const store = configureStore({
|
||||||
reducer: {
|
reducer: rootReducer,
|
||||||
auth: authReducer,
|
|
||||||
admin: adminReducer,
|
|
||||||
profile: profileReducer
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type RootState = ReturnType<typeof store.getState>;
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
export type AppDispatch = typeof store.dispatch;
|
export type AppDispatch = typeof store.dispatch;
|
||||||
export default store;
|
export default store;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ caps, component }) => {
|
||||||
// Super Admin Route Component
|
// Super Admin Route Component
|
||||||
const SuperAdminRoute: React.FC<SuperAdminRouteProps> = ({ children }) => {
|
const SuperAdminRoute: React.FC<SuperAdminRouteProps> = ({ children }) => {
|
||||||
const userRole = useSelector(
|
const userRole = useSelector(
|
||||||
(state: RootState) => state.profile.user?.role
|
(state: RootState) => state.profileReducer.user?.role
|
||||||
);
|
);
|
||||||
|
|
||||||
if (userRole !== "superadmin") {
|
if (userRole !== "superadmin") {
|
||||||
|
|
Loading…
Reference in a new issue