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.
 
 
 
 
 

663 lines
20 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,
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 (
<MobileShell width={375} height={1233} backgroundColor="#f3f1ef">
{/* Top Banner Calligraphy Image & Floating Actions */}
<div
style={{
position: 'relative',
width: '100%',
height: 152,
overflow: 'hidden',
flexShrink: 0,
}}
>
{!isBare && loading ? (
<ShimmerBox width="100%" height="100%" borderRadius={0} />
) : (
<img
src={
resolveMediaUrl(liveStore?.banner_url) ||
'/assets/images/bg-booth-calligraphy-header.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="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,
}}
/>
</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>
{!isBare && loading ? (
<StoreBoothBodyShimmer />
) : !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 */}
<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 */}
<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 */}
<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,
}}
/>
<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,
}}
/>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#747474',
textAlign: 'center',
whiteSpace: 'nowrap',
}}
>
{liveStore?.membership_label || '+1 year membership'}
</span>
<div
style={{
width: 1,
height: 12,
backgroundColor: '#d7dbe2',
flexShrink: 0,
}}
/>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#747474',
textAlign: 'center',
whiteSpace: 'nowrap',
}}
>
{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);
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,
}}
>
<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,
}}
/>
<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',
}}
>
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,
}}
/>
<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).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',
}}
>
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,
}}
/>
<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).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',
}}
>
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',
}}
>
About
</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.'
: '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',
}}
>
Products
</div>
{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>
)}
</MobileShell>
);
};