eeshaAI commited on
Commit
caaae09
·
1 Parent(s): 89320ee

feat: Instagram-style social feed homepage + Discover nav → home

Browse files
Files changed (2) hide show
  1. src/app/page.tsx +368 -514
  2. src/components/mobile-nav.tsx +1 -1
src/app/page.tsx CHANGED
@@ -1,599 +1,453 @@
1
  'use client';
2
 
3
- import { useEffect, useState } from 'react';
4
- import { api, Product, formatPrice } from '@/lib/api';
 
5
  import { Card } from '@/components/ui/card';
6
- import { Badge } from '@/components/ui/badge';
7
  import { Button } from '@/components/ui/button';
8
- import Link from 'next/link';
9
  import {
10
- Flame, TrendingUp, Store, Radio, Video, Users, Sparkles, ChevronRight,
11
- Search, Camera, Zap, Tag, Gift, Crown, Heart, ShoppingBag,
12
- Layers, Headphones, Truck, ShieldCheck, Award, Star, Bot, ChevronDown,
13
- MessageCircle, HelpCircle, Image as ImageIcon, Check
14
  } from 'lucide-react';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  export default function HomePage() {
17
- const [flashDeals, setFlashDeals] = useState<Product[]>([]);
18
- const [trending, setTrending] = useState<Product[]>([]);
19
- const [newArrivals, setNewArrivals] = useState<Product[]>([]);
20
- const [sellers, setSellers] = useState<any[]>([]);
 
 
 
21
  const [loading, setLoading] = useState(true);
 
 
 
 
22
 
23
  useEffect(() => {
24
  (async () => {
25
  try {
26
- const [homeResp, sellersResp] = await Promise.all([
 
27
  api.products.home(),
28
- api.social.discover(12),
 
29
  ]);
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  if (homeResp.success) {
32
- setFlashDeals(homeResp.flashDeals || []);
33
- setTrending(homeResp.trending || []);
34
- setNewArrivals(homeResp.newArrivals || []);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
- if (sellersResp.success) {
37
- setSellers(sellersResp.sellers || []);
38
  }
39
  } catch (e) {
40
- console.error('Home load error:', e);
41
  } finally {
42
  setLoading(false);
43
  }
44
  })();
45
  }, []);
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  if (loading) {
48
  return (
49
  <div className="flex items-center justify-center min-h-[60vh]">
50
- <div className="w-8 h-8 border-3 border-slate-200 border-t-primary rounded-full animate-spin" />
51
  </div>
52
  );
53
  }
54
 
55
- const allProducts = [...flashDeals, ...trending, ...newArrivals];
56
-
57
- return (
58
- <>
59
- {/* MOBILE LAYOUT */}
60
- <div className="md:hidden home-mobile-layout">
61
- <MobileHome
62
- flashDeals={flashDeals}
63
- trending={trending}
64
- newArrivals={newArrivals}
65
- sellers={sellers}
66
- allProducts={allProducts}
67
- />
68
- </div>
69
-
70
- {/* DESKTOP LAYOUT — Alibaba.com exact structure, rebranded to Cellex */}
71
- <div className="hidden md:block home-desktop-layout">
72
- <DesktopHome
73
- flashDeals={flashDeals}
74
- trending={trending}
75
- newArrivals={newArrivals}
76
- sellers={sellers}
77
- allProducts={allProducts}
78
- />
79
- </div>
80
- </>
81
- );
82
- }
83
-
84
- /* ============================================================
85
- MOBILE HOME — Temu/Pinduoduo UI + AI banner + sellers
86
- ============================================================ */
87
- function MobileHome({ flashDeals, trending, newArrivals, sellers, allProducts }: {
88
- flashDeals: Product[];
89
- trending: Product[];
90
- newArrivals: Product[];
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' },
109
- { label: 'Trending', icon: TrendingUp, badge: '50%', href: '/categories?sort=trending', color: 'bg-primary' },
110
- { label: 'Group Buy', icon: Users, badge: null, href: '/group-buy', color: 'bg-pink-500' },
111
- { label: 'AI Mode', icon: Sparkles, badge: 'New', href: '/ai-chat', color: 'bg-violet-500' },
112
- { label: '₦9.9 Deals', icon: Tag, badge: 'Hot', href: '/categories?sort=flash', color: 'bg-primary' },
113
- { label: 'Live Now', icon: Radio, badge: null, href: '/live', color: 'bg-red-500' },
114
- { label: 'Top Up', icon: ShoppingBag, badge: null, href: '/categories', color: 'bg-blue-500' },
115
- { label: 'Save Big', icon: Crown, badge: null, href: '/categories?sort=flash', color: 'bg-primary' },
116
- { label: 'Coupons', icon: Gift, badge: null, href: '/categories', color: 'bg-orange-500' },
117
- { label: 'Free Gifts', icon: Heart, badge: null, href: '/categories', color: 'bg-blue-500' },
118
- ];
119
-
120
  return (
121
- <div className="bg-white min-h-screen">
122
- {/* Spotlight search trigger — taps open the glassmorphic spotlight */}
123
  <div className="px-3 pt-3 pb-2 bg-white sticky top-0 z-30">
124
  <button
125
  onClick={() => window.dispatchEvent(new CustomEvent('open-spotlight'))}
126
  className="w-full flex items-center bg-neutral-100 rounded-full px-4 py-2.5 hover:bg-neutral-200 transition-colors group"
127
  >
128
  <Search className="w-4 h-4 text-neutral-400 mr-2 group-hover:text-black transition-colors" />
129
- <span className="flex-1 text-left text-sm text-neutral-400 group-hover:text-black transition-colors">
130
- Search products, categories...
131
- </span>
132
- <kbd className="hidden sm:flex items-center gap-0.5 px-1.5 py-0.5 bg-white rounded text-[9px] font-bold text-neutral-400 border border-neutral-200">
133
- ⌘K
134
- </kbd>
135
  </button>
136
  </div>
137
 
138
- {/* AI Assistant banner */}
139
- <Link href="/ai-chat" className="block mx-3 mb-2">
140
- <div className="bg-gradient-to-r from-violet-500 to-primary rounded-xl p-3 flex items-center gap-3 text-white">
141
- <div className="w-10 h-10 rounded-full bg-white/20 backdrop-blur flex items-center justify-center shrink-0">
142
- <Bot className="w-5 h-5" />
143
- </div>
144
- <div className="flex-1 min-w-0">
145
- <div className="font-bold text-sm">AI Shopping Assistant</div>
146
- <div className="text-xs text-white/85">Chat with Qwen2.5-72B to find products</div>
147
- </div>
148
- <ChevronRight className="w-4 h-4 shrink-0" />
149
- </div>
150
- </Link>
151
-
152
- {/* Category tabs */}
153
- <div className="flex items-center gap-4 px-3 py-2 overflow-x-auto no-scrollbar bg-white border-b border-slate-100">
154
- {categoryTabs.map((tab, i) => (
155
- <Link
156
- key={tab.label}
157
- href={tab.href}
158
- className={`text-sm whitespace-nowrap pb-1 ${
159
- i === 0
160
- ? 'text-primary font-bold border-b-2 border-primary'
161
- : 'text-black'
162
- }`}
163
- >
164
- {tab.label}
165
- </Link>
166
- ))}
167
- </div>
168
-
169
- {/* Friends / Social bar */}
170
- <Link href="/sellers" className="flex items-center justify-between px-3 py-2.5 bg-white border-b border-slate-100">
171
- <div className="flex items-center gap-2">
172
- <div className="w-7 h-7 rounded-full bg-gradient-to-br from-violet-500 to-pink-500 flex items-center justify-center">
173
- <Users className="w-3.5 h-3.5 text-white" />
174
- </div>
175
- <span className="text-sm font-bold text-slate-900">Friends</span>
176
- </div>
177
- <div className="flex items-center gap-1 text-xs text-slate-500">
178
- View friends' activity
179
- <ChevronRight className="w-3 h-3" />
180
- </div>
181
- </Link>
182
-
183
- {/* 2x5 category icon grid */}
184
- <div className="grid grid-cols-5 gap-2 px-3 py-3 bg-white">
185
- {iconCategories.map((cat) => {
186
- const Icon = cat.icon;
187
- return (
188
  <Link
189
- key={cat.label}
190
- href={cat.href}
191
- className="flex flex-col items-center gap-1"
192
  >
193
- <div className={`w-11 h-11 rounded-full ${cat.color} flex items-center justify-center relative`}>
194
- <Icon className="w-5 h-5 text-white" />
195
- {cat.badge && (
196
- <span className="absolute -top-1 -right-1 bg-red-500 text-white text-[9px] font-bold px-1 py-0 rounded-full">
197
- {cat.badge}
198
- </span>
199
- )}
 
 
 
200
  </div>
201
- <span className="text-[10px] text-slate-700 text-center leading-tight">{cat.label}</span>
202
  </Link>
203
- );
204
- })}
205
- </div>
206
-
207
- {/* Promo strip */}
208
- <Link href="/categories?sort=flash" className="block mx-3 mb-3 bg-orange-50 border border-orange-200 rounded-lg p-2.5">
209
- <div className="flex items-center justify-between">
210
- <div>
211
- <div className="text-sm font-bold text-orange-700">🔥 Fast-selling products</div>
212
- <div className="text-xs text-orange-600">Limited time deals — up to 50% off</div>
213
- </div>
214
- <ChevronRight className="w-4 h-4 text-orange-600" />
215
  </div>
216
- </Link>
217
-
218
- {/* Top Sellers — horizontal scroll */}
219
- {sellers.length > 0 && (
220
- <div className="px-3 mb-3">
221
- <div className="flex items-center justify-between mb-2">
222
- <h2 className="text-sm font-bold text-slate-900">Top Sellers</h2>
223
- <Link href="/sellers" className="text-xs font-semibold text-primary flex items-center">
224
- See all <ChevronRight className="w-3 h-3" />
225
- </Link>
226
- </div>
227
- <div className="flex gap-2 overflow-x-auto no-scrollbar pb-1">
228
- {sellers.slice(0, 6).map((seller) => {
229
- const name = seller.business_name || seller.farm_name || 'Unnamed store';
230
- const initial = name.charAt(0).toUpperCase();
231
- const sellerProducts = allProducts.filter(p => p.seller_id === seller.id).slice(0, 1);
232
- return (
233
- <Link
234
- key={seller.id}
235
- href={`/seller-profile?id=${seller.id}`}
236
- className="shrink-0 w-32 bg-white rounded-lg border border-slate-100 overflow-hidden hover:shadow-md transition-shadow"
237
- >
238
- <div className="aspect-square bg-slate-50">
239
- {sellerProducts[0]?.image_url ? (
240
- <img src={sellerProducts[0].image_url} alt="" className="w-full h-full object-cover" />
241
- ) : (
242
- <div className="w-full h-full flex items-center justify-center text-slate-300">
243
- <Store className="w-8 h-8" />
244
- </div>
245
- )}
246
- </div>
247
- <div className="p-1.5">
248
- <div className="flex items-center gap-1">
249
- {seller.profile_image ? (
250
- <img src={seller.profile_image} className="w-5 h-5 rounded-full object-cover" alt="" />
251
- ) : (
252
- <div className="w-5 h-5 rounded-full brand-gradient flex items-center justify-center text-white font-bold text-[9px]">
253
- {initial}
254
- </div>
255
- )}
256
- <span className="font-bold text-[11px] text-slate-900 truncate">{name}</span>
257
- </div>
258
- <div className="text-[10px] text-slate-500 mt-0.5">{seller.followers || 0} followers</div>
259
- </div>
260
- </Link>
261
- );
262
- })}
263
  </div>
264
- </div>
265
  )}
266
 
267
- {/* Product grid — 2-column */}
268
- <div className="grid grid-cols-2 gap-2 px-3 pb-4">
269
- {allProducts.map((p) => (
270
- <MobileProductCard key={p.id} product={p} />
 
 
 
 
 
 
 
 
 
 
 
271
  ))}
272
  </div>
273
 
274
- {/* Quick links */}
275
- <div className="grid grid-cols-4 gap-2 px-3 pb-4">
276
- <Link href="/videos" className="bg-slate-900 rounded-xl p-2 text-center">
277
- <Video className="w-4 h-4 text-primary mx-auto mb-0.5" />
278
- <div className="text-[10px] font-semibold text-white">Videos</div>
279
- </Link>
280
- <Link href="/live" className="bg-primary rounded-xl p-2 text-center">
281
- <Radio className="w-4 h-4 text-white mx-auto mb-0.5" />
282
- <div className="text-[10px] font-semibold text-white">Live</div>
283
- </Link>
284
- <Link href="/group-buy" className="brand-gradient rounded-xl p-2 text-center">
285
- <Users className="w-4 h-4 text-white mx-auto mb-0.5" />
286
- <div className="text-[10px] font-semibold text-white">Group Buy</div>
287
- </Link>
288
- <Link href="/ai-chat" className="bg-violet-500 rounded-xl p-2 text-center">
289
- <Sparkles className="w-4 h-4 text-white mx-auto mb-0.5" />
290
- <div className="text-[10px] font-semibold text-white">AI</div>
291
- </Link>
292
  </div>
293
  </div>
294
  );
295
  }
296
 
297
- function MobileProductCard({ product }: { product: Product }) {
298
- const isHot = typeof product.units_sold === 'number' && product.units_sold > 50;
299
- const isBestseller = typeof product.units_sold === 'number' && product.units_sold > 200;
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
- return (
302
- <Link href={`/product?id=${product.id}`} className="bg-white rounded-lg overflow-hidden border border-slate-100">
303
- <div className="aspect-square bg-slate-50 relative">
304
- {product.image_url ? (
305
- <img src={product.image_url} alt={product.name} className="w-full h-full object-cover" loading="lazy" />
306
- ) : (
307
- <div className="w-full h-full flex items-center justify-center text-slate-300">
308
- <Store className="w-10 h-10" />
309
- </div>
310
- )}
311
- {isHot && (
312
- <span className="absolute top-1.5 left-1.5 bg-primary text-white text-[10px] font-bold px-1.5 py-0.5 rounded">
313
- Hot
314
- </span>
315
- )}
316
- </div>
317
- <div className="p-2">
318
- <div className="text-xs font-medium text-slate-800 line-clamp-2 h-8 leading-tight">
319
- {product.name}
320
- </div>
321
- <div className="flex items-center gap-1 mt-1 flex-wrap">
322
- <span className="bg-green-50 text-green-700 text-[9px] font-bold px-1 py-0.5 rounded border border-green-200">
323
- Pay on delivery
324
- </span>
325
- {isBestseller && (
326
- <span className="bg-primary text-white text-[9px] font-bold px-1 py-0.5 rounded">
327
- Bestseller
328
- </span>
329
- )}
330
- </div>
331
- <div className="flex items-baseline gap-1 mt-1">
332
- <span className="text-lg font-extrabold price leading-none">{formatPrice(product.price)}</span>
333
- {typeof product.units_sold === 'number' && product.units_sold > 0 && (
334
- <span className="text-[10px] text-slate-400">
335
- {product.units_sold > 1000 ? `${(product.units_sold / 1000).toFixed(1)}k` : product.units_sold} sold
336
- </span>
337
- )}
338
- </div>
339
- {product.category && (
340
- <div className="text-[10px] text-slate-500 mt-0.5">With Coupon · {product.category}</div>
341
- )}
342
- </div>
343
- </Link>
344
- );
345
- }
346
 
347
- /* ============================================================
348
- DESKTOP HOME — Alibaba.com EXACT structure, rebranded to Cellex
349
- Reference HTML: Pasted Content_1783816379023.txt
350
- ============================================================ */
351
- function DesktopHome({ flashDeals, trending, newArrivals, sellers, allProducts }: {
352
- flashDeals: Product[];
353
- trending: Product[];
354
- newArrivals: Product[];
355
- sellers: any[];
356
- allProducts: Product[];
357
- }) {
358
- return (
359
- <div className="bg-white min-h-screen pb-12">
360
- {/* ===== 1. Top nav row: logo + small links ===== */}
361
- <div className="border-b border-slate-100">
362
- <div className="max-w-7xl mx-auto px-6 py-2.5 flex items-center justify-between">
363
- {/* Logo left */}
364
- <Link href="/" className="flex items-center gap-2 shrink-0">
365
- <div className="w-9 h-9 rounded-xl brand-gradient flex items-center justify-center glow">
366
- <span className="text-white font-extrabold text-lg" style={{ fontFamily: 'var(--font-geist-mono)' }}>C</span>
367
- </div>
368
- <span className="text-xl font-extrabold brand-text" style={{ fontFamily: 'var(--font-geist-mono)' }}>
369
- Cellex.com
370
- </span>
371
- </Link>
372
 
373
- {/* Small links */}
374
- <div className="flex items-center gap-5 text-sm text-slate-600">
375
- <Link href="/categories" className="hover:text-primary flex items-center gap-1">
376
- <Layers className="w-3.5 h-3.5" /> All categories
377
- </Link>
378
- <Link href="/sellers" className="hover:text-primary">Featured selections</Link>
379
- <Link href="/orders" className="hover:text-primary">Order protections</Link>
380
- <span className="text-slate-200">|</span>
381
- <Link href="/profile" className="hover:text-primary">Buyer Central</Link>
382
- <Link href="/telegram" className="hover:text-primary">Help Center</Link>
383
- <Link href="/link-account" className="hover:text-primary">App & extension</Link>
384
- <Link href="/seller" className="hover:text-primary flex items-center gap-1">
385
- <Store className="w-3.5 h-3.5" /> Sell on Cellex
 
 
 
 
 
 
 
 
 
 
 
386
  </Link>
 
 
 
387
  </div>
 
 
 
388
  </div>
389
- </div>
390
-
391
- {/* ===== 2. Tabs row (AI Mode | Products | Manufacturers | Worldwide) — ABOVE search ===== */}
392
- <div className="max-w-7xl mx-auto px-6 pt-6 pb-2">
393
- <nav className="flex items-center gap-5" aria-label="Search tabs">
394
- <Link href="/ai-chat" className="flex items-center gap-1.5 text-base font-semibold text-slate-800 hover:text-primary group">
395
- <Sparkles className="w-4 h-4 text-primary" />
396
- <span>AI Mode</span>
397
- </Link>
398
- <span className="w-px h-5 bg-slate-200" />
399
- <Link href="/categories" className="text-base font-bold text-primary border-b-2 border-primary pb-1">
400
- Products
401
- </Link>
402
- <Link href="/sellers" className="text-base font-semibold text-slate-800 hover:text-primary">
403
- Manufacturers
404
- </Link>
405
- <Link href="/live" className="text-base font-semibold text-slate-800 hover:text-primary">
406
- Worldwide
407
- </Link>
408
- </nav>
409
- </div>
410
-
411
- {/* ===== 3. Big centered search bar (cyan border, Image Search left, cyan Search button right) ===== */}
412
- <div className="max-w-7xl mx-auto px-6 py-4">
413
- <form
414
- onSubmit={(e) => {
415
- e.preventDefault();
416
- const input = (e.target as HTMLFormElement).querySelector('input');
417
- if (input?.value.trim()) {
418
- window.location.href = `/search?q=${encodeURIComponent(input.value.trim())}`;
419
- }
420
- }}
421
- className="max-w-4xl mx-auto flex items-center border-2 border-primary rounded-full overflow-hidden bg-white"
422
- >
423
- <Link href="/categories" className="px-4 py-3 text-slate-600 hover:text-primary border-r border-slate-200 flex items-center gap-1.5 shrink-0">
424
- <Camera className="w-4 h-4" />
425
- <span className="text-sm">Image Search</span>
426
- </Link>
427
- <input
428
- type="text"
429
- placeholder="What are you looking for?"
430
- className="flex-1 px-4 py-3 outline-none text-base"
431
- />
432
  <button
433
- type="submit"
434
- className="brand-gradient text-white font-bold px-8 py-3 flex items-center gap-1.5 shrink-0"
 
 
435
  >
436
- <Search className="w-4 h-4" />
437
- Search
438
  </button>
439
- </form>
440
  </div>
441
 
442
- {/* ===== 4. "Connect with verified manufacturers" strip with 3 checkmark features ===== */}
443
- <div className="max-w-7xl mx-auto px-6 py-4">
444
- <div className="flex items-center justify-center gap-6 flex-wrap">
445
- <div className="text-base font-bold text-slate-900 flex items-center gap-2">
446
- Connect with verified
447
- <span className="brand-text text-lg">manufacturers</span>
448
- </div>
449
- <div className="flex items-center gap-5 text-sm text-slate-600">
450
- <span className="flex items-center gap-1.5">
451
- <div className="w-5 h-5 rounded-full bg-primary/10 flex items-center justify-center">
452
- <Check className="w-3 h-3 text-primary" />
453
- </div>
454
- 5K+ industries covered
455
- </span>
456
- <span className="flex items-center gap-1.5">
457
- <div className="w-5 h-5 rounded-full bg-primary/10 flex items-center justify-center">
458
- <Check className="w-3 h-3 text-primary" />
459
- </div>
460
- Factory-direct pricing
461
- </span>
462
- <span className="flex items-center gap-1.5">
463
- <div className="w-5 h-5 rounded-full bg-primary/10 flex items-center justify-center">
464
- <Check className="w-3 h-3 text-primary" />
465
- </div>
466
- Sample & customization
467
- </span>
468
  </div>
469
- </div>
470
- </div>
471
 
472
- {/* ===== 5. Welcome row (heading left, 3 CTAs right with circular icons) ===== */}
473
- <div className="max-w-7xl mx-auto px-6 py-6 flex items-center justify-between">
474
- <h2 className="text-2xl font-extrabold text-slate-900">Welcome to Cellex</h2>
475
- <div className="flex items-center gap-8">
476
- <Link href="/cart" className="flex flex-col items-center gap-1.5 group">
477
- <div className="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center group-hover:bg-primary/10">
478
- <ShoppingBag className="w-5 h-5 text-slate-700 group-hover:text-primary" />
479
  </div>
480
- <span className="text-xs text-slate-600">Request for Quotation</span>
481
- </Link>
482
- <Link href="/sellers" className="flex flex-col items-center gap-1.5 group">
483
- <div className="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center group-hover:bg-primary/10">
484
- <Crown className="w-5 h-5 text-slate-700 group-hover:text-primary" />
485
- </div>
486
- <span className="text-xs text-slate-600">Top Ranking</span>
487
- </Link>
488
- <Link href="/seller" className="flex flex-col items-center gap-1.5 group">
489
- <div className="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center group-hover:bg-primary/10">
490
- <Zap className="w-5 h-5 text-slate-700 group-hover:text-primary" />
491
  </div>
492
- <span className="text-xs text-slate-600">Fast customize</span>
493
- </Link>
494
- </div>
495
- </div>
496
-
497
- {/* ===== 6. 4-column category cards with LIST items + right arrows ===== */}
498
- <div className="max-w-7xl mx-auto px-6">
499
- <div className="grid grid-cols-4 gap-3">
500
- {/* Card 1: Categories for you */}
501
- <CategoryListCard
502
- title="Categories for you"
503
- icon={Layers}
504
- items={[
505
- { label: 'Apparel & Accessories', href: '/categories?category=Fashion' },
506
- { label: 'Electronics & Phones', href: '/categories?category=Electronics' },
507
- { label: 'Home & Kitchen', href: '/categories?category=Home' },
508
- ]}
509
- />
510
-
511
- {/* Card 2: Frequently searched — Smart Watches */}
512
- <CategoryListCard
513
- title="Frequently searched"
514
- icon={Zap}
515
- items={[
516
- { label: 'Smart Watches', href: '/categories?category=Electronics' },
517
- { label: 'Wireless Earbuds', href: '/categories?category=Electronics' },
518
- { label: 'Phone Accessories', href: '/categories?category=Electronics' },
519
- ]}
520
- />
521
-
522
- {/* Card 3: Frequently searched — Cars (we'll use Motors / Sports) */}
523
- <CategoryListCard
524
- title="Frequently searched"
525
- icon={TrendingUp}
526
- items={[
527
- { label: 'Auto Parts', href: '/categories?category=Sports' },
528
- { label: 'Motorcycle Gear', href: '/categories?category=Sports' },
529
- { label: 'Bikes & Cycling', href: '/categories?category=Sports' },
530
- ]}
531
- />
532
-
533
- {/* Card 4: Fast-selling products (orange highlighted) */}
534
- <CategoryListCard
535
- title="Fast-selling products"
536
- icon={Flame}
537
- highlighted
538
- items={[
539
- { label: 'Flash Deals', href: '/categories?sort=flash' },
540
- { label: 'Trending Now', href: '/categories?sort=trending' },
541
- { label: 'New Arrivals', href: '/categories?sort=newest' },
542
- ]}
543
- />
544
- </div>
545
  </div>
546
 
547
- {/* ===== Floating right-side chat widget (3 vertical icons) ===== */}
548
- <div className="fixed right-4 bottom-8 z-40 flex flex-col gap-2">
549
- <button className="w-11 h-11 rounded-full bg-white border border-slate-200 shadow-md flex items-center justify-center hover:border-primary hover:shadow-lg transition-all">
550
- <MessageCircle className="w-5 h-5 text-slate-600" />
 
 
 
 
 
 
 
551
  </button>
552
- <button className="w-11 h-11 rounded-full bg-white border border-slate-200 shadow-md flex items-center justify-center hover:border-primary hover:shadow-lg transition-all">
553
- <ImageIcon className="w-5 h-5 text-slate-600" />
554
  </button>
555
- <button className="w-11 h-11 rounded-full bg-white border border-slate-200 shadow-md flex items-center justify-center hover:border-primary hover:shadow-lg transition-all">
556
- <HelpCircle className="w-5 h-5 text-slate-600" />
557
  </button>
558
  </div>
559
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  );
561
  }
562
 
563
- /* Category card with title + LIST items + right arrows (matches reference exactly) */
564
- function CategoryListCard({ title, icon: Icon, items, highlighted }: {
565
- title: string;
566
- icon: any;
567
- items: { label: string; href: string }[];
568
- highlighted?: boolean;
569
- }) {
570
- return (
571
- <div className={`rounded-xl p-4 border ${
572
- highlighted ? 'bg-orange-50 border-orange-200' : 'bg-white border-slate-100'
573
- }`}>
574
- {/* Card title with icon */}
575
- <div className="flex items-center gap-2 mb-3">
576
- <Icon className={`w-4 h-4 ${highlighted ? 'text-orange-600' : 'text-slate-400'}`} />
577
- <h3 className={`text-sm font-bold ${highlighted ? 'text-orange-700' : 'text-slate-900'}`}>
578
- {title}
579
- </h3>
580
- </div>
581
 
582
- {/* List items with right arrows */}
583
- <div className="space-y-2">
584
- {items.map((item) => (
585
- <Link
586
- key={item.label}
587
- href={item.href}
588
- className={`flex items-center justify-between text-sm py-1.5 px-2 rounded-md hover:bg-white ${
589
- highlighted ? 'text-slate-700 hover:bg-orange-100' : 'text-slate-600 hover:bg-slate-50'
590
- } transition-colors`}
591
- >
592
- <span>{item.label}</span>
593
- <ChevronRight className="w-3.5 h-3.5 text-slate-400" />
594
- </Link>
595
- ))}
596
- </div>
597
- </div>
598
- );
599
  }
 
1
  'use client';
2
 
3
+ import { useEffect, useState, useRef, useCallback } from 'react';
4
+ import { 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 { motion } from 'framer-motion';
9
  import {
10
+ Search, Heart, MessageCircle, Share2, Bookmark, ShoppingBag,
11
+ Store, Radio, Users, TrendingUp, Flame, ChevronRight, Play,
12
+ CheckCircle, Plus
 
13
  } from 'lucide-react';
14
+ import Link from 'next/link';
15
+ import { useAuth } from '@/components/auth-provider';
16
+ import { useToast } from '@/hooks/use-toast';
17
+ import { useOptimisticUI } from '@/components/optimistic-ui';
18
+
19
+ interface FeedPost {
20
+ type: 'video' | 'product';
21
+ id: string;
22
+ sellerId?: string;
23
+ sellerName: string;
24
+ sellerImage?: string;
25
+ mediaUrl: string;
26
+ caption: string;
27
+ likes: number;
28
+ views?: number;
29
+ comments: number;
30
+ product?: Product;
31
+ soldCount?: number;
32
+ createdAt?: string;
33
+ isLive?: boolean;
34
+ verified?: boolean;
35
+ }
36
 
37
  export default function HomePage() {
38
+ const router = useRouter();
39
+ const { user } = useAuth();
40
+ const { toast } = useToast();
41
+ const { burst } = useOptimisticUI();
42
+
43
+ const [feed, setFeed] = useState<FeedPost[]>([]);
44
+ const [stories, setStories] = useState<any[]>([]);
45
  const [loading, setLoading] = useState(true);
46
+ const [likedPosts, setLikedPosts] = useState<Set<string>>(new Set());
47
+ const [savedPosts, setSavedPosts] = useState<Set<string>>(new Set());
48
+ const [following, setFollowing] = useState<Set<string>>(new Set());
49
+ const [liveCount, setLiveCount] = useState(0);
50
 
51
  useEffect(() => {
52
  (async () => {
53
  try {
54
+ const [vidResp, homeResp, storiesResp, liveResp] = await Promise.all([
55
+ api.videos.feed(20),
56
  api.products.home(),
57
+ api.stories.activeBar().catch(() => ({ success: false })),
58
+ api.live.list('live').catch(() => ({ success: false })),
59
  ]);
60
 
61
+ const posts: FeedPost[] = [];
62
+
63
+ // Add video posts
64
+ if (vidResp.success) {
65
+ (vidResp.videos || []).forEach((v: any) => {
66
+ const seller = v.seller || {};
67
+ posts.push({
68
+ type: 'video',
69
+ id: `vid-${v.id}`,
70
+ sellerId: seller.id,
71
+ sellerName: seller.business_name || 'Seller',
72
+ sellerImage: seller.profile_image,
73
+ mediaUrl: v.video_url || '',
74
+ caption: v.caption || '',
75
+ likes: v.likes_count || 0,
76
+ views: v.views_count || 0,
77
+ comments: Math.floor((v.views_count || 0) / 20),
78
+ product: v.product,
79
+ soldCount: v.product?.units_sold,
80
+ createdAt: v.created_at,
81
+ verified: true,
82
+ });
83
+ });
84
+ }
85
+
86
+ // Add product spotlight posts (interleaved)
87
  if (homeResp.success) {
88
+ const allProducts = [
89
+ ...(homeResp.flashDeals || []),
90
+ ...(homeResp.trending || []),
91
+ ...(homeResp.newArrivals || []),
92
+ ].filter((p, i, arr) => arr.findIndex(x => x.id === p.id) === i);
93
+
94
+ allProducts.forEach((p: Product) => {
95
+ posts.push({
96
+ type: 'product',
97
+ id: `prod-${p.id}`,
98
+ sellerName: 'Cellex Seller',
99
+ mediaUrl: p.image_url || '',
100
+ caption: p.name,
101
+ likes: Math.floor((p.units_sold || 0) * 0.3),
102
+ comments: Math.floor((p.units_sold || 0) * 0.1),
103
+ product: p,
104
+ soldCount: p.units_sold,
105
+ verified: true,
106
+ });
107
+ });
108
+ }
109
+
110
+ // Shuffle to create variable reward (slot machine effect)
111
+ posts.sort(() => Math.random() - 0.5);
112
+
113
+ setFeed(posts);
114
+
115
+ if (storiesResp.success) {
116
+ setStories(storiesResp.stories || []);
117
  }
118
+ if (liveResp.success) {
119
+ setLiveCount((liveResp.sessions || []).length);
120
  }
121
  } catch (e) {
122
+ console.error('Feed load error:', e);
123
  } finally {
124
  setLoading(false);
125
  }
126
  })();
127
  }, []);
128
 
129
+ const toggleLike = (postId: string, e: React.MouseEvent) => {
130
+ e.preventDefault();
131
+ e.stopPropagation();
132
+ const newLiked = new Set(likedPosts);
133
+ if (newLiked.has(postId)) {
134
+ newLiked.delete(postId);
135
+ } else {
136
+ newLiked.add(postId);
137
+ burst(e.clientX, e.clientY, 'heart');
138
+ }
139
+ setLikedPosts(newLiked);
140
+ };
141
+
142
+ const toggleSave = (postId: string, e: React.MouseEvent) => {
143
+ e.preventDefault();
144
+ e.stopPropagation();
145
+ const newSaved = new Set(savedPosts);
146
+ if (newSaved.has(postId)) {
147
+ newSaved.delete(postId);
148
+ } else {
149
+ newSaved.add(postId);
150
+ toast({ title: 'Saved!' });
151
+ }
152
+ setSavedPosts(newSaved);
153
+ };
154
+
155
+ const toggleFollow = (sellerId: string, e: React.MouseEvent) => {
156
+ e.preventDefault();
157
+ e.stopPropagation();
158
+ if (!user) { router.push('/login'); return; }
159
+ const newFollowing = new Set(following);
160
+ if (newFollowing.has(sellerId)) {
161
+ newFollowing.delete(sellerId);
162
+ api.social.unfollow(sellerId);
163
+ } else {
164
+ newFollowing.add(sellerId);
165
+ api.social.follow(sellerId);
166
+ toast({ title: 'Following!' });
167
+ }
168
+ setFollowing(newFollowing);
169
+ };
170
+
171
+ const addToCart = (product: Product, e: React.MouseEvent) => {
172
+ e.preventDefault();
173
+ e.stopPropagation();
174
+ if (!user) { router.push('/login'); return; }
175
+ api.cart.add(product.id, 1);
176
+ burst(e.clientX, e.clientY, 'check');
177
+ toast({ title: 'Added to cart!', description: product.name });
178
+ };
179
+
180
  if (loading) {
181
  return (
182
  <div className="flex items-center justify-center min-h-[60vh]">
183
+ <div className="loading-dots"><span></span><span></span><span></span></div>
184
  </div>
185
  );
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  return (
189
+ <div className="bg-white min-h-screen max-w-xl mx-auto">
190
+ {/* Search trigger */}
191
  <div className="px-3 pt-3 pb-2 bg-white sticky top-0 z-30">
192
  <button
193
  onClick={() => window.dispatchEvent(new CustomEvent('open-spotlight'))}
194
  className="w-full flex items-center bg-neutral-100 rounded-full px-4 py-2.5 hover:bg-neutral-200 transition-colors group"
195
  >
196
  <Search className="w-4 h-4 text-neutral-400 mr-2 group-hover:text-black transition-colors" />
197
+ <span className="flex-1 text-left text-sm text-neutral-400">Search products, categories...</span>
198
+ <kbd className="hidden sm:flex px-1.5 py-0.5 bg-white rounded text-[9px] font-bold text-neutral-400 border border-neutral-200">⌘K</kbd>
 
 
 
 
199
  </button>
200
  </div>
201
 
202
+ {/* Stories bar */}
203
+ {stories.length > 0 && (
204
+ <div className="flex gap-3 px-3 py-2 overflow-x-auto no-scrollbar border-b border-neutral-100">
205
+ {stories.slice(0, 10).map((s: any, i: number) => (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  <Link
207
+ key={i}
208
+ href={`/seller-profile?id=${s.seller_id || ''}`}
209
+ className="shrink-0 flex flex-col items-center gap-1"
210
  >
211
+ <div className="w-14 h-14 rounded-full p-[2px] bg-gradient-to-tr from-neutral-800 via-neutral-600 to-neutral-800">
212
+ <div className="w-full h-full rounded-full border-2 border-white overflow-hidden bg-neutral-100">
213
+ {s.profile_image ? (
214
+ <img src={s.profile_image} alt="" className="w-full h-full object-cover" />
215
+ ) : (
216
+ <div className="w-full h-full flex items-center justify-center">
217
+ <Store className="w-5 h-5 text-neutral-300" />
218
+ </div>
219
+ )}
220
+ </div>
221
  </div>
222
+ <span className="text-[10px] text-neutral-600 max-w-[60px] truncate">{s.business_name || 'Seller'}</span>
223
  </Link>
224
+ ))}
 
 
 
 
 
 
 
 
 
 
 
225
  </div>
226
+ )}
227
+
228
+ {/* Live Now indicator */}
229
+ {liveCount > 0 && (
230
+ <Link href="/live" className="block mx-3 mt-2">
231
+ <div className="flex items-center gap-2 bg-black text-white rounded-xl px-4 py-2.5 hover:bg-neutral-800 transition-colors">
232
+ <span className="flex items-center gap-1.5">
233
+ <span className="w-2 h-2 bg-red-500 rounded-full animate-pulse" />
234
+ <span className="text-xs font-bold">LIVE NOW</span>
235
+ </span>
236
+ <span className="text-xs text-white/70">{liveCount} seller{liveCount > 1 ? 's' : ''} streaming</span>
237
+ <ChevronRight className="w-4 h-4 ml-auto" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  </div>
239
+ </Link>
240
  )}
241
 
242
+ {/* Feed */}
243
+ <div className="space-y-0">
244
+ {feed.map((post, index) => (
245
+ <FeedPostCard
246
+ key={post.id}
247
+ post={post}
248
+ index={index}
249
+ liked={likedPosts.has(post.id)}
250
+ saved={savedPosts.has(post.id)}
251
+ isFollowing={post.sellerId ? following.has(post.sellerId) : false}
252
+ onLike={(e) => toggleLike(post.id, e)}
253
+ onSave={(e) => toggleSave(post.id, e)}
254
+ onFollow={(e) => post.sellerId && toggleFollow(post.sellerId, e)}
255
+ onAddToCart={(e) => post.product && addToCart(post.product, e)}
256
+ />
257
  ))}
258
  </div>
259
 
260
+ {/* End of feed */}
261
+ <div className="text-center py-8">
262
+ <p className="text-xs text-neutral-400">You're all caught up ✨</p>
263
+ <p className="text-[10px] text-neutral-300 mt-1">Check back for more drops</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  </div>
265
  </div>
266
  );
267
  }
268
 
269
+ function FeedPostCard({
270
+ post, index, liked, saved, isFollowing, onLike, onSave, onFollow, onAddToCart
271
+ }: {
272
+ post: FeedPost;
273
+ index: number;
274
+ liked: boolean;
275
+ saved: boolean;
276
+ isFollowing: boolean;
277
+ onLike: (e: React.MouseEvent) => void;
278
+ onSave: (e: React.MouseEvent) => void;
279
+ onFollow: (e: React.MouseEvent) => void;
280
+ onAddToCart: (e: React.MouseEvent) => void;
281
+ }) {
282
+ const videoRef = useRef<HTMLVideoElement>(null);
283
+ const [inView, setInView] = useState(false);
284
 
285
+ useEffect(() => {
286
+ const observer = new IntersectionObserver(
287
+ ([entry]) => setInView(entry.isIntersecting),
288
+ { threshold: 0.5 }
289
+ );
290
+ if (videoRef.current) observer.observe(videoRef.current);
291
+ return () => observer.disconnect();
292
+ }, []);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
 
294
+ useEffect(() => {
295
+ if (videoRef.current) {
296
+ if (inView) videoRef.current.play().catch(() => {});
297
+ else videoRef.current.pause();
298
+ }
299
+ }, [inView]);
300
+
301
+ const isVideo = post.type === 'video';
302
+ const likeCount = post.likes + (liked ? 1 : 0);
303
+ const fomoText = post.soldCount && post.soldCount > 10
304
+ ? `🔥 ${post.soldCount > 1000 ? `${(post.soldCount / 1000).toFixed(1)}k` : post.soldCount} people bought this`
305
+ : post.views && post.views > 100
306
+ ? `👀 ${post.views} people viewing now`
307
+ : null;
 
 
 
 
 
 
 
 
 
 
 
308
 
309
+ return (
310
+ <motion.div
311
+ initial={{ opacity: 0, y: 20 }}
312
+ animate={{ opacity: 1, y: 0 }}
313
+ transition={{ duration: 0.3, delay: Math.min(index * 0.05, 0.3) }}
314
+ className="border-b border-neutral-100"
315
+ >
316
+ {/* Seller header */}
317
+ <div className="flex items-center gap-2.5 px-3 py-2.5">
318
+ <Link href={post.sellerId ? `/seller-profile?id=${post.sellerId}` : '#'}>
319
+ <div className="w-9 h-9 rounded-full overflow-hidden bg-neutral-100 shrink-0">
320
+ {post.sellerImage ? (
321
+ <img src={post.sellerImage} alt="" className="w-full h-full object-cover" />
322
+ ) : (
323
+ <div className="w-full h-full flex items-center justify-center bg-black">
324
+ <span className="text-white text-sm font-bold">{post.sellerName.charAt(0)}</span>
325
+ </div>
326
+ )}
327
+ </div>
328
+ </Link>
329
+ <div className="flex-1 min-w-0">
330
+ <div className="flex items-center gap-1">
331
+ <Link href={post.sellerId ? `/seller-profile?id=${post.sellerId}` : '#'} className="text-sm font-bold text-black truncate hover:underline">
332
+ {post.sellerName}
333
  </Link>
334
+ {post.verified && (
335
+ <CheckCircle className="w-3.5 h-3.5 text-black fill-black stroke-white shrink-0" />
336
+ )}
337
  </div>
338
+ {post.createdAt && (
339
+ <div className="text-[10px] text-neutral-400">{timeAgo(post.createdAt)}</div>
340
+ )}
341
  </div>
342
+ {post.sellerId && (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  <button
344
+ onClick={onFollow}
345
+ className={`text-xs font-bold px-3 py-1.5 rounded-full transition-all ${
346
+ isFollowing ? 'bg-neutral-100 text-neutral-600' : 'bg-black text-white hover:bg-neutral-800'
347
+ }`}
348
  >
349
+ {isFollowing ? 'Following' : 'Follow'}
 
350
  </button>
351
+ )}
352
  </div>
353
 
354
+ {/* Media */}
355
+ <div className="relative bg-neutral-50 aspect-square overflow-hidden">
356
+ {isVideo ? (
357
+ <video
358
+ ref={videoRef}
359
+ src={post.mediaUrl}
360
+ muted
361
+ loop
362
+ playsInline
363
+ className="w-full h-full object-cover"
364
+ />
365
+ ) : (
366
+ <Link href={post.product ? `/product?id=${post.product.id}` : '#'}>
367
+ <img src={post.mediaUrl} alt={post.caption} className="w-full h-full object-cover" loading="lazy" />
368
+ </Link>
369
+ )}
370
+
371
+ {/* FOMO overlay */}
372
+ {fomoText && (
373
+ <div className="absolute top-3 left-3 bg-black/70 backdrop-blur-sm text-white text-[10px] font-bold px-2.5 py-1 rounded-full">
374
+ {fomoText}
 
 
 
 
 
375
  </div>
376
+ )}
 
377
 
378
+ {/* Product badge */}
379
+ {post.product && (
380
+ <div className="absolute bottom-3 left-3 right-3 bg-white/90 backdrop-blur-md rounded-xl p-2.5 flex items-center gap-2.5">
381
+ <div className="w-10 h-10 rounded-lg overflow-hidden bg-neutral-100 shrink-0">
382
+ {post.product.image_url && (
383
+ <img src={post.product.image_url} alt="" className="w-full h-full object-cover" />
384
+ )}
385
  </div>
386
+ <div className="flex-1 min-w-0">
387
+ <div className="text-xs font-bold text-black truncate">{post.product.name}</div>
388
+ <div className="text-sm font-extrabold text-black">{formatPrice(post.product.price)}</div>
 
 
 
 
 
 
 
 
389
  </div>
390
+ <button
391
+ onClick={onAddToCart}
392
+ className="bg-black text-white text-xs font-bold px-3 py-2 rounded-lg hover:bg-neutral-800 transition-colors shrink-0 active:scale-95"
393
+ >
394
+ Buy Now
395
+ </button>
396
+ </div>
397
+ )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  </div>
399
 
400
+ {/* Action bar */}
401
+ <div className="flex items-center gap-4 px-3 py-2.5">
402
+ <button onClick={onLike} className="flex items-center gap-1.5 group">
403
+ <motion.div whileTap={{ scale: 1.3 }}>
404
+ <Heart className={`w-6 h-6 transition-colors ${liked ? 'fill-black text-black' : 'text-black'}`} />
405
+ </motion.div>
406
+ <span className="text-xs font-semibold text-black">{formatCount(likeCount)}</span>
407
+ </button>
408
+ <button className="flex items-center gap-1.5">
409
+ <MessageCircle className="w-6 h-6 text-black" />
410
+ <span className="text-xs font-semibold text-black">{formatCount(post.comments)}</span>
411
  </button>
412
+ <button className="flex items-center gap-1.5">
413
+ <Share2 className="w-6 h-6 text-black" />
414
  </button>
415
+ <button onClick={onSave} className="ml-auto">
416
+ <Bookmark className={`w-6 h-6 transition-colors ${saved ? 'fill-black text-black' : 'text-black'}`} />
417
  </button>
418
  </div>
419
+
420
+ {/* Caption */}
421
+ <div className="px-3 pb-3">
422
+ <p className="text-sm text-black">
423
+ <span className="font-bold mr-1.5">{post.sellerName}</span>
424
+ {post.caption}
425
+ </p>
426
+ {post.product?.category && (
427
+ <p className="text-xs text-neutral-400 mt-1">#{post.product.category.toLowerCase().replace(/\s+/g, '')}</p>
428
+ )}
429
+ {post.comments > 0 && (
430
+ <button className="text-xs text-neutral-400 mt-1.5 hover:text-black transition-colors">
431
+ View all {post.comments} comments
432
+ </button>
433
+ )}
434
+ </div>
435
+ </motion.div>
436
  );
437
  }
438
 
439
+ function timeAgo(iso?: string): string {
440
+ if (!iso) return '';
441
+ const d = new Date(iso);
442
+ const diff = (Date.now() - d.getTime()) / 1000;
443
+ if (diff < 3600) return Math.floor(diff / 60) + 'm ago';
444
+ if (diff < 86400) return Math.floor(diff / 3600) + 'h ago';
445
+ if (diff < 604800) return Math.floor(diff / 86400) + 'd ago';
446
+ return d.toLocaleDateString();
447
+ }
 
 
 
 
 
 
 
 
 
448
 
449
+ function formatCount(n: number): string {
450
+ if (n >= 1000000) return `${(n / 1000000).toFixed(1)}M`;
451
+ if (n >= 1000) return `${(n / 1000).toFixed(1)}K`;
452
+ return String(n);
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  }
src/components/mobile-nav.tsx CHANGED
@@ -8,7 +8,7 @@ import { useAuth } from '@/components/auth-provider';
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 },
14
  ];
 
8
  const navItems = [
9
  { href: '/', label: 'Home', icon: Home },
10
  { href: '/ai-chat', label: 'Chat', icon: MessageCircle },
11
+ { href: '/', label: 'Discover', icon: Compass, center: true },
12
  { href: '/cart', label: 'Cart', icon: ShoppingCart, showBadge: true },
13
  { href: '/profile', label: 'Account', icon: User, showDot: true },
14
  ];