Files
gruperly/apps/web/src/features/onboarding/CountryStep.tsx
Jose Selesan 2d80af082f feat(web): redesign onboarding and home after design critique
Onboarding:
- Keep the current step in ?step= so the device back gesture moves one
  step back; effectiveStep guards skipping the plan and re-opening the
  group form after the group exists. Show Back on mobile.
- Format prices with the chosen country's currency (form prefix and
  confirmation).
- Welcome describes the real flow and previews the WhatsApp payment
  reminder; the last step shares the group's invite link instead of
  listing settings chores.
- Accessibility: named stepper steps with aria-current, focus moves to
  the new step heading, alerts on errors, reduced-motion and
  direction-aware step animation, 48px primary actions.
- Group form split into "classes" and "billing", due day hidden for
  per-class billing; Stripe skips the empty Pro confirmation; Free
  features read "in Pro" instead of struck through.

Home:
- Payments section follows the plan: Free gets a locked preview with
  an upgrade link and is never asked to link Mercado Pago.
- Secondary text meets 4.5:1 contrast; accent-fg for links in dark.
- Class times use a 24h clock in Spanish and Portuguese.
- Drop the summary tiles; one hero for the current or next class, the
  rest of the day as compact rows; two columns on desktop.
- "Para atender" reads the shared ['attention'] query, so resolved
  alerts match "Requiere atención", with WhatsApp shortcuts and a link
  to the full list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 09:58:08 -03:00

87 lines
2.8 KiB
TypeScript

import type { CountryCode } from '@gruperly/shared'
import { COUNTRY_CURRENCY } from '@gruperly/shared'
import { ArrowLeft, ArrowRight } from 'lucide-react'
import { Button } from '../../components/ui'
import { cn } from '../../lib/utils'
import { useOnboarding } from './OnboardingProvider'
import { useTranslation } from 'react-i18next'
import { countryName, useIntlLocale } from '../../i18n'
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()
const { t } = useTranslation(['onboarding', 'common', 'groups'])
const locale = useIntlLocale()
return (
<section className="space-y-5">
<header className="space-y-1">
<h2 className="text-2xl font-bold text-primary">{t('country.title')}</h2>
<p className="text-sm text-foreground/60">
{t('country.description')}
</p>
</header>
<div role="radiogroup" aria-label={t('country.label')} 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">
{countryName(code, locale)}
</span>
<span className="text-sm text-foreground/50">{COUNTRY_CURRENCY[code]}</span>
</label>
)
})}
</div>
<div className="flex items-center gap-3">
<Button variant="outline" size="lg" onClick={onBack}>
<ArrowLeft className="size-4" />
{t('common:actions.back')}
</Button>
<Button variant="primary" size="lg" className="flex-1" onClick={() => onNext()}>
{t('continue')}
<ArrowRight className="size-4" />
</Button>
</div>
</section>
)
}