From a2e0a65b2599267efe94d665d6305f59b225bbd5 Mon Sep 17 00:00:00 2001 From: Biswa Kalyan Bhuyan Date: Tue, 29 Apr 2025 10:47:43 +0530 Subject: feat: added initlaized the frontend and backend --- frontend/src/components/layouts/AdminLayout.js | 300 +++++++++++++++++++++++++ frontend/src/components/layouts/MainLayout.js | 256 +++++++++++++++++++++ 2 files changed, 556 insertions(+) create mode 100644 frontend/src/components/layouts/AdminLayout.js create mode 100644 frontend/src/components/layouts/MainLayout.js (limited to 'frontend/src/components/layouts') diff --git a/frontend/src/components/layouts/AdminLayout.js b/frontend/src/components/layouts/AdminLayout.js new file mode 100644 index 0000000..fc05708 --- /dev/null +++ b/frontend/src/components/layouts/AdminLayout.js @@ -0,0 +1,300 @@ +import Link from 'next/link'; +import { useRouter } from 'next/navigation'; +import { useAuth } from '@/context/auth-context'; +import { useTheme } from '@/context/theme-context'; + +const AdminLayout = ({ children }) => { + const { user, logout } = useAuth(); + const { theme, toggleTheme } = useTheme(); + const router = useRouter(); + + // Redirect if not admin + if (user && user.role !== 'admin') { + router.push('/login'); + return null; + } + + return ( +
+ {/* Sidebar */} + + + {/* Main Content */} +
+ {/* Header */} +
+

Admin Dashboard

+ +
+ {/* Theme Toggle */} + + + {/* User Menu */} +
+ + + {/* Dropdown Menu */} +
+
+ + Profile + + + View Website + + +
+
+
+
+
+ + {/* Main Content */} +
{children}
+
+
+ ); +}; + +export default AdminLayout; \ No newline at end of file diff --git a/frontend/src/components/layouts/MainLayout.js b/frontend/src/components/layouts/MainLayout.js new file mode 100644 index 0000000..51e0e7e --- /dev/null +++ b/frontend/src/components/layouts/MainLayout.js @@ -0,0 +1,256 @@ +import Link from 'next/link'; +import { useAuth } from '@/context/auth-context'; +import { useCart } from '@/context/cart-context'; +import { useTheme } from '@/context/theme-context'; + +const MainLayout = ({ children }) => { + const { user, isAuthenticated, logout } = useAuth(); + const { getItemCount } = useCart(); + const { theme, toggleTheme } = useTheme(); + + const cartItemCount = getItemCount(); + + return ( +
+ {/* Header */} +
+
+ {/* Logo */} + + Restaurant + + + {/* Navigation Menu */} + + + {/* User Actions */} +
+ {/* Cart Icon */} + + + + + + + {cartItemCount > 0 && ( + + {cartItemCount} + + )} + + + {/* Theme Toggle */} + + + {/* Auth Actions */} + {isAuthenticated ? ( +
+ + + {/* Dropdown Menu */} +
+
+ + Profile + + + Orders + + {user?.role === 'admin' && ( + + Admin Dashboard + + )} + {user?.role === 'staff' && ( + + Staff Dashboard + + )} + +
+
+
+ ) : ( +
+ + Login + + + Register + +
+ )} +
+
+
+ + {/* Main Content */} +
{children}
+ + {/* Footer */} + +
+ ); +}; + +export default MainLayout; \ No newline at end of file -- cgit v1.2.3-59-g8ed1b