// Shared between client and server. Prices are in Ghana cedis (GHS).
export type CreditPackage = {
  id: string
  name: string
  credits: number
  price: number
  tagline: string
  popular?: boolean
}

export const CURRENCY = 'GHS'

export const PACKAGES: CreditPackage[] = [
  { id: 'starter', name: 'Starter', credits: 500, price: 17.5, tagline: 'Try it out on a small list' },
  { id: 'business', name: 'Business', credits: 2_000, price: 60, tagline: 'Weekly updates for a growing shop', popular: true },
  { id: 'pro', name: 'Pro', credits: 10_000, price: 250, tagline: 'Churches, schools and associations' },
  { id: 'enterprise', name: 'Enterprise', credits: 50_000, price: 1_000, tagline: 'High-volume alerts and campaigns' },
]

export function getPackage(id: string) {
  return PACKAGES.find((p) => p.id === id)
}

export function formatCedis(amount: number) {
  return `GH₵${amount.toLocaleString('en-GH', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
}

export function pricePerSms(pkg: CreditPackage) {
  return pkg.price / pkg.credits
}
