Browse Source

refactor(shop): clean up test pages, improve mobile shell layout, and enhance address and cookie handling

main
sina_sajjadi 1 week ago
parent
commit
f2d35396cc
  1. 147
      index.html
  2. 25
      src/App.tsx
  3. 5
      src/components/account/AccountMenuRow.tsx
  4. 5
      src/components/account/OrderCounterCard.tsx
  5. 7
      src/components/checkout/AddressCard.tsx
  6. 11
      src/components/checkout/CartItemCard.tsx
  7. 5
      src/components/checkout/OrderSummaryRows.tsx
  8. 3
      src/components/checkout/PaymentMethodCard.tsx
  9. 3
      src/components/checkout/ReviewItemCard.tsx
  10. 5
      src/components/common/CategoryCard.tsx
  11. 5
      src/components/common/CompactProductCard.tsx
  12. 5
      src/components/common/GridProductCard.tsx
  13. 15
      src/components/common/PhoneNumberInput.tsx
  14. 16
      src/components/common/SearchBar.tsx
  15. 7
      src/components/common/ShimmerSkeletons.tsx
  16. 17
      src/components/layout/BottomNavBar.tsx
  17. 381
      src/components/layout/MobileShell.tsx
  18. 7
      src/components/layout/StickyFooterBar.tsx
  19. 5
      src/components/layout/TopHeader.tsx
  20. 1067
      src/components/modals/AddressFormSheet.tsx
  21. 9
      src/components/modals/LoginRequiredModal.tsx
  22. 7
      src/components/modals/OrderSummarySheet.tsx
  23. 7
      src/components/modals/PaymentMethodsSheet.tsx
  24. 19
      src/components/modals/ShipmentTrackingSheet.tsx
  25. 11
      src/components/orders/OrderFilterTabs.tsx
  26. 9
      src/components/orders/OrderListCard.tsx
  27. 9
      src/components/orders/ShipmentStatusCard.tsx
  28. 176
      src/context/ShopAppContext.tsx
  29. 425
      src/data/routesRegistry.ts
  30. 3
      src/hooks/useSmartBack.ts
  31. 1388
      src/lib/cookies.ts
  32. 1
      src/lib/routes.ts
  33. 32
      src/pages/account/LanguageSettingPage.tsx
  34. 85
      src/pages/account/ProviderRequestPage.tsx
  35. 128
      src/pages/account/ShopAccountPage.tsx
  36. 3
      src/pages/account/ShopAddressPage.tsx
  37. 120
      src/pages/catalog/ShopBoothPage.tsx
  38. 9
      src/pages/catalog/ShopCatItemsPage.tsx
  39. 3
      src/pages/catalog/ShopCategoryPage.tsx
  40. 83
      src/pages/catalog/ShopSinglePage.tsx
  41. 48
      src/pages/chat/ShopChatPage.tsx
  42. 19
      src/pages/checkout/ShopBuy01Page.tsx
  43. 15
      src/pages/checkout/ShopCartPage.tsx
  44. 14
      src/pages/checkout/ShopOrderSummaryPage.tsx
  45. 24
      src/pages/checkout/ShopPayResultPage.tsx
  46. 16
      src/pages/checkout/ShopPaymentMethodsPage.tsx
  47. 9
      src/pages/checkout/ShopPaymentPage.tsx
  48. 35
      src/pages/home/ShopHomePage.tsx
  49. 27
      src/pages/orders/ShopOrderDetailPage.tsx
  50. 5
      src/pages/orders/ShopOrdersPage.tsx
  51. 37
      src/pages/orders/ShopSupportPage.tsx
  52. 602
      src/pages/test/PixelVerificationModal.tsx
  53. 2207
      src/pages/test/SellerChatButtonTestLab.tsx
  54. 576
      src/pages/test/TestDirectoryPage.tsx
  55. 1
      src/types/window.d.ts

