You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

792 lines
25 KiB

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,
ProductGridShimmer,
RetryBanner,
ShimmerBox,
} from '../../components/common/ShimmerSkeletons';
import { TWO_COLUMN_GRID_PRODUCTS } from '../../data/catalogData';
import { useShopApp } from '../../context/ShopAppContext';
import { useSmartBack } from '../../hooks/useSmartBack';
import { isRtlLanguage, tr } from '../../lib/cookies';
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 { isBookmarked, toggleBookmark, showToast, language } = useShopApp();
const isRtl = isRtlLanguage(language);
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 isStoreShimmer = !isBare && loading && !liveStore;
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 (
<MobileShell width={375} height={1233} backgroundColor="#f3f1ef">
{/* Top Store Logo Backdrop & Floating Actions */}
<div
style={{
position: 'relative',
width: '100%',
height: 152,
overflow: 'hidden',
flexShrink: 0,
}}
>
{isStoreShimmer ? (
<ShimmerBox width="100%" height="100%" borderRadius={0} />
) : (
<img
src={
resolveMediaUrl(liveStore?.logo_url) ||
'/assets/images/avatar-tashakol-booth.png'
}
alt=""
style={{
width: '100%',
height: '100%',
objectFit: 'cover',
display: 'block',
pointerEvents: 'none',
}}
/>
)}
<div
style={{
position: 'absolute',
top: 'calc(35px + var(--safe-top, 0px))',
left: 'var(--page-px)',
right: 'var(--page-px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}}
>
<button
type="button"
onClick={() => smartBack(ROUTES.home)}
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
borderRadius: 15,
backgroundColor: '#ffffff',
border: 'none',
padding: 0,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<img
src="/assets/images/icon-back-arrow-dark.svg"
alt=""
style={{
width: 18.22,
height: 14.56,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
{/* Right Top Actions */}
<div style={{ position: 'relative', width: 88, height: 40 }}>
<img
src="/assets/images/header-booth-share-cart-pill.svg"
alt=""
style={{
width: 88,
height: 40,
display: 'block',
pointerEvents: 'none',
}}
/>
<button
type="button"
onClick={() => {
void handleShare();
}}
aria-label="Share"
style={{
position: 'absolute',
left: 0,
top: 0,
width: 40,
height: 40,
borderRadius: 15,
backgroundColor: 'transparent',
border: 'none',
padding: 0,
cursor: 'pointer',
}}
/>
<button
type="button"
onClick={() => navigate(ROUTES.cart)}
aria-label="Cart"
style={{
position: 'absolute',
left: 48,
top: 0,
width: 40,
height: 40,
borderRadius: 15,
backgroundColor: 'transparent',
border: 'none',
padding: 0,
cursor: 'pointer',
}}
/>
</div>
</div>
</div>
{!isStoreShimmer && !liveStore && !useMockFallback ? (
<div
style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
gap: 14,
padding: '24px var(--page-px) 32px',
}}
>
{loadError && (
<RetryBanner
message="Could not load store booth details. Tap Retry to refresh."
onRetry={() => void storeQuery.refetch()}
/>
)}
<EmptyStateBox message="Store booth not found." />
</div>
) : (
<>
<div
style={{
position: 'relative',
zIndex: 1,
marginTop: -97,
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
padding: '0 var(--page-px) 32px',
}}
>
{/* Circular Store Avatar */}
{isStoreShimmer ? (
<ShimmerBox
width={64}
height={64}
borderRadius={32}
style={{ border: '1px solid #ffffff', boxSizing: 'border-box' }}
/>
) : (
<img
src={
resolveMediaUrl(liveStore?.logo_url) ||
'/assets/images/avatar-tashakol-booth.png'
}
alt={liveStore?.name || 'TashakolFarzandan Rohhallah'}
style={{
width: 64,
height: 64,
borderRadius: 32,
border: '1px solid #ffffff',
objectFit: 'cover',
boxSizing: 'border-box',
}}
/>
)}
{/* Store Title */}
{isStoreShimmer ? (
<ShimmerBox
width={186}
height={20}
borderRadius={6}
style={{ marginTop: 12 }}
/>
) : (
<h1
style={{
marginTop: 12,
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 16,
lineHeight: '20px',
color: '#151c31',
textAlign: 'center',
width: '100%',
}}
>
{liveStore?.name || 'TashakolFarzandan Rohhallah'}
</h1>
)}
{/* Iran Flag + Origin */}
{isStoreShimmer ? (
<ShimmerBox
width={104}
height={16}
borderRadius={5}
style={{ marginTop: 6 }}
/>
) : (
<div
style={{
marginTop: 6,
display: 'inline-flex',
alignItems: 'center',
gap: 4,
}}
>
<img
src="/assets/images/icon-flag-iran-19.svg"
alt="Origin"
style={{
width: 19,
height: 19,
}}
/>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 12,
lineHeight: '17px',
color: '#8b8b8b',
whiteSpace: 'nowrap',
}}
>
{liveStore
? [liveStore.country, liveStore.city].filter(Boolean).join(' | ')
: 'Iran | Tehran'}
</span>
</div>
)}
{!isBare && loadError && !store && (
<div style={{ width: '100%', marginTop: 14 }}>
<RetryBanner
message="Could not load store booth details. Tap Retry to refresh."
onRetry={() => void storeQuery.refetch()}
/>
</div>
)}
{/* Store Stats Row */}
<div
style={{
marginTop: 12,
width: '100%',
maxWidth: 460,
minHeight: 31,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-around',
gap: 6,
}}
>
<div style={{ display: 'inline-flex', alignItems: 'center', gap: 3 }}>
<img
src="/assets/images/icon-star-rating-16.svg"
alt=""
style={{
width: 16,
height: 15,
flexShrink: 0,
}}
/>
{isStoreShimmer ? (
<ShimmerBox width={46} height={12} borderRadius={4} />
) : (
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#747474',
whiteSpace: 'nowrap',
}}
>
{liveStore
? `${Number(
useMockFallback
? liveStore.rating_avg || 4.4
: liveStore.rating_avg ?? 0
).toFixed(1)} (${
liveStore.reviews_count ?? (useMockFallback ? 608 : 0)
})`
: '4.4 (608)'}
</span>
)}
</div>
<div
style={{
width: 1,
height: 12,
backgroundColor: '#d7dbe2',
flexShrink: 0,
}}
/>
{isStoreShimmer ? (
<ShimmerBox width={84} height={12} borderRadius={4} />
) : (
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#747474',
textAlign: 'center',
whiteSpace: 'nowrap',
}}
>
{tr(liveStore?.membership_label || '+1 year membership')}
</span>
)}
<div
style={{
width: 1,
height: 12,
backgroundColor: '#d7dbe2',
flexShrink: 0,
}}
/>
{isStoreShimmer ? (
<ShimmerBox width={52} height={12} borderRadius={4} />
) : (
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#747474',
textAlign: 'center',
whiteSpace: 'nowrap',
}}
>
{tr(liveStore?.sales_label || '+60 sales')}
</span>
)}
</div>
{/* 3 Store Metric Cards */}
<div className="habib-booth-metrics-grid" style={{ marginTop: 21 }}>
{/* Card 1: Avg. Response -> Opens Store Chat */}
<div
onClick={() => {
const target = ROUTES.chatThread(liveStore?.slug || resolvedSlug);
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,
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<img
src="/assets/images/icon-booth-chat-dots.svg"
alt=""
style={{
width: 24,
height: 24,
flexShrink: 0,
}}
/>
{isStoreShimmer ? (
<ShimmerBox width={36} height={18} borderRadius={5} />
) : (
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 'clamp(14px, 4.3vw, 16px)',
lineHeight: '20px',
background: 'linear-gradient(195deg, #eaba73 0%, #d78e06 100%)',
WebkitBackgroundClip: 'text',
WebkitTextFillColor: 'transparent',
whiteSpace: 'nowrap',
}}
>
{liveStore?.avg_response_time || '2h'}
</span>
)}
</div>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 'clamp(8.5px, 2.7vw, 10px)',
lineHeight: '13.9px',
color: '#1f1f1f',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{tr('Avg. Response')}
</span>
</div>
{/* Card 2: On-time Delivery */}
<div
style={{
minHeight: 58,
padding: '8px',
borderRadius: 8,
backgroundColor: '#efece9',
border: '1px solid #e8e4df',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
minWidth: 0,
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<img
src="/assets/images/icon-booth-delivery-truck.svg"
alt=""
style={{
width: 24,
height: 24,
flexShrink: 0,
}}
/>
{isStoreShimmer ? (
<ShimmerBox width={36} height={18} borderRadius={5} />
) : (
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 'clamp(14px, 4.3vw, 16px)',
lineHeight: '20px',
background: 'linear-gradient(195deg, #eaba73 0%, #d78e06 100%)',
WebkitBackgroundClip: 'text',
WebkitTextFillColor: 'transparent',
whiteSpace: 'nowrap',
}}
>
{liveStore
? `${String(liveStore.on_time_delivery_rate ?? 87).replace(/%+$/, '')}%`
: '87%'}
</span>
)}
</div>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 'clamp(8.5px, 2.7vw, 10px)',
lineHeight: '13.9px',
color: '#1f1f1f',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{tr('On-time Delivery')}
</span>
</div>
{/* Card 3: Satisfaction */}
<div
style={{
minHeight: 58,
padding: '8px',
borderRadius: 8,
backgroundColor: '#efece9',
border: '1px solid #e8e4df',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
minWidth: 0,
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<img
src="/assets/images/icon-booth-shield-protect.svg"
alt=""
style={{
width: 24,
height: 24,
flexShrink: 0,
}}
/>
{isStoreShimmer ? (
<ShimmerBox width={36} height={18} borderRadius={5} />
) : (
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 'clamp(14px, 4.3vw, 16px)',
lineHeight: '20px',
background: 'linear-gradient(195deg, #eaba73 0%, #d78e06 100%)',
WebkitBackgroundClip: 'text',
WebkitTextFillColor: 'transparent',
whiteSpace: 'nowrap',
}}
>
{liveStore
? `${String(liveStore.satisfaction_rate ?? 98).replace(/%+$/, '')}%`
: '98%'}
</span>
)}
</div>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 'clamp(8.5px, 2.7vw, 10px)',
lineHeight: '13.9px',
color: '#1f1f1f',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{tr('Satisfaction')}
</span>
</div>
</div>
{/* About Section */}
<section
style={{
marginTop: 26,
width: '100%',
display: 'flex',
flexDirection: 'column',
gap: 14,
}}
>
<div
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 14,
lineHeight: '19px',
color: '#292a2e',
}}
>
{tr('About')}
</div>
{isStoreShimmer ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 7 }}>
<ShimmerBox width="96%" height={13} borderRadius={5} />
<ShimmerBox width="90%" height={13} borderRadius={5} />
<ShimmerBox width="68%" height={13} borderRadius={5} />
</div>
) : (
<div
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 400,
fontSize: 12,
lineHeight: '18px',
color: '#747474',
whiteSpace: 'pre-wrap',
}}
>
{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.'
: tr('No description available.'))}
</div>
)}
</section>
{/* Products Section */}
<section
style={{
marginTop: 28,
width: '100%',
display: 'flex',
flexDirection: 'column',
gap: 12,
}}
>
<div
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 14,
lineHeight: '19px',
color: '#292a2e',
}}
>
{tr('Products')}
</div>
{isStoreShimmer ? (
<ProductGridShimmer count={4} />
) : liveStore?.products?.length ? (
<div className="habib-product-grid">
{liveStore.products.map((product) => (
<GridProductCard
key={product.id}
item={mapProductToGridItem(product)}
slugOrId={product.slug}
isBookmarked={isBookmarked(product.id, product.slug)}
onToggleBookmark={() => {
void toggleBookmark(product.slug, product.id, product.slug);
}}
/>
))}
</div>
) : useMockFallback ? (
<div className="habib-product-grid">
{TWO_COLUMN_GRID_PRODUCTS.map((product) => (
<GridProductCard key={product.id} item={product} />
))}
</div>
) : (
<EmptyStateBox message="No products in this store yet." />
)}
</section>
</div>
{/* Bottom Sticky Seller Chat Bar (Option 2: Full-Width Gold CTA in White Sticky Sheet) */}
<div
style={{
position: 'sticky',
bottom: 0,
zIndex: 20,
width: '100%',
padding: '14px var(--page-px) calc(14px + var(--safe-bottom, 0px))',
borderRadius: '17px 17px 0 0',
backgroundColor: '#ffffff',
boxShadow: '0px -7px 12px rgba(103, 110, 124, 0.15)',
marginTop: 'auto',
}}
>
<button
type="button"
className="habib-cta-btn"
onClick={() => {
const target = ROUTES.chatThread(liveStore?.slug || resolvedSlug);
navigate(target);
}}
style={{
width: '100%',
height: 52,
borderRadius: 11,
backgroundColor: '#d78e06',
border: 'none',
padding: '0 16px',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 8,
}}
>
<svg
width="22"
height="22"
viewBox="0 0 24 24"
fill="none"
style={{ flexShrink: 0 }}
>
<path
d="M14 19C17.771 19 19.657 19 20.828 17.828C21.999 16.656 22 14.771 22 11C22 7.229 22 5.343 20.828 4.172C19.656 3.001 17.771 3 14 3H10C6.229 3 4.343 3 3.172 4.172C2.001 5.344 2 7.229 2 11C2 14.771 2 16.657 3.172 17.828C3.825 18.482 4.7 18.771 6 18.898"
stroke="#fbfbfc"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M11.9973 11V11.01M7.99731 11V11.01M15.9973 11V11.01M13.9973 19C12.7613 19 11.3993 19.5 10.1563 20.145L10.1512 20.1477C8.15661 21.1829 7.15889 21.7007 6.66731 21.37C6.17531 21.039 6.26831 20.015 6.45531 17.966L6.49731 17.5"
stroke="#fbfbfc"
strokeWidth="2"
strokeLinecap="round"
/>
</svg>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 16,
lineHeight: '24px',
color: '#fbfbfc',
whiteSpace: 'nowrap',
}}
>
{tr('Chat with Seller')}
</span>
</button>
</div>
</>
)}
</MobileShell>
);
};