feat: sync pricing currency with selected language
Switch to MAD when Arabic is selected, EUR for French, USD for English. Currency still overridable via the manual toggle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useMarketplacePreferences } from '@/components/MarketplaceShell'
|
import { useMarketplacePreferences } from '@/components/MarketplaceShell'
|
||||||
import { resolveBrowserAppUrl } from '@/lib/appUrls'
|
import { resolveBrowserAppUrl } from '@/lib/appUrls'
|
||||||
@@ -10,6 +10,8 @@ type Billing = 'monthly' | 'annual'
|
|||||||
|
|
||||||
const SYMBOL: Record<Currency, string> = { MAD: 'MAD', USD: '$', EUR: '€' }
|
const SYMBOL: Record<Currency, string> = { MAD: 'MAD', USD: '$', EUR: '€' }
|
||||||
|
|
||||||
|
const LANGUAGE_CURRENCY: Record<string, Currency> = { ar: 'MAD', fr: 'EUR', en: 'USD' }
|
||||||
|
|
||||||
const PRICES: Record<string, Record<Currency, { monthly: number; annual: number }>> = {
|
const PRICES: Record<string, Record<Currency, { monthly: number; annual: number }>> = {
|
||||||
STARTER: {
|
STARTER: {
|
||||||
MAD: { monthly: 299, annual: 2990 },
|
MAD: { monthly: 299, annual: 2990 },
|
||||||
@@ -123,8 +125,12 @@ function annualSavingsPct(plan: string, currency: Currency): number {
|
|||||||
export default function PricingClient() {
|
export default function PricingClient() {
|
||||||
const { language } = useMarketplacePreferences()
|
const { language } = useMarketplacePreferences()
|
||||||
const dict = copy[language]
|
const dict = copy[language]
|
||||||
const [currency, setCurrency] = useState<Currency>('MAD')
|
const [currency, setCurrency] = useState<Currency>(() => LANGUAGE_CURRENCY[language] ?? 'MAD')
|
||||||
const [billing, setBilling] = useState<Billing>('monthly')
|
const [billing, setBilling] = useState<Billing>('monthly')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCurrency(LANGUAGE_CURRENCY[language] ?? 'MAD')
|
||||||
|
}, [language])
|
||||||
const dashboardUrl = resolveBrowserAppUrl(process.env.NEXT_PUBLIC_DASHBOARD_URL ?? 'http://localhost:3000/dashboard')
|
const dashboardUrl = resolveBrowserAppUrl(process.env.NEXT_PUBLIC_DASHBOARD_URL ?? 'http://localhost:3000/dashboard')
|
||||||
|
|
||||||
const savings = annualSavingsPct('STARTER', currency)
|
const savings = annualSavingsPct('STARTER', currency)
|
||||||
|
|||||||
Reference in New Issue
Block a user