dev-jaanvi #1

Open
jaanvi wants to merge 155 commits from dev-jaanvi into main
8 changed files with 413 additions and 260 deletions
Showing only changes of commit 709d9e17fc - Show all commits

BIN
public/mainPageLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 KiB

View file

@ -68,7 +68,7 @@ export default function AppNavbar() {
<Typography <Typography
variant="h4" variant="h4"
component="h1" component="h1"
sx={{ color: "text.primary" }} sx={{ color: "#202020" }}
> >
Dashboard Dashboard
</Typography> </Typography>
@ -81,7 +81,6 @@ export default function AppNavbar() {
<SideMenuMobile open={open} toggleDrawer={toggleDrawer} /> <SideMenuMobile open={open} toggleDrawer={toggleDrawer} />
</Stack> </Stack>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
); );
} }

View file

@ -45,14 +45,19 @@ export default function Header() {
sx={{ sx={{
p: 2, p: 2,
position: "absolute", position: "absolute",
top: "55px", // Adjust this value according to your AppBar height top: "55px",
right: "66px", right: "66px",
bgcolor: "lightblue", bgcolor: "background.paper",
boxShadow: 1, boxShadow: 1,
borderRadius: 1, borderRadius: 1,
zIndex: 1300, zIndex: 1300,
cursor: "pointer"
}} }}
> >
{/* <Typography variant="h6" color="text.primary">
Notifications
</Typography> */}
<Typography variant="body2" color="text.secondary"> <Typography variant="body2" color="text.secondary">
No notifications yet No notifications yet
</Typography> </Typography>

View file

@ -10,11 +10,13 @@ import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted";
import { Link, useLocation } from "react-router-dom"; import { Link, useLocation } from "react-router-dom";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { RootState } from "../../redux/store/store"; import { RootState } from "../../redux/store/store";
import DashboardOutlinedIcon from "@mui/icons-material/DashboardOutlined";
import ManageAccountsOutlinedIcon from "@mui/icons-material/ManageAccountsOutlined";
const baseMenuItems = [ const baseMenuItems = [
{ {
text: "Home", text: "Dashboard",
icon: <HomeRoundedIcon />, icon: <DashboardOutlinedIcon />,
url: "/panel/dashboard", url: "/panel/dashboard",
}, },
// { // {
@ -32,7 +34,7 @@ const baseMenuItems = [
const superAdminOnlyItems = [ const superAdminOnlyItems = [
{ {
text: "Admin List", text: "Admin List",
icon: <FormatListBulletedIcon />, icon: <ManageAccountsOutlinedIcon />,
url: "/panel/adminlist", url: "/panel/adminlist",
}, },
]; ];

View file

@ -51,7 +51,7 @@ export default function OptionsMenu({ avatar }: { avatar?: boolean }) {
) : ( ) : (
<Avatar <Avatar
sizes="small" sizes="small"
alt="Riley Carter" alt="Super Admin"
src="/static/images/avatar/7.jpg" src="/static/images/avatar/7.jpg"
sx={{ width: 36, height: 36 }} sx={{ width: 36, height: 36 }}
/> />
@ -117,4 +117,3 @@ export default function OptionsMenu({ avatar }: { avatar?: boolean }) {
</React.Fragment> </React.Fragment>
); );
} }

View file

@ -11,6 +11,9 @@ import NotificationsRoundedIcon from "@mui/icons-material/NotificationsRounded";
import MenuButton from "../MenuButton"; import MenuButton from "../MenuButton";
import MenuContent from "../MenuContent"; import MenuContent from "../MenuContent";
import CardAlert from "../CardAlert/CardAlert"; import CardAlert from "../CardAlert/CardAlert";
import { AppDispatch, RootState } from "../../redux/store/store";
import { useDispatch, useSelector } from "react-redux";
import { fetchAdminProfile } from "../../redux/slices/profileSlice";
interface SideMenuMobileProps { interface SideMenuMobileProps {
open: boolean | undefined; open: boolean | undefined;
@ -21,6 +24,12 @@ export default function SideMenuMobile({
open, open,
toggleDrawer, toggleDrawer,
}: SideMenuMobileProps) { }: SideMenuMobileProps) {
const dispatch = useDispatch<AppDispatch>();
const { user } = useSelector((state: RootState) => state?.profileReducer);
React.useEffect(() => {
dispatch(fetchAdminProfile());
}, [dispatch]);
return ( return (
<Drawer <Drawer
anchor="right" anchor="right"
@ -47,12 +56,12 @@ export default function SideMenuMobile({
> >
<Avatar <Avatar
sizes="small" sizes="small"
alt="Riley Carter" alt={user?.name || "User Avatar"}
src="/static/images/avatar/7.jpg" src="/static/images/avatar/7.jpg"
sx={{ width: 24, height: 24 }} sx={{ width: 24, height: 24 }}
/> />
<Typography component="p" variant="h6"> <Typography component="p" variant="h6">
Riley Carter Super Admin
</Typography> </Typography>
</Stack> </Stack>
<MenuButton showBadge> <MenuButton showBadge>
@ -61,7 +70,7 @@ export default function SideMenuMobile({
</Stack> </Stack>
<Divider /> <Divider />
<Stack sx={{ flexGrow: 1 }}> <Stack sx={{ flexGrow: 1 }}>
<MenuContent /> <MenuContent hidden={false} />
<Divider /> <Divider />
</Stack> </Stack>
<CardAlert /> <CardAlert />

View file

@ -1,18 +1,21 @@
import * as React from "react"; import * as React from "react";
import Box from "@mui/material/Box"; import {
import Button from "@mui/material/Button"; Box,
import Checkbox from "@mui/material/Checkbox"; Button,
import CssBaseline from "@mui/material/CssBaseline"; Checkbox,
import FormControlLabel from "@mui/material/FormControlLabel"; CssBaseline,
import Divider from "@mui/material/Divider"; FormControlLabel,
import FormLabel from "@mui/material/FormLabel"; FormLabel,
import FormControl from "@mui/material/FormControl"; FormControl,
import Link from "@mui/material/Link"; TextField,
import TextField from "@mui/material/TextField"; Typography,
import Typography from "@mui/material/Typography"; Stack,
import Stack from "@mui/material/Stack"; Card as MuiCard,
import MuiCard from "@mui/material/Card"; Grid,
import { styled } from "@mui/material/styles"; IconButton,
Link,
} from "@mui/material";
import { styled, useTheme } from "@mui/material/styles";
import { useForm, Controller, SubmitHandler } from "react-hook-form"; import { useForm, Controller, SubmitHandler } from "react-hook-form";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
import { loginUser } from "../../../redux/slices/authSlice.ts"; import { loginUser } from "../../../redux/slices/authSlice.ts";
@ -21,7 +24,10 @@ import AppTheme from "../../../shared-theme/AppTheme.tsx";
import ForgotPassword from "./ForgotPassword.tsx"; import ForgotPassword from "./ForgotPassword.tsx";
import { toast } from "sonner"; import { toast } from "sonner";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { Visibility, VisibilityOff } from "@mui/icons-material";
import RemoveRedEyeOutlinedIcon from "@mui/icons-material/RemoveRedEyeOutlined";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import { lime, purple } from "@mui/material/colors";
const Card = styled(MuiCard)(({ theme }) => ({ const Card = styled(MuiCard)(({ theme }) => ({
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
@ -29,25 +35,31 @@ const Card = styled(MuiCard)(({ theme }) => ({
width: "100%", width: "100%",
padding: theme.spacing(4), padding: theme.spacing(4),
gap: theme.spacing(2), gap: theme.spacing(2),
margin: "auto", margin: "16px",
backgroundColor: "#1E1F1F",
[theme.breakpoints.up("sm")]: { [theme.breakpoints.up("sm")]: {
maxWidth: "450px", maxWidth: "450px",
}, },
boxShadow: // boxShadow:
"hsla(220, 30%, 5%, 0.05) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.05) 0px 15px 35px -5px", // "hsla(220, 30%, 5%, 0.05) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.05) 0px 15px 35px -5px",
...theme.applyStyles("dark", { // ...theme.applyStyles("dark", {
boxShadow: // boxShadow:
"hsla(220, 30%, 5%, 0.5) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.08) 0px 15px 35px -5px", // "hsla(220, 30%, 5%, 0.5) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.08) 0px 15px 35px -5px",
}), // }),
})); }));
const theme = createTheme({
palette: {
primary: lime,
secondary: purple,
},
});
const SignInContainer = styled(Stack)(({ theme }) => ({ const SignInContainer = styled(Stack)(({ theme }) => ({
height: "calc((1 - var(--template-frame-height, 0)) * 100dvh)", height: "calc((1 - var(--template-frame-height, 0)) * 100dvh)",
minHeight: "100%", minHeight: "100%",
padding: theme.spacing(2), // padding: theme.spacing(2),
[theme.breakpoints.up("sm")]: { // [theme.breakpoints.up("sm")]: {
padding: theme.spacing(4), // padding: theme.spacing(4),
}, // },
"&::before": { "&::before": {
content: '""', content: '""',
display: "block", display: "block",
@ -69,6 +81,9 @@ interface ILoginForm {
} }
export default function Login(props: { disableCustomTheme?: boolean }) { export default function Login(props: { disableCustomTheme?: boolean }) {
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
console.log("theme", theme.palette.background);
const [showPassword, setShowPassword] = React.useState(false);
const { const {
control, control,
handleSubmit, handleSubmit,
@ -98,25 +113,50 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
}; };
return ( return (
<ThemeProvider theme={theme}>
<AppTheme {...props}> <AppTheme {...props}>
<CssBaseline enableColorScheme /> <CssBaseline enableColorScheme />
<SignInContainer direction="column" justifyContent="space-between"> <SignInContainer
<ColorModeSelect direction="column"
justifyContent="space-between"
>
{/* <ColorModeSelect
sx={{ position: "fixed", top: "1rem", right: "1rem" }} sx={{ position: "fixed", top: "1rem", right: "1rem" }}
/> /> */}
<Card variant="outlined">
{/* <SitemarkIcon /> */} <Grid container sx={{ height: "100vh" }}>
Digi-EV <Grid
<Typography item
component="h1" xs={7}
variant="h4"
sx={{ sx={{
width: "100%", background: `url('/mainPageLogo.png') center/cover no-repeat`,
fontSize: "clamp(2rem, 10vw, 2.15rem)", }}
/>
<Grid
item
xs={5}
sx={{
backgroundColor: "black",
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
}} }}
> >
Sign in <Typography
variant="h3"
sx={{
color: "white",
textAlign: "center",
}}
>
Welcome Back!
</Typography> </Typography>
<Card variant="outlined">
{/* <SitemarkIcon /> */}
<Box <Box
component="form" component="form"
onSubmit={handleSubmit(onSubmit)} onSubmit={handleSubmit(onSubmit)}
@ -128,8 +168,33 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
gap: 2, gap: 2,
}} }}
> >
<Typography
component="h1"
variant="h4"
sx={{
width: "100%",
textAlign: "center",
}}
>
Login
</Typography>
<Typography
component="h6"
variant="subtitle2"
sx={{
width: "100%",
textAlign: "center",
}}
>
Log in with your email and password
</Typography>
<FormControl> <FormControl>
<FormLabel htmlFor="email">Email</FormLabel> <FormLabel
htmlFor="email"
sx={{ fontSize: "1rem" }}
>
Email
</FormLabel>
<Controller <Controller
name="email" name="email"
control={control} control={control}
@ -146,17 +211,21 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
<TextField <TextField
{...field} {...field}
error={!!errors.email} error={!!errors.email}
helperText={errors.email?.message} helperText={
errors.email?.message
}
id="email" id="email"
type="email" type="email"
placeholder="your@email.com" placeholder="Email"
autoComplete="email" autoComplete="email"
autoFocus autoFocus
required required
fullWidth fullWidth
variant="outlined" variant="outlined"
color={ color={
errors.email ? "error" : "primary" errors.email
? "error"
: "primary"
} }
/> />
)} )}
@ -164,13 +233,19 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormLabel htmlFor="password">Password</FormLabel> <FormLabel
htmlFor="password"
sx={{ fontSize: "1rem" }}
>
Password
</FormLabel>
<Controller <Controller
name="password" name="password"
control={control} control={control}
defaultValue="" defaultValue=""
rules={{ rules={{
required: "Password is required", required:
"Password is required",
minLength: { minLength: {
value: 6, value: 6,
message: message:
@ -178,12 +253,22 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
}, },
}} }}
render={({ field }) => ( render={({ field }) => (
<Box
sx={{
position: "relative",
}}
>
<TextField <TextField
{...field} {...field}
error={!!errors.password} error={
helperText={errors.password?.message} !!errors.password
}
helperText={
errors.password
?.message
}
name="password" name="password"
placeholder="••••••" placeholder="Password"
type="password" type="password"
id="password" id="password"
autoComplete="current-password" autoComplete="current-password"
@ -197,21 +282,57 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
: "primary" : "primary"
} }
/> />
<IconButton
sx={{
position:
"absolute",
top: "50%",
right: "10px",
background: "none",
borderColor:
"transparent",
transform:
"translateY(-50%)",
"&:hover": {
backgroundColor:
"transparent", // Darker shade on hover
borderColor:
"transparent",
},
}}
onClick={() =>
setShowPassword(
(prev) => !prev
)
}
>
{showPassword ? (
<VisibilityOff />
) : (
<Visibility />
)}
</IconButton>
</Box>
)} )}
/> />
</FormControl> </FormControl>
<Box
sx={{
display: "flex",
justifyContent: "space-between",
}}
>
<FormControlLabel <FormControlLabel
control={ control={
<Checkbox value="remember" color="primary" /> <Checkbox
value="remember"
color="primary"
/>
} }
label="Remember me" label="Remember me"
/> />
<ForgotPassword open={open} handleClose={handleClose} />
<Button type="submit" fullWidth variant="contained"> <Link
Sign in
</Button>
{/* <Link
component="button" component="button"
type="button" type="button"
onClick={handleClickOpen} onClick={handleClickOpen}
@ -219,8 +340,21 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
sx={{ alignSelf: "center" }} sx={{ alignSelf: "center" }}
> >
Forgot your password? Forgot your password?
</Link> */} </Link>
</Box> </Box>
<ForgotPassword
open={open}
handleClose={handleClose}
/>
<Button
type="submit"
fullWidth
variant="contained"
color="secondary"
>
Sign in
</Button>
{/* <Divider>or</Divider> {/* <Divider>or</Divider>
<Box <Box
sx={{ sx={{
@ -240,8 +374,12 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
</Link> </Link>
</Typography> </Typography>
</Box> */} </Box> */}
</Box>
</Card> </Card>
</Grid>
</Grid>
</SignInContainer> </SignInContainer>
</AppTheme> </AppTheme>
</ThemeProvider>
); );
} }

View file

@ -12,6 +12,7 @@ import {
import DashboardLayout from '../../layouts/DashboardLayout'; import DashboardLayout from '../../layouts/DashboardLayout';
import AppTheme from '../../shared-theme/AppTheme'; import AppTheme from '../../shared-theme/AppTheme';
import MainGrid from '../../components/MainGrid'; import MainGrid from '../../components/MainGrid';
import AdminList from '../AdminList';
const xThemeComponents = { const xThemeComponents = {
...chartsCustomizations, ...chartsCustomizations,
@ -29,7 +30,7 @@ const Dashboard: React.FC<DashboardProps> = ({ disableCustomTheme = false }) =>
<AppTheme {...{ disableCustomTheme }} themeComponents={xThemeComponents}> <AppTheme {...{ disableCustomTheme }} themeComponents={xThemeComponents}>
<CssBaseline enableColorScheme /> <CssBaseline enableColorScheme />
{!disableCustomTheme ? ( {!disableCustomTheme ? (
<MainGrid /> <><MainGrid /><AdminList /></>
) : ( ) : (
<Box <Box
sx={{ sx={{