feat(i18n): traducir Grupos (lista, ficha, alta de miembros y estadísticas)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ArrowLeft, Loader2 } from 'lucide-react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { cn } from '../../../lib/utils'
|
||||
import { useAddAttendee } from './AddAttendeeProvider'
|
||||
import { BulkCapacityModal } from './BulkCapacityModal'
|
||||
@@ -8,13 +9,14 @@ import { CapacityModal } from './CapacityModal'
|
||||
import { QuickAddForm } from './QuickAddForm'
|
||||
|
||||
const TABS = [
|
||||
{ value: 'quick' as const, label: 'Carga Rápida (Individual)' },
|
||||
{ value: 'bulk' as const, label: 'Carga Masiva (CSV / Excel)' },
|
||||
{ value: 'quick' as const, label: 'tabs.quick' as const },
|
||||
{ value: 'bulk' as const, label: 'tabs.bulk' as const },
|
||||
]
|
||||
|
||||
export function AddAttendeePage() {
|
||||
const { groupId, groupName, attendeesTotal, capacity, groupPending, activeTab, setActiveTab } =
|
||||
useAddAttendee()
|
||||
const { t } = useTranslation('groupAdd')
|
||||
|
||||
if (groupPending) {
|
||||
return (
|
||||
@@ -32,24 +34,26 @@ export function AddAttendeePage() {
|
||||
className="hidden items-center gap-1 text-sm text-foreground/60 transition-colors hover:text-primary lg:inline-flex"
|
||||
>
|
||||
<ArrowLeft className="size-4" />
|
||||
<span>Volver al grupo</span>
|
||||
<span>{t('back')}</span>
|
||||
</Link>
|
||||
|
||||
<header className="space-y-1">
|
||||
<h1 className="text-2xl font-bold text-primary">Agregar miembros</h1>
|
||||
<h1 className="text-2xl font-bold text-primary">{t('title')}</h1>
|
||||
<p className="text-sm text-foreground/60">
|
||||
{groupName ? (
|
||||
<>
|
||||
Sumá miembros a <span className="font-medium text-primary">{groupName}</span> de forma
|
||||
individual o masiva desde una lista.
|
||||
</>
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="subtitleGroup"
|
||||
values={{ group: groupName }}
|
||||
components={{ strong: <span className="font-medium text-primary" /> }}
|
||||
/>
|
||||
) : (
|
||||
'Sumá miembros de forma individual o masiva desde una lista.'
|
||||
t('subtitle')
|
||||
)}
|
||||
</p>
|
||||
{capacity != null ? (
|
||||
<p className="text-xs text-foreground/50">
|
||||
{attendeesTotal} de {capacity} lugares ocupados.
|
||||
{t('occupancy', { count: attendeesTotal, capacity })}
|
||||
</p>
|
||||
) : null}
|
||||
</header>
|
||||
@@ -68,7 +72,7 @@ export function AddAttendeePage() {
|
||||
: 'text-foreground/60 hover:text-primary',
|
||||
)}
|
||||
>
|
||||
{tab.label}
|
||||
{t(tab.label)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -3,13 +3,17 @@ import type { ReactNode } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import type {
|
||||
BulkCreateAttendeesResult,
|
||||
CreateAttendee,
|
||||
CreateAttendeeResult,
|
||||
CreateGroupWaitlistEntry,
|
||||
GroupWaitlistEntryDto,
|
||||
GroupWaitlistList,
|
||||
} from '@gruperly/shared'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useToast } from '../../../components/ui'
|
||||
import { errorMessage } from '../../../i18n'
|
||||
import { i18n } from '../../../i18n/instance'
|
||||
import {
|
||||
addToGroupWaitlist,
|
||||
ApiError,
|
||||
@@ -72,6 +76,7 @@ const AddAttendeeContext = createContext<AddAttendeeContextValue | null>(null)
|
||||
export function AddAttendeeProvider({ groupId, children }: { groupId: string; children: ReactNode }) {
|
||||
const queryClient = useQueryClient()
|
||||
const toast = useToast()
|
||||
useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [activeTab, setActiveTab] = useState<AddAttendeeTab>('quick')
|
||||
@@ -116,11 +121,12 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
void queryClient.invalidateQueries({ queryKey: ['group', groupId] })
|
||||
}
|
||||
|
||||
const handleCreateSuccess = (result: CreateAttendeeResult) => {
|
||||
const handleCreateSuccess = (result: CreateAttendeeResult, payload: CreateAttendee) => {
|
||||
if (result.outcome === 'created') {
|
||||
toast.success(`Miembro ${result.attendee.fullName} agregado con éxito.`)
|
||||
toast.success(i18n.t('groupAdd:toast.created', { name: result.attendee.fullName }))
|
||||
} else {
|
||||
toast.info(result.message)
|
||||
const name = `${payload.firstName} ${payload.lastName ?? ''}`.trim()
|
||||
toast.info(i18n.t('groupAdd:toast.waitlisted', { name }))
|
||||
}
|
||||
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
||||
// Si era alguien de otro grupo, su ficha allá ahora lo muestra también acá.
|
||||
@@ -142,10 +148,10 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
// refresca la búsqueda para que aparezca la opción de agregar a esa persona.
|
||||
if (err instanceof ApiError && err.problem?.code === 'person_exists') {
|
||||
void queryClient.invalidateQueries({ queryKey: ['person-lookup', groupId] })
|
||||
toast.info('Ya tenés registrada a una persona con este teléfono. Podés agregarla a este grupo.')
|
||||
toast.info(i18n.t('groupAdd:toast.personExists'))
|
||||
return
|
||||
}
|
||||
toast.error(err.message || 'Error al agregar miembro.')
|
||||
toast.error(errorMessage(err, i18n.t('groupAdd:toast.addError')))
|
||||
},
|
||||
})
|
||||
|
||||
@@ -153,7 +159,7 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
mutationFn: (payload: CreateAttendee) => createAttendee(groupId, payload, { allowOverflow: true }),
|
||||
onSuccess: handleCreateSuccess,
|
||||
onError: (err: Error) => {
|
||||
toast.error(err.message || 'Error al agregar miembro.')
|
||||
toast.error(errorMessage(err, i18n.t('groupAdd:toast.addError')))
|
||||
},
|
||||
})
|
||||
|
||||
@@ -187,7 +193,7 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
return { previousWaitlist }
|
||||
},
|
||||
onSuccess: (entry) => {
|
||||
toast.info(`${entry.fullName} fue agregado a la lista de espera del grupo.`)
|
||||
toast.info(i18n.t('groupAdd:toast.waitlisted', { name: entry.fullName }))
|
||||
invalidateGroupQueries()
|
||||
goBackToGroup()
|
||||
},
|
||||
@@ -196,9 +202,9 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
queryClient.setQueryData<GroupWaitlistList>(['group-waitlist', groupId], context.previousWaitlist)
|
||||
}
|
||||
if (err instanceof ApiError && err.problem?.code === 'already_waitlisted') {
|
||||
toast.info('Este número ya está en la lista de espera del grupo.')
|
||||
toast.info(i18n.t('groupAdd:toast.alreadyWaitlisted'))
|
||||
} else {
|
||||
toast.error(err.message || 'Error al agregar a la lista de espera.')
|
||||
toast.error(errorMessage(err, i18n.t('groupAdd:toast.waitlistError')))
|
||||
}
|
||||
closeCapacityFlow()
|
||||
},
|
||||
@@ -207,14 +213,14 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
const bulkImportMutation = useMutation({
|
||||
mutationFn: (rows: BulkAttendeeRow[]) => bulkCreateAttendees(groupId, { attendees: rows }),
|
||||
onSuccess: (res) => {
|
||||
toast.success(res.message)
|
||||
toast.success(importSummary(res))
|
||||
setParsedContacts([])
|
||||
setFileName(null)
|
||||
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
||||
goBackToGroup()
|
||||
},
|
||||
onError: (err: Error) => {
|
||||
toast.error(err.message || 'Error al importar miembros.')
|
||||
toast.error(errorMessage(err, i18n.t('groupAdd:toast.importError')))
|
||||
},
|
||||
})
|
||||
|
||||
@@ -235,7 +241,7 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
|
||||
const runBulkImport = () => {
|
||||
if (validRows.length === 0) {
|
||||
toast.error('No hay miembros válidos para importar.')
|
||||
toast.error(i18n.t('groupAdd:bulk.noValidRows'))
|
||||
return
|
||||
}
|
||||
bulkImportMutation.mutate(validRows)
|
||||
@@ -243,7 +249,7 @@ export function AddAttendeeProvider({ groupId, children }: { groupId: string; ch
|
||||
|
||||
const requestBulkImport = () => {
|
||||
if (validRows.length === 0) {
|
||||
toast.error('No hay miembros válidos para importar.')
|
||||
toast.error(i18n.t('groupAdd:bulk.noValidRows'))
|
||||
return
|
||||
}
|
||||
if (capacity != null && attendeesTotal + validRows.length > capacity) {
|
||||
@@ -310,3 +316,16 @@ export function useAddAttendee() {
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
/** The bulk import summary, built from the counts (the API's `message` is Spanish only). */
|
||||
function importSummary(result: BulkCreateAttendeesResult): string {
|
||||
return [
|
||||
i18n.t('groupAdd:toast.imported', { count: result.createdCount }),
|
||||
result.linkedCount > 0 ? i18n.t('groupAdd:toast.importedLinked', { count: result.linkedCount }) : null,
|
||||
result.duplicatesCount > 0
|
||||
? i18n.t('groupAdd:toast.importedDuplicates', { count: result.duplicatesCount })
|
||||
: null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Check } from 'lucide-react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { Button, Modal } from '../../../components/ui'
|
||||
import { useAddAttendee } from './AddAttendeeProvider'
|
||||
|
||||
@@ -12,24 +13,28 @@ export function BulkCapacityModal() {
|
||||
groupName,
|
||||
capacity,
|
||||
} = useAddAttendee()
|
||||
const { t } = useTranslation(['groupAdd', 'common'])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isBulkCapacityModalOpen}
|
||||
onClose={closeBulkCapacityModal}
|
||||
title="Aviso de cupo"
|
||||
description="La carga supera el cupo del grupo."
|
||||
title={t('bulkCapacity.title')}
|
||||
description={t('bulkCapacity.description')}
|
||||
maxWidth="md"
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<p className="text-sm text-foreground/70">
|
||||
Estás por importar <strong className="text-primary">{validRowsCount}</strong> miembro(s), pero el
|
||||
grupo ya tiene <strong className="text-primary">{attendeesTotal}</strong> inscrito(s) y su cupo es
|
||||
de <strong className="text-primary">{capacity}</strong>. ¿Deseas importarlos de todos modos?
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="bulkCapacity.body"
|
||||
values={{ rows: validRowsCount, current: attendeesTotal, capacity }}
|
||||
components={{ strong: <strong className="text-primary" /> }}
|
||||
/>
|
||||
</p>
|
||||
<div className="flex flex-col-reverse gap-2.5 pt-2 sm:flex-row sm:items-center sm:justify-end">
|
||||
<Button variant="ghost" onClick={closeBulkCapacityModal} className="w-full sm:w-auto">
|
||||
Cancelar
|
||||
{t('common:actions.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
@@ -37,7 +42,7 @@ export function BulkCapacityModal() {
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
<Check className="size-4" />
|
||||
Importar de todos modos
|
||||
{t('bulkCapacity.confirm')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useRef } from 'react'
|
||||
import { Check, Download, FileSpreadsheet, Loader2, Trash2, UploadCloud } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Badge, Button, useToast } from '../../../components/ui'
|
||||
import {
|
||||
downloadAttendeeTemplateCsv,
|
||||
@@ -28,12 +29,13 @@ export function BulkImportPanel() {
|
||||
requestBulkImport,
|
||||
} = useAddAttendee()
|
||||
const toast = useToast()
|
||||
const { t } = useTranslation(['groupAdd', 'common'])
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const processFile = async (file: File) => {
|
||||
const fileExtension = file.name.split('.').pop()?.toLowerCase()
|
||||
if (!['csv', 'xlsx', 'xls', 'txt'].includes(fileExtension ?? '')) {
|
||||
toast.error('Formato no compatible. Sube un archivo .csv o .xlsx')
|
||||
toast.error(t('bulk.unsupported'))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -47,14 +49,14 @@ export function BulkImportPanel() {
|
||||
|
||||
const contacts = normalizeRowsToContacts(rawRows)
|
||||
if (contacts.length === 0) {
|
||||
toast.error('No se detectaron contactos en el archivo.')
|
||||
toast.error(t('bulk.noContacts'))
|
||||
} else {
|
||||
setParsedContacts(contacts)
|
||||
const validCount = contacts.filter((c) => c.isValid).length
|
||||
toast.info(`Se detectaron ${contacts.length} filas (${validCount} válidas).`)
|
||||
toast.info(t('bulk.detected', { count: contacts.length, valid: validCount }))
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : 'Error al procesar el archivo.'
|
||||
const message = err instanceof Error ? err.message : t('bulk.processError')
|
||||
toast.error(message)
|
||||
} finally {
|
||||
setIsParsingFile(false)
|
||||
@@ -103,9 +105,9 @@ export function BulkImportPanel() {
|
||||
/>
|
||||
<UploadCloud className="mb-2 size-10 text-accent" />
|
||||
<p className="text-sm font-semibold text-primary">
|
||||
Arrastra tu archivo aquí o haz clic para seleccionarlo
|
||||
{t('bulk.dropzone')}
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-foreground/60">Formatos soportados: CSV (.csv) o Excel (.xlsx)</p>
|
||||
<p className="mt-1 text-xs text-foreground/60">{t('bulk.formats')}</p>
|
||||
|
||||
{fileName ? (
|
||||
<div className="mt-3 flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-1.5 text-xs font-medium text-primary">
|
||||
@@ -116,21 +118,21 @@ export function BulkImportPanel() {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-start gap-1 px-1 text-xs sm:flex-row sm:items-center sm:justify-between">
|
||||
<span className="text-foreground/60">¿No tienes el archivo listo? Usa nuestra plantilla.</span>
|
||||
<span className="text-foreground/60">{t('bulk.templateHint')}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={downloadAttendeeTemplateCsv}
|
||||
className="inline-flex shrink-0 items-center gap-1 whitespace-nowrap font-medium text-accent transition-colors hover:text-accent-strong"
|
||||
>
|
||||
<Download className="size-3.5" />
|
||||
<span>Descargar plantilla CSV</span>
|
||||
<span>{t('bulk.downloadTemplate')}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{isParsingFile ? (
|
||||
<div className="flex items-center justify-center gap-2 py-6 text-sm text-foreground/60">
|
||||
<Loader2 className="size-4 animate-spin text-accent" />
|
||||
<span>Leyendo y analizando archivo...</span>
|
||||
<span>{t('bulk.parsing')}</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -138,9 +140,9 @@ export function BulkImportPanel() {
|
||||
<div className="space-y-3 pt-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 text-xs">
|
||||
<span className="font-semibold text-primary">Vista Previa:</span>
|
||||
<Badge variant="success">{validRowsCount} listos para importar</Badge>
|
||||
{invalidRowsCount > 0 ? <Badge variant="danger">{invalidRowsCount} con errores</Badge> : null}
|
||||
<span className="font-semibold text-primary">{t('bulk.preview')}</span>
|
||||
<Badge variant="success">{t('bulk.ready', { count: validRowsCount })}</Badge>
|
||||
{invalidRowsCount > 0 ? <Badge variant="danger">{t('bulk.withErrors', { count: invalidRowsCount })}</Badge> : null}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
@@ -152,7 +154,7 @@ export function BulkImportPanel() {
|
||||
}}
|
||||
className="h-7 px-2 text-xs text-foreground/50 hover:text-danger"
|
||||
>
|
||||
Limpiar lista
|
||||
{t('bulk.clear')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -160,10 +162,10 @@ export function BulkImportPanel() {
|
||||
<table className="w-full text-left text-xs">
|
||||
<thead className="sticky top-0 border-b border-border bg-surface font-semibold text-foreground/70">
|
||||
<tr>
|
||||
<th className="px-3 py-2">Nombre</th>
|
||||
<th className="px-3 py-2">Teléfono</th>
|
||||
<th className="px-3 py-2">Email</th>
|
||||
<th className="px-3 py-2">Estado</th>
|
||||
<th className="px-3 py-2">{t('bulk.name')}</th>
|
||||
<th className="px-3 py-2">{t('bulk.phone')}</th>
|
||||
<th className="px-3 py-2">{t('bulk.email')}</th>
|
||||
<th className="px-3 py-2">{t('bulk.status')}</th>
|
||||
<th className="px-2 py-2 text-right" />
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -174,16 +176,16 @@ export function BulkImportPanel() {
|
||||
className={!contact.isValid ? 'bg-danger-soft/30' : 'hover:bg-primary-soft/30'}
|
||||
>
|
||||
<td className="px-3 py-2 font-medium text-primary">
|
||||
{contact.fullName || <span className="italic text-danger">Sin nombre</span>}
|
||||
{contact.fullName || <span className="italic text-danger">{t('bulk.noName')}</span>}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-foreground/80">
|
||||
{contact.phone || <span className="italic text-danger">Sin teléfono</span>}
|
||||
{contact.phone || <span className="italic text-danger">{t('bulk.noPhone')}</span>}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-foreground/60">{contact.email || '—'}</td>
|
||||
<td className="px-3 py-2">
|
||||
{contact.isValid ? (
|
||||
<Badge variant="success" className="py-0 text-[10px]">
|
||||
Válido
|
||||
{t('bulk.valid')}
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="danger" className="py-0 text-[10px]" title={contact.error}>
|
||||
@@ -196,7 +198,7 @@ export function BulkImportPanel() {
|
||||
type="button"
|
||||
onClick={() => removeParsedContact(contact.id)}
|
||||
className="rounded p-1 text-foreground/40 transition-colors hover:text-danger"
|
||||
title="Eliminar fila"
|
||||
title={t('bulk.removeRow')}
|
||||
>
|
||||
<Trash2 className="size-3.5" />
|
||||
</button>
|
||||
@@ -209,7 +211,7 @@ export function BulkImportPanel() {
|
||||
|
||||
<div className="flex flex-col-reverse gap-2.5 border-t border-border pt-3 sm:flex-row sm:items-center sm:justify-end">
|
||||
<Button variant="ghost" onClick={cancelAddAttendee} className="w-full sm:w-auto">
|
||||
Cancelar
|
||||
{t('common:actions.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
@@ -218,7 +220,7 @@ export function BulkImportPanel() {
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
{isSubmittingBulkImport ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
||||
<span>Confirmar e Importar ({validRowsCount})</span>
|
||||
<span>{t('bulk.confirm', { count: validRowsCount })}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Clock, Loader2, UserPlus } from 'lucide-react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { Button, Modal } from '../../../components/ui'
|
||||
import { useAddAttendee } from './AddAttendeeProvider'
|
||||
|
||||
@@ -14,25 +15,30 @@ export function CapacityModal() {
|
||||
isSubmittingForcedAttendee,
|
||||
isSubmittingWaitlistEntry,
|
||||
} = useAddAttendee()
|
||||
const { t } = useTranslation('groupAdd')
|
||||
const isBusy = isSubmittingForcedAttendee || isSubmittingWaitlistEntry
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isCapacityModalOpen}
|
||||
onClose={closeCapacityModal}
|
||||
title="Cupo alcanzado"
|
||||
description="El grupo llegó a su cupo máximo de miembros."
|
||||
title={t('capacity.title')}
|
||||
description={t('capacity.description')}
|
||||
maxWidth="md"
|
||||
>
|
||||
{capacityPayload ? (
|
||||
<div className="space-y-4">
|
||||
<p className="text-sm text-foreground/70">
|
||||
El grupo <strong className="text-primary">{groupName}</strong> ya alcanzó su cupo de{' '}
|
||||
<strong className="text-primary">{capacity}</strong> miembros. ¿Qué deseas hacer con{' '}
|
||||
<strong className="text-primary">
|
||||
{`${capacityPayload.firstName.trim()} ${(capacityPayload.lastName ?? '').trim()}`.trim()}
|
||||
</strong>
|
||||
?
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="capacity.body"
|
||||
values={{
|
||||
group: groupName ?? '',
|
||||
capacity,
|
||||
name: `${capacityPayload.firstName.trim()} ${(capacityPayload.lastName ?? '').trim()}`.trim(),
|
||||
}}
|
||||
components={{ strong: <strong className="text-primary" /> }}
|
||||
/>
|
||||
</p>
|
||||
<div className="flex flex-col gap-2.5">
|
||||
<Button
|
||||
@@ -46,7 +52,7 @@ export function CapacityModal() {
|
||||
) : (
|
||||
<UserPlus className="size-4" />
|
||||
)}
|
||||
<span>Agregar de todos modos</span>
|
||||
<span>{t('capacity.force')}</span>
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
@@ -59,11 +65,11 @@ export function CapacityModal() {
|
||||
) : (
|
||||
<Clock className="size-4" />
|
||||
)}
|
||||
<span>Sumar a la lista de espera</span>
|
||||
<span>{t('capacity.waitlist')}</span>
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-center text-[11px] text-foreground/50">
|
||||
Si eliges agregarlo de todos modos, el grupo quedará por encima de su cupo.
|
||||
{t('capacity.forceHint')}
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { UserCheck } from 'lucide-react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import type { PersonSummary } from '@gruperly/shared'
|
||||
import { Button } from '../../../components/ui'
|
||||
|
||||
@@ -22,12 +23,13 @@ export function ExistingPersonNotice({
|
||||
onUnlink,
|
||||
onChangePhone,
|
||||
}: ExistingPersonNoticeProps) {
|
||||
const { t } = useTranslation('groupAdd')
|
||||
const groupNames = person.groups.map((group) => group.groupName).join(', ')
|
||||
|
||||
if (alreadyInGroup) {
|
||||
return (
|
||||
<div role="alert" className="mt-2 rounded-xl bg-danger-soft px-3 py-2.5 text-sm text-danger-fg">
|
||||
{person.fullName} ya es miembro de este grupo.
|
||||
{t('existing.alreadyInGroup', { name: person.fullName })}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -38,30 +40,29 @@ export function ExistingPersonNotice({
|
||||
<UserCheck className="mt-0.5 size-4 shrink-0 text-accent-fg" aria-hidden="true" />
|
||||
<p className="min-w-0">
|
||||
{isLinked ? (
|
||||
<>
|
||||
Vas a agregar a <strong>{person.fullName}</strong> a este grupo. Sus datos de contacto
|
||||
y notas son los mismos que en sus otros grupos.
|
||||
</>
|
||||
<Trans t={t} i18nKey="existing.linked" values={{ name: person.fullName }} components={{ strong: <strong /> }} />
|
||||
) : (
|
||||
<>
|
||||
Ya tenés a <strong>{person.fullName}</strong> con este teléfono
|
||||
{groupNames ? ` (en ${groupNames})` : ''}. ¿Es la misma persona?
|
||||
</>
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey={groupNames ? 'existing.foundInGroups' : 'existing.found'}
|
||||
values={{ name: person.fullName, groups: groupNames }}
|
||||
components={{ strong: <strong /> }}
|
||||
/>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-2.5 flex flex-wrap justify-end gap-2">
|
||||
{isLinked ? (
|
||||
<Button variant="ghost" onClick={onUnlink} size="sm">
|
||||
No es esta persona
|
||||
{t('existing.notThisPerson')}
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
<Button variant="ghost" onClick={onChangePhone} size="sm">
|
||||
Usar otro teléfono
|
||||
{t('existing.otherPhone')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={onLink} size="sm">
|
||||
Sí, agregarla
|
||||
{t('existing.confirm')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { Check, Loader2 } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button, Input, Label, useToast } from '../../../components/ui'
|
||||
import { useAddAttendee } from './AddAttendeeProvider'
|
||||
import { ExistingPersonNotice } from './ExistingPersonNotice'
|
||||
@@ -8,6 +9,7 @@ import { usePersonLookup } from './usePersonLookup'
|
||||
export function QuickAddForm() {
|
||||
const { groupId, submitQuickAttendee, isSubmittingAttendee, cancelAddAttendee } = useAddAttendee()
|
||||
const toast = useToast()
|
||||
const { t } = useTranslation(['groupAdd', 'common'])
|
||||
const [firstName, setFirstName] = useState('')
|
||||
const [lastName, setLastName] = useState('')
|
||||
const [phone, setPhone] = useState('')
|
||||
@@ -39,11 +41,11 @@ export function QuickAddForm() {
|
||||
return
|
||||
}
|
||||
if (mustLink) {
|
||||
toast.info('Ese teléfono ya es de una persona registrada: agregala o usá otro teléfono.')
|
||||
toast.info(t('quick.mustLink'))
|
||||
return
|
||||
}
|
||||
if (!firstName.trim() || !phone.trim()) {
|
||||
toast.error('Nombre y teléfono son obligatorios.')
|
||||
toast.error(t('quick.required'))
|
||||
return
|
||||
}
|
||||
submitQuickAttendee({
|
||||
@@ -69,11 +71,11 @@ export function QuickAddForm() {
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<div>
|
||||
<Label htmlFor="quick-first-name" className="mb-1 block text-xs">
|
||||
Nombre <span className="text-danger">*</span>
|
||||
{t('quick.firstName')} <span className="text-danger">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="quick-first-name"
|
||||
placeholder="Ej. Lucas"
|
||||
placeholder={t('quick.firstNamePlaceholder')}
|
||||
value={linkedPerson ? linkedPerson.fullName : firstName}
|
||||
onChange={(e) => setFirstName(e.target.value)}
|
||||
disabled={isLinked}
|
||||
@@ -82,11 +84,11 @@ export function QuickAddForm() {
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="quick-last-name" className="mb-1 block text-xs">
|
||||
Apellido
|
||||
{t('quick.lastName')}
|
||||
</Label>
|
||||
<Input
|
||||
id="quick-last-name"
|
||||
placeholder="Ej. González"
|
||||
placeholder={t('quick.lastNamePlaceholder')}
|
||||
value={isLinked ? '' : lastName}
|
||||
onChange={(e) => setLastName(e.target.value)}
|
||||
disabled={isLinked}
|
||||
@@ -96,11 +98,11 @@ export function QuickAddForm() {
|
||||
|
||||
<div>
|
||||
<Label htmlFor="quick-phone" className="mb-1 block text-xs">
|
||||
Teléfono / WhatsApp <span className="text-danger">*</span>
|
||||
{t('quick.phone')} <span className="text-danger">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="quick-phone"
|
||||
placeholder="Ej. +54 9 11 2345-6789"
|
||||
placeholder={t('quick.phonePlaceholder')}
|
||||
ref={phoneRef}
|
||||
value={phone}
|
||||
onChange={(e) => {
|
||||
@@ -123,19 +125,19 @@ export function QuickAddForm() {
|
||||
/>
|
||||
) : (
|
||||
<p className="mt-1 text-[11px] text-foreground/50">
|
||||
Usado para contacto y validación de duplicados.
|
||||
{t('quick.phoneHint')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="quick-email" className="mb-1 block text-xs">
|
||||
Email (opcional)
|
||||
{t('quick.email')}
|
||||
</Label>
|
||||
<Input
|
||||
id="quick-email"
|
||||
type="email"
|
||||
placeholder="alumno@ejemplo.com"
|
||||
placeholder={t('quick.emailPlaceholder')}
|
||||
value={linkedPerson ? (linkedPerson.email ?? '') : email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
disabled={isLinked}
|
||||
@@ -144,11 +146,11 @@ export function QuickAddForm() {
|
||||
|
||||
<div>
|
||||
<Label htmlFor="quick-notes" className="mb-1 block text-xs">
|
||||
Notas u Observaciones (opcional)
|
||||
{t('quick.notes')}
|
||||
</Label>
|
||||
<Input
|
||||
id="quick-notes"
|
||||
placeholder="Ej. Nivel intermedio, trae materiales propios"
|
||||
placeholder={t('quick.notesPlaceholder')}
|
||||
value={notes}
|
||||
onChange={(e) => setNotes(e.target.value)}
|
||||
disabled={isLinked}
|
||||
@@ -164,7 +166,7 @@ export function QuickAddForm() {
|
||||
}}
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
Cancelar
|
||||
{t('common:actions.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
@@ -173,7 +175,7 @@ export function QuickAddForm() {
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
{isSubmittingAttendee ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
||||
<span>Guardar Miembro</span>
|
||||
<span>{t('quick.submit')}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user