development #14
@@ -61,7 +61,7 @@ bun --filter @gruperly/web icons # regenera los iconos PWA de apps/web
|
|||||||
3. Sin `BILLING_ENFORCEMENT=on` todo es Pro y los guards no tocan la base (por eso los tests viejos con prisma mockeado no necesitan `billingSubscription`).
|
3. Sin `BILLING_ENFORCEMENT=on` todo es Pro y los guards no tocan la base (por eso los tests viejos con prisma mockeado no necesitan `billingSubscription`).
|
||||||
4. Los webhooks `POST /billing/webhooks/mp/:country` y `POST /billing/webhooks/stripe` son públicos (`isPublicApiRequest`): el adaptador verifica la firma (`x-signature` / `Stripe-Signature`) y solo dice qué suscripción sincronizar; se deduplica por `(source, dedupeKey)` y se le vuelve a pedir todo al proveedor. El polling (`ReconcileSubscriptions` + sync on-read en `GET /billing/status` si está `PENDING`) es el fallback.
|
4. Los webhooks `POST /billing/webhooks/mp/:country` y `POST /billing/webhooks/stripe` son públicos (`isPublicApiRequest`): el adaptador verifica la firma (`x-signature` / `Stripe-Signature`) y solo dice qué suscripción sincronizar; se deduplica por `(source, dedupeKey)` y se le vuelve a pedir todo al proveedor. El polling (`ReconcileSubscriptions` + sync on-read en `GET /billing/status` si está `PENDING`) es el fallback.
|
||||||
5. `402` con `plan_limit_reached` / `plan_feature_required` / `plan_read_only`: la web abre el aviso de Pro desde el `MutationCache` de `main.tsx`.
|
5. `402` con `plan_limit_reached` / `plan_feature_required` / `plan_read_only`: la web abre el aviso de Pro desde el `MutationCache` de `main.tsx`.
|
||||||
6. Onboarding: paso **Plan** obligatorio (`POST /onboarding/plan`, guarda `country` y `plan_selected_at`); `first-group` da `409 plan_not_selected` sin él. Los pasos del wizard son ids (`features/onboarding/steps.ts`) y con Free se saltean Cobros y WhatsApp.
|
6. Onboarding: paso **Plan** obligatorio (`POST /onboarding/plan`, guarda `country` y `plan_selected_at`); `first-group` da `409 plan_not_selected` sin él. Los pasos del wizard son ids (`features/onboarding/steps.ts`) y con Free se saltean Cobros y WhatsApp. El paso vive en `?step=` (el back del dispositivo retrocede un paso) y lo que pide la URL pasa por `effectiveStep`: sin plan no se pasa de Plan y con el grupo ya creado no se vuelve al formulario. Los callbacks (`?mp=`, `?wa=`, `?sub=`) navegan con `replace` al paso que corresponde.
|
||||||
- **zod en v3.24 (pin exacto)**, no v4: `better-call` (transitiva de better-auth) pide `zod ^4` — ese peer warning es conocido y aceptado. `validator` de hono (`hono/validator`) sustituyó a `@hono/zod-validator` (sus tipos duales zod v3/v4 causaban TS2589/exhaustion no resolubles con `ZodTypeAny`); las rutas tipan `c.req.valid` vía el `ValidationInput` derivado del schema.
|
- **zod en v3.24 (pin exacto)**, no v4: `better-call` (transitiva de better-auth) pide `zod ^4` — ese peer warning es conocido y aceptado. `validator` de hono (`hono/validator`) sustituyó a `@hono/zod-validator` (sus tipos duales zod v3/v4 causaban TS2589/exhaustion no resolubles con `ZodTypeAny`); las rutas tipan `c.req.valid` vía el `ValidationInput` derivado del schema.
|
||||||
- **PWA (`apps/web`)**: Workbox precachea todo lo que emite Vite, así que el tamaño del precache es un costo real de arranque offline. Cuatro trampas ya pisadas: (1) `globIgnores: ['**/workbox-*.js']` matchea también `workbox-window.*.js`, que es el módulo cliente de `virtual:pwa-register` — excluirlo rompe el registro del SW en cada carga; solo se excluye `**/sw.js`. (2) Importar `@fontsource-variable/inter/wght.css` arrastra los 7 subsets (~220 KB que el navegador nunca baja); por eso los `@font-face` de `latin`/`latin-ext` están escritos a mano en `src/index.css`. **No re-agregar `<link>` a `fonts.googleapis.com`**: rompe el offline. (3) El SW necesita contexto seguro (HTTPS o `localhost`); por IP de LAN sobre `http://` no se registra y no avisa. (4) El aviso de instalación vive en `PwaProvider` (fuera del `RouterProvider`, así que sigue la ruta con `router.subscribe('onResolved')`) y **no** en `RootLayout`: `AppLayoutGuard` desmonta `RootLayout` cada vez que su query de onboarding vuelve a `pending`, y un `settled` de dwell en el hijo se perdería en cada navegación.
|
- **PWA (`apps/web`)**: Workbox precachea todo lo que emite Vite, así que el tamaño del precache es un costo real de arranque offline. Cuatro trampas ya pisadas: (1) `globIgnores: ['**/workbox-*.js']` matchea también `workbox-window.*.js`, que es el módulo cliente de `virtual:pwa-register` — excluirlo rompe el registro del SW en cada carga; solo se excluye `**/sw.js`. (2) Importar `@fontsource-variable/inter/wght.css` arrastra los 7 subsets (~220 KB que el navegador nunca baja); por eso los `@font-face` de `latin`/`latin-ext` están escritos a mano en `src/index.css`. **No re-agregar `<link>` a `fonts.googleapis.com`**: rompe el offline. (3) El SW necesita contexto seguro (HTTPS o `localhost`); por IP de LAN sobre `http://` no se registra y no avisa. (4) El aviso de instalación vive en `PwaProvider` (fuera del `RouterProvider`, así que sigue la ruta con `router.subscribe('onResolved')`) y **no** en `RootLayout`: `AppLayoutGuard` desmonta `RootLayout` cada vez que su query de onboarding vuelve a `pending`, y un `settled` de dwell en el hijo se perdería en cada navegación.
|
||||||
- **Aviso de instalación (`src/features/pwa/`)**: se ofrece solo con **sesión iniciada**, fuera de `/onboarding` y tras **20 s seguidos en la misma ruta** (navegar antes reinicia la cuenta; después de armado ya no se oculta). El descarte es definitivo vía `localStorage['pwa-install-dismissed']`. Ojo: `_authenticated` **no** es un guard de sesión —`AppLayoutGuard` renderiza `RootLayout` aunque no haya `user`—, así que el gate se chequea en el provider. Safari en iOS no dispara `beforeinstallprompt`: ahí se muestra `IosInstallHint` con la instrucción de Compartir → Agregar a pantalla de inicio (excluye CriOS/FxiOS/EdgiOS, que también usan WebKit pero se instalan desde Safari).
|
- **Aviso de instalación (`src/features/pwa/`)**: se ofrece solo con **sesión iniciada**, fuera de `/onboarding` y tras **20 s seguidos en la misma ruta** (navegar antes reinicia la cuenta; después de armado ya no se oculta). El descarte es definitivo vía `localStorage['pwa-install-dismissed']`. Ojo: `_authenticated` **no** es un guard de sesión —`AppLayoutGuard` renderiza `RootLayout` aunque no haya `user`—, así que el gate se chequea en el provider. Safari en iOS no dispara `beforeinstallprompt`: ahí se muestra `IosInstallHint` con la instrucción de Compartir → Agregar a pantalla de inicio (excluye CriOS/FxiOS/EdgiOS, que también usan WebKit pero se instalan desde Safari).
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { forwardRef, type ButtonHTMLAttributes } from 'react'
|
|||||||
import { cn } from '../../lib/utils'
|
import { cn } from '../../lib/utils'
|
||||||
|
|
||||||
export type ButtonVariant = 'primary' | 'ghost' | 'outline'
|
export type ButtonVariant = 'primary' | 'ghost' | 'outline'
|
||||||
export type ButtonSize = 'sm' | 'md' | 'icon'
|
export type ButtonSize = 'sm' | 'md' | 'lg' | 'icon'
|
||||||
|
|
||||||
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
||||||
variant?: ButtonVariant
|
variant?: ButtonVariant
|
||||||
@@ -18,6 +18,8 @@ const variants: Record<ButtonVariant, string> = {
|
|||||||
const sizes: Record<ButtonSize, string> = {
|
const sizes: Record<ButtonSize, string> = {
|
||||||
sm: 'h-8 px-3 text-sm',
|
sm: 'h-8 px-3 text-sm',
|
||||||
md: 'h-10 px-4 text-sm',
|
md: 'h-10 px-4 text-sm',
|
||||||
|
// Acciones principales de un flujo en mobile: 48px, cómodo para el pulgar.
|
||||||
|
lg: 'h-12 px-5 text-sm',
|
||||||
icon: 'size-9',
|
icon: 'size-9',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Plan, PlanLimits } from '@gruperly/shared'
|
import type { Plan, PlanLimits } from '@gruperly/shared'
|
||||||
import { Check } from 'lucide-react'
|
import { Check, Lock } from 'lucide-react'
|
||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
import { Badge } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { cn } from '../../lib/utils'
|
import { cn } from '../../lib/utils'
|
||||||
@@ -29,18 +29,32 @@ export function PlanOptionCard({ plan, limits, price, current, highlighted, chil
|
|||||||
>
|
>
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex items-center justify-between gap-3">
|
||||||
<p className="text-base font-semibold text-primary">{PLAN_NAMES[plan]}</p>
|
<p className="text-base font-semibold text-primary">{PLAN_NAMES[plan]}</p>
|
||||||
{current ? <Badge variant="info">{t('option.yourPlan')}</Badge> : null}
|
{current ? (
|
||||||
|
<Badge variant="info">{t('option.yourPlan')}</Badge>
|
||||||
|
) : highlighted ? (
|
||||||
|
// El destacado no puede ser solo el color del borde.
|
||||||
|
<Badge variant="info">{t('option.recommended')}</Badge>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-sm text-foreground/60">{price ?? t('option.free')}</p>
|
<p className="mt-1 text-sm text-foreground/60">{price ?? t('option.free')}</p>
|
||||||
|
|
||||||
<ul className="mt-3 flex-1 space-y-1.5">
|
<ul className="mt-3 flex-1 space-y-1.5">
|
||||||
{planFeatureList(limits).map((feature) => (
|
{planFeatureList(limits).map((feature) => (
|
||||||
<li key={feature.label} className="flex items-start gap-2 text-sm">
|
<li key={feature.label} className="flex items-start gap-2 text-sm">
|
||||||
<Check
|
{feature.included ? (
|
||||||
className={cn('mt-0.5 size-4 shrink-0', feature.included ? 'text-success' : 'text-foreground/20')}
|
<Check aria-hidden="true" className="mt-0.5 size-4 shrink-0 text-success" />
|
||||||
/>
|
) : (
|
||||||
<span className={feature.included ? 'text-primary' : 'text-foreground/40 line-through'}>
|
<Lock aria-hidden="true" className="mt-0.5 size-4 shrink-0 text-foreground/30" />
|
||||||
|
)}
|
||||||
|
{/* Lo que el plan no trae se nombra como "en Pro" y no tachado: se
|
||||||
|
lee como lo que falta, no como un castigo. */}
|
||||||
|
<span className={feature.included ? 'text-primary' : 'text-foreground/50'}>
|
||||||
{feature.label}
|
{feature.label}
|
||||||
|
{feature.included ? null : (
|
||||||
|
<span className="ml-1.5 whitespace-nowrap text-xs font-medium text-foreground/50">
|
||||||
|
· {t('option.inPro')}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function SubscribeForm({
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{error ? <p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{error}</p> : null}
|
{error ? <p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{error}</p> : null}
|
||||||
|
|
||||||
<div className="flex justify-end gap-3">
|
<div className="flex justify-end gap-3">
|
||||||
{onCancel ? (
|
{onCancel ? (
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { type DefaultValues, useForm } from 'react-hook-form'
|
import { type DefaultValues, useForm } from 'react-hook-form'
|
||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
import type { BillingType, CountryCode, CreateFirstGroup, WeekDay } from '@gruperly/shared'
|
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 { ArrowLeft, Check, Loader2 } from 'lucide-react'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
import { useId } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { sortWeekDays } from '../../lib/format'
|
import { currencySymbol, sortWeekDays } from '../../lib/format'
|
||||||
import { cn } from '../../lib/utils'
|
import { cn } from '../../lib/utils'
|
||||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||||
import { BILLING_TYPES, WEEK_DAYS } from '../onboarding/constants'
|
import { BILLING_TYPES, WEEK_DAYS } from '../onboarding/constants'
|
||||||
@@ -15,6 +17,8 @@ type GroupFormProps = {
|
|||||||
submitLabel: string
|
submitLabel: string
|
||||||
isSubmitting: boolean
|
isSubmitting: boolean
|
||||||
errorMessage?: string | null
|
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. */
|
/** Solo lo usa el onboarding: ahí el país ya se eligió en el paso anterior. */
|
||||||
country?: CountryCode
|
country?: CountryCode
|
||||||
onSubmit: (values: CreateFirstGroup) => void
|
onSubmit: (values: CreateFirstGroup) => void
|
||||||
@@ -27,7 +31,8 @@ export function GroupForm({
|
|||||||
submitLabel,
|
submitLabel,
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
country = DEFAULT_COUNTRY,
|
errorAction,
|
||||||
|
country,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onBack,
|
onBack,
|
||||||
}: GroupFormProps) {
|
}: GroupFormProps) {
|
||||||
@@ -42,8 +47,13 @@ export function GroupForm({
|
|||||||
capacity: 10,
|
capacity: 10,
|
||||||
billingType: 'MONTHLY',
|
billingType: 'MONTHLY',
|
||||||
dueDay: 1,
|
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 {
|
const {
|
||||||
register,
|
register,
|
||||||
@@ -89,9 +99,13 @@ export function GroupForm({
|
|||||||
<FieldError message={errors.name?.message} />
|
<FieldError message={errors.name?.message} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<fieldset className="space-y-4">
|
||||||
|
<legend className="mb-3 text-base font-semibold text-primary">
|
||||||
|
{t('form.whenLegend')}
|
||||||
|
</legend>
|
||||||
<div>
|
<div>
|
||||||
<Label>{t('form.days')}</Label>
|
<Label id={daysLabelId}>{t('form.days')}</Label>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div role="group" aria-labelledby={daysLabelId} className="grid grid-cols-7 gap-1.5">
|
||||||
{WEEK_DAYS.map((value) => {
|
{WEEK_DAYS.map((value) => {
|
||||||
const isActive = days.includes(value)
|
const isActive = days.includes(value)
|
||||||
return (
|
return (
|
||||||
@@ -101,7 +115,7 @@ export function GroupForm({
|
|||||||
aria-pressed={isActive}
|
aria-pressed={isActive}
|
||||||
onClick={() => toggleDay(value)}
|
onClick={() => toggleDay(value)}
|
||||||
className={cn(
|
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
|
isActive
|
||||||
? 'border-accent bg-accent text-on-accent'
|
? 'border-accent bg-accent text-on-accent'
|
||||||
: 'border-border bg-surface text-primary hover:bg-primary-soft',
|
: 'border-border bg-surface text-primary hover:bg-primary-soft',
|
||||||
@@ -126,7 +140,6 @@ export function GroupForm({
|
|||||||
<FieldError message={errors.time?.message} />
|
<FieldError message={errors.time?.message} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-3">
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="capacity">{t('form.capacity')}</Label>
|
<Label htmlFor="capacity">{t('form.capacity')}</Label>
|
||||||
<Input
|
<Input
|
||||||
@@ -140,12 +153,18 @@ export function GroupForm({
|
|||||||
/>
|
/>
|
||||||
<FieldError message={errors.capacity?.message} />
|
<FieldError message={errors.capacity?.message} />
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset className="space-y-4">
|
||||||
|
<legend className="mb-3 text-base font-semibold text-primary">
|
||||||
|
{t('form.priceLegend')}
|
||||||
|
</legend>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="price">{t('form.price')}</Label>
|
<Label htmlFor="price">{t('form.price')}</Label>
|
||||||
<div className="relative">
|
<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">
|
<span className="pointer-events-none absolute inset-y-0 left-3 flex items-center text-base text-foreground/50 sm:text-sm">
|
||||||
$
|
{symbol}
|
||||||
</span>
|
</span>
|
||||||
<Input
|
<Input
|
||||||
id="price"
|
id="price"
|
||||||
@@ -154,18 +173,17 @@ export function GroupForm({
|
|||||||
min={0}
|
min={0}
|
||||||
step="0.01"
|
step="0.01"
|
||||||
placeholder={t('form.pricePlaceholder')}
|
placeholder={t('form.pricePlaceholder')}
|
||||||
className="pl-7"
|
className={symbol.length > 1 ? 'pl-10' : 'pl-7'}
|
||||||
invalid={!!errors.price}
|
invalid={!!errors.price}
|
||||||
{...register('price', { valueAsNumber: true })}
|
{...register('price', { valueAsNumber: true })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<FieldError message={errors.price?.message} />
|
<FieldError message={errors.price?.message} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label>{t('form.billingType')}</Label>
|
<Label id={billingLabelId}>{t('form.billingType')}</Label>
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div role="group" aria-labelledby={billingLabelId} className="grid grid-cols-2 gap-2">
|
||||||
{BILLING_TYPES.map((value) => {
|
{BILLING_TYPES.map((value) => {
|
||||||
const isActive = billingType === value
|
const isActive = billingType === value
|
||||||
return (
|
return (
|
||||||
@@ -196,6 +214,9 @@ export function GroupForm({
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
<div>
|
||||||
<Label htmlFor="dueDay">{t('form.dueDay')}</Label>
|
<Label htmlFor="dueDay">{t('form.dueDay')}</Label>
|
||||||
<Input
|
<Input
|
||||||
@@ -213,19 +234,24 @@ export function GroupForm({
|
|||||||
</p>
|
</p>
|
||||||
<FieldError message={errors.dueDay?.message} />
|
<FieldError message={errors.dueDay?.message} />
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
{errorMessage ? (
|
{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}
|
) : null}
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{onBack ? (
|
{onBack ? (
|
||||||
<Button variant="outline" onClick={onBack} disabled={isSubmitting}>
|
<Button variant="outline" size="lg" onClick={onBack} disabled={isSubmitting}>
|
||||||
<ArrowLeft className="size-4" />
|
<ArrowLeft className="size-4" />
|
||||||
{t('common:actions.back')}
|
{t('common:actions.back')}
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : 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 ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
||||||
{isSubmitting ? t('form.submitting') : submitLabel}
|
{isSubmitting ? t('form.submitting') : submitLabel}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,80 +1,69 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { Link } from '@tanstack/react-router'
|
import { Link } from '@tanstack/react-router'
|
||||||
import type { PendingPreRegistrations } from '@gruperly/shared'
|
import type { PendingPreRegistrations } from '@gruperly/shared'
|
||||||
import { CheckCircle2, ChevronRight, Inbox, Wallet } from 'lucide-react'
|
import { CheckCircle2, ChevronRight, Inbox, MessageCircle } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Avatar } from '../../components/ui'
|
import { Button } from '../../components/ui'
|
||||||
import { getGroupsRiskOverview, getPayments } from '../../lib/api'
|
import { AlertTag } from '../attention/AlertTag'
|
||||||
import { absenceReason } from '../groups/card'
|
import { alertLabel, flaggedStudents, reminderMessage, whatsappLink } from '../attention/attention'
|
||||||
|
import { attentionQueryOptions } from '../attention/queries'
|
||||||
|
import { SeverityAvatar } from '../attention/SeverityAvatar'
|
||||||
|
|
||||||
/** How many at-risk people Home names; the rest is in each group's stats. */
|
/** Cuántas personas nombra el Inicio; el resto está a un toque, en "Requiere atención". */
|
||||||
const MAX_AT_RISK = 4
|
const MAX_STUDENTS = 4
|
||||||
|
|
||||||
/* "Para atender": what the teacher has to act on today, across all groups.
|
/* "Para atender": lo que el profe tiene que resolver, en todos sus grupos.
|
||||||
Nothing is computed here: the at-risk people are the high-risk `urgentes` of
|
Sale de la misma query que "Requiere atención" (`['attention']`), así las dos
|
||||||
`GET /groups-risk/overview` (same query key as the group list, so the cache
|
pantallas aplican la misma regla (`computeStudentAlerts`) y un "Resuelto" en
|
||||||
is shared), the overdue payments are just the total of the filtered list and
|
una se ve en la otra sin refetch. Las preinscripciones vienen con el resumen
|
||||||
the pending pre-registrations come with the Home summary. */
|
del Inicio y van primero: del otro lado alguien espera una respuesta. */
|
||||||
export function AttentionList({
|
export function AttentionList({
|
||||||
pendingPreRegistrations,
|
pendingPreRegistrations,
|
||||||
}: {
|
}: {
|
||||||
pendingPreRegistrations: PendingPreRegistrations[]
|
pendingPreRegistrations: PendingPreRegistrations[]
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation('home')
|
const { t } = useTranslation(['home', 'attention', 'common'])
|
||||||
const riskQuery = useQuery({
|
const attentionQuery = useQuery(attentionQueryOptions)
|
||||||
queryKey: ['groups-risk-overview'],
|
|
||||||
queryFn: getGroupsRiskOverview,
|
|
||||||
})
|
|
||||||
const overdueQuery = useQuery({
|
|
||||||
queryKey: ['payments', { page: 1, pageSize: 1, status: 'OVERDUE' }],
|
|
||||||
queryFn: () => getPayments({ page: 1, pageSize: 1, status: 'OVERDUE' }),
|
|
||||||
})
|
|
||||||
|
|
||||||
if (riskQuery.isPending || overdueQuery.isPending) return null
|
const students = flaggedStudents(attentionQuery.data)
|
||||||
// A failing secondary block shouldn't take Home down: it just isn't shown.
|
const shown = students.slice(0, MAX_STUDENTS)
|
||||||
if (riskQuery.isError && overdueQuery.isError) return null
|
const hidden = students.length - shown.length
|
||||||
|
const isEmpty = students.length === 0 && pendingPreRegistrations.length === 0
|
||||||
const groups = riskQuery.data?.items ?? []
|
|
||||||
const atRisk = groups
|
|
||||||
.flatMap((group) =>
|
|
||||||
group.urgentes
|
|
||||||
.filter((member) => member.level === 'riesgo_alto')
|
|
||||||
.map((member) => ({ ...member, groupId: group.groupId, groupName: group.groupName })),
|
|
||||||
)
|
|
||||||
.sort((a, b) => b.consecutiveAbsences - a.consecutiveAbsences)
|
|
||||||
const totalAtRisk = groups.reduce((total, group) => total + group.riesgoAlto, 0)
|
|
||||||
const overdue = overdueQuery.data?.pagination.total ?? 0
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<section aria-labelledby="home-attention-title">
|
||||||
<h2 className="text-lg font-bold text-primary">{t('attention.title')}</h2>
|
<div className="flex items-baseline justify-between gap-3">
|
||||||
|
<h2 id="home-attention-title" className="text-lg font-bold text-primary">
|
||||||
|
{t('attention.title')}
|
||||||
|
</h2>
|
||||||
|
{students.length > 0 ? (
|
||||||
|
<Link
|
||||||
|
to="/groups/attention"
|
||||||
|
className="-my-2 inline-flex min-h-11 items-center text-sm font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded-lg px-1"
|
||||||
|
>
|
||||||
|
{t('attention.seeAll')}
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
{atRisk.length === 0 && overdue === 0 && pendingPreRegistrations.length === 0 ? (
|
{attentionQuery.isPending ? (
|
||||||
<p className="mt-3 flex items-center gap-2 rounded-xl border border-border bg-surface px-4 py-3 text-sm text-foreground/70">
|
// Reserva el lugar de dos filas: sin esto, la sección aparecía de golpe
|
||||||
|
// y empujaba los cobros.
|
||||||
|
<div aria-hidden="true" className="mt-3 h-[8.5rem] animate-pulse rounded-xl bg-primary-soft/60 motion-reduce:animate-none" />
|
||||||
|
) : attentionQuery.isError && pendingPreRegistrations.length === 0 ? (
|
||||||
|
<div role="alert" className="mt-3 flex items-center justify-between gap-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
|
<span>{t('attention.loadError')}</span>
|
||||||
|
<Button variant="outline" size="sm" onClick={() => void attentionQuery.refetch()}>
|
||||||
|
{t('common:actions.retry')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : isEmpty ? (
|
||||||
|
<p className="mt-3 flex items-center gap-2.5 rounded-xl border border-border bg-surface px-4 py-3.5 text-sm text-foreground">
|
||||||
<CheckCircle2 className="size-4 shrink-0 text-success" aria-hidden="true" />
|
<CheckCircle2 className="size-4 shrink-0 text-success" aria-hidden="true" />
|
||||||
{t('attention.allGood')}
|
{t('attention.allGood')}
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<ul className="mt-3 divide-y divide-border overflow-hidden rounded-xl border border-border bg-surface">
|
<ul className="mt-3 divide-y divide-border overflow-hidden rounded-xl border border-border bg-surface">
|
||||||
{overdue > 0 ? (
|
|
||||||
<li>
|
|
||||||
<Link to="/payments" className={ROW_CLASS_NAME}>
|
|
||||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-full bg-danger-soft text-danger">
|
|
||||||
<Wallet className="size-5" aria-hidden="true" />
|
|
||||||
</span>
|
|
||||||
<span className="min-w-0 flex-1">
|
|
||||||
<span className="block text-sm font-semibold text-primary">
|
|
||||||
{t('attention.overdue', { count: overdue })}
|
|
||||||
</span>
|
|
||||||
<span className="block text-xs text-foreground/60">{t('attention.overdueHint')}</span>
|
|
||||||
</span>
|
|
||||||
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{/* Someone waiting for an answer goes before the at-risk list: it's
|
|
||||||
the only item where the other side is actively waiting. */}
|
|
||||||
{pendingPreRegistrations.map((group) => (
|
{pendingPreRegistrations.map((group) => (
|
||||||
<li key={group.groupId}>
|
<li key={group.groupId}>
|
||||||
<Link
|
<Link
|
||||||
@@ -83,57 +72,74 @@ export function AttentionList({
|
|||||||
search={{ section: 'pending' }}
|
search={{ section: 'pending' }}
|
||||||
className={ROW_CLASS_NAME}
|
className={ROW_CLASS_NAME}
|
||||||
>
|
>
|
||||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent">
|
<span className="flex size-10 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg">
|
||||||
<Inbox className="size-5" aria-hidden="true" />
|
<Inbox className="size-5" aria-hidden="true" />
|
||||||
</span>
|
</span>
|
||||||
<span className="min-w-0 flex-1">
|
<span className="min-w-0 flex-1">
|
||||||
<span className="block text-sm font-semibold text-primary">
|
<span className="block text-sm font-semibold text-primary">
|
||||||
{t('attention.preRegistrations', { count: group.count })}
|
{t('attention.preRegistrations', { count: group.count })}
|
||||||
</span>
|
</span>
|
||||||
<span className="block truncate text-xs text-foreground/60">{group.groupName}</span>
|
<span className="block truncate text-xs text-foreground">{group.groupName}</span>
|
||||||
</span>
|
</span>
|
||||||
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
<ChevronRight className="size-4 shrink-0 text-foreground" aria-hidden="true" />
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{atRisk.slice(0, MAX_AT_RISK).map((member) => (
|
{shown.map((student) => {
|
||||||
<li key={member.attendeeId}>
|
const label = alertLabel(student.worst)
|
||||||
|
const isPayment = student.worst.tipo === 'pago'
|
||||||
|
const href = whatsappLink(student, isPayment ? reminderMessage(student) : undefined)
|
||||||
|
const action = isPayment ? t('attention:card.remind') : t('attention:card.contact')
|
||||||
|
return (
|
||||||
|
<li key={student.attendeeId} className="flex items-center">
|
||||||
<Link
|
<Link
|
||||||
to="/groups/$groupId/attendees/$attendeeId"
|
to="/groups/$groupId/attendees/$attendeeId"
|
||||||
params={{ groupId: member.groupId, attendeeId: member.attendeeId }}
|
params={{ groupId: student.groupId, attendeeId: student.attendeeId }}
|
||||||
className={ROW_CLASS_NAME}
|
className={`${ROW_CLASS_NAME} min-w-0 flex-1 pr-2`}
|
||||||
>
|
>
|
||||||
<Avatar name={member.fullName} className="size-10 rounded-full" />
|
<SeverityAvatar
|
||||||
|
name={student.fullName}
|
||||||
|
seed={student.attendeeId}
|
||||||
|
severity={student.worst.gravedad}
|
||||||
|
size="md"
|
||||||
|
/>
|
||||||
<span className="min-w-0 flex-1">
|
<span className="min-w-0 flex-1">
|
||||||
<span className="block truncate text-sm font-semibold text-primary">
|
<span className="block truncate text-sm font-semibold text-primary">{student.fullName}</span>
|
||||||
{member.fullName}
|
<span className="block truncate text-xs text-foreground">{student.groupName}</span>
|
||||||
</span>
|
</span>
|
||||||
<span className="block truncate text-xs text-foreground/60">
|
<AlertTag severity={student.worst.gravedad}>{label}</AlertTag>
|
||||||
{member.groupName}
|
|
||||||
{absenceReason(member) ? (
|
|
||||||
<>
|
|
||||||
{' · '}
|
|
||||||
<span className="text-danger">{absenceReason(member)}</span>
|
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
|
||||||
</Link>
|
</Link>
|
||||||
|
{/* El atajo del día a día: escribirle sin abrir la ficha. Va al
|
||||||
|
lado del link (no adentro) para no anidar controles. */}
|
||||||
|
{href ? (
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
aria-label={t('attention:card.actionWhatsapp', { action, name: student.fullName })}
|
||||||
|
className="mr-2 flex size-11 shrink-0 items-center justify-center rounded-xl text-success transition-colors hover:bg-success-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
||||||
|
>
|
||||||
|
<MessageCircle className="size-5" aria-hidden="true" />
|
||||||
|
</a>
|
||||||
|
) : null}
|
||||||
</li>
|
</li>
|
||||||
))}
|
)
|
||||||
|
})}
|
||||||
|
|
||||||
{totalAtRisk > MAX_AT_RISK ? (
|
{hidden > 0 ? (
|
||||||
<li className="px-4 py-3 text-xs text-foreground/60">
|
<li>
|
||||||
{t('attention.moreAtRisk', { count: totalAtRisk - MAX_AT_RISK })}
|
<Link to="/groups/attention" className={`${ROW_CLASS_NAME} text-sm font-medium text-accent-fg`}>
|
||||||
|
<span className="flex-1">{t('attention.more', { count: hidden })}</span>
|
||||||
|
<ChevronRight className="size-4 shrink-0" aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
) : null}
|
) : null}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
</div>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ROW_CLASS_NAME =
|
const ROW_CLASS_NAME =
|
||||||
'flex items-center gap-3 px-4 py-3 transition-colors hover:bg-primary-soft/50 active:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent'
|
'flex min-h-14 items-center gap-3 px-4 py-3 transition-colors hover:bg-primary-soft/50 active:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent'
|
||||||
|
|||||||
@@ -1,59 +1,59 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { Link, useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import { Loader2, Plus } from 'lucide-react'
|
import { Loader2, Plus } from 'lucide-react'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Button } from '../../components/ui'
|
import { Button } from '../../components/ui'
|
||||||
import { useAuth } from '../../context/AuthProvider'
|
import { useAuth } from '../../context/AuthProvider'
|
||||||
import { useIntlLocale } from '../../i18n'
|
import { useIntlLocale } from '../../i18n'
|
||||||
import { getClassesToday, getHomeSummary } from '../../lib/api'
|
import { getClassesToday, getHomeSummary } from '../../lib/api'
|
||||||
import { useMpStatus } from '../mp/useMpStatus'
|
|
||||||
import { AttentionList } from './AttentionList'
|
import { AttentionList } from './AttentionList'
|
||||||
import { SummaryStats } from './SummaryStats'
|
import { classState, planDay } from './day'
|
||||||
import { TodayClassCard } from './TodayClassCard'
|
|
||||||
import { NextClassHero } from './NextClassHero'
|
import { NextClassHero } from './NextClassHero'
|
||||||
import { UpcomingPaymentRow } from './UpcomingPaymentRow'
|
import { PaymentsSection } from './PaymentsSection'
|
||||||
|
import { TodayClassCard } from './TodayClassCard'
|
||||||
|
import { TodayClassRow } from './TodayClassRow'
|
||||||
|
|
||||||
|
/** Cada cuánto se recalcula qué clase va en el hero (una clase termina de estar
|
||||||
|
* "en curso" con la app abierta). */
|
||||||
|
const CLOCK_TICK_MS = 60_000
|
||||||
|
|
||||||
export function HomeView() {
|
export function HomeView() {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { t } = useTranslation(['home', 'common'])
|
const { t } = useTranslation(['home', 'common'])
|
||||||
const locale = useIntlLocale()
|
const locale = useIntlLocale()
|
||||||
const { user } = useAuth()
|
const { user } = useAuth()
|
||||||
const mpStatusQuery = useMpStatus()
|
|
||||||
const firstName = user?.name?.trim().split(/\s+/)[0]
|
const firstName = user?.name?.trim().split(/\s+/)[0]
|
||||||
// "martes 27 de octubre": the date anchors "Clase de hoy" and the due dates below.
|
const now = useNow(CLOCK_TICK_MS)
|
||||||
const today = new Date().toLocaleDateString(locale, {
|
// "jueves, 5 de noviembre": ancla la clase de hoy y los vencimientos de abajo.
|
||||||
weekday: 'long',
|
const today = now.toLocaleDateString(locale, { weekday: 'long', day: 'numeric', month: 'long' })
|
||||||
day: 'numeric',
|
|
||||||
month: 'long',
|
const summaryQuery = useQuery({ queryKey: ['home-summary'], queryFn: getHomeSummary })
|
||||||
})
|
|
||||||
const summaryQuery = useQuery({
|
|
||||||
queryKey: ['home-summary'],
|
|
||||||
queryFn: getHomeSummary,
|
|
||||||
})
|
|
||||||
const classesTodayQuery = useQuery({
|
const classesTodayQuery = useQuery({
|
||||||
queryKey: ['classes-today'],
|
queryKey: ['classes-today'],
|
||||||
queryFn: getClassesToday,
|
queryFn: getClassesToday,
|
||||||
staleTime: 60_000,
|
staleTime: 60_000,
|
||||||
})
|
})
|
||||||
const todayClasses = classesTodayQuery.data?.data ?? []
|
const { hero, rest } = planDay(classesTodayQuery.data?.data ?? [], now)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<div>
|
<header>
|
||||||
<p className="text-sm font-medium first-letter:uppercase text-foreground/60">{today}</p>
|
<p className="text-sm font-medium text-foreground first-letter:uppercase">{today}</p>
|
||||||
<h1 className="mt-1 text-2xl font-bold text-primary">
|
<h1 className="mt-1 text-2xl font-bold text-primary">
|
||||||
{firstName ? t('greetingName', { name: firstName }) : t('greeting')}
|
{firstName ? t('greetingName', { name: firstName }) : t('greeting')}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</header>
|
||||||
|
|
||||||
{summaryQuery.isPending ? (
|
{summaryQuery.isPending ? (
|
||||||
<div className="mt-8 flex items-center justify-center py-16">
|
<div role="status" className="mt-8 flex items-center justify-center py-16">
|
||||||
<Loader2 className="size-6 animate-spin text-foreground/40" />
|
<Loader2 className="size-6 animate-spin text-foreground" aria-hidden="true" />
|
||||||
|
<span className="sr-only">{t('loading')}</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{summaryQuery.isError ? (
|
{summaryQuery.isError ? (
|
||||||
<div className="mt-8 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
<div role="alert" className="mt-8 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
<p>{t('loadError')}</p>
|
<p>{t('loadError')}</p>
|
||||||
<Button variant="outline" size="sm" onClick={() => void summaryQuery.refetch()}>
|
<Button variant="outline" size="sm" onClick={() => void summaryQuery.refetch()}>
|
||||||
{t('common:actions.retry')}
|
{t('common:actions.retry')}
|
||||||
@@ -62,79 +62,69 @@ export function HomeView() {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{summaryQuery.isSuccess && summaryQuery.data.stats.groups === 0 ? (
|
{summaryQuery.isSuccess && summaryQuery.data.stats.groups === 0 ? (
|
||||||
<div className="mt-8 rounded-xl border border-dashed border-border bg-surface px-4 py-12 text-center">
|
<div className="mt-8 rounded-2xl border border-border bg-surface px-4 py-10 text-center">
|
||||||
<p className="font-medium text-primary">{t('empty.title')}</p>
|
<p className="font-semibold text-primary">{t('empty.title')}</p>
|
||||||
<p className="mt-1 text-sm text-foreground/60">
|
<p className="mt-1 text-sm text-foreground">{t('empty.description')}</p>
|
||||||
{t('empty.description')}
|
<Button variant="primary" size="lg" className="mt-5" onClick={() => void navigate({ to: '/groups/new' })}>
|
||||||
</p>
|
<Plus className="size-4" aria-hidden="true" />
|
||||||
<Button
|
|
||||||
variant="primary"
|
|
||||||
className="mt-5"
|
|
||||||
onClick={() => void navigate({ to: '/groups/new' })}
|
|
||||||
>
|
|
||||||
<Plus className="size-4" />
|
|
||||||
{t('empty.cta')}
|
{t('empty.cta')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{summaryQuery.isSuccess && summaryQuery.data.stats.groups > 0 ? (
|
{summaryQuery.isSuccess && summaryQuery.data.stats.groups > 0 ? (
|
||||||
<div className="mt-6 space-y-6">
|
// En desktop, dos columnas: el día a la izquierda y lo pendiente a la
|
||||||
{todayClasses.length > 0 ? (
|
// derecha. En mobile, el mismo orden de arriba abajo.
|
||||||
<div className="space-y-3">
|
<div className="mt-6 grid grid-cols-[minmax(0,1fr)] gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] lg:items-start lg:gap-10">
|
||||||
{todayClasses.map((classItem) => (
|
<div className="space-y-4">
|
||||||
<TodayClassCard key={classItem.sessionId} item={classItem} />
|
{classesTodayQuery.isError ? (
|
||||||
))}
|
<div role="alert" className="flex items-center justify-between gap-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
</div>
|
<span>{t('today.loadError')}</span>
|
||||||
) : summaryQuery.data.nextClass ? (
|
<Button variant="outline" size="sm" onClick={() => void classesTodayQuery.refetch()}>
|
||||||
<NextClassHero nextClass={summaryQuery.data.nextClass} />
|
{t('common:actions.retry')}
|
||||||
) : (
|
|
||||||
<div className="rounded-xl border border-dashed border-border bg-surface px-4 py-8 text-center">
|
|
||||||
<p className="text-sm font-medium text-primary">{t('noClasses.title')}</p>
|
|
||||||
<p className="mt-1 text-sm text-foreground/60">
|
|
||||||
{t('noClasses.description')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<SummaryStats summary={summaryQuery.data} />
|
|
||||||
|
|
||||||
<AttentionList pendingPreRegistrations={summaryQuery.data.pendingPreRegistrations} />
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div className="flex items-center justify-between gap-3">
|
|
||||||
<h2 className="text-lg font-bold text-primary">{t('upcoming.title')}</h2>
|
|
||||||
<Button variant="ghost" size="sm" onClick={() => void navigate({ to: '/payments' })}>
|
|
||||||
{t('upcoming.seeAll')}
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
) : hero ? (
|
||||||
|
<TodayClassCard item={hero} state={classState(hero, now)} />
|
||||||
|
) : summaryQuery.data.nextClass ? (
|
||||||
|
<NextClassHero nextClass={summaryQuery.data.nextClass} />
|
||||||
|
) : classesTodayQuery.isSuccess && rest.length === 0 ? (
|
||||||
|
<div className="rounded-2xl border border-border bg-surface px-4 py-6">
|
||||||
|
<p className="text-sm font-semibold text-primary">{t('noClasses.title')}</p>
|
||||||
|
<p className="mt-1 text-sm text-foreground">{t('noClasses.description')}</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{summaryQuery.data.upcomingPayments.length > 0 ? (
|
{rest.length > 0 ? (
|
||||||
<ul className="mt-3 space-y-3">
|
<section aria-labelledby="home-today-title">
|
||||||
{summaryQuery.data.upcomingPayments.map((payment) => (
|
<h2 id="home-today-title" className="text-sm font-semibold text-primary">
|
||||||
<UpcomingPaymentRow key={payment.id} payment={payment} />
|
{t('today.listTitle')}
|
||||||
|
</h2>
|
||||||
|
<ul className="mt-2 divide-y divide-border overflow-hidden rounded-xl border border-border bg-surface">
|
||||||
|
{rest.map((item) => (
|
||||||
|
<TodayClassRow key={item.sessionId} item={item} state={classState(item, now)} />
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
) : (
|
</section>
|
||||||
<div className="mt-3 rounded-xl border border-dashed border-border bg-surface px-4 py-6 text-center text-sm text-foreground/60">
|
) : null}
|
||||||
<p>{t('upcoming.empty')}</p>
|
|
||||||
{/* The empty state says how to get out of it: without Mercado
|
|
||||||
Pago there is no way to create payment links. */}
|
|
||||||
{mpStatusQuery.data && mpStatusQuery.data.status !== 'active' ? (
|
|
||||||
<Link
|
|
||||||
to="/settings"
|
|
||||||
className="mt-2 inline-block font-medium text-accent hover:underline"
|
|
||||||
>
|
|
||||||
{t('upcoming.linkMp')}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<p className="mt-1 text-xs">{t('upcoming.hint')}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
<div className="space-y-8">
|
||||||
|
<AttentionList pendingPreRegistrations={summaryQuery.data.pendingPreRegistrations} />
|
||||||
|
<PaymentsSection summary={summaryQuery.data} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** La hora actual, refrescada cada `intervalMs`. */
|
||||||
|
function useNow(intervalMs: number): Date {
|
||||||
|
const [now, setNow] = useState(() => new Date())
|
||||||
|
useEffect(() => {
|
||||||
|
const id = window.setInterval(() => setNow(new Date()), intervalMs)
|
||||||
|
return () => window.clearInterval(id)
|
||||||
|
}, [intervalMs])
|
||||||
|
return now
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,45 +1,37 @@
|
|||||||
import { useNavigate } from '@tanstack/react-router'
|
import { Link } from '@tanstack/react-router'
|
||||||
import type { NextClassDto } from '@gruperly/shared'
|
import type { NextClassDto } from '@gruperly/shared'
|
||||||
import { CalendarClock } from 'lucide-react'
|
import { ChevronRight } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Badge, Button } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { formatRelativeDateTime, formatSchedule } from '../../lib/format'
|
import { formatRelativeDateTime, formatSchedule } from '../../lib/format'
|
||||||
|
|
||||||
|
/** El hero cuando hoy ya no queda ninguna clase por dar: la próxima, sea cuando sea. */
|
||||||
export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||||
const navigate = useNavigate()
|
|
||||||
const { t } = useTranslation('home')
|
const { t } = useTranslation('home')
|
||||||
const hasSchedule = (nextClass.days?.length ?? 0) > 0
|
const hasSchedule = (nextClass.days?.length ?? 0) > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="relative overflow-hidden rounded-xl border border-accent/30 bg-surface p-5">
|
<Link
|
||||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
to="/groups/$groupId"
|
||||||
<div className="min-w-0">
|
params={{ groupId: nextClass.groupId }}
|
||||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
className="group block rounded-2xl border border-border bg-surface p-5 transition-colors hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
||||||
{nextClass.isNow ? t('nextClass.now') : t('nextClass.next')}
|
>
|
||||||
</p>
|
<div className="flex items-start justify-between gap-3">
|
||||||
<h2 className="mt-1 truncate text-xl font-bold text-primary">{nextClass.name}</h2>
|
<h2 className="min-w-0 truncate text-xl font-bold text-primary">{nextClass.name}</h2>
|
||||||
{hasSchedule ? (
|
<ChevronRight
|
||||||
<div className="mt-2 flex items-center gap-2 text-sm text-foreground/70">
|
className="mt-1 size-5 shrink-0 text-foreground transition-transform group-hover:translate-x-0.5 motion-reduce:transition-none"
|
||||||
<CalendarClock className="size-4 shrink-0 text-accent" />
|
aria-hidden="true"
|
||||||
<span>{formatSchedule(nextClass.days ?? [], nextClass.time)}</span>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
<p className="mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.9375rem] font-medium text-primary">
|
||||||
</div>
|
<span>{nextClass.isNow ? t('nextClass.now') : t('nextClass.next')}</span>
|
||||||
<div className="flex shrink-0 items-center gap-2">
|
|
||||||
<Badge variant={nextClass.isNow ? 'success' : 'neutral'}>
|
<Badge variant={nextClass.isNow ? 'success' : 'neutral'}>
|
||||||
{nextClass.isNow ? t('nextClass.nowBadge') : formatRelativeDateTime(nextClass.occurrenceAt)}
|
{nextClass.isNow ? t('nextClass.nowBadge') : formatRelativeDateTime(nextClass.occurrenceAt)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</p>
|
||||||
</div>
|
{hasSchedule ? (
|
||||||
<div className="mt-4 flex justify-end border-t border-border pt-3">
|
<p className="mt-1 text-sm text-foreground">{formatSchedule(nextClass.days ?? [], nextClass.time)}</p>
|
||||||
<Button
|
) : null}
|
||||||
variant="outline"
|
</Link>
|
||||||
size="sm"
|
|
||||||
onClick={() => void navigate({ to: `/groups/${nextClass.groupId}` })}
|
|
||||||
>
|
|
||||||
{t('nextClass.seeGroup')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
111
apps/web/src/features/home/PaymentsSection.tsx
Normal file
111
apps/web/src/features/home/PaymentsSection.tsx
Normal 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>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
import { useNavigate } from '@tanstack/react-router'
|
|
||||||
import type { HomeSummaryDto } from '@gruperly/shared'
|
|
||||||
import { UserCheck, Users, Wallet, type LucideIcon } from 'lucide-react'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
|
||||||
import { cn } from '../../lib/utils'
|
|
||||||
import { formatPrice } from '../../lib/format'
|
|
||||||
|
|
||||||
type StatTarget = '/groups' | '/payments'
|
|
||||||
|
|
||||||
/* Three compact tiles in a row, also on mobile: they are reference numbers, not
|
|
||||||
the protagonists of the screen, and stacked they pushed "Próximos cobros"
|
|
||||||
below the fold. The value always goes with its label: the old tile swapped
|
|
||||||
the label for a sub-line and read "0 / 0 por cobrar". */
|
|
||||||
export function SummaryStats({ summary }: { summary: HomeSummaryDto }) {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { t } = useTranslation('home')
|
|
||||||
const { pendingAmount, pendingPayments } = summary.stats
|
|
||||||
const stats: {
|
|
||||||
label: string
|
|
||||||
value: string
|
|
||||||
icon: LucideIcon
|
|
||||||
to: StatTarget
|
|
||||||
}[] = [
|
|
||||||
{
|
|
||||||
label: t('stats.groups', { count: summary.stats.groups }),
|
|
||||||
value: String(summary.stats.groups),
|
|
||||||
icon: Users,
|
|
||||||
to: '/groups',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: pendingPayments > 0 ? t('stats.toCollectCount', { count: pendingPayments }) : t('stats.toCollect'),
|
|
||||||
value: formatPrice(pendingAmount),
|
|
||||||
icon: Wallet,
|
|
||||||
to: '/payments',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('stats.students', { count: summary.stats.attendees }),
|
|
||||||
value: String(summary.stats.attendees),
|
|
||||||
icon: UserCheck,
|
|
||||||
to: '/groups',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-3 gap-2 sm:gap-4">
|
|
||||||
{stats.map((stat) => {
|
|
||||||
const Icon = stat.icon
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={stat.to + stat.label}
|
|
||||||
type="button"
|
|
||||||
onClick={() => void navigate({ to: stat.to })}
|
|
||||||
className={cn(
|
|
||||||
'flex min-w-0 flex-col items-start gap-2 rounded-xl border border-border bg-surface p-3 text-left transition-all sm:flex-row sm:items-center sm:gap-3 sm:p-4',
|
|
||||||
'hover:border-accent/40 active:scale-[0.98] motion-reduce:active:scale-100',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent sm:size-10">
|
|
||||||
<Icon className="size-4 sm:size-5" />
|
|
||||||
</span>
|
|
||||||
<span className="min-w-0 max-w-full">
|
|
||||||
<span className="block truncate text-lg font-bold leading-tight text-primary tabular-nums sm:text-xl">
|
|
||||||
{stat.value}
|
|
||||||
</span>
|
|
||||||
<span className="block truncate text-xs text-foreground/60">{stat.label}</span>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,53 +1,56 @@
|
|||||||
import { Link, useNavigate } from '@tanstack/react-router'
|
import { Link } from '@tanstack/react-router'
|
||||||
import type { ClassTodayDto } from '@gruperly/shared'
|
import type { ClassTodayDto } from '@gruperly/shared'
|
||||||
import { CalendarClock, ChevronRight, ClipboardCheck } from 'lucide-react'
|
import { ChevronRight, ClipboardCheck } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Badge, Button } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { useIntlLocale } from '../../i18n'
|
import { useIntlLocale } from '../../i18n'
|
||||||
|
import { formatClockTime } from '../../lib/format'
|
||||||
|
import { cn } from '../../lib/utils'
|
||||||
|
import type { ClassState } from './day'
|
||||||
|
|
||||||
export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
/** El hero del Inicio: la clase en curso o la próxima de hoy. */
|
||||||
const navigate = useNavigate()
|
export function TodayClassCard({ item, state }: { item: ClassTodayDto; state: ClassState }) {
|
||||||
const { t } = useTranslation('home')
|
const { t } = useTranslation('home')
|
||||||
const locale = useIntlLocale()
|
const locale = useIntlLocale()
|
||||||
const time = new Date(item.startsAt).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' })
|
const time = formatClockTime(item.startsAt, locale)
|
||||||
|
const isLive = state === 'live'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="relative overflow-hidden rounded-xl border border-accent/30 bg-surface p-5">
|
<article className="rounded-2xl border border-accent/30 bg-surface p-5">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
|
||||||
{t('today.label')}
|
|
||||||
</p>
|
|
||||||
{/* Only the done state earns a badge: "Por tomar" repeated what the
|
|
||||||
button below already says. */}
|
|
||||||
{item.hasAttendance ? <Badge variant="success">{t('today.attendanceTaken')}</Badge> : null}
|
|
||||||
</div>
|
|
||||||
<Link
|
<Link
|
||||||
to="/groups/$groupId"
|
to="/groups/$groupId"
|
||||||
params={{ groupId: item.groupId }}
|
params={{ groupId: item.groupId }}
|
||||||
className="group mt-1 flex items-center gap-1 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
className="group -m-1 flex min-w-0 items-center gap-1 rounded-lg p-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
||||||
>
|
>
|
||||||
<h2 className="truncate text-xl font-bold text-primary">{item.groupName}</h2>
|
<h2 className="truncate text-xl font-bold text-primary">{item.groupName}</h2>
|
||||||
<ChevronRight
|
<ChevronRight
|
||||||
className="size-5 shrink-0 text-foreground/40 transition-transform group-hover:translate-x-0.5"
|
className="size-5 shrink-0 text-foreground transition-transform group-hover:translate-x-0.5 motion-reduce:transition-none"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
<div className="mt-2 flex items-center gap-2 text-sm text-foreground/70">
|
{isLive ? <Badge variant="success">{t('today.live')}</Badge> : null}
|
||||||
<CalendarClock className="size-4 shrink-0 text-accent" />
|
|
||||||
<span>{t('today.time', { time })}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-xs text-foreground/60">
|
|
||||||
|
<p className="mt-1.5 text-[0.9375rem] font-medium tabular-nums text-primary">
|
||||||
|
{t('today.time', { time })}
|
||||||
|
</p>
|
||||||
|
<p className="mt-0.5 text-sm text-foreground">
|
||||||
{t('today.enrolled', { count: item.enrolledCount })}
|
{t('today.enrolled', { count: item.enrolledCount })}
|
||||||
{item.availableSlots != null ? ` · ${t('today.slots', { count: item.availableSlots })}` : ''}
|
{item.availableSlots != null ? ` · ${t('today.slots', { count: item.availableSlots })}` : ''}
|
||||||
</p>
|
</p>
|
||||||
<Button
|
|
||||||
variant={item.hasAttendance ? 'outline' : 'primary'}
|
<Link
|
||||||
className="mt-4 w-full"
|
to="/class/$sessionId/attendance"
|
||||||
onClick={() => void navigate({ to: `/class/${item.sessionId}/attendance` })}
|
params={{ sessionId: item.sessionId }}
|
||||||
|
className={cn(
|
||||||
|
'mt-4 inline-flex h-12 w-full items-center justify-center gap-2 rounded-xl px-5 text-sm font-medium transition-[background-color,transform] duration-150 ease-out active:scale-[0.96] motion-reduce:active:scale-100',
|
||||||
|
'bg-accent text-on-accent hover:bg-accent-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface',
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<ClipboardCheck className="size-4" />
|
<ClipboardCheck className="size-4" aria-hidden="true" />
|
||||||
{item.hasAttendance ? t('today.seeAttendance') : t('today.takeAttendance')}
|
{t('today.takeAttendance')}
|
||||||
</Button>
|
</Link>
|
||||||
</article>
|
</article>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
41
apps/web/src/features/home/TodayClassRow.tsx
Normal file
41
apps/web/src/features/home/TodayClassRow.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Link } from '@tanstack/react-router'
|
||||||
|
import type { ClassTodayDto } from '@gruperly/shared'
|
||||||
|
import { Check, ChevronRight } from 'lucide-react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useIntlLocale } from '../../i18n'
|
||||||
|
import { formatClockTime } from '../../lib/format'
|
||||||
|
import { cn } from '../../lib/utils'
|
||||||
|
import type { ClassState } from './day'
|
||||||
|
|
||||||
|
/** Una clase del día fuera del hero: hora, grupo y en qué quedó la asistencia. */
|
||||||
|
export function TodayClassRow({ item, state }: { item: ClassTodayDto; state: ClassState }) {
|
||||||
|
const { t } = useTranslation('home')
|
||||||
|
const locale = useIntlLocale()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<Link
|
||||||
|
to="/class/$sessionId/attendance"
|
||||||
|
params={{ sessionId: item.sessionId }}
|
||||||
|
className="flex min-h-14 items-center gap-3 px-4 py-2.5 transition-colors hover:bg-primary-soft/50 active:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent"
|
||||||
|
>
|
||||||
|
<span className="w-12 shrink-0 text-sm font-semibold tabular-nums text-primary">
|
||||||
|
{formatClockTime(item.startsAt, locale)}
|
||||||
|
</span>
|
||||||
|
<span className="min-w-0 flex-1 truncate text-sm font-medium text-primary">{item.groupName}</span>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'flex shrink-0 items-center gap-1 text-xs font-medium',
|
||||||
|
state === 'taken' && 'text-success',
|
||||||
|
state === 'missed' && 'text-accent-fg',
|
||||||
|
(state === 'upcoming' || state === 'live') && 'text-foreground',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{state === 'taken' ? <Check className="size-3.5" aria-hidden="true" /> : null}
|
||||||
|
{t(`today.state.${state}`)}
|
||||||
|
</span>
|
||||||
|
<ChevronRight className="size-4 shrink-0 text-foreground" aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { Link } from '@tanstack/react-router'
|
||||||
import type { UpcomingPaymentDto } from '@gruperly/shared'
|
import type { UpcomingPaymentDto } from '@gruperly/shared'
|
||||||
|
import { ChevronRight } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Badge } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { formatPrice, formatRelativeDateTime, paymentStatusLabel } from '../../lib/format'
|
import { formatPrice, formatRelativeDateTime, paymentStatusLabel } from '../../lib/format'
|
||||||
@@ -8,19 +10,25 @@ export function UpcomingPaymentRow({ payment }: { payment: UpcomingPaymentDto })
|
|||||||
// Re-render on language change: the labels come from lib/format.
|
// Re-render on language change: the labels come from lib/format.
|
||||||
useTranslation()
|
useTranslation()
|
||||||
return (
|
return (
|
||||||
<li className="flex items-center justify-between gap-3 rounded-xl border border-border bg-surface px-4 py-3">
|
<li>
|
||||||
<div className="min-w-0">
|
<Link
|
||||||
<p className="truncate text-sm font-semibold text-primary">{payment.attendeeName}</p>
|
to="/payments"
|
||||||
<p className="mt-0.5 truncate text-xs text-foreground/60">
|
className="flex min-h-14 items-center gap-3 px-4 py-3 transition-colors hover:bg-primary-soft/50 active:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent"
|
||||||
|
>
|
||||||
|
<span className="min-w-0 flex-1">
|
||||||
|
<span className="block truncate text-sm font-semibold text-primary">{payment.attendeeName}</span>
|
||||||
|
<span className="mt-0.5 block truncate text-xs text-foreground">
|
||||||
{payment.groupName} · {formatRelativeDateTime(payment.dueDate)}
|
{payment.groupName} · {formatRelativeDateTime(payment.dueDate)}
|
||||||
</p>
|
</span>
|
||||||
</div>
|
</span>
|
||||||
<div className="flex shrink-0 items-center gap-2">
|
<span className="flex shrink-0 items-center gap-2">
|
||||||
<span className="text-sm font-semibold text-primary">{formatPrice(payment.amount)}</span>
|
<span className="text-sm font-semibold tabular-nums text-primary">
|
||||||
<Badge variant={PAYMENT_BADGE_VARIANT[payment.status]}>
|
{formatPrice(payment.amount, payment.currency)}
|
||||||
{paymentStatusLabel(payment.status)}
|
</span>
|
||||||
</Badge>
|
<Badge variant={PAYMENT_BADGE_VARIANT[payment.status]}>{paymentStatusLabel(payment.status)}</Badge>
|
||||||
</div>
|
</span>
|
||||||
|
<ChevronRight className="size-4 shrink-0 text-foreground" aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
41
apps/web/src/features/home/day.ts
Normal file
41
apps/web/src/features/home/day.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import type { ClassTodayDto } from '@gruperly/shared'
|
||||||
|
|
||||||
|
/* El día del profe, como funciones puras: qué clase va en el hero y en qué
|
||||||
|
estado está cada una. `HomeView` las usa y `test/home-day.test.ts` las cubre. */
|
||||||
|
|
||||||
|
/** Cuánto después del inicio una clase sin asistencia sigue siendo "la de
|
||||||
|
* ahora". Pasado eso, deja el hero a la próxima y queda en la lista del día
|
||||||
|
* como pendiente. */
|
||||||
|
export const CLASS_ACTIVE_WINDOW_MS = 2 * 60 * 60 * 1000
|
||||||
|
|
||||||
|
export type ClassState =
|
||||||
|
/** La asistencia ya está tomada. */
|
||||||
|
| 'taken'
|
||||||
|
/** Empezó hace menos de `CLASS_ACTIVE_WINDOW_MS` y falta la asistencia. */
|
||||||
|
| 'live'
|
||||||
|
/** Todavía no empezó. */
|
||||||
|
| 'upcoming'
|
||||||
|
/** Ya pasó y nadie tomó asistencia: un olvido, se ofrece tomarla igual. */
|
||||||
|
| 'missed'
|
||||||
|
|
||||||
|
export function classState(item: ClassTodayDto, now: Date): ClassState {
|
||||||
|
if (item.hasAttendance) return 'taken'
|
||||||
|
const startsAt = new Date(item.startsAt).getTime()
|
||||||
|
if (startsAt > now.getTime()) return 'upcoming'
|
||||||
|
return now.getTime() - startsAt <= CLASS_ACTIVE_WINDOW_MS ? 'live' : 'missed'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* El hero es la clase en curso o la próxima de hoy que todavía no tiene
|
||||||
|
* asistencia. El resto del día va en filas compactas, en orden. Sin hero, el
|
||||||
|
* Inicio muestra la próxima clase (que puede ser de otro día).
|
||||||
|
*/
|
||||||
|
export function planDay(classes: readonly ClassTodayDto[], now: Date) {
|
||||||
|
const sorted = [...classes].sort((a, b) => a.startsAt.localeCompare(b.startsAt))
|
||||||
|
const hero =
|
||||||
|
sorted.find((item) => {
|
||||||
|
const state = classState(item, now)
|
||||||
|
return state === 'live' || state === 'upcoming'
|
||||||
|
}) ?? null
|
||||||
|
return { hero, rest: sorted.filter((item) => item !== hero) }
|
||||||
|
}
|
||||||
@@ -1,120 +1,167 @@
|
|||||||
import type { OnboardingGroupDto } from '@gruperly/shared'
|
import type { OnboardingGroupDto } from '@gruperly/shared'
|
||||||
import { useQueryClient } from '@tanstack/react-query'
|
import { COUNTRY_CURRENCY } from '@gruperly/shared'
|
||||||
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import { ArrowRight, CheckCircle2, CreditCard, MessageCircle, Sparkles } from 'lucide-react'
|
import { ArrowRight, Copy, Loader2, Send } from 'lucide-react'
|
||||||
import { Badge, Button } from '../../components/ui'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
import { Button, useToast } from '../../components/ui'
|
||||||
import { useAuth } from '../../context/AuthProvider'
|
import { useAuth } from '../../context/AuthProvider'
|
||||||
|
import { useIntlLocale } from '../../i18n'
|
||||||
|
import { getInviteToken } from '../../lib/api'
|
||||||
import { PLAN_NAMES } from '../billing'
|
import { PLAN_NAMES } from '../billing'
|
||||||
import { useMpStatus } from '../mp'
|
import { useMpStatus } from '../mp'
|
||||||
import { useWhatsappStatus } from '../whatsapp'
|
import { useWhatsappStatus } from '../whatsapp'
|
||||||
import { billingTypeLabel, formatPrice, formatSchedule } from './constants'
|
import { billingTypeLabel, formatPrice, formatSchedule } from './constants'
|
||||||
|
import { MessagePreview } from './MessagePreview'
|
||||||
import { useOnboarding } from './OnboardingProvider'
|
import { useOnboarding } from './OnboardingProvider'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
|
||||||
|
|
||||||
type ConfirmationStepProps = {
|
type ConfirmationStepProps = {
|
||||||
group: OnboardingGroupDto
|
group: OnboardingGroupDto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* El cierre del alta. El grupo ya existe, y el momento de valor es que llegue el
|
||||||
|
* primer miembro: por eso la acción principal es mandar el link de invitación
|
||||||
|
* (con el mensaje real que se comparte), y lo que queda para Ajustes se dice en
|
||||||
|
* una sola línea.
|
||||||
|
*/
|
||||||
export function ConfirmationStep({ group }: ConfirmationStepProps) {
|
export function ConfirmationStep({ group }: ConfirmationStepProps) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { t } = useTranslation(['onboarding', 'common', 'groups'])
|
const { t } = useTranslation(['onboarding', 'common', 'groupDetail'])
|
||||||
|
const locale = useIntlLocale()
|
||||||
|
const toast = useToast()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const { refresh } = useAuth()
|
const { refresh } = useAuth()
|
||||||
const statusQuery = useMpStatus()
|
const { selectedPlan, country } = useOnboarding()
|
||||||
const isMpConnected = statusQuery.data?.status === 'active'
|
const isMpConnected = useMpStatus().data?.status === 'active'
|
||||||
const whatsappQuery = useWhatsappStatus()
|
const isWhatsappConnected = useWhatsappStatus().data?.status === 'active'
|
||||||
const isWhatsappConnected = whatsappQuery.data?.status === 'active'
|
|
||||||
const { selectedPlan } = useOnboarding()
|
|
||||||
|
|
||||||
const goToDashboard = () => {
|
const inviteQuery = useQuery({
|
||||||
// Revalidates the cache (onboarding state, session, groups) before redirecting.
|
queryKey: ['invite-token', group.id],
|
||||||
|
queryFn: () => getInviteToken(group.id),
|
||||||
|
})
|
||||||
|
const inviteUrl = inviteQuery.data?.inviteUrl
|
||||||
|
const shareMessage = inviteUrl ? t('groupDetail:invite.message', { group: group.name, url: inviteUrl }) : ''
|
||||||
|
|
||||||
|
const copyLink = async () => {
|
||||||
|
if (!inviteUrl) return
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(inviteUrl)
|
||||||
|
toast.success(t('groupDetail:invite.linkCopied'))
|
||||||
|
} catch {
|
||||||
|
toast.error(t('groupDetail:invite.copyError'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const goHome = () => {
|
||||||
|
// Revalida todo (estado del alta, sesión, grupos) antes de salir.
|
||||||
void queryClient.invalidateQueries()
|
void queryClient.invalidateQueries()
|
||||||
void refresh()
|
void refresh()
|
||||||
void navigate({ to: '/' })
|
void navigate({ to: '/' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isMonthly = group.billingType === 'MONTHLY'
|
||||||
|
const price = formatPrice(group.price, COUNTRY_CURRENCY[country])
|
||||||
|
const statusLine =
|
||||||
|
selectedPlan === 'FREE'
|
||||||
|
? t('done.statusFree', { plan: PLAN_NAMES.FREE })
|
||||||
|
: isMpConnected && isWhatsappConnected
|
||||||
|
? t('done.statusAllSet')
|
||||||
|
: !isMpConnected && !isWhatsappConnected
|
||||||
|
? t('done.statusPendingBoth')
|
||||||
|
: !isMpConnected
|
||||||
|
? t('done.statusPendingMp')
|
||||||
|
: t('done.statusPendingWa')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6">
|
<section className="space-y-7">
|
||||||
<header className="space-y-2 text-center">
|
<header className="space-y-2">
|
||||||
<span className="mx-auto flex size-14 items-center justify-center rounded-2xl bg-success-soft">
|
<h2 className="text-[1.75rem] font-bold leading-tight tracking-tight text-primary text-balance">
|
||||||
<CheckCircle2 className="size-7 text-success" />
|
{t('done.title')}
|
||||||
</span>
|
</h2>
|
||||||
<h2 className="text-2xl font-bold text-primary">{t('done.title')}</h2>
|
<p className="text-[0.9375rem] text-foreground/70 text-pretty">{t('done.description')}</p>
|
||||||
<p className="text-sm text-foreground/60">
|
|
||||||
{t('done.description')}
|
|
||||||
</p>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div className="rounded-xl border border-border bg-surface p-5">
|
<div className="space-y-3">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<MessagePreview
|
||||||
<div className="min-w-0">
|
caption={t('done.previewCaption')}
|
||||||
<h3 className="truncate text-base font-semibold text-primary">{group.name}</h3>
|
contactName={t('done.previewContact')}
|
||||||
<p className="mt-0.5 text-sm text-foreground/60">
|
time={new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(new Date())}
|
||||||
{formatSchedule(group.days ?? [], group.time)}
|
>
|
||||||
</p>
|
<Trans
|
||||||
</div>
|
t={t}
|
||||||
<Badge variant="success">{t('done.active')}</Badge>
|
i18nKey="groupDetail:invite.messagePreview"
|
||||||
</div>
|
values={{ group: group.name }}
|
||||||
|
components={{ strong: <strong className="font-semibold" /> }}
|
||||||
|
/>
|
||||||
|
{inviteUrl ? (
|
||||||
|
<span className="font-medium text-accent underline underline-offset-2">{inviteUrl}</span>
|
||||||
|
) : inviteQuery.isError ? null : (
|
||||||
|
<span className="inline-flex items-center gap-1.5 text-foreground/50">
|
||||||
|
<Loader2 aria-hidden="true" className="size-3.5 animate-spin" />
|
||||||
|
{t('done.linkLoading')}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</MessagePreview>
|
||||||
|
|
||||||
<dl className="mt-4 divide-y divide-border text-sm">
|
{inviteQuery.isError ? (
|
||||||
<div className="flex items-center justify-between py-2.5">
|
<div role="alert" className="flex items-center justify-between gap-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
<dt className="text-foreground/60">{t('done.price')}</dt>
|
<span>{t('done.linkError')}</span>
|
||||||
<dd className="font-semibold text-primary">
|
<Button variant="outline" size="sm" onClick={() => void inviteQuery.refetch()}>
|
||||||
{formatPrice(group.price)}
|
{t('common:actions.retry')}
|
||||||
{group.billingType ? ` · ${billingTypeLabel(group.billingType)}` : ''}
|
</Button>
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center justify-between py-2.5">
|
|
||||||
<dt className="text-foreground/60">{t('done.capacity')}</dt>
|
|
||||||
<dd className="font-semibold text-primary">{group.capacity != null ? t('done.capacityValue', { count: group.capacity }) : '—'}</dd>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center justify-between py-2.5">
|
|
||||||
<dt className="text-foreground/60">{t('done.dueDay')}</dt>
|
|
||||||
<dd className="font-semibold text-primary">{group.dueDay != null ? t('done.dueDayValue', { day: group.dueDay }) : '—'}</dd>
|
|
||||||
</div>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{selectedPlan ? (
|
|
||||||
<div className="flex items-center gap-2 rounded-xl bg-primary-soft px-4 py-3">
|
|
||||||
<Sparkles className="size-4 shrink-0 text-accent" />
|
|
||||||
<p className="text-xs text-primary">
|
|
||||||
<Trans t={t} i18nKey="done.plan" values={{ plan: PLAN_NAMES[selectedPlan] }} components={{ strong: <span className="font-semibold" /> }} />
|
|
||||||
{selectedPlan === 'FREE' ? t('done.freeHint') : ''}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* Con Free no se cobra ni se automatiza: esos avisos son solo de Pro. */}
|
<div className="flex flex-col gap-2.5 sm:flex-row">
|
||||||
{selectedPlan === 'FREE' ? null : (
|
{/* Un <a> y no un botón con window.open: en iOS standalone es lo que
|
||||||
|
abre la app de WhatsApp sin bloqueos de pop-up. */}
|
||||||
|
<a
|
||||||
|
href={shareMessage ? `https://wa.me/?text=${encodeURIComponent(shareMessage)}` : undefined}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
aria-disabled={!shareMessage}
|
||||||
|
className="inline-flex h-12 items-center justify-center gap-2 rounded-xl bg-accent px-5 sm:flex-1 text-sm font-medium text-on-accent transition-[background-color,transform] duration-150 ease-out hover:bg-accent-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent active:scale-[0.96] aria-disabled:pointer-events-none aria-disabled:opacity-50 motion-reduce:active:scale-100"
|
||||||
|
>
|
||||||
|
<Send aria-hidden="true" className="size-4" />
|
||||||
|
{t('done.share')}
|
||||||
|
</a>
|
||||||
|
<Button variant="outline" size="lg" className="sm:flex-1" disabled={!inviteUrl} onClick={() => void copyLink()}>
|
||||||
|
<Copy aria-hidden="true" className="size-4" />
|
||||||
|
{t('done.copyLink')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-xl border border-border bg-surface px-4 py-3.5">
|
||||||
|
<p className="truncate text-sm font-semibold text-primary">{group.name}</p>
|
||||||
|
<p className="mt-0.5 text-sm text-foreground/60">{formatSchedule(group.days ?? [], group.time)}</p>
|
||||||
|
<dl className="mt-3 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm">
|
||||||
|
<dt className="text-foreground/60">{t('done.price')}</dt>
|
||||||
|
<dd className="text-right font-medium tabular-nums text-primary">
|
||||||
|
{price}
|
||||||
|
{group.billingType ? ` · ${billingTypeLabel(group.billingType)}` : ''}
|
||||||
|
</dd>
|
||||||
|
<dt className="text-foreground/60">{t('done.capacity')}</dt>
|
||||||
|
<dd className="text-right font-medium tabular-nums text-primary">
|
||||||
|
{group.capacity != null ? t('done.capacityValue', { count: group.capacity }) : '—'}
|
||||||
|
</dd>
|
||||||
|
{isMonthly && group.dueDay != null ? (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center gap-2 rounded-xl bg-primary-soft px-4 py-3">
|
<dt className="text-foreground/60">{t('done.dueDay')}</dt>
|
||||||
<CreditCard className="size-4 shrink-0 text-accent" />
|
<dd className="text-right font-medium tabular-nums text-primary">
|
||||||
<p className="text-xs text-primary">
|
{t('done.dueDayValue', { day: group.dueDay })}
|
||||||
{isMpConnected ? (
|
</dd>
|
||||||
<Trans t={t} i18nKey="done.mpConnected" components={{ strong: <span className="font-semibold" /> }} />
|
|
||||||
) : (
|
|
||||||
<Trans t={t} i18nKey="done.mpPending" components={{ strong: <span className="font-semibold" /> }} />
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-2 rounded-xl bg-primary-soft px-4 py-3">
|
|
||||||
<MessageCircle className="size-4 shrink-0 text-accent" />
|
|
||||||
<p className="text-xs text-primary">
|
|
||||||
{isWhatsappConnected ? (
|
|
||||||
t('done.waConnected')
|
|
||||||
) : (
|
|
||||||
<Trans t={t} i18nKey="done.waPending" components={{ strong: <span className="font-semibold" /> }} />
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)}
|
) : null}
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button variant="primary" className="w-full" onClick={goToDashboard}>
|
<p className="text-sm text-foreground/60 text-pretty">{statusLine}</p>
|
||||||
{t('done.goToPanel')}
|
|
||||||
<ArrowRight className="size-4" />
|
<Button variant="ghost" size="lg" className="w-full" onClick={goHome}>
|
||||||
|
{t('done.goHome')}
|
||||||
|
<ArrowRight aria-hidden="true" className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ export function CountryStep({ onNext, onBack }: CountryStepProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button variant="outline" onClick={onBack} className="hidden lg:inline-flex">
|
<Button variant="outline" size="lg" onClick={onBack}>
|
||||||
<ArrowLeft className="size-4" />
|
<ArrowLeft className="size-4" />
|
||||||
{t('common:actions.back')}
|
{t('common:actions.back')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" className="flex-1 lg:flex-none" onClick={() => onNext()}>
|
<Button variant="primary" size="lg" className="flex-1" onClick={() => onNext()}>
|
||||||
{t('continue')}
|
{t('continue')}
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import type { CreateFirstGroup, OnboardingGroupDto } from '@gruperly/shared'
|
import type { CreateFirstGroup, OnboardingGroupDto } from '@gruperly/shared'
|
||||||
import { useMutation } from '@tanstack/react-query'
|
import { useMutation } from '@tanstack/react-query'
|
||||||
import { createFirstGroup } from '../../lib/api'
|
import { ArrowLeft } from 'lucide-react'
|
||||||
|
import { Button } from '../../components/ui'
|
||||||
|
import { ApiError, createFirstGroup } from '../../lib/api'
|
||||||
import { errorMessage } from '../../i18n'
|
import { errorMessage } from '../../i18n'
|
||||||
import { GroupForm } from '../groups/GroupForm'
|
import { GroupForm } from '../groups/GroupForm'
|
||||||
import { useOnboarding } from './OnboardingProvider'
|
import { useOnboarding } from './OnboardingProvider'
|
||||||
@@ -12,12 +14,15 @@ type FirstGroupStepProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function FirstGroupStep({ onBack, onCompleted }: FirstGroupStepProps) {
|
export function FirstGroupStep({ onBack, onCompleted }: FirstGroupStepProps) {
|
||||||
const { country } = useOnboarding()
|
const { country, goTo } = useOnboarding()
|
||||||
const { t } = useTranslation(['onboarding', 'common', 'groups'])
|
const { t } = useTranslation(['onboarding', 'common', 'groups'])
|
||||||
const create = useMutation({
|
const create = useMutation({
|
||||||
mutationFn: (values: CreateFirstGroup) => createFirstGroup(values),
|
mutationFn: (values: CreateFirstGroup) => createFirstGroup(values),
|
||||||
onSuccess: (result) => onCompleted(result.group),
|
onSuccess: (result) => onCompleted(result.group),
|
||||||
})
|
})
|
||||||
|
// Sin plan elegido el backend no deja crear el grupo: se ofrece volver a Plan.
|
||||||
|
const needsPlan =
|
||||||
|
create.error instanceof ApiError && create.error.problem?.code === 'plan_not_selected'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GroupForm
|
<GroupForm
|
||||||
@@ -29,6 +34,14 @@ export function FirstGroupStep({ onBack, onCompleted }: FirstGroupStepProps) {
|
|||||||
errorMessage={
|
errorMessage={
|
||||||
create.isError ? errorMessage(create.error, t('groups:create.error')) : null
|
create.isError ? errorMessage(create.error, t('groups:create.error')) : null
|
||||||
}
|
}
|
||||||
|
errorAction={
|
||||||
|
needsPlan ? (
|
||||||
|
<Button variant="outline" size="sm" onClick={() => goTo('plan')}>
|
||||||
|
<ArrowLeft className="size-4" />
|
||||||
|
{t('group.choosePlan')}
|
||||||
|
</Button>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
onSubmit={(values) => create.mutate(values)}
|
onSubmit={(values) => create.mutate(values)}
|
||||||
onBack={onBack}
|
onBack={onBack}
|
||||||
/>
|
/>
|
||||||
|
|||||||
55
apps/web/src/features/onboarding/MessagePreview.tsx
Normal file
55
apps/web/src/features/onboarding/MessagePreview.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { CheckCheck } from 'lucide-react'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
import { cn } from '../../lib/utils'
|
||||||
|
|
||||||
|
type MessagePreviewProps = {
|
||||||
|
/** A quién le llega el mensaje (la cabecera del chat). */
|
||||||
|
contactName: string
|
||||||
|
/** Una línea chica arriba del chat que dice qué se está viendo. */
|
||||||
|
caption: string
|
||||||
|
/** La hora del mensaje, ya formateada. */
|
||||||
|
time: string
|
||||||
|
children: ReactNode
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vista previa de un mensaje tal como lo recibe el miembro en su chat.
|
||||||
|
*
|
||||||
|
* Es lo que hace reconocible al onboarding: en vez de prometer "cobrá al
|
||||||
|
* instante", muestra el mensaje real que sale desde el número del profe. La
|
||||||
|
* burbuja usa los tokens de la app (no imita la marca de ningún chat) y el
|
||||||
|
* texto lo arma quien la usa, con los mismos datos que manda el backend.
|
||||||
|
*/
|
||||||
|
export function MessagePreview({ contactName, caption, time, children, className }: MessagePreviewProps) {
|
||||||
|
const initial = contactName.trim().charAt(0).toUpperCase()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<figure className={cn('space-y-2', className)}>
|
||||||
|
<figcaption className="text-sm text-foreground/60">{caption}</figcaption>
|
||||||
|
<div className="overflow-hidden rounded-2xl border border-border bg-background">
|
||||||
|
<div className="flex items-center gap-2.5 border-b border-border bg-surface px-3.5 py-2.5">
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className="flex size-8 items-center justify-center rounded-full bg-primary-soft text-sm font-semibold text-primary"
|
||||||
|
>
|
||||||
|
{initial}
|
||||||
|
</span>
|
||||||
|
<span className="truncate text-sm font-semibold text-primary">{contactName}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="px-3.5 py-4">
|
||||||
|
<div className="ml-auto max-w-[88%] rounded-2xl rounded-tr-md bg-accent-soft px-3.5 py-2.5 shadow-[0_1px_2px_rgb(0_0_0/0.06)]">
|
||||||
|
<div className="whitespace-pre-line text-[0.9375rem] leading-snug text-primary [overflow-wrap:anywhere]">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
<p className="mt-1 flex items-center justify-end gap-1 text-[0.6875rem] text-foreground/50">
|
||||||
|
<span className="tabular-nums">{time}</span>
|
||||||
|
<CheckCheck aria-hidden="true" className="size-3.5 text-accent" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</figure>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { CountryCode, OnboardingGroupDto, OnboardingStatusDto, Plan } from '@gruperly/shared'
|
import type { CountryCode, OnboardingGroupDto, OnboardingStatusDto, Plan } from '@gruperly/shared'
|
||||||
import { DEFAULT_COUNTRY } from '@gruperly/shared'
|
import { countryCodeSchema, DEFAULT_COUNTRY } from '@gruperly/shared'
|
||||||
import type { UseQueryResult } from '@tanstack/react-query'
|
import type { UseQueryResult } from '@tanstack/react-query'
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useNavigate, useSearch } from '@tanstack/react-router'
|
import { useNavigate, useSearch } from '@tanstack/react-router'
|
||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
import { createContext, useContext, useEffect, useMemo, useState } from 'react'
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
|
||||||
import { useAuth } from '../../context/AuthProvider'
|
import { useAuth } from '../../context/AuthProvider'
|
||||||
import { getOnboardingStatus } from '../../lib/api'
|
import { getOnboardingStatus } from '../../lib/api'
|
||||||
import { billingStatusQueryKey } from '../billing'
|
import { billingStatusQueryKey } from '../billing'
|
||||||
@@ -12,12 +12,12 @@ import type { MpCallbackFeedback } from '../mp'
|
|||||||
import { mpStatusQueryKey, readMpCallbackFeedback } from '../mp'
|
import { mpStatusQueryKey, readMpCallbackFeedback } from '../mp'
|
||||||
import type { WhatsappCallbackFeedback } from '../whatsapp'
|
import type { WhatsappCallbackFeedback } from '../whatsapp'
|
||||||
import { readWhatsappCallbackFeedback, whatsappStatusQueryKey } from '../whatsapp'
|
import { readWhatsappCallbackFeedback, whatsappStatusQueryKey } from '../whatsapp'
|
||||||
import { type OnboardingStepId, resumeStep, visibleSteps } from './steps'
|
import { effectiveStep, type OnboardingStepId, parseStep, resumeStep, visibleSteps } from './steps'
|
||||||
|
|
||||||
type OnboardingContextValue = {
|
type OnboardingContextValue = {
|
||||||
step: OnboardingStepId
|
step: OnboardingStepId
|
||||||
steps: OnboardingStepId[]
|
steps: OnboardingStepId[]
|
||||||
goTo: (step: OnboardingStepId) => void
|
goTo: (step: OnboardingStepId, options?: { replace?: boolean }) => void
|
||||||
goNext: () => void
|
goNext: () => void
|
||||||
goBack: () => void
|
goBack: () => void
|
||||||
/** El país del profesor; define la moneda de los links de cobro y el precio de Pro. */
|
/** El país del profesor; define la moneda de los links de cobro y el precio de Pro. */
|
||||||
@@ -39,13 +39,34 @@ type OnboardingContextValue = {
|
|||||||
|
|
||||||
const OnboardingContext = createContext<OnboardingContextValue | null>(null)
|
const OnboardingContext = createContext<OnboardingContextValue | null>(null)
|
||||||
|
|
||||||
|
/* El país elegido se guarda en el servidor recién junto con el plan. Mientras
|
||||||
|
tanto vive en sessionStorage: con el paso en la URL, recargar en "Plan" ya no
|
||||||
|
vuelve a la bienvenida y no tiene que perder el país. */
|
||||||
|
const COUNTRY_STORAGE_KEY = 'onboarding-country'
|
||||||
|
|
||||||
|
function readStoredCountry(): CountryCode | null {
|
||||||
|
try {
|
||||||
|
const parsed = countryCodeSchema.safeParse(sessionStorage.getItem(COUNTRY_STORAGE_KEY))
|
||||||
|
return parsed.success ? parsed.data : null
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function storeCountry(country: CountryCode) {
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem(COUNTRY_STORAGE_KEY, country)
|
||||||
|
} catch {
|
||||||
|
// Sin storage (modo privado, bloqueado): el país vive solo en memoria.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function OnboardingProvider({ children }: { children: ReactNode }) {
|
export function OnboardingProvider({ children }: { children: ReactNode }) {
|
||||||
const { user } = useAuth()
|
const { user } = useAuth()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const search = useSearch({ from: '/onboarding' })
|
const search = useSearch({ from: '/onboarding' })
|
||||||
const [step, setStep] = useState<OnboardingStepId>('welcome')
|
const [country, setCountryState] = useState<CountryCode>(() => readStoredCountry() ?? DEFAULT_COUNTRY)
|
||||||
const [country, setCountry] = useState<CountryCode>(DEFAULT_COUNTRY)
|
|
||||||
const [selectedPlan, setSelectedPlan] = useState<Plan | null>(null)
|
const [selectedPlan, setSelectedPlan] = useState<Plan | null>(null)
|
||||||
const [mpFeedback, setMpFeedback] = useState<MpCallbackFeedback | null>(null)
|
const [mpFeedback, setMpFeedback] = useState<MpCallbackFeedback | null>(null)
|
||||||
const [waFeedback, setWaFeedback] = useState<WhatsappCallbackFeedback | null>(null)
|
const [waFeedback, setWaFeedback] = useState<WhatsappCallbackFeedback | null>(null)
|
||||||
@@ -58,16 +79,50 @@ export function OnboardingProvider({ children }: { children: ReactNode }) {
|
|||||||
enabled: !!user,
|
enabled: !!user,
|
||||||
})
|
})
|
||||||
|
|
||||||
const steps = useMemo(() => visibleSteps(selectedPlan), [selectedPlan])
|
const setCountry = useCallback((next: CountryCode) => {
|
||||||
|
setCountryState(next)
|
||||||
|
storeCountry(next)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
/* El paso vive en `?step=`: cada avance es una entrada del historial, así el
|
||||||
|
gesto de back del dispositivo retrocede un paso en vez de salir del alta.
|
||||||
|
Lo que pide la URL pasa por `effectiveStep`, que no deja saltear el plan ni
|
||||||
|
volver al formulario con el grupo ya creado. */
|
||||||
|
const plan = selectedPlan ?? statusQuery.data?.selectedPlan ?? null
|
||||||
|
const requestedStep = parseStep(search.step) ?? 'welcome'
|
||||||
|
const step = effectiveStep(requestedStep, { plan, hasCreatedGroup: createdGroup !== null })
|
||||||
|
const steps = useMemo(() => visibleSteps(plan), [plan])
|
||||||
|
|
||||||
|
const goTo = useCallback(
|
||||||
|
(target: OnboardingStepId, options?: { replace?: boolean }) => {
|
||||||
|
void navigate({
|
||||||
|
to: '/onboarding',
|
||||||
|
search: target === 'welcome' ? {} : { step: target },
|
||||||
|
replace: options?.replace ?? false,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[navigate],
|
||||||
|
)
|
||||||
const goNext = () => {
|
const goNext = () => {
|
||||||
const next = steps[steps.indexOf(step) + 1]
|
const next = steps[steps.indexOf(step) + 1]
|
||||||
if (next) setStep(next)
|
if (next) goTo(next)
|
||||||
}
|
}
|
||||||
|
// Reemplaza en vez de apilar: así el back del dispositivo después de "Volver"
|
||||||
|
// no rebota al paso del que se salió.
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
const previous = steps[steps.indexOf(step) - 1]
|
const previous = steps[steps.indexOf(step) - 1]
|
||||||
if (previous) setStep(previous)
|
if (previous) goTo(previous, { replace: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si la URL pedía un paso que no corresponde, se corrige sin apilar historial.
|
||||||
|
// Solo con el estado del servidor ya cargado: antes no se sabe el plan.
|
||||||
|
const hasStatus = statusQuery.data !== undefined
|
||||||
|
useEffect(() => {
|
||||||
|
if (hasStatus && search.step !== undefined && requestedStep !== step) {
|
||||||
|
goTo(step, { replace: true })
|
||||||
|
}
|
||||||
|
}, [hasStatus, search.step, requestedStep, step, goTo])
|
||||||
|
|
||||||
const callbackFeedback = useMemo(
|
const callbackFeedback = useMemo(
|
||||||
() => readMpCallbackFeedback(search.mp, search.reason),
|
() => readMpCallbackFeedback(search.mp, search.reason),
|
||||||
[search.mp, search.reason],
|
[search.mp, search.reason],
|
||||||
@@ -81,15 +136,11 @@ export function OnboardingProvider({ children }: { children: ReactNode }) {
|
|||||||
// "cambiar de cuenta" y el resumen final ya sabe que hay cuenta.
|
// "cambiar de cuenta" y el resumen final ya sabe que hay cuenta.
|
||||||
void queryClient.invalidateQueries({ queryKey: mpStatusQueryKey })
|
void queryClient.invalidateQueries({ queryKey: mpStatusQueryKey })
|
||||||
void queryClient.invalidateQueries({ queryKey: ['onboarding', 'status'] })
|
void queryClient.invalidateQueries({ queryKey: ['onboarding', 'status'] })
|
||||||
// Vuelve al paso de Cobros, que es de donde salió el flujo. Setearlo siempre
|
// Vuelve al paso de Cobros, que es de donde salió el flujo, y limpia los
|
||||||
// (y no solo desde el primer paso) evita que un `?mp=` que llega con el
|
// parámetros: si no, recargar volvería a mostrar el aviso de la vinculación
|
||||||
// proveedor recién montado salte al resumen sin mostrar la confirmación.
|
// vieja.
|
||||||
setStep('payment')
|
goTo('payment', { replace: true })
|
||||||
|
}, [callbackFeedback, goTo, queryClient])
|
||||||
// Se limpian los parámetros de la URL: si no, recargar la página volvería a
|
|
||||||
// mostrar el aviso de la vinculación vieja.
|
|
||||||
void navigate({ to: '/onboarding', search: {}, replace: true })
|
|
||||||
}, [callbackFeedback, navigate, queryClient])
|
|
||||||
|
|
||||||
const whatsappCallbackFeedback = useMemo(
|
const whatsappCallbackFeedback = useMemo(
|
||||||
() => readWhatsappCallbackFeedback(search.wa, search.reason),
|
() => readWhatsappCallbackFeedback(search.wa, search.reason),
|
||||||
@@ -104,9 +155,8 @@ export function OnboardingProvider({ children }: { children: ReactNode }) {
|
|||||||
setWaFeedback(whatsappCallbackFeedback)
|
setWaFeedback(whatsappCallbackFeedback)
|
||||||
void queryClient.invalidateQueries({ queryKey: whatsappStatusQueryKey })
|
void queryClient.invalidateQueries({ queryKey: whatsappStatusQueryKey })
|
||||||
void queryClient.invalidateQueries({ queryKey: ['onboarding', 'status'] })
|
void queryClient.invalidateQueries({ queryKey: ['onboarding', 'status'] })
|
||||||
setStep('whatsapp')
|
goTo('whatsapp', { replace: true })
|
||||||
void navigate({ to: '/onboarding', search: {}, replace: true })
|
}, [whatsappCallbackFeedback, goTo, queryClient])
|
||||||
}, [whatsappCallbackFeedback, navigate, queryClient])
|
|
||||||
|
|
||||||
// Vuelta de Mercado Pago tras la suscripción a Pro: el paso Plan muestra si
|
// Vuelta de Mercado Pago tras la suscripción a Pro: el paso Plan muestra si
|
||||||
// quedó activa o se sigue procesando (y deja seguir igual).
|
// quedó activa o se sigue procesando (y deja seguir igual).
|
||||||
@@ -117,9 +167,8 @@ export function OnboardingProvider({ children }: { children: ReactNode }) {
|
|||||||
setSelectedPlan('PRO')
|
setSelectedPlan('PRO')
|
||||||
void queryClient.invalidateQueries({ queryKey: billingStatusQueryKey })
|
void queryClient.invalidateQueries({ queryKey: billingStatusQueryKey })
|
||||||
void queryClient.invalidateQueries({ queryKey: ['onboarding', 'status'] })
|
void queryClient.invalidateQueries({ queryKey: ['onboarding', 'status'] })
|
||||||
setStep('plan')
|
goTo('plan', { replace: true })
|
||||||
void navigate({ to: '/onboarding', search: {}, replace: true })
|
}, [search.sub, goTo, queryClient])
|
||||||
}, [search.sub, navigate, queryClient])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const status = statusQuery.data
|
const status = statusQuery.data
|
||||||
@@ -128,18 +177,24 @@ export function OnboardingProvider({ children }: { children: ReactNode }) {
|
|||||||
// país y el plan elegidos se recuperan del servidor.
|
// país y el plan elegidos se recuperan del servidor.
|
||||||
if (status.country) setCountry(status.country)
|
if (status.country) setCountry(status.country)
|
||||||
if (status.selectedPlan) setSelectedPlan((current) => current ?? status.selectedPlan)
|
if (status.selectedPlan) setSelectedPlan((current) => current ?? status.selectedPlan)
|
||||||
|
}, [statusQuery.data, setCountry])
|
||||||
|
|
||||||
// Retomar donde quedó, solo si recién arranca (desde la bienvenida).
|
// Retomar donde quedó, solo si la URL no pide un paso ni vuelve de un redirect
|
||||||
|
// (esos ya llevan al paso que corresponde).
|
||||||
|
const isReturningFromRedirect = Boolean(search.mp || search.wa || search.sub)
|
||||||
|
useEffect(() => {
|
||||||
|
const status = statusQuery.data
|
||||||
|
if (!status || search.step !== undefined || isReturningFromRedirect) return
|
||||||
const resumeAt = resumeStep(status)
|
const resumeAt = resumeStep(status)
|
||||||
if (resumeAt) setStep((current) => (current === 'welcome' ? resumeAt : current))
|
if (resumeAt) goTo(resumeAt, { replace: true })
|
||||||
}, [statusQuery.data])
|
}, [statusQuery.data, search.step, isReturningFromRedirect, goTo])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OnboardingContext.Provider
|
<OnboardingContext.Provider
|
||||||
value={{
|
value={{
|
||||||
step,
|
step,
|
||||||
steps,
|
steps,
|
||||||
goTo: setStep,
|
goTo,
|
||||||
goNext,
|
goNext,
|
||||||
goBack,
|
goBack,
|
||||||
country,
|
country,
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import { Loader2 } from 'lucide-react'
|
import { Loader2 } from 'lucide-react'
|
||||||
import { useEffect } from 'react'
|
import { useEffect, useLayoutEffect, useRef } from 'react'
|
||||||
import { Logo, LogoIcon } from '../../components/brand'
|
import { Logo, LogoIcon } from '../../components/brand'
|
||||||
import { Button } from '../../components/ui'
|
import { Button } from '../../components/ui'
|
||||||
|
import { cn } from '../../lib/utils'
|
||||||
import { useAuth } from '../../context/AuthProvider'
|
import { useAuth } from '../../context/AuthProvider'
|
||||||
import { ConfirmationStep } from './ConfirmationStep'
|
import { ConfirmationStep } from './ConfirmationStep'
|
||||||
import { CountryStep } from './CountryStep'
|
import { CountryStep } from './CountryStep'
|
||||||
@@ -32,6 +33,32 @@ export function OnboardingView() {
|
|||||||
statusQuery,
|
statusQuery,
|
||||||
} = useOnboarding()
|
} = useOnboarding()
|
||||||
|
|
||||||
|
/* Al cambiar de paso: se sabe hacia dónde se movió (para la animación) y el
|
||||||
|
foco pasa al título del paso nuevo, así el lector de pantalla lo anuncia y
|
||||||
|
el teclado sigue desde ahí. Si el paso ya enfocó su primer campo
|
||||||
|
(`autoFocus`), se respeta. */
|
||||||
|
const stepIndex = steps.indexOf(step)
|
||||||
|
const previousIndex = useRef(stepIndex)
|
||||||
|
const direction = stepIndex < previousIndex.current ? 'back' : 'forward'
|
||||||
|
const stepContainer = useRef<HTMLDivElement>(null)
|
||||||
|
const isFirstStep = useRef(true)
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
previousIndex.current = stepIndex
|
||||||
|
}, [stepIndex])
|
||||||
|
useEffect(() => {
|
||||||
|
if (isFirstStep.current) {
|
||||||
|
isFirstStep.current = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.scrollTo({ top: 0 })
|
||||||
|
const container = stepContainer.current
|
||||||
|
if (!container || container.contains(document.activeElement)) return
|
||||||
|
const heading = container.querySelector<HTMLElement>('h1, h2')
|
||||||
|
if (!heading) return
|
||||||
|
heading.tabIndex = -1
|
||||||
|
heading.focus({ preventScroll: true })
|
||||||
|
}, [step])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (statusQuery.data?.completed) {
|
if (statusQuery.data?.completed) {
|
||||||
void navigate({ to: '/' })
|
void navigate({ to: '/' })
|
||||||
@@ -53,7 +80,7 @@ export function OnboardingView() {
|
|||||||
<span className="mx-auto flex size-14 items-center justify-center rounded-2xl bg-accent-soft">
|
<span className="mx-auto flex size-14 items-center justify-center rounded-2xl bg-accent-soft">
|
||||||
<LogoIcon className="size-8" />
|
<LogoIcon className="size-8" />
|
||||||
</span>
|
</span>
|
||||||
<h1 className="text-2xl font-bold text-primary">{t('signedOut.title')}</h1>
|
<h1 className="text-2xl font-bold text-primary text-balance">{t('signedOut.title')}</h1>
|
||||||
<p className="text-sm text-foreground/60">
|
<p className="text-sm text-foreground/60">
|
||||||
{t('signedOut.description')}
|
{t('signedOut.description')}
|
||||||
</p>
|
</p>
|
||||||
@@ -80,7 +107,7 @@ export function OnboardingView() {
|
|||||||
const firstName = user.name?.trim().split(/\s+/)[0] ?? t('fallbackName')
|
const firstName = user.name?.trim().split(/\s+/)[0] ?? t('fallbackName')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="mx-auto flex min-h-dvh w-full max-w-md flex-col px-4 pb-12 pt-8 sm:pt-12">
|
<main className="mx-auto flex min-h-dvh w-full max-w-md flex-col px-4 pt-8 pb-[calc(3rem+env(safe-area-inset-bottom))] sm:pt-12">
|
||||||
<header className="mb-6 flex items-center justify-center">
|
<header className="mb-6 flex items-center justify-center">
|
||||||
<Logo className="h-6" />
|
<Logo className="h-6" />
|
||||||
</header>
|
</header>
|
||||||
@@ -89,10 +116,17 @@ export function OnboardingView() {
|
|||||||
los pasos que se van a recorrer. */}
|
los pasos que se van a recorrer. */}
|
||||||
<Stepper
|
<Stepper
|
||||||
steps={steps.map((id) => ({ label: t(`steps.${id}`) }))}
|
steps={steps.map((id) => ({ label: t(`steps.${id}`) }))}
|
||||||
current={steps.indexOf(step)}
|
current={stepIndex}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div key={step} className="mt-8 animate-step-enter">
|
<div
|
||||||
|
key={step}
|
||||||
|
ref={stepContainer}
|
||||||
|
className={cn(
|
||||||
|
'mt-8 motion-reduce:animate-none [&_h1]:outline-none [&_h2]:outline-none',
|
||||||
|
direction === 'back' ? 'animate-step-enter-back' : 'animate-step-enter',
|
||||||
|
)}
|
||||||
|
>
|
||||||
{step === 'welcome' ? <WelcomeStep name={firstName} onNext={goNext} /> : null}
|
{step === 'welcome' ? <WelcomeStep name={firstName} onNext={goNext} /> : null}
|
||||||
{step === 'country' ? <CountryStep onNext={goNext} onBack={goBack} /> : null}
|
{step === 'country' ? <CountryStep onNext={goNext} onBack={goBack} /> : null}
|
||||||
{step === 'plan' ? <PlanStep /> : null}
|
{step === 'plan' ? <PlanStep /> : null}
|
||||||
@@ -107,7 +141,9 @@ export function OnboardingView() {
|
|||||||
onBack={goBack}
|
onBack={goBack}
|
||||||
onCompleted={(group) => {
|
onCompleted={(group) => {
|
||||||
setCreatedGroup(group)
|
setCreatedGroup(group)
|
||||||
goTo('done')
|
// Reemplaza: el formulario ya no tiene que quedar en el historial
|
||||||
|
// (volver a él crearía otro grupo).
|
||||||
|
goTo('done', { replace: true })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
48
apps/web/src/features/onboarding/PaymentReminderPreview.tsx
Normal file
48
apps/web/src/features/onboarding/PaymentReminderPreview.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { COUNTRY_CURRENCY, PRO_PRICE_BY_COUNTRY } from '@gruperly/shared'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useIntlLocale } from '../../i18n'
|
||||||
|
import { formatPrice } from '../../lib/format'
|
||||||
|
import { MessagePreview } from './MessagePreview'
|
||||||
|
import { useOnboarding } from './OnboardingProvider'
|
||||||
|
|
||||||
|
type PaymentReminderPreviewProps = {
|
||||||
|
caption: string
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Día de vencimiento y hora de la muestra: valores típicos, fijos para que la
|
||||||
|
vista previa no cambie entre renders. */
|
||||||
|
const SAMPLE_DUE_DAY = 10
|
||||||
|
const SAMPLE_TIME = new Date(2026, 0, 5, 10, 0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* El recordatorio de pago semanal, con el mismo texto que arma el backend
|
||||||
|
* (`whatsapp/lib/render-message.ts`) y un ejemplo en la moneda del país elegido.
|
||||||
|
*/
|
||||||
|
export function PaymentReminderPreview({ caption, className }: PaymentReminderPreviewProps) {
|
||||||
|
const { t } = useTranslation('onboarding')
|
||||||
|
const locale = useIntlLocale()
|
||||||
|
const { country } = useOnboarding()
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
const dueDate = new Date(now.getFullYear(), now.getMonth() + (now.getDate() >= SAMPLE_DUE_DAY ? 1 : 0), SAMPLE_DUE_DAY)
|
||||||
|
// El precio de ejemplo es el de Pro del país: un monto realista en su moneda.
|
||||||
|
const amount = formatPrice(PRO_PRICE_BY_COUNTRY[country], COUNTRY_CURRENCY[country])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<MessagePreview
|
||||||
|
caption={caption}
|
||||||
|
contactName={t('preview.sampleStudentFull')}
|
||||||
|
time={new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(SAMPLE_TIME)}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
{t('preview.reminder', {
|
||||||
|
name: t('preview.sampleStudent'),
|
||||||
|
group: t('preview.sampleGroup'),
|
||||||
|
amount,
|
||||||
|
date: new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long' }).format(dueDate),
|
||||||
|
})}{' '}
|
||||||
|
<span className="font-medium text-accent underline underline-offset-2">{t('preview.sampleLink')}</span>
|
||||||
|
</MessagePreview>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -51,7 +51,7 @@ export function PaymentStep({ feedback, onNext, onBack }: PaymentStepProps) {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{feedback?.kind === 'error' ? (
|
{feedback?.kind === 'error' ? (
|
||||||
<p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
<p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
{mpCallbackErrorMessage(feedback.reason)}
|
{mpCallbackErrorMessage(feedback.reason)}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -82,7 +82,8 @@ export function PaymentStep({ feedback, onNext, onBack }: PaymentStepProps) {
|
|||||||
|
|
||||||
<div className="px-4 py-3">
|
<div className="px-4 py-3">
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant={isConnected ? 'outline' : 'primary'}
|
||||||
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
disabled={startAuthorization.isStarting}
|
disabled={startAuthorization.isStarting}
|
||||||
onClick={() => void startAuthorization.start('onboarding')}
|
onClick={() => void startAuthorization.start('onboarding')}
|
||||||
@@ -102,17 +103,17 @@ export function PaymentStep({ feedback, onNext, onBack }: PaymentStepProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{startAuthorization.error ? (
|
{startAuthorization.error ? (
|
||||||
<p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
<p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
{startAuthorization.error}
|
{startAuthorization.error}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button variant="outline" onClick={onBack} className="hidden lg:inline-flex">
|
<Button variant="outline" size="lg" onClick={onBack}>
|
||||||
<ArrowLeft className="size-4" />
|
<ArrowLeft className="size-4" />
|
||||||
{t('common:actions.back')}
|
{t('common:actions.back')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" className="flex-1 lg:flex-none" onClick={onNext}>
|
<Button variant={isConnected ? 'primary' : 'outline'} size="lg" className="flex-1" onClick={onNext}>
|
||||||
{isConnected ? t('continue') : t('later')}
|
{isConnected ? t('continue') : t('later')}
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -82,6 +82,17 @@ export function PlanStep() {
|
|||||||
mutation.mutate({ plan: 'PRO', country, payerEmail })
|
mutation.mutate({ plan: 'PRO', country, payerEmail })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Con Mercado Pago hay que pedir el email de la cuenta que paga; con Stripe no
|
||||||
|
// hay nada que completar (lo pide su checkout), así que se va directo.
|
||||||
|
const startPro = () => {
|
||||||
|
if (provider === 'MERCADO_PAGO') {
|
||||||
|
setError(null)
|
||||||
|
setIsEnteringEmail(true)
|
||||||
|
} else {
|
||||||
|
choosePro(undefined)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const proPrice = t('billing:view.perMonth', {
|
const proPrice = t('billing:view.perMonth', {
|
||||||
price: formatPrice(PRO_PRICE_BY_COUNTRY[country], COUNTRY_CURRENCY[country]),
|
price: formatPrice(PRO_PRICE_BY_COUNTRY[country], COUNTRY_CURRENCY[country]),
|
||||||
})
|
})
|
||||||
@@ -93,7 +104,7 @@ export function PlanStep() {
|
|||||||
<CheckCircle2 className="mt-0.5 size-4 shrink-0" />
|
<CheckCircle2 className="mt-0.5 size-4 shrink-0" />
|
||||||
{t('plan.active')}
|
{t('plan.active')}
|
||||||
</p>
|
</p>
|
||||||
<Button variant="primary" className="w-full" onClick={() => goTo('payment')}>
|
<Button variant="primary" size="lg" className="w-full" onClick={() => goTo('payment')}>
|
||||||
{t('continue')}
|
{t('continue')}
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -123,21 +134,21 @@ export function PlanStep() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? <p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{error}</p> : null}
|
{error ? <p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{error}</p> : null}
|
||||||
|
|
||||||
<div className="flex flex-col gap-3 sm:flex-row">
|
<div className="flex flex-col gap-3 sm:flex-row">
|
||||||
{returnedFromSubscription ? (
|
{returnedFromSubscription ? (
|
||||||
<Button variant="primary" className="flex-1" onClick={() => goTo('payment')}>
|
<Button variant="primary" size="lg" className="flex-1" onClick={() => goTo('payment')}>
|
||||||
{t('continue')}
|
{t('continue')}
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Button variant="primary" className="flex-1" onClick={() => setIsEnteringEmail(true)}>
|
<Button variant="primary" size="lg" className="flex-1" onClick={startPro}>
|
||||||
<Sparkles className="size-4" />
|
<Sparkles className="size-4" />
|
||||||
{t('plan.retry')}
|
{t('plan.retry')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" className="flex-1" disabled={mutation.isPending} onClick={chooseFree}>
|
<Button variant="outline" size="lg" className="flex-1" disabled={mutation.isPending} onClick={chooseFree}>
|
||||||
{t('plan.stayFree')}
|
{t('plan.stayFree')}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
@@ -151,7 +162,7 @@ export function PlanStep() {
|
|||||||
<StepShell>
|
<StepShell>
|
||||||
<div className="grid gap-3">
|
<div className="grid gap-3">
|
||||||
<PlanOptionCard plan="FREE" limits={PLAN_LIMITS.FREE}>
|
<PlanOptionCard plan="FREE" limits={PLAN_LIMITS.FREE}>
|
||||||
<Button variant="outline" className="w-full" disabled={isLeavingToMp} onClick={chooseFree}>
|
<Button variant="outline" size="lg" className="w-full" disabled={isLeavingToMp} onClick={chooseFree}>
|
||||||
{mutation.isPending && mutation.variables?.plan === 'FREE' ? (
|
{mutation.isPending && mutation.variables?.plan === 'FREE' ? (
|
||||||
<Loader2 className="size-4 animate-spin" />
|
<Loader2 className="size-4 animate-spin" />
|
||||||
) : null}
|
) : null}
|
||||||
@@ -167,23 +178,31 @@ export function PlanStep() {
|
|||||||
provider={provider}
|
provider={provider}
|
||||||
defaultEmail={user?.email ?? ''}
|
defaultEmail={user?.email ?? ''}
|
||||||
isPending={isLeavingToMp}
|
isPending={isLeavingToMp}
|
||||||
error={null}
|
error={error}
|
||||||
onSubmit={choosePro}
|
onSubmit={choosePro}
|
||||||
onCancel={() => setIsEnteringEmail(false)}
|
onCancel={() => setIsEnteringEmail(false)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Button variant="primary" className="w-full" onClick={() => setIsEnteringEmail(true)}>
|
<Button variant="primary" size="lg" className="w-full" disabled={isLeavingToMp} onClick={startPro}>
|
||||||
|
{mutation.isPending && mutation.variables?.plan === 'PRO' ? (
|
||||||
|
<Loader2 className="size-4 animate-spin" />
|
||||||
|
) : (
|
||||||
<Sparkles className="size-4" />
|
<Sparkles className="size-4" />
|
||||||
|
)}
|
||||||
{t('plan.choosePro')}
|
{t('plan.choosePro')}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</PlanOptionCard>
|
</PlanOptionCard>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? <p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{error}</p> : null}
|
{/* Con el form de Pro abierto, el error se muestra adentro, junto a lo que
|
||||||
|
se acaba de enviar. */}
|
||||||
|
{error && !isEnteringEmail ? (
|
||||||
|
<p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{error}</p>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button variant="outline" onClick={goBack} className="hidden lg:inline-flex">
|
<Button variant="outline" size="lg" onClick={goBack}>
|
||||||
<ArrowLeft className="size-4" />
|
<ArrowLeft className="size-4" />
|
||||||
{t('common:actions.back')}
|
{t('common:actions.back')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ export type StepperProps = {
|
|||||||
|
|
||||||
export function Stepper({ steps, current }: StepperProps) {
|
export function Stepper({ steps, current }: StepperProps) {
|
||||||
const { t } = useTranslation('onboarding')
|
const { t } = useTranslation('onboarding')
|
||||||
|
const currentLabel = steps[current]?.label
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
<ol aria-label={t('steps.progress')} className="flex items-center">
|
<ol aria-label={t('steps.progress')} className="flex items-center">
|
||||||
{steps.map((step, index) => {
|
{steps.map((step, index) => {
|
||||||
const isDone = index < current
|
const isDone = index < current
|
||||||
@@ -18,28 +21,27 @@ export function Stepper({ steps, current }: StepperProps) {
|
|||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
key={step.label}
|
key={step.label}
|
||||||
|
aria-current={isActive ? 'step' : undefined}
|
||||||
className={cn('flex items-center', index < steps.length - 1 ? 'flex-1' : '')}
|
className={cn('flex items-center', index < steps.length - 1 ? 'flex-1' : '')}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col items-center gap-1.5">
|
<div className="flex flex-col items-center gap-1.5">
|
||||||
<span
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex size-8 items-center justify-center rounded-full border text-sm font-semibold transition-colors',
|
'flex size-8 items-center justify-center rounded-full border text-sm font-semibold tabular-nums transition-colors',
|
||||||
isDone && 'border-accent bg-accent text-on-accent',
|
isDone && 'border-accent bg-accent text-on-accent',
|
||||||
isActive && 'border-accent text-accent ring-4 ring-accent/15',
|
isActive && 'border-accent text-accent ring-4 ring-accent/15',
|
||||||
!isDone && !isActive && 'border-border text-foreground/40',
|
!isDone && !isActive && 'border-border text-foreground/40',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{isDone ? (
|
{isDone ? <Check className="size-4" strokeWidth={3} /> : index + 1}
|
||||||
<Check className="size-4" strokeWidth={3} />
|
|
||||||
) : (
|
|
||||||
<span>{index + 1}</span>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
// Sin corte: con 7 pasos en max-w-md, "Tu grupo" partía en dos
|
// `sr-only` y no `hidden` en mobile: el lector de pantalla
|
||||||
// líneas. Si falta lugar, se achica la línea entre pasos.
|
// tiene que oír el nombre del paso, no solo el número. Sin
|
||||||
'hidden whitespace-nowrap text-xs font-medium sm:block',
|
// corte: con 7 pasos en max-w-md, "Tu grupo" partía en dos.
|
||||||
|
'sr-only whitespace-nowrap text-xs font-medium sm:not-sr-only',
|
||||||
isActive ? 'text-accent' : 'text-foreground/50',
|
isActive ? 'text-accent' : 'text-foreground/50',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -49,6 +51,7 @@ export function Stepper({ steps, current }: StepperProps) {
|
|||||||
|
|
||||||
{index < steps.length - 1 ? (
|
{index < steps.length - 1 ? (
|
||||||
<span
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
className={cn(
|
className={cn(
|
||||||
'mx-2 mb-0 h-px flex-1 rounded-full transition-colors sm:mb-4',
|
'mx-2 mb-0 h-px flex-1 rounded-full transition-colors sm:mb-4',
|
||||||
isDone ? 'bg-accent' : 'bg-border',
|
isDone ? 'bg-accent' : 'bg-border',
|
||||||
@@ -59,5 +62,17 @@ export function Stepper({ steps, current }: StepperProps) {
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
{/* En mobile los nombres no entran debajo de cada círculo: el paso actual
|
||||||
|
se nombra en una línea, para que al volver de una interrupción se sepa
|
||||||
|
dónde se está. */}
|
||||||
|
{currentLabel ? (
|
||||||
|
<p aria-hidden="true" className="mt-3 text-center text-sm text-foreground/60 sm:hidden">
|
||||||
|
{t('steps.position', { current: current + 1, total: steps.length })}
|
||||||
|
<span className="mx-1.5 text-foreground/30">·</span>
|
||||||
|
<span className="font-medium text-primary">{currentLabel}</span>
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,62 +1,49 @@
|
|||||||
import { ArrowRight, Rocket, Users, Wallet } from 'lucide-react'
|
import { ArrowRight } from 'lucide-react'
|
||||||
import { Button } from '../../components/ui'
|
import { Button } from '../../components/ui'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { PaymentReminderPreview } from './PaymentReminderPreview'
|
||||||
|
|
||||||
type WelcomeStepProps = {
|
type WelcomeStepProps = {
|
||||||
name: string
|
name: string
|
||||||
onNext: () => void
|
onNext: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const STEPS_TO_SETUP = [
|
/* El recorrido real del alta, en orden. Cobros y WhatsApp van en el medio y son
|
||||||
{
|
opcionales (y solo de Pro): la lista lo dice en vez de prometer un "cobrá al
|
||||||
icon: Wallet,
|
instante" que con Free no existe. Labels: `onboarding:welcome.arc.*`. */
|
||||||
title: 'welcome.step1Title',
|
const ARC = ['setup', 'connect', 'group'] as const
|
||||||
description: 'welcome.step1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: Users,
|
|
||||||
title: 'welcome.step2Title',
|
|
||||||
description: 'welcome.step2',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: Rocket,
|
|
||||||
title: 'welcome.step3Title',
|
|
||||||
description: 'welcome.step3',
|
|
||||||
},
|
|
||||||
] as const
|
|
||||||
|
|
||||||
export function WelcomeStep({ name, onNext }: WelcomeStepProps) {
|
export function WelcomeStep({ name, onNext }: WelcomeStepProps) {
|
||||||
const { t } = useTranslation('onboarding')
|
const { t } = useTranslation('onboarding')
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6">
|
<section className="space-y-7">
|
||||||
<header className="space-y-2 text-center">
|
<header className="space-y-2">
|
||||||
<span className="mx-auto flex size-14 items-center justify-center rounded-2xl bg-accent-soft">
|
<h1 className="text-[1.75rem] font-bold leading-tight tracking-tight text-primary text-balance">
|
||||||
<Rocket className="size-7 text-accent" />
|
{t('welcome.title', { name })}
|
||||||
</span>
|
</h1>
|
||||||
<h1 className="text-2xl font-bold text-primary">{t('welcome.title', { name })}</h1>
|
<p className="text-[0.9375rem] text-foreground/70 text-pretty">{t('welcome.description')}</p>
|
||||||
<p className="text-sm text-foreground/60">
|
|
||||||
{t('welcome.description')}
|
|
||||||
</p>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<PaymentReminderPreview caption={t('welcome.previewCaption')} />
|
||||||
|
|
||||||
<ol className="space-y-3">
|
<ol className="space-y-3">
|
||||||
{STEPS_TO_SETUP.map(({ icon: Icon, title, description }) => (
|
{ARC.map((id, index) => (
|
||||||
<li
|
<li key={id} className="flex gap-3">
|
||||||
key={title}
|
<span
|
||||||
className="flex items-center gap-3 rounded-xl border border-border bg-surface p-4"
|
aria-hidden="true"
|
||||||
|
className="mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full border border-border text-xs font-semibold tabular-nums text-foreground/60"
|
||||||
>
|
>
|
||||||
<span className="rounded-lg bg-accent-soft p-2">
|
{index + 1}
|
||||||
<Icon className="size-5 text-accent" />
|
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div className="min-w-0">
|
||||||
<p className="text-sm font-semibold text-primary">{t(title)}</p>
|
<p className="text-sm font-semibold text-primary">{t(`welcome.arc.${id}Title`)}</p>
|
||||||
<p className="text-xs text-foreground/60">{t(description)}</p>
|
<p className="text-sm text-foreground/60">{t(`welcome.arc.${id}`)}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<Button variant="primary" size="md" className="w-full" onClick={onNext}>
|
<Button variant="primary" size="lg" className="w-full" onClick={onNext}>
|
||||||
{t('welcome.start')}
|
{t('welcome.start')}
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
whatsappStatusLabel,
|
whatsappStatusLabel,
|
||||||
} from '../whatsapp'
|
} from '../whatsapp'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { PaymentReminderPreview } from './PaymentReminderPreview'
|
||||||
|
|
||||||
type WhatsappStepProps = {
|
type WhatsappStepProps = {
|
||||||
/** Resultado de una vinculación por redirect, leído de `?wa=` al volver. */
|
/** Resultado de una vinculación por redirect, leído de `?wa=` al volver. */
|
||||||
@@ -46,7 +47,11 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
|
|||||||
</p>
|
</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{feedback?.kind === 'success' || (isConnected && !feedback) ? (
|
{!isConnected ? <PaymentReminderPreview caption={t('whatsapp.previewCaption')} /> : null}
|
||||||
|
|
||||||
|
{/* El banner es la confirmación de una vinculación recién hecha. Si ya
|
||||||
|
estaba vinculado, alcanza con el estado de la tarjeta. */}
|
||||||
|
{feedback?.kind === 'success' ? (
|
||||||
<p className="flex items-start gap-2 rounded-xl bg-success-soft px-4 py-3 text-sm text-success">
|
<p className="flex items-start gap-2 rounded-xl bg-success-soft px-4 py-3 text-sm text-success">
|
||||||
<CheckCircle2 className="mt-0.5 size-4 shrink-0" />
|
<CheckCircle2 className="mt-0.5 size-4 shrink-0" />
|
||||||
{statusQuery.data?.displayPhoneNumber
|
{statusQuery.data?.displayPhoneNumber
|
||||||
@@ -56,7 +61,7 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{feedback?.kind === 'error' ? (
|
{feedback?.kind === 'error' ? (
|
||||||
<p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
<p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||||
{whatsappCallbackErrorMessage(feedback.reason)}
|
{whatsappCallbackErrorMessage(feedback.reason)}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -79,6 +84,13 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
|
|||||||
statusQuery.error instanceof ApiError ? statusQuery.error.status : null,
|
statusQuery.error instanceof ApiError ? statusQuery.error.status : null,
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
) : isConnected ? (
|
||||||
|
<p className="text-sm text-foreground/60">
|
||||||
|
{statusQuery.data?.displayPhoneNumber
|
||||||
|
? t('whatsapp.connectedWith', { phone: statusQuery.data.displayPhoneNumber })
|
||||||
|
: t('whatsapp.connected')}{' '}
|
||||||
|
{t('whatsapp.perGroup')}
|
||||||
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-sm text-foreground/60">
|
<p className="text-sm text-foreground/60">
|
||||||
{usesQr
|
{usesQr
|
||||||
@@ -93,6 +105,7 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
|
|||||||
<div className="px-4 py-3">
|
<div className="px-4 py-3">
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
disabled={connection.isStarting || statusQuery.isError}
|
disabled={connection.isStarting || statusQuery.isError}
|
||||||
onClick={() => void connection.start('onboarding')}
|
onClick={() => void connection.start('onboarding')}
|
||||||
@@ -109,7 +122,7 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{connection.error ? (
|
{connection.error ? (
|
||||||
<p className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{connection.error}</p>
|
<p role="alert" className="rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">{connection.error}</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<WhatsappLinkModal
|
<WhatsappLinkModal
|
||||||
@@ -119,11 +132,11 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button variant="outline" onClick={onBack} className="hidden lg:inline-flex">
|
<Button variant="outline" size="lg" onClick={onBack}>
|
||||||
<ArrowLeft className="size-4" />
|
<ArrowLeft className="size-4" />
|
||||||
{t('common:actions.back')}
|
{t('common:actions.back')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" className="flex-1 lg:flex-none" onClick={onNext}>
|
<Button variant={isConnected ? 'primary' : 'outline'} size="lg" className="flex-1" onClick={onNext}>
|
||||||
{isConnected ? t('continue') : t('later')}
|
{isConnected ? t('continue') : t('later')}
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export type OnboardingStepId =
|
|||||||
|
|
||||||
/** Labels: `onboarding:steps.<id>`. */
|
/** Labels: `onboarding:steps.<id>`. */
|
||||||
|
|
||||||
const ALL_STEPS: readonly OnboardingStepId[] = [
|
export const ALL_STEPS: readonly OnboardingStepId[] = [
|
||||||
'welcome',
|
'welcome',
|
||||||
'country',
|
'country',
|
||||||
'plan',
|
'plan',
|
||||||
@@ -45,3 +45,31 @@ export function resumeStep(status: OnboardingStatusDto): OnboardingStepId | null
|
|||||||
if (status.step === 'PAYMENT_CONNECTED') return status.whatsappConnected ? 'group' : 'whatsapp'
|
if (status.step === 'PAYMENT_CONNECTED') return status.whatsappConnected ? 'group' : 'whatsapp'
|
||||||
return 'payment'
|
return 'payment'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Lee `?step=` de la URL: cualquier valor desconocido es "sin paso". */
|
||||||
|
export function parseStep(value: unknown): OnboardingStepId | undefined {
|
||||||
|
return typeof value === 'string' && (ALL_STEPS as readonly string[]).includes(value)
|
||||||
|
? (value as OnboardingStepId)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pasos que necesitan el plan ya elegido (el backend da 409 `plan_not_selected`). */
|
||||||
|
const NEEDS_PLAN: readonly OnboardingStepId[] = ['payment', 'whatsapp', 'group', 'done']
|
||||||
|
|
||||||
|
/**
|
||||||
|
* El paso que realmente se muestra para el que pide la URL. El paso vive en
|
||||||
|
* `?step=` (así el back del dispositivo retrocede un paso), y una URL puede
|
||||||
|
* pedir uno que hoy no corresponde: sin plan no se pasa de Plan, con Free no
|
||||||
|
* hay Cobros ni WhatsApp, "Listo" sin grupo creado vuelve al formulario, y con
|
||||||
|
* el grupo ya creado no se vuelve a mostrar el formulario (crearía otro).
|
||||||
|
*/
|
||||||
|
export function effectiveStep(
|
||||||
|
requested: OnboardingStepId,
|
||||||
|
{ plan, hasCreatedGroup }: { plan: Plan | null; hasCreatedGroup: boolean },
|
||||||
|
): OnboardingStepId {
|
||||||
|
if (hasCreatedGroup) return 'done'
|
||||||
|
if (plan === null && NEEDS_PLAN.includes(requested)) return 'plan'
|
||||||
|
if (!visibleSteps(plan).includes(requested)) return 'group'
|
||||||
|
if (requested === 'done') return 'group'
|
||||||
|
return requested
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,7 +56,9 @@
|
|||||||
},
|
},
|
||||||
"option": {
|
"option": {
|
||||||
"yourPlan": "Your plan",
|
"yourPlan": "Your plan",
|
||||||
"free": "Free"
|
"free": "Free",
|
||||||
|
"inPro": "in Pro",
|
||||||
|
"recommended": "Recommended"
|
||||||
},
|
},
|
||||||
"charges": {
|
"charges": {
|
||||||
"title": "Payment history",
|
"title": "Payment history",
|
||||||
|
|||||||
@@ -63,6 +63,8 @@
|
|||||||
"billingType": "Billing type",
|
"billingType": "Billing type",
|
||||||
"dueDay": "Due day",
|
"dueDay": "Due day",
|
||||||
"dueDayHint": "Payments will be due on day {{day}} of each month.",
|
"dueDayHint": "Payments will be due on day {{day}} of each month.",
|
||||||
"submitting": "Creating…"
|
"submitting": "Creating…",
|
||||||
|
"whenLegend": "Classes",
|
||||||
|
"priceLegend": "Billing"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,41 +16,47 @@
|
|||||||
"seeAll": "See all",
|
"seeAll": "See all",
|
||||||
"empty": "No pending payments for now.",
|
"empty": "No pending payments for now.",
|
||||||
"linkMp": "Link Mercado Pago to get paid",
|
"linkMp": "Link Mercado Pago to get paid",
|
||||||
"hint": "You create them from each group's page."
|
"hint": "You create them from each group's page.",
|
||||||
},
|
"pending_one": "{{amount}} to collect across {{count}} payment",
|
||||||
"stats": {
|
"pending_other": "{{amount}} to collect across {{count}} payments"
|
||||||
"groups_one": "Group",
|
|
||||||
"groups_other": "Groups",
|
|
||||||
"toCollect": "To collect",
|
|
||||||
"toCollectCount": "To collect · {{count}}",
|
|
||||||
"students_one": "Student",
|
|
||||||
"students_other": "Students"
|
|
||||||
},
|
},
|
||||||
"nextClass": {
|
"nextClass": {
|
||||||
"now": "Class in progress",
|
"now": "Class in progress",
|
||||||
"next": "Next class",
|
"next": "Next class",
|
||||||
"nowBadge": "Happening now",
|
"nowBadge": "Happening now"
|
||||||
"seeGroup": "View group"
|
|
||||||
},
|
},
|
||||||
"today": {
|
"today": {
|
||||||
"label": "Today's class",
|
"time": "Today, {{time}}",
|
||||||
"attendanceTaken": "Attendance taken",
|
|
||||||
"time": "Today · {{time}}",
|
|
||||||
"enrolled_one": "{{count}} enrolled",
|
"enrolled_one": "{{count}} enrolled",
|
||||||
"enrolled_other": "{{count}} enrolled",
|
"enrolled_other": "{{count}} enrolled",
|
||||||
"slots_one": "{{count}} spot left",
|
"slots_one": "{{count}} spot left",
|
||||||
"slots_other": "{{count}} spots left",
|
"slots_other": "{{count}} spots left",
|
||||||
"seeAttendance": "View attendance",
|
"takeAttendance": "Take attendance",
|
||||||
"takeAttendance": "Take attendance"
|
"live": "In progress",
|
||||||
|
"listTitle": "Today's classes",
|
||||||
|
"state": {
|
||||||
|
"taken": "Attendance taken",
|
||||||
|
"missed": "Take attendance",
|
||||||
|
"upcoming": "Later",
|
||||||
|
"live": "In progress"
|
||||||
|
},
|
||||||
|
"loadError": "We couldn't load today's classes."
|
||||||
},
|
},
|
||||||
"attention": {
|
"attention": {
|
||||||
"title": "Needs attention",
|
"title": "Needs attention",
|
||||||
"allGood": "All good: no one at risk, no overdue payments or pre-registrations.",
|
"allGood": "Nothing pending: no one at risk or with overdue fees.",
|
||||||
"overdue_one": "{{count}} overdue payment",
|
|
||||||
"overdue_other": "{{count}} overdue payments",
|
|
||||||
"overdueHint": "Review them in Payments",
|
|
||||||
"preRegistrations_one": "{{count}} pre-registration to approve",
|
"preRegistrations_one": "{{count}} pre-registration to approve",
|
||||||
"preRegistrations_other": "{{count}} pre-registrations to approve",
|
"preRegistrations_other": "{{count}} pre-registrations to approve",
|
||||||
"moreAtRisk": "And {{count}} more at risk. Check each group's stats."
|
"seeAll": "See all",
|
||||||
|
"more_one": "{{count}} more person to follow up",
|
||||||
|
"more_other": "{{count}} more people to follow up",
|
||||||
|
"loadError": "We couldn't load what needs attention."
|
||||||
|
},
|
||||||
|
"loading": "Loading your day…",
|
||||||
|
"teaser": {
|
||||||
|
"sample1": "Sofia Martinez",
|
||||||
|
"sample2": "Tom Ruiz",
|
||||||
|
"description": "With Pro, see who owes you and how much here, and collect with Mercado Pago links.",
|
||||||
|
"cta": "Explore Pro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,26 +7,30 @@
|
|||||||
"whatsapp": "WhatsApp",
|
"whatsapp": "WhatsApp",
|
||||||
"group": "Your group",
|
"group": "Your group",
|
||||||
"done": "Done",
|
"done": "Done",
|
||||||
"progress": "Setup progress"
|
"progress": "Setup progress",
|
||||||
|
"position": "Step {{current}} of {{total}}"
|
||||||
},
|
},
|
||||||
"continue": "Continue",
|
"continue": "Continue",
|
||||||
"later": "I'll do it later",
|
"later": "I'll do it later",
|
||||||
"signedOut": {
|
"signedOut": {
|
||||||
"title": "Your account is ready",
|
"title": "Sign in to continue",
|
||||||
"description": "Sign in to set up your payments and create your first group.",
|
"description": "Sign in to set up your payments and create your first group.",
|
||||||
"action": "Sign in"
|
"action": "Sign in"
|
||||||
},
|
},
|
||||||
"fallbackName": "there",
|
"fallbackName": "there",
|
||||||
"welcome": {
|
"welcome": {
|
||||||
"title": "Hi, {{name}}!",
|
"title": "Hi, {{name}}!",
|
||||||
"description": "Let's set up your account in 3 steps. It takes less than 5 minutes.",
|
"description": "In a few minutes your account is ready to collect payments from your members and track class attendance.",
|
||||||
"step1Title": "Connect your payment account",
|
"start": "Get started",
|
||||||
"step1": "Link Mercado Pago and charge your members from the group.",
|
"previewCaption": "With Pro, Gruperly reminds your members to pay on WhatsApp, from your own number:",
|
||||||
"step2Title": "Create your first group",
|
"arc": {
|
||||||
"step2": "Days, time, price and capacity of your class.",
|
"setupTitle": "Your country and plan",
|
||||||
"step3Title": "Start collecting",
|
"setup": "So you charge in your currency. You can start for free.",
|
||||||
"step3": "All set to add members and get paid right away.",
|
"connectTitle": "Payments and WhatsApp",
|
||||||
"start": "Get started"
|
"connect": "Optional, with Pro: Mercado Pago and automatic reminders.",
|
||||||
|
"groupTitle": "Your first group",
|
||||||
|
"group": "Days, time, price and capacity of your class."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"country": {
|
"country": {
|
||||||
"title": "Which country will you charge in?",
|
"title": "Which country will you charge in?",
|
||||||
@@ -54,7 +58,7 @@
|
|||||||
"loading": "Checking your account…",
|
"loading": "Checking your account…",
|
||||||
"linkedOn": "Linked on {{date}}.",
|
"linkedOn": "Linked on {{date}}.",
|
||||||
"connectedHint": "Your groups' payments will go into this account.",
|
"connectedHint": "Your groups' payments will go into this account.",
|
||||||
"connectHint": "We'll take you to Mercado Pago to authorize payments. Money goes straight into your account, no middlemen.",
|
"connectHint": "We'll take you to Mercado Pago to authorize Gruperly: we use it to create your members' payment links and see which ones were paid. The money goes straight to your account, no middlemen.",
|
||||||
"opening": "Opening Mercado Pago…",
|
"opening": "Opening Mercado Pago…",
|
||||||
"change": "Change account",
|
"change": "Change account",
|
||||||
"connect": "Link account"
|
"connect": "Link account"
|
||||||
@@ -67,27 +71,42 @@
|
|||||||
"qrHint": "Link it with your phone number or by scanning a QR code, like WhatsApp Web.",
|
"qrHint": "Link it with your phone number or by scanning a QR code, like WhatsApp Web.",
|
||||||
"metaHint": "We'll take you to Meta to connect your WhatsApp Business account.",
|
"metaHint": "We'll take you to Meta to connect your WhatsApp Business account.",
|
||||||
"perGroup": "You turn on automatic messages later in each group.",
|
"perGroup": "You turn on automatic messages later in each group.",
|
||||||
"opening": "Opening…",
|
"opening": "Preparing the link…",
|
||||||
"connect": "Link WhatsApp"
|
"connect": "Link WhatsApp",
|
||||||
|
"previewCaption": "This is what a member with a pending fee receives:",
|
||||||
|
"connected": "Messages are sent from your number.",
|
||||||
|
"connectedWith": "Messages are sent from {{phone}}."
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"heading": "Your first group"
|
"heading": "Your first group",
|
||||||
|
"choosePlan": "Choose a plan"
|
||||||
},
|
},
|
||||||
"done": {
|
"done": {
|
||||||
"title": "All set!",
|
"title": "Your group is ready",
|
||||||
"description": "Your group was created. You can now invite members and take attendance.",
|
"description": "Now add your members: send them this link, they fill in their details and you approve each request.",
|
||||||
"active": "Active",
|
|
||||||
"price": "Price",
|
"price": "Price",
|
||||||
"capacity": "Capacity",
|
"capacity": "Capacity",
|
||||||
"capacityValue": "{{count}} members",
|
"capacityValue": "{{count}} members",
|
||||||
"dueDay": "Due date",
|
"dueDay": "Due date",
|
||||||
"dueDayValue": "Day {{day}} of each month",
|
"dueDayValue": "Day {{day}} of each month",
|
||||||
"plan": "You're on the <strong>{{plan}}</strong> plan.",
|
"previewCaption": "The message you'll share:",
|
||||||
"freeHint": " When you want to collect with Mercado Pago or automate WhatsApp, upgrade to Pro from Settings.",
|
"previewContact": "Your members",
|
||||||
"mpConnected": "You'll collect with <strong>Mercado Pago</strong>. Payments go straight into your account.",
|
"linkLoading": "Generating the link…",
|
||||||
"mpPending": "When you're ready to collect, link <strong>Mercado Pago</strong> from Settings. Your group is already created.",
|
"linkError": "We couldn't generate the invite link.",
|
||||||
"waConnected": "Your WhatsApp is linked. Turn on payment reminders and re-engagement from the group's page.",
|
"share": "Share on WhatsApp",
|
||||||
"waPending": "To send automatic reminders, link <strong>WhatsApp</strong> from Settings.",
|
"copyLink": "Copy link",
|
||||||
"goToPanel": "Go to my dashboard"
|
"statusFree": "You're on {{plan}}. Collecting with Mercado Pago and automating WhatsApp are Pro features: turn them on anytime from Settings.",
|
||||||
|
"statusAllSet": "Mercado Pago and WhatsApp are linked. Turn on reminders from the group page.",
|
||||||
|
"statusPendingBoth": "When you want to collect payments and send reminders, link Mercado Pago and WhatsApp from Settings.",
|
||||||
|
"statusPendingMp": "WhatsApp is linked. To collect payments, link Mercado Pago from Settings.",
|
||||||
|
"statusPendingWa": "Mercado Pago is linked. For automatic reminders, link WhatsApp from Settings.",
|
||||||
|
"goHome": "Go to home"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"sampleStudent": "Sofia",
|
||||||
|
"sampleStudentFull": "Sofia Martinez",
|
||||||
|
"sampleGroup": "Yoga · Level 1",
|
||||||
|
"reminder": "Hi {{name}}! This is a reminder about your {{group}} payment of {{amount}}, due on {{date}}. You can pay from this link:",
|
||||||
|
"sampleLink": "mercadopago.com/checkout/…"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,9 @@
|
|||||||
},
|
},
|
||||||
"option": {
|
"option": {
|
||||||
"yourPlan": "Tu plan",
|
"yourPlan": "Tu plan",
|
||||||
"free": "Gratis"
|
"free": "Gratis",
|
||||||
|
"inPro": "en Pro",
|
||||||
|
"recommended": "Recomendado"
|
||||||
},
|
},
|
||||||
"charges": {
|
"charges": {
|
||||||
"title": "Historial de pagos",
|
"title": "Historial de pagos",
|
||||||
|
|||||||
@@ -63,6 +63,8 @@
|
|||||||
"billingType": "Tipo de cobro",
|
"billingType": "Tipo de cobro",
|
||||||
"dueDay": "Día de vencimiento",
|
"dueDay": "Día de vencimiento",
|
||||||
"dueDayHint": "Los cobros vencerán el día {{day}} de cada mes.",
|
"dueDayHint": "Los cobros vencerán el día {{day}} de cada mes.",
|
||||||
"submitting": "Creando…"
|
"submitting": "Creando…",
|
||||||
|
"whenLegend": "Las clases",
|
||||||
|
"priceLegend": "El cobro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,41 +16,47 @@
|
|||||||
"seeAll": "Ver todos",
|
"seeAll": "Ver todos",
|
||||||
"empty": "Sin cobros pendientes por ahora.",
|
"empty": "Sin cobros pendientes por ahora.",
|
||||||
"linkMp": "Vincula Mercado Pago para cobrar",
|
"linkMp": "Vincula Mercado Pago para cobrar",
|
||||||
"hint": "Los creas desde la ficha de cada grupo."
|
"hint": "Los creas desde la ficha de cada grupo.",
|
||||||
},
|
"pending_one": "{{amount}} por cobrar en {{count}} cobro",
|
||||||
"stats": {
|
"pending_other": "{{amount}} por cobrar en {{count}} cobros"
|
||||||
"groups_one": "Grupo",
|
|
||||||
"groups_other": "Grupos",
|
|
||||||
"toCollect": "Por cobrar",
|
|
||||||
"toCollectCount": "Por cobrar · {{count}}",
|
|
||||||
"students_one": "Alumno",
|
|
||||||
"students_other": "Alumnos"
|
|
||||||
},
|
},
|
||||||
"nextClass": {
|
"nextClass": {
|
||||||
"now": "Clase en curso",
|
"now": "Clase en curso",
|
||||||
"next": "Próxima clase",
|
"next": "Próxima clase",
|
||||||
"nowBadge": "En curso ahora",
|
"nowBadge": "En curso ahora"
|
||||||
"seeGroup": "Ver grupo"
|
|
||||||
},
|
},
|
||||||
"today": {
|
"today": {
|
||||||
"label": "Clase de hoy",
|
"time": "Hoy, {{time}}",
|
||||||
"attendanceTaken": "Asistencia tomada",
|
|
||||||
"time": "Hoy · {{time}} h",
|
|
||||||
"enrolled_one": "{{count}} inscrito",
|
"enrolled_one": "{{count}} inscrito",
|
||||||
"enrolled_other": "{{count}} inscritos",
|
"enrolled_other": "{{count}} inscritos",
|
||||||
"slots_one": "{{count}} lugar disponible",
|
"slots_one": "{{count}} lugar disponible",
|
||||||
"slots_other": "{{count}} lugares disponibles",
|
"slots_other": "{{count}} lugares disponibles",
|
||||||
"seeAttendance": "Ver asistencia",
|
"takeAttendance": "Tomar asistencia",
|
||||||
"takeAttendance": "Tomar asistencia"
|
"live": "En curso",
|
||||||
|
"listTitle": "Clases de hoy",
|
||||||
|
"state": {
|
||||||
|
"taken": "Asistencia tomada",
|
||||||
|
"missed": "Tomar asistencia",
|
||||||
|
"upcoming": "Más tarde",
|
||||||
|
"live": "En curso"
|
||||||
|
},
|
||||||
|
"loadError": "No pudimos cargar las clases de hoy."
|
||||||
},
|
},
|
||||||
"attention": {
|
"attention": {
|
||||||
"title": "Para atender",
|
"title": "Para atender",
|
||||||
"allGood": "Todo en orden: nadie en riesgo, sin cobros vencidos ni preinscripciones.",
|
"allGood": "Nada pendiente: nadie en riesgo ni con cuotas vencidas.",
|
||||||
"overdue_one": "{{count}} cobro vencido",
|
|
||||||
"overdue_other": "{{count}} cobros vencidos",
|
|
||||||
"overdueHint": "Revísalos en Cobros",
|
|
||||||
"preRegistrations_one": "{{count}} preinscripción por aprobar",
|
"preRegistrations_one": "{{count}} preinscripción por aprobar",
|
||||||
"preRegistrations_other": "{{count}} preinscripciones por aprobar",
|
"preRegistrations_other": "{{count}} preinscripciones por aprobar",
|
||||||
"moreAtRisk": "Y {{count}} más en riesgo. Revisa las estadísticas de cada grupo."
|
"seeAll": "Ver todo",
|
||||||
|
"more_one": "{{count}} persona más por atender",
|
||||||
|
"more_other": "{{count}} personas más por atender",
|
||||||
|
"loadError": "No pudimos cargar los pendientes."
|
||||||
|
},
|
||||||
|
"loading": "Cargando tu día…",
|
||||||
|
"teaser": {
|
||||||
|
"sample1": "Sofía Martínez",
|
||||||
|
"sample2": "Tomás Ruiz",
|
||||||
|
"description": "Con Pro, aquí ves quién te debe y cuánto, y cobras con enlaces de Mercado Pago.",
|
||||||
|
"cta": "Conoce Pro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,26 +7,30 @@
|
|||||||
"whatsapp": "WhatsApp",
|
"whatsapp": "WhatsApp",
|
||||||
"group": "Tu grupo",
|
"group": "Tu grupo",
|
||||||
"done": "Listo",
|
"done": "Listo",
|
||||||
"progress": "Progreso del alta"
|
"progress": "Progreso del alta",
|
||||||
|
"position": "Paso {{current}} de {{total}}"
|
||||||
},
|
},
|
||||||
"continue": "Continuar",
|
"continue": "Continuar",
|
||||||
"later": "Lo haré después",
|
"later": "Lo haré después",
|
||||||
"signedOut": {
|
"signedOut": {
|
||||||
"title": "Tu cuenta, lista",
|
"title": "Inicia sesión para continuar",
|
||||||
"description": "Inicia sesión para configurar tus cobros y crear tu primer grupo.",
|
"description": "Inicia sesión para configurar tus cobros y crear tu primer grupo.",
|
||||||
"action": "Iniciar sesión"
|
"action": "Iniciar sesión"
|
||||||
},
|
},
|
||||||
"fallbackName": "profe",
|
"fallbackName": "profe",
|
||||||
"welcome": {
|
"welcome": {
|
||||||
"title": "¡Hola, {{name}}!",
|
"title": "¡Hola, {{name}}!",
|
||||||
"description": "Configuremos tu cuenta en 3 pasos. Te tomará menos de 5 minutos.",
|
"description": "En unos minutos dejas tu cuenta lista para cobrarles a tus miembros y llevar la asistencia de tus clases.",
|
||||||
"step1Title": "Conecta tu cuenta de cobro",
|
"start": "Comenzar",
|
||||||
"step1": "Vincula Mercado Pago y cóbrales a tus miembros desde el grupo.",
|
"previewCaption": "Con Pro, Gruperly les recuerda los pagos a tus miembros por WhatsApp, desde tu número:",
|
||||||
"step2Title": "Crea tu primer grupo",
|
"arc": {
|
||||||
"step2": "Días, horario, precio y cupo de tu clase.",
|
"setupTitle": "Tu país y tu plan",
|
||||||
"step3Title": "Empieza a cobrar",
|
"setup": "Para cobrar en tu moneda. Puedes empezar gratis.",
|
||||||
"step3": "Todo listo para sumar miembros y cobrar al instante.",
|
"connectTitle": "Cobros y WhatsApp",
|
||||||
"start": "Comenzar"
|
"connect": "Opcional, con Pro: Mercado Pago y recordatorios automáticos.",
|
||||||
|
"groupTitle": "Tu primer grupo",
|
||||||
|
"group": "Días, horario, precio y cupo de tu clase."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"country": {
|
"country": {
|
||||||
"title": "¿En qué país vas a cobrar?",
|
"title": "¿En qué país vas a cobrar?",
|
||||||
@@ -54,7 +58,7 @@
|
|||||||
"loading": "Consultando tu cuenta…",
|
"loading": "Consultando tu cuenta…",
|
||||||
"linkedOn": "Vinculada el {{date}}.",
|
"linkedOn": "Vinculada el {{date}}.",
|
||||||
"connectedHint": "Los pagos de tus grupos entrarán a esta cuenta.",
|
"connectedHint": "Los pagos de tus grupos entrarán a esta cuenta.",
|
||||||
"connectHint": "Te llevamos a Mercado Pago para autorizar los cobros. Los pagos entran directo en tu cuenta, sin intermediarios.",
|
"connectHint": "Te llevamos a Mercado Pago para autorizar a Gruperly: lo usamos para crear los enlaces de cobro de tus miembros y ver cuáles se pagaron. El dinero entra directo a tu cuenta, sin intermediarios.",
|
||||||
"opening": "Abriendo Mercado Pago…",
|
"opening": "Abriendo Mercado Pago…",
|
||||||
"change": "Cambiar de cuenta",
|
"change": "Cambiar de cuenta",
|
||||||
"connect": "Vincular cuenta"
|
"connect": "Vincular cuenta"
|
||||||
@@ -67,27 +71,42 @@
|
|||||||
"qrHint": "Lo vinculas con tu número de teléfono o escaneando un código QR, como WhatsApp Web.",
|
"qrHint": "Lo vinculas con tu número de teléfono o escaneando un código QR, como WhatsApp Web.",
|
||||||
"metaHint": "Te llevamos a Meta para conectar tu cuenta de WhatsApp Business.",
|
"metaHint": "Te llevamos a Meta para conectar tu cuenta de WhatsApp Business.",
|
||||||
"perGroup": "Los envíos automáticos los activas después en cada grupo.",
|
"perGroup": "Los envíos automáticos los activas después en cada grupo.",
|
||||||
"opening": "Abriendo…",
|
"opening": "Preparando la vinculación…",
|
||||||
"connect": "Vincular WhatsApp"
|
"connect": "Vincular WhatsApp",
|
||||||
|
"previewCaption": "Esto es lo que recibe un miembro con la cuota pendiente:",
|
||||||
|
"connected": "Los mensajes salen desde tu número.",
|
||||||
|
"connectedWith": "Los mensajes salen desde {{phone}}."
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"heading": "Tu primer grupo"
|
"heading": "Tu primer grupo",
|
||||||
|
"choosePlan": "Elegir un plan"
|
||||||
},
|
},
|
||||||
"done": {
|
"done": {
|
||||||
"title": "¡Todo listo!",
|
"title": "Tu grupo está listo",
|
||||||
"description": "Tu grupo se creó. Ya puedes invitar miembros y pasar lista.",
|
"description": "Ahora suma a tus miembros: envíales este enlace, completan sus datos y tú apruebas cada solicitud.",
|
||||||
"active": "Activo",
|
|
||||||
"price": "Precio",
|
"price": "Precio",
|
||||||
"capacity": "Cupo",
|
"capacity": "Cupo",
|
||||||
"capacityValue": "{{count}} miembros",
|
"capacityValue": "{{count}} miembros",
|
||||||
"dueDay": "Vencimiento",
|
"dueDay": "Vencimiento",
|
||||||
"dueDayValue": "Día {{day}} de cada mes",
|
"dueDayValue": "Día {{day}} de cada mes",
|
||||||
"plan": "Estás en el plan <strong>{{plan}}</strong>.",
|
"previewCaption": "El mensaje que vas a compartir:",
|
||||||
"freeHint": " Cuando quieras cobrar con Mercado Pago o automatizar WhatsApp, cámbiate a Pro desde Ajustes.",
|
"previewContact": "Tus miembros",
|
||||||
"mpConnected": "Cobrarás con <strong>Mercado Pago</strong>. Los pagos entran directo en tu cuenta.",
|
"linkLoading": "Generando el enlace…",
|
||||||
"mpPending": "Cuando quieras cobrar, vincula <strong>Mercado Pago</strong> desde Ajustes. Tu grupo ya quedó creado.",
|
"linkError": "No pudimos generar el enlace de invitación.",
|
||||||
"waConnected": "Tu WhatsApp está vinculado. Activa los recordatorios de pago y el reenganche desde la ficha del grupo.",
|
"share": "Compartir por WhatsApp",
|
||||||
"waPending": "Para enviar recordatorios automáticos, vincula <strong>WhatsApp</strong> desde Ajustes.",
|
"copyLink": "Copiar enlace",
|
||||||
"goToPanel": "Ir a mi Panel"
|
"statusFree": "Estás en {{plan}}. Cobrar con Mercado Pago y automatizar WhatsApp es de Pro: lo activas cuando quieras desde Ajustes.",
|
||||||
|
"statusAllSet": "Mercado Pago y WhatsApp quedaron vinculados. Activa los recordatorios desde la ficha del grupo.",
|
||||||
|
"statusPendingBoth": "Cuando quieras cobrar y enviar recordatorios, vincula Mercado Pago y WhatsApp desde Ajustes.",
|
||||||
|
"statusPendingMp": "WhatsApp quedó vinculado. Para cobrar, vincula Mercado Pago desde Ajustes.",
|
||||||
|
"statusPendingWa": "Mercado Pago quedó vinculado. Para los recordatorios automáticos, vincula WhatsApp desde Ajustes.",
|
||||||
|
"goHome": "Ir al inicio"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"sampleStudent": "Sofía",
|
||||||
|
"sampleStudentFull": "Sofía Martínez",
|
||||||
|
"sampleGroup": "Yoga · Nivel 1",
|
||||||
|
"reminder": "¡Hola, {{name}}! Te recordamos el pago de {{group}} por {{amount}}, con vencimiento el {{date}}. Puedes pagarlo desde este enlace:",
|
||||||
|
"sampleLink": "mercadopago.com/checkout/…"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,9 @@
|
|||||||
},
|
},
|
||||||
"option": {
|
"option": {
|
||||||
"yourPlan": "Tu plan",
|
"yourPlan": "Tu plan",
|
||||||
"free": "Gratis"
|
"free": "Gratis",
|
||||||
|
"inPro": "en Pro",
|
||||||
|
"recommended": "Recomendado"
|
||||||
},
|
},
|
||||||
"charges": {
|
"charges": {
|
||||||
"title": "Historial de pagos",
|
"title": "Historial de pagos",
|
||||||
|
|||||||
@@ -63,6 +63,8 @@
|
|||||||
"billingType": "Tipo de cobro",
|
"billingType": "Tipo de cobro",
|
||||||
"dueDay": "Día de vencimiento",
|
"dueDay": "Día de vencimiento",
|
||||||
"dueDayHint": "Los cobros vencerán el día {{day}} de cada mes.",
|
"dueDayHint": "Los cobros vencerán el día {{day}} de cada mes.",
|
||||||
"submitting": "Creando…"
|
"submitting": "Creando…",
|
||||||
|
"whenLegend": "Las clases",
|
||||||
|
"priceLegend": "El cobro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,41 +16,47 @@
|
|||||||
"seeAll": "Ver todos",
|
"seeAll": "Ver todos",
|
||||||
"empty": "Sin cobros pendientes por ahora.",
|
"empty": "Sin cobros pendientes por ahora.",
|
||||||
"linkMp": "Vinculá Mercado Pago para cobrar",
|
"linkMp": "Vinculá Mercado Pago para cobrar",
|
||||||
"hint": "Los creás desde la ficha de cada grupo."
|
"hint": "Los creás desde la ficha de cada grupo.",
|
||||||
},
|
"pending_one": "{{amount}} por cobrar en {{count}} cobro",
|
||||||
"stats": {
|
"pending_other": "{{amount}} por cobrar en {{count}} cobros"
|
||||||
"groups_one": "Grupo",
|
|
||||||
"groups_other": "Grupos",
|
|
||||||
"toCollect": "Por cobrar",
|
|
||||||
"toCollectCount": "Por cobrar · {{count}}",
|
|
||||||
"students_one": "Alumno",
|
|
||||||
"students_other": "Alumnos"
|
|
||||||
},
|
},
|
||||||
"nextClass": {
|
"nextClass": {
|
||||||
"now": "Clase en curso",
|
"now": "Clase en curso",
|
||||||
"next": "Próxima clase",
|
"next": "Próxima clase",
|
||||||
"nowBadge": "En curso ahora",
|
"nowBadge": "En curso ahora"
|
||||||
"seeGroup": "Ver grupo"
|
|
||||||
},
|
},
|
||||||
"today": {
|
"today": {
|
||||||
"label": "Clase de hoy",
|
"time": "Hoy, {{time}} hs",
|
||||||
"attendanceTaken": "Asistencia tomada",
|
"enrolled_one": "{{count}} inscripto",
|
||||||
"time": "Hoy · {{time}} hs",
|
"enrolled_other": "{{count}} inscriptos",
|
||||||
"enrolled_one": "{{count}} inscrito",
|
|
||||||
"enrolled_other": "{{count}} inscritos",
|
|
||||||
"slots_one": "{{count}} cupo disponible",
|
"slots_one": "{{count}} cupo disponible",
|
||||||
"slots_other": "{{count}} cupos disponibles",
|
"slots_other": "{{count}} cupos disponibles",
|
||||||
"seeAttendance": "Ver asistencia",
|
"takeAttendance": "Tomar asistencia",
|
||||||
"takeAttendance": "Tomar asistencia"
|
"live": "En curso",
|
||||||
|
"listTitle": "Clases de hoy",
|
||||||
|
"state": {
|
||||||
|
"taken": "Asistencia tomada",
|
||||||
|
"missed": "Tomar asistencia",
|
||||||
|
"upcoming": "Más tarde",
|
||||||
|
"live": "En curso"
|
||||||
|
},
|
||||||
|
"loadError": "No pudimos cargar las clases de hoy."
|
||||||
},
|
},
|
||||||
"attention": {
|
"attention": {
|
||||||
"title": "Para atender",
|
"title": "Para atender",
|
||||||
"allGood": "Todo en orden: nadie en riesgo, sin cobros vencidos ni preinscripciones.",
|
"allGood": "Nada pendiente: nadie en riesgo ni con cuotas vencidas.",
|
||||||
"overdue_one": "{{count}} cobro vencido",
|
|
||||||
"overdue_other": "{{count}} cobros vencidos",
|
|
||||||
"overdueHint": "Revisalos en Cobros",
|
|
||||||
"preRegistrations_one": "{{count}} preinscripción por aprobar",
|
"preRegistrations_one": "{{count}} preinscripción por aprobar",
|
||||||
"preRegistrations_other": "{{count}} preinscripciones por aprobar",
|
"preRegistrations_other": "{{count}} preinscripciones por aprobar",
|
||||||
"moreAtRisk": "Y {{count}} más en riesgo. Mirá las estadísticas de cada grupo."
|
"seeAll": "Ver todo",
|
||||||
|
"more_one": "{{count}} persona más para atender",
|
||||||
|
"more_other": "{{count}} personas más para atender",
|
||||||
|
"loadError": "No pudimos cargar lo pendiente."
|
||||||
|
},
|
||||||
|
"loading": "Cargando tu día…",
|
||||||
|
"teaser": {
|
||||||
|
"sample1": "Sofía Martínez",
|
||||||
|
"sample2": "Tomás Ruiz",
|
||||||
|
"description": "Con Pro, acá ves quién te debe y cuánto, y cobrás con links de Mercado Pago.",
|
||||||
|
"cta": "Conocé Pro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,26 +7,30 @@
|
|||||||
"whatsapp": "WhatsApp",
|
"whatsapp": "WhatsApp",
|
||||||
"group": "Tu grupo",
|
"group": "Tu grupo",
|
||||||
"done": "Listo",
|
"done": "Listo",
|
||||||
"progress": "Progreso del alta"
|
"progress": "Progreso del alta",
|
||||||
|
"position": "Paso {{current}} de {{total}}"
|
||||||
},
|
},
|
||||||
"continue": "Continuar",
|
"continue": "Continuar",
|
||||||
"later": "Lo hago después",
|
"later": "Lo hago después",
|
||||||
"signedOut": {
|
"signedOut": {
|
||||||
"title": "Tu cuenta, lista",
|
"title": "Iniciá sesión para seguir",
|
||||||
"description": "Iniciá sesión para configurar tus cobros y crear tu primer grupo.",
|
"description": "Iniciá sesión para configurar tus cobros y crear tu primer grupo.",
|
||||||
"action": "Iniciar sesión"
|
"action": "Iniciar sesión"
|
||||||
},
|
},
|
||||||
"fallbackName": "profe",
|
"fallbackName": "profe",
|
||||||
"welcome": {
|
"welcome": {
|
||||||
"title": "¡Hola, {{name}}!",
|
"title": "¡Hola, {{name}}!",
|
||||||
"description": "Vamos a configurar tu cuenta en 3 pasos. Vas a tardar menos de 5 minutos.",
|
"description": "En unos minutos dejás tu cuenta lista para cobrarles a tus miembros y llevar la asistencia de tus clases.",
|
||||||
"step1Title": "Conectá tu cuenta de cobro",
|
"start": "Comenzar",
|
||||||
"step1": "Vinculá Mercado Pago y cobrale a tus miembros desde el grupo.",
|
"previewCaption": "Con Pro, Gruperly les recuerda los pagos a tus miembros por WhatsApp, desde tu número:",
|
||||||
"step2Title": "Creá tu primer grupo",
|
"arc": {
|
||||||
"step2": "Días, horario, precio y cupo de tu clase.",
|
"setupTitle": "Tu país y tu plan",
|
||||||
"step3Title": "Empezá a cobrar",
|
"setup": "Para cobrar en tu moneda. Podés empezar gratis.",
|
||||||
"step3": "Todo listo para sumar miembros y cobrar al instante.",
|
"connectTitle": "Cobros y WhatsApp",
|
||||||
"start": "Comenzar"
|
"connect": "Opcional, con Pro: Mercado Pago y recordatorios automáticos.",
|
||||||
|
"groupTitle": "Tu primer grupo",
|
||||||
|
"group": "Días, horario, precio y cupo de tu clase."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"country": {
|
"country": {
|
||||||
"title": "¿En qué país vas a cobrar?",
|
"title": "¿En qué país vas a cobrar?",
|
||||||
@@ -54,7 +58,7 @@
|
|||||||
"loading": "Consultando tu cuenta…",
|
"loading": "Consultando tu cuenta…",
|
||||||
"linkedOn": "Vinculada el {{date}}.",
|
"linkedOn": "Vinculada el {{date}}.",
|
||||||
"connectedHint": "Los pagos de tus grupos van a entrar a esta cuenta.",
|
"connectedHint": "Los pagos de tus grupos van a entrar a esta cuenta.",
|
||||||
"connectHint": "Te llevamos a Mercado Pago para autorizar los cobros. Los pagos entran directo en tu cuenta, sin intermediarios.",
|
"connectHint": "Te llevamos a Mercado Pago para autorizar a Gruperly: lo usamos para crear los links de cobro de tus miembros y ver cuáles se pagaron. La plata entra directo en tu cuenta, sin intermediarios.",
|
||||||
"opening": "Abriendo Mercado Pago…",
|
"opening": "Abriendo Mercado Pago…",
|
||||||
"change": "Cambiar de cuenta",
|
"change": "Cambiar de cuenta",
|
||||||
"connect": "Vincular cuenta"
|
"connect": "Vincular cuenta"
|
||||||
@@ -67,27 +71,42 @@
|
|||||||
"qrHint": "Lo vinculás con tu número de teléfono o escaneando un código QR, como WhatsApp Web.",
|
"qrHint": "Lo vinculás con tu número de teléfono o escaneando un código QR, como WhatsApp Web.",
|
||||||
"metaHint": "Te llevamos a Meta para conectar tu cuenta de WhatsApp Business.",
|
"metaHint": "Te llevamos a Meta para conectar tu cuenta de WhatsApp Business.",
|
||||||
"perGroup": "Los envíos automáticos los prendés después en cada grupo.",
|
"perGroup": "Los envíos automáticos los prendés después en cada grupo.",
|
||||||
"opening": "Abriendo…",
|
"opening": "Preparando la vinculación…",
|
||||||
"connect": "Vincular WhatsApp"
|
"connect": "Vincular WhatsApp",
|
||||||
|
"previewCaption": "Esto es lo que recibe un miembro con la cuota pendiente:",
|
||||||
|
"connected": "Los mensajes salen desde tu número.",
|
||||||
|
"connectedWith": "Los mensajes salen desde {{phone}}."
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"heading": "Tu primer grupo"
|
"heading": "Tu primer grupo",
|
||||||
|
"choosePlan": "Elegir un plan"
|
||||||
},
|
},
|
||||||
"done": {
|
"done": {
|
||||||
"title": "¡Todo listo!",
|
"title": "Tu grupo está listo",
|
||||||
"description": "Tu grupo se creó. Ya podés invitar miembros y pasar lista.",
|
"description": "Ahora sumá a tus miembros: mandales este link, completan sus datos y vos aprobás cada solicitud.",
|
||||||
"active": "Activo",
|
|
||||||
"price": "Precio",
|
"price": "Precio",
|
||||||
"capacity": "Cupo",
|
"capacity": "Cupo",
|
||||||
"capacityValue": "{{count}} miembros",
|
"capacityValue": "{{count}} miembros",
|
||||||
"dueDay": "Vencimiento",
|
"dueDay": "Vencimiento",
|
||||||
"dueDayValue": "Día {{day}} de cada mes",
|
"dueDayValue": "Día {{day}} de cada mes",
|
||||||
"plan": "Estás en el plan <strong>{{plan}}</strong>.",
|
"previewCaption": "El mensaje que vas a compartir:",
|
||||||
"freeHint": " Cuando quieras cobrar con Mercado Pago o automatizar WhatsApp, pasate a Pro desde Ajustes.",
|
"previewContact": "Tus miembros",
|
||||||
"mpConnected": "Vas a cobrar con <strong>Mercado Pago</strong>. Los pagos entran directo en tu cuenta.",
|
"linkLoading": "Generando el link…",
|
||||||
"mpPending": "Cuando quieras cobrar, vinculá <strong>Mercado Pago</strong> desde Ajustes. Tu grupo ya quedó creado.",
|
"linkError": "No pudimos generar el link de invitación.",
|
||||||
"waConnected": "Tu WhatsApp está vinculado. Activá los recordatorios de pago y el reenganche desde la ficha del grupo.",
|
"share": "Compartir por WhatsApp",
|
||||||
"waPending": "Para enviar recordatorios automáticos, vinculá <strong>WhatsApp</strong> desde Ajustes.",
|
"copyLink": "Copiar link",
|
||||||
"goToPanel": "Ir a mi Panel"
|
"statusFree": "Estás en {{plan}}. Cobrar con Mercado Pago y automatizar WhatsApp es de Pro: lo activás cuando quieras desde Ajustes.",
|
||||||
|
"statusAllSet": "Mercado Pago y WhatsApp quedaron vinculados. Prendé los recordatorios desde la ficha del grupo.",
|
||||||
|
"statusPendingBoth": "Cuando quieras cobrar y mandar recordatorios, vinculá Mercado Pago y WhatsApp desde Ajustes.",
|
||||||
|
"statusPendingMp": "WhatsApp quedó vinculado. Para cobrar, vinculá Mercado Pago desde Ajustes.",
|
||||||
|
"statusPendingWa": "Mercado Pago quedó vinculado. Para los recordatorios automáticos, vinculá WhatsApp desde Ajustes.",
|
||||||
|
"goHome": "Ir al inicio"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"sampleStudent": "Sofía",
|
||||||
|
"sampleStudentFull": "Sofía Martínez",
|
||||||
|
"sampleGroup": "Yoga · Nivel 1",
|
||||||
|
"reminder": "¡Hola {{name}}! Te recordamos el pago de {{group}} por {{amount}}, con vencimiento el {{date}}. Podés pagarlo desde este link:",
|
||||||
|
"sampleLink": "mercadopago.com/checkout/…"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,9 @@
|
|||||||
},
|
},
|
||||||
"option": {
|
"option": {
|
||||||
"yourPlan": "Seu plano",
|
"yourPlan": "Seu plano",
|
||||||
"free": "Grátis"
|
"free": "Grátis",
|
||||||
|
"inPro": "no Pro",
|
||||||
|
"recommended": "Recomendado"
|
||||||
},
|
},
|
||||||
"charges": {
|
"charges": {
|
||||||
"title": "Histórico de pagamentos",
|
"title": "Histórico de pagamentos",
|
||||||
|
|||||||
@@ -63,6 +63,8 @@
|
|||||||
"billingType": "Tipo de cobrança",
|
"billingType": "Tipo de cobrança",
|
||||||
"dueDay": "Dia de vencimento",
|
"dueDay": "Dia de vencimento",
|
||||||
"dueDayHint": "As cobranças vencerão todo dia {{day}}.",
|
"dueDayHint": "As cobranças vencerão todo dia {{day}}.",
|
||||||
"submitting": "Criando…"
|
"submitting": "Criando…",
|
||||||
|
"whenLegend": "As aulas",
|
||||||
|
"priceLegend": "A cobrança"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,41 +16,47 @@
|
|||||||
"seeAll": "Ver todas",
|
"seeAll": "Ver todas",
|
||||||
"empty": "Nenhuma cobrança pendente por enquanto.",
|
"empty": "Nenhuma cobrança pendente por enquanto.",
|
||||||
"linkMp": "Vincule o Mercado Pago para cobrar",
|
"linkMp": "Vincule o Mercado Pago para cobrar",
|
||||||
"hint": "Você cria as cobranças na página de cada grupo."
|
"hint": "Você cria as cobranças na página de cada grupo.",
|
||||||
},
|
"pending_one": "{{amount}} a receber em {{count}} cobrança",
|
||||||
"stats": {
|
"pending_other": "{{amount}} a receber em {{count}} cobranças"
|
||||||
"groups_one": "Grupo",
|
|
||||||
"groups_other": "Grupos",
|
|
||||||
"toCollect": "A receber",
|
|
||||||
"toCollectCount": "A receber · {{count}}",
|
|
||||||
"students_one": "Aluno",
|
|
||||||
"students_other": "Alunos"
|
|
||||||
},
|
},
|
||||||
"nextClass": {
|
"nextClass": {
|
||||||
"now": "Aula em andamento",
|
"now": "Aula em andamento",
|
||||||
"next": "Próxima aula",
|
"next": "Próxima aula",
|
||||||
"nowBadge": "Acontecendo agora",
|
"nowBadge": "Acontecendo agora"
|
||||||
"seeGroup": "Ver grupo"
|
|
||||||
},
|
},
|
||||||
"today": {
|
"today": {
|
||||||
"label": "Aula de hoje",
|
"time": "Hoje, {{time}}",
|
||||||
"attendanceTaken": "Presença registrada",
|
|
||||||
"time": "Hoje · {{time}}",
|
|
||||||
"enrolled_one": "{{count}} inscrito",
|
"enrolled_one": "{{count}} inscrito",
|
||||||
"enrolled_other": "{{count}} inscritos",
|
"enrolled_other": "{{count}} inscritos",
|
||||||
"slots_one": "{{count}} vaga disponível",
|
"slots_one": "{{count}} vaga disponível",
|
||||||
"slots_other": "{{count}} vagas disponíveis",
|
"slots_other": "{{count}} vagas disponíveis",
|
||||||
"seeAttendance": "Ver presença",
|
"takeAttendance": "Fazer chamada",
|
||||||
"takeAttendance": "Fazer chamada"
|
"live": "Em andamento",
|
||||||
|
"listTitle": "Aulas de hoje",
|
||||||
|
"state": {
|
||||||
|
"taken": "Presença registrada",
|
||||||
|
"missed": "Registrar presença",
|
||||||
|
"upcoming": "Mais tarde",
|
||||||
|
"live": "Em andamento"
|
||||||
|
},
|
||||||
|
"loadError": "Não conseguimos carregar as aulas de hoje."
|
||||||
},
|
},
|
||||||
"attention": {
|
"attention": {
|
||||||
"title": "Para resolver",
|
"title": "Para resolver",
|
||||||
"allGood": "Tudo certo: ninguém em risco, sem cobranças vencidas nem pré-inscrições.",
|
"allGood": "Nada pendente: ninguém em risco nem com mensalidades vencidas.",
|
||||||
"overdue_one": "{{count}} cobrança vencida",
|
|
||||||
"overdue_other": "{{count}} cobranças vencidas",
|
|
||||||
"overdueHint": "Confira em Cobranças",
|
|
||||||
"preRegistrations_one": "{{count}} pré-inscrição para aprovar",
|
"preRegistrations_one": "{{count}} pré-inscrição para aprovar",
|
||||||
"preRegistrations_other": "{{count}} pré-inscrições para aprovar",
|
"preRegistrations_other": "{{count}} pré-inscrições para aprovar",
|
||||||
"moreAtRisk": "E mais {{count}} em risco. Veja as estatísticas de cada grupo."
|
"seeAll": "Ver tudo",
|
||||||
|
"more_one": "Mais {{count}} pessoa para atender",
|
||||||
|
"more_other": "Mais {{count}} pessoas para atender",
|
||||||
|
"loadError": "Não conseguimos carregar as pendências."
|
||||||
|
},
|
||||||
|
"loading": "Carregando seu dia…",
|
||||||
|
"teaser": {
|
||||||
|
"sample1": "Sofia Martins",
|
||||||
|
"sample2": "Tomás Rocha",
|
||||||
|
"description": "Com o Pro, aqui você vê quem deve e quanto, e cobra com links do Mercado Pago.",
|
||||||
|
"cta": "Conheça o Pro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,26 +7,30 @@
|
|||||||
"whatsapp": "WhatsApp",
|
"whatsapp": "WhatsApp",
|
||||||
"group": "Seu grupo",
|
"group": "Seu grupo",
|
||||||
"done": "Pronto",
|
"done": "Pronto",
|
||||||
"progress": "Progresso do cadastro"
|
"progress": "Progresso do cadastro",
|
||||||
|
"position": "Passo {{current}} de {{total}}"
|
||||||
},
|
},
|
||||||
"continue": "Continuar",
|
"continue": "Continuar",
|
||||||
"later": "Faço depois",
|
"later": "Faço depois",
|
||||||
"signedOut": {
|
"signedOut": {
|
||||||
"title": "Sua conta, pronta",
|
"title": "Entre para continuar",
|
||||||
"description": "Entre para configurar suas cobranças e criar seu primeiro grupo.",
|
"description": "Entre para configurar suas cobranças e criar seu primeiro grupo.",
|
||||||
"action": "Entrar"
|
"action": "Entrar"
|
||||||
},
|
},
|
||||||
"fallbackName": "professor",
|
"fallbackName": "professor",
|
||||||
"welcome": {
|
"welcome": {
|
||||||
"title": "Olá, {{name}}!",
|
"title": "Olá, {{name}}!",
|
||||||
"description": "Vamos configurar sua conta em 3 passos. Leva menos de 5 minutos.",
|
"description": "Em poucos minutos sua conta fica pronta para cobrar seus membros e registrar a presença nas aulas.",
|
||||||
"step1Title": "Conecte sua conta de recebimento",
|
"start": "Começar",
|
||||||
"step1": "Vincule o Mercado Pago e cobre seus membros pelo grupo.",
|
"previewCaption": "Com o Pro, o Gruperly lembra seus membros dos pagamentos pelo WhatsApp, a partir do seu número:",
|
||||||
"step2Title": "Crie seu primeiro grupo",
|
"arc": {
|
||||||
"step2": "Dias, horário, preço e vagas da sua aula.",
|
"setupTitle": "Seu país e seu plano",
|
||||||
"step3Title": "Comece a cobrar",
|
"setup": "Para cobrar na sua moeda. Você pode começar grátis.",
|
||||||
"step3": "Tudo pronto para adicionar membros e cobrar na hora.",
|
"connectTitle": "Cobranças e WhatsApp",
|
||||||
"start": "Começar"
|
"connect": "Opcional, com o Pro: Mercado Pago e lembretes automáticos.",
|
||||||
|
"groupTitle": "Seu primeiro grupo",
|
||||||
|
"group": "Dias, horário, preço e vagas da sua aula."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"country": {
|
"country": {
|
||||||
"title": "Em que país você vai cobrar?",
|
"title": "Em que país você vai cobrar?",
|
||||||
@@ -54,7 +58,7 @@
|
|||||||
"loading": "Consultando sua conta…",
|
"loading": "Consultando sua conta…",
|
||||||
"linkedOn": "Vinculada em {{date}}.",
|
"linkedOn": "Vinculada em {{date}}.",
|
||||||
"connectedHint": "Os pagamentos dos seus grupos vão entrar nesta conta.",
|
"connectedHint": "Os pagamentos dos seus grupos vão entrar nesta conta.",
|
||||||
"connectHint": "Vamos te levar ao Mercado Pago para autorizar as cobranças. Os pagamentos entram direto na sua conta, sem intermediários.",
|
"connectHint": "Levamos você ao Mercado Pago para autorizar o Gruperly: usamos isso para criar os links de cobrança dos seus membros e ver quais foram pagos. O dinheiro cai direto na sua conta, sem intermediários.",
|
||||||
"opening": "Abrindo o Mercado Pago…",
|
"opening": "Abrindo o Mercado Pago…",
|
||||||
"change": "Trocar de conta",
|
"change": "Trocar de conta",
|
||||||
"connect": "Vincular conta"
|
"connect": "Vincular conta"
|
||||||
@@ -67,27 +71,42 @@
|
|||||||
"qrHint": "Você vincula com seu número de telefone ou escaneando um QR code, como no WhatsApp Web.",
|
"qrHint": "Você vincula com seu número de telefone ou escaneando um QR code, como no WhatsApp Web.",
|
||||||
"metaHint": "Vamos te levar à Meta para conectar sua conta do WhatsApp Business.",
|
"metaHint": "Vamos te levar à Meta para conectar sua conta do WhatsApp Business.",
|
||||||
"perGroup": "Os envios automáticos você ativa depois em cada grupo.",
|
"perGroup": "Os envios automáticos você ativa depois em cada grupo.",
|
||||||
"opening": "Abrindo…",
|
"opening": "Preparando a vinculação…",
|
||||||
"connect": "Vincular WhatsApp"
|
"connect": "Vincular WhatsApp",
|
||||||
|
"previewCaption": "Isto é o que recebe um membro com a mensalidade pendente:",
|
||||||
|
"connected": "As mensagens saem do seu número.",
|
||||||
|
"connectedWith": "As mensagens saem de {{phone}}."
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"heading": "Seu primeiro grupo"
|
"heading": "Seu primeiro grupo",
|
||||||
|
"choosePlan": "Escolher um plano"
|
||||||
},
|
},
|
||||||
"done": {
|
"done": {
|
||||||
"title": "Tudo pronto!",
|
"title": "Seu grupo está pronto",
|
||||||
"description": "Seu grupo foi criado. Agora você pode convidar membros e fazer a chamada.",
|
"description": "Agora adicione seus membros: envie este link, eles preenchem os dados e você aprova cada solicitação.",
|
||||||
"active": "Ativo",
|
|
||||||
"price": "Preço",
|
"price": "Preço",
|
||||||
"capacity": "Vagas",
|
"capacity": "Vagas",
|
||||||
"capacityValue": "{{count}} membros",
|
"capacityValue": "{{count}} membros",
|
||||||
"dueDay": "Vencimento",
|
"dueDay": "Vencimento",
|
||||||
"dueDayValue": "Todo dia {{day}}",
|
"dueDayValue": "Todo dia {{day}}",
|
||||||
"plan": "Você está no plano <strong>{{plan}}</strong>.",
|
"previewCaption": "A mensagem que você vai compartilhar:",
|
||||||
"freeHint": " Quando quiser cobrar com Mercado Pago ou automatizar o WhatsApp, mude para o Pro em Ajustes.",
|
"previewContact": "Seus membros",
|
||||||
"mpConnected": "Você vai cobrar com <strong>Mercado Pago</strong>. Os pagamentos entram direto na sua conta.",
|
"linkLoading": "Gerando o link…",
|
||||||
"mpPending": "Quando quiser cobrar, vincule o <strong>Mercado Pago</strong> em Ajustes. Seu grupo já foi criado.",
|
"linkError": "Não conseguimos gerar o link de convite.",
|
||||||
"waConnected": "Seu WhatsApp está vinculado. Ative os lembretes de pagamento e o reengajamento na página do grupo.",
|
"share": "Compartilhar no WhatsApp",
|
||||||
"waPending": "Para enviar lembretes automáticos, vincule o <strong>WhatsApp</strong> em Ajustes.",
|
"copyLink": "Copiar link",
|
||||||
"goToPanel": "Ir para o meu painel"
|
"statusFree": "Você está no {{plan}}. Cobrar com o Mercado Pago e automatizar o WhatsApp é do Pro: ative quando quiser em Ajustes.",
|
||||||
|
"statusAllSet": "Mercado Pago e WhatsApp vinculados. Ative os lembretes na página do grupo.",
|
||||||
|
"statusPendingBoth": "Quando quiser cobrar e enviar lembretes, vincule o Mercado Pago e o WhatsApp em Ajustes.",
|
||||||
|
"statusPendingMp": "O WhatsApp foi vinculado. Para cobrar, vincule o Mercado Pago em Ajustes.",
|
||||||
|
"statusPendingWa": "O Mercado Pago foi vinculado. Para os lembretes automáticos, vincule o WhatsApp em Ajustes.",
|
||||||
|
"goHome": "Ir para o início"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"sampleStudent": "Sofia",
|
||||||
|
"sampleStudentFull": "Sofia Martins",
|
||||||
|
"sampleGroup": "Yoga · Nível 1",
|
||||||
|
"reminder": "Olá, {{name}}! Lembramos do pagamento de {{group}} no valor de {{amount}}, com vencimento em {{date}}. Você pode pagar por este link:",
|
||||||
|
"sampleLink": "mercadopago.com/checkout/…"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
/* Animations */
|
/* Animations */
|
||||||
--animate-fade-in: fade-in 0.2s ease-out;
|
--animate-fade-in: fade-in 0.2s ease-out;
|
||||||
--animate-step-enter: step-enter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
|
--animate-step-enter: step-enter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||||
|
--animate-step-enter-back: step-enter-back 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||||
--animate-sheet-up: sheet-up 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
--animate-sheet-up: sheet-up 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||||
|
|
||||||
@keyframes fade-in {
|
@keyframes fade-in {
|
||||||
@@ -114,6 +115,18 @@
|
|||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Al volver un paso, el contenido entra desde la izquierda. */
|
||||||
|
@keyframes step-enter-back {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(-1.5rem);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
@@ -111,6 +111,37 @@ export function formatPrice(
|
|||||||
return tidyCurrencySpacing(formatter.format(price))
|
return tidyCurrencySpacing(formatter.format(price))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** El símbolo de la moneda tal como lo escribe `formatPrice` ("$", "R$", "S/").
|
||||||
|
Sin moneda, la del país del navegador, igual que `formatPrice`. */
|
||||||
|
export function currencySymbol(currency?: string): string {
|
||||||
|
const browser = browserLocale()
|
||||||
|
const country = countryOf(browser)
|
||||||
|
const resolvedCurrency = currency ?? currencyForRegion(country)
|
||||||
|
if (!resolvedCurrency) return '$'
|
||||||
|
try {
|
||||||
|
const parts = new Intl.NumberFormat(localeForRegion(country) ?? browser, {
|
||||||
|
style: 'currency',
|
||||||
|
currency: resolvedCurrency,
|
||||||
|
currencyDisplay: 'narrowSymbol',
|
||||||
|
}).formatToParts(0)
|
||||||
|
return parts.find((part) => part.type === 'currency')?.value ?? '$'
|
||||||
|
} catch {
|
||||||
|
return '$'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** La hora de una clase: "19:00" en español y portugués (reloj de 24 h, que
|
||||||
|
es como se anuncia una clase en la región, aunque el sistema use 12 h) y la
|
||||||
|
del idioma en el resto ("7:00 PM"). */
|
||||||
|
export function formatClockTime(date: Date | string, locale: string): string {
|
||||||
|
const uses24h = /^(es|pt)\b/i.test(locale)
|
||||||
|
return new Intl.DateTimeFormat(locale, {
|
||||||
|
hour: 'numeric',
|
||||||
|
minute: '2-digit',
|
||||||
|
...(uses24h ? { hourCycle: 'h23' as const } : {}),
|
||||||
|
}).format(typeof date === 'string' ? new Date(date) : date)
|
||||||
|
}
|
||||||
|
|
||||||
/* Intl separates the currency symbol with a hard space: "$ 50.000" reads as two
|
/* Intl separates the currency symbol with a hard space: "$ 50.000" reads as two
|
||||||
loose tokens. We strip it only when it separates symbol from number; between
|
loose tokens. We strip it only when it separates symbol from number; between
|
||||||
digits and the code ("50.000 ARS") the non-breaking space prevents the
|
digits and the code ("50.000 ARS") the non-breaking space prevents the
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
import { OnboardingProvider } from '../features/onboarding/OnboardingProvider'
|
import { OnboardingProvider } from '../features/onboarding/OnboardingProvider'
|
||||||
import { OnboardingView } from '../features/onboarding/OnboardingView'
|
import { OnboardingView } from '../features/onboarding/OnboardingView'
|
||||||
|
import { type OnboardingStepId, parseStep } from '../features/onboarding/steps'
|
||||||
|
|
||||||
export const Route = createFileRoute('/onboarding')({
|
export const Route = createFileRoute('/onboarding')({
|
||||||
/* Los callbacks de Mercado Pago (`?mp=`) y de WhatsApp por redirect (`?wa=`)
|
/* Los callbacks de Mercado Pago (`?mp=`) y de WhatsApp por redirect (`?wa=`)
|
||||||
devuelven el control acá con `success` o `error&reason=…`; la suscripción a
|
devuelven el control acá con `success` o `error&reason=…`; la suscripción a
|
||||||
Pro vuelve con `?sub=return`. Se validan como
|
Pro vuelve con `?sub=return`. El paso actual vive en `?step=` para que el
|
||||||
|
back del dispositivo retroceda un paso. Se validan como
|
||||||
search params para que el provider tenga los valores ya tipados y no tenga
|
search params para que el provider tenga los valores ya tipados y no tenga
|
||||||
que leer el `location` crudo. */
|
que leer el `location` crudo. */
|
||||||
validateSearch: (
|
validateSearch: (
|
||||||
search: Record<string, unknown>,
|
search: Record<string, unknown>,
|
||||||
): { mp?: string; wa?: string; reason?: string; sub?: string } => ({
|
): { mp?: string; wa?: string; reason?: string; sub?: string; step?: OnboardingStepId } => ({
|
||||||
mp: typeof search.mp === 'string' ? search.mp : undefined,
|
mp: typeof search.mp === 'string' ? search.mp : undefined,
|
||||||
wa: typeof search.wa === 'string' ? search.wa : undefined,
|
wa: typeof search.wa === 'string' ? search.wa : undefined,
|
||||||
reason: typeof search.reason === 'string' ? search.reason : undefined,
|
reason: typeof search.reason === 'string' ? search.reason : undefined,
|
||||||
sub: typeof search.sub === 'string' ? search.sub : undefined,
|
sub: typeof search.sub === 'string' ? search.sub : undefined,
|
||||||
|
step: parseStep(search.step),
|
||||||
}),
|
}),
|
||||||
component: () => (
|
component: () => (
|
||||||
<OnboardingProvider>
|
<OnboardingProvider>
|
||||||
|
|||||||
54
apps/web/test/home-day.test.ts
Normal file
54
apps/web/test/home-day.test.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { describe, expect, test } from 'bun:test'
|
||||||
|
import type { ClassTodayDto } from '@gruperly/shared'
|
||||||
|
import { classState, planDay } from '../src/features/home/day'
|
||||||
|
import { formatClockTime } from '../src/lib/format'
|
||||||
|
|
||||||
|
function session(id: string, startsAt: string, hasAttendance = false): ClassTodayDto {
|
||||||
|
return {
|
||||||
|
sessionId: id,
|
||||||
|
groupId: `g-${id}`,
|
||||||
|
groupName: `Grupo ${id}`,
|
||||||
|
startsAt,
|
||||||
|
enrolledCount: 5,
|
||||||
|
capacity: 10,
|
||||||
|
availableSlots: 5,
|
||||||
|
hasAttendance,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = new Date('2026-11-05T22:00:00.000Z')
|
||||||
|
|
||||||
|
describe('el día del Inicio', () => {
|
||||||
|
test('estado de cada clase', () => {
|
||||||
|
expect(classState(session('a', '2026-11-05T23:00:00.000Z'), now)).toBe('upcoming')
|
||||||
|
expect(classState(session('b', '2026-11-05T21:00:00.000Z'), now)).toBe('live')
|
||||||
|
expect(classState(session('c', '2026-11-05T18:00:00.000Z'), now)).toBe('missed')
|
||||||
|
expect(classState(session('d', '2026-11-05T21:00:00.000Z', true), now)).toBe('taken')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('el hero es la clase en curso o la próxima sin asistencia; el resto va en orden', () => {
|
||||||
|
const morning = session('m', '2026-11-05T12:00:00.000Z', true)
|
||||||
|
const live = session('l', '2026-11-05T21:30:00.000Z')
|
||||||
|
const later = session('n', '2026-11-05T23:30:00.000Z')
|
||||||
|
const { hero, rest } = planDay([later, morning, live], now)
|
||||||
|
expect(hero?.sessionId).toBe('l')
|
||||||
|
expect(rest.map((item) => item.sessionId)).toEqual(['m', 'n'])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('terminado el día no hay hero: las clases quedan en la lista', () => {
|
||||||
|
const missed = session('x', '2026-11-05T18:00:00.000Z')
|
||||||
|
const taken = session('y', '2026-11-05T19:00:00.000Z', true)
|
||||||
|
const { hero, rest } = planDay([taken, missed], now)
|
||||||
|
expect(hero).toBeNull()
|
||||||
|
expect(rest.map((item) => item.sessionId)).toEqual(['x', 'y'])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('hora de una clase', () => {
|
||||||
|
test('24 h en español y portugués', () => {
|
||||||
|
const date = new Date(2026, 10, 5, 19, 0)
|
||||||
|
expect(formatClockTime(date, 'es-AR')).toBe('19:00')
|
||||||
|
expect(formatClockTime(date, 'pt-BR')).toBe('19:00')
|
||||||
|
expect(formatClockTime(new Date(2026, 10, 5, 9, 5), 'es-419')).toBe('09:05')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, test } from 'bun:test'
|
import { describe, expect, test } from 'bun:test'
|
||||||
import type { OnboardingStatusDto } from '@gruperly/shared'
|
import type { OnboardingStatusDto } from '@gruperly/shared'
|
||||||
import { resumeStep, visibleSteps } from '../src/features/onboarding/steps'
|
import { effectiveStep, parseStep, resumeStep, visibleSteps } from '../src/features/onboarding/steps'
|
||||||
|
|
||||||
function status(overrides: Partial<OnboardingStatusDto> = {}): OnboardingStatusDto {
|
function status(overrides: Partial<OnboardingStatusDto> = {}): OnboardingStatusDto {
|
||||||
return {
|
return {
|
||||||
@@ -46,3 +46,30 @@ describe('pasos del onboarding', () => {
|
|||||||
).toBe('group')
|
).toBe('group')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('paso pedido por la URL', () => {
|
||||||
|
test('solo acepta ids de pasos conocidos', () => {
|
||||||
|
expect(parseStep('plan')).toBe('plan')
|
||||||
|
expect(parseStep('nope')).toBeUndefined()
|
||||||
|
expect(parseStep(undefined)).toBeUndefined()
|
||||||
|
expect(parseStep(3)).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('sin plan elegido no se pasa del paso Plan', () => {
|
||||||
|
expect(effectiveStep('group', { plan: null, hasCreatedGroup: false })).toBe('plan')
|
||||||
|
expect(effectiveStep('payment', { plan: null, hasCreatedGroup: false })).toBe('plan')
|
||||||
|
expect(effectiveStep('country', { plan: null, hasCreatedGroup: false })).toBe('country')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('con Free no se muestran Cobros ni WhatsApp', () => {
|
||||||
|
expect(effectiveStep('payment', { plan: 'FREE', hasCreatedGroup: false })).toBe('group')
|
||||||
|
expect(effectiveStep('whatsapp', { plan: 'FREE', hasCreatedGroup: false })).toBe('group')
|
||||||
|
expect(effectiveStep('payment', { plan: 'PRO', hasCreatedGroup: false })).toBe('payment')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('"Listo" necesita el grupo creado, y con el grupo creado no se vuelve al formulario', () => {
|
||||||
|
expect(effectiveStep('done', { plan: 'PRO', hasCreatedGroup: false })).toBe('group')
|
||||||
|
expect(effectiveStep('group', { plan: 'PRO', hasCreatedGroup: true })).toBe('done')
|
||||||
|
expect(effectiveStep('plan', { plan: 'FREE', hasCreatedGroup: true })).toBe('done')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user