update subscription algorithm

This commit is contained in:
root
2026-05-25 03:12:19 -04:00
parent 95376d3223
commit c9cbe479aa
42 changed files with 3098 additions and 307 deletions
+10 -10
View File
@@ -19,32 +19,32 @@ export interface ApiError {
[key: string]: unknown
}
// Plan prices in smallest currency unit
// Plan prices in smallest currency unit (MAD, in centimes)
export const PLAN_PRICES: Record<string, Record<string, Record<string, number>>> = {
STARTER: {
MONTHLY: { MAD: 2990, USD: 2900, EUR: 2700 },
ANNUAL: { MAD: 29900, USD: 29000, EUR: 27000 },
MONTHLY: { MAD: 2990 },
ANNUAL: { MAD: 29900 },
},
GROWTH: {
MONTHLY: { MAD: 3990, USD: 5900, EUR: 5400 },
ANNUAL: { MAD: 39900, USD: 59000, EUR: 54000 },
MONTHLY: { MAD: 3990 },
ANNUAL: { MAD: 39900 },
},
PRO: {
MONTHLY: { MAD: 99900, USD: 9900, EUR: 9000 },
ANNUAL: { MAD: 999000, USD: 99000, EUR: 90000 },
MONTHLY: { MAD: 99900 },
ANNUAL: { MAD: 999000 },
},
}
export type Locale = 'en' | 'fr' | 'ar'
export type SupportedCurrency = 'MAD' | 'USD' | 'EUR'
export type SupportedCurrency = 'MAD'
export function formatCurrency(amount: number, currency: SupportedCurrency, locale: Locale = 'en'): string {
export function formatCurrency(amount: number, _currency: SupportedCurrency = 'MAD', locale: Locale = 'en'): string {
const divisor = 100
const value = amount / divisor
const localeMap: Record<Locale, string> = { en: 'en-US', fr: 'fr-FR', ar: 'ar-MA' }
return new Intl.NumberFormat(localeMap[locale], {
style: 'currency',
currency,
currency: 'MAD',
minimumFractionDigits: 2,
}).format(value)
}