From 72b8e33f8cbad2ea48e4384043d29a9636a89ea4 Mon Sep 17 00:00:00 2001 From: bender Date: Thu, 12 Mar 2026 13:59:54 +0000 Subject: [PATCH 1/3] Add src/app/admin/page.tsx --- src/app/admin/page.tsx | 343 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 src/app/admin/page.tsx diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx new file mode 100644 index 0000000..35d7322 --- /dev/null +++ b/src/app/admin/page.tsx @@ -0,0 +1,343 @@ +"use client"; + +import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import NavbarStyleCentered from "@/components/navbar/NavbarStyleCentered/NavbarStyleCentered"; +import FooterBase from "@/components/sections/footer/FooterBase"; +import Input from "@/components/form/Input"; +import ButtonHoverMagnetic from "@/components/button/ButtonHoverMagnetic/ButtonHoverMagnetic"; +import { useState, useEffect } from "react"; +import { Edit2, Trash2, Plus, LogOut } from "lucide-react"; +import { useRouter } from "next/navigation"; + +interface Product { + id: string; + name: string; + price: string; + category: string; +} + +export default function AdminPage() { + const [products, setProducts] = useState([ + { id: "1", name: "Samsung Galaxy M54", price: "₹25,999", category: "Smartphones" }, + { id: "2", name: "Redmi Note 13", price: "₹18,999", category: "Smartphones" }, + { id: "3", name: "OPPO A78", price: "₹16,999", category: "Smartphones" }, + { id: "4", name: "Vivo T2", price: "₹19,999", category: "Smartphones" }, + { id: "5", name: "iPhone 14", price: "₹78,999", category: "Smartphones" }, + { id: "6", name: "Universal Phone Case", price: "₹499", category: "Accessories" }, + ]); + const [editingId, setEditingId] = useState(null); + const [editValues, setEditValues] = useState>({}); + const [newProduct, setNewProduct] = useState>({ + name: "", price: "", category: "Smartphones"}); + const [isAuthorized, setIsAuthorized] = useState(false); + const [loading, setLoading] = useState(true); + const router = useRouter(); + + useEffect(() => { + // Check if user is authenticated + const token = localStorage.getItem("adminToken"); + if (!token) { + router.push("/login"); + } else { + setIsAuthorized(true); + setLoading(false); + } + }, [router]); + + const handleLogout = () => { + localStorage.removeItem("adminToken"); + router.push("/login"); + }; + + const handleEdit = (product: Product) => { + setEditingId(product.id); + setEditValues({ ...product }); + }; + + const handleSave = (id: string) => { + setProducts( + products.map((p) => (p.id === id ? { ...p, ...editValues } : p)) + ); + setEditingId(null); + setEditValues({}); + }; + + const handleDelete = (id: string) => { + if (confirm("Are you sure you want to delete this product?")) { + setProducts(products.filter((p) => p.id !== id)); + } + }; + + const handleAddProduct = () => { + if (newProduct.name && newProduct.price && newProduct.category) { + const product: Product = { + id: Date.now().toString(), + name: newProduct.name as string, + price: newProduct.price as string, + category: newProduct.category as string, + }; + setProducts([...products, product]); + setNewProduct({ name: "", price: "", category: "Smartphones" }); + } + }; + + if (loading) { + return ( +
+

Loading...

+
+ ); + } + + if (!isAuthorized) { + return ( +
+

Redirecting to login...

+
+ ); + } + + return ( + + + +
+
+
+
+

Admin Dashboard

+

Manage prices and product inventory

+
+ +
+ + {/* Add New Product Section */} +
+

+ + Add New Product +

+
+ + setNewProduct({ ...newProduct, name: value }) + } + type="text" + placeholder="Product name" + /> + + setNewProduct({ ...newProduct, price: value }) + } + type="text" + placeholder="Price (e.g., ₹25,999)" + /> + + +
+
+ + {/* Products Table */} +
+ + + + + + + + + + + {products.map((product) => ( + + + + + + + ))} + +
Product NamePriceCategoryActions
+ {editingId === product.id ? ( + + setEditValues({ ...editValues, name: value }) + } + type="text" + placeholder="Product name" + /> + ) : ( + {product.name} + )} + + {editingId === product.id ? ( + + setEditValues({ ...editValues, price: value }) + } + type="text" + placeholder="Price" + /> + ) : ( + + {product.price} + + )} + + {editingId === product.id ? ( + + ) : ( + {product.category} + )} + +
+ {editingId === product.id ? ( + <> + + + + ) : ( + <> + + + + )} +
+
+
+ + {products.length === 0 && ( +
+

No products found. Add your first product above.

+
+ )} +
+
+ + +
+ ); +} -- 2.49.1 From 07abb2531d2fd7f09bbff922b6b9bd08c6f2530d Mon Sep 17 00:00:00 2001 From: bender Date: Thu, 12 Mar 2026 13:59:55 +0000 Subject: [PATCH 2/3] Add src/app/login/page.tsx --- src/app/login/page.tsx | 188 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 src/app/login/page.tsx diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx new file mode 100644 index 0000000..676d788 --- /dev/null +++ b/src/app/login/page.tsx @@ -0,0 +1,188 @@ +"use client"; + +import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import NavbarStyleCentered from "@/components/navbar/NavbarStyleCentered/NavbarStyleCentered"; +import FooterBase from "@/components/sections/footer/FooterBase"; +import Input from "@/components/form/Input"; +import ButtonHoverMagnetic from "@/components/button/ButtonHoverMagnetic/ButtonHoverMagnetic"; +import { useState } from "react"; +import { Lock, Mail } from "lucide-react"; +import { useRouter } from "next/navigation"; + +export default function LoginPage() { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + const [loading, setLoading] = useState(false); + const router = useRouter(); + + const handleLogin = async (e: React.FormEvent) => { + e.preventDefault(); + setError(""); + setLoading(true); + + try { + // Basic validation + if (!email || !password) { + setError("Please enter email and password"); + setLoading(false); + return; + } + + // TODO: Replace with actual authentication logic + // For now, accept demo credentials + if (email === "admin@citycellworld.com" && password === "admin123") { + // Store authentication token or session + localStorage.setItem("adminToken", "authenticated"); + router.push("/admin"); + } else { + setError("Invalid email or password"); + } + } catch (err) { + setError("Login failed. Please try again."); + } finally { + setLoading(false); + } + }; + + return ( + + + +
+
+
+
+ +

Admin Login

+

Access the admin dashboard to manage prices and inventory

+
+ +
+ {error && ( +
+ {error} +
+ )} + +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+ +
+

+ Demo credentials: +

+

+ Email: admin@citycellworld.com +

+

+ Password: admin123 +

+
+
+
+
+ + +
+ ); +} -- 2.49.1 From e871e1329a985aa899692c00366efe63025a6b07 Mon Sep 17 00:00:00 2001 From: bender Date: Thu, 12 Mar 2026 13:59:55 +0000 Subject: [PATCH 3/3] Update src/app/page.tsx --- src/app/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index b2d58a9..1267276 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -50,6 +50,7 @@ export default function HomePage() { { name: "Products", id: "products" }, { name: "About", id: "why-choose" }, { name: "Contact", id: "contact-faq" }, + { name: "Admin", id: "/admin" }, ]} button={{ text: "Call Now", href: "tel:+919876543210"}} @@ -298,4 +299,4 @@ export default function HomePage() { ); -} \ No newline at end of file +} -- 2.49.1