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 { 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>
|
||||
|
||||
Reference in New Issue
Block a user