147
index.html

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
@ -161,6 +161,60 @@
currentCoins = 21;
}
function normalizeBootLang(raw) {
if (typeof raw !== 'string') return '';
var clean = raw.trim().toLowerCase();
if (!clean) return '';
if (clean.indexOf('fa') === 0 || clean === 'persian' || clean === 'farsi') return 'fa';
if (clean.indexOf('ar') === 0 || clean === 'arabic') return 'ar';
if (clean.indexOf('en') === 0 || clean === 'english') return 'en';
return '';
}
function applyBootLanguage(langCode) {
var norm = normalizeBootLang(langCode) || 'en';
var dir = norm === 'fa' || norm === 'ar' ? 'rtl' : 'ltr';
if (document.documentElement) {
document.documentElement.lang = norm;
document.documentElement.dir = dir;
}
if (document.body) {
document.body.dir = dir;
}
}
function resolveInitialLanguage() {
var urlLang = '';
try {
if (window.location && window.location.search) {
var sp = new URLSearchParams(window.location.search);
urlLang = normalizeBootLang(sp.get('lang') || sp.get('locale') || sp.get('language') || '');
}
} catch (_eLangUrl) {}
var cookieLang = normalizeBootLang(
readCookie('HABIB_LANGUAGE') || readCookie('HABIB_USER_LANGUAGE') || readCookie('habib_language')
);
var lsLang = '';
try {
lsLang = normalizeBootLang(
window.localStorage.getItem('habib_shop_language') ||
window.localStorage.getItem('HABIB_LANGUAGE') ||
''
);
} catch (_eLangLs) {}
var chosen = urlLang || cookieLang || lsLang || 'en';
if (urlLang) {
document.cookie = 'HABIB_LANGUAGE=' + encodeURIComponent(chosen) + '; path=/; SameSite=Lax';
document.cookie = 'HABIB_USER_LANGUAGE=' + encodeURIComponent(chosen) + '; path=/; SameSite=Lax';
try {
window.localStorage.setItem('habib_shop_language', chosen);
} catch (_eSaveUrlLang) {}
}
return chosen;
}
applyBootLanguage(resolveInitialLanguage());
function getFlutterBridge() {
var ch = window.HabibApp || window.FlutterChannel;
if (ch && typeof ch.postMessage === 'function') {
@ -279,6 +333,29 @@
);
}
var incomingLang = normalizeBootLang(
data.language ||
data.locale ||
(data.user && (data.user.preferred_language || data.user.language)) ||
''
);
if (incomingLang) {
var prevBootLang = resolveBootLang();
document.cookie = 'HABIB_LANGUAGE=' + encodeURIComponent(incomingLang) + '; path=/; SameSite=Lax';
document.cookie = 'HABIB_USER_LANGUAGE=' + encodeURIComponent(incomingLang) + '; path=/; SameSite=Lax';
try {
window.localStorage.setItem('habib_shop_language', incomingLang);
} catch (_eBridgeLang) {}
applyBootLanguage(incomingLang);
if (incomingLang !== prevBootLang) {
window.dispatchEvent(
new CustomEvent('habib:language-changed', {
detail: { language: incomingLang },
})
);
}
}
if (explicitToken) {
window.HABIB_TOKEN = explicitToken;
} else if (action === 'login' && payload.success !== false) {
@ -353,12 +430,12 @@
}, 120);
};
// Safety fallback so Flutter's reveal cover never hangs permanently
// Emergency fallback only if React bundle fails to mount
window.setTimeout(function () {
if (!webReadySent) {
if (!webReadySent && !document.querySelector('.habib-mobile-viewport')) {
tryPostWebReady();
}
}, 3500);
}, 10000);
function postClientLog(level, message, details) {
var bridge = getFlutterBridge();
@ -399,7 +476,67 @@
</script>
</head>
<body>
<div id="root"></div>
<div id="root">
<div class="habib-boot-shell" aria-hidden="true">
<div class="habib-boot-viewport">
<div style="padding: 37px 16px 22px; display: flex; flex-direction: column; gap: 20px;">
<div style="display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: 11px;">
<div class="habib-boot-bone" style="width: 40px; height: 40px; border-radius: 15px;"></div>
<div class="habib-boot-bone" style="width: 68px; height: 22px; border-radius: 8px;"></div>
<div class="habib-boot-bone" style="width: 40px; height: 40px; border-radius: 15px;"></div>
</div>
<div style="display: flex; gap: 10px; align-items: center;">
<div class="habib-boot-bone" style="flex: 1; height: 44px; border-radius: 14px;"></div>
<div class="habib-boot-bone" style="width: 44px; height: 44px; border-radius: 14px;"></div>
</div>
<div class="habib-boot-bone" style="width: 100%; height: 164px; border-radius: 15px;"></div>
<div style="display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px;">
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
</div>
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
</div>
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
</div>
<div style="display: flex; flex-direction: column; align-items: center; align-items: center; gap: 6px;">
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
</div>
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;">
<div style="padding: 12px; border-radius: 15px; background: #ffffff; display: flex; flex-direction: column; gap: 8px;">
<div class="habib-boot-bone" style="width: 100%; height: 112px; border-radius: 10px;"></div>
<div class="habib-boot-bone" style="width: 62%; height: 10px; border-radius: 5px;"></div>
<div class="habib-boot-bone" style="width: 90%; height: 13px; border-radius: 6px;"></div>
<div class="habib-boot-bone" style="width: 54px; height: 15px; border-radius: 6px;"></div>
</div>
<div style="padding: 12px; border-radius: 15px; background: #ffffff; display: flex; flex-direction: column; gap: 8px;">
<div class="habib-boot-bone" style="width: 100%; height: 112px; border-radius: 10px;"></div>
<div class="habib-boot-bone" style="width: 62%; height: 10px; border-radius: 5px;"></div>
<div class="habib-boot-bone" style="width: 90%; height: 13px; border-radius: 6px;"></div>
<div class="habib-boot-bone" style="width: 54px; height: 15px; border-radius: 6px;"></div>
</div>
</div>
</div>
<div style="height: 78px; border-radius: 17px 17px 0 0; background: #ffffff; display: flex; align-items: center; justify-content: space-around; padding: 0 16px;">
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
<div class="habib-boot-bone" style="width: 54px; height: 48px; border-radius: 24px;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
</div>
</div>
</div>
</div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

25
src/App.tsx

@ -4,7 +4,10 @@ import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-route
import { ShopAppProvider } from './context/ShopAppContext';
import { HabibBridgeProviders } from './components/bridge/HabibBridgeProviders';
import { MajorTabActiveContext } from './components/layout/MobileShell';
import {
MajorTabActiveContext,
useHomeBootSettled,
} from './components/layout/MobileShell';
import { isBareMode } from './lib/routes';
import { shopQueryClient } from './lib/shopQueries';
@ -40,10 +43,6 @@ import { LanguageSettingPage } from './pages/account/LanguageSettingPage';
// Standalone Component / Icon / Text Nodes (6 Top-Level Nodes)
import { StandaloneNodesPage } from './pages/standalone/StandaloneNodesPage';
// Test & QA Hub (/test)
import { TestDirectoryPage } from './pages/test/TestDirectoryPage';
import { SellerChatButtonTestLab } from './pages/test/SellerChatButtonTestLab';
type MajorTab = 'home' | 'category' | 'account' | 'cart';
function resolveMajorTab(pathname: string): MajorTab | null {
@ -69,18 +68,24 @@ const MAJOR_PAGE_SLOTS: Array<{ tab: MajorTab; element: React.ReactNode }> = [
const AppRoutes: React.FC = () => {
const location = useLocation();
const homeBootSettled = useHomeBootSettled();
const isBare = isBareMode(location.search);
const isNonShellRoute =
isBare ||
location.pathname.startsWith('/test') ||
location.pathname.startsWith('/node/');
const activeMajorTab = isBare ? null : resolveMajorTab(location.pathname);
const visibleSlots = homeBootSettled
? MAJOR_PAGE_SLOTS
: MAJOR_PAGE_SLOTS.filter(({ tab }) => tab === 'home');
return (
<>
{!isNonShellRoute &&
MAJOR_PAGE_SLOTS.map(({ tab, element }) => {
const isActive = activeMajorTab === tab;
visibleSlots.map(({ tab, element }) => {
const isActive =
!homeBootSettled && activeMajorTab !== null
? tab === 'home'
: activeMajorTab === tab;
return (
<MajorTabActiveContext.Provider key={tab} value={isActive}>
<div
@ -96,10 +101,6 @@ const AppRoutes: React.FC = () => {
{activeMajorTab === null && (
<Routes>
{/* Test & QA Hub */}
<Route path="/test" element={<SellerChatButtonTestLab />} />
<Route path="/test/qa" element={<TestDirectoryPage />} />
{/* ===================================================== */}
{/* Production Parameterized Routes */}
{/* ===================================================== */}

5
src/components/account/AccountMenuRow.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { AccountMenuRowItem } from '../../data/accountData';
import { tr } from '../../lib/cookies';
interface AccountMenuRowProps {
row: AccountMenuRowItem;
@ -111,7 +112,7 @@ export const AccountMenuRow: React.FC<AccountMenuRowProps> = ({ row, onClick })
textOverflow: 'ellipsis',
}}
>
{row.title}
{tr(row.title)}
</div>
{row.subtitle && (
<div
@ -126,7 +127,7 @@ export const AccountMenuRow: React.FC<AccountMenuRowProps> = ({ row, onClick })
textOverflow: 'ellipsis',
}}
>
{row.subtitle}
{tr(row.subtitle)}
</div>
)}
</div>

5
src/components/account/OrderCounterCard.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { OrderStatusCounterItem } from '../../data/accountData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface OrderCounterCardProps {
@ -88,7 +89,7 @@ export const OrderCounterCard: React.FC<OrderCounterCardProps> = ({
textOverflow: 'ellipsis',
}}
>
{counter.label}
{tr(counter.label)}
</div>
<div
style={{
@ -102,7 +103,7 @@ export const OrderCounterCard: React.FC<OrderCounterCardProps> = ({
textOverflow: 'ellipsis',
}}
>
{counter.countText}
{tr(counter.countText)}
</div>
</div>
</div>

7
src/components/checkout/AddressCard.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { ShippingAddressOption } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface AddressCardProps {
@ -121,7 +122,7 @@ export const AddressCard: React.FC<AddressCardProps> = ({
flexShrink: 0,
}}
>
Change Adress
{tr('Change Adress')}
</span>
) : (
<div
@ -261,7 +262,7 @@ export const AddNewAddressCard: React.FC<AddNewAddressCardProps> = ({ onClick })
color: '#36363c',
}}
>
Add New adress
{tr('Add New adress')}
</span>
<span
style={{
@ -272,7 +273,7 @@ export const AddNewAddressCard: React.FC<AddNewAddressCardProps> = ({ onClick })
color: '#8b8b8b',
}}
>
Add New Delivery adress
{tr('Add New Delivery adress')}
</span>
</div>

11
src/components/checkout/CartItemCard.tsx

@ -1,5 +1,6 @@
import React from 'react';
import type { CartItemData, OrderSummaryBgItemData } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
interface MainCartItemCardProps {
item: CartItemData;
@ -78,7 +79,7 @@ export const MainCartItemCard: React.FC<MainCartItemCardProps> = ({
cursor: onClickItem ? 'pointer' : undefined,
}}
>
{item.title}
{tr(item.title)}
</div>
{/* Origin Row */}
@ -110,7 +111,7 @@ export const MainCartItemCard: React.FC<MainCartItemCardProps> = ({
color: '#747474',
}}
>
{item.origin}
{tr(item.origin)}
</span>
</div>
</div>
@ -120,7 +121,7 @@ export const MainCartItemCard: React.FC<MainCartItemCardProps> = ({
className={onRemove ? 'habib-icon-btn' : undefined}
onClick={() => onRemove?.(item.id)}
role={onRemove ? 'button' : undefined}
aria-label="Remove item"
aria-label={tr('Remove item')}
style={{
width: '24px',
height: '24px',
@ -318,7 +319,7 @@ export const OrderSummaryBgItemCard: React.FC<OrderSummaryBgItemCardProps> = ({
color: '#111111',
}}
>
{item.title}
{tr(item.title)}
</div>
<div
style={{
@ -346,7 +347,7 @@ export const OrderSummaryBgItemCard: React.FC<OrderSummaryBgItemCardProps> = ({
color: '#8b8b8b',
}}
>
{item.origin}
{tr(item.origin)}
</span>
</div>
</div>

5
src/components/checkout/OrderSummaryRows.tsx

@ -1,5 +1,6 @@
import React from 'react';
import { ORDER_SUMMARY_ROWS } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
export interface SummaryLineRow {
id: string;
@ -59,7 +60,7 @@ export const OrderSummaryRows: React.FC<OrderSummaryRowsProps> = ({
color: '#747474',
}}
>
{row.label}
{tr(row.label)}
</span>
<span
style={{
@ -104,7 +105,7 @@ export const OrderSummaryRows: React.FC<OrderSummaryRowsProps> = ({
color: '#111111',
}}
>
Total
{tr('Total')}
</span>
<span
style={{

3
src/components/checkout/PaymentMethodCard.tsx

@ -1,5 +1,6 @@
import React from 'react';
import type { PaymentMethodItem } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
interface PaymentMethodCardProps {
item: PaymentMethodItem;
@ -99,7 +100,7 @@ export const PaymentMethodCard: React.FC<PaymentMethodCardProps> = ({
color: '#292a2e',
}}
>
{item.label}
{tr(item.label)}
</span>
</div>
</div>

3
src/components/checkout/ReviewItemCard.tsx

@ -1,5 +1,6 @@
import React from 'react';
import type { PaymentReviewItem } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
interface ReviewItemCardProps {
item: PaymentReviewItem;
@ -59,7 +60,7 @@ export const ReviewItemCard: React.FC<ReviewItemCardProps> = ({
color: '#111111',
}}
>
{item.title}
{tr(item.title)}
</span>
<div

5
src/components/common/CategoryCard.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { CategoryTileItem } from '../../data/catalogData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface CategoryCardProps {
@ -76,7 +77,7 @@ export const CategoryCard: React.FC<CategoryCardProps> = ({
<img
src={tile.iconSrc}
alt={tile.label}
alt={tr(tile.label)}
style={{
width: `${tile.iconWidth}px`,
height: `${tile.iconHeight}px`,
@ -94,7 +95,7 @@ export const CategoryCard: React.FC<CategoryCardProps> = ({
textAlign: 'center',
}}
>
{tile.label}
{tr(tile.label)}
</span>
</div>
);

5
src/components/common/CompactProductCard.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { CompactProductItem } from '../../data/catalogData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface CompactProductCardProps {
@ -160,7 +161,7 @@ export const CompactProductCard: React.FC<CompactProductCardProps> = ({
color: '#111111',
}}
>
{item.title}
{tr(item.title)}
</div>
<div
@ -193,7 +194,7 @@ export const CompactProductCard: React.FC<CompactProductCardProps> = ({
textOverflow: 'ellipsis',
}}
>
{item.origin}
{tr(item.origin)}
</span>
</div>

5
src/components/common/GridProductCard.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { GridProductItem } from '../../data/catalogData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface GridProductCardProps {
@ -161,7 +162,7 @@ export const GridProductCard: React.FC<GridProductCardProps> = ({
color: '#111111',
}}
>
{item.title}
{tr(item.title)}
</div>
<div
@ -194,7 +195,7 @@ export const GridProductCard: React.FC<GridProductCardProps> = ({
textOverflow: 'ellipsis',
}}
>
{item.origin}
{tr(item.origin)}
</span>
</div>

15
src/components/common/PhoneNumberInput.tsx

@ -10,6 +10,7 @@ import {
resolveRegionFromDialCode,
validatePhoneNumber,
} from '../../lib/phone';
import { tr } from '../../lib/cookies';
import { EmptyStateBox } from './ShimmerSkeletons';
export interface PhoneNumberInputProps {
@ -188,7 +189,7 @@ export const PhoneNumberInput: React.FC<PhoneNumberInputProps> = ({
!validation.isValid;
const placeholderText = bare
? 'Phone number'
? tr('Phone number')
: `${getPlaceholderForDialCode(dialCode)}${required ? ' *' : ''}`;
const emitChange = (
@ -354,7 +355,7 @@ export const PhoneNumberInput: React.FC<PhoneNumberInputProps> = ({
paddingLeft: 2,
}}
>
{errorMessage || validation.error || 'Enter a valid phone number'}
{tr(errorMessage || validation.error || 'Enter a valid phone number')}
</span>
)}
@ -410,13 +411,13 @@ export const PhoneNumberInput: React.FC<PhoneNumberInputProps> = ({
color: '#111111',
}}
>
Select Country Code
{tr('Select Country Code')}
</span>
<button
type="button"
className="habib-icon-btn"
onClick={closeSheet}
aria-label="Close country selector"
aria-label={tr('Close country selector')}
style={{
width: 24,
height: 24,
@ -453,7 +454,7 @@ export const PhoneNumberInput: React.FC<PhoneNumberInputProps> = ({
>
<img
src="/assets/images/icon-search-magnifier.svg"
alt="Search"
alt={tr('Search')}
style={{
position: 'absolute',
left: 9,
@ -469,8 +470,8 @@ export const PhoneNumberInput: React.FC<PhoneNumberInputProps> = ({
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="habib-search-input"
placeholder="Search country name or code (+1, +98...)"
aria-label="Search country name or code"
placeholder={tr('Search country name or code (+1, +98...)')}
aria-label={tr('Search country name or code')}
style={{
width: '100%',
height: '100%',

16
src/components/common/SearchBar.tsx

@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { isRtlLanguage, tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface SearchBarProps {
@ -30,6 +31,8 @@ export const SearchBar: React.FC<SearchBarProps> = ({
const navigate = useNavigate();
const [internalVal, setInternalVal] = useState(defaultValue);
const currentValue = value !== undefined ? value : internalVal;
const isRtl = isRtlLanguage();
const localizedPlaceholder = tr(placeholder);
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
@ -65,10 +68,11 @@ export const SearchBar: React.FC<SearchBarProps> = ({
>
<img
src="/assets/images/icon-search-magnifier.svg"
alt="Search"
alt={tr('Search')}
style={{
position: 'absolute',
left: '9px',
left: isRtl ? undefined : '9px',
right: isRtl ? '9px' : undefined,
top: '13px',
width: '23.83px',
height: '24px',
@ -87,13 +91,13 @@ export const SearchBar: React.FC<SearchBarProps> = ({
onChange?.(e.target.value);
}}
className="habib-search-input"
placeholder={placeholder}
aria-label={placeholder}
placeholder={localizedPlaceholder}
aria-label={localizedPlaceholder}
style={{
width: '100%',
height: '100%',
borderRadius: '15px',
padding: '15px 12px 17px 39px',
padding: isRtl ? '15px 39px 17px 12px' : '15px 12px 17px 39px',
fontFamily: 'var(--font-sans)',
fontWeight: 400,
fontSize: '12px',
@ -107,7 +111,7 @@ export const SearchBar: React.FC<SearchBarProps> = ({
<button
type="button"
onClick={onFilterClick}
aria-label="Filter"
aria-label={tr('Filter')}
style={{
width: '50px',
height: '50px',

7
src/components/common/ShimmerSkeletons.tsx

@ -1,4 +1,5 @@
import React from 'react';
import { tr } from '../../lib/cookies';
const ShimmerGate: React.FC<{ children: React.ReactNode }> = ({ children }) => (
<>{children}</>
@ -76,7 +77,7 @@ export const RetryBanner: React.FC<{
color: '#292a2e',
}}
>
{message}
{tr(message)}
</span>
<button
type="button"
@ -92,7 +93,7 @@ export const RetryBanner: React.FC<{
cursor: 'pointer',
}}
>
Retry
{tr('Retry')}
</button>
</div>
);
@ -117,7 +118,7 @@ export const EmptyStateBox: React.FC<{
color: '#747474',
}}
>
{message}
{tr(message)}
</div>
);

17
src/components/layout/BottomNavBar.tsx

@ -1,6 +1,7 @@
import React, { useEffect, useSyncExternalStore } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useShopApp } from '../../context/ShopAppContext';
import { tr } from '../../lib/cookies';
import { isBareMode, ROUTES } from '../../lib/routes';
import { openAiAssistant } from '../../lib/webview-actions';
@ -259,10 +260,10 @@ export const BottomNavBar: React.FC<BottomNavBarProps> = ({
<NavTabIcon
activeSrc="/assets/images/nav-home-active.svg"
inactiveSrc="/assets/images/nav-home-inactive.svg"
alt="Home"
alt={tr('Home')}
visualClass={homeVisual}
/>
<span className={`habib-nav-label ${homeVisual}`}>Home</span>
<span className={`habib-nav-label ${homeVisual}`}>{tr('Home')}</span>
{homePhase && (
<IndicatorWave
key={snapshot.seq}
@ -291,10 +292,10 @@ export const BottomNavBar: React.FC<BottomNavBarProps> = ({
<NavTabIcon
activeSrc="/assets/images/nav-category-active.svg"
inactiveSrc="/assets/images/nav-category-inactive.svg"
alt="Category"
alt={tr('Category')}
visualClass={categoryVisual}
/>
<span className={`habib-nav-label ${categoryVisual}`}>Category</span>
<span className={`habib-nav-label ${categoryVisual}`}>{tr('Category')}</span>
{categoryPhase && (
<IndicatorWave
key={snapshot.seq}
@ -354,10 +355,10 @@ export const BottomNavBar: React.FC<BottomNavBarProps> = ({
<NavTabIcon
activeSrc="/assets/images/nav-account-active.svg"
inactiveSrc="/assets/images/nav-account-inactive.svg"
alt="Account"
alt={tr('Account')}
visualClass={accountVisual}
/>
<span className={`habib-nav-label ${accountVisual}`}>Account</span>
<span className={`habib-nav-label ${accountVisual}`}>{tr('Account')}</span>
{accountPhase && (
<IndicatorWave
key={snapshot.seq}
@ -387,7 +388,7 @@ export const BottomNavBar: React.FC<BottomNavBarProps> = ({
<NavTabIcon
activeSrc="/assets/images/nav-cart-active.svg"
inactiveSrc="/assets/images/nav-cart-inactive.svg"
alt="Cart"
alt={tr('Cart')}
visualClass={cartVisual}
/>
{showCartBadge && resolvedBadgeCount > 0 && (
@ -423,7 +424,7 @@ export const BottomNavBar: React.FC<BottomNavBarProps> = ({
</div>
)}
</div>
<span className={`habib-nav-label ${cartVisual}`}>Cart</span>
<span className={`habib-nav-label ${cartVisual}`}>{tr('Cart')}</span>
{cartPhase && (
<IndicatorWave
key={snapshot.seq}

381
src/components/layout/MobileShell.tsx

@ -1,7 +1,15 @@
import React, { createContext, useContext, useEffect, useRef, useState } from 'react';
import React, {
createContext,
useContext,
useEffect,
useRef,
useSyncExternalStore,
} from 'react';
import { useQueryClient } from '@tanstack/react-query';
import { useLocation, useNavigationType } from 'react-router-dom';
import { consumeBackNavigation } from '../../hooks/useSmartBack';
import { getToken } from '../../lib/auth-bridge';
import { shopKeys } from '../../lib/shopQueries';
import { FullPageRouteShimmer } from '../common/ShimmerSkeletons';
export const MajorTabActiveContext = createContext<boolean>(true);
@ -26,8 +34,96 @@ export const ROOT_TAB_PATHS = new Set([
'/shop-category-4214-345',
]);
const settledPathnames = new Set<string>(ROOT_TAB_PATHS);
let majorPagesBootSettled = false;
type BootPhase = 'home' | 'other-tabs' | 'settled';
interface ShellStoreSnapshot {
version: number;
bootPhase: BootPhase;
otherTabsBackgroundSettled: boolean;
clearVersion: number;
settledPathnames: ReadonlySet<string>;
}
const settledPathnames = new Set<string>();
let bootPhase: BootPhase = 'home';
let otherTabsBackgroundSettled = false;
let clearVersion = 0;
let storeVersion = 0;
const shellListeners = new Set<() => void>();
let currentShellSnapshot: ShellStoreSnapshot = {
version: 0,
bootPhase: 'home',
otherTabsBackgroundSettled: false,
clearVersion: 0,
settledPathnames: new Set<string>(),
};
function emitShellStoreChange(): void {
storeVersion += 1;
currentShellSnapshot = {
version: storeVersion,
bootPhase,
otherTabsBackgroundSettled,
clearVersion,
settledPathnames: new Set(settledPathnames),
};
shellListeners.forEach((listener) => listener());
}
function subscribeShellStore(listener: () => void): () => void {
shellListeners.add(listener);
return () => {
shellListeners.delete(listener);
};
}
function getShellStoreSnapshot(): ShellStoreSnapshot {
return currentShellSnapshot;
}
function getHomeBootSettledSnapshot(): boolean {
return currentShellSnapshot.bootPhase !== 'home';
}
export function useHomeBootSettled(): boolean {
'use no memo';
return useSyncExternalStore(
subscribeShellStore,
getHomeBootSettledSnapshot,
getHomeBootSettledSnapshot
);
}
function addSettledPathname(pathname: string): void {
settledPathnames.add(pathname);
if (pathname === '/' || pathname === '/shop-home') {
settledPathnames.add('/');
settledPathnames.add('/shop-home');
} else if (pathname === '/categories' || pathname === '/shop-category') {
settledPathnames.add('/categories');
settledPathnames.add('/shop-category');
} else if (
pathname === '/account' ||
pathname === '/shop-account' ||
pathname === '/shop-category-4214-345'
) {
settledPathnames.add('/account');
settledPathnames.add('/shop-account');
settledPathnames.add('/shop-category-4214-345');
} else if (pathname === '/cart' || pathname === '/shop-cart') {
settledPathnames.add('/cart');
settledPathnames.add('/shop-cart');
}
}
export function clearSettledPathnames(): void {
settledPathnames.clear();
otherTabsBackgroundSettled = false;
clearVersion += 1;
emitShellStoreChange();
}
let lastPathname: string | null = null;
let lastTransitionClass = '';
@ -127,6 +223,7 @@ export const MobileShell: React.FC<MobileShellProps> = ({
borderRadius = 0,
children,
}) => {
'use no memo';
const location = useLocation();
const navigationType = useNavigationType();
const queryClient = useQueryClient();
@ -137,14 +234,17 @@ export const MobileShell: React.FC<MobileShellProps> = ({
const isMajorTabActive = useContext(MajorTabActiveContext);
const isMajorTabRoute = ROOT_TAB_PATHS.has(location.pathname);
const [readyPathname, setReadyPathname] = useState<string | null>(() =>
isEmbed || settledPathnames.has(location.pathname) ? location.pathname : null
const shellState = useSyncExternalStore(
subscribeShellStore,
getShellStoreSnapshot,
getShellStoreSnapshot
);
const currentBootPhase = shellState.bootPhase;
const currentClearVersion = shellState.clearVersion;
const isOtherTabsBackgroundSettled = shellState.otherTabsBackgroundSettled;
const isPageReady =
isEmbed ||
isMajorTabRoute ||
settledPathnames.has(location.pathname) ||
readyPathname === location.pathname;
isEmbed || shellState.settledPathnames.has(location.pathname);
useEffect(() => {
preloadSharedIcons();
@ -153,7 +253,18 @@ export const MobileShell: React.FC<MobileShellProps> = ({
useEffect(() => {
if (!isMajorTabActive) return;
if (isPageReady && (majorPagesBootSettled || isEmbed)) {
if (isEmbed) {
if (typeof window !== 'undefined') {
window.__announceHabibWebReady?.();
}
return;
}
if (
currentBootPhase === 'settled' &&
isPageReady &&
(isOtherTabsBackgroundSettled || currentClearVersion > 0)
) {
if (typeof window !== 'undefined') {
window.__announceHabibWebReady?.();
}
@ -162,35 +273,105 @@ export const MobileShell: React.FC<MobileShellProps> = ({
const targetPathname = location.pathname;
let cancelled = false;
let rafId: number | null = null;
let rafId1: number | null = null;
let rafId2: number | null = null;
let verifying = false;
const markReady = () => {
settledPathnames.add(targetPathname);
majorPagesBootSettled = true;
setReadyPathname(targetPathname);
if (typeof window !== 'undefined') {
window.__announceHabibWebReady?.();
const cancelPendingRafs = () => {
if (rafId1 !== null) {
window.cancelAnimationFrame(rafId1);
rafId1 = null;
}
if (rafId2 !== null) {
window.cancelAnimationFrame(rafId2);
rafId2 = null;
}
};
const safetyTimer = window.setTimeout(() => {
if (!cancelled) {
markReady();
const isHomeQueryReady = (): boolean => {
const homeState = queryClient.getQueryState(shopKeys.home());
if (!homeState || homeState.status === 'pending') return false;
if (queryClient.isFetching({ queryKey: shopKeys.home() }) > 0) return false;
return true;
};
const areOtherMajorPagesQueriesReady = (): boolean => {
if (typeof document !== 'undefined') {
const mountedTabs = document.querySelectorAll('[data-major-tab]');
if (mountedTabs.length < 4) return false;
}
}, 3500);
const catState = queryClient.getQueryState(shopKeys.categories());
if (!catState || catState.status === 'pending') return false;
if (getToken()) {
const authQueryKeys = [
shopKeys.cart(),
shopKeys.profile(),
shopKeys.addresses(),
shopKeys.shippingMethods(),
shopKeys.bookmarks(),
shopKeys.orderCounters(),
];
for (const key of authQueryKeys) {
const state = queryClient.getQueryState(key);
if (!state || state.status === 'pending') return false;
}
}
if (queryClient.isFetching() > 0) return false;
return true;
};
const areTargetQueriesReady = (): boolean => {
if (currentBootPhase === 'home') {
return isHomeQueryReady();
}
if (
currentBootPhase === 'other-tabs' ||
(currentBootPhase === 'settled' &&
isPageReady &&
!isOtherTabsBackgroundSettled &&
currentClearVersion === 0)
) {
return areOtherMajorPagesQueriesReady();
}
return queryClient.isFetching() === 0;
};
const getInspectionRoot = (): HTMLElement | null => {
if (!majorPagesBootSettled && typeof document !== 'undefined') {
return document.getElementById('root') || viewportRef.current;
if (currentBootPhase === 'home') {
if (typeof document !== 'undefined') {
const homeEl = document.querySelector<HTMLElement>(
'[data-major-tab="home"]'
);
if (homeEl) return homeEl;
}
return viewportRef.current;
}
if (
currentBootPhase === 'other-tabs' ||
(currentBootPhase === 'settled' &&
isPageReady &&
!isOtherTabsBackgroundSettled &&
currentClearVersion === 0)
) {
if (typeof document !== 'undefined') {
return document.getElementById('root') || viewportRef.current;
}
}
return viewportRef.current;
};
const hasUnderlyingShimmer = (root: HTMLElement): boolean => {
const shimmers = root.querySelectorAll('.habib-shimmer, .habib-shimmer-dark');
const shimmers = root.querySelectorAll(
'.habib-shimmer, .habib-shimmer-dark, .habib-inline-spinner'
);
for (let i = 0; i < shimmers.length; i += 1) {
if (!shimmers[i].closest('.habib-page-shimmer-overlay')) {
if (
!shimmers[i].closest(
'.habib-page-shimmer-overlay, .habib-auth-loading-overlay'
)
) {
return true;
}
}
@ -209,56 +390,105 @@ export const MobileShell: React.FC<MobileShellProps> = ({
return result;
};
const markReady = (allMajorPagesComplete: boolean) => {
if (currentBootPhase === 'home') {
addSettledPathname('/');
addSettledPathname(targetPathname);
bootPhase = 'other-tabs';
emitShellStoreChange();
if (typeof window !== 'undefined') {
window.__announceHabibWebReady?.();
}
return;
}
if (allMajorPagesComplete) {
for (const p of ROOT_TAB_PATHS) {
settledPathnames.add(p);
}
otherTabsBackgroundSettled = true;
}
addSettledPathname(targetPathname);
bootPhase = 'settled';
emitShellStoreChange();
if (typeof window !== 'undefined') {
window.__announceHabibWebReady?.();
}
};
// Safety fallback so no boot phase or route transition can stay stuck on shimmers forever.
const safetyTimer =
currentBootPhase === 'home' ||
currentBootPhase === 'other-tabs' ||
(currentBootPhase === 'settled' && !isPageReady)
? window.setTimeout(
() => {
if (!cancelled) {
markReady(false);
}
},
currentBootPhase === 'home' ? 3500 : 3000
)
: undefined;
const evaluateReadiness = () => {
if (cancelled || verifying) return;
const rootEl = getInspectionRoot();
if (!rootEl) return;
if (queryClient.isFetching() > 0) return;
if (!areTargetQueriesReady()) return;
if (hasUnderlyingShimmer(rootEl)) return;
if (rafId !== null) {
window.cancelAnimationFrame(rafId);
}
cancelPendingRafs();
rafId = window.requestAnimationFrame(() => {
rafId = null;
rafId1 = window.requestAnimationFrame(() => {
rafId1 = null;
if (cancelled || verifying) return;
const currentEl = getInspectionRoot();
if (!currentEl) return;
if (queryClient.isFetching() > 0 || hasUnderlyingShimmer(currentEl)) {
return;
}
verifying = true;
const images = getUnderlyingImages(currentEl);
const fontPromise =
typeof document !== 'undefined' && document.fonts?.ready
? document.fonts.ready.catch(() => {})
: Promise.resolve();
void Promise.all([fontPromise, ...images.map(waitForImageReady)]).then(
() => {
verifying = false;
if (cancelled) return;
const latestEl = getInspectionRoot();
if (!latestEl) return;
if (queryClient.isFetching() > 0 || hasUnderlyingShimmer(latestEl)) {
evaluateReadiness();
return;
}
rafId2 = window.requestAnimationFrame(() => {
rafId2 = null;
if (cancelled || verifying) return;
const currentEl = getInspectionRoot();
if (!currentEl) return;
if (!areTargetQueriesReady() || hasUnderlyingShimmer(currentEl)) {
return;
}
const latestImages = getUnderlyingImages(latestEl);
const hasIncompleteNewImage = latestImages.some((img) => !img.complete);
if (hasIncompleteNewImage) {
evaluateReadiness();
return;
verifying = true;
const images = getUnderlyingImages(currentEl);
const awaitedSet = new Set(images);
const fontPromise =
typeof document !== 'undefined' && document.fonts?.ready
? document.fonts.ready.catch(() => {})
: Promise.resolve();
void Promise.all([fontPromise, ...images.map(waitForImageReady)]).then(
() => {
verifying = false;
if (cancelled) return;
const latestEl = getInspectionRoot();
if (!latestEl) return;
if (!areTargetQueriesReady() || hasUnderlyingShimmer(latestEl)) {
evaluateReadiness();
return;
}
const latestImages = getUnderlyingImages(latestEl);
const hasIncompleteNewImage = latestImages.some(
(img) => !awaitedSet.has(img) && !img.complete
);
if (hasIncompleteNewImage) {
evaluateReadiness();
return;
}
markReady(
currentBootPhase === 'other-tabs' ||
(!isOtherTabsBackgroundSettled && currentClearVersion === 0)
);
}
markReady();
}
);
);
});
});
};
@ -287,14 +517,23 @@ export const MobileShell: React.FC<MobileShellProps> = ({
return () => {
cancelled = true;
window.clearTimeout(safetyTimer);
if (rafId !== null) {
window.cancelAnimationFrame(rafId);
if (safetyTimer !== undefined) {
window.clearTimeout(safetyTimer);
}
cancelPendingRafs();
observer?.disconnect();
unsubscribeQueryCache();
};
}, [isEmbed, isMajorTabActive, isPageReady, location.pathname, queryClient]);
}, [
currentBootPhase,
currentClearVersion,
isEmbed,
isMajorTabActive,
isOtherTabsBackgroundSettled,
isPageReady,
location.pathname,
queryClient,
]);
const cssVars = {
'--desktop-frame-w': `${width}px`,
@ -321,7 +560,7 @@ export const MobileShell: React.FC<MobileShellProps> = ({
const viewportClasses = [
'habib-mobile-viewport',
transitionClass,
!isPageReady ? 'is-habib-loading' : '',
isMajorTabActive && !isPageReady ? 'is-habib-loading' : '',
]
.filter(Boolean)
.join(' ');
@ -337,7 +576,9 @@ export const MobileShell: React.FC<MobileShellProps> = ({
className={viewportClasses}
style={cssVars}
>
{!isPageReady && <FullPageRouteShimmer pathname={location.pathname} />}
{isMajorTabActive && !isPageReady && (
<FullPageRouteShimmer pathname={location.pathname} />
)}
{children}
</div>
</div>

7
src/components/layout/StickyFooterBar.tsx

@ -1,5 +1,6 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { tr } from '../../lib/cookies';
interface StickyFooterBarProps {
top?: number;
@ -154,7 +155,7 @@ export const StickyFooterBar: React.FC<StickyFooterBarProps> = ({
whiteSpace: 'nowrap',
}}
>
{totalItemsLabel}
{tr(totalItemsLabel)}
</span>
<img
src="/assets/images/icon-caret-up-gold.svg"
@ -175,7 +176,7 @@ export const StickyFooterBar: React.FC<StickyFooterBarProps> = ({
whiteSpace: 'nowrap',
}}
>
{topLabel}
{tr(topLabel)}
</span>
)}
</div>
@ -240,7 +241,7 @@ export const StickyFooterBar: React.FC<StickyFooterBarProps> = ({
whiteSpace: 'nowrap',
}}
>
{buttonText}
{tr(buttonText)}
</span>
{isIconRight && (
<img

5
src/components/layout/TopHeader.tsx

@ -1,5 +1,6 @@
import React from 'react';
import { useSmartBack } from '../../hooks/useSmartBack';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface StandardPageHeaderProps {
@ -42,7 +43,7 @@ export const StandardPageHeader: React.FC<StandardPageHeaderProps> = ({
smartBack(backTo);
}
}}
aria-label="Back"
aria-label={tr('Back')}
style={{
position: 'absolute',
left: 'var(--page-px, 16px)',
@ -84,7 +85,7 @@ export const StandardPageHeader: React.FC<StandardPageHeaderProps> = ({
textAlign: 'center',
}}
>
{title}
{tr(title)}
</h1>
</header>
);

1067
src/components/modals/AddressFormSheet.tsx
File diff suppressed because it is too large
View File

9
src/components/modals/LoginRequiredModal.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useAnimatedPresence } from '../../hooks/use-animated-presence';
import { useHardwareBackHandler } from '../../hooks/use-hardware-back-handler';
import { tr } from '../../lib/cookies';
import { InlineSpinner } from '../common/ShimmerSkeletons';
export interface LoginRequiredModalProps {
@ -110,7 +111,7 @@ export const LoginRequiredModal: React.FC<LoginRequiredModalProps> = ({
color: '#111111',
}}
>
{title}
{tr(title)}
</h2>
{/* Description */}
@ -124,7 +125,7 @@ export const LoginRequiredModal: React.FC<LoginRequiredModalProps> = ({
color: '#64748b',
}}
>
{description}
{tr(description)}
</p>
{/* Actions */}
@ -162,7 +163,7 @@ export const LoginRequiredModal: React.FC<LoginRequiredModalProps> = ({
}}
>
{isLoggingIn && <InlineSpinner size={16} />}
<span>{isLoggingIn ? 'Opening Habib Login...' : 'Log In'}</span>
<span>{isLoggingIn ? tr('Opening Habib Login...') : tr('Log In')}</span>
</button>
<button
@ -183,7 +184,7 @@ export const LoginRequiredModal: React.FC<LoginRequiredModalProps> = ({
cursor: isLoggingIn ? 'not-allowed' : 'pointer',
}}
>
Cancel
{tr('Cancel')}
</button>
</div>
</div>

7
src/components/modals/OrderSummarySheet.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useAnimatedPresence } from '../../hooks/use-animated-presence';
import { useHardwareBackHandler } from '../../hooks/use-hardware-back-handler';
import { tr } from '../../lib/cookies';
import { OrderSummaryRows, type SummaryLineRow } from '../checkout/OrderSummaryRows';
interface OrderSummarySheetProps {
@ -70,13 +71,13 @@ export const OrderSummarySheet: React.FC<OrderSummarySheetProps> = ({
color: '#111111',
}}
>
Order Summary
{tr('Order Summary')}
</span>
<button
type="button"
className="habib-icon-btn"
onClick={onClose}
aria-label="Close"
aria-label={tr('Close')}
style={{
width: '24px',
height: '24px',
@ -120,7 +121,7 @@ export const OrderSummarySheet: React.FC<OrderSummarySheetProps> = ({
color: '#fbfbfc',
}}
>
{ctaText}
{tr(ctaText)}
</button>
</div>
</div>

7
src/components/modals/PaymentMethodsSheet.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useAnimatedPresence } from '../../hooks/use-animated-presence';
import { useHardwareBackHandler } from '../../hooks/use-hardware-back-handler';
import { tr } from '../../lib/cookies';
import { EmptyStateBox, InlineSpinner } from '../common/ShimmerSkeletons';
import { PaymentMethodCard } from '../checkout/PaymentMethodCard';
import type { PaymentMethodItem } from '../../data/checkoutData';
@ -81,7 +82,7 @@ export const PaymentMethodsSheet: React.FC<PaymentMethodsSheetProps> = ({
color: '#111111',
}}
>
Payment Methods
{tr('Payment Methods')}
</div>
<button
@ -89,7 +90,7 @@ export const PaymentMethodsSheet: React.FC<PaymentMethodsSheetProps> = ({
className="habib-icon-btn"
disabled={isSubmitting}
onClick={onClose}
aria-label="Close"
aria-label={tr('Close')}
style={{
width: '24px',
height: '24px',
@ -189,7 +190,7 @@ export const PaymentMethodsSheet: React.FC<PaymentMethodsSheetProps> = ({
color: '#fbfbfc',
}}
>
{isSubmitting ? 'Processing...' : 'Purchase'}
{isSubmitting ? tr('Processing...') : tr('Purchase')}
</span>
</div>

19
src/components/modals/ShipmentTrackingSheet.tsx

@ -1,6 +1,7 @@
import React, { useRef } from 'react';
import { useAnimatedPresence } from '../../hooks/use-animated-presence';
import { useHardwareBackHandler } from '../../hooks/use-hardware-back-handler';
import { tr } from '../../lib/cookies';
import type { ApiShipment } from '../../lib/shopApi';
import { copyToClipboard } from '../../lib/webview-actions';
@ -77,13 +78,13 @@ export const ShipmentTrackingSheet: React.FC<ShipmentTrackingSheetProps> = ({
color: '#111111',
}}
>
Shipment Tracking • {activeShipment.booth_name}
{tr('Shipment Tracking')} • {activeShipment.booth_name}
</span>
<button
type="button"
className="habib-icon-btn"
onClick={onClose}
aria-label="Close"
aria-label={tr('Close')}
style={{
width: '24px',
height: '24px',
@ -112,7 +113,7 @@ export const ShipmentTrackingSheet: React.FC<ShipmentTrackingSheetProps> = ({
}}
>
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: '12px' }}>
<span style={{ color: '#747474', fontWeight: 600 }}>Carrier</span>
<span style={{ color: '#747474', fontWeight: 600 }}>{tr('Carrier')}</span>
<span style={{ color: '#111111', fontWeight: 700 }}>
{activeShipment.carrier_name || 'Habib Global Post'}
</span>
@ -126,7 +127,7 @@ export const ShipmentTrackingSheet: React.FC<ShipmentTrackingSheetProps> = ({
fontSize: '12px',
}}
>
<span style={{ color: '#747474', fontWeight: 600 }}>Tracking Code</span>
<span style={{ color: '#747474', fontWeight: 600 }}>{tr('Tracking code')}</span>
<button
type="button"
onClick={handleCopyTracking}
@ -137,14 +138,14 @@ export const ShipmentTrackingSheet: React.FC<ShipmentTrackingSheetProps> = ({
cursor: 'pointer',
}}
>
{activeShipment.tracking_code} (Copy)
{activeShipment.tracking_code} ({tr('Copy')})
</button>
</div>
)}
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: '12px' }}>
<span style={{ color: '#747474', fontWeight: 600 }}>Estimated Delivery</span>
<span style={{ color: '#747474', fontWeight: 600 }}>{tr('Estimated Delivery')}</span>
<span style={{ color: '#111111', fontWeight: 700 }}>
{activeShipment.estimated_delivery_label || '2–3 Business Days'}
{tr(activeShipment.estimated_delivery_label || '2-3 business day')}
</span>
</div>
</div>
@ -171,7 +172,7 @@ export const ShipmentTrackingSheet: React.FC<ShipmentTrackingSheetProps> = ({
/>
<div style={{ display: 'flex', flexDirection: 'column', gap: '2px' }}>
<span style={{ fontSize: '13px', fontWeight: 700, color: '#111111' }}>
{ev.title}
{tr(ev.title)}
</span>
<span style={{ fontSize: '11px', color: '#747474' }}>
{ev.location ? `${ev.location} • ` : ''}
@ -197,7 +198,7 @@ export const ShipmentTrackingSheet: React.FC<ShipmentTrackingSheetProps> = ({
cursor: 'pointer',
}}
>
Close
{tr('Close')}
</button>
</div>
</div>

11
src/components/orders/OrderFilterTabs.tsx

@ -1,5 +1,6 @@
import React from 'react';
import type { OrderFilterTabItem } from '../../data/ordersData';
import { isRtlLanguage, tr } from '../../lib/cookies';
interface OrderFilterTabsProps {
tabs: OrderFilterTabItem[];
@ -17,6 +18,7 @@ export const OrderFilterTabs: React.FC<OrderFilterTabsProps> = ({
activeTabId,
onSelectTab,
}) => {
const isRtl = isRtlLanguage();
const activeIndex = Math.max(
0,
tabs.findIndex((t) => t.id === activeTabId)
@ -41,7 +43,8 @@ export const OrderFilterTabs: React.FC<OrderFilterTabsProps> = ({
aria-hidden="true"
style={{
position: 'absolute',
left: 4,
left: isRtl ? undefined : 4,
right: isRtl ? 4 : undefined,
top: 4,
bottom: 4,
width: 'calc((100% - 16px) / 3)',
@ -49,7 +52,9 @@ export const OrderFilterTabs: React.FC<OrderFilterTabsProps> = ({
backgroundColor: '#d78e06',
border: '1px solid rgba(255, 255, 255, 0.3)',
boxShadow: '0px 4px 11px rgba(215, 142, 6, 0.3)',
transform: `translateX(calc(${activeIndex} * (100% + 4px)))`,
transform: isRtl
? `translateX(calc(-${activeIndex} * (100% + 4px)))`
: `translateX(calc(${activeIndex} * (100% + 4px)))`,
transition: 'transform 260ms cubic-bezier(0.22, 1, 0.36, 1)',
pointerEvents: 'none',
zIndex: 1,
@ -96,7 +101,7 @@ export const OrderFilterTabs: React.FC<OrderFilterTabsProps> = ({
transition: 'color 220ms cubic-bezier(0.22, 1, 0.36, 1)',
}}
>
{tab.label}
{tr(tab.label)}
</span>
{/* Count badge pill 19×19 */}

9
src/components/orders/OrderListCard.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { OrderCardData } from '../../data/ordersData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface OrderListCardProps {
@ -214,7 +215,7 @@ export const OrderListCard: React.FC<OrderListCardProps> = ({
whiteSpace: 'nowrap',
}}
>
{order.itemsCountText}
{tr(order.itemsCountText)}
</span>
</div>
@ -247,7 +248,7 @@ export const OrderListCard: React.FC<OrderListCardProps> = ({
whiteSpace: 'nowrap',
}}
>
{order.shopsCountText}
{tr(order.shopsCountText)}
</span>
</div>
</div>
@ -290,7 +291,7 @@ export const OrderListCard: React.FC<OrderListCardProps> = ({
whiteSpace: 'nowrap',
}}
>
{order.deliveryProgressText}
{tr(order.deliveryProgressText)}
</span>
</div>
</div>
@ -338,7 +339,7 @@ export const OrderListCard: React.FC<OrderListCardProps> = ({
whiteSpace: 'nowrap',
}}
>
View Details
{tr('View Details')}
</span>
</button>
</div>

9
src/components/orders/ShipmentStatusCard.tsx

@ -1,5 +1,6 @@
import React from 'react';
import type { ShipmentCardData } from '../../data/ordersData';
import { tr } from '../../lib/cookies';
interface ShipmentStatusCardProps {
shipment: ShipmentCardData;
@ -104,7 +105,7 @@ export const ShipmentStatusCard: React.FC<ShipmentStatusCardProps> = ({ shipment
whiteSpace: 'nowrap',
}}
>
{shipment.statusLabel}
{tr(shipment.statusLabel)}
</span>
</div>
</div>
@ -178,7 +179,7 @@ export const ShipmentStatusCard: React.FC<ShipmentStatusCardProps> = ({ shipment
whiteSpace: 'nowrap',
}}
>
{row.label}
{tr(row.label)}
</span>
</div>
<span
@ -192,7 +193,7 @@ export const ShipmentStatusCard: React.FC<ShipmentStatusCardProps> = ({ shipment
wordBreak: 'break-all',
}}
>
{row.value}
{tr(row.value)}
</span>
</div>
))}
@ -306,7 +307,7 @@ export const ShipmentStatusCard: React.FC<ShipmentStatusCardProps> = ({ shipment
whiteSpace: 'nowrap',
}}
>
{label}
{tr(label)}
</span>
</div>
);

176
src/context/ShopAppContext.tsx

@ -9,13 +9,25 @@ import React, {
} from 'react';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useLocation } from 'react-router-dom';
import {
clearSettledPathnames,
useHomeBootSettled,
} from '../components/layout/MobileShell';
import { InlineSpinner } from '../components/common/ShimmerSkeletons';
import { LoginRequiredModal } from '../components/modals/LoginRequiredModal';
import {
ensureToken,
getToken,
readBootstrapUserHint,
} from '../lib/auth-bridge';
import { getUserLanguage, setUserLanguage } from '../lib/cookies';
import {
applyDocumentLanguage,
getUserLanguage,
normalizeLanguage,
setUserLanguage,
tr,
} from '../lib/cookies';
import { resolveMediaUrl } from '../lib/http';
import {
type ApiAddress,
type ApiCart,
@ -135,6 +147,7 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
useHabibWebReady(isNonShellRoute);
const hasAuthToken = Boolean(authToken);
const homeBootSettled = useHomeBootSettled();
const homeQuery = useQuery({
queryKey: shopKeys.home(),
@ -145,7 +158,7 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
const categoriesQuery = useQuery({
queryKey: shopKeys.categories(),
queryFn: () => shopApi.fetchCategories(),
enabled: !isBare,
enabled: !isBare && homeBootSettled,
});
useEffect(() => {
@ -162,49 +175,51 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
const cartQuery = useQuery({
queryKey: shopKeys.cart(),
queryFn: () => shopApi.fetchCart(false),
enabled: !isBare && hasAuthToken,
enabled: !isBare && hasAuthToken && homeBootSettled,
});
const profileQuery = useQuery({
queryKey: shopKeys.profile(),
queryFn: () => shopApi.fetchProfile(),
enabled: !isBare && hasAuthToken,
enabled: !isBare && hasAuthToken && homeBootSettled,
});
const addressesQuery = useQuery({
queryKey: shopKeys.addresses(),
queryFn: () => shopApi.fetchAddresses(),
enabled: !isBare && hasAuthToken,
enabled: !isBare && hasAuthToken && homeBootSettled,
});
const shippingMethodsQuery = useQuery({
queryKey: shopKeys.shippingMethods(),
queryFn: () => shopApi.fetchShippingMethods(),
enabled: !isBare && hasAuthToken,
enabled: !isBare && hasAuthToken && homeBootSettled,
staleTime: 5 * 60_000,
});
const bookmarksQuery = useQuery({
queryKey: shopKeys.bookmarks(),
queryFn: () => shopApi.fetchBookmarks(),
enabled: !isBare && hasAuthToken,
enabled: !isBare && hasAuthToken && homeBootSettled,
});
const orderCountersQuery = useQuery({
queryKey: shopKeys.orderCounters(),
queryFn: () => shopApi.fetchOrderCounters(),
enabled: !isBare && hasAuthToken,
enabled: !isBare && hasAuthToken && homeBootSettled,
});
const publicMajorHydrated =
!homeQuery.isPending && !categoriesQuery.isPending;
homeBootSettled && !homeQuery.isPending && !categoriesQuery.isPending;
const authMajorHydrated =
!hasAuthToken ||
(!cartQuery.isPending &&
(homeBootSettled &&
!cartQuery.isPending &&
!bookmarksQuery.isPending &&
!profileQuery.isPending &&
!orderCountersQuery.isPending &&
!addressesQuery.isPending);
!addressesQuery.isPending &&
!shippingMethodsQuery.isPending);
const hydrated = isBare || (publicMajorHydrated && authMajorHydrated);
const cart = cartQuery.data ?? null;
@ -229,10 +244,10 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
const isProfileLoading =
!isBare &&
isUserAuthenticated &&
!hasProfileIdentity &&
(isAuthProfileSyncing ||
profileQuery.isPending ||
profileQuery.isFetching);
(!hasProfileIdentity &&
homeBootSettled &&
(profileQuery.isPending || profileQuery.isFetching)));
const addresses = useMemo(
() => addressesQuery.data?.results ?? [],
@ -263,7 +278,7 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
);
const showToast = useCallback((message: string) => {
setToastMessage(message);
setToastMessage(tr(message));
if (typeof window !== 'undefined') {
if (toastTimerRef.current !== undefined) {
window.clearTimeout(toastTimerRef.current);
@ -274,6 +289,48 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
}
}, []);
useEffect(() => {
applyDocumentLanguage(language);
}, [language, location.pathname, location.search]);
useEffect(() => {
if (typeof window === 'undefined') return;
const syncExternalLanguage = (nextRaw?: string) => {
const next = normalizeLanguage(nextRaw ?? getUserLanguage());
applyDocumentLanguage(next);
setLanguage((prev) => {
if (prev !== next) {
clearSettledPathnames();
void queryClient.invalidateQueries({ queryKey: shopKeys.all });
}
return next;
});
};
const handleLangChanged = (event: Event) => {
const custom = event as CustomEvent<{ language?: string }>;
syncExternalLanguage(custom.detail?.language);
};
const handleStorage = (event: StorageEvent) => {
if (
!event.key ||
event.key === 'habib_shop_language' ||
event.key === 'HABIB_LANGUAGE'
) {
syncExternalLanguage(event.newValue || undefined);
}
};
window.addEventListener('habib:language-changed', handleLangChanged);
window.addEventListener('storage', handleStorage);
return () => {
window.removeEventListener('habib:language-changed', handleLangChanged);
window.removeEventListener('storage', handleStorage);
};
}, [queryClient]);
const seedProfileFromBridgeHint = useCallback(() => {
const hint = readBootstrapUserHint();
if (!hint) return;
@ -319,17 +376,52 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
});
}, [queryClient]);
const preloadAvatarImage = useCallback((rawAvatarUrl?: string | null): Promise<void> => {
if (typeof window === 'undefined' || !rawAvatarUrl?.trim()) {
return Promise.resolve();
}
const resolved = resolveMediaUrl(rawAvatarUrl);
if (!resolved) return Promise.resolve();
return new Promise<void>((resolve) => {
let settled = false;
const img = new Image();
const finish = () => {
if (settled) return;
settled = true;
window.clearTimeout(timer);
if (typeof img.decode === 'function') {
void img.decode().catch(() => {}).finally(resolve);
} else {
resolve();
}
};
const timer = window.setTimeout(finish, 2500);
img.onload = finish;
img.onerror = finish;
img.src = resolved;
if (img.complete) {
finish();
}
});
}, []);
const refreshAccountData = useCallback(async () => {
if (!getToken()) return;
seedProfileFromBridgeHint();
setIsAuthProfileSyncing(true);
try {
await Promise.allSettled([
queryClient.fetchQuery({
queryKey: shopKeys.profile(),
queryFn: () => shopApi.fetchProfile(),
staleTime: 0,
}),
queryClient
.fetchQuery({
queryKey: shopKeys.profile(),
queryFn: () => shopApi.fetchProfile(),
staleTime: 0,
})
.then(async (fetchedProfile) => {
if (fetchedProfile?.avatar_url) {
await preloadAvatarImage(fetchedProfile.avatar_url);
}
}),
queryClient.fetchQuery({
queryKey: shopKeys.addresses(),
queryFn: () => shopApi.fetchAddresses(),
@ -355,7 +447,7 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
} finally {
setIsAuthProfileSyncing(false);
}
}, [queryClient, seedProfileFromBridgeHint]);
}, [preloadAvatarImage, queryClient, seedProfileFromBridgeHint]);
useEffect(() => {
if (typeof window === 'undefined') return;
@ -663,10 +755,13 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
const changeLanguage = useCallback(
(lang: string) => {
setUserLanguage(lang);
setLanguage(lang);
const normalized = normalizeLanguage(lang);
setUserLanguage(normalized);
setLanguage(normalized);
applyDocumentLanguage(normalized);
clearSettledPathnames();
const label =
lang === 'fa' ? 'فارسی' : lang === 'ar' ? 'العربية' : 'English';
normalized === 'fa' ? 'فارسی' : normalized === 'ar' ? 'العربية' : 'English';
showToast(`Language set to ${label}`);
void queryClient.invalidateQueries({ queryKey: shopKeys.all });
},
@ -780,6 +875,39 @@ export const ShopAppProvider: React.FC<{ children: React.ReactNode }> = ({
return (
<ShopAppContext.Provider value={value}>
{children}
{isProfileLoading && (
<div
role="status"
aria-live="polite"
aria-label="Loading account data"
className="habib-auth-loading-overlay habib-sheet-backdrop"
style={{
position: 'fixed',
inset: 0,
zIndex: 9998,
backgroundColor: 'rgba(21, 28, 49, 0.42)',
backdropFilter: 'blur(3px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<div
style={{
width: 68,
height: 68,
borderRadius: 20,
backgroundColor: '#ffffff',
boxShadow: '0px 14px 36px rgba(17, 17, 17, 0.22)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<InlineSpinner size={30} gold />
</div>
</div>
)}
<LoginRequiredModal
isOpen={loginModalState.isOpen}
title={loginModalState.title}

425
src/data/routesRegistry.ts

@ -1,425 +0,0 @@
export interface ScreenRouteEntry {
id: string;
figmaNodeId: string;
figmaName: string;
title: string;
route: string;
aliases?: string[];
category: 'Home & Discovery' | 'Product & Store' | 'Cart & Checkout' | 'Orders & Support' | 'Account & Settings' | 'Standalone Nodes';
width: number;
height: number;
refImage?: string;
description: string;
scenarios: {
label: string;
route: string;
description: string;
}[];
}
export const ALL_IMPLEMENTED_ROUTES: ScreenRouteEntry[] = [
// 1. Home & Discovery
{
id: 'shop-home',
figmaNodeId: '4080:9587',
figmaName: 'shop-home',
title: 'Shop Home (Marketplace Landing)',
route: '/shop-home',
aliases: ['/'],
category: 'Home & Discovery',
width: 375,
height: 1074,
refImage: '/assets/images/references/ref-shop-home.png',
description: 'Main Habib Shop landing page with Islamic pattern header, search bar, green hero banner, 5 quick categories, Populars & New Stores product carousels, and bottom navigation.',
scenarios: [
{ label: 'Default Landing View', route: '/shop-home', description: 'Initial marketplace home state (375×1074).' },
{ label: 'Open Category Grid via "More"', route: '/shop-category', description: 'Navigate to full 2×6 category grid.' },
{ label: 'Open Single Product Card', route: '/shop-single-page', description: 'Click any product card to view product details.' },
],
},
{
id: 'shop-category',
figmaNodeId: '4181:12170',
figmaName: 'shop-category',
title: 'Shop Category Grid',
route: '/shop-category',
category: 'Home & Discovery',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-category.png',
description: '2-column × 6-row category grid with "24" count badges, search bar, and active Category bottom navigation tab.',
scenarios: [
{ label: 'Default Category Grid', route: '/shop-category', description: 'Full 12-tile category view (375×814).' },
{ label: 'Select Category -> Category Items', route: '/shop-catitems', description: 'Click any category tile to open Home & Living items.' },
],
},
{
id: 'shop-catitems',
figmaNodeId: '4181:12817',
figmaName: 'shop-catitems',
title: 'Category Items (Home & Living)',
route: '/shop-catitems',
category: 'Home & Discovery',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-catitems.png',
description: 'Category product listing for "Home & Living" with back button, search bar, and 2-column × 3-row product grid.',
scenarios: [
{ label: 'Default Category Items Grid', route: '/shop-catitems', description: '6 product cards in 2 columns (375×814).' },
],
},
// 2. Product & Store
{
id: 'shop-single-page',
figmaNodeId: '4153:19198',
figmaName: 'shop-single page',
title: 'Single Product Page',
route: '/shop-single-page',
category: 'Product & Store',
width: 375,
height: 1233,
refImage: '/assets/images/references/ref-shop-single-page.png',
description: 'Product detail page for "Islam in the Bible Book" with hero image, condition/processing/type badges, Al-Hujjah Books seller row, Information/Review tabs, Populars row, and sticky Add to Cart footer.',
scenarios: [
{ label: 'Information Tab (Default)', route: '/shop-single-page', description: 'Default product details with Information tab active (375×1233).' },
{ label: 'Visit Seller Booth (Al-Hujjah Books)', route: '/shop-booth', description: 'Click seller row to open shop-Booth.' },
{ label: 'Add to Cart Action', route: '/shop-cart', description: 'Click Add to Cart button to navigate to Cart.' },
],
},
{
id: 'shop-booth',
figmaNodeId: '4129:15733',
figmaName: 'shop-Booth',
title: 'Shop Booth (Seller Storefront)',
route: '/shop-booth',
category: 'Product & Store',
width: 375,
height: 1233,
refImage: '/assets/images/references/ref-shop-booth.png',
description: 'Storefront page for "Al-Hujjah Books" with banner cover, circular logo, Iran flag, 4.2 rating, Chat/Delivery/Guarantee action cards, search bar, and 2×3 product grid.',
scenarios: [
{ label: 'Default Storefront View', route: '/shop-booth', description: 'Al-Hujjah Books booth page (375×1233).' },
{ label: 'Open Booth Chat', route: '/shop-chat', description: 'Click Chat card to message Al-Hujjah Books.' },
],
},
{
id: 'shop-chat',
figmaNodeId: '4129:17403',
figmaName: 'shop-chat',
title: 'Shop Chat (Direct Messaging)',
route: '/shop-chat',
category: 'Product & Store',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-chat.png',
description: 'Direct chat interface with Al-Hujjah Books featuring encryption notice, support notice card, incoming/outgoing message bubbles, delivery error retry, and message composer.',
scenarios: [
{ label: 'Default Conversation State', route: '/shop-chat', description: 'Exact Figma conversation state with retry indicator (375×814).' },
],
},
// 3. Cart & Checkout
{
id: 'shop-cart',
figmaNodeId: '4129:17527',
figmaName: 'shop-cart',
title: 'Shopping Cart',
route: '/shop-cart',
category: 'Cart & Checkout',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-cart.png',
description: 'Shopping cart with "3 item from 2 Shops", "Clear all" action, 2 cart item cards with quantity steppers, sticky checkout bar, and active Cart bottom nav tab.',
scenarios: [
{ label: 'Default Cart View', route: '/shop-cart', description: '2 cart items with sticky checkout bar (375×814).' },
{ label: 'Open Order Summary Sheet', route: '/shop-order-summery', description: 'Click "Total 4 item ^" to open order summary modal.' },
{ label: 'Proceed to Shipping Details', route: '/shop-buy01', description: 'Click checkout button to select delivery address.' },
],
},
{
id: 'shop-order-summery',
figmaNodeId: '4154:20497',
figmaName: 'shop-order summery',
title: 'Order Summary Modal Sheet',
route: '/shop-order-summery',
category: 'Cart & Checkout',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-order-summery.png',
description: 'Cart screen overlaid with dark backdrop (opacity 0.9) and "Orded Summery" bottom sheet showing line items ($70.50), Total, and "Got it" button.',
scenarios: [
{ label: 'Modal Open State (Default)', route: '/shop-order-summery', description: 'Order Summary bottom sheet open over Cart (375×814).' },
],
},
{
id: 'shop-buy01',
figmaNodeId: '4159:367',
figmaName: 'shop-buy01',
title: 'Shipping Details (Checkout Step 1)',
route: '/shop-buy01',
category: 'Cart & Checkout',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-buy01.png',
description: 'Shipping details page with Delivery Address selection (Ali Ghaderi selected, Sina Sajjadi, Add New adress), Standard shiping ($5,00), encryption notice, and Continue footer.',
scenarios: [
{ label: 'Default Shipping Details', route: '/shop-buy01', description: 'Ali Ghaderi address & Standard shipping selected (375×814).' },
{ label: 'Continue to Review & Confirm', route: '/shop-payment', description: 'Click Continue to review order items.' },
],
},
{
id: 'shop-payment',
figmaNodeId: '4160:11203',
figmaName: 'shop-payment',
title: 'Review & Confirm (Checkout Step 2)',
route: '/shop-payment',
category: 'Cart & Checkout',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-payment.png',
description: 'Order review screen showing Review items (2 book cards with quantities 1 and 2), Delivery Address (Ali Ghaderi), Orded Summery ($70.50), and Payment CTA footer.',
scenarios: [
{ label: 'Default Review & Confirm', route: '/shop-payment', description: 'Review items, address, and summary (375×814).' },
{ label: 'Open Payment Methods Sheet', route: '/shop-payment-methods', description: 'Click Payment button to choose payment method.' },
],
},
{
id: 'shop-payment-methods',
figmaNodeId: '4171:1394',
figmaName: 'shop-payment (modal)',
title: 'Payment Methods Modal Sheet',
route: '/shop-payment-methods',
category: 'Cart & Checkout',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-payment-methods.png',
description: 'Bottom sheet modal "Payment methos" with Google Pay (selected), PayPal, and Master Card options, plus "Purchase $24.00" CTA button.',
scenarios: [
{ label: 'Google Pay Selected (Default)', route: '/shop-payment-methods', description: 'Payment methods modal sheet (375×814).' },
{ label: 'Complete Purchase -> Payment Result', route: '/shop-payresult', description: 'Click Purchase button to view payment receipt.' },
],
},
{
id: 'shop-payresult',
figmaNodeId: '4162:11664',
figmaName: 'shop-payresult',
title: 'Payment Result (Success Receipt)',
route: '/shop-payresult',
category: 'Cart & Checkout',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-payresult.png',
description: 'Payment Successful screen with 3D shopping basket & green checkmark, Total Paid ($70.50), Order Code (ORD-28465), PayPal, Mar 15,2025 | 9:41 PM, track Order, and Continue Shoping.',
scenarios: [
{ label: 'Payment Success Receipt', route: '/shop-payresult', description: 'Confirmed order receipt (375×814).' },
{ label: 'Track Order -> Order Details', route: '/shop-order-detail', description: 'Click track Order to inspect shipment progress.' },
],
},
// 4. Orders & Support
{
id: 'shop-orders',
figmaNodeId: '4175:9811',
figmaName: 'shop-orders',
title: 'Orders List',
route: '/shop-orders',
category: 'Orders & Support',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-orders.png',
description: 'Orders list page with segmented filter tabs (Current 2, Delivered 5, Canceled 0) and 2 order summary cards with item thumbnails, delivery status badges, and View Details buttons.',
scenarios: [
{ label: 'Current Orders Tab (Default)', route: '/shop-orders', description: 'Current orders tab active with 2 orders (375×814).' },
{ label: 'Open Order Details', route: '/shop-order-detail', description: 'Click View Details on any order card.' },
],
},
{
id: 'shop-order-detail',
figmaNodeId: '4175:10421',
figmaName: 'shop-order detail',
title: 'Order Details (Multi-Shipment Stepper)',
route: '/shop-order-detail',
category: 'Orders & Support',
width: 375,
height: 1061,
refImage: '/assets/images/references/ref-shop-order-detail.png',
description: 'Detailed order view for ORD-28465 showing 3 shipment cards (Packed, Delivered, Shiping) with 4-step progress bars (Order, Packed, Shiping, Delivery) and Order support CTA.',
scenarios: [
{ label: 'All 3 Shipment States (Default)', route: '/shop-order-detail', description: 'Packed, Delivered, and Shiping shipment cards (375×1061).' },
{ label: 'Request Order Support', route: '/shop-support', description: 'Click Order support button at bottom.' },
],
},
{
id: 'shop-support',
figmaNodeId: '4177:11244',
figmaName: 'shop-support',
title: 'Order Support Request Form',
route: '/shop-support',
category: 'Orders & Support',
width: 375,
height: 1061,
refImage: '/assets/images/references/ref-shop-support.png',
description: 'Support form with product summary, Order support info banner, 6 Request Subject* tiles (Counterfeit Item selected), Description* textarea, Upload Image dropzone, and Submit Order CTA.',
scenarios: [
{ label: 'Counterfeit Item Selected (Default)', route: '/shop-support', description: 'Exact Figma support form state (375×1061).' },
],
},
// 5. Account & Settings
{
id: 'shop-account',
figmaNodeId: '4214:345',
figmaName: 'shop-category (Account)',
title: 'Shop Account Overview',
route: '/shop-account',
aliases: ['/shop-category-4214-345'],
category: 'Account & Settings',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-account.png',
description: 'User account dashboard for "Habib shoper" (09102036523) with 3 order status counters (In Progress, Delivered, Returned), 7 settings rows (Accunt detail, Adresses, Language, Notifications, Bookmarks, FAQ, Support & Requests), Sign out button, and active Account nav tab.',
scenarios: [
{ label: 'Default Account Overview', route: '/shop-account', description: 'Habib shoper profile & order counters (375×814).' },
{ label: 'Account Details', route: '/provider-requst', description: 'Click Accunt detail row to edit profile details.' },
{ label: 'Manage Addresses', route: '/shop-adreess', description: 'Click Adresses row to manage saved addresses.' },
{ label: 'Open Language & Provider Hub', route: '/language-setting', description: 'Click Language row.' },
],
},
{
id: 'shop-adreess',
figmaNodeId: '4182:13316',
figmaName: 'shop-adreess',
title: 'My Addresses',
route: '/shop-adreess',
category: 'Account & Settings',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-shop-adreess.png',
description: 'Saved addresses screen ("My Adresses") with Ali Ghaderi (selected) and Sina Sajjadi cards featuring delete/edit icon buttons, plus "Add New adress" row.',
scenarios: [
{ label: 'Default Saved Addresses', route: '/shop-adreess', description: 'Ali Ghaderi & Sina Sajjadi addresses (375×814).' },
],
},
{
id: 'provider-requst',
figmaNodeId: '4220:13695',
figmaName: 'cs (Accunt detail)',
title: 'Account Detail',
route: '/provider-requst',
category: 'Account & Settings',
width: 375,
height: 814,
refImage: '/assets/images/references/ref-provider-requst.png',
description: 'Account detail form ("Accunt detail") with avatar & camera badge, email subtitle, Full Name*, Date of Birth*, Whatsapp Number*, Email input, and Submit button.',
scenarios: [
{ label: 'Account Detail Form (Default)', route: '/provider-requst', description: 'Account detail screen (375×814).' },
],
},
{
id: 'language-setting',
figmaNodeId: '4214:11018',
figmaName: 'language-setting',
title: 'Language Setting & Provider Status',
route: '/language-setting',
category: 'Account & Settings',
width: 375,
height: 813,
refImage: '/assets/images/references/ref-language-setting.png',
description: 'Profile & language overview for "Ahd Art" (Ahdart14@gmail.com) with Pending/rejected provider requests, Donate Habib green banner, 21 Habib Coins, Apply as Provider, My Wallet ($24), and Location/Language rows.',
scenarios: [
{ label: 'Default Language & Provider Overview', route: '/language-setting', description: 'Ahd Art profile & settings (375×813).' },
],
},
// 6. Standalone Component / Icon / Text Nodes
{
id: 'node-boxicons-user-filled',
figmaNodeId: '4128:14530',
figmaName: 'boxicons:user-filled',
title: 'Standalone Node: boxicons:user-filled',
route: '/node/boxicons-user-filled',
category: 'Standalone Nodes',
width: 28,
height: 28,
refImage: '/assets/images/references/ref-boxicons-user-filled.png',
description: 'Standalone 28×28 user icon frame extracted at top-level of data.md.',
scenarios: [
{ label: 'Exact 28×28 Node', route: '/node/boxicons-user-filled', description: 'View standalone 28×28 node.' },
],
},
{
id: 'node-frame-4175-10154',
figmaNodeId: '4175:10154',
figmaName: 'Frame 2095586758 (Packed)',
title: 'Standalone Node: Packed Step Icon',
route: '/node/frame-4175-10154',
category: 'Standalone Nodes',
width: 42,
height: 39.15,
refImage: '/assets/images/references/ref-frame-4175-10154.png',
description: 'Standalone 42×39.15 "Packed" step icon and label frame.',
scenarios: [
{ label: 'Exact 42×39.15 Node', route: '/node/frame-4175-10154', description: 'View standalone Packed step node.' },
],
},
{
id: 'node-frame-4175-10157',
figmaNodeId: '4175:10157',
figmaName: 'Frame 2095586759 (Delivery)',
title: 'Standalone Node: Delivery Step Icon',
route: '/node/frame-4175-10157',
category: 'Standalone Nodes',
width: 48,
height: 39.15,
refImage: '/assets/images/references/ref-frame-4175-10157.png',
description: 'Standalone 48×39.15 "Delivery" step icon and label frame.',
scenarios: [
{ label: 'Exact 48×39.15 Node', route: '/node/frame-4175-10157', description: 'View standalone Delivery step node.' },
],
},
{
id: 'node-frame-4175-10160',
figmaNodeId: '4175:10160',
figmaName: 'Frame 2095586760 (Shiping)',
title: 'Standalone Node: Shiping Step Icon',
route: '/node/frame-4175-10160',
category: 'Standalone Nodes',
width: 48,
height: 40,
refImage: '/assets/images/references/ref-frame-4175-10160.png',
description: 'Standalone 48×40 "Shiping" step icon and label frame.',
scenarios: [
{ label: 'Exact 48×40 Node', route: '/node/frame-4175-10160', description: 'View standalone Shiping step node.' },
],
},
{
id: 'node-group-4175-10166',
figmaNodeId: '4175:10166',
figmaName: 'Group 1597880489 (Order)',
title: 'Standalone Node: Order Step Icon',
route: '/node/group-4175-10166',
category: 'Standalone Nodes',
width: 48,
height: 40,
refImage: '/assets/images/references/ref-group-4175-10166.png',
description: 'Standalone 48×40 "Order" step icon and label group.',
scenarios: [
{ label: 'Exact 48×40 Node', route: '/node/group-4175-10166', description: 'View standalone Order step node.' },
],
},
{
id: 'node-shop-home-text',
figmaNodeId: '4182:13493',
figmaName: 'shop-home (TEXT)',
title: 'Standalone Node: "shop-home" Label',
route: '/node/shop-home-text',
category: 'Standalone Nodes',
width: 62,
height: 18,
description: 'Standalone 62×18 "shop-home" text node (Segoe UI Semibold 12px #000000).',
scenarios: [
{ label: 'Exact 62×18 Text Node', route: '/node/shop-home-text', description: 'View standalone shop-home text node.' },
],
},
];

3
src/hooks/useSmartBack.ts

@ -37,10 +37,7 @@ export function useSmartBack(defaultFallback: string = ROUTES.home) {
if (isRoot) {
if (isInFlutterWebView()) {
closeService();
return;
}
markBackNavigation();
navigate(ROUTES.test);
return;
}

1388
src/lib/cookies.ts
File diff suppressed because it is too large
View File

1
src/lib/routes.ts

@ -31,7 +31,6 @@ export const ROUTES = {
addresses: '/account/addresses',
profile: '/account/profile',
settings: '/account/settings',
test: '/test',
} as const;
export const USE_MOCK_DATA =

32
src/pages/account/LanguageSettingPage.tsx

@ -8,6 +8,7 @@ import { useShopApp } from '../../context/ShopAppContext';
import { useAnimatedPresence } from '../../hooks/use-animated-presence';
import { useHardwareBackHandler } from '../../hooks/use-hardware-back-handler';
import { useSmartBack } from '../../hooks/useSmartBack';
import { isRtlLanguage, tr } from '../../lib/cookies';
import { resolveMediaUrl } from '../../lib/http';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import {
@ -123,6 +124,7 @@ export const LanguageSettingPage: React.FC = () => {
changeLanguage,
showToast,
} = useShopApp();
const isRtl = isRtlLanguage(language);
const [habibCoinsBalance, setHabibCoinsBalance] = useState<number>(() =>
typeof window !== 'undefined' && typeof window.HABIB_COINS === 'number'
@ -278,7 +280,7 @@ export const LanguageSettingPage: React.FC = () => {
type="button"
className="habib-icon-btn"
onClick={() => (bare ? navigate('/shop-account') : smartBack(ROUTES.account))}
aria-label="Back"
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
@ -299,6 +301,7 @@ export const LanguageSettingPage: React.FC = () => {
style={{
width: 18.22,
height: 15.21,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
@ -444,7 +447,7 @@ export const LanguageSettingPage: React.FC = () => {
wordBreak: 'break-word',
}}
>
{pRow.label}
{tr(pRow.label)}
</div>
</div>
@ -479,7 +482,7 @@ export const LanguageSettingPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{pRow.statusText}
{tr(pRow.statusText)}
</span>
</div>
</div>
@ -531,7 +534,7 @@ export const LanguageSettingPage: React.FC = () => {
color: '#ffffff',
}}
>
Donate Habib
{tr('Donate Habib')}
</div>
<div
style={{
@ -542,7 +545,7 @@ export const LanguageSettingPage: React.FC = () => {
color: 'rgba(255, 255, 255, 0.6)',
}}
>
Help Habib&apos;s Large-Scale project
{tr("Help Habib's Large-Scale project")}
</div>
</div>
@ -577,7 +580,7 @@ export const LanguageSettingPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Donate
{tr('Donate')}
</span>
</button>
</div>
@ -618,7 +621,7 @@ export const LanguageSettingPage: React.FC = () => {
color: '#73889d',
}}
>
Your Inventory
{tr('Your Inventory')}
</div>
<div
style={{
@ -629,7 +632,7 @@ export const LanguageSettingPage: React.FC = () => {
color: '#151c31',
}}
>
{bare ? '21 Habib Coins' : `${habibCoinsBalance} Habib Coins`}
{tr(bare ? '21 Habib Coins' : `${habibCoinsBalance} Habib Coins`)}
</div>
</div>
</div>
@ -661,7 +664,7 @@ export const LanguageSettingPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Buy Coins
{tr('Buy Coins')}
</span>
</button>
</div>
@ -714,7 +717,7 @@ export const LanguageSettingPage: React.FC = () => {
color: '#111111',
}}
>
Apply as Provider
{tr('Apply as Provider')}
</div>
</div>
@ -776,7 +779,7 @@ export const LanguageSettingPage: React.FC = () => {
color: '#111111',
}}
>
{useMockFallback ? 'My Wallet ($24)' : 'My Wallet ($0)'}
{tr(useMockFallback ? 'My Wallet ($24)' : 'My Wallet ($0)')}
</div>
<div
style={{
@ -787,7 +790,7 @@ export const LanguageSettingPage: React.FC = () => {
color: '#73889d',
}}
>
income from Habib
{tr('income from Habib')}
</div>
</div>
<img
@ -797,6 +800,7 @@ export const LanguageSettingPage: React.FC = () => {
width: 5,
height: 10,
flexShrink: 0,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</div>
@ -869,13 +873,13 @@ export const LanguageSettingPage: React.FC = () => {
color: '#111111',
}}
>
Select Shop Language
{tr('Select Shop Language')}
</span>
<button
type="button"
className="habib-icon-btn"
onClick={() => setLangSheetOpen(false)}
aria-label="Close"
aria-label={tr('Close')}
style={{
width: 24,
height: 24,

85
src/pages/account/ProviderRequestPage.tsx

@ -1,9 +1,9 @@
import React, { useEffect, useRef, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { MobileShell } from '../../components/layout/MobileShell';
import { InlineSpinner } from '../../components/common/ShimmerSkeletons';
import { useShopApp } from '../../context/ShopAppContext';
import { useSmartBack } from '../../hooks/useSmartBack';
import { isRtlLanguage, tr } from '../../lib/cookies';
import { resolveMediaUrl } from '../../lib/http';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import { useUpdateProfileMutation } from '../../lib/shopQueries';
@ -24,9 +24,10 @@ export const ProviderRequestPage: React.FC = () => {
isUserAuthenticated,
requireAuth,
profile,
isProfileLoading,
language,
showToast,
} = useShopApp();
const isRtl = isRtlLanguage(language);
const updateProfileMutation = useUpdateProfileMutation();
const savingProfile = updateProfileMutation.isPending;
@ -54,25 +55,6 @@ export const ProviderRequestPage: React.FC = () => {
? resolveMediaUrl(profile.avatar_url)
: '';
const avatarImgRef = useRef<HTMLImageElement | null>(null);
const [loadedAvatarUrl, setLoadedAvatarUrl] = useState<string>('');
const [erroredAvatarUrl, setErroredAvatarUrl] = useState<string>('');
useEffect(() => {
if (!avatarUrl) return;
const img = avatarImgRef.current;
if (img && img.complete && img.naturalWidth > 0) {
setLoadedAvatarUrl(avatarUrl);
}
}, [avatarUrl]);
const hasValidAvatarUrl =
Boolean(avatarUrl) && erroredAvatarUrl !== avatarUrl;
const isAvatarImageLoading =
hasValidAvatarUrl && loadedAvatarUrl !== avatarUrl;
const showAvatarSpinner =
!bare && isUserAuthenticated && (isProfileLoading || isAvatarImageLoading);
const headerEmailText = bare
? 'Ahdart14@gmail.com'
: email.trim() ||
@ -148,7 +130,7 @@ export const ProviderRequestPage: React.FC = () => {
onClick={() =>
bare ? navigate('/shop-account') : smartBack(ROUTES.account)
}
aria-label="Back"
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
@ -169,6 +151,7 @@ export const ProviderRequestPage: React.FC = () => {
style={{
width: 18.21,
height: 14.56,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
@ -183,7 +166,7 @@ export const ProviderRequestPage: React.FC = () => {
textAlign: 'center',
}}
>
Accunt detail
{tr('Accunt detail')}
</div>
<div style={{ width: 40, height: 40, flexShrink: 0 }} />
@ -207,7 +190,6 @@ export const ProviderRequestPage: React.FC = () => {
>
<div
style={{
position: 'relative',
width: 84,
height: 84,
borderRadius: 78.5,
@ -218,36 +200,17 @@ export const ProviderRequestPage: React.FC = () => {
overflow: 'hidden',
}}
>
{hasValidAvatarUrl && (
{avatarUrl ? (
<img
ref={avatarImgRef}
src={avatarUrl}
alt={fullName || 'Profile'}
onLoad={() => setLoadedAvatarUrl(avatarUrl)}
onError={() => setErroredAvatarUrl(avatarUrl)}
style={{
width: '100%',
height: '100%',
objectFit: 'cover',
opacity: isAvatarImageLoading ? 0 : 1,
}}
/>
)}
{showAvatarSpinner ? (
<div
role="status"
aria-label="Loading avatar"
style={{
position: 'absolute',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<InlineSpinner size={28} />
</div>
) : !hasValidAvatarUrl ? (
) : (
<img
src="/assets/images/icon-account-avatar-gold.svg"
alt=""
@ -256,7 +219,7 @@ export const ProviderRequestPage: React.FC = () => {
height: 33.04,
}}
/>
) : null}
)}
</div>
<img
@ -276,7 +239,6 @@ export const ProviderRequestPage: React.FC = () => {
<div
style={{
marginTop: 13,
minHeight: 26,
padding: '3px 10px',
borderRadius: 8,
fontFamily: 'Inter, var(--font-sans)',
@ -285,16 +247,9 @@ export const ProviderRequestPage: React.FC = () => {
lineHeight: '20px',
color: '#d78e06',
textAlign: 'center',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
{!bare && isUserAuthenticated && isProfileLoading ? (
<InlineSpinner size={18} gold />
) : (
headerEmailText
)}
{headerEmailText}
</div>
</div>
@ -317,9 +272,9 @@ export const ProviderRequestPage: React.FC = () => {
color: '#151c31',
}}
>
Full Name<span style={{ color: '#d44747' }}>*</span>{' '}
{tr('Full Name')}<span style={{ color: '#d44747' }}>*</span>{' '}
<span style={{ color: '#8b8b8b', fontWeight: 400 }}>
(People will see this)
{tr('(People will see this)')}
</span>
</label>
<input
@ -370,7 +325,7 @@ export const ProviderRequestPage: React.FC = () => {
color: '#111111',
}}
>
Date of Birth<span style={{ color: '#d44747' }}>*</span>
{tr('Date of Birth')}<span style={{ color: '#d44747' }}>*</span>
</label>
<div
onClick={() => {
@ -422,7 +377,7 @@ export const ProviderRequestPage: React.FC = () => {
color: '#36363c',
}}
>
{birthdate || 'Select date'}
{birthdate || tr('Select date')}
</span>
<input
ref={dateInputRef}
@ -432,7 +387,7 @@ export const ProviderRequestPage: React.FC = () => {
onFocus={() => setFocusedField('birthdate')}
onBlur={() => setFocusedField(null)}
onChange={(e) => setBirthdate(e.target.value)}
aria-label="Date of Birth"
aria-label={tr('Date of Birth')}
style={{
position: 'absolute',
inset: 0,
@ -465,7 +420,7 @@ export const ProviderRequestPage: React.FC = () => {
color: '#111111',
}}
>
Whatsapp Number<span style={{ color: '#d44747' }}>*</span>
{tr('Whatsapp Number')}<span style={{ color: '#d44747' }}>*</span>
</label>
<input
id="account-whatsapp"
@ -474,7 +429,7 @@ export const ProviderRequestPage: React.FC = () => {
onFocus={() => setFocusedField('waNumber')}
onBlur={() => setFocusedField(null)}
onChange={(e) => setWaNumber(e.target.value)}
placeholder="Sample: +77 2350654"
placeholder={tr('Sample: +77 2350654')}
style={{
width: '100%',
height: 55,
@ -515,7 +470,7 @@ export const ProviderRequestPage: React.FC = () => {
color: '#111111',
}}
>
Email
{tr('Email')}
</label>
<input
id="account-email"
@ -524,7 +479,7 @@ export const ProviderRequestPage: React.FC = () => {
onFocus={() => setFocusedField('email')}
onBlur={() => setFocusedField(null)}
onChange={(e) => setEmail(e.target.value)}
placeholder="For iOS users"
placeholder={tr('For iOS users')}
style={{
width: '100%',
height: 55,
@ -570,7 +525,7 @@ export const ProviderRequestPage: React.FC = () => {
color: '#fbfbfc',
}}
>
{savingProfile ? 'Saving...' : 'Submit'}
{savingProfile ? tr('Saving...') : tr('Submit')}
</button>
</form>
</MobileShell>

128
src/pages/account/ShopAccountPage.tsx

@ -1,10 +1,9 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import React, { useMemo } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { MobileShell } from '../../components/layout/MobileShell';
import { BottomNavBar } from '../../components/layout/BottomNavBar';
import { OrderCounterCard } from '../../components/account/OrderCounterCard';
import { AccountMenuRow } from '../../components/account/AccountMenuRow';
import { InlineSpinner } from '../../components/common/ShimmerSkeletons';
import {
ACCOUNT_ORDER_COUNTERS,
type AccountMenuRowItem,
@ -12,6 +11,7 @@ import {
} from '../../data/accountData';
import { useShopApp } from '../../context/ShopAppContext';
import { resolveMediaUrl } from '../../lib/http';
import { tr } from '../../lib/cookies';
import { formatPhoneForDisplay } from '../../lib/phone';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
@ -29,7 +29,6 @@ export const ShopAccountPage: React.FC = () => {
openLoginModal,
requireAuth,
profile,
isProfileLoading,
orderCounters,
addresses,
selectedAddress,
@ -164,25 +163,6 @@ export const ShopAccountPage: React.FC = () => {
? resolveMediaUrl(profile.avatar_url)
: '';
const avatarImgRef = useRef<HTMLImageElement | null>(null);
const [loadedAvatarUrl, setLoadedAvatarUrl] = useState<string>('');
const [erroredAvatarUrl, setErroredAvatarUrl] = useState<string>('');
useEffect(() => {
if (!avatarUrl) return;
const img = avatarImgRef.current;
if (img && img.complete && img.naturalWidth > 0) {
setLoadedAvatarUrl(avatarUrl);
}
}, [avatarUrl]);
const hasValidAvatarUrl =
Boolean(avatarUrl) && erroredAvatarUrl !== avatarUrl;
const isAvatarImageLoading =
hasValidAvatarUrl && loadedAvatarUrl !== avatarUrl;
const showAvatarSpinner =
!bare && isUserAuthenticated && (isProfileLoading || isAvatarImageLoading);
const handleProtectedNavigate = (targetRoute: string, featureName: string) => {
if (bare) {
navigate(targetRoute);
@ -217,7 +197,6 @@ export const ShopAccountPage: React.FC = () => {
{/* Avatar Circle (4215:11560) */}
<div
style={{
position: 'relative',
width: 84,
height: 84,
borderRadius: 78.5,
@ -228,36 +207,17 @@ export const ShopAccountPage: React.FC = () => {
overflow: 'hidden',
}}
>
{hasValidAvatarUrl && (
{avatarUrl ? (
<img
ref={avatarImgRef}
src={avatarUrl}
alt={displayName}
onLoad={() => setLoadedAvatarUrl(avatarUrl)}
onError={() => setErroredAvatarUrl(avatarUrl)}
style={{
width: '100%',
height: '100%',
objectFit: 'cover',
opacity: isAvatarImageLoading ? 0 : 1,
}}
/>
)}
{showAvatarSpinner ? (
<div
role="status"
aria-label="Loading avatar"
style={{
position: 'absolute',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<InlineSpinner size={28} />
</div>
) : !hasValidAvatarUrl ? (
) : (
<img
src="/assets/images/icon-account-avatar-gold.svg"
alt={displayName}
@ -266,56 +226,38 @@ export const ShopAccountPage: React.FC = () => {
height: 33.04,
}}
/>
) : null}
)}
</div>
{!bare && isUserAuthenticated && isProfileLoading ? (
<div
role="status"
aria-label="Loading profile"
style={{
marginTop: 9,
minHeight: 42,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<InlineSpinner size={22} gold />
</div>
) : (
<>
{/* User Name "Habib shoper" (4214:366) */}
<div
style={{
marginTop: 9,
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 18,
lineHeight: '26px',
color: '#111111',
textAlign: 'center',
}}
>
{displayName}
</div>
{/* User Name "Habib shoper" (4214:366) */}
<div
style={{
marginTop: 9,
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: 18,
lineHeight: '26px',
color: '#111111',
textAlign: 'center',
}}
>
{tr(displayName)}
</div>
{/* Phone "09102036523" (4214:367) */}
<div
style={{
marginTop: 3,
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#8b8b8b',
textAlign: 'center',
}}
>
{displaySub}
</div>
</>
)}
{/* Phone "09102036523" (4214:367) */}
<div
style={{
marginTop: 3,
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: 10,
lineHeight: '12.9px',
color: '#8b8b8b',
textAlign: 'center',
}}
>
{tr(displaySub)}
</div>
</div>
{/* 3 Order Status Counter Cards (4215:11563) */}
@ -454,7 +396,7 @@ export const ShopAccountPage: React.FC = () => {
color: bare ? '#d44747' : '#d78e06',
}}
>
{bare ? 'Sign out' : 'Log in with Habib'}
{tr(bare ? 'Sign out' : 'Log in with Habib')}
</div>
<div
style={{
@ -465,7 +407,7 @@ export const ShopAccountPage: React.FC = () => {
color: '#8b8b8b',
}}
>
{bare ? 'sign out from account' : 'connect your Habib account'}
{tr(bare ? 'sign out from account' : 'connect your Habib account')}
</div>
</div>
</div>

3
src/pages/account/ShopAddressPage.tsx

@ -9,6 +9,7 @@ import {
import { AddressFormSheet } from '../../components/modals/AddressFormSheet';
import { BUY01_ADDRESSES } from '../../data/checkoutData';
import { useShopApp } from '../../context/ShopAppContext';
import { tr } from '../../lib/cookies';
import { mapAddressToOption } from '../../lib/mappers';
import { isBareMode, ROUTES } from '../../lib/routes';
import type { ApiAddress } from '../../lib/shopApi';
@ -100,7 +101,7 @@ export const ShopAddressPage: React.FC = () => {
color: '#73889d',
}}
>
No saved delivery addresses yet. Tap below to add your first address.
{tr('No saved delivery addresses yet. Tap below to add your first address.')}
</div>
)}
</div>

120
src/pages/catalog/ShopBoothPage.tsx

@ -11,6 +11,7 @@ import {
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';
@ -27,7 +28,8 @@ export const ShopBoothPage: React.FC = () => {
const useMockFallback = isBare || USE_MOCK_DATA;
const { storeId } = useParams<{ storeId?: string }>();
const smartBack = useSmartBack(ROUTES.home);
const { isBookmarked, toggleBookmark, showToast } = useShopApp();
const { isBookmarked, toggleBookmark, showToast, language } = useShopApp();
const isRtl = isRtlLanguage(language);
const resolvedSlug = storeId || 'tashakol-farzandan-rohhallah';
const storeQuery = useStoreDetailQuery(resolvedSlug, !isBare);
@ -112,7 +114,7 @@ export const ShopBoothPage: React.FC = () => {
<button
type="button"
onClick={() => smartBack(ROUTES.home)}
aria-label="Back"
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
@ -132,6 +134,7 @@ export const ShopBoothPage: React.FC = () => {
style={{
width: 18.22,
height: 14.56,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
@ -209,18 +212,19 @@ export const ShopBoothPage: React.FC = () => {
<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',
}}
>
<>
<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={
@ -361,7 +365,7 @@ export const ShopBoothPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveStore?.membership_label || '+1 year membership'}
{tr(liveStore?.membership_label || '+1 year membership')}
</span>
<div
@ -384,7 +388,7 @@ export const ShopBoothPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveStore?.sales_label || '+60 sales'}
{tr(liveStore?.sales_label || '+60 sales')}
</span>
</div>
@ -446,7 +450,7 @@ export const ShopBoothPage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
Avg. Response
{tr('Avg. Response')}
</span>
</div>
@ -503,7 +507,7 @@ export const ShopBoothPage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
On-time Delivery
{tr('On-time Delivery')}
</span>
</div>
@ -560,7 +564,7 @@ export const ShopBoothPage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
Satisfaction
{tr('Satisfaction')}
</span>
</div>
</div>
@ -584,7 +588,7 @@ export const ShopBoothPage: React.FC = () => {
color: '#292a2e',
}}
>
About
{tr('About')}
</div>
<div
style={{
@ -599,7 +603,7 @@ export const ShopBoothPage: React.FC = () => {
{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.')}
: tr('No description available.'))}
</div>
</section>
@ -622,7 +626,7 @@ export const ShopBoothPage: React.FC = () => {
color: '#292a2e',
}}
>
Products
{tr('Products')}
</div>
{liveStore?.products?.length ? (
@ -650,6 +654,78 @@ export const ShopBoothPage: React.FC = () => {
)}
</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>
);

9
src/pages/catalog/ShopCatItemsPage.tsx

@ -11,6 +11,7 @@ import {
} from '../../components/common/ShimmerSkeletons';
import { TWO_COLUMN_GRID_PRODUCTS } from '../../data/catalogData';
import { useShopApp } from '../../context/ShopAppContext';
import { tr } from '../../lib/cookies';
import { mapProductToGridItem } from '../../lib/mappers';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import {
@ -170,9 +171,11 @@ export const ShopCatItemsPage: React.FC<ShopCatItemsPageProps> = ({
fontWeight: 600,
}}
>
{mode === 'bookmarks'
? 'No saved items yet. Tap the bookmark icon on any product to save it here.'
: 'No matching products found.'}
{tr(
mode === 'bookmarks'
? 'No saved items yet. Tap the bookmark icon on any product to save it here.'
: 'No matching products found.'
)}
</div>
)
) : (

3
src/pages/catalog/ShopCategoryPage.tsx

@ -9,6 +9,7 @@ import {
RetryBanner,
} from '../../components/common/ShimmerSkeletons';
import { CATEGORY_GRID_TILES } from '../../data/catalogData';
import { useShopApp } from '../../context/ShopAppContext';
import { mapCategoryToTile } from '../../lib/mappers';
import { isBareMode, USE_MOCK_DATA } from '../../lib/routes';
import { useCategoriesQuery } from '../../lib/shopQueries';
@ -18,6 +19,8 @@ import { useCategoriesQuery } from '../../lib/shopQueries';
*/
export const ShopCategoryPage: React.FC = () => {
const location = useLocation();
const { language } = useShopApp();
void language;
const isBare = isBareMode(location.search);
const useMockFallback = isBare || USE_MOCK_DATA;
const [searchQuery, setSearchQuery] = useState('');

83
src/pages/catalog/ShopSinglePage.tsx

@ -12,6 +12,7 @@ import {
import { HOME_POPULAR_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 { mapProductToCompactItem } from '../../lib/mappers';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
@ -65,8 +66,10 @@ export const ShopSinglePage: React.FC = () => {
isCartBusy,
isBookmarked,
toggleBookmark,
language,
showToast,
} = useShopApp();
const isRtl = isRtlLanguage(language);
const [activeTab, setActiveTab] = useState<'info' | 'review'>('info');
const [reviewRating, setReviewRating] = useState(5);
@ -209,7 +212,7 @@ export const ShopSinglePage: React.FC = () => {
type="button"
className="habib-icon-btn"
onClick={() => smartBack(ROUTES.home)}
aria-label="Back"
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
@ -229,6 +232,7 @@ export const ShopSinglePage: React.FC = () => {
style={{
width: 18.22,
height: 14.56,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
@ -372,8 +376,10 @@ export const ShopSinglePage: React.FC = () => {
cursor: liveProduct?.category_slug ? 'pointer' : undefined,
}}
>
{liveProduct?.breadcrumb ||
'Leather accessories and supplies / Leather bags'}
{tr(
liveProduct?.breadcrumb ||
'Leather accessories and supplies / Leather bags'
)}
</div>
<div
@ -522,11 +528,13 @@ export const ShopSinglePage: React.FC = () => {
color: '#747474',
}}
>
{isBare
? '0 Reviews'
: `${displayReviews.length} ${
displayReviews.length === 1 ? 'Review' : 'Reviews'
}`}
{tr(
isBare
? '0 Reviews'
: `${displayReviews.length} ${
displayReviews.length === 1 ? 'Review' : 'Reviews'
}`
)}
</span>
</div>
</div>
@ -559,7 +567,7 @@ export const ShopSinglePage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
Product Condition
{tr('Product Condition')}
</div>
<div
style={{
@ -587,7 +595,10 @@ export const ShopSinglePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveProduct?.condition_label || (inStock ? 'In Stock' : 'Out of Stock')}
{tr(
liveProduct?.condition_label ||
(inStock ? 'In Stock' : 'Out of Stock')
)}
</span>
</div>
</div>
@ -618,7 +629,7 @@ export const ShopSinglePage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
Processing Time
{tr('Processing Time')}
</div>
<div
style={{
@ -630,7 +641,7 @@ export const ShopSinglePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveProduct?.processing_time_label || '2–3 Days'}
{tr(liveProduct?.processing_time_label || '2–3 Days')}
</div>
</div>
@ -660,7 +671,7 @@ export const ShopSinglePage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
Product Type
{tr('Product Type')}
</div>
<div
style={{
@ -672,7 +683,7 @@ export const ShopSinglePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveProduct?.product_type_label || 'Bag'}
{tr(liveProduct?.product_type_label || 'Bag')}
</div>
</div>
</div>
@ -719,7 +730,7 @@ export const ShopSinglePage: React.FC = () => {
>
{storeDetail?.name ||
liveProduct?.store_name ||
(useMockFallback ? 'Al-Hujjah Books' : 'Store')}
(useMockFallback ? 'Al-Hujjah Books' : tr('Store'))}
</span>
<img
src="/assets/images/icon-caret-right-gold.svg"
@ -728,6 +739,7 @@ export const ShopSinglePage: React.FC = () => {
width: 14,
height: 14,
flexShrink: 0,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</div>
@ -799,7 +811,7 @@ export const ShopSinglePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
({storeDetail?.since_label || 'Since 2008'})
({tr(storeDetail?.since_label || 'Since 2008')})
</div>
)}
</div>
@ -808,7 +820,7 @@ export const ShopSinglePage: React.FC = () => {
{/* Tabs: "Information" & "Review(N)" */}
<div
role="tablist"
aria-label="Product details tabs"
aria-label={tr('Product details tabs')}
style={{
position: 'relative',
display: 'grid',
@ -833,7 +845,7 @@ export const ShopSinglePage: React.FC = () => {
transition: 'color 200ms cubic-bezier(0.22, 1, 0.36, 1)',
}}
>
Information
{tr('Information')}
</button>
<button
type="button"
@ -852,14 +864,20 @@ export const ShopSinglePage: React.FC = () => {
transition: 'color 200ms cubic-bezier(0.22, 1, 0.36, 1)',
}}
>
Review({displayReviews.length})
{tr(`Review(${displayReviews.length})`)}
</button>
{/* Active Tab Indicator Bar */}
<div
style={{
position: 'absolute',
left: activeTab === 'info' ? '0%' : '50%',
left: isRtl
? activeTab === 'info'
? '50%'
: '0%'
: activeTab === 'info'
? '0%'
: '50%',
bottom: 0,
width: '50%',
height: 3,
@ -900,7 +918,7 @@ export const ShopSinglePage: React.FC = () => {
color: '#3d3d3d',
}}
>
Category
{tr('Category')}
</div>
<div
style={{
@ -911,7 +929,7 @@ export const ShopSinglePage: React.FC = () => {
color: '#747474',
}}
>
{liveProduct?.category_title || 'Art & Handicrafts'}
{tr(liveProduct?.category_title || 'Art & Handicrafts')}
</div>
</div>
@ -926,7 +944,7 @@ export const ShopSinglePage: React.FC = () => {
color: '#3d3d3d',
}}
>
Introduction
{tr('Introduction')}
</div>
<div
style={{
@ -941,7 +959,7 @@ export const ShopSinglePage: React.FC = () => {
{liveProduct?.description ||
(useMockFallback
? 'Mollit non deserunt ullamco est sit aliqua dolor do amet sint. Velit officia consequat duis enim velit mollit. Exercitation veniam consequat sunt.\nVelit officia consequat duis enim velit mollit. Amet minim mollit non deserunt ullamco est sit aliqua dolor do amet sint. Velit officia consequat duis enim velit mollit. Exercitation veniam consequat sunt nostrud amet.'
: 'No description available.')}
: tr('No description available.'))}
</div>
</div>
</div>
@ -949,7 +967,7 @@ export const ShopSinglePage: React.FC = () => {
<div
key="review"
role="tabpanel"
aria-label="Customer reviews"
aria-label={tr('Customer reviews')}
className="habib-tab-panel"
style={{ display: 'flex', flexDirection: 'column', gap: 12 }}
>
@ -970,7 +988,7 @@ export const ShopSinglePage: React.FC = () => {
color: '#3d3d3d',
}}
>
Customer Reviews ({displayReviews.length})
{tr(`Customer Reviews (${displayReviews.length})`)}
</span>
<div style={{ display: 'inline-flex', alignItems: 'center', gap: 4 }}>
<img
@ -1036,7 +1054,7 @@ export const ShopSinglePage: React.FC = () => {
color: '#111111',
}}
>
Write a Review
{tr('Write a Review')}
</span>
<div style={{ display: 'inline-flex', gap: 4 }}>
{[1, 2, 3, 4, 5].map((star) => (
@ -1067,7 +1085,7 @@ export const ShopSinglePage: React.FC = () => {
rows={2}
value={reviewComment}
onChange={(e) => setReviewComment(e.target.value)}
placeholder="Share your experience with this product..."
placeholder={tr('Share your experience with this product...')}
style={{
width: '100%',
borderRadius: 10,
@ -1094,7 +1112,7 @@ export const ShopSinglePage: React.FC = () => {
opacity: submittingReview || !reviewComment.trim() ? 0.6 : 1,
}}
>
{submittingReview ? 'Posting...' : 'Post Review'}
{submittingReview ? tr('Posting...') : tr('Post Review')}
</button>
</form>
)}
@ -1230,7 +1248,7 @@ export const ShopSinglePage: React.FC = () => {
color: '#36363c',
}}
>
Populars
{tr('Populars')}
</div>
<div
onClick={() => navigate(ROUTES.search())}
@ -1251,7 +1269,7 @@ export const ShopSinglePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
See more
{tr('See more')}
</span>
<img
src="/assets/images/icon-arrow-right-circle-grey.svg"
@ -1259,6 +1277,7 @@ export const ShopSinglePage: React.FC = () => {
style={{
width: 13,
height: 13,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</div>
@ -1415,7 +1434,7 @@ export const ShopSinglePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{isCartBusy ? 'Adding...' : inStock ? 'Add to Cart' : 'Sold Out'}
{isCartBusy ? tr('Adding...') : inStock ? tr('Add to Cart') : tr('Sold Out')}
</span>
</button>
</div>

48
src/pages/chat/ShopChatPage.tsx

@ -9,6 +9,7 @@ import {
import { useShopApp } from '../../context/ShopAppContext';
import { useHardwareBackHandler } from '../../hooks/use-hardware-back-handler';
import { useSmartBack } from '../../hooks/useSmartBack';
import { isRtlLanguage, tr } from '../../lib/cookies';
import { resolveMediaUrl } from '../../lib/http';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import {
@ -235,7 +236,8 @@ export const ShopChatPage: React.FC = () => {
const { conversationId } = useParams<{ conversationId?: string }>();
const resolvedConvRef = conversationId || 'al-hujjah-books';
const smartBack = useSmartBack(ROUTES.store(resolvedConvRef));
const { showToast } = useShopApp();
const { showToast, language } = useShopApp();
const isRtl = isRtlLanguage(language);
const [menuOpen, setMenuOpen] = useState(false);
const [messageText, setMessageText] = useState('');
@ -661,7 +663,7 @@ export const ShopChatPage: React.FC = () => {
type="button"
className="habib-icon-btn"
onClick={() => smartBack(ROUTES.store(storeSlug))}
aria-label="Back"
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
@ -682,6 +684,7 @@ export const ShopChatPage: React.FC = () => {
style={{
width: 18.22,
height: 15.21,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
@ -726,7 +729,7 @@ export const ShopChatPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{storeLocation}
{tr(storeLocation)}
</div>
</div>
@ -735,7 +738,7 @@ export const ShopChatPage: React.FC = () => {
type="button"
className="habib-icon-btn"
onClick={() => setMenuOpen((prev) => !prev)}
aria-label="More options"
aria-label={tr('More options')}
style={{
width: 40,
height: 40,
@ -766,11 +769,18 @@ export const ShopChatPage: React.FC = () => {
className="habib-dropdown-menu"
style={{
position: 'absolute',
right: 'var(--page-px)',
...(isRtl
? {
left: 'var(--page-px)',
borderRadius: '0px 15px 15px 15px',
}
: {
right: 'var(--page-px)',
borderRadius: '15px 0px 15px 15px',
}),
top: 'calc(69px + var(--safe-top, 0px))',
width: 132,
padding: 12,
borderRadius: '15px 0px 15px 15px',
background: 'linear-gradient(180deg, #ffffff 0%, #f4f7f5 100%)',
border: '1px solid rgba(255, 255, 255, 0.3)',
boxShadow: '0px 4px 11px rgba(30, 30, 30, 0.19)',
@ -812,7 +822,7 @@ export const ShopChatPage: React.FC = () => {
color: '#151c31',
}}
>
Report
{tr('Report')}
</span>
</div>
@ -847,7 +857,7 @@ export const ShopChatPage: React.FC = () => {
color: '#151c31',
}}
>
Support
{tr('Support')}
</span>
</div>
@ -896,7 +906,7 @@ export const ShopChatPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Guidelines
{tr('Guidelines')}
</span>
</div>
</div>
@ -944,7 +954,7 @@ export const ShopChatPage: React.FC = () => {
textAlign: 'center',
}}
>
{msg.date_group}
{tr(msg.date_group)}
</div>
)}
@ -1129,7 +1139,7 @@ export const ShopChatPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Try Again
{tr('Try Again')}
</div>
</div>
@ -1221,7 +1231,7 @@ export const ShopChatPage: React.FC = () => {
textAlign: 'center',
}}
>
Yesterday
{tr('Yesterday')}
</div>
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 9 }}>
@ -1372,7 +1382,7 @@ export const ShopChatPage: React.FC = () => {
textAlign: 'center',
}}
>
{'Today '}
{tr('Today ')}
</div>
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 9 }}>
@ -1646,7 +1656,7 @@ export const ShopChatPage: React.FC = () => {
textOverflow: 'ellipsis',
}}
>
{stagedAttachment.label}
{tr(stagedAttachment.label)}
</span>
<span
style={{
@ -1655,7 +1665,7 @@ export const ShopChatPage: React.FC = () => {
color: '#64748b',
}}
>
Ready to send
{tr('Ready to send')}
</span>
</div>
</>
@ -1717,7 +1727,7 @@ export const ShopChatPage: React.FC = () => {
flexShrink: 0,
}}
>
Cancel
{tr('Cancel')}
</button>
<div
@ -1747,7 +1757,7 @@ export const ShopChatPage: React.FC = () => {
color: '#111111',
}}
>
Recording {formatDurationMmSs(recordingSeconds)}
{tr(`Recording ${formatDurationMmSs(recordingSeconds)}`)}
</span>
</div>
@ -1769,7 +1779,7 @@ export const ShopChatPage: React.FC = () => {
flexShrink: 0,
}}
>
Done
{tr('Done')}
</button>
<img
@ -1838,7 +1848,7 @@ export const ShopChatPage: React.FC = () => {
void handleSendText();
}
}}
placeholder="Messages"
placeholder={tr('Messages')}
style={{
flex: 1,
minWidth: 0,

19
src/pages/checkout/ShopBuy01Page.tsx

@ -9,6 +9,7 @@ import { AddressFormSheet } from '../../components/modals/AddressFormSheet';
import { useShopApp } from '../../context/ShopAppContext';
import { BUY01_ADDRESSES } from '../../data/checkoutData';
import { mapAddressToOption } from '../../lib/mappers';
import { tr } from '../../lib/cookies';
import { isValidPhoneString } from '../../lib/phone';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import type { ApiAddress } from '../../lib/shopApi';
@ -132,7 +133,7 @@ export const ShopBuy01Page: React.FC = () => {
color: '#111111',
}}
>
Delivery Address
{tr('Delivery Address')}
</span>
</div>
@ -197,7 +198,7 @@ export const ShopBuy01Page: React.FC = () => {
color: '#111111',
}}
>
Delivery method
{tr('Delivery method')}
</span>
</div>
@ -278,7 +279,7 @@ export const ShopBuy01Page: React.FC = () => {
color: '#36363c',
}}
>
{method.title}
{tr(method.title)}
</div>
<div
style={{
@ -289,8 +290,10 @@ export const ShopBuy01Page: React.FC = () => {
color: '#747474',
}}
>
{method.subtitle ||
`${method.estimated_days_min}-${method.estimated_days_max} business days`}
{tr(
method.subtitle ||
`${method.estimated_days_min}-${method.estimated_days_max} business days`
)}
</div>
</div>
@ -375,7 +378,7 @@ export const ShopBuy01Page: React.FC = () => {
color: '#36363c',
}}
>
Standard shiping
{tr('Standard shiping')}
</div>
<div
style={{
@ -386,7 +389,7 @@ export const ShopBuy01Page: React.FC = () => {
color: '#747474',
}}
>
2-3 business day
{tr('2-3 business day')}
</div>
</div>
@ -434,7 +437,7 @@ export const ShopBuy01Page: React.FC = () => {
textAlign: 'center',
}}
>
Your information is encrypted during transmission.
{tr('Your information is encrypted during transmission.')}
</span>
</div>
</div>

15
src/pages/checkout/ShopCartPage.tsx

@ -10,6 +10,7 @@ import { OrderSummarySheet } from '../../components/modals/OrderSummarySheet';
import { useShopApp } from '../../context/ShopAppContext';
import { CART_ITEMS_MAIN, type CartItemData } from '../../data/checkoutData';
import { mapCartItemToCard } from '../../lib/mappers';
import { tr } from '../../lib/cookies';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
interface InteractiveCartItem extends CartItemData {
@ -190,7 +191,7 @@ export const ShopCartPage: React.FC = () => {
color: '#292a2e',
}}
>
<span>{topInfoText}</span>
<span>{tr(topInfoText)}</span>
{!isBare && isCartBusy && <InlineSpinner size={12} gold />}
</div>
@ -202,7 +203,7 @@ export const ShopCartPage: React.FC = () => {
}
}}
role="button"
aria-label={hasAnyItems ? 'Clear all' : 'Add sample item'}
aria-label={tr(hasAnyItems ? 'Clear all' : 'Add sample item')}
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
@ -215,7 +216,7 @@ export const ShopCartPage: React.FC = () => {
userSelect: 'none',
}}
>
{hasAnyItems ? 'Clear all' : isBare ? 'Restore' : '+ Add Sample'}
{tr(hasAnyItems ? 'Clear all' : isBare ? 'Restore' : '+ Add Sample')}
</div>
)}
</div>
@ -320,7 +321,7 @@ export const ShopCartPage: React.FC = () => {
color: '#111111',
}}
>
Your cart is empty
{tr('Your cart is empty')}
</div>
<div
style={{
@ -331,7 +332,7 @@ export const ShopCartPage: React.FC = () => {
color: '#747474',
}}
>
Browse verified Muslim booths and add products to start your order.
{tr('Browse verified Muslim booths and add products to start your order.')}
</div>
<div
style={{
@ -357,7 +358,7 @@ export const ShopCartPage: React.FC = () => {
cursor: 'pointer',
}}
>
Browse Shop
{tr('Browse Shop')}
</button>
<button
type="button"
@ -374,7 +375,7 @@ export const ShopCartPage: React.FC = () => {
cursor: 'pointer',
}}
>
Explore Categories
{tr('Explore Categories')}
</button>
</div>
</div>

14
src/pages/checkout/ShopOrderSummaryPage.tsx

@ -5,13 +5,17 @@ import { BottomNavBar } from '../../components/layout/BottomNavBar';
import { StickyFooterBar } from '../../components/layout/StickyFooterBar';
import { OrderSummaryBgItemCard } from '../../components/checkout/CartItemCard';
import { OrderSummaryRows } from '../../components/checkout/OrderSummaryRows';
import { useShopApp } from '../../context/ShopAppContext';
import { ORDER_SUMMARY_BG_ITEMS } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
/**
* Node 4154:20497 — `shop-order summery` (Order Summary Bottom Sheet Modal over Cart, 375×814)
*/
export const ShopOrderSummaryPage: React.FC = () => {
const navigate = useNavigate();
const { language } = useShopApp();
void language;
return (
<MobileShell width={375} height={814} backgroundColor="#f5f5f5">
@ -35,7 +39,7 @@ export const ShopOrderSummaryPage: React.FC = () => {
textAlign: 'center',
}}
>
Cart
{tr('Cart')}
</div>
<div
style={{
@ -47,7 +51,7 @@ export const ShopOrderSummaryPage: React.FC = () => {
textAlign: 'center',
}}
>
3 Products from 2 Shops
{tr('3 Products from 2 Shops')}
</div>
<div
@ -121,13 +125,13 @@ export const ShopOrderSummaryPage: React.FC = () => {
color: '#111111',
}}
>
Orded Summery
{tr('Orded Summery')}
</div>
<button
type="button"
onClick={() => navigate('/shop-cart')}
aria-label="Close"
aria-label={tr('Close')}
style={{
width: 24,
height: 24,
@ -181,7 +185,7 @@ export const ShopOrderSummaryPage: React.FC = () => {
color: '#fbfbfc',
}}
>
Got it
{tr('Got it')}
</span>
</button>
</div>

24
src/pages/checkout/ShopPayResultPage.tsx

@ -3,6 +3,8 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom';
import { MobileShell } from '../../components/layout/MobileShell';
import { StandardPageHeader } from '../../components/layout/TopHeader';
import { EmptyStateBox, ShimmerBox } from '../../components/common/ShimmerSkeletons';
import { useShopApp } from '../../context/ShopAppContext';
import { tr } from '../../lib/cookies';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import { useOrderReceiptQuery } from '../../lib/shopQueries';
@ -12,6 +14,8 @@ import { useOrderReceiptQuery } from '../../lib/shopQueries';
export const ShopPayResultPage: React.FC = () => {
const navigate = useNavigate();
const location = useLocation();
const { language } = useShopApp();
void language;
const isBare = isBareMode(location.search);
const useMockFallback = isBare || USE_MOCK_DATA;
const { orderId } = useParams<{ orderId?: string }>();
@ -70,7 +74,7 @@ export const ShopPayResultPage: React.FC = () => {
>
<img
src="/assets/images/illustration-payment-success-basket.png"
alt="Payment Successful"
alt={tr('Payment Successful')}
style={{
width: 93.26,
height: 93.26,
@ -87,7 +91,7 @@ export const ShopPayResultPage: React.FC = () => {
color: '#0eb13c',
}}
>
Payment Successful
{tr('Payment Successful')}
</div>
<div
@ -102,7 +106,7 @@ export const ShopPayResultPage: React.FC = () => {
textAlign: 'center',
}}
>
Thank you for your purchase. your order has been places and is now being processed
{tr('Thank you for your purchase. your order has been places and is now being processed')}
</div>
</div>
@ -160,7 +164,7 @@ export const ShopPayResultPage: React.FC = () => {
color: '#292a2e',
}}
>
Total Paid
{tr('Total Paid')}
</span>
</div>
@ -220,7 +224,7 @@ export const ShopPayResultPage: React.FC = () => {
color: '#747474',
}}
>
Order Code
{tr('Order Code')}
</span>
</div>
@ -280,7 +284,7 @@ export const ShopPayResultPage: React.FC = () => {
color: '#747474',
}}
>
Payment method
{tr('Payment method')}
</span>
</div>
@ -296,7 +300,7 @@ export const ShopPayResultPage: React.FC = () => {
color: '#292a2e',
}}
>
{!isBare && receipt ? receipt.paymentMethodLabel : 'PayPal'}
{tr(!isBare && receipt ? receipt.paymentMethodLabel : 'PayPal')}
</span>
)}
</div>
@ -330,7 +334,7 @@ export const ShopPayResultPage: React.FC = () => {
color: '#747474',
}}
>
Order Date
{tr('Order Date')}
</span>
</div>
@ -392,7 +396,7 @@ export const ShopPayResultPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
track Order
{tr('track Order')}
</span>
</button>
</div>
@ -437,7 +441,7 @@ export const ShopPayResultPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Continue Shoping
{tr('Continue Shoping')}
</span>
</button>
</div>

16
src/pages/checkout/ShopPaymentMethodsPage.tsx

@ -9,12 +9,16 @@ import {
ORDER_SUMMARY_BG_ITEMS,
PAYMENT_METHODS_LIST,
} from '../../data/checkoutData';
import { useShopApp } from '../../context/ShopAppContext';
import { isRtlLanguage, tr } from '../../lib/cookies';
/**
* Node 4171:1394 — `shop-payment` (Payment Methods Bottom Sheet Modal, 375×814)
*/
export const ShopPaymentMethodsPage: React.FC = () => {
const navigate = useNavigate();
const { language } = useShopApp();
const isRtl = isRtlLanguage(language);
const [selectedMethodId, setSelectedMethodId] = useState('pm-google');
return (
@ -39,7 +43,7 @@ export const ShopPaymentMethodsPage: React.FC = () => {
textAlign: 'center',
}}
>
Cart
{tr('Cart')}
</div>
<div
style={{
@ -51,7 +55,7 @@ export const ShopPaymentMethodsPage: React.FC = () => {
textAlign: 'center',
}}
>
3 Products from 2 Shops
{tr('3 Products from 2 Shops')}
</div>
<div
@ -125,13 +129,13 @@ export const ShopPaymentMethodsPage: React.FC = () => {
color: '#111111',
}}
>
Payment methos
{tr('Payment methos')}
</div>
<button
type="button"
onClick={() => navigate('/shop-payment')}
aria-label="Close"
aria-label={tr('Close')}
style={{
width: 24,
height: 24,
@ -219,7 +223,7 @@ export const ShopPaymentMethodsPage: React.FC = () => {
color: '#fbfbfc',
}}
>
Purchase
{tr('Purchase')}
</span>
</div>
@ -227,7 +231,7 @@ export const ShopPaymentMethodsPage: React.FC = () => {
<div
style={{
position: 'absolute',
right: 14,
...(isRtl ? { left: 14 } : { right: 14 }),
top: '50%',
transform: 'translateY(-50%)',
minWidth: 56,

9
src/pages/checkout/ShopPaymentPage.tsx

@ -17,6 +17,7 @@ import {
type PaymentMethodItem,
} from '../../data/checkoutData';
import { resolveMediaUrl } from '../../lib/http';
import { tr } from '../../lib/cookies';
import { mapCartItemToReview } from '../../lib/mappers';
import { formatPhoneForDisplay, isValidPhoneString } from '../../lib/phone';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
@ -202,7 +203,7 @@ export const ShopPaymentPage: React.FC = () => {
color: '#111111',
}}
>
Review items
{tr('Review items')}
</span>
</div>
@ -253,7 +254,7 @@ export const ShopPaymentPage: React.FC = () => {
color: '#111111',
}}
>
Delivery Address
{tr('Delivery Address')}
</span>
</div>
@ -268,7 +269,7 @@ export const ShopPaymentPage: React.FC = () => {
cursor: 'pointer',
}}
>
Edit
{tr('Edit')}
</span>
)}
</div>
@ -366,7 +367,7 @@ export const ShopPaymentPage: React.FC = () => {
color: '#111111',
}}
>
Orded Summery
{tr('Orded Summery')}
</span>
</div>

35
src/pages/home/ShopHomePage.tsx

@ -15,6 +15,7 @@ import {
} 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 { mapProductToCompactItem } from '../../lib/mappers';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
@ -65,8 +66,9 @@ export const ShopHomePage: React.FC = () => {
const location = useLocation();
const isBare = isBareMode(location.search);
const useMockFallback = isBare || USE_MOCK_DATA;
const smartBack = useSmartBack(ROUTES.test);
const { isBookmarked, toggleBookmark } = useShopApp();
const smartBack = useSmartBack(ROUTES.home);
const { isBookmarked, toggleBookmark, language } = useShopApp();
const isRtl = isRtlLanguage(language);
const homeQuery = useHomeFeedQuery(!isBare);
const feed = homeQuery.data ?? null;
@ -373,7 +375,7 @@ export const ShopHomePage: React.FC = () => {
<button
type="button"
onClick={() => smartBack()}
aria-label="Back"
aria-label={tr('Back')}
style={{
width: 40,
height: 40,
@ -394,6 +396,7 @@ export const ShopHomePage: React.FC = () => {
style={{
width: 18.22,
height: 15.18,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</button>
@ -408,13 +411,13 @@ export const ShopHomePage: React.FC = () => {
textAlign: 'center',
}}
>
Shop
{tr('Shop')}
</div>
<button
type="button"
onClick={() => navigate(ROUTES.orders())}
aria-label="Notifications"
aria-label={tr('Notifications')}
style={{
width: 40,
height: 40,
@ -492,6 +495,7 @@ export const ShopHomePage: React.FC = () => {
}
}}
style={{
direction: 'ltr',
display: 'flex',
width: '100%',
height: '100%',
@ -509,6 +513,7 @@ export const ShopHomePage: React.FC = () => {
<div
key={slide.id}
style={{
direction: isRtl ? 'rtl' : 'ltr',
position: 'relative',
flex: '0 0 100%',
width: '100%',
@ -555,7 +560,7 @@ export const ShopHomePage: React.FC = () => {
color: '#caaf7f',
}}
>
{slide.tag}
{tr(slide.tag)}
</div>
<div
@ -570,7 +575,7 @@ export const ShopHomePage: React.FC = () => {
WebkitTextFillColor: 'transparent',
}}
>
{slide.title}
{tr(slide.title)}
</div>
<div
@ -583,7 +588,7 @@ export const ShopHomePage: React.FC = () => {
color: '#afcdb6',
}}
>
{slide.subtitle}
{tr(slide.subtitle)}
</div>
</div>
@ -614,7 +619,7 @@ export const ShopHomePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{slide.ctaLabel}
{tr(slide.ctaLabel)}
</span>
</button>
</div>
@ -714,7 +719,7 @@ export const ShopHomePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{cat.label}
{tr(cat.label)}
</div>
</div>
))}
@ -740,7 +745,7 @@ export const ShopHomePage: React.FC = () => {
color: '#36363c',
}}
>
Populars
{tr('Populars')}
</div>
<div
onClick={() => navigate(ROUTES.search())}
@ -761,7 +766,7 @@ export const ShopHomePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
See more
{tr('See more')}
</span>
<img
src="/assets/images/icon-arrow-right-circle-grey.svg"
@ -769,6 +774,7 @@ export const ShopHomePage: React.FC = () => {
style={{
width: 13,
height: 13,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</div>
@ -825,7 +831,7 @@ export const ShopHomePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
New Stores
{tr('New Stores')}
</div>
<div
onClick={() => navigate(featuredStoreRoute)}
@ -846,7 +852,7 @@ export const ShopHomePage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
See more
{tr('See more')}
</span>
<img
src="/assets/images/icon-arrow-right-circle-grey.svg"
@ -854,6 +860,7 @@ export const ShopHomePage: React.FC = () => {
style={{
width: 13,
height: 13,
transform: isRtl ? 'scaleX(-1)' : undefined,
}}
/>
</div>

27
src/pages/orders/ShopOrderDetailPage.tsx

@ -13,6 +13,7 @@ import { ShipmentTrackingSheet } from '../../components/modals/ShipmentTrackingS
import { useShopApp } from '../../context/ShopAppContext';
import { ORDER_DETAIL_SHIPMENTS } from '../../data/ordersData';
import { mapShipmentToCardData } from '../../lib/mappers';
import { tr } from '../../lib/cookies';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import type { ApiShipment } from '../../lib/shopApi';
import {
@ -237,7 +238,7 @@ export const ShopOrderDetailPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveOrder ? `${liveOrder.items_count} item` : '3 item'}
{tr(liveOrder ? `${liveOrder.items_count} item` : '3 item')}
</span>
</div>
@ -271,7 +272,7 @@ export const ShopOrderDetailPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveOrder ? `${liveOrder.shops_count} shop` : '1 shop'}
{tr(liveOrder ? `${liveOrder.shops_count} shop` : '1 shop')}
</span>
</div>
</div>
@ -316,14 +317,16 @@ export const ShopOrderDetailPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{liveOrder
? liveOrder.status === 'canceled'
? 'Canceled'
: `${liveOrder.delivered_shipments_count} / ${Math.max(
1,
liveOrder.total_shipments_count
)} Delivery`
: '1 / 3 Delivery'}
{tr(
liveOrder
? liveOrder.status === 'canceled'
? 'Canceled'
: `${liveOrder.delivered_shipments_count} / ${Math.max(
1,
liveOrder.total_shipments_count
)} Delivery`
: '1 / 3 Delivery'
)}
</span>
</div>
</div>
@ -394,7 +397,7 @@ export const ShopOrderDetailPage: React.FC = () => {
}}
>
{canceling && <InlineSpinner size={14} gold />}
{canceling ? 'Canceling...' : 'Cancel Order'}
{canceling ? tr('Canceling...') : tr('Cancel Order')}
</button>
)}
@ -446,7 +449,7 @@ export const ShopOrderDetailPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Order support
{tr('Order support')}
</span>
</button>
</div>

5
src/pages/orders/ShopOrdersPage.tsx

@ -16,6 +16,7 @@ import {
type OrderFilterTabItem,
} from '../../data/ordersData';
import { mapOrderToCardData } from '../../lib/mappers';
import { tr } from '../../lib/cookies';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import { useOrdersQuery } from '../../lib/shopQueries';
@ -143,7 +144,7 @@ export const ShopOrdersPage: React.FC = () => {
color: '#111111',
}}
>
{`No ${activeTabId} orders`}
{tr(`No ${activeTabId} orders`)}
</span>
<button
type="button"
@ -161,7 +162,7 @@ export const ShopOrdersPage: React.FC = () => {
cursor: 'pointer',
}}
>
Browse Shop
{tr('Browse Shop')}
</button>
</div>
)

37
src/pages/orders/ShopSupportPage.tsx

@ -6,6 +6,7 @@ import { EmptyStateBox } from '../../components/common/ShimmerSkeletons';
import { useShopApp } from '../../context/ShopAppContext';
import { SUPPORT_SUBJECT_OPTIONS } from '../../data/ordersData';
import { resolveMediaUrl } from '../../lib/http';
import { tr } from '../../lib/cookies';
import { isBareMode, ROUTES, USE_MOCK_DATA } from '../../lib/routes';
import {
useCreateSupportTicketMutation,
@ -235,11 +236,13 @@ export const ShopSupportPage: React.FC = () => {
}}
>
{firstItem?.title_snapshot ||
(orderId
? `Order ${orderId}`
: isBare
? 'Islam in the Bible Book'
: 'Habib Shop Support Desk')}
tr(
orderId
? `Order ${orderId}`
: isBare
? 'Islam in the Bible Book'
: 'Habib Shop Support Desk'
)}
</div>
<div
@ -337,7 +340,7 @@ export const ShopSupportPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
Order support
{tr('Order support')}
</span>
</div>
@ -351,7 +354,9 @@ export const ShopSupportPage: React.FC = () => {
textAlign: 'center',
}}
>
We’ve received your support request and will follow up on it. Rest assured, our team will take care of it.
{tr(
'We’ve received your support request and will follow up on it. Rest assured, our team will take care of it.'
)}
</div>
</div>
@ -372,7 +377,7 @@ export const ShopSupportPage: React.FC = () => {
color: '#111111',
}}
>
Request Subject<span style={{ color: '#ff383c' }}>*</span>
{tr('Request Subject')}<span style={{ color: '#ff383c' }}>*</span>
</div>
{/* 6 Subject Tiles Grid */}
@ -406,7 +411,7 @@ export const ShopSupportPage: React.FC = () => {
>
<img
src={option.iconSrc}
alt={option.label}
alt={tr(option.label)}
style={{
width: 28,
height: 28,
@ -423,7 +428,7 @@ export const ShopSupportPage: React.FC = () => {
textAlign: 'center',
}}
>
{option.label}
{tr(option.label)}
</span>
</button>
);
@ -452,7 +457,7 @@ export const ShopSupportPage: React.FC = () => {
color: '#111111',
}}
>
Description<span style={{ color: '#ff383c' }}>*</span>
{tr('Description')}<span style={{ color: '#ff383c' }}>*</span>
</label>
<textarea
@ -460,7 +465,7 @@ export const ShopSupportPage: React.FC = () => {
className="habib-textarea"
value={description}
onChange={(e) => setDescription(e.target.value)}
placeholder="Write here..."
placeholder={tr('Write here...')}
style={{
width: '100%',
height: 148,
@ -496,7 +501,7 @@ export const ShopSupportPage: React.FC = () => {
color: '#111111',
}}
>
Add Evidence or Image(Optional)
{tr('Add Evidence or Image(Optional)')}
</div>
<div
@ -538,7 +543,7 @@ export const ShopSupportPage: React.FC = () => {
color: '#0eb13c',
}}
>
Attachment ready (tap to replace)
{tr('Attachment ready (tap to replace)')}
</div>
</>
) : (
@ -561,7 +566,7 @@ export const ShopSupportPage: React.FC = () => {
textAlign: 'center',
}}
>
{uploading ? 'Uploading...' : '+ Upload Image'}
{uploading ? tr('Uploading...') : tr('+ Upload Image')}
</div>
<div
style={{
@ -623,7 +628,7 @@ export const ShopSupportPage: React.FC = () => {
whiteSpace: 'nowrap',
}}
>
{submitting ? 'Submitting...' : 'Submit Order'}
{submitting ? tr('Submitting...') : tr('Submit Order')}
</span>
</button>
</div>

602
src/pages/test/PixelVerificationModal.tsx

@ -1,602 +0,0 @@
import React, { useState, useRef, useEffect } from 'react';
import type { ScreenRouteEntry } from '../../data/routesRegistry';
interface PixelVerificationModalProps {
entry: ScreenRouteEntry;
onClose: () => void;
onSelectEntry?: (entry: ScreenRouteEntry) => void;
allEntries?: ScreenRouteEntry[];
}
type CompareMode = 'side-by-side' | 'onion-skin' | 'difference';
export const PixelVerificationModal: React.FC<PixelVerificationModalProps> = ({
entry,
onClose,
onSelectEntry,
allEntries = [],
}) => {
const [mode, setMode] = useState<CompareMode>('side-by-side');
const [overlayOpacity, setOverlayOpacity] = useState<number>(0.5);
const [scenarioOverrides, setScenarioOverrides] = useState<Record<string, string>>({});
const [showGrid, setShowGrid] = useState<boolean>(false);
const viewportRef = useRef<HTMLDivElement>(null);
const activeScenarioRoute = scenarioOverrides[entry.id] ?? entry.route;
const setActiveScenarioRoute = (route: string) => {
setScenarioOverrides((prev) => ({ ...prev, [entry.id]: route }));
};
useEffect(() => {
if (viewportRef.current) {
viewportRef.current.scrollTop = 0;
}
}, [entry.id]);
const currentIndex = allEntries.findIndex((item) => item.id === entry.id);
const prevEntry = currentIndex > 0 ? allEntries[currentIndex - 1] : null;
const nextEntry =
currentIndex >= 0 && currentIndex < allEntries.length - 1
? allEntries[currentIndex + 1]
: null;
const iframeSrc = `${activeScenarioRoute}${activeScenarioRoute.includes('?') ? '&' : '?'}bare=1`;
return (
<div
style={{
position: 'fixed',
inset: 0,
zIndex: 9999,
backgroundColor: 'rgba(10, 15, 13, 0.92)',
backdropFilter: 'blur(6px)',
display: 'flex',
flexDirection: 'column',
color: '#ffffff',
fontFamily: "'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
{/* Top Toolbar */}
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '10px var(--page-px, 16px)',
backgroundColor: '#111916',
borderBottom: '1px solid rgba(255, 255, 255, 0.12)',
flexWrap: 'wrap',
gap: 10,
maxHeight: '42vh',
overflowY: 'auto',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', minWidth: 0 }}>
<span
style={{
backgroundColor: '#00714f',
color: '#ffffff',
fontSize: 12,
fontWeight: 600,
padding: '4px 10px',
borderRadius: 6,
flexShrink: 0,
}}
>
Node {entry.figmaNodeId}
</span>
<div style={{ minWidth: 0 }}>
<div style={{ fontSize: 15, fontWeight: 700, lineHeight: '20px', wordBreak: 'break-word' }}>
{entry.title}{' '}
<span style={{ color: '#9ca3af', fontWeight: 400, fontSize: 12 }}>
({entry.figmaName} — {entry.width}×{entry.height}px)
</span>
</div>
<div style={{ fontSize: 12, color: '#9ca3af', marginTop: 2, wordBreak: 'break-all' }}>
Route:{' '}
<a
href={activeScenarioRoute}
target="_blank"
rel="noreferrer"
style={{ color: '#38ae8a', textDecoration: 'underline' }}
>
<code style={{ color: '#38ae8a' }}>{activeScenarioRoute}</code>
</a>
</div>
</div>
</div>
{/* Mode Controls */}
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
<div
style={{
display: 'inline-flex',
flexWrap: 'wrap',
backgroundColor: '#1c2823',
padding: 3,
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.1)',
}}
>
{(
[
{ id: 'side-by-side', label: 'Side-by-Side' },
{ id: 'onion-skin', label: 'Onion Skin Overlay' },
{ id: 'difference', label: 'Pixel Difference' },
] as { id: CompareMode; label: string }[]
).map((tab) => (
<button
key={tab.id}
type="button"
onClick={() => setMode(tab.id)}
style={{
padding: '6px 12px',
fontSize: 12,
fontWeight: 600,
borderRadius: 6,
border: 'none',
cursor: 'pointer',
backgroundColor: mode === tab.id ? '#00714f' : 'transparent',
color: mode === tab.id ? '#ffffff' : '#d1d5db',
}}
>
{tab.label}
</button>
))}
</div>
{mode === 'onion-skin' && (
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 8,
backgroundColor: '#1c2823',
padding: '6px 12px',
borderRadius: 8,
}}
>
<span style={{ fontSize: 12, color: '#d1d5db' }}>
Figma Opacity: {Math.round(overlayOpacity * 100)}%
</span>
<input
type="range"
min={0}
max={1}
step={0.05}
value={overlayOpacity}
onChange={(e) => setOverlayOpacity(parseFloat(e.target.value))}
style={{ width: 100, accentColor: '#00714f', cursor: 'pointer' }}
/>
</div>
)}
<button
type="button"
onClick={() => setShowGrid((prev) => !prev)}
style={{
padding: '6px 12px',
fontSize: 12,
fontWeight: 600,
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.15)',
backgroundColor: showGrid ? '#00714f' : '#1c2823',
color: '#ffffff',
cursor: 'pointer',
}}
>
{showGrid ? 'Hide 8px Grid' : 'Show 8px Grid'}
</button>
<div
style={{
display: 'inline-flex',
backgroundColor: '#1c2823',
padding: 3,
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.1)',
gap: 2,
}}
>
<button
type="button"
onClick={() => {
if (viewportRef.current) viewportRef.current.scrollTop = 0;
}}
style={{
padding: '4px 8px',
fontSize: 11,
fontWeight: 600,
borderRadius: 5,
border: 'none',
backgroundColor: '#25352f',
color: '#d1d5db',
cursor: 'pointer',
}}
>
↑ Top
</button>
<button
type="button"
onClick={() => {
if (viewportRef.current) {
viewportRef.current.scrollTop = Math.max(
0,
(viewportRef.current.scrollHeight - viewportRef.current.clientHeight) / 2
);
}
}}
style={{
padding: '4px 8px',
fontSize: 11,
fontWeight: 600,
borderRadius: 5,
border: 'none',
backgroundColor: '#25352f',
color: '#d1d5db',
cursor: 'pointer',
}}
>
↕ Mid
</button>
<button
type="button"
onClick={() => {
if (viewportRef.current) {
viewportRef.current.scrollTop = viewportRef.current.scrollHeight;
}
}}
style={{
padding: '4px 8px',
fontSize: 11,
fontWeight: 600,
borderRadius: 5,
border: 'none',
backgroundColor: '#25352f',
color: '#d1d5db',
cursor: 'pointer',
}}
>
↓ Bottom
</button>
</div>
{prevEntry && onSelectEntry && (
<button
type="button"
onClick={() => {
setActiveScenarioRoute(prevEntry.route);
onSelectEntry(prevEntry);
}}
style={{
padding: '6px 12px',
fontSize: 12,
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.15)',
backgroundColor: '#1c2823',
color: '#ffffff',
cursor: 'pointer',
}}
>
← Prev
</button>
)}
{nextEntry && onSelectEntry && (
<button
type="button"
onClick={() => {
setActiveScenarioRoute(nextEntry.route);
onSelectEntry(nextEntry);
}}
style={{
padding: '6px 12px',
fontSize: 12,
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.15)',
backgroundColor: '#1c2823',
color: '#ffffff',
cursor: 'pointer',
}}
>
Next →
</button>
)}
<a
href={activeScenarioRoute}
target="_blank"
rel="noreferrer"
style={{
padding: '6px 12px',
fontSize: 12,
fontWeight: 600,
borderRadius: 8,
backgroundColor: '#25352f',
color: '#38ae8a',
textDecoration: 'none',
border: '1px solid rgba(56, 174, 138, 0.35)',
}}
>
Open Route ↗
</a>
<button
type="button"
onClick={onClose}
style={{
padding: '6px 14px',
fontSize: 12,
fontWeight: 700,
borderRadius: 8,
border: 'none',
backgroundColor: '#dc2626',
color: '#ffffff',
cursor: 'pointer',
}}
>
Close ✕
</button>
</div>
</div>
{/* Scenarios Bar */}
{entry.scenarios.length > 0 && (
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 8,
padding: '8px 24px',
backgroundColor: '#16201c',
borderBottom: '1px solid rgba(255,255,255,0.08)',
overflowX: 'auto',
}}
>
<span style={{ fontSize: 12, color: '#9ca3af', fontWeight: 600, marginRight: 4 }}>
Scenarios:
</span>
{entry.scenarios.map((sc, idx) => {
const isSelected = activeScenarioRoute === sc.route;
return (
<button
key={`${sc.route}-${idx}`}
type="button"
onClick={() => setActiveScenarioRoute(sc.route)}
title={sc.description}
style={{
padding: '4px 10px',
fontSize: 12,
borderRadius: 6,
border: isSelected
? '1px solid #38ae8a'
: '1px solid rgba(255,255,255,0.12)',
backgroundColor: isSelected ? 'rgba(0, 113, 79, 0.35)' : '#1c2823',
color: isSelected ? '#ffffff' : '#d1d5db',
cursor: 'pointer',
whiteSpace: 'nowrap',
}}
>
{sc.label} ({sc.route})
</button>
);
})}
</div>
)}
{/* Main Comparison Viewport */}
<div
id="pixel-comparison-viewport"
ref={viewportRef}
style={{
flex: 1,
overflow: 'auto',
padding: '20px var(--page-px, 16px)',
}}
>
<div
style={{
display: 'flex',
flexWrap: 'wrap',
justifyContent: 'center',
alignItems: 'flex-start',
gap: 28,
minWidth: 'min-content',
}}
>
{mode === 'side-by-side' ? (
<>
{/* Live Implementation */}
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<div
style={{
marginBottom: 10,
fontSize: 13,
fontWeight: 600,
color: '#38ae8a',
display: 'flex',
alignItems: 'center',
gap: 8,
}}
>
<span>Live React Implementation ({entry.width}×{entry.height}px)</span>
</div>
<div
style={{
position: 'relative',
width: entry.width,
height: Math.ceil(entry.height),
backgroundColor: entry.width < 100 ? '#ffffff' : '#f8f8f8',
boxShadow: '0 12px 36px rgba(0,0,0,0.45)',
outline: '1px solid rgba(255,255,255,0.2)',
overflow: 'hidden',
}}
>
<iframe
title={`Live ${entry.title}`}
src={iframeSrc}
style={{
width: entry.width,
height: Math.ceil(entry.height),
border: 'none',
display: 'block',
backgroundColor: 'transparent',
}}
/>
{showGrid && (
<div
style={{
position: 'absolute',
inset: 0,
pointerEvents: 'none',
backgroundImage:
'linear-gradient(to right, rgba(255,0,128,0.15) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,0,128,0.15) 1px, transparent 1px)',
backgroundSize: '8px 8px',
}}
/>
)}
</div>
</div>
{/* Figma Reference PNG */}
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<div
style={{
marginBottom: 10,
fontSize: 13,
fontWeight: 600,
color: '#f59e0b',
display: 'flex',
alignItems: 'center',
gap: 8,
}}
>
<span>Figma Extracted Reference PNG ({entry.width}×{entry.height}px)</span>
</div>
<div
style={{
position: 'relative',
width: entry.width,
height: Math.ceil(entry.height),
backgroundColor: entry.width < 100 ? '#ffffff' : '#f8f8f8',
boxShadow: '0 12px 36px rgba(0,0,0,0.45)',
outline: '1px solid rgba(245, 158, 11, 0.35)',
overflow: 'hidden',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
{entry.refImage ? (
<img
src={entry.refImage}
alt={`Figma Reference ${entry.title}`}
style={{
width: entry.width,
height: entry.height,
display: 'block',
objectFit: 'contain',
}}
/>
) : (
<div
style={{
fontSize: 11,
color: '#374151',
textAlign: 'center',
padding: 4,
}}
>
Pure TEXT node (no PNG exported in archive)
</div>
)}
{showGrid && (
<div
style={{
position: 'absolute',
inset: 0,
pointerEvents: 'none',
backgroundImage:
'linear-gradient(to right, rgba(255,0,128,0.15) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,0,128,0.15) 1px, transparent 1px)',
backgroundSize: '8px 8px',
}}
/>
)}
</div>
</div>
</>
) : (
/* Onion-Skin or Difference Overlay */
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<div
style={{
marginBottom: 10,
fontSize: 13,
fontWeight: 600,
color: '#38ae8a',
}}
>
{mode === 'onion-skin'
? `Onion-Skin Overlay (Figma PNG Opacity: ${Math.round(overlayOpacity * 100)}%)`
: 'Pixel Difference Mode (Identical pixels render black)'}
</div>
<div
style={{
position: 'relative',
width: entry.width,
height: Math.ceil(entry.height),
backgroundColor: entry.width < 100 ? '#ffffff' : '#f8f8f8',
boxShadow: '0 12px 36px rgba(0,0,0,0.45)',
outline: '1px solid rgba(255,255,255,0.25)',
overflow: 'hidden',
}}
>
<iframe
title={`Live ${entry.title}`}
src={iframeSrc}
style={{
width: entry.width,
height: Math.ceil(entry.height),
border: 'none',
display: 'block',
backgroundColor: 'transparent',
}}
/>
{entry.refImage && (
<img
src={entry.refImage}
alt={`Figma Overlay ${entry.title}`}
style={{
position: 'absolute',
left: 0,
top: 0,
width: entry.width,
height: entry.height,
pointerEvents: 'none',
opacity: mode === 'onion-skin' ? overlayOpacity : 1,
mixBlendMode: mode === 'difference' ? 'difference' : 'normal',
}}
/>
)}
{showGrid && (
<div
style={{
position: 'absolute',
inset: 0,
pointerEvents: 'none',
backgroundImage:
'linear-gradient(to right, rgba(255,0,128,0.15) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,0,128,0.15) 1px, transparent 1px)',
backgroundSize: '8px 8px',
}}
/>
)}
</div>
</div>
)}
</div>
</div>
</div>
);
};
export default PixelVerificationModal;

2207
src/pages/test/SellerChatButtonTestLab.tsx
File diff suppressed because it is too large
View File

576
src/pages/test/TestDirectoryPage.tsx

@ -1,576 +0,0 @@
import React, { useState, useMemo } from 'react';
import { Link } from 'react-router-dom';
import {
ALL_IMPLEMENTED_ROUTES,
type ScreenRouteEntry,
} from '../../data/routesRegistry';
import { PixelVerificationModal } from './PixelVerificationModal';
const CATEGORIES: Array<'All' | ScreenRouteEntry['category']> = [
'All',
'Home & Discovery',
'Product & Store',
'Cart & Checkout',
'Orders & Support',
'Account & Settings',
'Standalone Nodes',
];
export const TestDirectoryPage: React.FC = () => {
const [selectedCategory, setSelectedCategory] = useState<'All' | ScreenRouteEntry['category']>('All');
const [searchQuery, setSearchQuery] = useState<string>('');
const [inspectingEntry, setInspectingEntry] = useState<ScreenRouteEntry | null>(null);
const filteredRoutes = useMemo(() => {
return ALL_IMPLEMENTED_ROUTES.filter((entry) => {
const matchesCat =
selectedCategory === 'All' || entry.category === selectedCategory;
const q = searchQuery.trim().toLowerCase();
if (!q) return matchesCat;
return (
matchesCat &&
(entry.title.toLowerCase().includes(q) ||
entry.figmaName.toLowerCase().includes(q) ||
entry.figmaNodeId.toLowerCase().includes(q) ||
entry.route.toLowerCase().includes(q) ||
entry.description.toLowerCase().includes(q) ||
entry.scenarios.some((s) => s.label.toLowerCase().includes(q)))
);
});
}, [selectedCategory, searchQuery]);
const fullScreenCount = ALL_IMPLEMENTED_ROUTES.filter(
(r) => r.category !== 'Standalone Nodes'
).length;
const standaloneCount = ALL_IMPLEMENTED_ROUTES.filter(
(r) => r.category === 'Standalone Nodes'
).length;
const totalScenarios = ALL_IMPLEMENTED_ROUTES.reduce(
(acc, r) => acc + r.scenarios.length,
0
);
return (
<div
style={{
minHeight: '100vh',
backgroundColor: '#0e1512',
color: '#f3f4f6',
fontFamily: "'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",
paddingBottom: 64,
}}
>
{/* Header Banner */}
<header
style={{
background: 'linear-gradient(135deg, #004d36 0%, #00714f 55%, #0a2e22 100%)',
borderBottom: '1px solid rgba(255,255,255,0.12)',
padding: '28px var(--page-px, 16px)',
}}
>
<div style={{ maxWidth: 1280, margin: '0 auto' }}>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: 16,
}}
>
<div style={{ minWidth: 0, flex: '1 1 260px' }}>
<div
style={{
display: 'inline-flex',
alignItems: 'center',
gap: 8,
backgroundColor: 'rgba(0,0,0,0.28)',
padding: '4px 12px',
borderRadius: 999,
fontSize: 12,
fontWeight: 600,
color: '#a7f3d0',
marginBottom: 10,
maxWidth: '100%',
}}
>
<span style={{ wordBreak: 'break-word' }}>
Habib Shop — Figma Design Extraction QA & Test Hub
</span>
</div>
<h1
style={{
margin: 0,
fontSize: 'clamp(20px, 4.5vw, 28px)',
fontWeight: 700,
letterSpacing: '-0.02em',
color: '#ffffff',
wordBreak: 'break-word',
}}
>
Implemented Pages, Scenarios & Pixel Verification (`/test`)
</h1>
<p
style={{
margin: '8px 0 0',
fontSize: 14,
color: '#d1fae5',
maxWidth: 780,
lineHeight: '20px',
}}
>
Complete directory of all {ALL_IMPLEMENTED_ROUTES.length} top-level Figma nodes from{' '}
<code>data.md</code> ({fullScreenCount} full-screen mobile pages + {standaloneCount}{' '}
standalone component/icon/text nodes) and {totalScenarios} interactive scenarios.
</p>
</div>
<div style={{ display: 'flex', gap: 10, flexWrap: 'wrap' }}>
<Link
to="/shop-home"
style={{
padding: '10px 18px',
borderRadius: 10,
backgroundColor: '#ffffff',
color: '#00714f',
fontSize: 13,
fontWeight: 700,
textDecoration: 'none',
boxShadow: '0 4px 14px rgba(0,0,0,0.25)',
}}
>
Launch App (`/shop-home`) →
</Link>
<button
type="button"
onClick={() => setInspectingEntry(ALL_IMPLEMENTED_ROUTES[0])}
style={{
padding: '10px 18px',
borderRadius: 10,
backgroundColor: 'rgba(0,0,0,0.35)',
color: '#ffffff',
border: '1px solid rgba(255,255,255,0.25)',
fontSize: 13,
fontWeight: 600,
cursor: 'pointer',
}}
>
Open Pixel Inspector
</button>
</div>
</div>
{/* Summary Metrics */}
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 160px), 1fr))',
gap: 12,
marginTop: 24,
}}
>
{[
{ label: 'Total Top-Level Figma Nodes', value: ALL_IMPLEMENTED_ROUTES.length },
{ label: 'Full-Screen Mobile Pages (375px)', value: fullScreenCount },
{ label: 'Standalone Component Nodes', value: standaloneCount },
{ label: 'Interactive Scenarios Mapped', value: totalScenarios },
].map((stat) => (
<div
key={stat.label}
style={{
backgroundColor: 'rgba(0, 0, 0, 0.28)',
border: '1px solid rgba(255, 255, 255, 0.14)',
borderRadius: 10,
padding: '12px 16px',
}}
>
<div style={{ fontSize: 22, fontWeight: 700, color: '#ffffff' }}>
{stat.value}
</div>
<div style={{ fontSize: 12, color: '#a7f3d0', marginTop: 2 }}>
{stat.label}
</div>
</div>
))}
</div>
</div>
</header>
{/* Filter & Search Controls */}
<div
style={{
maxWidth: 1280,
margin: '24px auto 0',
padding: '0 var(--page-px, 16px)',
}}
>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: 14,
backgroundColor: '#15201b',
padding: 14,
borderRadius: 12,
border: '1px solid rgba(255,255,255,0.08)',
}}
>
{/* Category Pills */}
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{CATEGORIES.map((category) => {
const active = selectedCategory === category;
const count =
category === 'All'
? ALL_IMPLEMENTED_ROUTES.length
: ALL_IMPLEMENTED_ROUTES.filter((r) => r.category === category).length;
return (
<button
key={category}
type="button"
onClick={() => setSelectedCategory(category)}
style={{
padding: '7px 13px',
borderRadius: 8,
border: active
? '1px solid #38ae8a'
: '1px solid rgba(255,255,255,0.1)',
backgroundColor: active ? '#00714f' : '#1c2a24',
color: active ? '#ffffff' : '#d1d5db',
fontSize: 12,
fontWeight: 600,
cursor: 'pointer',
}}
>
{category} ({count})
</button>
);
})}
</div>
{/* Search Input */}
<input
type="text"
placeholder="Search by screen name, node ID, route, or scenario..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
style={{
flex: '1 1 220px',
minWidth: 0,
width: '100%',
maxWidth: 360,
padding: '8px 14px',
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.15)',
backgroundColor: '#0e1512',
color: '#ffffff',
fontSize: 13,
outline: 'none',
}}
/>
</div>
{/* Cards Grid */}
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, minmax(min(100%, 340px), 1fr))',
gap: 20,
marginTop: 24,
}}
>
{filteredRoutes.map((entry, idx) => (
<div
key={entry.id}
style={{
backgroundColor: '#15201b',
border: '1px solid rgba(255,255,255,0.1)',
borderRadius: 14,
overflow: 'hidden',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
minWidth: 0,
}}
>
<div>
{/* Top Card Header */}
<div
style={{
padding: '12px 14px',
borderBottom: '1px solid rgba(255,255,255,0.08)',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: 8,
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' }}>
<span
style={{
backgroundColor: '#00714f',
color: '#ffffff',
fontSize: 11,
fontWeight: 700,
padding: '2px 8px',
borderRadius: 6,
}}
>
#{idx + 1}
</span>
<span
style={{
backgroundColor: '#1f2f28',
color: '#6ee7b7',
fontSize: 11,
fontWeight: 600,
padding: '2px 8px',
borderRadius: 6,
}}
>
Node {entry.figmaNodeId}
</span>
<span
style={{
fontSize: 11,
color: '#9ca3af',
}}
>
{entry.width}×{entry.height}px
</span>
</div>
<span
style={{
fontSize: 11,
color: '#9ca3af',
backgroundColor: 'rgba(255,255,255,0.05)',
padding: '2px 8px',
borderRadius: 6,
}}
>
{entry.category}
</span>
</div>
{/* Main Body with Reference Thumbnail & Details */}
<div
style={{
padding: 14,
display: 'flex',
gap: 14,
alignItems: 'flex-start',
flexWrap: 'wrap',
}}
>
{/* Reference Thumbnail Preview */}
<div
onClick={() => setInspectingEntry(entry)}
title="Click to open Pixel Comparison Modal"
style={{
width: 88,
height: 140,
flexShrink: 0,
backgroundColor: '#0b110e',
borderRadius: 8,
border: '1px solid rgba(255,255,255,0.12)',
overflow: 'hidden',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: 'pointer',
}}
>
{entry.refImage ? (
<img
src={entry.refImage}
alt={entry.title}
style={{
maxWidth: '100%',
maxHeight: '100%',
objectFit: 'contain',
display: 'block',
}}
/>
) : (
<span
style={{
fontSize: 11,
color: '#9ca3af',
textAlign: 'center',
padding: 6,
}}
>
TEXT Node
</span>
)}
</div>
{/* Text Details */}
<div style={{ flex: '1 1 160px', minWidth: 0 }}>
<h2
style={{
margin: 0,
fontSize: 16,
fontWeight: 700,
color: '#ffffff',
lineHeight: '22px',
wordBreak: 'break-word',
}}
>
{entry.title}
</h2>
<div
style={{
fontSize: 12,
color: '#9ca3af',
marginTop: 2,
wordBreak: 'break-word',
}}
>
Figma Name: <strong style={{ color: '#e5e7eb' }}>{entry.figmaName}</strong>
</div>
<div
style={{
fontSize: 12,
color: '#38ae8a',
marginTop: 4,
fontFamily: 'monospace',
wordBreak: 'break-all',
}}
>
{entry.route}
{entry.aliases && entry.aliases.length > 0
? ` (alias: ${entry.aliases.join(', ')})`
: ''}
</div>
<p
style={{
margin: '8px 0 0',
fontSize: 12,
color: '#d1d5db',
lineHeight: '17px',
wordBreak: 'break-word',
}}
>
{entry.description}
</p>
</div>
</div>
{/* Scenarios List */}
<div style={{ padding: '0 14px 14px' }}>
<div
style={{
fontSize: 11,
fontWeight: 700,
textTransform: 'uppercase',
letterSpacing: '0.05em',
color: '#9ca3af',
marginBottom: 8,
}}
>
Scenarios ({entry.scenarios.length})
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{entry.scenarios.map((sc, sIdx) => (
<Link
key={`${entry.id}-sc-${sIdx}`}
to={sc.route}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: 6,
padding: '6px 10px',
borderRadius: 6,
backgroundColor: '#1c2a24',
border: '1px solid rgba(255,255,255,0.06)',
color: '#e5e7eb',
textDecoration: 'none',
fontSize: 12,
}}
>
<span style={{ wordBreak: 'break-word' }}>{sc.label}</span>
<span
style={{
color: '#38ae8a',
fontSize: 11,
fontFamily: 'monospace',
wordBreak: 'break-all',
}}
>
{sc.route} →
</span>
</Link>
))}
</div>
</div>
</div>
{/* Card Footer Actions */}
<div
style={{
padding: '12px 14px',
backgroundColor: '#111a16',
borderTop: '1px solid rgba(255,255,255,0.08)',
display: 'flex',
flexWrap: 'wrap',
gap: 10,
}}
>
<Link
to={entry.route}
style={{
flex: '1 1 110px',
textAlign: 'center',
padding: '8px 12px',
borderRadius: 8,
backgroundColor: '#00714f',
color: '#ffffff',
fontSize: 12,
fontWeight: 600,
textDecoration: 'none',
}}
>
Open Screen
</Link>
<button
type="button"
onClick={() => setInspectingEntry(entry)}
style={{
flex: '1 1 130px',
padding: '8px 12px',
borderRadius: 8,
backgroundColor: '#1f2f28',
color: '#6ee7b7',
border: '1px solid rgba(110, 231, 183, 0.3)',
fontSize: 12,
fontWeight: 600,
cursor: 'pointer',
}}
>
Verify Pixels vs PNG
</button>
</div>
</div>
))}
</div>
</div>
{/* Pixel Comparison Modal */}
{inspectingEntry && (
<PixelVerificationModal
entry={inspectingEntry}
onClose={() => setInspectingEntry(null)}
onSelectEntry={(next) => setInspectingEntry(next)}
allEntries={ALL_IMPLEMENTED_ROUTES}
/>
)}
</div>
);
};
export default TestDirectoryPage;

1
src/types/window.d.ts

@ -30,6 +30,7 @@ declare global {
interface WindowEventMap {
'habib:auth-token-changed': CustomEvent<{ token: string; previousToken: string }>;
'habib:language-changed': CustomEvent<{ language: string; previousLanguage: string }>;
'habib:coins-changed': CustomEvent<{ coins: number }>;
}
}

Loading…
Cancel
Save