From fccc8cecd2bda655922d7a4f7028de62bcc7f775 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Sat, 14 Nov 2026 12:53:58 +0530 Subject: [PATCH] feat(store-preview): add section navigation tabs, interactive category management, and align official Tradhox footer for PREPILOT-44 --- src/pages/StorePreviewPage.tsx | 1026 ++++++++++++++++++++++---------- 1 file changed, 711 insertions(+), 315 deletions(-) diff --git a/src/pages/StorePreviewPage.tsx b/src/pages/StorePreviewPage.tsx index 1f0fe98..f23ee17 100644 --- a/src/pages/StorePreviewPage.tsx +++ b/src/pages/StorePreviewPage.tsx @@ -2,8 +2,9 @@ import React, { useState, useEffect } from 'react'; import { Link, useParams } from 'react-router-dom'; import { useSeller } from '../context/SellerContext'; import { api } from '../services/api'; +import { CATEGORIES_WITH_SUBCATEGORIES } from '../data/categories'; -const products = [ +const fallbackProducts = [ { id: 'MW-DUP-012', title: 'Banarasi & Maheshwari Katan Silk Zari Dupatta', @@ -139,11 +140,17 @@ interface StoreDetails { is_verified?: boolean; categories?: string[]; total_products?: number; + gi_certificate_number?: string; + gi_certificate_url?: string; + gi_registry_verified?: boolean; + is_exclusive_gi?: boolean; + guild_status?: string; + gi_seller_type?: string; } export const StorePreviewPage: React.FC = () => { const { slug } = useParams<{ slug?: string }>(); - const { user, onboarding, inventory } = useSeller(); + const { user, onboarding, inventory, updateProfile } = useSeller(); const isCustomerView = Boolean(slug && slug !== 'preview'); @@ -158,14 +165,28 @@ export const StorePreviewPage: React.FC = () => { location: user?.profile?.city ? `${user?.profile?.city}, ${user?.profile?.state}` : (onboarding.city ? `${onboarding.city}, ${onboarding.state}` : 'Maheshwar, Madhya Pradesh (Est. 1994)'), craft_lineage_years: user?.profile?.craft_lineage_years || onboarding.craftLineageYears || 30, is_verified: user?.profile?.is_verified ?? true, - categories: onboarding.categories?.length ? onboarding.categories : ['Handicrafts', 'Handloom & Textiles', 'Pottery & Ceramics'] + categories: user?.profile?.categories && user.profile.categories.length > 0 + ? user.profile.categories + : (onboarding.categories?.length ? onboarding.categories : ['Handloom Textiles', 'GI Maheshwari Silk', 'Handicrafts']), + gi_certificate_number: user?.profile?.gi_certificate_number || '', + gi_certificate_url: user?.profile?.gi_certificate_url || '', + gi_registry_verified: Boolean(user?.profile?.gi_registry_verified), + is_exclusive_gi: Boolean(user?.profile?.is_exclusive_gi), + guild_status: user?.profile?.guild_status || '', + gi_seller_type: user?.profile?.gi_seller_type || 'non_gi' })); - const [activeProducts, setActiveProducts] = useState(products); + const [activeProducts, setActiveProducts] = useState(fallbackProducts); const [isFollowing, setIsFollowing] = useState(false); const [wishlist, setWishlist] = useState>({}); const [activeCategory, setActiveCategory] = useState('all'); const [sortBy, setSortBy] = useState('featured'); + const [activeSectionTab, setActiveSectionTab] = useState<'catalog' | 'heritage' | 'gi' | 'guarantees'>('catalog'); + + // Category management modal in preview mode + const [isCategoryModalOpen, setIsCategoryModalOpen] = useState(false); + const [categorySearch, setCategorySearch] = useState(''); + const [toastMsg, setToastMsg] = useState(''); const [showToast, setShowToast] = useState(false); const [toastTimeout, setToastTimeout] = useState(null); @@ -189,7 +210,13 @@ export const StorePreviewPage: React.FC = () => { location: res.store.location || 'India', craft_lineage_years: res.store.craft_lineage_years || 25, is_verified: res.store.is_verified ?? true, - categories: res.store.categories?.length ? res.store.categories : ['Handicrafts'] + categories: res.store.categories?.length ? res.store.categories : ['Handicrafts'], + gi_certificate_number: res.store.gi_certificate_number || '', + gi_certificate_url: res.store.gi_certificate_url || '', + gi_registry_verified: Boolean(res.store.gi_registry_verified), + is_exclusive_gi: Boolean(res.store.is_exclusive_gi), + guild_status: res.store.guild_status || '', + gi_seller_type: res.store.gi_seller_type || 'non_gi' }); } if (res?.products && Array.isArray(res.products) && res.products.length > 0) { @@ -220,7 +247,7 @@ export const StorePreviewPage: React.FC = () => { if (isMounted) setLoading(false); }); } else { - // Preview mode: sync current seller profile, banner, logo, and inventory + // Preview mode: sync current seller profile, banner, logo, categories, and inventory const banner = user?.profile?.banner_url || onboarding.bannerUrl || 'https://images.unsplash.com/photo-1606744837616-56c9a5c6a6eb?auto=format&fit=crop&w=1600&q=80'; const logo = user?.profile?.logo_url || user?.profile?.store_logo || onboarding.logoUrl || onboarding.artisanAvatar || 'https://images.unsplash.com/photo-1544717305-2782549b5136?auto=format&fit=crop&w=400&q=80'; const name = user?.profile?.store_name || user?.storeName || onboarding.storeName || 'My Store'; @@ -228,6 +255,10 @@ export const StorePreviewPage: React.FC = () => { ? `${user?.profile?.city}, ${user?.profile?.state}` : (onboarding.city ? `${onboarding.city}, ${onboarding.state}` : 'India'); + const cats = user?.profile?.categories && user.profile.categories.length > 0 + ? user.profile.categories + : (onboarding.categories?.length ? onboarding.categories : ['Handloom Textiles', 'GI Maheshwari Silk', 'Handicrafts']); + setStoreData(prev => ({ ...prev, name, @@ -239,6 +270,13 @@ export const StorePreviewPage: React.FC = () => { location: loc, craft_lineage_years: user?.profile?.craft_lineage_years || onboarding.craftLineageYears || 25, is_verified: user?.profile?.is_verified ?? true, + categories: cats, + gi_certificate_number: user?.profile?.gi_certificate_number || prev.gi_certificate_number || '', + gi_certificate_url: user?.profile?.gi_certificate_url || prev.gi_certificate_url || '', + gi_registry_verified: user?.profile?.gi_registry_verified !== undefined ? Boolean(user.profile.gi_registry_verified) : prev.gi_registry_verified, + is_exclusive_gi: user?.profile?.is_exclusive_gi !== undefined ? Boolean(user.profile.is_exclusive_gi) : prev.is_exclusive_gi, + guild_status: user?.profile?.guild_status || prev.guild_status || '', + gi_seller_type: user?.profile?.gi_seller_type || prev.gi_seller_type || 'non_gi' })); if (inventory && inventory.length > 0) { @@ -295,25 +333,71 @@ export const StorePreviewPage: React.FC = () => { displayToast('Storefront link copied to clipboard!'); }; + // Add / Remove Category Handlers + const handleToggleCategory = async (catName: string) => { + const currentCats = storeData.categories || []; + let updated: string[]; + if (currentCats.includes(catName)) { + updated = currentCats.filter(c => c !== catName); + } else { + updated = [...currentCats, catName]; + } + setStoreData(prev => ({ ...prev, categories: updated })); + try { + await updateProfile({ categories: updated }); + displayToast(`Craft category "${catName}" ${currentCats.includes(catName) ? 'removed' : 'added'}`); + } catch { + displayToast(`Saved locally: ${catName}`); + } + }; + + const handleRemoveCategory = async (catName: string) => { + const currentCats = storeData.categories || []; + const updated = currentCats.filter(c => c !== catName); + setStoreData(prev => ({ ...prev, categories: updated })); + try { + await updateProfile({ categories: updated }); + displayToast(`Removed "${catName}"`); + } catch { + displayToast(`Removed locally: ${catName}`); + } + }; + // Filter and Sort Logic - const categoryCounts = activeProducts.reduce>((acc, p) => { - acc['all'] = (acc['all'] || 0) + 1; - const cat = p.category ? p.category.toLowerCase().trim() : 'other'; - acc[cat] = (acc[cat] || 0) + 1; - return acc; - }, { all: activeProducts.length }); + const allCategorySet = new Set(); + activeProducts.forEach(p => { + if (p.category) allCategorySet.add(p.category.toLowerCase().trim()); + }); + if (storeData.categories) { + storeData.categories.forEach(c => allCategorySet.add(c.toLowerCase().trim())); + } const dynamicCategories = [ - { id: 'all', label: `All Handcrafts (${categoryCounts['all'] || 0})` }, - ...Object.keys(categoryCounts) - .filter(k => k !== 'all') - .map(k => ({ + { id: 'all', label: `All Handcrafts (${activeProducts.length})` }, + ...Array.from(allCategorySet).map(k => { + const count = activeProducts.filter(p => { + const pCat = (p.category || '').toLowerCase(); + const pTitle = (p.title || '').toLowerCase(); + const pDesc = (p.description || '').toLowerCase(); + const matchK = k.toLowerCase(); + return pCat === matchK || pCat.includes(matchK) || pTitle.includes(matchK) || pDesc.includes(matchK); + }).length; + const displayLabel = k.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); + return { id: k, - label: `${k.charAt(0).toUpperCase() + k.slice(1)} (${categoryCounts[k]})` - })) + label: `${displayLabel} (${count})` + }; + }) ]; - let displayedProducts = activeProducts.filter(p => activeCategory === 'all' || (p.category && p.category.toLowerCase().trim() === activeCategory)); + let displayedProducts = activeProducts.filter(p => { + if (activeCategory === 'all') return true; + const matchCat = activeCategory.toLowerCase(); + const pCat = (p.category || '').toLowerCase(); + const pTitle = (p.title || '').toLowerCase(); + const pDesc = (p.description || '').toLowerCase(); + return pCat === matchCat || pCat.includes(matchCat) || pTitle.includes(matchCat) || pDesc.includes(matchCat); + }); if (sortBy === 'price-asc') { displayedProducts.sort((a, b) => a.price - b.price); @@ -323,6 +407,12 @@ export const StorePreviewPage: React.FC = () => { displayedProducts.sort((a, b) => b.rating - a.rating); } + // Filtered categories for the picker modal + const filteredModalCategories = CATEGORIES_WITH_SUBCATEGORIES.filter(cat => + cat.label.toLowerCase().includes(categorySearch.toLowerCase()) || + cat.subcategories.some(sub => sub.toLowerCase().includes(categorySearch.toLowerCase())) + ); + if (loading) { return (
@@ -352,7 +442,8 @@ export const StorePreviewPage: React.FC = () => { } return ( -
+
+ {/* Header Bar */}
{isCustomerView ? ( @@ -382,7 +473,7 @@ export const StorePreviewPage: React.FC = () => { share Share - {user?.profile?.store_slug === storeData.slug && ( + {!isCustomerView && ( {
-
+ +
- {/* Top Workshop Ambient Scrim & Banner */} + {/* Top Workshop Ambient Banner */}
{ >
+ + {/* Top Verified Ribbon */}
- verified - {storeData.is_verified ? 'Verified Master Guild' : 'Artisan Workshop'} + + {storeData.gi_registry_verified ? 'verified_user' : 'verified'} + + + {storeData.gi_registry_verified ? 'Govt GI Registry Verified' : (storeData.is_verified ? 'Verified Master Guild' : 'Artisan Workshop')} +
{/* Artisan Storefront Header Card Overlap */} -
+
{/* Left identity cluster */}
@@ -429,18 +527,20 @@ export const StorePreviewPage: React.FC = () => { }} />
-
+
verified_user

{storeData.name}

- {storeData.is_verified ? 'Master Weaver Guild' : 'Craft Workshop'} + + {storeData.gi_registry_verified ? 'Govt GI Registry Verified' : (storeData.is_verified ? 'Master Weaver Guild' : 'Craft Workshop')} +

{storeData.location} {storeData.craft_lineage_years ? `· ${storeData.craft_lineage_years}+ Years Lineage` : ''}

-
+
workspace_premiumAuthentic Indian Heritage Provenance
@@ -449,17 +549,64 @@ export const StorePreviewPage: React.FC = () => {
-
- - eco 100% Direct Artisan Guild - - - token Assayed Quality Tested - - - award_star Verified Tradhox Partner + + {/* Active Craft Category Chips with + Add Category Button */} +
+ + category Craft Focus: + {storeData.categories && storeData.categories.map((cat, i) => ( + + {cat} + {!isCustomerView && ( + + )} + + ))} + {!isCustomerView && ( + + )}
+ + {/* GI Registration Certificate Row */} + {storeData.gi_certificate_number && ( +
+
+ verified + GI Reg No: {storeData.gi_certificate_number} + {storeData.gi_registry_verified ? ( + Govt Verified + ) : ( + Pending CRM Review + )} +
+ {storeData.gi_certificate_url && ( + + visibility + View GI Certificate + + )} +
+ )}
@@ -473,7 +620,7 @@ export const StorePreviewPage: React.FC = () => { {isFollowing ? 'Following Studio' : 'Follow Artisan'}
-
@@ -497,7 +644,7 @@ export const StorePreviewPage: React.FC = () => {
15,000+ Pins
-
Pan-India Courier
+
Pan-India Express Courier
@@ -510,253 +657,384 @@ export const StorePreviewPage: React.FC = () => {
+ + {/* Storefront Section Navigation Tabs */} +
+ + + + +
- - {/* Artisan Heritage Story & Provenance Bento Section */} -
-
-
-
-
-
- - Lineage & Heritage Provenance + {/* Tab 1: Complete Handcrafted Catalog Section */} + {(activeSectionTab === 'catalog' || activeSectionTab === 'heritage') && ( +
+
+
+
+
+ + Artisan Inventory
- About the Craft · Handcrafted Lineage +

Available Mastercrafts

-

- {storeData.name ? `${storeData.name} · Craft Tradition` : 'Generational Craft Heritage'} -

-

- {storeData.bio || 'Authentic generational mastercrafts crafted with natural indigenous heritage and time-honored traditional techniques.'} -

-

- Every piece created in our workshop preserves authentic indigenous artisan skills passed down through generations. Sourced from pure natural materials and crafted with human rhythm and meticulous hand finishing. -

-
-
- format_quote +
+
+ sort + + +
+
+
+ + {/* Category Filter Pills */} +
+ {dynamicCategories.map(cat => ( + + ))} + {!isCustomerView && ( + + )} +
+
+ + {/* Product Grid */} +
+ {displayedProducts.length === 0 ? ( +
+
+ inventory_2 +
+

No mastercrafts found

+

+ {activeCategory !== 'all' + ? `No products found under category "${activeCategory}". Switch back to view all artisan handcrafts.` + : 'This artisan studio is currently preparing and curating their handcrafted catalog.'} +

+ {activeCategory !== 'all' && ( + + )} +
+ ) : ( + displayedProducts.map(product => ( +
+
+ {product.title} { + (e.target as HTMLImageElement).src = 'https://images.unsplash.com/photo-1606744837616-56c9a5c6a6eb?auto=format&fit=crop&w=800&q=80'; + }} + /> + + {product.badge} + + +
+ SKU: {product.id} + {product.metaText} +
+
+
-

« {storeData.tagline || 'Authentic Handcrafted Treasures from Master Artisans'} »

-
- {storeData.name} Master Workshop - {storeData.location} +
+ star + {product.rating.toFixed(1)} + ({product.reviews}) +
+

{product.title}

+

{product.description}

+
+
+
+ ₹{product.price.toLocaleString('en-IN')} + {product.originalPrice && ( + ₹{product.originalPrice.toLocaleString('en-IN')} + )} + {product.discount && ( + {product.discount} + )} + {!product.originalPrice && ( + Standard Free Shipping + )} +
+
+ + {product.stockText} +
+ +
+
+
+ )))} +
+ + {/* Catalog Pagination */} +
+
+ Showing {displayedProducts.length} of {activeProducts.length} verified handcrafted products +
+
+ + 1 + + +
+
+
+ )} + + {/* Tab 2: Artisan Heritage Story & Provenance Bento Section */} + {(activeSectionTab === 'heritage' || activeSectionTab === 'catalog') && ( +
+
+
+
+
+
+ + Lineage & Heritage Provenance +
+ About the Craft · Handcrafted Lineage +
+

+ {storeData.name ? `${storeData.name} · Craft Tradition` : 'Generational Craft Heritage'} +

+

+ {storeData.bio || 'Authentic generational mastercrafts crafted with natural indigenous heritage and time-honored traditional techniques.'} +

+

+ Every piece created in our workshop preserves authentic indigenous artisan skills passed down through generations. Sourced from pure natural materials and crafted with human rhythm and meticulous hand finishing. +

+
+
+ format_quote +
+

« {storeData.tagline || 'Authentic Handcrafted Treasures from Master Artisans'} »

+
+ {storeData.name} Master Workshop + {storeData.location} +
-
-
-
- verified - GI Tag Verified - Govt of India -
-
- palette - Zero Synthetics - Natural Roots & Lac -
-
- handshake - 100% Direct Guild - Zero Middlemen -
-
- local_police - Silk Mark India - Assayed Purity -
-
-
-
-
- Weaving workshop -
-
- precision_manufacturing - Maheshwari Handloom Manufacturing Atelier & Pit Looms +
+
+ verified + GI Tag Verified + Govt of India +
+
+ palette + Zero Synthetics + Natural Roots & Lac +
+
+ handshake + 100% Direct Guild + Zero Middlemen +
+
+ local_police + Silk Mark India + Assayed Purity
-
- Zari preparation -
- Pre-loom Zari Preparation +
+
+ Weaving workshop +
+
+ precision_manufacturing + Handloom Manufacturing Atelier & Pit Looms +
+
-
-
- Bugdi pattern -
- Signature Reversible Borders +
+ Zari preparation +
+ Pre-loom Zari Preparation +
+
+
+ Bugdi pattern +
+ Signature Reversible Borders +
-
-
+
+ )} - {/* Complete Handcrafted Catalog Section */} -
-
-
-
-
- - Artisan Inventory + {/* Tab 3: GI Accreditation & Official Registry Credentials Section */} + {(activeSectionTab === 'gi' || activeSectionTab === 'catalog') && ( +
+
+
+
+
+ verified_user +
+
+
+

Geographical Indication (GI) Registry Status

+ + {storeData.gi_registry_verified ? 'Verified Active Seal' : 'Pending Verification'} + +
+

+ Official certification issued by the Geographical Indications Registry, Government of India. Confirms the origin, traditional artisan techniques, and indigenous heritage of all catalog items. +

+
-

Available Mastercrafts

-
-
-
- sort - - -
-
-
- - {/* Category Filter Pills */} -
- {dynamicCategories.map(cat => ( - - ))} -
-
- - {/* Product Grid */} -
- {displayedProducts.length === 0 ? ( -
-
- inventory_2 -
-

No mastercrafts found

-

- {activeCategory !== 'all' - ? 'No products found under this specific craft category. Switch back to view all artisan handcrafts.' - : 'This artisan studio is currently preparing and curating their handcrafted catalog.'} -

- {activeCategory !== 'all' && ( - + verified + View Official Certificate + )}
- ) : ( - displayedProducts.map(product => ( -
-
- {product.title} { - (e.target as HTMLImageElement).src = 'https://images.unsplash.com/photo-1606744837616-56c9a5c6a6eb?auto=format&fit=crop&w=800&q=80'; - }} - /> - - {product.badge} - - -
- SKU: {product.id} - {product.metaText} + +
+
+
GI Certificate Number
+
+ {storeData.gi_certificate_number || 'GI-REG-IN-2026-X'}
-
-
-
- star - {product.rating.toFixed(1)} - ({product.reviews}) -
-

{product.title}

-

{product.description}

+
+
Accreditation Tier
+
+ {storeData.is_exclusive_gi ? '100% Exclusive GI Guild' : 'Artisan Mixed Craft'}
-
-
- ₹{product.price.toLocaleString('en-IN')} - {product.originalPrice && ( - ₹{product.originalPrice.toLocaleString('en-IN')} - )} - {product.discount && ( - {product.discount} - )} - {!product.originalPrice && ( - Standard Free Shipping - )} -
-
- - {product.stockText} -
- +
+
+
Guild Status
+
+ {storeData.guild_status || 'Generational Master Weaver'} +
+
+
+
CRM Audit Verification
+
+ {storeData.gi_registry_verified ? 'check_circle' : 'hourglass_top'} + {storeData.gi_registry_verified ? 'Verified & Locked' : 'Under Review'}
- )))} -
- - {/* Catalog Pagination */} -
-
- Showing {displayedProducts.length} of {categoryCounts.all} verified handcrafted products
-
- - 1 - - - -
-
-
+ + )} - - - {/* Buyer Trust & Guarantees Strip */} -
+ {/* Tab 4: Buyer Trust & Guarantees Strip */} +
@@ -765,7 +1043,7 @@ export const StorePreviewPage: React.FC = () => {

Direct Artisan Payout

-

100% of product value goes straight into the master weaver bank escrow account.

+

100% of product value goes straight into the master artisan bank escrow account.

@@ -773,8 +1051,8 @@ export const StorePreviewPage: React.FC = () => { local_shipping
-

Pan-India Courier

-

Doorstep express delivery across 15,000+ pin codes with realtime live tracking.

+

Pan-India Express

+

Doorstep express courier across 15,000+ pin codes with realtime live tracking.

@@ -783,7 +1061,7 @@ export const StorePreviewPage: React.FC = () => {

Authenticity & Care

-

7-day transit damage protection guarantee and handcraft silk preservation guide.

+

7-day transit damage protection guarantee and handcraft preservation guide.

@@ -792,7 +1070,7 @@ export const StorePreviewPage: React.FC = () => {

GI Registry Guarantee

-

Authenticated government GI tag seals affixed to all handloom textile warps.

+

Authenticated government GI tag seals affixed to all mastercraft creations.

@@ -806,67 +1084,185 @@ export const StorePreviewPage: React.FC = () => { {toastMsg} + + {/* Category Picker Modal */} + {isCategoryModalOpen && ( +
+
+
+
+ category +

Manage Craft Categories

+
+ +
+ +
+
+ search + setCategorySearch(e.target.value)} + className="w-full pl-10 pr-4 py-2 bg-surface-container-low border border-outline-variant rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-primary" + /> +
+ +
+ Selected ({(storeData.categories || []).length}): Click to add or remove +
+ +
+ {filteredModalCategories.map(cat => ( +
+
+ +
+
+ {cat.subcategories.map((sub, idx) => { + const isSelected = (storeData.categories || []).includes(sub); + return ( + + ); + })} +
+
+ ))} +
+
+ +
+ +
+
+
+ )} -