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>
This commit is contained in:
Jose Selesan
2026-11-06 09:58:08 -03:00
parent 70ef049f34
commit 2d80af082f
48 changed files with 1507 additions and 784 deletions

View File

@@ -0,0 +1,111 @@
import { Link } from '@tanstack/react-router'
import type { HomeSummaryDto } from '@gruperly/shared'
import { Lock, Sparkles } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import { useBillingStatus } from '../billing/useBillingStatus'
import { useMpStatus } from '../mp/useMpStatus'
import { formatPrice } from '../../lib/format'
import { UpcomingPaymentRow } from './UpcomingPaymentRow'
/* Filas de muestra de la vista previa de Free: nombres y montos de ejemplo, en
la moneda que formatea el navegador. Nunca son datos del profe. */
const TEASER_ROWS = [
{ name: 'teaser.sample1', amount: 15000 },
{ name: 'teaser.sample2', amount: 15000 },
] as const
/**
* "Próximos cobros". Con un plan que cobra por Mercado Pago muestra los cobros
* y lo que queda por cobrar; sin él (Free), una vista previa bloqueada de cómo
* se vería, con el paso a Pro. Nunca ofrece vincular Mercado Pago a quien no
* puede cobrar con él.
*/
export function PaymentsSection({ summary }: { summary: HomeSummaryDto }) {
const { t } = useTranslation('home')
const billingQuery = useBillingStatus()
const mpStatusQuery = useMpStatus()
// Mientras no se sabe el plan no se decide nada: ni cobros ni vista previa.
if (billingQuery.isPending) return null
// Sin enforcement (o si el estado del plan no cargó) todo es Pro: se muestran
// los cobros, como hasta ahora.
const billing = billingQuery.data
const canCharge = !billing || !billing.enforced || billing.limits.mpCharges
const { pendingAmount, pendingPayments } = summary.stats
return (
<section aria-labelledby="home-payments-title">
<div className="flex items-baseline justify-between gap-3">
<h2 id="home-payments-title" className="text-lg font-bold text-primary">
{t('upcoming.title')}
</h2>
{canCharge ? (
<Link
to="/payments"
className="-my-2 inline-flex min-h-11 items-center rounded-lg px-1 text-sm font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
>
{t('upcoming.seeAll')}
</Link>
) : null}
</div>
{!canCharge ? (
<div className="relative mt-3 overflow-hidden rounded-xl border border-border bg-surface">
<ul aria-hidden="true" className="divide-y divide-border opacity-50 blur-[1.5px] select-none">
{TEASER_ROWS.map((row) => (
<li key={row.name} className="flex items-center justify-between gap-3 px-4 py-3">
<span className="text-sm font-semibold text-primary">{t(row.name)}</span>
<span className="text-sm font-semibold tabular-nums text-primary">{formatPrice(row.amount)}</span>
</li>
))}
</ul>
<div className="border-t border-border px-4 py-4">
<p className="flex items-start gap-2 text-sm text-primary">
<Lock className="mt-0.5 size-4 shrink-0 text-foreground" aria-hidden="true" />
{t('teaser.description')}
</p>
<Link
to="/billing"
className="mt-3 inline-flex h-11 items-center gap-2 rounded-xl bg-accent-soft px-4 text-sm font-semibold text-accent-fg transition-colors hover:bg-accent/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
>
<Sparkles className="size-4" aria-hidden="true" />
{t('teaser.cta')}
</Link>
</div>
</div>
) : (
<>
{pendingPayments > 0 ? (
<p className="mt-1 text-sm text-foreground">
{t('upcoming.pending', { amount: formatPrice(pendingAmount), count: pendingPayments })}
</p>
) : null}
{summary.upcomingPayments.length > 0 ? (
<ul className="mt-3 divide-y divide-border overflow-hidden rounded-xl border border-border bg-surface">
{summary.upcomingPayments.map((payment) => (
<UpcomingPaymentRow key={payment.id} payment={payment} />
))}
</ul>
) : (
<div className="mt-3 rounded-xl border border-border bg-surface px-4 py-4 text-sm">
<p className="font-medium text-primary">{t('upcoming.empty')}</p>
{/* El vacío dice cómo salir de él: sin Mercado Pago vinculado no
hay cómo crear links de cobro. */}
{mpStatusQuery.data && mpStatusQuery.data.status !== 'active' ? (
<Link
to="/settings"
className="mt-1 inline-flex min-h-11 items-center font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded-lg"
>
{t('upcoming.linkMp')}
</Link>
) : (
<p className="mt-0.5 text-foreground">{t('upcoming.hint')}</p>
)}
</div>
)}
</>
)}
</section>
)
}