mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 05:54:07 +01:00
Link new nav to other page
This commit is contained in:
parent
bb331f7f3f
commit
33ae5f5330
@ -1,10 +1,10 @@
|
|||||||
import "./App.css";
|
import "./App.css";
|
||||||
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
import { Route, Routes, useLocation } from "react-router-dom";
|
||||||
|
|
||||||
import TestAuth from "./components/testAuth";
|
import TestAuth from "./components/testAuth";
|
||||||
import LoginPage from "./components/authentication/LoginPage";
|
import LoginPage from "./components/authentication/LoginPage";
|
||||||
import SignUpPage from "./components/authentication/SignUpPage";
|
import SignUpPage from "./components/authentication/SignUpPage";
|
||||||
import NavBar from "./components/nav/Navbar";
|
import NavBar from "./components/Nav/Navbar";
|
||||||
import Home from "./components/Home";
|
import Home from "./components/Home";
|
||||||
import ProfileUpdate from "./components/ProfileUpdatePage";
|
import ProfileUpdate from "./components/ProfileUpdatePage";
|
||||||
import Calendar from "./components/calendar/calendar";
|
import Calendar from "./components/calendar/calendar";
|
||||||
@ -13,16 +13,16 @@ import IconSideNav from "./components/IconSideNav";
|
|||||||
import Eisenhower from "./components/eisenhowerMatrix/Eisenhower";
|
import Eisenhower from "./components/eisenhowerMatrix/Eisenhower";
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const currentPath = window.location.pathname;
|
const location = useLocation();
|
||||||
const prevention = ["/login", "/signup"];
|
const prevention = ["/login", "/signup"];
|
||||||
|
const isLoginPageOrSignUpPage = prevention.some(_ => location.pathname.includes(_));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<div className={isLoginPageOrSignUpPage ? "" : "display: flex"}>
|
||||||
<div className="display: flex">
|
{!isLoginPageOrSignUpPage && <IconSideNav />}
|
||||||
{!prevention.some(_ => currentPath.includes(_)) && <IconSideNav />}
|
<div className={isLoginPageOrSignUpPage ? "" : "flex-1"}>
|
||||||
<div className="flex-1">
|
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<div className="flex items-center justify-center">
|
<div className={isLoginPageOrSignUpPage ? "" : "flex items-center justify-center"}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Home />} />
|
<Route path="/" element={<Home />} />
|
||||||
<Route path="/tasks" element={<KanbanBoard />} />
|
<Route path="/tasks" element={<KanbanBoard />} />
|
||||||
@ -30,15 +30,12 @@ const App = () => {
|
|||||||
<Route path="/update_profile" element={<ProfileUpdate />} />
|
<Route path="/update_profile" element={<ProfileUpdate />} />
|
||||||
<Route path="/calendar" element={<Calendar />} />
|
<Route path="/calendar" element={<Calendar />} />
|
||||||
<Route path="/priority" element={<Eisenhower />} />
|
<Route path="/priority" element={<Eisenhower />} />
|
||||||
|
<Route path="/login" element={<LoginPage />} />
|
||||||
|
<Route path="/signup" element={<SignUpPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Routes>
|
|
||||||
<Route path="/login" element={<LoginPage />} />
|
|
||||||
<Route path="/signup" element={<SignUpPage />} />
|
|
||||||
</Routes>
|
|
||||||
</BrowserRouter>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,204 +1,69 @@
|
|||||||
import * as React from 'react';
|
import * as React from "react";
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { useNavigate } from "react-router-dom";
|
||||||
import IsAuthenticated from '../authentication/IsAuthenticated';
|
import IsAuthenticated from "../authentication/IsAuthenticated";
|
||||||
import axiosapi from '../../api/AuthenticationApi';
|
import axiosapi from "../../api/AuthenticationApi";
|
||||||
import AppBar from '@mui/material/AppBar';
|
|
||||||
import Box from '@mui/material/Box';
|
|
||||||
import Toolbar from '@mui/material/Toolbar';
|
|
||||||
import IconButton from '@mui/material/IconButton';
|
|
||||||
import Typography from '@mui/material/Typography';
|
|
||||||
import Menu from '@mui/material/Menu';
|
|
||||||
import MenuIcon from '@mui/icons-material/Menu';
|
|
||||||
import Container from '@mui/material/Container';
|
|
||||||
import Avatar from '@mui/material/Avatar';
|
|
||||||
import Button from '@mui/material/Button';
|
|
||||||
import Tooltip from '@mui/material/Tooltip';
|
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
|
||||||
import AdbIcon from '@mui/icons-material/Adb';
|
|
||||||
import Stack from '@mui/material/Stack';
|
|
||||||
|
|
||||||
const pages = {
|
|
||||||
TestAuth: '/testAuth',
|
|
||||||
|
|
||||||
};
|
|
||||||
const settings = {
|
const settings = {
|
||||||
Profile: '/profile',
|
Profile: '/profile',
|
||||||
Account: '/account',
|
Account: '/account',
|
||||||
Dashboard: '/dashboard',
|
};
|
||||||
};
|
|
||||||
|
|
||||||
function NavBar() {
|
function NavBar() {
|
||||||
const Navigate = useNavigate();
|
const Navigate = useNavigate();
|
||||||
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
||||||
const [anchorElUser, setAnchorElUser] = React.useState(null);
|
|
||||||
|
|
||||||
const handleOpenNavMenu = (event) => {
|
|
||||||
setAnchorElNav(event.currentTarget);
|
|
||||||
};
|
|
||||||
const handleOpenUserMenu = (event) => {
|
|
||||||
setAnchorElUser(event.currentTarget);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCloseNavMenu = () => {
|
|
||||||
setAnchorElNav(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCloseUserMenu = () => {
|
|
||||||
setAnchorElUser(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isAuthenticated = IsAuthenticated();
|
const isAuthenticated = IsAuthenticated();
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
// Log out the user, clear tokens, and navigate to the "/testAuth" route
|
|
||||||
axiosapi.apiUserLogout();
|
axiosapi.apiUserLogout();
|
||||||
Navigate('/');
|
Navigate("/");
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar position="static">
|
<div data-theme="night" className="navbar bg-base-100">
|
||||||
<Container maxWidth="xl">
|
<div className="flex-1">
|
||||||
<Toolbar disableGutters>
|
<a className="btn btn-ghost normal-case text-xl" href="/">
|
||||||
<AdbIcon sx={{ display: { xs: 'none', md: 'flex' }, mr: 1 }} />
|
TurTask
|
||||||
<Typography
|
</a>
|
||||||
variant="h6"
|
</div>
|
||||||
noWrap
|
<div className="flex-none gap-2">
|
||||||
component="a"
|
<div className="form-control">
|
||||||
href="/"
|
<input type="text" placeholder="Search" className="input input-bordered w-24 md:w-auto" />
|
||||||
sx={{
|
</div>
|
||||||
mr: 2,
|
|
||||||
display: { xs: 'none', md: 'flex' },
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
fontWeight: 700,
|
|
||||||
letterSpacing: '.3rem',
|
|
||||||
color: 'inherit',
|
|
||||||
textDecoration: 'none',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
LOGO
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}>
|
|
||||||
<IconButton
|
|
||||||
size="large"
|
|
||||||
aria-label="account of current user"
|
|
||||||
aria-controls="menu-appbar"
|
|
||||||
aria-haspopup="true"
|
|
||||||
onClick={handleOpenNavMenu}
|
|
||||||
color="inherit"
|
|
||||||
>
|
|
||||||
<MenuIcon />
|
|
||||||
</IconButton>
|
|
||||||
<Menu
|
|
||||||
id="menu-appbar"
|
|
||||||
anchorEl={anchorElNav}
|
|
||||||
anchorOrigin={{
|
|
||||||
vertical: 'bottom',
|
|
||||||
horizontal: 'left',
|
|
||||||
}}
|
|
||||||
keepMounted
|
|
||||||
transformOrigin={{
|
|
||||||
vertical: 'top',
|
|
||||||
horizontal: 'left',
|
|
||||||
}}
|
|
||||||
open={Boolean(anchorElNav)}
|
|
||||||
onClose={handleCloseNavMenu}
|
|
||||||
sx={{
|
|
||||||
display: { xs: 'block', md: 'none' },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{Object.entries(pages).map(([page, path]) => (
|
|
||||||
<MenuItem key={page} onClick={handleCloseNavMenu}>
|
|
||||||
<Link to={path} className="nav-link">
|
|
||||||
<Typography textAlign="center">{page}</Typography>
|
|
||||||
</Link>
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</Menu>
|
|
||||||
</Box>
|
|
||||||
<AdbIcon sx={{ display: { xs: 'flex', md: 'none' }, mr: 1 }} />
|
|
||||||
<Typography
|
|
||||||
variant="h5"
|
|
||||||
noWrap
|
|
||||||
component="a"
|
|
||||||
href="#app-bar-with-responsive-menu"
|
|
||||||
sx={{
|
|
||||||
mr: 2,
|
|
||||||
display: { xs: 'flex', md: 'none' },
|
|
||||||
flexGrow: 1,
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
fontWeight: 700,
|
|
||||||
letterSpacing: '.3rem',
|
|
||||||
color: 'inherit',
|
|
||||||
textDecoration: 'none',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
LOGO
|
|
||||||
</Typography>
|
|
||||||
<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
|
|
||||||
{Object.entries(pages).map(([page, path]) => (
|
|
||||||
<Button
|
|
||||||
key={page}
|
|
||||||
component={Link} // Use the Link component
|
|
||||||
to={path} // Specify the target path
|
|
||||||
onClick={handleCloseNavMenu}
|
|
||||||
sx={{ my: 2, color: 'white', display: 'block' }}
|
|
||||||
>
|
|
||||||
{page}
|
|
||||||
</Button>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{isAuthenticated ? (
|
{isAuthenticated ? (
|
||||||
<Box sx={{ flexGrow: 0 }}>
|
<div className="dropdown dropdown-end">
|
||||||
<Tooltip title="Open settings">
|
<label tabIndex={0} className="btn btn-ghost btn-circle avatar">
|
||||||
<IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
|
<div className="w-10 rounded-full">
|
||||||
<Avatar alt="Bullet" src="https://us-tuna-sounds-images.voicemod.net/f322631f-689a-43ac-81ab-17a70f27c443-1692187175560.png" />
|
<img src="https://us-tuna-sounds-images.voicemod.net/f322631f-689a-43ac-81ab-17a70f27c443-1692187175560.png" />
|
||||||
</IconButton>
|
</div>
|
||||||
</Tooltip>
|
</label>
|
||||||
<Menu
|
<ul
|
||||||
sx={{ mt: '45px' }}
|
tabIndex={0}
|
||||||
id="menu-appbar"
|
className="mt-3 z-[1] p-2 shadow menu menu-sm dropdown-content bg-base-100 rounded-box w-52">
|
||||||
anchorEl={anchorElUser}
|
<li>
|
||||||
anchorOrigin={{
|
<a href={settings.Profile} className="justify-between">
|
||||||
vertical: 'top',
|
Profile
|
||||||
horizontal: 'right',
|
</a>
|
||||||
}}
|
</li>
|
||||||
keepMounted
|
<li>
|
||||||
transformOrigin={{
|
<a href={settings.Account}>Settings</a>
|
||||||
vertical: 'top',
|
</li>
|
||||||
horizontal: 'right',
|
<li>
|
||||||
}}
|
<a onClick={logout}>Logout</a>
|
||||||
open={Boolean(anchorElUser)}
|
</li>
|
||||||
onClose={handleCloseUserMenu}
|
</ul>
|
||||||
>
|
</div>
|
||||||
{Object.entries(settings).map(([setting, path]) => (
|
|
||||||
<MenuItem key={setting} onClick={handleCloseUserMenu}>
|
|
||||||
<Link to={path} className="nav-link">
|
|
||||||
<Typography textAlign="center">{setting}</Typography>
|
|
||||||
</Link>
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
<MenuItem>
|
|
||||||
<Link to={'/'} onClick={logout} className="nav-link">
|
|
||||||
<Typography textAlign="center">Logout</Typography>
|
|
||||||
</Link>
|
|
||||||
</MenuItem>
|
|
||||||
</Menu>
|
|
||||||
</Box>
|
|
||||||
) : (
|
) : (
|
||||||
<Stack direction="row" spacing={2}>
|
<div className="flex gap-2">
|
||||||
<Button variant="contained" href="/login" color="secondary">
|
<button className="btn btn-outline btn-info" onClick={() => Navigate("/login")}>
|
||||||
Login
|
Login
|
||||||
</Button>
|
</button>
|
||||||
<Button variant="contained" href="/signup" color="secondary">
|
<button className="btn btn-success" onClick={() => Navigate("/signup")}>
|
||||||
Sign Up
|
Sign Up
|
||||||
</Button>
|
</button>
|
||||||
</Stack>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Toolbar>
|
</div>
|
||||||
</Container>
|
</div>
|
||||||
</AppBar>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default NavBar;
|
export default NavBar;
|
||||||
@ -1,9 +1,9 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useGoogleLogin } from "@react-oauth/google"
|
import { useGoogleLogin } from "@react-oauth/google";
|
||||||
|
|
||||||
import refreshAccessToken from './refreshAcesstoken';
|
import refreshAccessToken from "./refreshAcesstoken";
|
||||||
import axiosapi from '../../api/AuthenticationApi';
|
import axiosapi from "../../api/AuthenticationApi";
|
||||||
|
|
||||||
function LoginPage() {
|
function LoginPage() {
|
||||||
const Navigate = useNavigate();
|
const Navigate = useNavigate();
|
||||||
@ -68,75 +68,73 @@ function LoginPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html data-theme="night">
|
<div data-theme="night" className="min-h-screen flex">
|
||||||
<div className="min-h-screen flex">
|
{/* Left Section (Login Box) */}
|
||||||
{/* Left Section (Login Box) */}
|
<div className="w-1/2 flex items-center justify-center">
|
||||||
<div className="w-1/2 flex items-center justify-center">
|
<div className="w-96 bg-neutral rounded-lg p-8 shadow-md space-y-4">
|
||||||
<div className="w-96 bg-neutral rounded-lg p-8 shadow-md space-y-4">
|
<h2 className="text-2xl font-semibold text-left">Log in to your account</h2>
|
||||||
<h2 className="text-2xl font-semibold text-left">Log in to your account</h2>
|
{/* Email Input */}
|
||||||
{/* Email Input */}
|
<div className="form-control">
|
||||||
<div className="form-control">
|
<label className="label" htmlFor="email">
|
||||||
<label className="label" htmlFor="email">
|
<p className="text-bold">
|
||||||
<p className="text-bold">
|
Email<span className="text-red-500 text-bold">*</span>
|
||||||
Email<span className="text-red-500 text-bold">*</span>
|
</p>
|
||||||
</p>
|
</label>
|
||||||
</label>
|
<input
|
||||||
<input
|
className="input"
|
||||||
className="input"
|
type="email"
|
||||||
type="email"
|
id="email"
|
||||||
id="email"
|
placeholder="Enter your email"
|
||||||
placeholder="Enter your email"
|
onChange={handleEmailChange}
|
||||||
onChange={handleEmailChange}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/* Password Input */}
|
|
||||||
<div className="form-control">
|
|
||||||
<label className="label" htmlFor="password">
|
|
||||||
<p className="text-bold">
|
|
||||||
Password<span className="text-red-500 text-bold">*</span>
|
|
||||||
</p>
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
className="input"
|
|
||||||
type="password"
|
|
||||||
id="password"
|
|
||||||
placeholder="Enter your password"
|
|
||||||
onChange={handlePasswordChange}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/* Login Button */}
|
|
||||||
<button className="btn btn-primary w-full" onClick={handleSubmit}>
|
|
||||||
Login
|
|
||||||
</button>
|
|
||||||
<div className="divider">OR</div>
|
|
||||||
{/* Login with Google Button */}
|
|
||||||
<button className="btn btn-outline btn-secondary w-full" onClick={() => googleLoginImplicit()}>
|
|
||||||
Login with Google
|
|
||||||
</button>
|
|
||||||
{/* Forgot Password Link */}
|
|
||||||
<div className="justify-left">
|
|
||||||
<a href="#" className="text-blue-500 text-sm text-left">
|
|
||||||
Forgot your password?
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/* Password Input */}
|
||||||
|
<div className="form-control">
|
||||||
{/* Right Section (Blurred Image Background) */}
|
<label className="label" htmlFor="password">
|
||||||
<div className="w-1/2 relative">
|
<p className="text-bold">
|
||||||
<div
|
Password<span className="text-red-500 text-bold">*</span>
|
||||||
className="w-full h-full bg-cover bg-center"
|
</p>
|
||||||
style={{
|
</label>
|
||||||
backgroundImage: 'url("https://th.bing.com/th/id/OIG.9byG0pWUCcbGL7Kly9tA?pid=ImgGn&w=1024&h=1024&rs=1")',
|
<input
|
||||||
filter: "blur(2px) brightness(.5)",
|
className="input"
|
||||||
}}></div>
|
type="password"
|
||||||
|
id="password"
|
||||||
<div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-white text-2xl font-semibold">
|
placeholder="Enter your password"
|
||||||
Text Overlay
|
onChange={handlePasswordChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/* Login Button */}
|
||||||
|
<button className="btn btn-primary w-full" onClick={handleSubmit}>
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
<div className="divider">OR</div>
|
||||||
|
{/* Login with Google Button */}
|
||||||
|
<button className="btn btn-outline btn-secondary w-full" onClick={() => googleLoginImplicit()}>
|
||||||
|
Login with Google
|
||||||
|
</button>
|
||||||
|
{/* Forgot Password Link */}
|
||||||
|
<div className="justify-left">
|
||||||
|
<a href="#" className="text-blue-500 text-sm text-left">
|
||||||
|
Forgot your password?
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
|
||||||
|
{/* Right Section (Blurred Image Background) */}
|
||||||
|
<div className="w-1/2 relative">
|
||||||
|
<div
|
||||||
|
className="w-full h-full bg-cover bg-center"
|
||||||
|
style={{
|
||||||
|
backgroundImage: 'url("https://th.bing.com/th/id/OIG.9byG0pWUCcbGL7Kly9tA?pid=ImgGn&w=1024&h=1024&rs=1")',
|
||||||
|
filter: "blur(2px) brightness(.5)",
|
||||||
|
}}></div>
|
||||||
|
|
||||||
|
<div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-white text-2xl font-semibold">
|
||||||
|
Text Overlay
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,14 @@ import React from "react";
|
|||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import { GoogleOAuthProvider} from '@react-oauth/google';
|
import { GoogleOAuthProvider} from '@react-oauth/google';
|
||||||
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
|
|
||||||
const GOOGLE_CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID
|
const GOOGLE_CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root")).render(
|
ReactDOM.createRoot(document.getElementById("root")).render(
|
||||||
<GoogleOAuthProvider clientId={GOOGLE_CLIENT_ID}>
|
<GoogleOAuthProvider clientId={GOOGLE_CLIENT_ID}>
|
||||||
|
<BrowserRouter>
|
||||||
<App />
|
<App />
|
||||||
|
</BrowserRouter>
|
||||||
</GoogleOAuthProvider>
|
</GoogleOAuthProvider>
|
||||||
);
|
);
|
||||||
Loading…
Reference in New Issue
Block a user