implemented feedback changes

This commit is contained in:
jaanvi 2025-02-17 16:07:24 +05:30
parent be5de3ac9e
commit a105ad3ab4
16 changed files with 18951 additions and 18983 deletions

37843
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,7 @@
"react-scripts": "5.0.1",
"react-toastify": "^11.0.2",
"RichTreeView": "file:@mui/x-tree-view/RichTreeView",
"sonner": "^1.7.4",
"Stack": "file:@mui/material/Stack",
"styles": "file:@mui/material/styles",
"Tabs": "file:@mui/material/Tabs",

View file

@ -75,27 +75,7 @@ const AddEditCategoryModal: React.FC<AddEditCategoryModalProps> = ({
>
<DialogTitle>{editRow ? "Edit" : "Add"} Category</DialogTitle>
<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
name="name"
control={control}
@ -134,6 +114,7 @@ const AddEditCategoryModal: React.FC<AddEditCategoryModalProps> = ({
variant="standard"
error={!!errors.role}
helperText={errors.role?.message}
disabled
/>
)}
/>

View file

@ -44,7 +44,7 @@ type PropType = {
export default function MenuContent({ hidden }: PropType) {
const location = useLocation();
const userRole = useSelector(
(state: RootState) => state.profile.user?.role
(state: RootState) => state.profileReducer.user?.role
);
const mainListItems = [

View file

@ -12,6 +12,7 @@ import MoreVertRoundedIcon from "@mui/icons-material/MoreVertRounded";
import MenuButton from "../MenuButton";
import { Avatar } from "@mui/material";
import { useNavigate } from "react-router-dom";
import { toast } from "sonner";
const MenuItem = styled(MuiMenuItem)({
margin: "2px 0",
@ -40,6 +41,7 @@ export default function OptionsMenu({ avatar }: { avatar?: boolean }) {
const handlelogout = () => {
localStorage.clear();
navigate("/auth/login");
toast.success("Logged out successfully");
};
return (
<React.Fragment>

View file

@ -34,7 +34,7 @@ export default function SideMenu() {
//Dispatch is called with user from Authstate Interface
const dispatch = useDispatch<AppDispatch>();
const { user } = useSelector((state: RootState) => state?.profile);
const { user } = useSelector((state: RootState) => state?.profileReducer);
useEffect(() => {
dispatch(fetchAdminProfile());

View file

@ -5,20 +5,14 @@ import reportWebVitals from "./reportWebVitals";
import App from "./App";
import { Provider } from "react-redux";
import store from "./redux/store/store.ts";
import { Slide, ToastContainer } from "react-toastify";
import { Toaster } from "sonner";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<Provider store={store}>
<App />
<ToastContainer
autoClose={2000}
hideProgressBar
theme="dark"
transition={Slide}
toastStyle={{ border: "1px solid dimgray" }}
/>
<Toaster position="top-right" richColors />
</Provider>
</React.StrictMode>
);

View file

@ -17,7 +17,7 @@ export default function AdminList() {
const dispatch = useDispatch<AppDispatch>();
// 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
useEffect(() => {

View file

@ -19,7 +19,7 @@ import { loginUser } from '../../../redux/slices/authSlice.ts';
import ColorModeSelect from '../../../shared-theme/ColorModeSelect.tsx';
import AppTheme from '../../../shared-theme/AppTheme.tsx';
import ForgotPassword from './ForgotPassword.tsx';
import { toast } from 'react-toastify';
import { toast } from 'sonner';
import { useNavigate } from 'react-router-dom';
const Card = styled(MuiCard)(({ theme }) => ({

View file

@ -20,7 +20,7 @@ import ColorModeSelect from "../../../shared-theme/ColorModeSelect.tsx";
import MuiPhoneNumber from "mui-phone-number";
import { useDispatch } from "react-redux";
import { registerUser } from "../../../redux/slices/authSlice.ts";
import { toast } from "react-toastify";
import { toast } from "sonner";
import { InputLabel, MenuItem, Select } from "@mui/material";
import { useNavigate } from "react-router-dom";

View file

@ -23,8 +23,8 @@ const ProfilePage = () => {
//date:- 12-Feb-2025
//Dispatch is called and user, isLoading, and error from Authstate Interface
const dispatch = useDispatch<AppDispatch>();
const { user, isLoading, error } = useSelector(
(state: RootState) => state?.profile
const { user, isLoading } = useSelector(
(state: RootState) => state?.profileReducer
);
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 (
<Container sx={{ py: 4 }}>
<Typography variant="h4" gutterBottom>

View file

@ -1,6 +1,6 @@
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
import http from "../../lib/https";
import { toast } from "react-toastify";
import { toast } from "sonner";
// Interfaces
interface User {

View file

@ -1,6 +1,7 @@
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
import http from "../../lib/https";
import { toast } from "react-toastify";
// import { toast } from "react-toastify";
import { toast } from "sonner";
// Define types for state
//Eknoor singh
@ -9,12 +10,6 @@ import { toast } from "react-toastify";
interface User {
data: any;
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;
name: string;
email: string;
@ -72,7 +67,7 @@ export const registerUser = createAsyncThunk<
role: string;
},
{ rejectValue: string }
>("auth/signup", async (data, { rejectWithValue }) => {
>("SignUpUser", async (data, { rejectWithValue }) => {
try {
const response = await http.post("auth/signup", data);
return response.data;

View file

@ -1,5 +1,6 @@
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import http from "../../lib/https";
import { toast } from "sonner";
interface User {
token: string | null;
@ -34,6 +35,7 @@ export const fetchAdminProfile = createAsyncThunk<
return response.data.data;
} catch (error: any) {
toast.error("Error fetching Profile");
return rejectWithValue(
error?.response?.data?.message || "An error occurred"
);

View file

@ -1,17 +1,9 @@
import { configureStore } from '@reduxjs/toolkit';
import authReducer from '../slices/authSlice.ts'
import adminReducer from "../slices/adminSlice.ts"
import profileReducer from "../slices/profileSlice.ts"
import { configureStore } from "@reduxjs/toolkit";
import rootReducer from "../reducers.ts";
const store = configureStore({
reducer: {
auth: authReducer,
admin: adminReducer,
profile: profileReducer
},
reducer: rootReducer,
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export default store;

View file

@ -38,7 +38,7 @@ const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ caps, component }) => {
// Super Admin Route Component
const SuperAdminRoute: React.FC<SuperAdminRouteProps> = ({ children }) => {
const userRole = useSelector(
(state: RootState) => state.profile.user?.role
(state: RootState) => state.profileReducer.user?.role
);
if (userRole !== "superadmin") {