minor
This commit is contained in:
parent
ab51b412c5
commit
0920b7a686
@ -34,7 +34,7 @@ useEffect(() => {
|
||||
try {
|
||||
await account.deleteSession('current');
|
||||
// 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) {
|
||||
console.error("Error signing out:", error);
|
||||
}
|
||||
@ -241,9 +241,9 @@ useEffect(() => {
|
||||
className="flex items-center text-gray-700 dark:text-gray-400"
|
||||
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 ? (
|
||||
<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()}
|
||||
</div>
|
||||
) : (
|
||||
@ -255,7 +255,7 @@ useEffect(() => {
|
||||
)}
|
||||
</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"}
|
||||
</span>
|
||||
|
||||
|
@ -5,34 +5,51 @@ import { usePathname } from "next/navigation";
|
||||
import Navbar from "./components/Navbar";
|
||||
import Sidebar from "./components/Sidebar";
|
||||
import { AuthProvider } from "./context/AuthContext";
|
||||
import { ThemeProvider } from "./context/ThemeContext";
|
||||
export default function RootLayout({ children }) {
|
||||
import { ThemeProvider,useTheme } from "./context/ThemeContext";
|
||||
|
||||
function LayoutContent({ children }) {
|
||||
const { darkMode } = useTheme();
|
||||
const pathname = usePathname();
|
||||
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 (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Employee Portal</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/images/brand/brand-06.svg" /></head>
|
||||
<body className={isAuthPage ? "" : "flex h-screen overflow-hidden"}>
|
||||
<ThemeProvider>
|
||||
<AuthProvider>
|
||||
{!isAuthPage ? (
|
||||
<>
|
||||
<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>
|
||||
<link rel="icon" href="/images/brand/brand-08.svg" />
|
||||
</head>
|
||||
<ThemeProvider>
|
||||
<LayoutContent>{children}</LayoutContent>
|
||||
</ThemeProvider>
|
||||
</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 { account } from '../../lib/appwrite'; // adjust path as needed
|
||||
|
||||
const RegisterStudent = () => {
|
||||
const RegisterEmployee = () => {
|
||||
const [user, setUser] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@ -24,7 +24,7 @@ const RegisterStudent = () => {
|
||||
|
||||
return (
|
||||
<nav className="flex justify-between p-4 bg-white shadow">
|
||||
<div>MyApp</div>
|
||||
<div>You are on register employee page</div>
|
||||
<div>
|
||||
{!loading && user ? (
|
||||
<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