minor
This commit is contained in:
parent
ab51b412c5
commit
0920b7a686
@ -34,7 +34,7 @@ useEffect(() => {
|
|||||||
try {
|
try {
|
||||||
await account.deleteSession('current');
|
await account.deleteSession('current');
|
||||||
// Redirect to login page or home page after sign out
|
// Redirect to login page or home page after sign out
|
||||||
window.location.href = '/login'; // or your preferred redirect
|
window.location.href = '/'; // or your preferred redirect
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error signing out:", error);
|
console.error("Error signing out:", error);
|
||||||
}
|
}
|
||||||
@ -241,9 +241,9 @@ useEffect(() => {
|
|||||||
className="flex items-center text-gray-700 dark:text-gray-400"
|
className="flex items-center text-gray-700 dark:text-gray-400"
|
||||||
onClick={() => setDropdownOpen(!dropdownOpen)}
|
onClick={() => setDropdownOpen(!dropdownOpen)}
|
||||||
>
|
>
|
||||||
<span className="mr-3 h-8 w-8 overflow-hidden rounded-full">
|
<span className="mr-3 h-10 w-10 overflow-hidden rounded-full">
|
||||||
{user?.name ? (
|
{user?.name ? (
|
||||||
<div className="h-full w-full flex items-center justify-center bg-primary text-white font-medium">
|
<div className="h-full w-full flex items-center justify-center bg-pink-200 text-red-800 font-medium">
|
||||||
{user.name.charAt(0).toUpperCase()}
|
{user.name.charAt(0).toUpperCase()}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@ -255,7 +255,7 @@ useEffect(() => {
|
|||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="mr-1 block text-sm font-medium">
|
<span className="mr-1 block text-sm text-blue-800 font-medium">
|
||||||
{loading ? "Loading..." : user?.name || "Guest"}
|
{loading ? "Loading..." : user?.name || "Guest"}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
@ -5,34 +5,51 @@ import { usePathname } from "next/navigation";
|
|||||||
import Navbar from "./components/Navbar";
|
import Navbar from "./components/Navbar";
|
||||||
import Sidebar from "./components/Sidebar";
|
import Sidebar from "./components/Sidebar";
|
||||||
import { AuthProvider } from "./context/AuthContext";
|
import { AuthProvider } from "./context/AuthContext";
|
||||||
import { ThemeProvider } from "./context/ThemeContext";
|
import { ThemeProvider,useTheme } from "./context/ThemeContext";
|
||||||
export default function RootLayout({ children }) {
|
|
||||||
|
function LayoutContent({ children }) {
|
||||||
|
const { darkMode } = useTheme();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const isAuthPage = pathname === '/' || pathname.startsWith('/login');
|
const isAuthPage = pathname === '/' || pathname.startsWith('/login');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<body className={isAuthPage ? "" : "flex h-screen overflow-hidden"}>
|
||||||
|
<AuthProvider>
|
||||||
|
{!isAuthPage ? (
|
||||||
|
<>
|
||||||
|
<Sidebar />
|
||||||
|
<div className="flex flex-col flex-1 overflow-hidden">
|
||||||
|
<Navbar />
|
||||||
|
<main
|
||||||
|
className={`flex-1 overflow-y-auto p-4 ${
|
||||||
|
darkMode
|
||||||
|
? "bg-gray-800 text-white"
|
||||||
|
: "bg-white text-gray-800"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
children
|
||||||
|
)}
|
||||||
|
</AuthProvider>
|
||||||
|
</body>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function RootLayout({ children }) {
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Employee Portal</title>
|
<title>Employee Portal</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" href="/images/brand/brand-06.svg" /></head>
|
<link rel="icon" href="/images/brand/brand-08.svg" />
|
||||||
<body className={isAuthPage ? "" : "flex h-screen overflow-hidden"}>
|
</head>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<AuthProvider>
|
<LayoutContent>{children}</LayoutContent>
|
||||||
{!isAuthPage ? (
|
</ThemeProvider>
|
||||||
<>
|
|
||||||
<Sidebar />
|
|
||||||
<div className="flex flex-col flex-1 overflow-hidden">
|
|
||||||
<Navbar />
|
|
||||||
<main className="flex-1 overflow-y-auto p-4">{children}</main>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
children
|
|
||||||
)}
|
|
||||||
</AuthProvider>
|
|
||||||
</ThemeProvider>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
// import { NextResponse } from 'next/server';
|
|
||||||
|
|
||||||
// export function middleware(request) {
|
|
||||||
// const isLoggedIn = request.cookies.get('appwrite-session'); // Set manually if needed
|
|
||||||
// const url = request.nextUrl;
|
|
||||||
|
|
||||||
// if (!isLoggedIn && url.pathname.startsWith('/pages')) {
|
|
||||||
// return NextResponse.redirect(new URL('/login', request.url));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return NextResponse.next();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export const config = {
|
|
||||||
// matcher: ['/pages/:path*'],
|
|
||||||
// };
|
|
@ -3,7 +3,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { account } from '../../lib/appwrite'; // adjust path as needed
|
import { account } from '../../lib/appwrite'; // adjust path as needed
|
||||||
|
|
||||||
const RegisterStudent = () => {
|
const RegisterEmployee = () => {
|
||||||
const [user, setUser] = useState(null);
|
const [user, setUser] = useState(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ const RegisterStudent = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="flex justify-between p-4 bg-white shadow">
|
<nav className="flex justify-between p-4 bg-white shadow">
|
||||||
<div>MyApp</div>
|
<div>You are on register employee page</div>
|
||||||
<div>
|
<div>
|
||||||
{!loading && user ? (
|
{!loading && user ? (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
@ -39,4 +39,4 @@ const RegisterStudent = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default RegisterStudent;
|
export default RegisterEmployee;
|
Loading…
Reference in New Issue
Block a user