feat: add subscription plans. Add admin panel. Add password recovery
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { ChevronDown, LogOut, Settings, UserRound, X } from 'lucide-react'
|
||||
import { ChevronDown, LogOut, Settings, ShieldCheck, UserRound, X } from 'lucide-react'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { signOut } from '../../lib/auth-client'
|
||||
import { useAuth } from '../../context/AuthProvider'
|
||||
import { useIsMobile } from '../../hooks/useIsMobile'
|
||||
import { useAdminAccess } from '../../features/admin/useAdminAccess'
|
||||
import { Avatar } from '../ui'
|
||||
|
||||
const itemClass =
|
||||
@@ -17,6 +18,8 @@ export function UserMenu() {
|
||||
const [open, setOpen] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const navigate = useNavigate()
|
||||
// Solo el equipo de Gruperly ve el acceso al backoffice.
|
||||
const isAdmin = useAdminAccess(!!user).data?.isAdmin ?? false
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || isMobile) return
|
||||
@@ -124,6 +127,17 @@ export function UserMenu() {
|
||||
<Settings className="size-5 text-foreground/60" />
|
||||
Ajustes
|
||||
</Link>
|
||||
{isAdmin ? (
|
||||
<Link
|
||||
role="menuitem"
|
||||
to="/admin"
|
||||
onClick={() => setOpen(false)}
|
||||
className={cn(itemClass, 'py-3.5')}
|
||||
>
|
||||
<ShieldCheck className="size-5 text-foreground/60" />
|
||||
Backoffice
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<button
|
||||
@@ -162,6 +176,12 @@ export function UserMenu() {
|
||||
<Settings className="size-4 text-foreground/60" />
|
||||
Ajustes
|
||||
</Link>
|
||||
{isAdmin ? (
|
||||
<Link role="menuitem" to="/admin" onClick={() => setOpen(false)} className={itemClass}>
|
||||
<ShieldCheck className="size-4 text-foreground/60" />
|
||||
Backoffice
|
||||
</Link>
|
||||
) : null}
|
||||
<div className="mx-3 my-1 h-px bg-border" />
|
||||
<button type="button" role="menuitem" onClick={handleSignOut} className={itemClass}>
|
||||
<LogOut className="size-4 text-foreground/60" />
|
||||
|
||||
60
apps/web/src/features/admin/AdminAccountDetailProvider.tsx
Normal file
60
apps/web/src/features/admin/AdminAccountDetailProvider.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { AdminAccountDetail } from '@gruperly/shared'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { ReactNode } from 'react'
|
||||
import { createContext, useContext } from 'react'
|
||||
import { ApiError, getAdminAccount } from '../../lib/api'
|
||||
|
||||
type AdminAccountDetailContextValue = {
|
||||
account: AdminAccountDetail | null
|
||||
isPending: boolean
|
||||
isError: boolean
|
||||
isNotFound: boolean
|
||||
errorMessage: string | null
|
||||
retry: () => void
|
||||
}
|
||||
|
||||
const AdminAccountDetailContext = createContext<AdminAccountDetailContextValue | null>(null)
|
||||
|
||||
export function AdminAccountDetailProvider({
|
||||
accountId,
|
||||
children,
|
||||
}: {
|
||||
accountId: string
|
||||
children: ReactNode
|
||||
}) {
|
||||
const accountQuery = useQuery({
|
||||
queryKey: ['admin', 'accounts', 'detail', accountId],
|
||||
queryFn: () => getAdminAccount(accountId),
|
||||
})
|
||||
|
||||
const error = accountQuery.error
|
||||
const isNotFound = error instanceof ApiError && error.status === 404
|
||||
const errorMessage = accountQuery.isError
|
||||
? error instanceof ApiError
|
||||
? (error.problem?.detail ?? 'No pudimos cargar la cuenta.')
|
||||
: 'No pudimos cargar la cuenta.'
|
||||
: null
|
||||
|
||||
return (
|
||||
<AdminAccountDetailContext.Provider
|
||||
value={{
|
||||
account: accountQuery.data ?? null,
|
||||
isPending: accountQuery.isPending,
|
||||
isError: accountQuery.isError,
|
||||
isNotFound,
|
||||
errorMessage,
|
||||
retry: () => void accountQuery.refetch(),
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</AdminAccountDetailContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useAdminAccountDetail() {
|
||||
const context = useContext(AdminAccountDetailContext)
|
||||
if (!context) {
|
||||
throw new Error('useAdminAccountDetail debe usarse dentro de <AdminAccountDetailProvider>')
|
||||
}
|
||||
return context
|
||||
}
|
||||
160
apps/web/src/features/admin/AdminAccountDetailView.tsx
Normal file
160
apps/web/src/features/admin/AdminAccountDetailView.tsx
Normal file
@@ -0,0 +1,160 @@
|
||||
import type { AdminAccountDetail } from '@gruperly/shared'
|
||||
import { PLAN_LIMITS } from '@gruperly/shared'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ArrowLeft, Loader2 } from 'lucide-react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Badge, Button } from '../../components/ui'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { formatBillingDate, formatUsage, subscriptionStatusLabel } from '../billing'
|
||||
import { useAdminAccountDetail } from './AdminAccountDetailProvider'
|
||||
import {
|
||||
countryLabel,
|
||||
MP_STATUS_LABELS,
|
||||
planLabel,
|
||||
planVariant,
|
||||
subscriptionVariant,
|
||||
WHATSAPP_STATUS_LABELS,
|
||||
} from './copy'
|
||||
|
||||
export function AdminAccountDetailView() {
|
||||
const { account, isPending, isError, isNotFound, errorMessage, retry } = useAdminAccountDetail()
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Link
|
||||
to="/admin"
|
||||
className="hidden items-center gap-1.5 text-sm font-medium text-foreground/60 hover:text-primary lg:inline-flex"
|
||||
>
|
||||
<ArrowLeft className="size-4" aria-hidden="true" />
|
||||
Cuentas
|
||||
</Link>
|
||||
|
||||
{/* El h1 va siempre, también cargando, para que el layout no salte. */}
|
||||
<h1 className="mt-2 truncate text-2xl font-bold text-primary">{account?.name ?? 'Cuenta'}</h1>
|
||||
{account ? <p className="mt-0.5 truncate text-sm text-foreground/60">{account.email}</p> : null}
|
||||
|
||||
{isPending ? (
|
||||
<div className="mt-8 flex items-center justify-center py-16" role="status">
|
||||
<Loader2 className="size-6 animate-spin text-secondary/50" aria-hidden="true" />
|
||||
<span className="sr-only">Cargando cuenta</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isError ? (
|
||||
<div className="mt-8 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||
<p>{isNotFound ? 'Esta cuenta no existe.' : errorMessage}</p>
|
||||
{isNotFound ? null : (
|
||||
<Button variant="outline" size="sm" onClick={retry}>
|
||||
Reintentar
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{account ? <AccountDetail account={account} /> : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
function AccountDetail({ account }: { account: AdminAccountDetail }) {
|
||||
const subscription = account.subscription
|
||||
const limits = PLAN_LIMITS[account.plan ?? 'FREE']
|
||||
|
||||
return (
|
||||
<div className="mt-6 grid gap-4 lg:grid-cols-2">
|
||||
<Card title="Cuenta">
|
||||
<Field label="País">{countryLabel(account.country)}</Field>
|
||||
<Field label="Alta">{formatBillingDate(account.createdAt)}</Field>
|
||||
<Field label="Onboarding">{account.onboardingCompleted ? 'Completo' : 'Sin terminar'}</Field>
|
||||
<Field label="Mercado Pago">{MP_STATUS_LABELS[account.mpStatus ?? 'NONE']}</Field>
|
||||
<Field label="WhatsApp">{WHATSAPP_STATUS_LABELS[account.whatsappStatus ?? 'NONE']}</Field>
|
||||
</Card>
|
||||
|
||||
<Card title="Plan">
|
||||
<Field label="Plan">
|
||||
<span className="inline-flex flex-wrap items-center gap-1.5">
|
||||
<Badge variant={planVariant(account.plan)}>{planLabel(account.plan)}</Badge>
|
||||
{account.readOnly ? <Badge variant="danger">Solo lectura</Badge> : null}
|
||||
</span>
|
||||
</Field>
|
||||
<Field label="Elegido el">{formatBillingDate(account.planSelectedAt) ?? '—'}</Field>
|
||||
<Field label="Suscripción">
|
||||
<Badge variant={subscriptionVariant(subscription?.status ?? null)}>
|
||||
{subscriptionStatusLabel(subscription?.status ?? null)}
|
||||
</Badge>
|
||||
</Field>
|
||||
{subscription ? (
|
||||
<>
|
||||
<Field label="Precio">{formatPrice(subscription.amount, subscription.currency)} / mes</Field>
|
||||
<Field label="Pagado hasta">{formatBillingDate(subscription.paidThrough) ?? '—'}</Field>
|
||||
<Field label="Próximo cobro">{formatBillingDate(subscription.nextPaymentDate) ?? '—'}</Field>
|
||||
<Field label="Email de pago">{subscription.payerEmail}</Field>
|
||||
</>
|
||||
) : null}
|
||||
{account.graceUntil ? (
|
||||
<Field label="En gracia hasta">{formatBillingDate(account.graceUntil)}</Field>
|
||||
) : null}
|
||||
</Card>
|
||||
|
||||
<Card title="Uso">
|
||||
<Field label="Grupos">{formatUsage(account.groupsCount, limits.maxGroups)}</Field>
|
||||
<Field label="Alumnos activos">{formatUsage(account.attendeesCount, limits.maxAttendees)}</Field>
|
||||
{account.groups.length > 0 ? (
|
||||
<ul className="mt-2 divide-y divide-border border-t border-border">
|
||||
{account.groups.map((group) => (
|
||||
<li key={group.id} className="flex items-center justify-between gap-3 py-2 text-sm">
|
||||
<span className="min-w-0 truncate text-primary">{group.name}</span>
|
||||
<span className="shrink-0 text-xs text-foreground/60">
|
||||
{group.attendeesCount} {group.attendeesCount === 1 ? 'alumno' : 'alumnos'} · desde{' '}
|
||||
{formatBillingDate(group.createdAt)}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="mt-2 text-sm text-foreground/60">Todavía no creó grupos.</p>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card title="Cobros de Gruperly">
|
||||
{account.charges.length > 0 ? (
|
||||
<ul className="divide-y divide-border">
|
||||
{account.charges.map((charge) => (
|
||||
<li key={charge.id} className="flex items-center justify-between gap-3 py-2 text-sm">
|
||||
<span className="text-primary">
|
||||
{formatBillingDate(charge.paidAt ?? charge.createdAt)}
|
||||
</span>
|
||||
<span className="flex items-center gap-2">
|
||||
<span className="tabular-nums text-foreground/70">
|
||||
{formatPrice(charge.amount, charge.currency)}
|
||||
</span>
|
||||
<Badge variant={charge.status === 'approved' ? 'success' : 'warning'}>{charge.status}</Badge>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="text-sm text-foreground/60">Sin cobros registrados.</p>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Card({ title, children }: { title: string; children: ReactNode }) {
|
||||
return (
|
||||
<div className="rounded-xl border border-border bg-surface p-4">
|
||||
<h2 className="text-sm font-semibold uppercase tracking-wide text-foreground/50">{title}</h2>
|
||||
<div className="mt-3 space-y-2">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Field({ label, children }: { label: string; children: ReactNode }) {
|
||||
return (
|
||||
<div className="flex items-start justify-between gap-4 text-sm">
|
||||
<span className="shrink-0 text-foreground/60">{label}</span>
|
||||
<span className="min-w-0 text-right text-primary [overflow-wrap:anywhere]">{children}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
72
apps/web/src/features/admin/AdminAccountRow.tsx
Normal file
72
apps/web/src/features/admin/AdminAccountRow.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import type { AdminAccountListItem } from '@gruperly/shared'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ChevronRight } from 'lucide-react'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { formatBillingDate, subscriptionStatusLabel } from '../billing'
|
||||
import { countryLabel, planLabel, planVariant, subscriptionVariant } from './copy'
|
||||
|
||||
/** Columnas de la grilla en `lg+`; el encabezado de `AdminAccountsView` usa las mismas. */
|
||||
export const ACCOUNT_GRID_COLUMNS =
|
||||
'lg:grid-cols-[minmax(0,2.2fr)_minmax(0,1fr)_minmax(0,0.8fr)_minmax(0,1.6fr)_4.5rem_4.5rem_1rem]'
|
||||
|
||||
/* Una cuenta de la lista: tarjeta en móvil, fila de la grilla en escritorio. */
|
||||
export function AdminAccountRow({ account }: { account: AdminAccountListItem }) {
|
||||
const subscription = account.subscription
|
||||
const status = subscription?.status ?? null
|
||||
const paidThrough = formatBillingDate(subscription?.paidThrough ?? null)
|
||||
const planBadge = <Badge variant={planVariant(account.plan)}>{planLabel(account.plan)}</Badge>
|
||||
const statusBadge = <Badge variant={subscriptionVariant(status)}>{subscriptionStatusLabel(status)}</Badge>
|
||||
|
||||
return (
|
||||
<li>
|
||||
<Link
|
||||
to="/admin/accounts/$accountId"
|
||||
params={{ accountId: account.id }}
|
||||
className="block rounded-xl border border-border bg-surface px-4 py-3 transition-colors hover:bg-primary-soft lg:rounded-none lg:border-0 lg:border-b lg:bg-transparent"
|
||||
>
|
||||
{/* Móvil */}
|
||||
<div className="lg:hidden">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-semibold text-primary">{account.name}</p>
|
||||
<p className="truncate text-xs text-foreground/60">{account.email}</p>
|
||||
</div>
|
||||
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
||||
</div>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-1.5">
|
||||
{planBadge}
|
||||
{statusBadge}
|
||||
</div>
|
||||
<p className="mt-2 text-xs text-foreground/60">
|
||||
{countryLabel(account.country)} · {account.groupsCount}{' '}
|
||||
{account.groupsCount === 1 ? 'grupo' : 'grupos'} · {account.attendeesCount}{' '}
|
||||
{account.attendeesCount === 1 ? 'alumno' : 'alumnos'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Escritorio */}
|
||||
<div className={`hidden items-center gap-4 lg:grid ${ACCOUNT_GRID_COLUMNS}`}>
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-semibold text-primary">{account.name}</p>
|
||||
<p className="truncate text-xs text-foreground/60">{account.email}</p>
|
||||
</div>
|
||||
<p className="truncate text-sm text-foreground/70">{countryLabel(account.country)}</p>
|
||||
<div>{planBadge}</div>
|
||||
<div className="min-w-0">
|
||||
{statusBadge}
|
||||
{subscription ? (
|
||||
<p className="mt-1 truncate text-xs text-foreground/50">
|
||||
{formatPrice(subscription.amount, subscription.currency)}
|
||||
{paidThrough ? ` · hasta ${paidThrough}` : ''}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="text-right text-sm tabular-nums text-foreground/70">{account.groupsCount}</p>
|
||||
<p className="text-right text-sm tabular-nums text-foreground/70">{account.attendeesCount}</p>
|
||||
<ChevronRight className="size-4 text-foreground/40" aria-hidden="true" />
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
123
apps/web/src/features/admin/AdminAccountsProvider.tsx
Normal file
123
apps/web/src/features/admin/AdminAccountsProvider.tsx
Normal file
@@ -0,0 +1,123 @@
|
||||
import type {
|
||||
AdminAccountListItem,
|
||||
AdminAccountQueryInput,
|
||||
AdminPlanFilter,
|
||||
AdminSubscriptionFilter,
|
||||
CountryCode,
|
||||
} from '@gruperly/shared'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { ReactNode } from 'react'
|
||||
import { createContext, useContext, useEffect, useMemo, useState } from 'react'
|
||||
import { ApiError, getAdminAccounts } from '../../lib/api'
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
const SEARCH_DEBOUNCE_MS = 300
|
||||
|
||||
type AdminAccountsContextValue = {
|
||||
accounts: AdminAccountListItem[]
|
||||
total: number
|
||||
page: number
|
||||
totalPages: number
|
||||
isPending: boolean
|
||||
isFetching: boolean
|
||||
isError: boolean
|
||||
errorMessage: string | null
|
||||
search: string
|
||||
setSearch: (search: string) => void
|
||||
country: CountryCode | null
|
||||
setCountry: (country: CountryCode | null) => void
|
||||
plan: AdminPlanFilter | null
|
||||
setPlan: (plan: AdminPlanFilter | null) => void
|
||||
subscriptionStatus: AdminSubscriptionFilter | null
|
||||
setSubscriptionStatus: (status: AdminSubscriptionFilter | null) => void
|
||||
setPage: (page: number) => void
|
||||
retry: () => void
|
||||
}
|
||||
|
||||
const AdminAccountsContext = createContext<AdminAccountsContextValue | null>(null)
|
||||
|
||||
export function AdminAccountsProvider({ children }: { children: ReactNode }) {
|
||||
const [page, setPage] = useState(1)
|
||||
const [search, setSearch] = useState('')
|
||||
const [debouncedSearch, setDebouncedSearch] = useState('')
|
||||
const [country, setCountry] = useState<CountryCode | null>(null)
|
||||
const [plan, setPlan] = useState<AdminPlanFilter | null>(null)
|
||||
const [subscriptionStatus, setSubscriptionStatus] = useState<AdminSubscriptionFilter | null>(null)
|
||||
|
||||
// La búsqueda espera a que se deje de tipear para no pedir una página por tecla.
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(() => {
|
||||
setDebouncedSearch(search.trim())
|
||||
setPage(1)
|
||||
}, SEARCH_DEBOUNCE_MS)
|
||||
return () => clearTimeout(timeout)
|
||||
}, [search])
|
||||
|
||||
const params = useMemo<AdminAccountQueryInput>(
|
||||
() => ({
|
||||
page,
|
||||
pageSize: PAGE_SIZE,
|
||||
search: debouncedSearch || undefined,
|
||||
country: country ?? undefined,
|
||||
plan: plan ?? undefined,
|
||||
subscriptionStatus: subscriptionStatus ?? undefined,
|
||||
}),
|
||||
[page, debouncedSearch, country, plan, subscriptionStatus],
|
||||
)
|
||||
|
||||
const accountsQuery = useQuery({
|
||||
queryKey: ['admin', 'accounts', params],
|
||||
queryFn: () => getAdminAccounts(params),
|
||||
placeholderData: (previous) => previous,
|
||||
})
|
||||
|
||||
const data = accountsQuery.data
|
||||
const errorMessage = accountsQuery.isError
|
||||
? accountsQuery.error instanceof ApiError
|
||||
? (accountsQuery.error.problem?.detail ?? 'No pudimos cargar las cuentas.')
|
||||
: 'No pudimos cargar las cuentas.'
|
||||
: null
|
||||
|
||||
// Cambiar un filtro vuelve a la primera página.
|
||||
const withFirstPage =
|
||||
<T,>(setter: (value: T) => void) =>
|
||||
(value: T) => {
|
||||
setter(value)
|
||||
setPage(1)
|
||||
}
|
||||
|
||||
return (
|
||||
<AdminAccountsContext.Provider
|
||||
value={{
|
||||
accounts: data?.data ?? [],
|
||||
total: data?.pagination.total ?? 0,
|
||||
page,
|
||||
totalPages: Math.max(data?.pagination.totalPages ?? 1, 1),
|
||||
isPending: accountsQuery.isPending,
|
||||
isFetching: accountsQuery.isFetching,
|
||||
isError: accountsQuery.isError,
|
||||
errorMessage,
|
||||
search,
|
||||
setSearch,
|
||||
country,
|
||||
setCountry: withFirstPage(setCountry),
|
||||
plan,
|
||||
setPlan: withFirstPage(setPlan),
|
||||
subscriptionStatus,
|
||||
setSubscriptionStatus: withFirstPage(setSubscriptionStatus),
|
||||
setPage,
|
||||
retry: () => void accountsQuery.refetch(),
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</AdminAccountsContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useAdminAccounts() {
|
||||
const context = useContext(AdminAccountsContext)
|
||||
if (!context) {
|
||||
throw new Error('useAdminAccounts debe usarse dentro de <AdminAccountsProvider>')
|
||||
}
|
||||
return context
|
||||
}
|
||||
198
apps/web/src/features/admin/AdminAccountsView.tsx
Normal file
198
apps/web/src/features/admin/AdminAccountsView.tsx
Normal file
@@ -0,0 +1,198 @@
|
||||
import type { AdminPlanFilter, AdminSubscriptionFilter, CountryCode } from '@gruperly/shared'
|
||||
import { ChevronLeft, ChevronRight, Loader2, Search, Users } from 'lucide-react'
|
||||
import { Button, Input } from '../../components/ui'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { ACCOUNT_GRID_COLUMNS, AdminAccountRow } from './AdminAccountRow'
|
||||
import { useAdminAccounts } from './AdminAccountsProvider'
|
||||
import { COUNTRY_OPTIONS, PLAN_FILTER_OPTIONS, SUBSCRIPTION_FILTER_OPTIONS } from './copy'
|
||||
|
||||
const selectClass =
|
||||
'h-10 w-full rounded-xl border border-border bg-surface px-3 text-base text-primary sm:text-sm focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/30'
|
||||
|
||||
export function AdminAccountsView() {
|
||||
const {
|
||||
accounts,
|
||||
total,
|
||||
page,
|
||||
totalPages,
|
||||
isPending,
|
||||
isFetching,
|
||||
isError,
|
||||
errorMessage,
|
||||
search,
|
||||
setSearch,
|
||||
country,
|
||||
setCountry,
|
||||
plan,
|
||||
setPlan,
|
||||
subscriptionStatus,
|
||||
setSubscriptionStatus,
|
||||
setPage,
|
||||
retry,
|
||||
} = useAdminAccounts()
|
||||
|
||||
const hasFilters = !!search.trim() || !!country || !!plan || !!subscriptionStatus
|
||||
|
||||
return (
|
||||
<section>
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-primary">Cuentas</h1>
|
||||
<p className="mt-1 text-sm text-foreground/60">
|
||||
Profesores que usan Gruperly, con su plan y su uso.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-5 grid gap-3 sm:grid-cols-2 lg:grid-cols-[minmax(0,2fr)_repeat(3,minmax(0,1fr))]">
|
||||
<label className="block sm:col-span-2 lg:col-span-1">
|
||||
<span className="mb-1.5 block text-sm font-medium text-primary">Buscar</span>
|
||||
<div className="relative">
|
||||
<Search
|
||||
className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-foreground/40"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Input
|
||||
type="search"
|
||||
autoFocus
|
||||
value={search}
|
||||
onChange={(event) => setSearch(event.target.value)}
|
||||
placeholder="Nombre o email"
|
||||
className="pl-9"
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label className="block">
|
||||
<span className="mb-1.5 block text-sm font-medium text-primary">País</span>
|
||||
<select
|
||||
value={country ?? ''}
|
||||
onChange={(event) => setCountry((event.target.value || null) as CountryCode | null)}
|
||||
className={selectClass}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{COUNTRY_OPTIONS.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label className="block">
|
||||
<span className="mb-1.5 block text-sm font-medium text-primary">Plan</span>
|
||||
<select
|
||||
value={plan ?? ''}
|
||||
onChange={(event) => setPlan((event.target.value || null) as AdminPlanFilter | null)}
|
||||
className={selectClass}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{PLAN_FILTER_OPTIONS.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label className="block">
|
||||
<span className="mb-1.5 block text-sm font-medium text-primary">Suscripción</span>
|
||||
<select
|
||||
value={subscriptionStatus ?? ''}
|
||||
onChange={(event) =>
|
||||
setSubscriptionStatus((event.target.value || null) as AdminSubscriptionFilter | null)
|
||||
}
|
||||
className={selectClass}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{SUBSCRIPTION_FILTER_OPTIONS.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{isPending ? (
|
||||
<div className="mt-8 flex items-center justify-center py-16" role="status">
|
||||
<Loader2 className="size-6 animate-spin text-secondary/50" aria-hidden="true" />
|
||||
<span className="sr-only">Cargando cuentas</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isError ? (
|
||||
<div className="mt-8 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||
<p>{errorMessage}</p>
|
||||
<Button variant="outline" size="sm" onClick={retry}>
|
||||
Reintentar
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!isPending && !isError && accounts.length === 0 ? (
|
||||
<div className="mt-8 rounded-xl bg-primary-soft px-5 py-12 text-center">
|
||||
<span className="mx-auto flex size-14 items-center justify-center rounded-2xl bg-accent-soft text-accent-fg">
|
||||
<Users className="size-7" aria-hidden="true" />
|
||||
</span>
|
||||
<p className="mt-4 text-base font-semibold text-primary">
|
||||
{hasFilters ? 'Ninguna cuenta coincide' : 'Todavía no hay cuentas'}
|
||||
</p>
|
||||
{hasFilters ? (
|
||||
<p className="mx-auto mt-1.5 max-w-[34ch] text-sm leading-relaxed text-secondary">
|
||||
Probá con otra búsqueda o sacá algún filtro.
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!isPending && !isError && accounts.length > 0 ? (
|
||||
<>
|
||||
<div
|
||||
className={cn(
|
||||
'mt-6 lg:rounded-xl lg:border lg:border-border lg:bg-surface',
|
||||
isFetching && 'opacity-70 transition-opacity',
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'hidden gap-4 border-b border-border px-4 py-2.5 text-xs font-medium uppercase tracking-wide text-foreground/50 lg:grid',
|
||||
ACCOUNT_GRID_COLUMNS,
|
||||
)}
|
||||
>
|
||||
<span>Cuenta</span>
|
||||
<span>País</span>
|
||||
<span>Plan</span>
|
||||
<span>Suscripción</span>
|
||||
<span className="text-right">Grupos</span>
|
||||
<span className="text-right">Alumnos</span>
|
||||
<span />
|
||||
</div>
|
||||
<ul className="space-y-3 lg:space-y-0">
|
||||
{accounts.map((account) => (
|
||||
<AdminAccountRow key={account.id} account={account} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex items-center justify-between gap-3">
|
||||
<Button variant="outline" size="sm" disabled={page <= 1} onClick={() => setPage(page - 1)}>
|
||||
<ChevronLeft className="size-4" />
|
||||
Anteriores
|
||||
</Button>
|
||||
<p className="text-xs text-foreground/50">
|
||||
Página {page} de {totalPages} · {total} {total === 1 ? 'cuenta' : 'cuentas'}
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={page >= totalPages}
|
||||
onClick={() => setPage(page + 1)}
|
||||
>
|
||||
Siguientes
|
||||
<ChevronRight className="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
61
apps/web/src/features/admin/AdminGuard.tsx
Normal file
61
apps/web/src/features/admin/AdminGuard.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import { useEffect } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { Loader2, ShieldOff } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { useAuth } from '../../context/AuthProvider'
|
||||
import { AdminLayout } from './AdminLayout'
|
||||
import { useAdminAccess } from './useAdminAccess'
|
||||
|
||||
/* El backoffice cuelga de la raíz y no de `_authenticated`: un admin no tiene
|
||||
por qué completar el onboarding de profesor. La sesión y el permiso se
|
||||
chequean acá; el backend vuelve a chequear el permiso en cada pedido. */
|
||||
export function AdminGuard({ children }: { children: ReactNode }) {
|
||||
const { user, isPending } = useAuth()
|
||||
const navigate = useNavigate()
|
||||
const access = useAdminAccess(!!user)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPending && !user) void navigate({ to: '/login', replace: true })
|
||||
}, [isPending, user, navigate])
|
||||
|
||||
if (isPending || !user || access.isPending) {
|
||||
return (
|
||||
<div className="flex min-h-dvh items-center justify-center">
|
||||
<Loader2 className="size-6 animate-spin text-foreground/40" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (access.isError) {
|
||||
return (
|
||||
<div className="flex min-h-dvh flex-col items-center justify-center gap-3 px-4 text-center">
|
||||
<p className="text-sm text-danger">No pudimos verificar tu acceso al backoffice.</p>
|
||||
<Button variant="outline" size="sm" onClick={() => void access.refetch()}>
|
||||
Reintentar
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!access.data?.isAdmin) {
|
||||
return (
|
||||
<div className="flex min-h-dvh flex-col items-center justify-center gap-4 px-4 text-center">
|
||||
<span className="flex size-14 items-center justify-center rounded-2xl bg-danger-soft text-danger">
|
||||
<ShieldOff className="size-7" aria-hidden="true" />
|
||||
</span>
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-primary">No tenés acceso</h1>
|
||||
<p className="mt-1 max-w-[36ch] text-sm text-secondary">
|
||||
El backoffice es solo para el equipo de Gruperly.
|
||||
</p>
|
||||
</div>
|
||||
<Link to="/" className="text-sm font-medium text-accent-fg hover:underline">
|
||||
Ir a la app
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return <AdminLayout>{children}</AdminLayout>
|
||||
}
|
||||
33
apps/web/src/features/admin/AdminLayout.tsx
Normal file
33
apps/web/src/features/admin/AdminLayout.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ArrowLeft } from 'lucide-react'
|
||||
import { ThemeToggle } from '../../components/layout/ThemeToggle'
|
||||
|
||||
/* Layout propio del backoffice: sin la navegación del profesor y pensado para
|
||||
escritorio, aunque en móvil se lee igual (columna única). */
|
||||
export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="min-h-dvh bg-background">
|
||||
<header className="sticky top-0 z-30 border-b border-border bg-surface/90 backdrop-blur">
|
||||
<div className="mx-auto flex h-14 max-w-6xl items-center justify-between gap-3 px-4 lg:px-8">
|
||||
<Link to="/admin" className="text-base font-bold text-primary">
|
||||
Gruperly <span className="font-medium text-foreground/50">· Backoffice</span>
|
||||
</Link>
|
||||
<div className="flex items-center gap-2">
|
||||
<ThemeToggle />
|
||||
<Link
|
||||
to="/"
|
||||
className="hidden items-center gap-1.5 rounded-xl px-3 py-1.5 text-sm font-medium text-foreground/70 transition-colors hover:bg-primary-soft hover:text-primary lg:inline-flex"
|
||||
>
|
||||
<ArrowLeft className="size-4" aria-hidden="true" />
|
||||
Volver a la app
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main className="mx-auto max-w-6xl px-4 py-6 pb-[calc(2rem+env(safe-area-inset-bottom))] lg:px-8 lg:py-8">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
75
apps/web/src/features/admin/copy.ts
Normal file
75
apps/web/src/features/admin/copy.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import type {
|
||||
AdminAccountDetail,
|
||||
AdminPlanFilter,
|
||||
AdminSubscriptionFilter,
|
||||
CountryCode,
|
||||
Plan,
|
||||
SubscriptionStatus,
|
||||
} from '@gruperly/shared'
|
||||
import { COUNTRY_LABELS } from '@gruperly/shared'
|
||||
import type { BadgeVariant } from '../../components/ui'
|
||||
import { PLAN_NAMES, subscriptionStatusLabel } from '../billing'
|
||||
|
||||
/* Copy del backoffice. Los nombres de plan y de estado de suscripción salen de
|
||||
billing, así el equipo ve lo mismo que el profesor en su pantalla del plan. */
|
||||
|
||||
export const PLAN_FILTER_OPTIONS: readonly { value: AdminPlanFilter; label: string }[] = [
|
||||
{ value: 'PRO', label: PLAN_NAMES.PRO },
|
||||
{ value: 'FREE', label: PLAN_NAMES.FREE },
|
||||
{ value: 'NOT_SELECTED', label: 'Sin elegir' },
|
||||
]
|
||||
|
||||
export const SUBSCRIPTION_FILTER_OPTIONS: readonly { value: AdminSubscriptionFilter; label: string }[] = [
|
||||
{ value: 'AUTHORIZED', label: subscriptionStatusLabel('AUTHORIZED') },
|
||||
{ value: 'PENDING', label: subscriptionStatusLabel('PENDING') },
|
||||
{ value: 'PAUSED', label: subscriptionStatusLabel('PAUSED') },
|
||||
{ value: 'CANCELLED', label: subscriptionStatusLabel('CANCELLED') },
|
||||
{ value: 'NONE', label: subscriptionStatusLabel(null) },
|
||||
]
|
||||
|
||||
export const COUNTRY_OPTIONS = (Object.keys(COUNTRY_LABELS) as CountryCode[]).map((code) => ({
|
||||
value: code,
|
||||
label: COUNTRY_LABELS[code],
|
||||
}))
|
||||
|
||||
export function countryLabel(country: CountryCode | null): string {
|
||||
return country ? COUNTRY_LABELS[country] : 'Sin país'
|
||||
}
|
||||
|
||||
export function planLabel(plan: Plan | null): string {
|
||||
return plan ? PLAN_NAMES[plan] : 'Sin elegir'
|
||||
}
|
||||
|
||||
export function planVariant(plan: Plan | null): BadgeVariant {
|
||||
if (plan === 'PRO') return 'success'
|
||||
return plan === 'FREE' ? 'neutral' : 'warning'
|
||||
}
|
||||
|
||||
export function subscriptionVariant(status: SubscriptionStatus | null): BadgeVariant {
|
||||
switch (status) {
|
||||
case 'AUTHORIZED':
|
||||
return 'success'
|
||||
case 'PENDING':
|
||||
return 'info'
|
||||
case 'PAUSED':
|
||||
return 'warning'
|
||||
case 'CANCELLED':
|
||||
return 'danger'
|
||||
default:
|
||||
return 'neutral'
|
||||
}
|
||||
}
|
||||
|
||||
export const MP_STATUS_LABELS: Record<NonNullable<AdminAccountDetail['mpStatus']> | 'NONE', string> = {
|
||||
ACTIVE: 'Vinculada',
|
||||
REQUIRES_REAUTH: 'Requiere volver a vincular',
|
||||
REVOKED: 'Desvinculada',
|
||||
NONE: 'Sin vincular',
|
||||
}
|
||||
|
||||
export const WHATSAPP_STATUS_LABELS: Record<NonNullable<AdminAccountDetail['whatsappStatus']> | 'NONE', string> = {
|
||||
ACTIVE: 'Conectado',
|
||||
PENDING: 'Conectando',
|
||||
DISCONNECTED: 'Desconectado',
|
||||
NONE: 'Sin conectar',
|
||||
}
|
||||
12
apps/web/src/features/admin/useAdminAccess.ts
Normal file
12
apps/web/src/features/admin/useAdminAccess.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getAdminMe } from '../../lib/api'
|
||||
|
||||
/** Si el usuario es del equipo de Gruperly. La comparten el guard del backoffice y el menú. */
|
||||
export function useAdminAccess(enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: ['admin', 'me'],
|
||||
queryFn: getAdminMe,
|
||||
enabled,
|
||||
staleTime: 10 * 60 * 1000,
|
||||
})
|
||||
}
|
||||
95
apps/web/src/features/auth/ForgotPasswordPage.tsx
Normal file
95
apps/web/src/features/auth/ForgotPasswordPage.tsx
Normal file
@@ -0,0 +1,95 @@
|
||||
import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useSearch } from '@tanstack/react-router'
|
||||
import { Loader2, MailCheck } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
const schema = z.object({
|
||||
email: z.string().email('Ingresá un email válido'),
|
||||
})
|
||||
|
||||
type FormValues = z.infer<typeof schema>
|
||||
|
||||
export function ForgotPasswordPage() {
|
||||
const { email: initialEmail } = useSearch({ strict: false }) as { email?: string }
|
||||
const [sentTo, setSentTo] = useState<string | null>(null)
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
setError,
|
||||
formState: { errors, isSubmitting },
|
||||
} = useForm<FormValues>({
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: { email: initialEmail ?? '' },
|
||||
})
|
||||
|
||||
const onSubmit = handleSubmit(async ({ email }) => {
|
||||
// Absoluto: un redirectTo relativo Better Auth lo resuelve contra la URL de la API
|
||||
const { error } = await authClient.requestPasswordReset({
|
||||
email,
|
||||
redirectTo: `${window.location.origin}/reset-password`,
|
||||
})
|
||||
if (error) {
|
||||
setError('root', { message: error.message ?? 'No se pudo enviar el email' })
|
||||
return
|
||||
}
|
||||
setSentTo(email)
|
||||
})
|
||||
|
||||
if (sentTo) {
|
||||
return (
|
||||
<AuthShell title="Revisá tu email">
|
||||
<div className="flex flex-col items-center gap-4 py-2 text-center">
|
||||
<MailCheck className="size-10 text-success" />
|
||||
<p className="text-sm text-foreground/60">
|
||||
Si hay una cuenta con <span className="font-medium text-primary">{sentTo}</span>, te
|
||||
enviamos un enlace para elegir una nueva contraseña. Vence en 1 hora.
|
||||
</p>
|
||||
<Link to="/login" className="text-sm font-medium text-accent hover:underline">
|
||||
Volver a iniciar sesión
|
||||
</Link>
|
||||
</div>
|
||||
</AuthShell>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthShell
|
||||
title="Recuperar contraseña"
|
||||
subtitle="Te enviamos un enlace para elegir una nueva"
|
||||
>
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
autoFocus
|
||||
placeholder="vos@ejemplo.com"
|
||||
invalid={!!errors.email}
|
||||
{...register('email')}
|
||||
/>
|
||||
{errors.email ? <p className="mt-1 text-sm text-danger">{errors.email.message}</p> : null}
|
||||
</div>
|
||||
|
||||
{errors.root ? <p className="text-sm text-danger">{errors.root.message}</p> : null}
|
||||
|
||||
<Button type="submit" variant="primary" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
{isSubmitting ? 'Enviando…' : 'Enviar enlace'}
|
||||
</Button>
|
||||
|
||||
<p className="text-center text-sm text-foreground/60">
|
||||
<Link to="/login" className="font-medium text-accent hover:underline">
|
||||
Volver a iniciar sesión
|
||||
</Link>
|
||||
</p>
|
||||
</form>
|
||||
</AuthShell>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { Link, useNavigate, useSearch } from '@tanstack/react-router'
|
||||
import { Fingerprint, Loader2 } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
@@ -16,10 +16,12 @@ type FormValues = z.infer<typeof schema>
|
||||
|
||||
export function LoginPage() {
|
||||
const navigate = useNavigate()
|
||||
const { reset } = useSearch({ strict: false }) as { reset?: 'ok' }
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
setError,
|
||||
watch,
|
||||
formState: { errors, isSubmitting },
|
||||
} = useForm<FormValues>({ resolver: zodResolver(schema) })
|
||||
|
||||
@@ -48,6 +50,12 @@ export function LoginPage() {
|
||||
return (
|
||||
<AuthShell title="Iniciar sesión" subtitle="Accedé a tus cobros grupales">
|
||||
<div className="space-y-4">
|
||||
{reset === 'ok' ? (
|
||||
<p className="rounded-xl bg-success-soft px-4 py-3 text-sm text-success">
|
||||
Tu contraseña se actualizó. Ingresá con la nueva.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="email">Email</Label>
|
||||
@@ -75,6 +83,15 @@ export function LoginPage() {
|
||||
{errors.password ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.password.message}</p>
|
||||
) : null}
|
||||
<div className="mt-1 text-right">
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
search={{ email: watch('email') || undefined }}
|
||||
className="text-sm text-accent hover:underline"
|
||||
>
|
||||
¿Olvidaste tu contraseña?
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{errors.root ? <p className="text-sm text-danger">{errors.root.message}</p> : null}
|
||||
|
||||
107
apps/web/src/features/auth/ResetPasswordPage.tsx
Normal file
107
apps/web/src/features/auth/ResetPasswordPage.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useNavigate, useSearch } from '@tanstack/react-router'
|
||||
import { Loader2, MailWarning } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
const schema = z
|
||||
.object({
|
||||
newPassword: z.string().min(8, 'La contraseña debe tener al menos 8 caracteres'),
|
||||
confirmPassword: z.string(),
|
||||
})
|
||||
.refine((v) => v.newPassword === v.confirmPassword, {
|
||||
message: 'Las contraseñas no coinciden',
|
||||
path: ['confirmPassword'],
|
||||
})
|
||||
|
||||
type FormValues = z.infer<typeof schema>
|
||||
|
||||
export function ResetPasswordPage() {
|
||||
const { token, error } = useSearch({ strict: false }) as { token?: string; error?: string }
|
||||
const navigate = useNavigate()
|
||||
const [invalidLink, setInvalidLink] = useState(!token || !!error)
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
setError,
|
||||
formState: { errors, isSubmitting },
|
||||
} = useForm<FormValues>({ resolver: zodResolver(schema) })
|
||||
|
||||
const onSubmit = handleSubmit(async ({ newPassword }) => {
|
||||
if (!token) return
|
||||
const { error } = await authClient.resetPassword({ newPassword, token })
|
||||
if (error) {
|
||||
if (error.code === 'INVALID_TOKEN') {
|
||||
setInvalidLink(true)
|
||||
return
|
||||
}
|
||||
setError('root', { message: error.message ?? 'No se pudo cambiar la contraseña' })
|
||||
return
|
||||
}
|
||||
navigate({ to: '/login', search: { reset: 'ok' } })
|
||||
})
|
||||
|
||||
if (invalidLink) {
|
||||
return (
|
||||
<AuthShell title="Vínculo inválido">
|
||||
<div className="flex flex-col items-center gap-4 py-2 text-center">
|
||||
<MailWarning className="size-10 text-warning" />
|
||||
<p className="text-sm text-foreground/60">
|
||||
El enlace para restablecer la contraseña no es válido o venció.
|
||||
</p>
|
||||
<Link to="/forgot-password" className="text-sm font-medium text-accent hover:underline">
|
||||
Pedir un enlace nuevo
|
||||
</Link>
|
||||
</div>
|
||||
</AuthShell>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthShell title="Nueva contraseña" subtitle="Elegí una contraseña para tu cuenta">
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="newPassword">Nueva contraseña</Label>
|
||||
<Input
|
||||
id="newPassword"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
autoFocus
|
||||
placeholder="••••••••"
|
||||
invalid={!!errors.newPassword}
|
||||
{...register('newPassword')}
|
||||
/>
|
||||
{errors.newPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.newPassword.message}</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="confirmPassword">Repetir contraseña</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
placeholder="••••••••"
|
||||
invalid={!!errors.confirmPassword}
|
||||
{...register('confirmPassword')}
|
||||
/>
|
||||
{errors.confirmPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.confirmPassword.message}</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{errors.root ? <p className="text-sm text-danger">{errors.root.message}</p> : null}
|
||||
|
||||
<Button type="submit" variant="primary" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
{isSubmitting ? 'Guardando…' : 'Guardar contraseña'}
|
||||
</Button>
|
||||
</form>
|
||||
</AuthShell>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export {
|
||||
formatBillingDate,
|
||||
formatUsage,
|
||||
hasPlanFeature,
|
||||
isPlanProblem,
|
||||
PLAN_FEATURE_REQUIRED_MESSAGES,
|
||||
|
||||
@@ -35,7 +35,9 @@ export function Stepper({ steps, current }: StepperProps) {
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
'hidden text-xs font-medium sm:block',
|
||||
// Sin corte: con 7 pasos en max-w-md, "Tu grupo" partía en dos
|
||||
// líneas. Si falta lugar, se achica la línea entre pasos.
|
||||
'hidden whitespace-nowrap text-xs font-medium sm:block',
|
||||
isActive ? 'text-accent' : 'text-foreground/50',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import type {
|
||||
AbsenceDetails,
|
||||
AdminAccountDetail,
|
||||
AdminAccountList,
|
||||
AdminAccountQueryInput,
|
||||
AdminMeDto,
|
||||
ApproveGroupPreRegistrationResult,
|
||||
AttendeeDetailDto,
|
||||
AttendeeDto,
|
||||
@@ -383,3 +387,18 @@ export const updateAttendeeStatus = (attendeeId: string, status: AttendeeStatus)
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ status }),
|
||||
})
|
||||
|
||||
// — Backoffice (equipo de Gruperly) —
|
||||
|
||||
export const getAdminMe = () => apiFetch<AdminMeDto>('/api/v1/admin/me')
|
||||
|
||||
export const getAdminAccounts = (params: AdminAccountQueryInput) => {
|
||||
const query = new URLSearchParams()
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value !== undefined && value !== '') query.set(key, String(value))
|
||||
}
|
||||
return apiFetch<AdminAccountList>(`/api/v1/admin/accounts?${query.toString()}`)
|
||||
}
|
||||
|
||||
export const getAdminAccount = (accountId: string) =>
|
||||
apiFetch<AdminAccountDetail>(`/api/v1/admin/accounts/${encodeURIComponent(accountId)}`)
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
|
||||
import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as AuthenticatedRouteImport } from './routes/_authenticated'
|
||||
import { Route as AdminRouteImport } from './routes/admin'
|
||||
import { Route as ForgotPasswordRouteImport } from './routes/forgot-password'
|
||||
import { Route as LoginRouteImport } from './routes/login'
|
||||
import { Route as OnboardingRouteImport } from './routes/onboarding'
|
||||
import { Route as ResetPasswordRouteImport } from './routes/reset-password'
|
||||
import { Route as SignupRouteImport } from './routes/signup'
|
||||
import { Route as VerifyEmailRouteImport } from './routes/verify-email'
|
||||
import { Route as AuthenticatedIndexRouteImport } from './routes/_authenticated/index'
|
||||
@@ -20,10 +23,12 @@ import { Route as AuthenticatedPaymentsRouteImport } from './routes/_authenticat
|
||||
import { Route as AuthenticatedProfileRouteImport } from './routes/_authenticated/profile'
|
||||
import { Route as AuthenticatedSecurityRouteImport } from './routes/_authenticated/security'
|
||||
import { Route as AuthenticatedSettingsRouteImport } from './routes/_authenticated/settings'
|
||||
import { Route as AdminIndexRouteImport } from './routes/admin/index'
|
||||
import { Route as JoinTokenRouteImport } from './routes/join.$token'
|
||||
import { Route as ReportAbsenceTokenRouteImport } from './routes/report-absence.$token'
|
||||
import { Route as AuthenticatedGroupsIndexRouteImport } from './routes/_authenticated/groups/index'
|
||||
import { Route as AuthenticatedGroupsNewRouteImport } from './routes/_authenticated/groups/new'
|
||||
import { Route as AdminAccountsAccountIdRouteImport } from './routes/admin/accounts.$accountId'
|
||||
import { Route as AuthenticatedClassSessionIdAttendanceRouteImport } from './routes/_authenticated/class/$sessionId/attendance'
|
||||
import { Route as AuthenticatedGroupsGroupIdIndexRouteImport } from './routes/_authenticated/groups/$groupId/index'
|
||||
import { Route as AuthenticatedGroupsGroupIdAnalyticsRouteImport } from './routes/_authenticated/groups/$groupId/analytics'
|
||||
@@ -34,6 +39,16 @@ const AuthenticatedRoute = AuthenticatedRouteImport.update({
|
||||
id: '/_authenticated',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const AdminRoute = AdminRouteImport.update({
|
||||
id: '/admin',
|
||||
path: '/admin',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ForgotPasswordRoute = ForgotPasswordRouteImport.update({
|
||||
id: '/forgot-password',
|
||||
path: '/forgot-password',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const LoginRoute = LoginRouteImport.update({
|
||||
id: '/login',
|
||||
path: '/login',
|
||||
@@ -44,6 +59,11 @@ const OnboardingRoute = OnboardingRouteImport.update({
|
||||
path: '/onboarding',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ResetPasswordRoute = ResetPasswordRouteImport.update({
|
||||
id: '/reset-password',
|
||||
path: '/reset-password',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const SignupRoute = SignupRouteImport.update({
|
||||
id: '/signup',
|
||||
path: '/signup',
|
||||
@@ -84,6 +104,11 @@ const AuthenticatedSettingsRoute = AuthenticatedSettingsRouteImport.update({
|
||||
path: '/settings',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any)
|
||||
const AdminIndexRoute = AdminIndexRouteImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => AdminRoute,
|
||||
} as any)
|
||||
const JoinTokenRoute = JoinTokenRouteImport.update({
|
||||
id: '/join/$token',
|
||||
path: '/join/$token',
|
||||
@@ -105,6 +130,11 @@ const AuthenticatedGroupsNewRoute = AuthenticatedGroupsNewRouteImport.update({
|
||||
path: '/groups/new',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any)
|
||||
const AdminAccountsAccountIdRoute = AdminAccountsAccountIdRouteImport.update({
|
||||
id: '/accounts/$accountId',
|
||||
path: '/accounts/$accountId',
|
||||
getParentRoute: () => AdminRoute,
|
||||
} as any)
|
||||
const AuthenticatedClassSessionIdAttendanceRoute =
|
||||
AuthenticatedClassSessionIdAttendanceRouteImport.update({
|
||||
id: '/class/$sessionId/attendance',
|
||||
@@ -138,8 +168,11 @@ const AuthenticatedGroupsGroupIdAttendeesNewRoute =
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof AuthenticatedIndexRoute
|
||||
'/admin': typeof AdminRouteWithChildren
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/onboarding': typeof OnboardingRoute
|
||||
'/reset-password': typeof ResetPasswordRoute
|
||||
'/signup': typeof SignupRoute
|
||||
'/verify-email': typeof VerifyEmailRoute
|
||||
'/billing': typeof AuthenticatedBillingRoute
|
||||
@@ -149,7 +182,9 @@ export interface FileRoutesByFullPath {
|
||||
'/settings': typeof AuthenticatedSettingsRoute
|
||||
'/join/$token': typeof JoinTokenRoute
|
||||
'/report-absence/$token': typeof ReportAbsenceTokenRoute
|
||||
'/admin/': typeof AdminIndexRoute
|
||||
'/groups/new': typeof AuthenticatedGroupsNewRoute
|
||||
'/admin/accounts/$accountId': typeof AdminAccountsAccountIdRoute
|
||||
'/groups/': typeof AuthenticatedGroupsIndexRoute
|
||||
'/class/$sessionId/attendance': typeof AuthenticatedClassSessionIdAttendanceRoute
|
||||
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||
@@ -158,8 +193,10 @@ export interface FileRoutesByFullPath {
|
||||
'/groups/$groupId/attendees/new': typeof AuthenticatedGroupsGroupIdAttendeesNewRoute
|
||||
}
|
||||
export interface FileRoutesByTo {
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/onboarding': typeof OnboardingRoute
|
||||
'/reset-password': typeof ResetPasswordRoute
|
||||
'/signup': typeof SignupRoute
|
||||
'/verify-email': typeof VerifyEmailRoute
|
||||
'/billing': typeof AuthenticatedBillingRoute
|
||||
@@ -170,7 +207,9 @@ export interface FileRoutesByTo {
|
||||
'/join/$token': typeof JoinTokenRoute
|
||||
'/report-absence/$token': typeof ReportAbsenceTokenRoute
|
||||
'/': typeof AuthenticatedIndexRoute
|
||||
'/admin': typeof AdminIndexRoute
|
||||
'/groups/new': typeof AuthenticatedGroupsNewRoute
|
||||
'/admin/accounts/$accountId': typeof AdminAccountsAccountIdRoute
|
||||
'/groups': typeof AuthenticatedGroupsIndexRoute
|
||||
'/class/$sessionId/attendance': typeof AuthenticatedClassSessionIdAttendanceRoute
|
||||
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||
@@ -181,8 +220,11 @@ export interface FileRoutesByTo {
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRouteImport
|
||||
'/_authenticated': typeof AuthenticatedRouteWithChildren
|
||||
'/admin': typeof AdminRouteWithChildren
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/onboarding': typeof OnboardingRoute
|
||||
'/reset-password': typeof ResetPasswordRoute
|
||||
'/signup': typeof SignupRoute
|
||||
'/verify-email': typeof VerifyEmailRoute
|
||||
'/_authenticated/billing': typeof AuthenticatedBillingRoute
|
||||
@@ -193,7 +235,9 @@ export interface FileRoutesById {
|
||||
'/join/$token': typeof JoinTokenRoute
|
||||
'/report-absence/$token': typeof ReportAbsenceTokenRoute
|
||||
'/_authenticated/': typeof AuthenticatedIndexRoute
|
||||
'/admin/': typeof AdminIndexRoute
|
||||
'/_authenticated/groups/new': typeof AuthenticatedGroupsNewRoute
|
||||
'/admin/accounts/$accountId': typeof AdminAccountsAccountIdRoute
|
||||
'/_authenticated/groups/': typeof AuthenticatedGroupsIndexRoute
|
||||
'/_authenticated/class/$sessionId/attendance': typeof AuthenticatedClassSessionIdAttendanceRoute
|
||||
'/_authenticated/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||
@@ -205,8 +249,11 @@ export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths:
|
||||
| '/'
|
||||
| '/admin'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/onboarding'
|
||||
| '/reset-password'
|
||||
| '/signup'
|
||||
| '/verify-email'
|
||||
| '/billing'
|
||||
@@ -216,7 +263,9 @@ export interface FileRouteTypes {
|
||||
| '/settings'
|
||||
| '/join/$token'
|
||||
| '/report-absence/$token'
|
||||
| '/admin/'
|
||||
| '/groups/new'
|
||||
| '/admin/accounts/$accountId'
|
||||
| '/groups/'
|
||||
| '/class/$sessionId/attendance'
|
||||
| '/groups/$groupId/analytics'
|
||||
@@ -225,8 +274,10 @@ export interface FileRouteTypes {
|
||||
| '/groups/$groupId/attendees/new'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to:
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/onboarding'
|
||||
| '/reset-password'
|
||||
| '/signup'
|
||||
| '/verify-email'
|
||||
| '/billing'
|
||||
@@ -237,7 +288,9 @@ export interface FileRouteTypes {
|
||||
| '/join/$token'
|
||||
| '/report-absence/$token'
|
||||
| '/'
|
||||
| '/admin'
|
||||
| '/groups/new'
|
||||
| '/admin/accounts/$accountId'
|
||||
| '/groups'
|
||||
| '/class/$sessionId/attendance'
|
||||
| '/groups/$groupId/analytics'
|
||||
@@ -247,8 +300,11 @@ export interface FileRouteTypes {
|
||||
id:
|
||||
| '__root__'
|
||||
| '/_authenticated'
|
||||
| '/admin'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/onboarding'
|
||||
| '/reset-password'
|
||||
| '/signup'
|
||||
| '/verify-email'
|
||||
| '/_authenticated/billing'
|
||||
@@ -259,7 +315,9 @@ export interface FileRouteTypes {
|
||||
| '/join/$token'
|
||||
| '/report-absence/$token'
|
||||
| '/_authenticated/'
|
||||
| '/admin/'
|
||||
| '/_authenticated/groups/new'
|
||||
| '/admin/accounts/$accountId'
|
||||
| '/_authenticated/groups/'
|
||||
| '/_authenticated/class/$sessionId/attendance'
|
||||
| '/_authenticated/groups/$groupId/analytics'
|
||||
@@ -270,8 +328,11 @@ export interface FileRouteTypes {
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
AuthenticatedRoute: typeof AuthenticatedRouteWithChildren
|
||||
AdminRoute: typeof AdminRouteWithChildren
|
||||
ForgotPasswordRoute: typeof ForgotPasswordRoute
|
||||
LoginRoute: typeof LoginRoute
|
||||
OnboardingRoute: typeof OnboardingRoute
|
||||
ResetPasswordRoute: typeof ResetPasswordRoute
|
||||
SignupRoute: typeof SignupRoute
|
||||
VerifyEmailRoute: typeof VerifyEmailRoute
|
||||
JoinTokenRoute: typeof JoinTokenRoute
|
||||
@@ -287,6 +348,20 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/admin': {
|
||||
id: '/admin'
|
||||
path: '/admin'
|
||||
fullPath: '/admin'
|
||||
preLoaderRoute: typeof AdminRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/forgot-password': {
|
||||
id: '/forgot-password'
|
||||
path: '/forgot-password'
|
||||
fullPath: '/forgot-password'
|
||||
preLoaderRoute: typeof ForgotPasswordRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/login': {
|
||||
id: '/login'
|
||||
path: '/login'
|
||||
@@ -301,6 +376,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof OnboardingRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/reset-password': {
|
||||
id: '/reset-password'
|
||||
path: '/reset-password'
|
||||
fullPath: '/reset-password'
|
||||
preLoaderRoute: typeof ResetPasswordRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/signup': {
|
||||
id: '/signup'
|
||||
path: '/signup'
|
||||
@@ -357,6 +439,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedSettingsRouteImport
|
||||
parentRoute: typeof AuthenticatedRoute
|
||||
}
|
||||
'/admin/': {
|
||||
id: '/admin/'
|
||||
path: '/'
|
||||
fullPath: '/admin/'
|
||||
preLoaderRoute: typeof AdminIndexRouteImport
|
||||
parentRoute: typeof AdminRoute
|
||||
}
|
||||
'/join/$token': {
|
||||
id: '/join/$token'
|
||||
path: '/join/$token'
|
||||
@@ -385,6 +474,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedGroupsNewRouteImport
|
||||
parentRoute: typeof AuthenticatedRoute
|
||||
}
|
||||
'/admin/accounts/$accountId': {
|
||||
id: '/admin/accounts/$accountId'
|
||||
path: '/accounts/$accountId'
|
||||
fullPath: '/admin/accounts/$accountId'
|
||||
preLoaderRoute: typeof AdminAccountsAccountIdRouteImport
|
||||
parentRoute: typeof AdminRoute
|
||||
}
|
||||
'/_authenticated/class/$sessionId/attendance': {
|
||||
id: '/_authenticated/class/$sessionId/attendance'
|
||||
path: '/class/$sessionId/attendance'
|
||||
@@ -463,10 +559,25 @@ const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
||||
AuthenticatedRouteChildren,
|
||||
)
|
||||
|
||||
interface AdminRouteChildren {
|
||||
AdminIndexRoute: typeof AdminIndexRoute
|
||||
AdminAccountsAccountIdRoute: typeof AdminAccountsAccountIdRoute
|
||||
}
|
||||
|
||||
const AdminRouteChildren: AdminRouteChildren = {
|
||||
AdminIndexRoute: AdminIndexRoute,
|
||||
AdminAccountsAccountIdRoute: AdminAccountsAccountIdRoute,
|
||||
}
|
||||
|
||||
const AdminRouteWithChildren = AdminRoute._addFileChildren(AdminRouteChildren)
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
AuthenticatedRoute: AuthenticatedRouteWithChildren,
|
||||
AdminRoute: AdminRouteWithChildren,
|
||||
ForgotPasswordRoute: ForgotPasswordRoute,
|
||||
LoginRoute: LoginRoute,
|
||||
OnboardingRoute: OnboardingRoute,
|
||||
ResetPasswordRoute: ResetPasswordRoute,
|
||||
SignupRoute: SignupRoute,
|
||||
VerifyEmailRoute: VerifyEmailRoute,
|
||||
JoinTokenRoute: JoinTokenRoute,
|
||||
|
||||
10
apps/web/src/routes/admin.tsx
Normal file
10
apps/web/src/routes/admin.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createFileRoute, Outlet } from '@tanstack/react-router'
|
||||
import { AdminGuard } from '../features/admin/AdminGuard'
|
||||
|
||||
export const Route = createFileRoute('/admin')({
|
||||
component: () => (
|
||||
<AdminGuard>
|
||||
<Outlet />
|
||||
</AdminGuard>
|
||||
),
|
||||
})
|
||||
14
apps/web/src/routes/admin/accounts.$accountId.tsx
Normal file
14
apps/web/src/routes/admin/accounts.$accountId.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createFileRoute, useParams } from '@tanstack/react-router'
|
||||
import { AdminAccountDetailProvider } from '../../features/admin/AdminAccountDetailProvider'
|
||||
import { AdminAccountDetailView } from '../../features/admin/AdminAccountDetailView'
|
||||
|
||||
export const Route = createFileRoute('/admin/accounts/$accountId')({
|
||||
component: () => {
|
||||
const { accountId } = useParams({ from: '/admin/accounts/$accountId' })
|
||||
return (
|
||||
<AdminAccountDetailProvider accountId={accountId}>
|
||||
<AdminAccountDetailView />
|
||||
</AdminAccountDetailProvider>
|
||||
)
|
||||
},
|
||||
})
|
||||
11
apps/web/src/routes/admin/index.tsx
Normal file
11
apps/web/src/routes/admin/index.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { AdminAccountsProvider } from '../../features/admin/AdminAccountsProvider'
|
||||
import { AdminAccountsView } from '../../features/admin/AdminAccountsView'
|
||||
|
||||
export const Route = createFileRoute('/admin/')({
|
||||
component: () => (
|
||||
<AdminAccountsProvider>
|
||||
<AdminAccountsView />
|
||||
</AdminAccountsProvider>
|
||||
),
|
||||
})
|
||||
9
apps/web/src/routes/forgot-password.tsx
Normal file
9
apps/web/src/routes/forgot-password.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { ForgotPasswordPage } from '../features/auth/ForgotPasswordPage'
|
||||
|
||||
export const Route = createFileRoute('/forgot-password')({
|
||||
validateSearch: (search: Record<string, unknown>): { email?: string } => ({
|
||||
email: typeof search.email === 'string' ? search.email : undefined,
|
||||
}),
|
||||
component: ForgotPasswordPage,
|
||||
})
|
||||
@@ -2,5 +2,8 @@ import { createFileRoute } from '@tanstack/react-router'
|
||||
import { LoginPage } from '../features/auth/LoginPage'
|
||||
|
||||
export const Route = createFileRoute('/login')({
|
||||
validateSearch: (search: Record<string, unknown>): { reset?: 'ok' } => ({
|
||||
reset: search.reset === 'ok' ? 'ok' : undefined,
|
||||
}),
|
||||
component: LoginPage,
|
||||
})
|
||||
|
||||
10
apps/web/src/routes/reset-password.tsx
Normal file
10
apps/web/src/routes/reset-password.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { ResetPasswordPage } from '../features/auth/ResetPasswordPage'
|
||||
|
||||
export const Route = createFileRoute('/reset-password')({
|
||||
validateSearch: (search: Record<string, unknown>): { token?: string; error?: string } => ({
|
||||
token: typeof search.token === 'string' ? search.token : undefined,
|
||||
error: typeof search.error === 'string' ? search.error : undefined,
|
||||
}),
|
||||
component: ResetPasswordPage,
|
||||
})
|
||||
Reference in New Issue
Block a user