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:
@@ -1,10 +1,12 @@
|
||||
import { type DefaultValues, useForm } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import type { BillingType, CountryCode, CreateFirstGroup, WeekDay } from '@gruperly/shared'
|
||||
import { CreateFirstGroupSchema, DEFAULT_COUNTRY } from '@gruperly/shared'
|
||||
import { COUNTRY_CURRENCY, CreateFirstGroupSchema, DEFAULT_COUNTRY } from '@gruperly/shared'
|
||||
import { ArrowLeft, Check, Loader2 } from 'lucide-react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { useId } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { sortWeekDays } from '../../lib/format'
|
||||
import { currencySymbol, sortWeekDays } from '../../lib/format'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { BILLING_TYPES, WEEK_DAYS } from '../onboarding/constants'
|
||||
@@ -15,6 +17,8 @@ type GroupFormProps = {
|
||||
submitLabel: string
|
||||
isSubmitting: boolean
|
||||
errorMessage?: string | null
|
||||
/** Una acción para salir del error (p. ej. volver a elegir el plan). */
|
||||
errorAction?: ReactNode
|
||||
/** Solo lo usa el onboarding: ahí el país ya se eligió en el paso anterior. */
|
||||
country?: CountryCode
|
||||
onSubmit: (values: CreateFirstGroup) => void
|
||||
@@ -27,7 +31,8 @@ export function GroupForm({
|
||||
submitLabel,
|
||||
isSubmitting,
|
||||
errorMessage,
|
||||
country = DEFAULT_COUNTRY,
|
||||
errorAction,
|
||||
country,
|
||||
onSubmit,
|
||||
onBack,
|
||||
}: GroupFormProps) {
|
||||
@@ -42,8 +47,13 @@ export function GroupForm({
|
||||
capacity: 10,
|
||||
billingType: 'MONTHLY',
|
||||
dueDay: 1,
|
||||
country,
|
||||
country: country ?? DEFAULT_COUNTRY,
|
||||
}
|
||||
// Con país (onboarding) el símbolo sale de su moneda; sin país, del navegador,
|
||||
// igual que el resto de los montos de la app.
|
||||
const symbol = currencySymbol(country ? COUNTRY_CURRENCY[country] : undefined)
|
||||
const daysLabelId = useId()
|
||||
const billingLabelId = useId()
|
||||
|
||||
const {
|
||||
register,
|
||||
@@ -89,9 +99,13 @@ export function GroupForm({
|
||||
<FieldError message={errors.name?.message} />
|
||||
</div>
|
||||
|
||||
<fieldset className="space-y-4">
|
||||
<legend className="mb-3 text-base font-semibold text-primary">
|
||||
{t('form.whenLegend')}
|
||||
</legend>
|
||||
<div>
|
||||
<Label>{t('form.days')}</Label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Label id={daysLabelId}>{t('form.days')}</Label>
|
||||
<div role="group" aria-labelledby={daysLabelId} className="grid grid-cols-7 gap-1.5">
|
||||
{WEEK_DAYS.map((value) => {
|
||||
const isActive = days.includes(value)
|
||||
return (
|
||||
@@ -101,7 +115,7 @@ export function GroupForm({
|
||||
aria-pressed={isActive}
|
||||
onClick={() => toggleDay(value)}
|
||||
className={cn(
|
||||
'h-9 rounded-full border px-3.5 text-sm font-medium transition-colors',
|
||||
'h-11 rounded-xl border text-sm font-medium transition-colors',
|
||||
isActive
|
||||
? 'border-accent bg-accent text-on-accent'
|
||||
: 'border-border bg-surface text-primary hover:bg-primary-soft',
|
||||
@@ -126,7 +140,6 @@ export function GroupForm({
|
||||
<FieldError message={errors.time?.message} />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<Label htmlFor="capacity">{t('form.capacity')}</Label>
|
||||
<Input
|
||||
@@ -140,12 +153,18 @@ export function GroupForm({
|
||||
/>
|
||||
<FieldError message={errors.capacity?.message} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset className="space-y-4">
|
||||
<legend className="mb-3 text-base font-semibold text-primary">
|
||||
{t('form.priceLegend')}
|
||||
</legend>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="price">{t('form.price')}</Label>
|
||||
<div className="relative">
|
||||
<span className="pointer-events-none absolute inset-y-0 left-3 flex items-center text-base text-foreground/50 sm:text-sm">
|
||||
$
|
||||
{symbol}
|
||||
</span>
|
||||
<Input
|
||||
id="price"
|
||||
@@ -154,18 +173,17 @@ export function GroupForm({
|
||||
min={0}
|
||||
step="0.01"
|
||||
placeholder={t('form.pricePlaceholder')}
|
||||
className="pl-7"
|
||||
className={symbol.length > 1 ? 'pl-10' : 'pl-7'}
|
||||
invalid={!!errors.price}
|
||||
{...register('price', { valueAsNumber: true })}
|
||||
/>
|
||||
</div>
|
||||
<FieldError message={errors.price?.message} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label>{t('form.billingType')}</Label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<Label id={billingLabelId}>{t('form.billingType')}</Label>
|
||||
<div role="group" aria-labelledby={billingLabelId} className="grid grid-cols-2 gap-2">
|
||||
{BILLING_TYPES.map((value) => {
|
||||
const isActive = billingType === value
|
||||
return (
|
||||
@@ -196,6 +214,9 @@ export function GroupForm({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* El vencimiento es de la cuota mensual: cobrando por clase no aplica (el
|
||||
valor por default sigue en el form para que el esquema valide). */}
|
||||
{billingType === 'MONTHLY' ? (
|
||||
<div>
|
||||
<Label htmlFor="dueDay">{t('form.dueDay')}</Label>
|
||||
<Input
|
||||
@@ -213,19 +234,24 @@ export function GroupForm({
|
||||
</p>
|
||||
<FieldError message={errors.dueDay?.message} />
|
||||
</div>
|
||||
) : null}
|
||||
</fieldset>
|
||||
|
||||
{errorMessage ? (
|
||||
<p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{errorMessage}</p>
|
||||
<div role="alert" className="space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||
<p>{errorMessage}</p>
|
||||
{errorAction}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
{onBack ? (
|
||||
<Button variant="outline" onClick={onBack} disabled={isSubmitting}>
|
||||
<Button variant="outline" size="lg" onClick={onBack} disabled={isSubmitting}>
|
||||
<ArrowLeft className="size-4" />
|
||||
{t('common:actions.back')}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button type="submit" variant="primary" className="flex-1" disabled={isSubmitting}>
|
||||
<Button type="submit" variant="primary" size="lg" className="flex-1" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
||||
{isSubmitting ? t('form.submitting') : submitLabel}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user