- Módulo billing: suscripción Pro mensual vía /preapproval con credenciales de plataforma por país, webhook firmado y reconciliación por polling. - PlanGuard en los use-cases que crean grupos/alumnos, cobran con MP o activan automatizaciones (402 plan_limit_reached / plan_feature_required / plan_read_only), detrás de BILLING_ENFORCEMENT. - Onboarding: paso Plan obligatorio (POST /onboarding/plan); con Free se saltean Cobros y WhatsApp. - Web: pantalla /billing, aviso de Pro desde el MutationCache. - Migración billing_subscriptions y docs/billing.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
2.7 KiB
TypeScript
83 lines
2.7 KiB
TypeScript
import type { CountryCode } from '@gruperly/shared'
|
|
import { COUNTRY_CURRENCY, COUNTRY_LABELS } from '@gruperly/shared'
|
|
import { ArrowLeft, ArrowRight } from 'lucide-react'
|
|
import { Button } from '../../components/ui'
|
|
import { cn } from '../../lib/utils'
|
|
import { useOnboarding } from './OnboardingProvider'
|
|
|
|
export const COUNTRY_OPTIONS: readonly CountryCode[] = [
|
|
'AR',
|
|
'BR',
|
|
'CL',
|
|
'CO',
|
|
'MX',
|
|
'PE',
|
|
'UY',
|
|
]
|
|
|
|
type CountryStepProps = {
|
|
onNext: () => void
|
|
onBack: () => void
|
|
}
|
|
|
|
/**
|
|
* Paso "País" del onboarding.
|
|
*
|
|
* El país del profesor define la moneda con la que se generan los links de
|
|
* cobro y el precio de Pro, así que se pregunta al empezar. Por default
|
|
* Argentina (la moneda por default es ARS). Vive en el provider: el paso Plan y
|
|
* el del primer grupo lo usan, y se guarda junto con el plan.
|
|
*/
|
|
export function CountryStep({ onNext, onBack }: CountryStepProps) {
|
|
const { country, setCountry } = useOnboarding()
|
|
|
|
return (
|
|
<section className="space-y-5">
|
|
<header className="space-y-1">
|
|
<h2 className="text-2xl font-bold text-primary">¿En qué país vas a cobrar?</h2>
|
|
<p className="text-sm text-foreground/60">
|
|
Tus links se generan en la moneda de ese país.
|
|
</p>
|
|
</header>
|
|
|
|
<div role="radiogroup" aria-label="País" className="space-y-2">
|
|
{COUNTRY_OPTIONS.map((code) => {
|
|
const isSelected = code === country
|
|
return (
|
|
<label
|
|
key={code}
|
|
className={cn(
|
|
'flex cursor-pointer items-center gap-3 rounded-xl border border-border bg-surface px-4 py-3 transition-colors',
|
|
isSelected && 'border-accent bg-accent-soft ring-2 ring-accent/20',
|
|
)}
|
|
>
|
|
<input
|
|
type="radio"
|
|
name="country"
|
|
value={code}
|
|
checked={isSelected}
|
|
onChange={() => setCountry(code)}
|
|
className="size-4 accent-accent"
|
|
/>
|
|
<span className="flex-1 text-sm font-medium text-primary">
|
|
{COUNTRY_LABELS[code]}
|
|
</span>
|
|
<span className="text-sm text-foreground/50">{COUNTRY_CURRENCY[code]}</span>
|
|
</label>
|
|
)
|
|
})}
|
|
</div>
|
|
|
|
<div className="flex items-center gap-3">
|
|
<Button variant="outline" onClick={onBack} className="hidden lg:inline-flex">
|
|
<ArrowLeft className="size-4" />
|
|
Volver
|
|
</Button>
|
|
<Button variant="primary" className="flex-1 lg:flex-none" onClick={() => onNext()}>
|
|
Continuar
|
|
<ArrowRight className="size-4" />
|
|
</Button>
|
|
</div>
|
|
</section>
|
|
)
|
|
} |