Spaces:
Sleeping
Sleeping
eeshaAI commited on
Commit ·
3627684
1
Parent(s): 3df146a
feat: Migrate frontend from static HTML to Next.js 16 App Router
Browse files- All 16 buyer pages: home, login, product, cart, checkout, payment,
categories, search, seller-profile, profile, orders, wishlist,
videos, live, live-watch, group-buy, ai-chat, link-account, telegram
- 7 seller dashboard pages with shared sidebar layout
- 22 API route proxies to existing Supabase Edge Functions
- Suspense boundaries for useSearchParams pages
- Standalone output build for Docker deployment
- Dockerfile (multi-stage Node 20 alpine, port 7860)
- README with HF Space YAML frontmatter
- .hfignore for lean Docker context
Backend unchanged: 27 Supabase Edge Functions, Render bot, OpenWA,
PalmPay payment verifier — all remain in place.
- src/app/categories/page.tsx +441 -81
- src/app/layout.tsx +4 -4
- src/app/page.tsx +17 -6
- src/components/layout-shell.tsx +29 -0
- src/components/mobile-nav.tsx +5 -7
src/app/categories/page.tsx
CHANGED
|
@@ -1,33 +1,43 @@
|
|
| 1 |
'use client';
|
| 2 |
|
| 3 |
-
import { useEffect, useState, useCallback
|
| 4 |
import { useSearchParams, useRouter } from 'next/navigation';
|
| 5 |
-
import { api, type Product } from '@/lib/api';
|
| 6 |
-
import { ProductGrid } from '@/components/product-card';
|
| 7 |
-
import { Button } from '@/components/ui/button';
|
| 8 |
import { Card } from '@/components/ui/card';
|
| 9 |
-
import {
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
{
|
| 15 |
-
{
|
| 16 |
-
{
|
| 17 |
-
{
|
| 18 |
-
{
|
| 19 |
-
{
|
| 20 |
-
{
|
| 21 |
-
{
|
|
|
|
|
|
|
| 22 |
];
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
const SORTS = [
|
| 25 |
{ key: 'newest', label: 'Newest' },
|
| 26 |
{ key: 'popular', label: 'Popular' },
|
| 27 |
{ key: 'price_low', label: 'Price: Low → High' },
|
| 28 |
{ key: 'price_high', label: 'Price: High → Low' },
|
| 29 |
-
{ key: 'flash', label: '⚡ Flash Deals' },
|
| 30 |
-
{ key: 'trending', label: '🔥 Trending' },
|
| 31 |
];
|
| 32 |
|
| 33 |
function CategoriesContent() {
|
|
@@ -35,101 +45,452 @@ function CategoriesContent() {
|
|
| 35 |
const router = useRouter();
|
| 36 |
const initialCategory = params.get('category') || '';
|
| 37 |
const initialSort = params.get('sort') || 'newest';
|
|
|
|
| 38 |
|
| 39 |
const [category, setCategory] = useState(initialCategory);
|
| 40 |
const [sort, setSort] = useState(initialSort);
|
| 41 |
-
const [
|
| 42 |
const [products, setProducts] = useState<Product[]>([]);
|
| 43 |
const [loading, setLoading] = useState(true);
|
| 44 |
const [showSortMenu, setShowSortMenu] = useState(false);
|
|
|
|
| 45 |
|
| 46 |
const load = useCallback(async () => {
|
| 47 |
setLoading(true);
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
setLoading(false);
|
| 53 |
-
}, [category, sort,
|
| 54 |
|
| 55 |
useEffect(() => { load(); }, [load]);
|
| 56 |
|
| 57 |
// Update URL when filter changes
|
| 58 |
-
|
| 59 |
-
const
|
| 60 |
-
if (
|
| 61 |
-
if (
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
const
|
|
|
|
| 67 |
|
| 68 |
return (
|
| 69 |
-
<div className="
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
</div>
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
{activeSort?.label}
|
| 101 |
-
<ChevronDown className="w-3 h-3" />
|
| 102 |
-
</button>
|
| 103 |
-
{showSortMenu && (
|
| 104 |
-
<div className="absolute right-0 top-9 z-10 bg-white border border-slate-100 rounded-xl shadow-xl py-1 min-w-[180px]">
|
| 105 |
-
{SORTS.map((s) => (
|
| 106 |
<button
|
| 107 |
-
key={
|
| 108 |
-
onClick={() => {
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
}
|
|
|
|
| 112 |
>
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
| 114 |
</button>
|
| 115 |
))}
|
| 116 |
</div>
|
| 117 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
</div>
|
| 119 |
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
-
|
| 123 |
-
<div className="
|
| 124 |
-
<
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
</div>
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
</div>
|
| 130 |
);
|
| 131 |
}
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
export default function CategoriesPage() {
|
| 134 |
return (
|
| 135 |
<Suspense fallback={<div className="flex items-center justify-center min-h-[60vh]"><div className="w-8 h-8 border-3 border-slate-200 border-t-primary rounded-full animate-spin" /></div>}>
|
|
@@ -137,4 +498,3 @@ export default function CategoriesPage() {
|
|
| 137 |
</Suspense>
|
| 138 |
);
|
| 139 |
}
|
| 140 |
-
|
|
|
|
| 1 |
'use client';
|
| 2 |
|
| 3 |
+
import { useEffect, useState, useCallback, Suspense } from 'react';
|
| 4 |
import { useSearchParams, useRouter } from 'next/navigation';
|
| 5 |
+
import { api, formatPrice, type Product } from '@/lib/api';
|
|
|
|
|
|
|
| 6 |
import { Card } from '@/components/ui/card';
|
| 7 |
+
import { Button } from '@/components/ui/button';
|
| 8 |
+
import { Search, Camera, ChevronLeft, Store, Filter, ChevronDown } from 'lucide-react';
|
| 9 |
+
import Link from 'next/link';
|
| 10 |
+
|
| 11 |
+
const ALL_CATEGORIES = [
|
| 12 |
+
{ label: 'All', value: '', emoji: '🛍️' },
|
| 13 |
+
{ label: 'Electronics', value: 'Electronics', emoji: '📱' },
|
| 14 |
+
{ label: 'Fashion', value: 'Fashion', emoji: '👗' },
|
| 15 |
+
{ label: 'Home', value: 'Home', emoji: '🏠' },
|
| 16 |
+
{ label: 'Beauty', value: 'Beauty', emoji: '💄' },
|
| 17 |
+
{ label: 'Farm', value: 'Farm', emoji: '🌱' },
|
| 18 |
+
{ label: 'Sports', value: 'Sports', emoji: '⚽' },
|
| 19 |
+
{ label: 'Food', value: 'Food', emoji: '🍲' },
|
| 20 |
+
{ label: 'Toys', value: 'Toys', emoji: '🧸' },
|
| 21 |
+
{ label: 'Books', value: 'Books', emoji: '📚' },
|
| 22 |
];
|
| 23 |
|
| 24 |
+
const SUBCATEGORIES: Record<string, string[]> = {
|
| 25 |
+
'Electronics': ['Smart Watches', 'Headphones', 'Speakers', 'Chargers', 'Cameras', 'Gaming', 'Drones', 'Accessories'],
|
| 26 |
+
'Fashion': ['Ankara', 'Shirts', 'Shoes', 'Bags', 'Watches', 'Jewelry', 'Heels', 'Sneakers'],
|
| 27 |
+
'Home': ['Kitchen', 'Bedding', 'Appliances', 'Decor', 'Lighting', 'Storage', 'Cookware', 'Cleaning'],
|
| 28 |
+
'Beauty': ['Skincare', 'Makeup', 'Hair', 'Perfume', 'Nails', 'Wigs', 'Lotion', 'Brushes'],
|
| 29 |
+
'Farm': ['Vegetables', 'Grains', 'Tubers', 'Palm Oil', 'Honey', 'Fruits', 'Pepper', 'Spices'],
|
| 30 |
+
'Sports': ['Football', 'Fitness', 'Cycling', 'Camping', 'Boxing', 'Tennis', 'Swimming', 'Running'],
|
| 31 |
+
'Food': ['Snacks', 'Beverages', 'Coffee', 'Tea', 'Spices', 'Biscuits', 'Nuts', 'Chocolate'],
|
| 32 |
+
'Toys': ['Building', 'RC Cars', 'Dolls', 'Puzzles', 'Board Games', 'Plush', 'STEM', 'Music'],
|
| 33 |
+
'Books': ['African Lit', 'Textbooks', 'Children', 'Religious', 'Stationery', 'JAMB', 'WAEC', 'Dictionary'],
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
const SORTS = [
|
| 37 |
{ key: 'newest', label: 'Newest' },
|
| 38 |
{ key: 'popular', label: 'Popular' },
|
| 39 |
{ key: 'price_low', label: 'Price: Low → High' },
|
| 40 |
{ key: 'price_high', label: 'Price: High → Low' },
|
|
|
|
|
|
|
| 41 |
];
|
| 42 |
|
| 43 |
function CategoriesContent() {
|
|
|
|
| 45 |
const router = useRouter();
|
| 46 |
const initialCategory = params.get('category') || '';
|
| 47 |
const initialSort = params.get('sort') || 'newest';
|
| 48 |
+
const initialQuery = params.get('q') || '';
|
| 49 |
|
| 50 |
const [category, setCategory] = useState(initialCategory);
|
| 51 |
const [sort, setSort] = useState(initialSort);
|
| 52 |
+
const [searchQuery, setSearchQuery] = useState(initialQuery);
|
| 53 |
const [products, setProducts] = useState<Product[]>([]);
|
| 54 |
const [loading, setLoading] = useState(true);
|
| 55 |
const [showSortMenu, setShowSortMenu] = useState(false);
|
| 56 |
+
const [showSearch, setShowSearch] = useState(false);
|
| 57 |
|
| 58 |
const load = useCallback(async () => {
|
| 59 |
setLoading(true);
|
| 60 |
+
if (searchQuery.trim()) {
|
| 61 |
+
const result = await api.products.search(searchQuery, null);
|
| 62 |
+
if (result.success) {
|
| 63 |
+
setProducts(result.results || result.products || []);
|
| 64 |
+
}
|
| 65 |
+
} else {
|
| 66 |
+
const result = await api.products.category(category, sort, 1);
|
| 67 |
+
if (result.success) {
|
| 68 |
+
setProducts(result.products || []);
|
| 69 |
+
}
|
| 70 |
}
|
| 71 |
setLoading(false);
|
| 72 |
+
}, [category, sort, searchQuery]);
|
| 73 |
|
| 74 |
useEffect(() => { load(); }, [load]);
|
| 75 |
|
| 76 |
// Update URL when filter changes
|
| 77 |
+
const updateUrl = (cat: string, s: string) => {
|
| 78 |
+
const urlParams = new URLSearchParams();
|
| 79 |
+
if (cat) urlParams.set('category', cat);
|
| 80 |
+
if (s !== 'newest') urlParams.set('sort', s);
|
| 81 |
+
const qs = urlParams.toString();
|
| 82 |
+
router.replace(`/categories${qs ? '?' + qs : ''}`);
|
| 83 |
+
};
|
| 84 |
+
|
| 85 |
+
const handleCategoryChange = (cat: string) => {
|
| 86 |
+
setCategory(cat);
|
| 87 |
+
setSearchQuery('');
|
| 88 |
+
updateUrl(cat, sort);
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
const handleSortChange = (s: string) => {
|
| 92 |
+
setSort(s);
|
| 93 |
+
setShowSortMenu(false);
|
| 94 |
+
updateUrl(category, s);
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
const handleSearch = (e: React.FormEvent) => {
|
| 98 |
+
e.preventDefault();
|
| 99 |
+
if (searchQuery.trim()) {
|
| 100 |
+
load();
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
|
| 104 |
+
const activeCategoryLabel = ALL_CATEGORIES.find(c => c.value === category)?.label || 'All';
|
| 105 |
+
const subcats = category ? SUBCATEGORIES[category] || [] : [];
|
| 106 |
|
| 107 |
return (
|
| 108 |
+
<div className="bg-white min-h-screen">
|
| 109 |
+
{/* === MOBILE LAYOUT === */}
|
| 110 |
+
<div className="md:hidden">
|
| 111 |
+
{/* Search bar — full width with back arrow */}
|
| 112 |
+
<div className="sticky top-0 z-30 bg-white px-3 pt-3 pb-2 border-b border-slate-100">
|
| 113 |
+
<div className="flex items-center gap-2">
|
| 114 |
+
<Link href="/" className="shrink-0">
|
| 115 |
+
<ChevronLeft className="w-5 h-5 text-black" />
|
| 116 |
+
</Link>
|
| 117 |
+
<form onSubmit={handleSearch} className="flex-1 flex items-center bg-slate-100 rounded-full px-3 py-2">
|
| 118 |
+
<Search className="w-4 h-4 text-slate-400 mr-2" />
|
| 119 |
+
<input
|
| 120 |
+
type="text"
|
| 121 |
+
value={searchQuery}
|
| 122 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 123 |
+
placeholder="Search for items you want"
|
| 124 |
+
className="flex-1 bg-transparent outline-none text-sm text-black placeholder:text-slate-400"
|
| 125 |
+
/>
|
| 126 |
+
<Camera className="w-4 h-4 text-slate-500 ml-2" />
|
| 127 |
+
</form>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
|
| 131 |
+
{/* Category tabs with underline */}
|
| 132 |
+
<div className="flex items-center gap-5 px-3 py-2 overflow-x-auto no-scrollbar bg-white border-b border-slate-100">
|
| 133 |
+
{ALL_CATEGORIES.map((cat) => (
|
| 134 |
+
<button
|
| 135 |
+
key={cat.value}
|
| 136 |
+
onClick={() => handleCategoryChange(cat.value)}
|
| 137 |
+
className={`text-sm whitespace-nowrap pb-1.5 transition-colors ${
|
| 138 |
+
category === cat.value
|
| 139 |
+
? 'text-primary font-bold border-b-2 border-primary'
|
| 140 |
+
: 'text-black'
|
| 141 |
+
}`}
|
| 142 |
+
>
|
| 143 |
+
{cat.label}
|
| 144 |
+
</button>
|
| 145 |
+
))}
|
| 146 |
</div>
|
| 147 |
+
|
| 148 |
+
{/* Subcategory grid (5-column) */}
|
| 149 |
+
{subcats.length > 0 && (
|
| 150 |
+
<div className="grid grid-cols-5 gap-2 px-3 py-3 bg-white border-b border-slate-100">
|
| 151 |
+
{subcats.map((sub, i) => (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
<button
|
| 153 |
+
key={sub}
|
| 154 |
+
onClick={() => {
|
| 155 |
+
setSearchQuery(sub);
|
| 156 |
+
load();
|
| 157 |
+
}}
|
| 158 |
+
className="flex flex-col items-center gap-1"
|
| 159 |
>
|
| 160 |
+
<div className="w-11 h-11 rounded-full bg-slate-50 border border-slate-100 flex items-center justify-center text-lg">
|
| 161 |
+
{ALL_CATEGORIES.find(c => c.value === category)?.emoji || '🛍️'}
|
| 162 |
+
</div>
|
| 163 |
+
<span className="text-[10px] text-black text-center leading-tight truncate w-full">{sub}</span>
|
| 164 |
</button>
|
| 165 |
))}
|
| 166 |
</div>
|
| 167 |
)}
|
| 168 |
+
|
| 169 |
+
{/* Sort bar */}
|
| 170 |
+
<div className="flex items-center justify-between px-3 py-2 bg-white border-b border-slate-100">
|
| 171 |
+
<div className="text-xs text-slate-500">
|
| 172 |
+
{loading ? 'Loading...' : `${products.length} products`}
|
| 173 |
+
</div>
|
| 174 |
+
<div className="relative">
|
| 175 |
+
<button
|
| 176 |
+
onClick={() => setShowSortMenu(!showSortMenu)}
|
| 177 |
+
className="flex items-center gap-1 text-xs font-bold text-black px-3 py-1.5 rounded-lg border border-slate-200"
|
| 178 |
+
>
|
| 179 |
+
<Filter className="w-3 h-3" />
|
| 180 |
+
{SORTS.find(s => s.key === sort)?.label}
|
| 181 |
+
<ChevronDown className="w-3 h-3" />
|
| 182 |
+
</button>
|
| 183 |
+
{showSortMenu && (
|
| 184 |
+
<div className="absolute right-0 top-9 z-10 bg-white border border-slate-100 rounded-xl shadow-xl py-1 min-w-[180px]">
|
| 185 |
+
{SORTS.map((s) => (
|
| 186 |
+
<button
|
| 187 |
+
key={s.key}
|
| 188 |
+
onClick={() => handleSortChange(s.key)}
|
| 189 |
+
className={`block w-full text-left px-3 py-2 text-xs hover:bg-slate-50 ${
|
| 190 |
+
sort === s.key ? 'text-primary font-bold' : 'text-black'
|
| 191 |
+
}`}
|
| 192 |
+
>
|
| 193 |
+
{s.label}
|
| 194 |
+
</button>
|
| 195 |
+
))}
|
| 196 |
+
</div>
|
| 197 |
+
)}
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
|
| 201 |
+
{/* Product grid — 2-column Temu-style */}
|
| 202 |
+
<div className="grid grid-cols-2 gap-2 px-3 py-3">
|
| 203 |
+
{loading ? (
|
| 204 |
+
Array.from({ length: 8 }).map((_, i) => (
|
| 205 |
+
<div key={i} className="bg-slate-100 rounded-lg animate-pulse aspect-[3/4]" />
|
| 206 |
+
))
|
| 207 |
+
) : products.length === 0 ? (
|
| 208 |
+
<div className="col-span-2 text-center py-12">
|
| 209 |
+
<Store className="w-10 h-10 mx-auto text-slate-300 mb-2" />
|
| 210 |
+
<p className="text-sm text-slate-500">No products found</p>
|
| 211 |
+
</div>
|
| 212 |
+
) : (
|
| 213 |
+
products.map((p) => (
|
| 214 |
+
<MobileCategoryProductCard key={p.id} product={p} />
|
| 215 |
+
))
|
| 216 |
+
)}
|
| 217 |
+
</div>
|
| 218 |
</div>
|
| 219 |
|
| 220 |
+
{/* === DESKTOP LAYOUT === */}
|
| 221 |
+
<div className="hidden md:block">
|
| 222 |
+
{/* Top thin row */}
|
| 223 |
+
<div className="border-b border-slate-100">
|
| 224 |
+
<div className="max-w-7xl mx-auto px-6 py-2.5 flex items-center justify-between text-sm text-slate-600">
|
| 225 |
+
<div className="flex items-center gap-5">
|
| 226 |
+
<Link href="/" className="hover:text-primary flex items-center gap-1">
|
| 227 |
+
<ChevronLeft className="w-3.5 h-3.5" /> Back to home
|
| 228 |
+
</Link>
|
| 229 |
+
<span className="text-slate-200">|</span>
|
| 230 |
+
<Link href="/categories" className="hover:text-primary">All categories</Link>
|
| 231 |
+
<Link href="/sellers" className="hover:text-primary">Featured sellers</Link>
|
| 232 |
+
</div>
|
| 233 |
+
<div className="flex items-center gap-5">
|
| 234 |
+
<Link href="/profile" className="hover:text-primary">Buyer Central</Link>
|
| 235 |
+
<Link href="/telegram" className="hover:text-primary">Help Center</Link>
|
| 236 |
+
<Link href="/seller" className="hover:text-primary flex items-center gap-1">
|
| 237 |
+
<Store className="w-3.5 h-3.5" /> Sell on Cellex
|
| 238 |
+
</Link>
|
| 239 |
+
</div>
|
| 240 |
+
</div>
|
| 241 |
+
</div>
|
| 242 |
|
| 243 |
+
{/* Logo + big search */}
|
| 244 |
+
<div className="max-w-7xl mx-auto px-6 py-5 flex items-center gap-6">
|
| 245 |
+
<Link href="/" className="flex items-center gap-2 shrink-0">
|
| 246 |
+
<div className="w-10 h-10 rounded-xl brand-gradient flex items-center justify-center glow">
|
| 247 |
+
<span className="text-white font-extrabold text-xl" style={{ fontFamily: 'var(--font-geist-mono)' }}>C</span>
|
| 248 |
+
</div>
|
| 249 |
+
<span className="text-2xl font-extrabold brand-text" style={{ fontFamily: 'var(--font-geist-mono)' }}>
|
| 250 |
+
Cellex
|
| 251 |
+
</span>
|
| 252 |
+
</Link>
|
| 253 |
+
|
| 254 |
+
<form
|
| 255 |
+
onSubmit={handleSearch}
|
| 256 |
+
className="flex-1 max-w-3xl flex items-center border-2 border-primary rounded-full overflow-hidden"
|
| 257 |
+
>
|
| 258 |
+
<div className="px-3 py-2.5 text-slate-500 border-r border-slate-200 flex items-center gap-1">
|
| 259 |
+
<Camera className="w-4 h-4" />
|
| 260 |
+
<span className="text-xs">Image</span>
|
| 261 |
+
</div>
|
| 262 |
+
<input
|
| 263 |
+
type="text"
|
| 264 |
+
value={searchQuery}
|
| 265 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 266 |
+
placeholder="What are you looking for?"
|
| 267 |
+
className="flex-1 px-4 py-2.5 outline-none text-base"
|
| 268 |
+
/>
|
| 269 |
+
<button type="submit" className="brand-gradient text-white font-bold px-8 py-2.5 flex items-center gap-1.5">
|
| 270 |
+
<Search className="w-4 h-4" />
|
| 271 |
+
Search
|
| 272 |
+
</button>
|
| 273 |
+
</form>
|
| 274 |
+
|
| 275 |
+
<Link href="/cart" className="flex items-center gap-2 text-sm text-slate-600 hover:text-primary">
|
| 276 |
+
<Store className="w-5 h-5" />
|
| 277 |
+
<span>Cart</span>
|
| 278 |
+
</Link>
|
| 279 |
+
</div>
|
| 280 |
+
|
| 281 |
+
{/* Tabs row */}
|
| 282 |
+
<div className="border-b border-slate-100">
|
| 283 |
+
<div className="max-w-7xl mx-auto px-6 flex items-center gap-6">
|
| 284 |
+
<Link href="/ai-chat" className="flex items-center gap-1.5 py-3 text-sm font-bold text-slate-900 border-b-2 border-transparent hover:border-primary">
|
| 285 |
+
AI Mode
|
| 286 |
+
</Link>
|
| 287 |
+
<Link href="/categories" className="flex items-center gap-1.5 py-3 text-sm font-bold text-primary border-b-2 border-primary">
|
| 288 |
+
Products
|
| 289 |
+
</Link>
|
| 290 |
+
<Link href="/sellers" className="flex items-center gap-1.5 py-3 text-sm font-bold text-slate-900 border-b-2 border-transparent hover:border-primary">
|
| 291 |
+
Sellers
|
| 292 |
+
</Link>
|
| 293 |
+
<Link href="/live" className="flex items-center gap-1.5 py-3 text-sm font-bold text-slate-900 border-b-2 border-transparent hover:border-primary">
|
| 294 |
+
Live
|
| 295 |
+
</Link>
|
| 296 |
+
</div>
|
| 297 |
</div>
|
| 298 |
+
|
| 299 |
+
{/* Category pills + sort */}
|
| 300 |
+
<div className="max-w-7xl mx-auto px-6 py-4">
|
| 301 |
+
<div className="flex items-center justify-between mb-4">
|
| 302 |
+
<div className="flex items-center gap-2 overflow-x-auto no-scrollbar">
|
| 303 |
+
{ALL_CATEGORIES.map((cat) => (
|
| 304 |
+
<button
|
| 305 |
+
key={cat.value}
|
| 306 |
+
onClick={() => handleCategoryChange(cat.value)}
|
| 307 |
+
className={`text-sm font-medium px-4 py-1.5 rounded-full whitespace-nowrap transition-all ${
|
| 308 |
+
category === cat.value
|
| 309 |
+
? 'brand-gradient text-white font-bold'
|
| 310 |
+
: 'bg-slate-100 text-black hover:bg-slate-200'
|
| 311 |
+
}`}
|
| 312 |
+
>
|
| 313 |
+
{cat.emoji} {cat.label}
|
| 314 |
+
</button>
|
| 315 |
+
))}
|
| 316 |
+
</div>
|
| 317 |
+
|
| 318 |
+
<div className="flex items-center gap-3 shrink-0 ml-4">
|
| 319 |
+
<div className="text-sm text-slate-500">
|
| 320 |
+
{loading ? 'Loading...' : `${products.length} products`}
|
| 321 |
+
</div>
|
| 322 |
+
<div className="relative">
|
| 323 |
+
<button
|
| 324 |
+
onClick={() => setShowSortMenu(!showSortMenu)}
|
| 325 |
+
className="flex items-center gap-1 text-sm font-bold text-black px-3 py-1.5 rounded-lg border border-slate-200"
|
| 326 |
+
>
|
| 327 |
+
<Filter className="w-3.5 h-3.5" />
|
| 328 |
+
{SORTS.find(s => s.key === sort)?.label}
|
| 329 |
+
<ChevronDown className="w-3.5 h-3.5" />
|
| 330 |
+
</button>
|
| 331 |
+
{showSortMenu && (
|
| 332 |
+
<div className="absolute right-0 top-9 z-10 bg-white border border-slate-100 rounded-xl shadow-xl py-1 min-w-[180px]">
|
| 333 |
+
{SORTS.map((s) => (
|
| 334 |
+
<button
|
| 335 |
+
key={s.key}
|
| 336 |
+
onClick={() => handleSortChange(s.key)}
|
| 337 |
+
className={`block w-full text-left px-3 py-2 text-sm hover:bg-slate-50 ${
|
| 338 |
+
sort === s.key ? 'text-primary font-bold' : 'text-black'
|
| 339 |
+
}`}
|
| 340 |
+
>
|
| 341 |
+
{s.label}
|
| 342 |
+
</button>
|
| 343 |
+
))}
|
| 344 |
+
</div>
|
| 345 |
+
)}
|
| 346 |
+
</div>
|
| 347 |
+
</div>
|
| 348 |
+
</div>
|
| 349 |
+
|
| 350 |
+
{/* Subcategory chips */}
|
| 351 |
+
{subcats.length > 0 && (
|
| 352 |
+
<div className="flex items-center gap-2 mb-4 overflow-x-auto no-scrollbar">
|
| 353 |
+
{subcats.map((sub) => (
|
| 354 |
+
<button
|
| 355 |
+
key={sub}
|
| 356 |
+
onClick={() => { setSearchQuery(sub); load(); }}
|
| 357 |
+
className="shrink-0 text-xs font-medium text-black bg-slate-50 hover:bg-primary/10 hover:text-primary px-3 py-1.5 rounded-full border border-slate-100"
|
| 358 |
+
>
|
| 359 |
+
{sub}
|
| 360 |
+
</button>
|
| 361 |
+
))}
|
| 362 |
+
</div>
|
| 363 |
+
)}
|
| 364 |
+
|
| 365 |
+
{/* Product grid — 4-column on desktop */}
|
| 366 |
+
{loading ? (
|
| 367 |
+
<div className="grid grid-cols-4 gap-3">
|
| 368 |
+
{Array.from({ length: 12 }).map((_, i) => (
|
| 369 |
+
<div key={i} className="bg-slate-100 rounded-lg animate-pulse aspect-[3/4]" />
|
| 370 |
+
))}
|
| 371 |
+
</div>
|
| 372 |
+
) : products.length === 0 ? (
|
| 373 |
+
<div className="text-center py-16">
|
| 374 |
+
<Store className="w-12 h-12 mx-auto text-slate-300 mb-3" />
|
| 375 |
+
<p className="text-base text-slate-500">No products found</p>
|
| 376 |
+
</div>
|
| 377 |
+
) : (
|
| 378 |
+
<div className="grid grid-cols-4 gap-3">
|
| 379 |
+
{products.map((p) => (
|
| 380 |
+
<DesktopCategoryProductCard key={p.id} product={p} />
|
| 381 |
+
))}
|
| 382 |
+
</div>
|
| 383 |
+
)}
|
| 384 |
+
</div>
|
| 385 |
+
</div>
|
| 386 |
</div>
|
| 387 |
);
|
| 388 |
}
|
| 389 |
|
| 390 |
+
/* Mobile product card — Temu-style: image, title, badges, cyan price */
|
| 391 |
+
function MobileCategoryProductCard({ product }: { product: Product }) {
|
| 392 |
+
const isHot = typeof product.units_sold === 'number' && product.units_sold > 50;
|
| 393 |
+
const isBestseller = typeof product.units_sold === 'number' && product.units_sold > 200;
|
| 394 |
+
|
| 395 |
+
return (
|
| 396 |
+
<Link href={`/product?id=${product.id}`} className="bg-white rounded-lg overflow-hidden border border-slate-100">
|
| 397 |
+
<div className="aspect-square bg-slate-50 relative">
|
| 398 |
+
{product.image_url ? (
|
| 399 |
+
<img src={product.image_url} alt={product.name} className="w-full h-full object-cover" loading="lazy" />
|
| 400 |
+
) : (
|
| 401 |
+
<div className="w-full h-full flex items-center justify-center text-slate-300">
|
| 402 |
+
<Store className="w-10 h-10" />
|
| 403 |
+
</div>
|
| 404 |
+
)}
|
| 405 |
+
{isHot && (
|
| 406 |
+
<span className="absolute top-1.5 left-1.5 bg-primary text-white text-[10px] font-bold px-1.5 py-0.5 rounded flex items-center gap-0.5">
|
| 407 |
+
⚡ Hot
|
| 408 |
+
</span>
|
| 409 |
+
)}
|
| 410 |
+
</div>
|
| 411 |
+
<div className="p-2">
|
| 412 |
+
<div className="text-xs font-medium text-black line-clamp-2 h-8 leading-tight">
|
| 413 |
+
{product.name}
|
| 414 |
+
</div>
|
| 415 |
+
<div className="flex items-center gap-1 mt-1 flex-wrap">
|
| 416 |
+
<span className="bg-green-50 text-green-700 text-[9px] font-bold px-1 py-0.5 rounded border border-green-200">
|
| 417 |
+
Pay on delivery
|
| 418 |
+
</span>
|
| 419 |
+
{isBestseller && (
|
| 420 |
+
<span className="bg-primary text-white text-[9px] font-bold px-1 py-0.5 rounded">
|
| 421 |
+
Bestseller
|
| 422 |
+
</span>
|
| 423 |
+
)}
|
| 424 |
+
</div>
|
| 425 |
+
<div className="flex items-baseline gap-1 mt-1">
|
| 426 |
+
<span className="text-lg font-extrabold price leading-none">{formatPrice(product.price)}</span>
|
| 427 |
+
{typeof product.units_sold === 'number' && product.units_sold > 0 && (
|
| 428 |
+
<span className="text-[10px] text-slate-400">
|
| 429 |
+
{product.units_sold > 1000 ? `${(product.units_sold / 1000).toFixed(1)}k` : product.units_sold} sold
|
| 430 |
+
</span>
|
| 431 |
+
)}
|
| 432 |
+
</div>
|
| 433 |
+
{product.category && (
|
| 434 |
+
<div className="text-[10px] text-slate-500 mt-0.5">With Coupon · {product.category}</div>
|
| 435 |
+
)}
|
| 436 |
+
</div>
|
| 437 |
+
</Link>
|
| 438 |
+
);
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
/* Desktop product card */
|
| 442 |
+
function DesktopCategoryProductCard({ product }: { product: Product }) {
|
| 443 |
+
const isHot = typeof product.units_sold === 'number' && product.units_sold > 50;
|
| 444 |
+
const isBestseller = typeof product.units_sold === 'number' && product.units_sold > 200;
|
| 445 |
+
|
| 446 |
+
return (
|
| 447 |
+
<Link href={`/product?id=${product.id}`} className="block group">
|
| 448 |
+
<Card className="overflow-hidden border-slate-100 shadow-sm hover:shadow-md transition-all hover:-translate-y-0.5">
|
| 449 |
+
<div className="aspect-square bg-slate-50 relative">
|
| 450 |
+
{product.image_url ? (
|
| 451 |
+
<img src={product.image_url} alt={product.name} className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" loading="lazy" />
|
| 452 |
+
) : (
|
| 453 |
+
<div className="w-full h-full flex items-center justify-center text-slate-300">
|
| 454 |
+
<Store className="w-10 h-10" />
|
| 455 |
+
</div>
|
| 456 |
+
)}
|
| 457 |
+
{isHot && (
|
| 458 |
+
<span className="absolute top-2 left-2 bg-primary text-white text-xs font-bold px-2 py-0.5 rounded">
|
| 459 |
+
⚡ Hot
|
| 460 |
+
</span>
|
| 461 |
+
)}
|
| 462 |
+
</div>
|
| 463 |
+
<div className="p-3">
|
| 464 |
+
<div className="text-sm font-medium text-black line-clamp-2 h-10 leading-tight">
|
| 465 |
+
{product.name}
|
| 466 |
+
</div>
|
| 467 |
+
<div className="flex items-center gap-1.5 mt-1.5 flex-wrap">
|
| 468 |
+
<span className="bg-green-50 text-green-700 text-[10px] font-bold px-1.5 py-0.5 rounded border border-green-200">
|
| 469 |
+
Pay on delivery
|
| 470 |
+
</span>
|
| 471 |
+
{isBestseller && (
|
| 472 |
+
<span className="bg-primary text-white text-[10px] font-bold px-1.5 py-0.5 rounded">
|
| 473 |
+
Bestseller
|
| 474 |
+
</span>
|
| 475 |
+
)}
|
| 476 |
+
</div>
|
| 477 |
+
<div className="flex items-baseline gap-2 mt-1.5">
|
| 478 |
+
<span className="text-xl font-extrabold price">{formatPrice(product.price)}</span>
|
| 479 |
+
{typeof product.units_sold === 'number' && product.units_sold > 0 && (
|
| 480 |
+
<span className="text-xs text-slate-400">
|
| 481 |
+
{product.units_sold > 1000 ? `${(product.units_sold / 1000).toFixed(1)}k` : product.units_sold} sold
|
| 482 |
+
</span>
|
| 483 |
+
)}
|
| 484 |
+
</div>
|
| 485 |
+
{product.category && (
|
| 486 |
+
<div className="text-xs text-slate-500 mt-1">With Coupon · {product.category}</div>
|
| 487 |
+
)}
|
| 488 |
+
</div>
|
| 489 |
+
</Card>
|
| 490 |
+
</Link>
|
| 491 |
+
);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
export default function CategoriesPage() {
|
| 495 |
return (
|
| 496 |
<Suspense fallback={<div className="flex items-center justify-center min-h-[60vh]"><div className="w-8 h-8 border-3 border-slate-200 border-t-primary rounded-full animate-spin" /></div>}>
|
|
|
|
| 498 |
</Suspense>
|
| 499 |
);
|
| 500 |
}
|
|
|
src/app/layout.tsx
CHANGED
|
@@ -2,9 +2,9 @@ import type { Metadata } from "next";
|
|
| 2 |
import { Plus_Jakarta_Sans, Sora } from "next/font/google";
|
| 3 |
import "./globals.css";
|
| 4 |
import { Toaster } from "@/components/ui/toaster";
|
| 5 |
-
import { Navbar } from "@/components/navbar";
|
| 6 |
import { MobileNav } from "@/components/mobile-nav";
|
| 7 |
import { AuthProvider } from "@/components/auth-provider";
|
|
|
|
| 8 |
|
| 9 |
const jakarta = Plus_Jakarta_Sans({
|
| 10 |
variable: "--font-geist-sans",
|
|
@@ -38,9 +38,9 @@ export default function RootLayout({
|
|
| 38 |
className={`${jakarta.variable} ${sora.variable} antialiased bg-background text-foreground min-h-screen flex flex-col`}
|
| 39 |
>
|
| 40 |
<AuthProvider>
|
| 41 |
-
<
|
| 42 |
-
|
| 43 |
-
<
|
| 44 |
<Toaster />
|
| 45 |
</AuthProvider>
|
| 46 |
</body>
|
|
|
|
| 2 |
import { Plus_Jakarta_Sans, Sora } from "next/font/google";
|
| 3 |
import "./globals.css";
|
| 4 |
import { Toaster } from "@/components/ui/toaster";
|
|
|
|
| 5 |
import { MobileNav } from "@/components/mobile-nav";
|
| 6 |
import { AuthProvider } from "@/components/auth-provider";
|
| 7 |
+
import { LayoutShell } from "@/components/layout-shell";
|
| 8 |
|
| 9 |
const jakarta = Plus_Jakarta_Sans({
|
| 10 |
variable: "--font-geist-sans",
|
|
|
|
| 38 |
className={`${jakarta.variable} ${sora.variable} antialiased bg-background text-foreground min-h-screen flex flex-col`}
|
| 39 |
>
|
| 40 |
<AuthProvider>
|
| 41 |
+
<LayoutShell>
|
| 42 |
+
{children}
|
| 43 |
+
</LayoutShell>
|
| 44 |
<Toaster />
|
| 45 |
</AuthProvider>
|
| 46 |
</body>
|
src/app/page.tsx
CHANGED
|
@@ -91,7 +91,18 @@ function MobileHome({ flashDeals, trending, newArrivals, sellers, allProducts }:
|
|
| 91 |
sellers: any[];
|
| 92 |
allProducts: Product[];
|
| 93 |
}) {
|
| 94 |
-
const categoryTabs = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
const iconCategories = [
|
| 97 |
{ label: 'Flash Sale', icon: Zap, badge: 'Hot', href: '/categories?sort=flash', color: 'bg-primary' },
|
|
@@ -109,7 +120,7 @@ function MobileHome({ flashDeals, trending, newArrivals, sellers, allProducts }:
|
|
| 109 |
return (
|
| 110 |
<div className="bg-white min-h-screen">
|
| 111 |
{/* Search bar — full width */}
|
| 112 |
-
<div className="px-3 pt-3 pb-2 bg-white sticky top-
|
| 113 |
<div className="flex items-center bg-slate-100 rounded-full px-3 py-2">
|
| 114 |
<Search className="w-4 h-4 text-slate-400 mr-2" />
|
| 115 |
<input
|
|
@@ -146,15 +157,15 @@ function MobileHome({ flashDeals, trending, newArrivals, sellers, allProducts }:
|
|
| 146 |
<div className="flex items-center gap-4 px-3 py-2 overflow-x-auto no-scrollbar bg-white border-b border-slate-100">
|
| 147 |
{categoryTabs.map((tab, i) => (
|
| 148 |
<Link
|
| 149 |
-
key={tab}
|
| 150 |
-
href={tab
|
| 151 |
className={`text-sm whitespace-nowrap pb-1 ${
|
| 152 |
i === 0
|
| 153 |
? 'text-primary font-bold border-b-2 border-primary'
|
| 154 |
-
: 'text-
|
| 155 |
}`}
|
| 156 |
>
|
| 157 |
-
{tab}
|
| 158 |
</Link>
|
| 159 |
))}
|
| 160 |
</div>
|
|
|
|
| 91 |
sellers: any[];
|
| 92 |
allProducts: Product[];
|
| 93 |
}) {
|
| 94 |
+
const categoryTabs = [
|
| 95 |
+
{ label: 'All', href: '/' },
|
| 96 |
+
{ label: 'Electronics', href: '/categories?category=Electronics' },
|
| 97 |
+
{ label: 'Fashion', href: '/categories?category=Fashion' },
|
| 98 |
+
{ label: 'Home', href: '/categories?category=Home' },
|
| 99 |
+
{ label: 'Beauty', href: '/categories?category=Beauty' },
|
| 100 |
+
{ label: 'Farm', href: '/categories?category=Farm' },
|
| 101 |
+
{ label: 'Sports', href: '/categories?category=Sports' },
|
| 102 |
+
{ label: 'Food', href: '/categories?category=Food' },
|
| 103 |
+
{ label: 'Toys', href: '/categories?category=Toys' },
|
| 104 |
+
{ label: 'Books', href: '/categories?category=Books' },
|
| 105 |
+
];
|
| 106 |
|
| 107 |
const iconCategories = [
|
| 108 |
{ label: 'Flash Sale', icon: Zap, badge: 'Hot', href: '/categories?sort=flash', color: 'bg-primary' },
|
|
|
|
| 120 |
return (
|
| 121 |
<div className="bg-white min-h-screen">
|
| 122 |
{/* Search bar — full width */}
|
| 123 |
+
<div className="px-3 pt-3 pb-2 bg-white sticky top-0 z-30">
|
| 124 |
<div className="flex items-center bg-slate-100 rounded-full px-3 py-2">
|
| 125 |
<Search className="w-4 h-4 text-slate-400 mr-2" />
|
| 126 |
<input
|
|
|
|
| 157 |
<div className="flex items-center gap-4 px-3 py-2 overflow-x-auto no-scrollbar bg-white border-b border-slate-100">
|
| 158 |
{categoryTabs.map((tab, i) => (
|
| 159 |
<Link
|
| 160 |
+
key={tab.label}
|
| 161 |
+
href={tab.href}
|
| 162 |
className={`text-sm whitespace-nowrap pb-1 ${
|
| 163 |
i === 0
|
| 164 |
? 'text-primary font-bold border-b-2 border-primary'
|
| 165 |
+
: 'text-black'
|
| 166 |
}`}
|
| 167 |
>
|
| 168 |
+
{tab.label}
|
| 169 |
</Link>
|
| 170 |
))}
|
| 171 |
</div>
|
src/components/layout-shell.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client';
|
| 2 |
+
|
| 3 |
+
import { usePathname } from 'next/navigation';
|
| 4 |
+
import { MobileNav } from '@/components/mobile-nav';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* LayoutShell — conditionally renders the mobile bottom nav.
|
| 8 |
+
*
|
| 9 |
+
* Rules:
|
| 10 |
+
* - Login page (/login): NO mobile bottom nav (clean auth page)
|
| 11 |
+
* - All other pages: mobile bottom nav visible
|
| 12 |
+
* - The global top Navbar is removed entirely — the homepage has its own
|
| 13 |
+
* top nav built into its desktop/mobile layouts.
|
| 14 |
+
*/
|
| 15 |
+
export function LayoutShell({ children }: { children: React.ReactNode }) {
|
| 16 |
+
const pathname = usePathname();
|
| 17 |
+
|
| 18 |
+
// Hide mobile nav on login page
|
| 19 |
+
const hideMobileNav = pathname === '/login';
|
| 20 |
+
|
| 21 |
+
return (
|
| 22 |
+
<>
|
| 23 |
+
<main className={`flex-1 ${hideMobileNav ? '' : 'pb-20 md:pb-0'}`}>
|
| 24 |
+
{children}
|
| 25 |
+
</main>
|
| 26 |
+
{!hideMobileNav && <MobileNav />}
|
| 27 |
+
</>
|
| 28 |
+
);
|
| 29 |
+
}
|
src/components/mobile-nav.tsx
CHANGED
|
@@ -2,12 +2,12 @@
|
|
| 2 |
|
| 3 |
import Link from 'next/link';
|
| 4 |
import { usePathname } from 'next/navigation';
|
| 5 |
-
import { Home,
|
| 6 |
import { useAuth } from '@/components/auth-provider';
|
| 7 |
|
| 8 |
const navItems = [
|
| 9 |
{ href: '/', label: 'Home', icon: Home },
|
| 10 |
-
{ href: '/
|
| 11 |
{ href: '/videos', label: 'Discover', icon: Compass, center: true },
|
| 12 |
{ href: '/cart', label: 'Cart', icon: ShoppingCart, showBadge: true },
|
| 13 |
{ href: '/profile', label: 'Account', icon: User, showDot: true },
|
|
@@ -18,7 +18,7 @@ export function MobileNav() {
|
|
| 18 |
const { cartCount, user } = useAuth();
|
| 19 |
|
| 20 |
return (
|
| 21 |
-
<nav className="fixed bottom-0 left-0 right-0 z-50 bg-white
|
| 22 |
<div className="flex items-center justify-around max-w-lg mx-auto py-2 relative">
|
| 23 |
{navItems.map((item) => {
|
| 24 |
const isActive = pathname === item.href;
|
|
@@ -32,9 +32,7 @@ export function MobileNav() {
|
|
| 32 |
className="flex flex-col items-center gap-0.5"
|
| 33 |
style={{ transform: 'scale(1.15)' }}
|
| 34 |
>
|
| 35 |
-
<div
|
| 36 |
-
className="w-10 h-10 rounded-full brand-gradient flex items-center justify-center glow"
|
| 37 |
-
>
|
| 38 |
<Icon className="w-5 h-5 text-white" />
|
| 39 |
</div>
|
| 40 |
<span className="text-[10px] font-bold text-primary">{item.label}</span>
|
|
@@ -47,7 +45,7 @@ export function MobileNav() {
|
|
| 47 |
key={item.href}
|
| 48 |
href={item.href}
|
| 49 |
className={`flex flex-col items-center gap-0.5 relative ${
|
| 50 |
-
isActive ? 'text-primary' : 'text-
|
| 51 |
}`}
|
| 52 |
>
|
| 53 |
<div className="relative">
|
|
|
|
| 2 |
|
| 3 |
import Link from 'next/link';
|
| 4 |
import { usePathname } from 'next/navigation';
|
| 5 |
+
import { Home, MessageCircle, Compass, ShoppingCart, User } from 'lucide-react';
|
| 6 |
import { useAuth } from '@/components/auth-provider';
|
| 7 |
|
| 8 |
const navItems = [
|
| 9 |
{ href: '/', label: 'Home', icon: Home },
|
| 10 |
+
{ href: '/ai-chat', label: 'Chat', icon: MessageCircle },
|
| 11 |
{ href: '/videos', label: 'Discover', icon: Compass, center: true },
|
| 12 |
{ href: '/cart', label: 'Cart', icon: ShoppingCart, showBadge: true },
|
| 13 |
{ href: '/profile', label: 'Account', icon: User, showDot: true },
|
|
|
|
| 18 |
const { cartCount, user } = useAuth();
|
| 19 |
|
| 20 |
return (
|
| 21 |
+
<nav className="fixed bottom-0 left-0 right-0 z-50 bg-white border-t border-slate-200 md:hidden">
|
| 22 |
<div className="flex items-center justify-around max-w-lg mx-auto py-2 relative">
|
| 23 |
{navItems.map((item) => {
|
| 24 |
const isActive = pathname === item.href;
|
|
|
|
| 32 |
className="flex flex-col items-center gap-0.5"
|
| 33 |
style={{ transform: 'scale(1.15)' }}
|
| 34 |
>
|
| 35 |
+
<div className="w-10 h-10 rounded-full brand-gradient flex items-center justify-center glow">
|
|
|
|
|
|
|
| 36 |
<Icon className="w-5 h-5 text-white" />
|
| 37 |
</div>
|
| 38 |
<span className="text-[10px] font-bold text-primary">{item.label}</span>
|
|
|
|
| 45 |
key={item.href}
|
| 46 |
href={item.href}
|
| 47 |
className={`flex flex-col items-center gap-0.5 relative ${
|
| 48 |
+
isActive ? 'text-primary' : 'text-black'
|
| 49 |
}`}
|
| 50 |
>
|
| 51 |
<div className="relative">
|