@davoodmehraban89 / medusa / commits / 84bb49a5
Fork 0

Bootstrap storefront: commerce/src/main.tsx

davoodmehraban89 committed Oct 13, 2026 at 23:06 UTC 84bb49a5597bb1b850de0558e388c377d540a164
1 file changed +42
commerce/src/main.tsx new
+42
@@ -0,0 +1,42 @@
1 +import React from "react"
2 +import { createRoot } from "react-dom/client"
3 +import { MARKETS, LOCALES, type MarketCode, type StoreLocale } from "./config/markets"
4 +import "./styles.css"
5 +
6 +function App() {
7 + const [market, setMarket] = React.useState<MarketCode>("IR")
8 + const [locale, setLocale] = React.useState<StoreLocale>("fa-IR")
9 + const isFa = locale === "fa-IR"
10 + const marketNames: Record<MarketCode, string> = isFa
11 + ? { IR: "ایران", AE: "امارات", OM: "عمان", IQ: "عراق", QA: "قطر" }
12 + : { IR: "Iran", AE: "UAE", OM: "Oman", IQ: "Iraq", QA: "Qatar" }
13 + return (
14 + <main dir={LOCALES[locale].direction} lang={LOCALES[locale].language}>
15 + <header className="header">
16 + <a href="/" className="logo">MEDUSA <span>COMMERCE</span></a>
17 + <nav aria-label={isFa ? "تنظیمات فروشگاه" : "Store settings"}>
18 + <label>{isFa ? "کشور" : "Country"} <select value={market} onChange={(event) => setMarket(event.target.value as MarketCode)}>
19 + {Object.keys(MARKETS).map((code) => <option key={code} value={code}>{marketNames[code as MarketCode]}</option>)}
20 + </select></label>
21 + <label>{isFa ? "زبان" : "Language"} <select value={locale} onChange={(event) => setLocale(event.target.value as StoreLocale)}>
22 + <option value="fa-IR">فارسی</option><option value="en">English</option>
23 + </select></label>
24 + </nav>
25 + </header>
26 + <section className="hero">
27 + <p className="eyebrow">{isFa ? "تجربه خرید در پنج بازار" : "Shopping across five markets"}</p>
28 + <h1>{isFa ? "یک فروشگاه، جهانی از انتخاب‌ها" : "One store. More possibilities."}</h1>
29 + <p>{isFa ? "فروشگاه چندکشوری با محصولات دیجیتال و کالاهای منتخب ایران" : "A multi-market store for electronics and selected Iran-origin goods."}</p>
30 + <div className="market">{isFa ? "بازار انتخاب‌شده:" : "Selected market:"} <strong>{marketNames[market]}</strong> · {MARKETS[market].currencyCode.toUpperCase()}</div>
31 + </section>
32 + <section className="content" aria-labelledby="catalog-title">
33 + <h2 id="catalog-title">{isFa ? "محصولات فروشگاه" : "Store products"}</h2>
34 + <p>{isFa ? "کاتالوگ پس از اتصال و تأیید API فروشگاه نمایش داده می‌شود." : "The catalog will appear after the store API is connected and verified."}</p>
35 + <p className="notice">{isFa ? "این نسخه پیش‌نمایش رابط است؛ خرید و پرداخت هنوز فعال نیست." : "This is a UI preview; checkout and payments are not active."}</p>
36 + </section>
37 + <footer>© Medusa Commerce · {isFa ? "نسخه توسعه" : "Development preview"}</footer>
38 + </main>
39 + )
40 +}
41 +
42 +createRoot(document.getElementById("root")!).render(<React.StrictMode><App /></React.StrictMode>)