Skip to content

Commit 620bb36

Browse files
committed
modification list:
themeswitcher added [light theme is pending css] home page converted into componenet Update profile UI added and api integrted where fetch profile and update profile Update Password UI integrated and API integrated
1 parent 1ba43c1 commit 620bb36

23 files changed

+1023
-95
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ eslintcache
9191
# Lock files (optional: if you don't want to track lock files)
9292
package-lock.json
9393
yarn.lock
94+
95+
#custom files and folders
96+
_notes.txt

src/App.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@
5454
100% {
5555
transform: rotate(360deg);
5656
}
57-
}
57+
}
58+

src/App.jsx

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,43 @@
1-
import React, { Suspense } from "react";
1+
import React, { useState, Suspense } from "react";
22
import { Route, Routes, Navigate } from "react-router-dom";
33
import { CssBaseline, Box, CircularProgress } from "@mui/material";
4-
import { createTheme, ThemeProvider } from "@mui/material/styles";
4+
import { ThemeProvider } from "@mui/material/styles";
55
import HeaderMenu from "./components/Layout/HeaderMenu";
66
import Footer from "./components/Layout/Footer";
7+
import { SnackbarProvider } from "notistack";
8+
import lightTheme from "@/themes/lightTheme";
9+
import darkTheme from "./themes/darkTheme";
710
import "./App.css";
811
const HomePage = React.lazy(() => import("./pages/HomePage"));
912
const LoginPage = React.lazy(() => import("./pages/Auth/LoginPage"));
1013
const RegisterPage = React.lazy(() => import("./pages/Auth/RegisterPage"));
14+
const ProfilePage = React.lazy(() => import("@/pages/Profile/ProfilePage"));
1115
const NotFoundPage = React.lazy(() => import("./pages/ErrorPages/Page404"));
12-
import { SnackbarProvider } from "notistack";
13-
14-
const theme = createTheme({
15-
palette: {
16-
primary: {
17-
main: "#0A0F24",
18-
},
19-
secondary: {
20-
main: "#FAE3CF",
21-
},
22-
other: {
23-
white: "#fff",
24-
black: "#000",
25-
},
26-
background: {
27-
default: "#f4f6f8",
28-
},
29-
},
30-
typography: {
31-
fontFamily: "Roboto, Arial, sans-serif", //monospace
32-
h1: {
33-
fontSize: "2rem",
34-
},
35-
body1: {
36-
fontSize: "1rem",
37-
},
38-
},
39-
});
16+
const ProfilePage2 = React.lazy(() =>
17+
import("@/components/Profile/ProfileForm")
18+
);
4019
function App() {
20+
const [currentTheme, setCurrentTheme] = useState("dark");
21+
const themes = {
22+
light: lightTheme,
23+
dark: darkTheme,
24+
};
25+
const handleThemeChange = (theme) => {
26+
setCurrentTheme(theme);
27+
};
28+
4129
return (
4230
<SnackbarProvider
4331
maxSnack={1}
4432
anchorOrigin={{ vertical: "top", horizontal: "right" }}
4533
>
46-
<ThemeProvider theme={theme}>
34+
<ThemeProvider theme={themes[currentTheme]}>
4735
<CssBaseline />
4836
<Box display="flex" flexDirection="column" minHeight="100vh">
49-
<HeaderMenu />
37+
<HeaderMenu
38+
currentTheme={currentTheme}
39+
onThemeChange={handleThemeChange}
40+
/>
5041
<Box
5142
component="main"
5243
sx={{ flexGrow: 1, bgcolor: "background.default", p: 3 }}
@@ -63,6 +54,9 @@ function App() {
6354
<Route path="/home" element={<Navigate to="/" />} />
6455
<Route path="/login" element={<LoginPage />} />
6556
<Route path="/register" element={<RegisterPage />} />
57+
<Route path="/my-profile" element={<ProfilePage />} />
58+
<Route path="/me" element={<ProfilePage2 />} />
59+
<Route path="/update-password" element={<ProfilePage />} />
6660
<Route path="*" element={<NotFoundPage />} />
6761
</Routes>
6862
</Suspense>

src/components/Home/Banner.jsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
import {
2-
Typography,
3-
Paper,
4-
} from "@mui/material";
1+
import { Typography, Paper } from "@mui/material";
52
const Banner = () => {
63
return (
7-
<Paper className="home-banner">
8-
<Typography variant="h2" gutterBottom>
9-
Welcome to {import.meta.env.VITE_APP_NAME} !
10-
</Typography>
11-
<Typography variant="h6">
12-
Designing Innovative Solutions Inspired by Excellence
13-
</Typography>
14-
</Paper>
4+
<>
5+
<Paper className="home-banner">
6+
<Typography
7+
variant="h2"
8+
gutterBottom
9+
sx={{
10+
fontSize: { xs: "2rem", sm: "3rem", md: "4rem" },
11+
}}
12+
>
13+
Welcome To {import.meta.env.VITE_APP_NAME} !
14+
</Typography>
15+
<Typography
16+
variant="h6"
17+
sx={{
18+
fontSize: { xs: "1rem", sm: "1.25rem", md: "1.5rem" },
19+
}}
20+
>
21+
Designing Innovative Solutions Inspired by Excellence
22+
</Typography>
23+
</Paper>
24+
</>
1525
);
1626
};
1727
export default Banner;

src/components/Layout/HeaderMenu.jsx

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ import {
1818
ListItemIcon,
1919
Divider,
2020
Tooltip,
21+
Select,
22+
Chip,
2123
} from "@mui/material";
22-
import { Menu as MenuIcon, Logout } from "@mui/icons-material";
24+
import {
25+
Menu as MenuIcon,
26+
Logout,
27+
PersonAdd,
28+
Person2Outlined,
29+
PasswordOutlined,
30+
} from "@mui/icons-material";
2331
import { Link, useNavigate } from "react-router-dom";
2432
import { useDispatch, useSelector } from "react-redux";
2533
import CommonHelper from "@/utils/commonHelpers";
2634
import { logout, resetError } from "@/store/auth/authSlice";
35+
import ThemeSwitcher from "@/components/Layout/ThemeSwitcher";
2736

2837
const pages = [
2938
{ name: "Home", path: "/", public: 1, auth: 1 },
@@ -32,7 +41,7 @@ const pages = [
3241
{ name: "SignUp", path: "/register", public: 1, auth: 0 },
3342
];
3443

35-
function HeaderMenu() {
44+
function HeaderMenu({ currentTheme, onThemeChange }) {
3645
const dispatch = useDispatch();
3746
const { isLoggedIn, user } = useSelector((state) => state.auth);
3847
const [anchorElNav, setAnchorElNav] = useState(null);
@@ -252,6 +261,11 @@ function HeaderMenu() {
252261
return null;
253262
})}
254263
</Box>
264+
<ThemeSwitcher
265+
currentTheme={currentTheme}
266+
onThemeChange={onThemeChange}
267+
/>
268+
255269
{isLoggedIn && user ? (
256270
<>
257271
<Box
@@ -265,17 +279,18 @@ function HeaderMenu() {
265279
<IconButton
266280
onClick={handleClick}
267281
size="small"
268-
sx={{ ml: 2 }}
282+
sx={{ ml: 0 }}
269283
aria-controls={open ? "account-menu" : undefined}
270284
aria-haspopup="true"
271285
aria-expanded={open ? "true" : undefined}
272286
>
273287
<Avatar
274288
sx={{
289+
fontWeight: "bold",
275290
width: 40,
276291
height: 40,
277292
color: "primary.main",
278-
background: "secondary.main",
293+
backgroundColor: "secondary.main",
279294
}}
280295
>
281296
{CommonHelper._nameInitials(user.full_name)}
@@ -321,14 +336,37 @@ function HeaderMenu() {
321336
anchorOrigin={{ horizontal: "right", vertical: "bottom" }}
322337
>
323338
<MenuItem>
324-
<strong>
325-
Hello, {user.full_name} [{user.unique_id}]
339+
<strong style={{ display: "flex", alignItems: "center" }}>
340+
Hello, {user.first_name}{" "}
341+
<Chip
342+
label={user.unique_id}
343+
size="small"
344+
color="primary"
345+
sx={{ marginLeft: "8px", verticalAlign: "middle" }}
346+
/>
326347
</strong>
327348
</MenuItem>
328-
<MenuItem onClick={handleClose}>
329-
<Avatar /> My account
349+
350+
<MenuItem
351+
onClick={handleClose}
352+
component={Link}
353+
to="/my-profile"
354+
>
355+
<ListItemIcon>
356+
<Person2Outlined fontSize="small" />
357+
</ListItemIcon>
358+
My Account
359+
</MenuItem>
360+
<MenuItem
361+
onClick={handleClose}
362+
component={Link}
363+
to="/update-password"
364+
>
365+
<ListItemIcon>
366+
<PasswordOutlined fontSize="small" />
367+
</ListItemIcon>
368+
Change Password
330369
</MenuItem>
331-
<Divider />
332370
{/* <MenuItem onClick={handleClose}>
333371
<ListItemIcon>
334372
<PersonAdd fontSize="small" />
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
import { Box, IconButton } from "@mui/material";
3+
import { LightMode, DarkMode } from "@mui/icons-material";
4+
5+
const ThemeSwitcher = ({ currentTheme, onThemeChange }) => {
6+
const handleToggleTheme = () => {
7+
onThemeChange(currentTheme === "light" ? "dark" : "light");
8+
};
9+
10+
return (
11+
<Box>
12+
<IconButton onClick={handleToggleTheme} color="inherit">
13+
{currentTheme === "light" ? <DarkMode /> : <LightMode />}
14+
</IconButton>
15+
</Box>
16+
);
17+
};
18+
19+
export default ThemeSwitcher;

0 commit comments

Comments
 (0)