import React from 'react'; import { useLocation, useNavigate, useParams } from 'react-router-dom'; import { MobileShell } from '../../components/layout/MobileShell'; import { GridProductCard } from '../../components/common/GridProductCard'; import { EmptyStateBox, RetryBanner, ShimmerBox, StoreBoothBodyShimmer, } from '../../components/common/ShimmerSkeletons'; import { TWO_COLUMN_GRID_PRODUCTS } from '../../data/catalogData'; import { useShopApp } from '../../context/ShopAppContext'; import { useSmartBack } from '../../hooks/useSmartBack'; import { resolveMediaUrl } from '../../lib/http'; import { mapProductToGridItem } from '../../lib/mappers'; import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes'; import { useStoreDetailQuery } from '../../lib/shopQueries'; import { copyToClipboard } from '../../lib/webview-actions'; /** * Node 4129:15733 — `shop-Booth` (375×1233) */ export const ShopBoothPage: React.FC = () => { const navigate = useNavigate(); const location = useLocation(); const isBare = isBareMode(location.search); const useMockFallback = isBare || USE_MOCK_DATA; const { storeId } = useParams<{ storeId?: string }>(); const smartBack = useSmartBack(ROUTES.home); const { requireAuth, isBookmarked, toggleBookmark, showToast } = useShopApp(); const resolvedSlug = storeId || 'tashakol-farzandan-rohhallah'; const storeQuery = useStoreDetailQuery(resolvedSlug, !isBare); const store = storeQuery.data ?? null; const loading = !isBare && (storeQuery.isPending || (!store && storeQuery.isFetching)); const loadError = !isBare && storeQuery.isError; const liveStore = !isBare ? store : null; const handleShare = async () => { const url = window.location.href; const shareData: ShareData = { title: liveStore?.name || 'TashakolFarzandan Rohhallah', url, }; if ( typeof navigator !== 'undefined' && typeof navigator.share === 'function' && (!navigator.canShare || navigator.canShare(shareData)) ) { try { await navigator.share(shareData); return; } catch (err) { if ( (err instanceof DOMException || err instanceof Error) && (err.name === 'AbortError' || err.name === 'InvalidStateError') ) { return; } } } const didCopy = await copyToClipboard(url); showToast(didCopy ? 'Store link copied' : 'Could not copy link'); }; return ( {/* Top Banner Calligraphy Image & Floating Actions */}
{!isBare && loading ? ( ) : ( )}
{/* Right Top Actions */}
{!isBare && loading ? ( ) : !liveStore && !useMockFallback ? (
{loadError && ( void storeQuery.refetch()} /> )}
) : (
{/* Circular Store Avatar */} {liveStore?.name {/* Store Title */}

{liveStore?.name || 'TashakolFarzandan Rohhallah'}

{/* Iran Flag + Origin */}
Origin {liveStore ? [liveStore.country, liveStore.city].filter(Boolean).join(' | ') : 'Iran | Tehran'}
{!isBare && loadError && !store && (
void storeQuery.refetch()} />
)} {/* Store Stats Row */}
{liveStore ? `${Number( useMockFallback ? liveStore.rating_avg || 4.4 : liveStore.rating_avg ?? 0 ).toFixed(1)} (${ liveStore.reviews_count ?? (useMockFallback ? 608 : 0) })` : '4.4 (608)'}
{liveStore?.membership_label || '+1 year membership'}
{liveStore?.sales_label || '+60 sales'}
{/* 3 Store Metric Cards */}
{/* Card 1: Avg. Response -> Opens Store Chat */}
{ const target = ROUTES.chatThread(liveStore?.slug || resolvedSlug); if (isBare) { navigate(target); return; } void requireAuth({ featureName: 'booth chat', onAuthenticated: () => navigate(target), }); }} style={{ minHeight: 58, padding: '8px', borderRadius: 8, backgroundColor: '#efece9', border: '1px solid #e8e4df', cursor: 'pointer', display: 'flex', flexDirection: 'column', justifyContent: 'space-between', minWidth: 0, }} >
{liveStore?.avg_response_time || '2h'}
Avg. Response
{/* Card 2: On-time Delivery */}
{liveStore ? `${String(liveStore.on_time_delivery_rate).replace(/%+$/, '')}%` : '87%'}
On-time Delivery
{/* Card 3: Satisfaction */}
{liveStore ? `${String(liveStore.satisfaction_rate).replace(/%+$/, '')}%` : '98%'}
Satisfaction
{/* About Section */}
About
{liveStore?.description || (useMockFallback ? 'In this room, we are going to talk about raising children from the perspective of Islam In this room, we are going to talk about raising children from the perspective of Islam of Islam In this room, we are going to talk about raising children from about the perspective talk about of Islam room.' : 'No description available.')}
{/* Products Section */}
Products
{liveStore?.products?.length ? (
{liveStore.products.map((product) => ( { void toggleBookmark(product.slug, product.id, product.slug); }} /> ))}
) : useMockFallback ? (
{TWO_COLUMN_GRID_PRODUCTS.map((product) => ( ))}
) : ( )}
)} ); };