From 342ca856d954ab022bbab15906448c16da70d2a8 Mon Sep 17 00:00:00 2001 From: Urvish Date: Fri, 20 Nov 2026 15:46:28 +0530 Subject: [PATCH 1/2] feat(pricing): implement phase 1 - EUR and USD price parity and EU country currency mapping --- src/App.tsx | 4 +++- src/components/catalog/CatalogSection.tsx | 4 ++-- src/constants/countries.ts | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 24044a5..e91428c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -262,7 +262,7 @@ export default function App() { return { priceInr: livePlan.price_inr ?? item.priceInr, priceUsd: livePlan.price_usd ?? item.priceUsd, - priceEur: item.priceEur, + priceEur: livePlan.price_eur ?? livePlan.price_usd ?? item.priceEur, isActive: livePlan.is_active !== undefined ? livePlan.is_active : true, }; } @@ -703,6 +703,7 @@ export default function App() { ...item, priceInr: live.priceInr, priceUsd: live.priceUsd, + priceEur: live.priceEur, }; }) ); @@ -783,6 +784,7 @@ export default function App() { ...module, priceInr: live.priceInr, priceUsd: live.priceUsd, + priceEur: live.priceEur, }; const exists = cart.find(item => item.code === module.code); diff --git a/src/components/catalog/CatalogSection.tsx b/src/components/catalog/CatalogSection.tsx index f942b3d..cc74f77 100644 --- a/src/components/catalog/CatalogSection.tsx +++ b/src/components/catalog/CatalogSection.tsx @@ -665,7 +665,7 @@ export const CatalogSection: React.FC = ({ category: 'Bundle', priceInr: pInr, priceUsd: pUsd, - priceEur: pUsd, + priceEur: cPlan.price_eur ?? pUsd, desc: cPlan.description || 'Custom bundled access.', color: 'from-slate-700 to-slate-900' }; @@ -717,7 +717,7 @@ export const CatalogSection: React.FC = ({ ) : ( - {currency === 'INR' ? `₹${pInr}` : `$${pUsd}`} + {currency === 'INR' ? `₹${pInr}` : currency === 'EUR' ? `€${cPlan.price_eur ?? pUsd}` : `$${pUsd}`} )} {!isUnlocked && ( diff --git a/src/constants/countries.ts b/src/constants/countries.ts index c179b4d..867f07e 100644 --- a/src/constants/countries.ts +++ b/src/constants/countries.ts @@ -54,6 +54,12 @@ export const COUNTRY_CODES: CountryCode[] = [ { iso2: 'HR', code: '+385', label: '🇭🇷 +385', country: 'Croatia', currency: 'EUR', minLength: 8, maxLength: 9, placeholder: '8 to 9 digits' }, { iso2: 'SK', code: '+421', label: '🇸🇰 +421', country: 'Slovakia', currency: 'EUR', minLength: 9, maxLength: 9, placeholder: '9-digit mobile number' }, { iso2: 'BG', code: '+359', label: '🇧🇬 +359', country: 'Bulgaria', currency: 'EUR', minLength: 8, maxLength: 9, placeholder: '8 to 9 digits' }, + { iso2: 'CY', code: '+357', label: '🇨🇾 +357', country: 'Cyprus', currency: 'EUR', minLength: 8, maxLength: 8, placeholder: '8-digit phone number' }, + { iso2: 'EE', code: '+372', label: '🇪🇪 +372', country: 'Estonia', currency: 'EUR', minLength: 7, maxLength: 8, placeholder: '7 to 8 digits' }, + { iso2: 'LV', code: '+371', label: '🇱🇻 +371', country: 'Latvia', currency: 'EUR', minLength: 8, maxLength: 8, placeholder: '8-digit phone number' }, + { iso2: 'LT', code: '+370', label: '🇱🇹 +370', country: 'Lithuania', currency: 'EUR', minLength: 8, maxLength: 8, placeholder: '8-digit phone number' }, + { iso2: 'MT', code: '+356', label: '🇲🇹 +356', country: 'Malta', currency: 'EUR', minLength: 8, maxLength: 8, placeholder: '8-digit phone number' }, + { iso2: 'SI', code: '+386', label: '🇸🇮 +386', country: 'Slovenia', currency: 'EUR', minLength: 8, maxLength: 8, placeholder: '8-digit phone number' }, { iso2: 'RU', code: '+7', label: '🇷🇺 +7', country: 'Russia', currency: 'USD', minLength: 10, maxLength: 10, placeholder: '10-digit mobile number' }, { iso2: 'TR', code: '+90', label: '🇹🇷 +90', country: 'Turkey', currency: 'USD', minLength: 10, maxLength: 10, placeholder: '10-digit mobile number' }, -- 2.34.1 From dc55ab4acfd3e3ca18441f0e3b842b69ab9d217f Mon Sep 17 00:00:00 2001 From: Urvish Date: Fri, 20 Nov 2026 15:52:05 +0530 Subject: [PATCH 2/2] feat(cart): implement phase 2 - lock currency to country, remove manual toggle, and add timezone region detection --- src/App.tsx | 30 +++++++++++++---- src/components/cart/CartDrawer.tsx | 52 ++++++++++++++++-------------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index e91428c..3685210 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useMemo } from 'react'; import axios from 'axios'; import { CURRICULUM_MODULES } from './constants/modules'; @@ -37,6 +37,23 @@ const getInitialTab = (): 'storefront' | 'subscriptions' | 'logged-out' => { return 'storefront'; }; +const getInitialRegion = (): { currency: Currency; country: string; dialCode: string } => { + if (typeof Intl !== 'undefined') { + try { + const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || ''; + if (tz.includes('Kolkata') || tz.includes('Calcutta')) { + return { currency: 'INR', country: 'India', dialCode: '+91' }; + } + if (tz.startsWith('Europe/')) { + return { currency: 'EUR', country: 'Germany', dialCode: '+49' }; + } + } catch { + // ignore + } + } + return { currency: 'USD', country: 'United States', dialCode: '+1' }; +}; + export default function App() { const [activeTab, setActiveTab] = useState<'storefront' | 'subscriptions' | 'logged-out'>(getInitialTab); @@ -52,7 +69,8 @@ export default function App() { } }; - const [currency, setCurrency] = useState('INR'); + const initialRegion = useMemo(getInitialRegion, []); + const [currency, setCurrency] = useState(initialRegion.currency); // Auth state const [userToken, setUserToken] = useState(localStorage.getItem('access_token')); @@ -80,8 +98,8 @@ export default function App() { const [authPassword, setAuthPassword] = useState(''); const [authDisplayName, setAuthDisplayName] = useState(''); const [authPhone, setAuthPhone] = useState(''); - const [authDialCode, setAuthDialCode] = useState('+91'); - const [authCountry, setAuthCountry] = useState('India'); + const [authDialCode, setAuthDialCode] = useState(initialRegion.dialCode); + const [authCountry, setAuthCountry] = useState(initialRegion.country); const [authLoading, setAuthLoading] = useState(false); const [authError, setAuthError] = useState(null); @@ -404,7 +422,8 @@ export default function App() { setShowProfileDrawer(false); setProfileDisplayName(''); setProfilePhone(''); - setProfileCountry('India'); + setProfileCountry(initialRegion.country); + setCurrency(initialRegion.currency); setProfileError(null); setProfileSuccess(false); setShowAuthModal(false); @@ -1099,7 +1118,6 @@ export default function App() { void; toggleCartItem: (module: ModuleItem) => void; couponCode: string; setCouponCode: (code: string) => void; @@ -25,7 +24,6 @@ interface CartDrawerProps { export const CartDrawer: React.FC = ({ cart, currency, - setCurrency, toggleCartItem, couponCode, setCouponCode, @@ -77,28 +75,23 @@ export const CartDrawer: React.FC = ({ - {/* Currency selector toggle */} -
- Billing Currency: -
- - + {/* Billing Currency & Region Badge */} +
+
+ + + {loggedInUser ? 'Billing Currency' : 'Estimated Currency'}: + +
+
+ + {currency === 'INR' ? 'INR (₹)' : currency === 'EUR' ? 'EUR (€)' : 'USD ($)'} + + {loggedInUser?.country && ( + + • {loggedInUser.country} + + )}
@@ -417,6 +410,15 @@ export const CartDrawer: React.FC = ({

* Integrated with Razorpay Gateway API (Test Mode).

+

+ Billing currency is tied to your country. Need billing assistance?{' '} + + Contact Support + +

)}
-- 2.34.1