From d21f4f5d2765672d696a5486cb23078c84daa26e Mon Sep 17 00:00:00 2001 From: jaanvi Date: Mon, 3 Mar 2025 13:36:37 +0530 Subject: [PATCH] add functionality to search and password visibility and responsivess added in somepage --- src/components/AddEditCategoryModal/index.tsx | 76 ++++++++++++++----- src/components/AppNavbar/index.tsx | 2 +- src/components/CustomTable/index.tsx | 25 ++++-- src/components/Header/index.tsx | 35 +++++++-- src/pages/AddEditRolePage/index.tsx | 10 ++- src/pages/AdminList/index.tsx | 57 +++++++++++--- src/pages/Auth/Login/index.tsx | 1 - src/pages/RoleList/index.tsx | 64 +++++++++++----- 8 files changed, 199 insertions(+), 71 deletions(-) diff --git a/src/components/AddEditCategoryModal/index.tsx b/src/components/AddEditCategoryModal/index.tsx index 2033bbc..521bbba 100644 --- a/src/components/AddEditCategoryModal/index.tsx +++ b/src/components/AddEditCategoryModal/index.tsx @@ -6,10 +6,12 @@ import { DialogActions, DialogContent, DialogTitle, + IconButton, TextField, } from "@mui/material"; import CloseIcon from "@mui/icons-material/Close"; import { useForm, Controller } from "react-hook-form"; +import { Visibility, VisibilityOff } from "@mui/icons-material"; //By Jaanvi : Edit Model :: 11-feb-25 interface AddEditCategoryModalProps { @@ -86,6 +88,8 @@ const AddEditCategoryModal: React.FC = ({ } }, [editRow, setValue, reset]); + const [showPassword, setShowPassword] = React.useState(false); + return ( = ({ /> )} /> - {!editRow && ( - - )} - />} + {!editRow && ( + ( + <> + + + + setShowPassword((prev) => !prev) + } + > + {showPassword ? ( + + ) : ( + + )} + + + + )} + /> + )} - + {/* */} diff --git a/src/components/CustomTable/index.tsx b/src/components/CustomTable/index.tsx index e995eca..4927964 100644 --- a/src/components/CustomTable/index.tsx +++ b/src/components/CustomTable/index.tsx @@ -127,7 +127,14 @@ const CustomTable: React.FC = ({ return ( - +
{columns.map((column) => ( @@ -136,7 +143,13 @@ const CustomTable: React.FC = ({ align={column.align || "left"} sx={{ whiteSpace: "nowrap", // Prevent wrapping - fontSize: { xs: "12px", sm: "14px" }, // Responsively adjust font size + // fontSize: { xs: "12px", sm: "14px" }, + fontSize: { + xs: "10px", + sm: "12px", + md: "14px", + }, // Adjust font size responsively + padding: { xs: "8px", sm: "12px" }, }} > {column.label} @@ -154,9 +167,11 @@ const CustomTable: React.FC = ({ sx={{ whiteSpace: "nowrap", // Prevent wrapping fontSize: { - xs: "12px", - sm: "14px", - }, // Responsively adjust font size + xs: "10px", + sm: "12px", + md: "14px", + }, // Adjust font size responsively + padding: { xs: "8px", sm: "12px" }, }} > {isImage(row[column.id]) ? ( diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 563cea5..4c3f027 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -12,10 +12,10 @@ import ColorModeIconDropdown from "../../shared-theme/ColorModeIconDropdown"; import NotificationsRoundedIcon from "@mui/icons-material/NotificationsRounded"; export default function Header() { - const [showNotifications, setShowNotifications] = React.useState(false); - const toggleNotifications = () => { - setShowNotifications((prev) => !prev); - }; + const [showNotifications, setShowNotifications] = React.useState(false); + const toggleNotifications = () => { + setShowNotifications((prev) => !prev); + }; return ( @@ -35,11 +36,16 @@ export default function Header() { spacing={3} alignItems="center" justifyContent="flex-end" + sx={{ + width: "100%", + justifyContent: { xs: "center", sm: "flex-end" }, + marginTop: { xs: 2, sm: 0 }, + }} > {/* Search Bar */} {/* Notification and Profile Section */} - + {/* Custom Bell Icon */} {/* diff --git a/src/pages/AddEditRolePage/index.tsx b/src/pages/AddEditRolePage/index.tsx index 65bd82d..3ee8144 100644 --- a/src/pages/AddEditRolePage/index.tsx +++ b/src/pages/AddEditRolePage/index.tsx @@ -157,14 +157,17 @@ const AddEditRolePage: React.FC = () => { {/* Role Name Input */} - + + @@ -270,7 +273,6 @@ const AddEditRolePage: React.FC = () => { autoHideDuration={3000} onClose={() => setOpenSnackbar(false)} message="Role added successfully!" - /> ); diff --git a/src/pages/AdminList/index.tsx b/src/pages/AdminList/index.tsx index f554794..f579f75 100644 --- a/src/pages/AdminList/index.tsx +++ b/src/pages/AdminList/index.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { Box, Button, Typography } from "@mui/material"; +import { Box, Button, TextField, Typography } from "@mui/material"; import AddEditCategoryModal from "../../components/AddEditCategoryModal"; import { useForm } from "react-hook-form"; import CustomTable, { Column } from "../../components/CustomTable"; @@ -10,6 +10,7 @@ import { createAdmin, } from "../../redux/slices/adminSlice"; import { AppDispatch, RootState } from "../../redux/store/store"; +import SearchIcon from "@mui/icons-material/Search"; export default function AdminList() { const [modalOpen, setModalOpen] = useState(false); @@ -22,7 +23,7 @@ export default function AdminList() { const dispatch = useDispatch(); const admins = useSelector((state: RootState) => state.adminReducer.admins); - + const [searchTerm, setSearchTerm] = useState(""); useEffect(() => { dispatch(adminList()); }, [dispatch]); @@ -84,9 +85,18 @@ export default function AdminList() { { id: "registeredAddress", label: "Address" }, { id: "action", label: "Action", align: "center" }, ]; + const filteredAdmins = admins?.filter( + (admin) => + admin.name.toLowerCase().includes(searchTerm.toLowerCase()) || + admin.email.toLowerCase().includes(searchTerm.toLowerCase()) || + admin.phone.toLowerCase().includes(searchTerm.toLowerCase()) || + admin.registeredAddress + .toLowerCase() + .includes(searchTerm.toLowerCase()) + ); - const categoryRows = admins?.length - ? admins?.map( + const categoryRows = filteredAdmins?.length + ? filteredAdmins?.map( ( admin: { id: string; @@ -109,6 +119,19 @@ export default function AdminList() { return ( <> + + Admins + + - - Admins - + setSearchTerm(e.target.value)} + sx={{ + width: { xs: "100%", sm: "30%" }, + marginBottom: { xs: 2, sm: 0 }, + }} + InputProps={{ + startAdornment: ( + + ), + }} + /> +