New page for Add group member
This commit is contained in:
@@ -28,7 +28,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
type={type}
|
type={type}
|
||||||
className={cn(
|
className={cn(
|
||||||
'inline-flex items-center justify-center gap-2 rounded-xl font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:pointer-events-none disabled:opacity-50',
|
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-xl font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:pointer-events-none disabled:opacity-50',
|
||||||
variants[variant],
|
variants[variant],
|
||||||
sizes[size],
|
sizes[size],
|
||||||
className,
|
className,
|
||||||
|
|||||||
83
apps/web/src/features/groups/add/AddAttendeePage.tsx
Normal file
83
apps/web/src/features/groups/add/AddAttendeePage.tsx
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import { Link } from '@tanstack/react-router'
|
||||||
|
import { ArrowLeft, Loader2 } from 'lucide-react'
|
||||||
|
import { cn } from '../../../lib/utils'
|
||||||
|
import { useAddAttendee } from './AddAttendeeProvider'
|
||||||
|
import { BulkCapacityModal } from './BulkCapacityModal'
|
||||||
|
import { BulkImportPanel } from './BulkImportPanel'
|
||||||
|
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)' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export function AddAttendeePage() {
|
||||||
|
const { groupId, groupName, attendeesTotal, capacity, groupPending, activeTab, setActiveTab } =
|
||||||
|
useAddAttendee()
|
||||||
|
|
||||||
|
if (groupPending) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center py-20">
|
||||||
|
<Loader2 className="size-8 animate-spin text-accent" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="mx-auto w-full max-w-2xl animate-fade-in space-y-5">
|
||||||
|
<Link
|
||||||
|
to="/groups/$groupId"
|
||||||
|
params={{ groupId }}
|
||||||
|
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>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<header className="space-y-1">
|
||||||
|
<h1 className="text-2xl font-bold text-primary">Agregar miembros</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.
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
'Sumá miembros de forma individual o masiva desde una lista.'
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
{capacity != null ? (
|
||||||
|
<p className="text-xs text-foreground/50">
|
||||||
|
{attendeesTotal} de {capacity} lugares ocupados.
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div className="rounded-xl border border-border bg-surface p-4 sm:p-5">
|
||||||
|
<div className="mb-5 flex items-center rounded-xl bg-primary-soft p-1">
|
||||||
|
{TABS.map((tab) => (
|
||||||
|
<button
|
||||||
|
key={tab.value}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setActiveTab(tab.value)}
|
||||||
|
className={cn(
|
||||||
|
'flex-1 rounded-lg px-1 py-2 text-xs font-semibold transition-all',
|
||||||
|
activeTab === tab.value
|
||||||
|
? 'bg-surface text-primary shadow-xs'
|
||||||
|
: 'text-foreground/60 hover:text-primary',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{tab.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{activeTab === 'quick' ? <QuickAddForm /> : <BulkImportPanel />}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CapacityModal />
|
||||||
|
<BulkCapacityModal />
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
302
apps/web/src/features/groups/add/AddAttendeeProvider.tsx
Normal file
302
apps/web/src/features/groups/add/AddAttendeeProvider.tsx
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
import { createContext, useContext, useMemo, useState } from 'react'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import type {
|
||||||
|
CreateAttendee,
|
||||||
|
CreateAttendeeResult,
|
||||||
|
CreateGroupWaitlistEntry,
|
||||||
|
GroupWaitlistEntryDto,
|
||||||
|
GroupWaitlistList,
|
||||||
|
} from '@gruperly/shared'
|
||||||
|
import { useToast } from '../../../components/ui'
|
||||||
|
import {
|
||||||
|
addToGroupWaitlist,
|
||||||
|
ApiError,
|
||||||
|
bulkCreateAttendees,
|
||||||
|
createAttendee,
|
||||||
|
getGroup,
|
||||||
|
getGroupAttendees,
|
||||||
|
} from '../../../lib/api'
|
||||||
|
import type { ParsedContactRow } from '../../../lib/file-parser'
|
||||||
|
|
||||||
|
export type BulkAttendeeRow = {
|
||||||
|
firstName: string
|
||||||
|
lastName: string
|
||||||
|
fullName: string
|
||||||
|
phone: string
|
||||||
|
email?: string
|
||||||
|
notes?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AddAttendeeTab = 'quick' | 'bulk'
|
||||||
|
|
||||||
|
type AddAttendeeContextValue = {
|
||||||
|
groupId: string
|
||||||
|
groupName: string | undefined
|
||||||
|
groupPending: boolean
|
||||||
|
attendeesTotal: number
|
||||||
|
capacity: number | null
|
||||||
|
activeTab: AddAttendeeTab
|
||||||
|
setActiveTab: (value: AddAttendeeTab) => void
|
||||||
|
cancelAddAttendee: () => void
|
||||||
|
isCapacityModalOpen: boolean
|
||||||
|
capacityPayload: CreateAttendee | null
|
||||||
|
closeCapacityModal: () => void
|
||||||
|
isBulkCapacityModalOpen: boolean
|
||||||
|
closeBulkCapacityModal: () => void
|
||||||
|
parsedContacts: ParsedContactRow[]
|
||||||
|
setParsedContacts: (contacts: ParsedContactRow[]) => void
|
||||||
|
removeParsedContact: (id: string) => void
|
||||||
|
fileName: string | null
|
||||||
|
setFileName: (name: string | null) => void
|
||||||
|
isParsingFile: boolean
|
||||||
|
setIsParsingFile: (value: boolean) => void
|
||||||
|
isDragging: boolean
|
||||||
|
setIsDragging: (value: boolean) => void
|
||||||
|
validRowsCount: number
|
||||||
|
invalidRowsCount: number
|
||||||
|
isSubmittingAttendee: boolean
|
||||||
|
isSubmittingForcedAttendee: boolean
|
||||||
|
isSubmittingWaitlistEntry: boolean
|
||||||
|
isSubmittingBulkImport: boolean
|
||||||
|
submitQuickAttendee: (payload: CreateAttendee) => void
|
||||||
|
submitForcedAttendee: () => void
|
||||||
|
submitWaitlistEntry: () => void
|
||||||
|
requestBulkImport: () => void
|
||||||
|
confirmBulkImportOverCapacity: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const AddAttendeeContext = createContext<AddAttendeeContextValue | null>(null)
|
||||||
|
|
||||||
|
export function AddAttendeeProvider({ groupId, children }: { groupId: string; children: ReactNode }) {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
const toast = useToast()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
|
const [activeTab, setActiveTab] = useState<AddAttendeeTab>('quick')
|
||||||
|
const [isCapacityModalOpen, setIsCapacityModalOpen] = useState(false)
|
||||||
|
const [pendingCapacityPayload, setPendingCapacityPayload] = useState<CreateAttendee | null>(null)
|
||||||
|
const [isBulkCapacityModalOpen, setIsBulkCapacityModalOpen] = useState(false)
|
||||||
|
const [parsedContacts, setParsedContacts] = useState<ParsedContactRow[]>([])
|
||||||
|
const [fileName, setFileName] = useState<string | null>(null)
|
||||||
|
const [isParsingFile, setIsParsingFile] = useState(false)
|
||||||
|
const [isDragging, setIsDragging] = useState(false)
|
||||||
|
|
||||||
|
// Mismas query keys que el detalle del grupo: la data ya está en caché al navegar,
|
||||||
|
// así que la página se monta sin spinner ni fetch duplicado.
|
||||||
|
const groupQuery = useQuery({
|
||||||
|
queryKey: ['group', groupId],
|
||||||
|
queryFn: () => getGroup(groupId),
|
||||||
|
enabled: Boolean(groupId),
|
||||||
|
})
|
||||||
|
|
||||||
|
const attendeesQuery = useQuery({
|
||||||
|
queryKey: ['group-attendees', groupId],
|
||||||
|
queryFn: () => getGroupAttendees(groupId, 1, 100),
|
||||||
|
enabled: Boolean(groupId),
|
||||||
|
})
|
||||||
|
|
||||||
|
const group = groupQuery.data
|
||||||
|
const attendeesTotal = attendeesQuery.data?.pagination?.total ?? 0
|
||||||
|
const capacity = group?.capacity ?? null
|
||||||
|
|
||||||
|
const goBackToGroup = () => {
|
||||||
|
void navigate({ to: '/groups/$groupId', params: { groupId } })
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeCapacityFlow = () => {
|
||||||
|
setPendingCapacityPayload(null)
|
||||||
|
setIsCapacityModalOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const invalidateGroupQueries = () => {
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['group-waitlist', groupId] })
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['group', groupId] })
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCreateSuccess = (result: CreateAttendeeResult) => {
|
||||||
|
if (result.outcome === 'created') {
|
||||||
|
toast.success(`Miembro ${result.attendee.fullName} agregado con éxito.`)
|
||||||
|
} else {
|
||||||
|
toast.info(result.message)
|
||||||
|
}
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
||||||
|
goBackToGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
const createAttendeeMutation = useMutation({
|
||||||
|
mutationFn: (payload: CreateAttendee) => createAttendee(groupId, payload),
|
||||||
|
onMutate: (payload) => setPendingCapacityPayload(payload),
|
||||||
|
onSuccess: handleCreateSuccess,
|
||||||
|
onError: (err: Error) => {
|
||||||
|
if (err instanceof ApiError && err.problem?.code === 'group_capacity_reached') {
|
||||||
|
setIsCapacityModalOpen(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toast.error(err.message || 'Error al agregar miembro.')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const createAttendeeForceMutation = useMutation({
|
||||||
|
mutationFn: (payload: CreateAttendee) => createAttendee(groupId, payload, { allowOverflow: true }),
|
||||||
|
onSuccess: handleCreateSuccess,
|
||||||
|
onError: (err: Error) => {
|
||||||
|
toast.error(err.message || 'Error al agregar miembro.')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const addToWaitlistMutation = useMutation({
|
||||||
|
mutationFn: (payload: CreateGroupWaitlistEntry) => addToGroupWaitlist(groupId, payload),
|
||||||
|
onMutate: async (payload: CreateGroupWaitlistEntry) => {
|
||||||
|
await queryClient.cancelQueries({ queryKey: ['group-waitlist', groupId] })
|
||||||
|
const previousWaitlist = queryClient.getQueryData<GroupWaitlistList>(['group-waitlist', groupId])
|
||||||
|
|
||||||
|
if (previousWaitlist) {
|
||||||
|
const optimisticEntry: GroupWaitlistEntryDto = {
|
||||||
|
id: `temp-${Date.now()}`,
|
||||||
|
groupId,
|
||||||
|
fullName: `${payload.firstName} ${payload.lastName ?? ''}`.trim(),
|
||||||
|
phone: payload.phone,
|
||||||
|
email: payload.email || null,
|
||||||
|
notes: payload.notes ?? null,
|
||||||
|
status: 'PENDING',
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
}
|
||||||
|
queryClient.setQueryData<GroupWaitlistList>(['group-waitlist', groupId], {
|
||||||
|
data: [optimisticEntry, ...previousWaitlist.data],
|
||||||
|
pagination: {
|
||||||
|
...previousWaitlist.pagination,
|
||||||
|
total: previousWaitlist.pagination.total + 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return { previousWaitlist }
|
||||||
|
},
|
||||||
|
onSuccess: (entry) => {
|
||||||
|
toast.info(`${entry.fullName} fue agregado a la lista de espera del grupo.`)
|
||||||
|
invalidateGroupQueries()
|
||||||
|
goBackToGroup()
|
||||||
|
},
|
||||||
|
onError: (err: Error, _payload, context) => {
|
||||||
|
if (context?.previousWaitlist) {
|
||||||
|
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.')
|
||||||
|
} else {
|
||||||
|
toast.error(err.message || 'Error al agregar a la lista de espera.')
|
||||||
|
}
|
||||||
|
closeCapacityFlow()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const bulkImportMutation = useMutation({
|
||||||
|
mutationFn: (rows: BulkAttendeeRow[]) => bulkCreateAttendees(groupId, { attendees: rows }),
|
||||||
|
onSuccess: (res) => {
|
||||||
|
toast.success(res.message)
|
||||||
|
setParsedContacts([])
|
||||||
|
setFileName(null)
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
||||||
|
goBackToGroup()
|
||||||
|
},
|
||||||
|
onError: (err: Error) => {
|
||||||
|
toast.error(err.message || 'Error al importar miembros.')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const validRows: BulkAttendeeRow[] = useMemo(
|
||||||
|
() =>
|
||||||
|
parsedContacts
|
||||||
|
.filter((contact) => contact.isValid)
|
||||||
|
.map((contact) => ({
|
||||||
|
firstName: contact.firstName,
|
||||||
|
lastName: contact.lastName,
|
||||||
|
fullName: contact.fullName,
|
||||||
|
phone: contact.phone,
|
||||||
|
email: contact.email || undefined,
|
||||||
|
notes: contact.notes || undefined,
|
||||||
|
})),
|
||||||
|
[parsedContacts],
|
||||||
|
)
|
||||||
|
|
||||||
|
const runBulkImport = () => {
|
||||||
|
if (validRows.length === 0) {
|
||||||
|
toast.error('No hay miembros válidos para importar.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bulkImportMutation.mutate(validRows)
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestBulkImport = () => {
|
||||||
|
if (validRows.length === 0) {
|
||||||
|
toast.error('No hay miembros válidos para importar.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (capacity != null && attendeesTotal + validRows.length > capacity) {
|
||||||
|
setIsBulkCapacityModalOpen(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
runBulkImport()
|
||||||
|
}
|
||||||
|
|
||||||
|
const value: AddAttendeeContextValue = {
|
||||||
|
groupId,
|
||||||
|
groupName: group?.name,
|
||||||
|
groupPending: groupQuery.isPending,
|
||||||
|
attendeesTotal,
|
||||||
|
capacity,
|
||||||
|
activeTab,
|
||||||
|
setActiveTab,
|
||||||
|
cancelAddAttendee: goBackToGroup,
|
||||||
|
isCapacityModalOpen,
|
||||||
|
capacityPayload: pendingCapacityPayload,
|
||||||
|
closeCapacityModal: closeCapacityFlow,
|
||||||
|
isBulkCapacityModalOpen,
|
||||||
|
closeBulkCapacityModal: () => setIsBulkCapacityModalOpen(false),
|
||||||
|
parsedContacts,
|
||||||
|
setParsedContacts,
|
||||||
|
removeParsedContact: (id) => setParsedContacts((prev) => prev.filter((c) => c.id !== id)),
|
||||||
|
fileName,
|
||||||
|
setFileName,
|
||||||
|
isParsingFile,
|
||||||
|
setIsParsingFile,
|
||||||
|
isDragging,
|
||||||
|
setIsDragging,
|
||||||
|
validRowsCount: validRows.length,
|
||||||
|
invalidRowsCount: parsedContacts.length - validRows.length,
|
||||||
|
isSubmittingAttendee: createAttendeeMutation.isPending,
|
||||||
|
isSubmittingForcedAttendee: createAttendeeForceMutation.isPending,
|
||||||
|
isSubmittingWaitlistEntry: addToWaitlistMutation.isPending,
|
||||||
|
isSubmittingBulkImport: bulkImportMutation.isPending,
|
||||||
|
submitQuickAttendee: (payload) => createAttendeeMutation.mutate(payload),
|
||||||
|
submitForcedAttendee: () => {
|
||||||
|
if (pendingCapacityPayload) {
|
||||||
|
createAttendeeForceMutation.mutate({ ...pendingCapacityPayload })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submitWaitlistEntry: () => {
|
||||||
|
if (pendingCapacityPayload) {
|
||||||
|
addToWaitlistMutation.mutate({ ...pendingCapacityPayload })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
requestBulkImport,
|
||||||
|
confirmBulkImportOverCapacity: () => {
|
||||||
|
setIsBulkCapacityModalOpen(false)
|
||||||
|
runBulkImport()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return <AddAttendeeContext.Provider value={value}>{children}</AddAttendeeContext.Provider>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAddAttendee() {
|
||||||
|
const context = useContext(AddAttendeeContext)
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useAddAttendee debe usarse dentro de <AddAttendeeProvider>')
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Check } from 'lucide-react'
|
import { Check } from 'lucide-react'
|
||||||
import { Button, Modal } from '../../../components/ui'
|
import { Button, Modal } from '../../../components/ui'
|
||||||
import { useGroupDetail } from './GroupDetailProvider'
|
import { useAddAttendee } from './AddAttendeeProvider'
|
||||||
|
|
||||||
export function BulkCapacityModal() {
|
export function BulkCapacityModal() {
|
||||||
const {
|
const {
|
||||||
@@ -9,8 +9,9 @@ export function BulkCapacityModal() {
|
|||||||
confirmBulkImportOverCapacity,
|
confirmBulkImportOverCapacity,
|
||||||
validRowsCount,
|
validRowsCount,
|
||||||
attendeesTotal,
|
attendeesTotal,
|
||||||
group,
|
groupName,
|
||||||
} = useGroupDetail()
|
capacity,
|
||||||
|
} = useAddAttendee()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -24,13 +25,17 @@ export function BulkCapacityModal() {
|
|||||||
<p className="text-sm text-foreground/70">
|
<p className="text-sm text-foreground/70">
|
||||||
Estás por importar <strong className="text-primary">{validRowsCount}</strong> miembro(s), pero el
|
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
|
grupo ya tiene <strong className="text-primary">{attendeesTotal}</strong> inscrito(s) y su cupo es
|
||||||
de <strong className="text-primary">{group?.capacity}</strong>. ¿Deseas importarlos de todos modos?
|
de <strong className="text-primary">{capacity}</strong>. ¿Deseas importarlos de todos modos?
|
||||||
</p>
|
</p>
|
||||||
<div className="flex items-center justify-end gap-2.5 pt-2">
|
<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}>
|
<Button variant="ghost" onClick={closeBulkCapacityModal} className="w-full sm:w-auto">
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" onClick={confirmBulkImportOverCapacity} className="gap-2">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
onClick={confirmBulkImportOverCapacity}
|
||||||
|
className="w-full sm:w-auto"
|
||||||
|
>
|
||||||
<Check className="size-4" />
|
<Check className="size-4" />
|
||||||
Importar de todos modos
|
Importar de todos modos
|
||||||
</Button>
|
</Button>
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
parseXlsxContent,
|
parseXlsxContent,
|
||||||
} from '../../../lib/file-parser'
|
} from '../../../lib/file-parser'
|
||||||
import { cn } from '../../../lib/utils'
|
import { cn } from '../../../lib/utils'
|
||||||
import { useGroupDetail } from './GroupDetailProvider'
|
import { useAddAttendee } from './AddAttendeeProvider'
|
||||||
|
|
||||||
export function BulkImportPanel() {
|
export function BulkImportPanel() {
|
||||||
const {
|
const {
|
||||||
@@ -24,9 +24,9 @@ export function BulkImportPanel() {
|
|||||||
validRowsCount,
|
validRowsCount,
|
||||||
invalidRowsCount,
|
invalidRowsCount,
|
||||||
isSubmittingBulkImport,
|
isSubmittingBulkImport,
|
||||||
closeAddAttendeeModal,
|
cancelAddAttendee,
|
||||||
requestBulkImport,
|
requestBulkImport,
|
||||||
} = useGroupDetail()
|
} = useAddAttendee()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
@@ -115,12 +115,12 @@ export function BulkImportPanel() {
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between px-1 text-xs">
|
<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">¿No tienes el archivo listo? Usa nuestra plantilla.</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={downloadAttendeeTemplateCsv}
|
onClick={downloadAttendeeTemplateCsv}
|
||||||
className="inline-flex items-center gap-1 font-medium text-accent transition-colors hover:text-accent-strong"
|
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" />
|
<Download className="size-3.5" />
|
||||||
<span>Descargar plantilla CSV</span>
|
<span>Descargar plantilla CSV</span>
|
||||||
@@ -207,15 +207,15 @@ export function BulkImportPanel() {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-end gap-2.5 border-t border-border pt-3">
|
<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={closeAddAttendeeModal}>
|
<Button variant="ghost" onClick={cancelAddAttendee} className="w-full sm:w-auto">
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
onClick={requestBulkImport}
|
onClick={requestBulkImport}
|
||||||
disabled={isSubmittingBulkImport || validRowsCount === 0}
|
disabled={isSubmittingBulkImport || validRowsCount === 0}
|
||||||
className="gap-2"
|
className="w-full sm:w-auto"
|
||||||
>
|
>
|
||||||
{isSubmittingBulkImport ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
{isSubmittingBulkImport ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
||||||
<span>Confirmar e Importar ({validRowsCount})</span>
|
<span>Confirmar e Importar ({validRowsCount})</span>
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
import { Clock, Loader2, UserPlus } from 'lucide-react'
|
import { Clock, Loader2, UserPlus } from 'lucide-react'
|
||||||
import { Button, Modal } from '../../../components/ui'
|
import { Button, Modal } from '../../../components/ui'
|
||||||
import { useGroupDetail } from './GroupDetailProvider'
|
import { useAddAttendee } from './AddAttendeeProvider'
|
||||||
|
|
||||||
export function CapacityModal() {
|
export function CapacityModal() {
|
||||||
const {
|
const {
|
||||||
isCapacityModalOpen,
|
isCapacityModalOpen,
|
||||||
closeCapacityModal,
|
closeCapacityModal,
|
||||||
capacityPayload,
|
capacityPayload,
|
||||||
group,
|
groupName,
|
||||||
|
capacity,
|
||||||
submitForcedAttendee,
|
submitForcedAttendee,
|
||||||
submitWaitlistEntry,
|
submitWaitlistEntry,
|
||||||
isSubmittingForcedAttendee,
|
isSubmittingForcedAttendee,
|
||||||
isSubmittingWaitlistEntry,
|
isSubmittingWaitlistEntry,
|
||||||
} = useGroupDetail()
|
} = useAddAttendee()
|
||||||
const isBusy = isSubmittingForcedAttendee || isSubmittingWaitlistEntry
|
const isBusy = isSubmittingForcedAttendee || isSubmittingWaitlistEntry
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -26,15 +27,20 @@ export function CapacityModal() {
|
|||||||
{capacityPayload ? (
|
{capacityPayload ? (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<p className="text-sm text-foreground/70">
|
<p className="text-sm text-foreground/70">
|
||||||
El grupo <strong className="text-primary">{group?.name}</strong> ya alcanzó su cupo de{' '}
|
El grupo <strong className="text-primary">{groupName}</strong> ya alcanzó su cupo de{' '}
|
||||||
<strong className="text-primary">{group?.capacity}</strong> miembros. ¿Qué deseas hacer con{' '}
|
<strong className="text-primary">{capacity}</strong> miembros. ¿Qué deseas hacer con{' '}
|
||||||
<strong className="text-primary">
|
<strong className="text-primary">
|
||||||
{`${capacityPayload.firstName.trim()} ${(capacityPayload.lastName ?? '').trim()}`.trim()}
|
{`${capacityPayload.firstName.trim()} ${(capacityPayload.lastName ?? '').trim()}`.trim()}
|
||||||
</strong>
|
</strong>
|
||||||
?
|
?
|
||||||
</p>
|
</p>
|
||||||
<div className="flex flex-col gap-2.5">
|
<div className="flex flex-col gap-2.5">
|
||||||
<Button variant="primary" onClick={submitForcedAttendee} disabled={isBusy} className="gap-2">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
onClick={submitForcedAttendee}
|
||||||
|
disabled={isBusy}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
{isSubmittingForcedAttendee ? (
|
{isSubmittingForcedAttendee ? (
|
||||||
<Loader2 className="size-4 animate-spin" />
|
<Loader2 className="size-4 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
@@ -42,7 +48,12 @@ export function CapacityModal() {
|
|||||||
)}
|
)}
|
||||||
<span>Agregar de todos modos</span>
|
<span>Agregar de todos modos</span>
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" onClick={submitWaitlistEntry} disabled={isBusy} className="gap-2">
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={submitWaitlistEntry}
|
||||||
|
disabled={isBusy}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
{isSubmittingWaitlistEntry ? (
|
{isSubmittingWaitlistEntry ? (
|
||||||
<Loader2 className="size-4 animate-spin" />
|
<Loader2 className="size-4 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Check, Loader2 } from 'lucide-react'
|
import { Check, Loader2 } from 'lucide-react'
|
||||||
import { Button, Input, Label, useToast } from '../../../components/ui'
|
import { Button, Input, Label, useToast } from '../../../components/ui'
|
||||||
import { useGroupDetail } from './GroupDetailProvider'
|
import { useAddAttendee } from './AddAttendeeProvider'
|
||||||
|
|
||||||
export function QuickAddForm() {
|
export function QuickAddForm() {
|
||||||
const { submitQuickAttendee, isSubmittingAttendee, closeAddAttendeeModal } = useGroupDetail()
|
const { submitQuickAttendee, isSubmittingAttendee, cancelAddAttendee } = useAddAttendee()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const [firstName, setFirstName] = useState('')
|
const [firstName, setFirstName] = useState('')
|
||||||
const [lastName, setLastName] = useState('')
|
const [lastName, setLastName] = useState('')
|
||||||
@@ -34,7 +34,6 @@ export function QuickAddForm() {
|
|||||||
setEmail('')
|
setEmail('')
|
||||||
setNotes('')
|
setNotes('')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||||
@@ -104,17 +103,23 @@ export function QuickAddForm() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-end gap-2.5 border-t border-border pt-3">
|
<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
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
resetForm()
|
resetForm()
|
||||||
closeAddAttendeeModal()
|
cancelAddAttendee()
|
||||||
}}
|
}}
|
||||||
|
className="w-full sm:w-auto"
|
||||||
>
|
>
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" type="submit" disabled={isSubmittingAttendee} className="gap-2">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
type="submit"
|
||||||
|
disabled={isSubmittingAttendee}
|
||||||
|
className="w-full sm:w-auto"
|
||||||
|
>
|
||||||
{isSubmittingAttendee ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
{isSubmittingAttendee ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}
|
||||||
<span>Guardar Miembro</span>
|
<span>Guardar Miembro</span>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import { Modal } from '../../../components/ui'
|
|
||||||
import { cn } from '../../../lib/utils'
|
|
||||||
import { BulkImportPanel } from './BulkImportPanel'
|
|
||||||
import { QuickAddForm } from './QuickAddForm'
|
|
||||||
import { useGroupDetail } from './GroupDetailProvider'
|
|
||||||
|
|
||||||
export function AddAttendeeModal() {
|
|
||||||
const { isAddAttendeeModalOpen, closeAddAttendeeModal, activeTab, setActiveTab } = useGroupDetail()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
isOpen={isAddAttendeeModalOpen}
|
|
||||||
onClose={closeAddAttendeeModal}
|
|
||||||
title="Agregar Miembros al Grupo"
|
|
||||||
description="Agrega miembros rápidamente completando sus datos o importa una lista de contactos."
|
|
||||||
maxWidth="lg"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<div className="mb-5 flex items-center rounded-xl bg-primary-soft p-1">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setActiveTab('quick')}
|
|
||||||
className={cn(
|
|
||||||
'flex-1 rounded-lg py-2 text-xs font-semibold transition-all',
|
|
||||||
activeTab === 'quick' ? 'bg-surface text-primary shadow-xs' : 'text-foreground/60 hover:text-primary',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
Carga Rápida (Individual)
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setActiveTab('bulk')}
|
|
||||||
className={cn(
|
|
||||||
'flex-1 rounded-lg py-2 text-xs font-semibold transition-all',
|
|
||||||
activeTab === 'bulk' ? 'bg-surface text-primary shadow-xs' : 'text-foreground/60 hover:text-primary',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
Carga Masiva (CSV / Excel)
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{activeTab === 'quick' ? <QuickAddForm /> : <BulkImportPanel />}
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -3,21 +3,13 @@ import type { ReactNode } from 'react'
|
|||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import type {
|
import type {
|
||||||
AttendeeDto,
|
AttendeeDto,
|
||||||
CreateAttendee,
|
|
||||||
CreateAttendeeResult,
|
|
||||||
CreateGroupWaitlistEntry,
|
|
||||||
GroupDto,
|
GroupDto,
|
||||||
GroupWaitlistEntryDto,
|
GroupWaitlistEntryDto,
|
||||||
GroupWaitlistList,
|
|
||||||
GroupRiskLevel,
|
GroupRiskLevel,
|
||||||
} from '@gruperly/shared'
|
} from '@gruperly/shared'
|
||||||
import { useToast } from '../../../components/ui'
|
import { useToast } from '../../../components/ui'
|
||||||
import type { ParsedContactRow } from '../../../lib/file-parser'
|
|
||||||
import {
|
import {
|
||||||
addToGroupWaitlist,
|
|
||||||
ApiError,
|
ApiError,
|
||||||
bulkCreateAttendees,
|
|
||||||
createAttendee,
|
|
||||||
getGroup,
|
getGroup,
|
||||||
getGroupAttendees,
|
getGroupAttendees,
|
||||||
getGroupsRiskOverview,
|
getGroupsRiskOverview,
|
||||||
@@ -28,17 +20,7 @@ import {
|
|||||||
} from '../../../lib/api'
|
} from '../../../lib/api'
|
||||||
import { useRemoveAttendee } from './useRemoveAttendee'
|
import { useRemoveAttendee } from './useRemoveAttendee'
|
||||||
|
|
||||||
export type BulkAttendeeRow = {
|
|
||||||
firstName: string
|
|
||||||
lastName: string
|
|
||||||
fullName: string
|
|
||||||
phone: string
|
|
||||||
email?: string
|
|
||||||
notes?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ListSection = 'members' | 'waitlist'
|
export type ListSection = 'members' | 'waitlist'
|
||||||
export type AddAttendeeTab = 'quick' | 'bulk'
|
|
||||||
|
|
||||||
type GroupDetailContextValue = {
|
type GroupDetailContextValue = {
|
||||||
groupId: string
|
groupId: string
|
||||||
@@ -60,49 +42,19 @@ type GroupDetailContextValue = {
|
|||||||
setSearchFilter: (value: string) => void
|
setSearchFilter: (value: string) => void
|
||||||
listSection: ListSection
|
listSection: ListSection
|
||||||
setListSection: (value: ListSection) => void
|
setListSection: (value: ListSection) => void
|
||||||
activeTab: AddAttendeeTab
|
|
||||||
setActiveTab: (value: AddAttendeeTab) => void
|
|
||||||
isInviteModalOpen: boolean
|
isInviteModalOpen: boolean
|
||||||
openInviteModal: () => void
|
openInviteModal: () => void
|
||||||
closeInviteModal: () => void
|
closeInviteModal: () => void
|
||||||
isAddAttendeeModalOpen: boolean
|
|
||||||
openAddAttendeeModal: () => void
|
|
||||||
closeAddAttendeeModal: () => void
|
|
||||||
attendeeToRemove: AttendeeDto | null
|
attendeeToRemove: AttendeeDto | null
|
||||||
requestRemoveAttendee: (attendee: AttendeeDto) => void
|
requestRemoveAttendee: (attendee: AttendeeDto) => void
|
||||||
cancelRemoveAttendee: () => void
|
cancelRemoveAttendee: () => void
|
||||||
confirmRemoveAttendee: (promoteFromWaitlist: boolean) => void
|
confirmRemoveAttendee: (promoteFromWaitlist: boolean) => void
|
||||||
selectedWaitlistEntry: GroupWaitlistEntryDto | null
|
selectedWaitlistEntry: GroupWaitlistEntryDto | null
|
||||||
setSelectedWaitlistEntry: (entry: GroupWaitlistEntryDto | null) => void
|
setSelectedWaitlistEntry: (entry: GroupWaitlistEntryDto | null) => void
|
||||||
isCapacityModalOpen: boolean
|
|
||||||
capacityPayload: CreateAttendee | null
|
|
||||||
closeCapacityModal: () => void
|
|
||||||
isBulkCapacityModalOpen: boolean
|
|
||||||
closeBulkCapacityModal: () => void
|
|
||||||
parsedContacts: ParsedContactRow[]
|
|
||||||
setParsedContacts: (contacts: ParsedContactRow[]) => void
|
|
||||||
removeParsedContact: (id: string) => void
|
|
||||||
fileName: string | null
|
|
||||||
setFileName: (name: string | null) => void
|
|
||||||
isParsingFile: boolean
|
|
||||||
setIsParsingFile: (value: boolean) => void
|
|
||||||
isDragging: boolean
|
|
||||||
setIsDragging: (value: boolean) => void
|
|
||||||
validRowsCount: number
|
|
||||||
invalidRowsCount: number
|
|
||||||
isSubmittingAttendee: boolean
|
|
||||||
isSubmittingForcedAttendee: boolean
|
|
||||||
isSubmittingWaitlistEntry: boolean
|
|
||||||
isSubmittingBulkImport: boolean
|
|
||||||
isSubmittingRemoval: boolean
|
isSubmittingRemoval: boolean
|
||||||
isSubmittingPromotion: boolean
|
isSubmittingPromotion: boolean
|
||||||
isSubmittingWaitlistRemoval: boolean
|
isSubmittingWaitlistRemoval: boolean
|
||||||
isRegeneratingInvite: boolean
|
isRegeneratingInvite: boolean
|
||||||
submitQuickAttendee: (payload: CreateAttendee) => void
|
|
||||||
submitForcedAttendee: () => void
|
|
||||||
submitWaitlistEntry: () => void
|
|
||||||
requestBulkImport: () => void
|
|
||||||
confirmBulkImportOverCapacity: () => void
|
|
||||||
promoteEntry: (entry: GroupWaitlistEntryDto) => void
|
promoteEntry: (entry: GroupWaitlistEntryDto) => void
|
||||||
removeEntry: (entry: GroupWaitlistEntryDto) => void
|
removeEntry: (entry: GroupWaitlistEntryDto) => void
|
||||||
regenerateInvite: () => void
|
regenerateInvite: () => void
|
||||||
@@ -118,19 +70,10 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
|
|||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const [isInviteModalOpen, setIsInviteModalOpen] = useState(false)
|
const [isInviteModalOpen, setIsInviteModalOpen] = useState(false)
|
||||||
const [isAddAttendeeModalOpen, setIsAddAttendeeModalOpen] = useState(false)
|
|
||||||
const [activeTab, setActiveTab] = useState<AddAttendeeTab>('quick')
|
|
||||||
const [listSection, setListSection] = useState<ListSection>('members')
|
const [listSection, setListSection] = useState<ListSection>('members')
|
||||||
const [attendeeToRemove, setAttendeeToRemove] = useState<AttendeeDto | null>(null)
|
const [attendeeToRemove, setAttendeeToRemove] = useState<AttendeeDto | null>(null)
|
||||||
const [selectedWaitlistEntry, setSelectedWaitlistEntry] = useState<GroupWaitlistEntryDto | null>(null)
|
const [selectedWaitlistEntry, setSelectedWaitlistEntry] = useState<GroupWaitlistEntryDto | null>(null)
|
||||||
const [isCapacityModalOpen, setIsCapacityModalOpen] = useState(false)
|
|
||||||
const [pendingCapacityPayload, setPendingCapacityPayload] = useState<CreateAttendee | null>(null)
|
|
||||||
const [isBulkCapacityModalOpen, setIsBulkCapacityModalOpen] = useState(false)
|
|
||||||
const [searchFilter, setSearchFilter] = useState('')
|
const [searchFilter, setSearchFilter] = useState('')
|
||||||
const [parsedContacts, setParsedContacts] = useState<ParsedContactRow[]>([])
|
|
||||||
const [fileName, setFileName] = useState<string | null>(null)
|
|
||||||
const [isParsingFile, setIsParsingFile] = useState(false)
|
|
||||||
const [isDragging, setIsDragging] = useState(false)
|
|
||||||
|
|
||||||
const groupQuery = useQuery({
|
const groupQuery = useQuery({
|
||||||
queryKey: ['group', groupId],
|
queryKey: ['group', groupId],
|
||||||
@@ -170,28 +113,12 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
|
|||||||
const firstWaitlistEntry = waitlistEntries[0] ?? null
|
const firstWaitlistEntry = waitlistEntries[0] ?? null
|
||||||
const hasFreeCapacity = group?.capacity == null || attendeesTotal < group.capacity
|
const hasFreeCapacity = group?.capacity == null || attendeesTotal < group.capacity
|
||||||
|
|
||||||
const closeAddAttendeeFlow = () => {
|
|
||||||
setPendingCapacityPayload(null)
|
|
||||||
setIsCapacityModalOpen(false)
|
|
||||||
setIsAddAttendeeModalOpen(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const invalidateGroupQueries = () => {
|
const invalidateGroupQueries = () => {
|
||||||
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
||||||
void queryClient.invalidateQueries({ queryKey: ['group-waitlist', groupId] })
|
void queryClient.invalidateQueries({ queryKey: ['group-waitlist', groupId] })
|
||||||
void queryClient.invalidateQueries({ queryKey: ['group', groupId] })
|
void queryClient.invalidateQueries({ queryKey: ['group', groupId] })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCreateSuccess = (result: CreateAttendeeResult) => {
|
|
||||||
if (result.outcome === 'created') {
|
|
||||||
toast.success(`Miembro ${result.attendee.fullName} agregado con éxito.`)
|
|
||||||
} else {
|
|
||||||
toast.info(result.message)
|
|
||||||
}
|
|
||||||
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
|
||||||
closeAddAttendeeFlow()
|
|
||||||
}
|
|
||||||
|
|
||||||
const regenerateTokenMutation = useMutation({
|
const regenerateTokenMutation = useMutation({
|
||||||
mutationFn: () => getInviteToken(groupId, true),
|
mutationFn: () => getInviteToken(groupId, true),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
@@ -203,89 +130,6 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const createAttendeeMutation = useMutation({
|
|
||||||
mutationFn: (payload: CreateAttendee) => createAttendee(groupId, payload),
|
|
||||||
onMutate: (payload) => setPendingCapacityPayload(payload),
|
|
||||||
onSuccess: handleCreateSuccess,
|
|
||||||
onError: (err: Error) => {
|
|
||||||
if (err instanceof ApiError && err.problem?.code === 'group_capacity_reached') {
|
|
||||||
setIsCapacityModalOpen(true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
toast.error(err.message || 'Error al agregar miembro.')
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const createAttendeeForceMutation = useMutation({
|
|
||||||
mutationFn: (payload: CreateAttendee) => createAttendee(groupId, payload, { allowOverflow: true }),
|
|
||||||
onSuccess: handleCreateSuccess,
|
|
||||||
onError: (err: Error) => {
|
|
||||||
toast.error(err.message || 'Error al agregar miembro.')
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const addToWaitlistMutation = useMutation({
|
|
||||||
mutationFn: (payload: CreateGroupWaitlistEntry) => addToGroupWaitlist(groupId, payload),
|
|
||||||
onMutate: async (payload: CreateGroupWaitlistEntry) => {
|
|
||||||
await queryClient.cancelQueries({ queryKey: ['group-waitlist', groupId] })
|
|
||||||
const previousWaitlist = queryClient.getQueryData<GroupWaitlistList>(['group-waitlist', groupId])
|
|
||||||
|
|
||||||
if (previousWaitlist) {
|
|
||||||
const optimisticEntry: GroupWaitlistEntryDto = {
|
|
||||||
id: `temp-${Date.now()}`,
|
|
||||||
groupId,
|
|
||||||
fullName: `${payload.firstName} ${payload.lastName ?? ''}`.trim(),
|
|
||||||
phone: payload.phone,
|
|
||||||
email: payload.email || null,
|
|
||||||
notes: payload.notes ?? null,
|
|
||||||
status: 'PENDING',
|
|
||||||
createdAt: new Date().toISOString(),
|
|
||||||
updatedAt: new Date().toISOString(),
|
|
||||||
}
|
|
||||||
queryClient.setQueryData<GroupWaitlistList>(['group-waitlist', groupId], {
|
|
||||||
data: [optimisticEntry, ...previousWaitlist.data],
|
|
||||||
pagination: {
|
|
||||||
...previousWaitlist.pagination,
|
|
||||||
total: previousWaitlist.pagination.total + 1,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return { previousWaitlist }
|
|
||||||
},
|
|
||||||
onSuccess: (entry) => {
|
|
||||||
toast.info(`${entry.fullName} fue agregado a la lista de espera del grupo.`)
|
|
||||||
invalidateGroupQueries()
|
|
||||||
closeAddAttendeeFlow()
|
|
||||||
},
|
|
||||||
onError: (err: Error, _payload, context) => {
|
|
||||||
if (context?.previousWaitlist) {
|
|
||||||
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.')
|
|
||||||
} else {
|
|
||||||
toast.error(err.message || 'Error al agregar a la lista de espera.')
|
|
||||||
}
|
|
||||||
setPendingCapacityPayload(null)
|
|
||||||
setIsCapacityModalOpen(false)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const bulkImportMutation = useMutation({
|
|
||||||
mutationFn: (rows: BulkAttendeeRow[]) => bulkCreateAttendees(groupId, { attendees: rows }),
|
|
||||||
onSuccess: (res) => {
|
|
||||||
toast.success(res.message)
|
|
||||||
setParsedContacts([])
|
|
||||||
setFileName(null)
|
|
||||||
void queryClient.invalidateQueries({ queryKey: ['group-attendees', groupId] })
|
|
||||||
setIsAddAttendeeModalOpen(false)
|
|
||||||
},
|
|
||||||
onError: (err: Error) => {
|
|
||||||
toast.error(err.message || 'Error al importar miembros.')
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const removeAttendeeMutation = useRemoveAttendee({
|
const removeAttendeeMutation = useRemoveAttendee({
|
||||||
groupId,
|
groupId,
|
||||||
onRemoved: () => setAttendeeToRemove(null),
|
onRemoved: () => setAttendeeToRemove(null),
|
||||||
@@ -359,41 +203,6 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
|
|||||||
window.open(whatsappShareUrl, '_blank', 'noopener,noreferrer')
|
window.open(whatsappShareUrl, '_blank', 'noopener,noreferrer')
|
||||||
}
|
}
|
||||||
|
|
||||||
const validRows: BulkAttendeeRow[] = useMemo(
|
|
||||||
() =>
|
|
||||||
parsedContacts
|
|
||||||
.filter((contact) => contact.isValid)
|
|
||||||
.map((contact) => ({
|
|
||||||
firstName: contact.firstName,
|
|
||||||
lastName: contact.lastName,
|
|
||||||
fullName: contact.fullName,
|
|
||||||
phone: contact.phone,
|
|
||||||
email: contact.email || undefined,
|
|
||||||
notes: contact.notes || undefined,
|
|
||||||
})),
|
|
||||||
[parsedContacts],
|
|
||||||
)
|
|
||||||
|
|
||||||
const runBulkImport = () => {
|
|
||||||
if (validRows.length === 0) {
|
|
||||||
toast.error('No hay miembros válidos para importar.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
bulkImportMutation.mutate(validRows)
|
|
||||||
}
|
|
||||||
|
|
||||||
const requestBulkImport = () => {
|
|
||||||
if (validRows.length === 0) {
|
|
||||||
toast.error('No hay miembros válidos para importar.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (group?.capacity != null && attendeesTotal + validRows.length > group.capacity) {
|
|
||||||
setIsBulkCapacityModalOpen(true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
runBulkImport()
|
|
||||||
}
|
|
||||||
|
|
||||||
const value: GroupDetailContextValue = {
|
const value: GroupDetailContextValue = {
|
||||||
groupId,
|
groupId,
|
||||||
group,
|
group,
|
||||||
@@ -414,14 +223,9 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
|
|||||||
setSearchFilter,
|
setSearchFilter,
|
||||||
listSection,
|
listSection,
|
||||||
setListSection,
|
setListSection,
|
||||||
activeTab,
|
|
||||||
setActiveTab,
|
|
||||||
isInviteModalOpen,
|
isInviteModalOpen,
|
||||||
openInviteModal: () => setIsInviteModalOpen(true),
|
openInviteModal: () => setIsInviteModalOpen(true),
|
||||||
closeInviteModal: () => setIsInviteModalOpen(false),
|
closeInviteModal: () => setIsInviteModalOpen(false),
|
||||||
isAddAttendeeModalOpen,
|
|
||||||
openAddAttendeeModal: () => setIsAddAttendeeModalOpen(true),
|
|
||||||
closeAddAttendeeModal: () => setIsAddAttendeeModalOpen(false),
|
|
||||||
attendeeToRemove,
|
attendeeToRemove,
|
||||||
requestRemoveAttendee: (attendee) => setAttendeeToRemove(attendee),
|
requestRemoveAttendee: (attendee) => setAttendeeToRemove(attendee),
|
||||||
cancelRemoveAttendee: () => setAttendeeToRemove(null),
|
cancelRemoveAttendee: () => setAttendeeToRemove(null),
|
||||||
@@ -431,49 +235,10 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
|
|||||||
},
|
},
|
||||||
selectedWaitlistEntry,
|
selectedWaitlistEntry,
|
||||||
setSelectedWaitlistEntry,
|
setSelectedWaitlistEntry,
|
||||||
isCapacityModalOpen,
|
|
||||||
capacityPayload: pendingCapacityPayload,
|
|
||||||
closeCapacityModal: () => {
|
|
||||||
setPendingCapacityPayload(null)
|
|
||||||
setIsCapacityModalOpen(false)
|
|
||||||
},
|
|
||||||
isBulkCapacityModalOpen,
|
|
||||||
closeBulkCapacityModal: () => setIsBulkCapacityModalOpen(false),
|
|
||||||
parsedContacts,
|
|
||||||
setParsedContacts,
|
|
||||||
removeParsedContact: (id) => setParsedContacts((prev) => prev.filter((c) => c.id !== id)),
|
|
||||||
fileName,
|
|
||||||
setFileName,
|
|
||||||
isParsingFile,
|
|
||||||
setIsParsingFile,
|
|
||||||
isDragging,
|
|
||||||
setIsDragging,
|
|
||||||
validRowsCount: validRows.length,
|
|
||||||
invalidRowsCount: parsedContacts.length - validRows.length,
|
|
||||||
isSubmittingAttendee: createAttendeeMutation.isPending,
|
|
||||||
isSubmittingForcedAttendee: createAttendeeForceMutation.isPending,
|
|
||||||
isSubmittingWaitlistEntry: addToWaitlistMutation.isPending,
|
|
||||||
isSubmittingBulkImport: bulkImportMutation.isPending,
|
|
||||||
isSubmittingRemoval: removeAttendeeMutation.isRemovingAttendee,
|
isSubmittingRemoval: removeAttendeeMutation.isRemovingAttendee,
|
||||||
isSubmittingPromotion: promoteWaitlistMutation.isPending,
|
isSubmittingPromotion: promoteWaitlistMutation.isPending,
|
||||||
isSubmittingWaitlistRemoval: removeWaitlistEntryMutation.isPending,
|
isSubmittingWaitlistRemoval: removeWaitlistEntryMutation.isPending,
|
||||||
isRegeneratingInvite: regenerateTokenMutation.isPending,
|
isRegeneratingInvite: regenerateTokenMutation.isPending,
|
||||||
submitQuickAttendee: (payload) => createAttendeeMutation.mutate(payload),
|
|
||||||
submitForcedAttendee: () => {
|
|
||||||
if (pendingCapacityPayload) {
|
|
||||||
createAttendeeForceMutation.mutate({ ...pendingCapacityPayload })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
submitWaitlistEntry: () => {
|
|
||||||
if (pendingCapacityPayload) {
|
|
||||||
addToWaitlistMutation.mutate({ ...pendingCapacityPayload })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
requestBulkImport,
|
|
||||||
confirmBulkImportOverCapacity: () => {
|
|
||||||
setIsBulkCapacityModalOpen(false)
|
|
||||||
runBulkImport()
|
|
||||||
},
|
|
||||||
promoteEntry: (entry) => {
|
promoteEntry: (entry) => {
|
||||||
setSelectedWaitlistEntry(null)
|
setSelectedWaitlistEntry(null)
|
||||||
promoteWaitlistMutation.mutate(entry.id)
|
promoteWaitlistMutation.mutate(entry.id)
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import { Loader2 } from 'lucide-react'
|
import { Loader2 } from 'lucide-react'
|
||||||
import { Button } from '../../../components/ui'
|
import { Button } from '../../../components/ui'
|
||||||
import { AddAttendeeModal } from './AddAttendeeModal'
|
|
||||||
import { BulkCapacityModal } from './BulkCapacityModal'
|
|
||||||
import { CapacityModal } from './CapacityModal'
|
|
||||||
import { GroupHeader } from './GroupHeader'
|
import { GroupHeader } from './GroupHeader'
|
||||||
import { GroupInfoCard } from './GroupInfoCard'
|
import { GroupInfoCard } from './GroupInfoCard'
|
||||||
import { InviteLinkModal } from './InviteLinkModal'
|
import { InviteLinkModal } from './InviteLinkModal'
|
||||||
@@ -52,9 +49,6 @@ export function GroupDetailView() {
|
|||||||
<MembersWaitlistSection />
|
<MembersWaitlistSection />
|
||||||
|
|
||||||
<InviteLinkModal />
|
<InviteLinkModal />
|
||||||
<AddAttendeeModal />
|
|
||||||
<CapacityModal />
|
|
||||||
<BulkCapacityModal />
|
|
||||||
<RemoveAttendeeModal
|
<RemoveAttendeeModal
|
||||||
attendee={attendeeToRemove}
|
attendee={attendeeToRemove}
|
||||||
groupName={group?.name}
|
groupName={group?.name}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { RISK_LABELS } from '../constants'
|
|||||||
import { useGroupDetail } from './GroupDetailProvider'
|
import { useGroupDetail } from './GroupDetailProvider'
|
||||||
|
|
||||||
export function GroupHeader() {
|
export function GroupHeader() {
|
||||||
const { group, groupId, riskLevel, openInviteModal, openAddAttendeeModal } = useGroupDetail()
|
const { group, groupId, riskLevel, openInviteModal } = useGroupDetail()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const hasRisk = riskLevel === 'HIGH' || riskLevel === 'MEDIUM'
|
const hasRisk = riskLevel === 'HIGH' || riskLevel === 'MEDIUM'
|
||||||
|
|
||||||
@@ -39,13 +39,13 @@ export function GroupHeader() {
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid w-full grid-cols-3 gap-2 sm:flex sm:w-auto sm:flex-wrap sm:items-center sm:gap-2.5">
|
<div className="grid w-full grid-cols-2 gap-2 sm:flex sm:w-auto sm:flex-wrap sm:items-center sm:gap-2.5">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
void navigate({ to: '/groups/$groupId/analytics', params: { groupId } })
|
void navigate({ to: '/groups/$groupId/analytics', params: { groupId } })
|
||||||
}
|
}
|
||||||
className="w-full justify-center gap-1.5 border-border sm:w-auto"
|
className="w-full justify-center border-border sm:w-auto"
|
||||||
>
|
>
|
||||||
<BarChart3 className="size-4 text-accent" />
|
<BarChart3 className="size-4 text-accent" />
|
||||||
<span>Estadísticas</span>
|
<span>Estadísticas</span>
|
||||||
@@ -53,7 +53,7 @@ export function GroupHeader() {
|
|||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={openInviteModal}
|
onClick={openInviteModal}
|
||||||
className="w-full justify-center gap-1.5 border-border sm:w-auto"
|
className="w-full justify-center border-border sm:w-auto"
|
||||||
>
|
>
|
||||||
<Share2 className="size-4 text-accent" />
|
<Share2 className="size-4 text-accent" />
|
||||||
<span>
|
<span>
|
||||||
@@ -62,8 +62,10 @@ export function GroupHeader() {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
onClick={openAddAttendeeModal}
|
onClick={() =>
|
||||||
className="w-full justify-center gap-1.5 sm:w-auto"
|
void navigate({ to: '/groups/$groupId/attendees/new', params: { groupId } })
|
||||||
|
}
|
||||||
|
className="col-span-2 w-full justify-center sm:w-auto"
|
||||||
>
|
>
|
||||||
<UserPlus className="size-4" />
|
<UserPlus className="size-4" />
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import { Clock, Loader2, Plus, Search, Share2, Users } from 'lucide-react'
|
import { Clock, Loader2, Plus, Search, Share2, Users } from 'lucide-react'
|
||||||
import { Button, Input } from '../../../components/ui'
|
import { Button, Input } from '../../../components/ui'
|
||||||
import { cn } from '../../../lib/utils'
|
import { cn } from '../../../lib/utils'
|
||||||
@@ -7,6 +8,7 @@ import { WaitlistTable } from './WaitlistTable'
|
|||||||
|
|
||||||
export function MembersWaitlistSection() {
|
export function MembersWaitlistSection() {
|
||||||
const {
|
const {
|
||||||
|
groupId,
|
||||||
attendees,
|
attendees,
|
||||||
attendeesTotal,
|
attendeesTotal,
|
||||||
attendeesPending,
|
attendeesPending,
|
||||||
@@ -18,8 +20,8 @@ export function MembersWaitlistSection() {
|
|||||||
searchFilter,
|
searchFilter,
|
||||||
setSearchFilter,
|
setSearchFilter,
|
||||||
openInviteModal,
|
openInviteModal,
|
||||||
openAddAttendeeModal,
|
|
||||||
} = useGroupDetail()
|
} = useGroupDetail()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const query = searchFilter.toLowerCase()
|
const query = searchFilter.toLowerCase()
|
||||||
const filteredAttendees = attendees.filter(
|
const filteredAttendees = attendees.filter(
|
||||||
@@ -98,12 +100,24 @@ export function MembersWaitlistSection() {
|
|||||||
Puedes compartir el enlace de invitación único o agregar miembros de forma manual o
|
Puedes compartir el enlace de invitación único o agregar miembros de forma manual o
|
||||||
masiva.
|
masiva.
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-4 flex items-center justify-center gap-3">
|
<div className="mt-4 flex flex-col gap-2.5 sm:flex-row sm:items-center sm:justify-center sm:gap-3">
|
||||||
<Button variant="outline" size="sm" onClick={openInviteModal} className="gap-2">
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={openInviteModal}
|
||||||
|
className="w-full sm:w-auto"
|
||||||
|
>
|
||||||
<Share2 className="size-4" />
|
<Share2 className="size-4" />
|
||||||
Compartir Enlace
|
Compartir Enlace
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" size="sm" onClick={openAddAttendeeModal} className="gap-2">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="sm"
|
||||||
|
onClick={() =>
|
||||||
|
void navigate({ to: '/groups/$groupId/attendees/new', params: { groupId } })
|
||||||
|
}
|
||||||
|
className="w-full sm:w-auto"
|
||||||
|
>
|
||||||
<Plus className="size-4" />
|
<Plus className="size-4" />
|
||||||
Agregar Miembros
|
Agregar Miembros
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { Route as AuthenticatedClassSessionIdAttendanceRouteImport } from './rou
|
|||||||
import { Route as AuthenticatedGroupsGroupIdIndexRouteImport } from './routes/_authenticated/groups/$groupId/index'
|
import { Route as AuthenticatedGroupsGroupIdIndexRouteImport } from './routes/_authenticated/groups/$groupId/index'
|
||||||
import { Route as AuthenticatedGroupsGroupIdAnalyticsRouteImport } from './routes/_authenticated/groups/$groupId/analytics'
|
import { Route as AuthenticatedGroupsGroupIdAnalyticsRouteImport } from './routes/_authenticated/groups/$groupId/analytics'
|
||||||
import { Route as AuthenticatedGroupsGroupIdAttendeesAttendeeIdRouteImport } from './routes/_authenticated/groups/$groupId/attendees/$attendeeId'
|
import { Route as AuthenticatedGroupsGroupIdAttendeesAttendeeIdRouteImport } from './routes/_authenticated/groups/$groupId/attendees/$attendeeId'
|
||||||
|
import { Route as AuthenticatedGroupsGroupIdAttendeesNewRouteImport } from './routes/_authenticated/groups/$groupId/attendees/new'
|
||||||
|
|
||||||
const AuthenticatedRoute = AuthenticatedRouteImport.update({
|
const AuthenticatedRoute = AuthenticatedRouteImport.update({
|
||||||
id: '/_authenticated',
|
id: '/_authenticated',
|
||||||
@@ -122,6 +123,12 @@ const AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute =
|
|||||||
path: '/groups/$groupId/attendees/$attendeeId',
|
path: '/groups/$groupId/attendees/$attendeeId',
|
||||||
getParentRoute: () => AuthenticatedRoute,
|
getParentRoute: () => AuthenticatedRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AuthenticatedGroupsGroupIdAttendeesNewRoute =
|
||||||
|
AuthenticatedGroupsGroupIdAttendeesNewRouteImport.update({
|
||||||
|
id: '/groups/$groupId/attendees/new',
|
||||||
|
path: '/groups/$groupId/attendees/new',
|
||||||
|
getParentRoute: () => AuthenticatedRoute,
|
||||||
|
} as any)
|
||||||
|
|
||||||
export interface FileRoutesByFullPath {
|
export interface FileRoutesByFullPath {
|
||||||
'/': typeof AuthenticatedIndexRoute
|
'/': typeof AuthenticatedIndexRoute
|
||||||
@@ -141,6 +148,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||||
'/groups/$groupId/': typeof AuthenticatedGroupsGroupIdIndexRoute
|
'/groups/$groupId/': typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||||
'/groups/$groupId/attendees/$attendeeId': typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
'/groups/$groupId/attendees/$attendeeId': typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
||||||
|
'/groups/$groupId/attendees/new': typeof AuthenticatedGroupsGroupIdAttendeesNewRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
@@ -160,6 +168,7 @@ export interface FileRoutesByTo {
|
|||||||
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||||
'/groups/$groupId': typeof AuthenticatedGroupsGroupIdIndexRoute
|
'/groups/$groupId': typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||||
'/groups/$groupId/attendees/$attendeeId': typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
'/groups/$groupId/attendees/$attendeeId': typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
||||||
|
'/groups/$groupId/attendees/new': typeof AuthenticatedGroupsGroupIdAttendeesNewRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesById {
|
export interface FileRoutesById {
|
||||||
__root__: typeof rootRouteImport
|
__root__: typeof rootRouteImport
|
||||||
@@ -181,6 +190,7 @@ export interface FileRoutesById {
|
|||||||
'/_authenticated/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
'/_authenticated/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||||
'/_authenticated/groups/$groupId/': typeof AuthenticatedGroupsGroupIdIndexRoute
|
'/_authenticated/groups/$groupId/': typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||||
'/_authenticated/groups/$groupId/attendees/$attendeeId': typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
'/_authenticated/groups/$groupId/attendees/$attendeeId': typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
||||||
|
'/_authenticated/groups/$groupId/attendees/new': typeof AuthenticatedGroupsGroupIdAttendeesNewRoute
|
||||||
}
|
}
|
||||||
export interface FileRouteTypes {
|
export interface FileRouteTypes {
|
||||||
fileRoutesByFullPath: FileRoutesByFullPath
|
fileRoutesByFullPath: FileRoutesByFullPath
|
||||||
@@ -202,6 +212,7 @@ export interface FileRouteTypes {
|
|||||||
| '/groups/$groupId/analytics'
|
| '/groups/$groupId/analytics'
|
||||||
| '/groups/$groupId/'
|
| '/groups/$groupId/'
|
||||||
| '/groups/$groupId/attendees/$attendeeId'
|
| '/groups/$groupId/attendees/$attendeeId'
|
||||||
|
| '/groups/$groupId/attendees/new'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to:
|
to:
|
||||||
| '/login'
|
| '/login'
|
||||||
@@ -221,6 +232,7 @@ export interface FileRouteTypes {
|
|||||||
| '/groups/$groupId/analytics'
|
| '/groups/$groupId/analytics'
|
||||||
| '/groups/$groupId'
|
| '/groups/$groupId'
|
||||||
| '/groups/$groupId/attendees/$attendeeId'
|
| '/groups/$groupId/attendees/$attendeeId'
|
||||||
|
| '/groups/$groupId/attendees/new'
|
||||||
id:
|
id:
|
||||||
| '__root__'
|
| '__root__'
|
||||||
| '/_authenticated'
|
| '/_authenticated'
|
||||||
@@ -241,6 +253,7 @@ export interface FileRouteTypes {
|
|||||||
| '/_authenticated/groups/$groupId/analytics'
|
| '/_authenticated/groups/$groupId/analytics'
|
||||||
| '/_authenticated/groups/$groupId/'
|
| '/_authenticated/groups/$groupId/'
|
||||||
| '/_authenticated/groups/$groupId/attendees/$attendeeId'
|
| '/_authenticated/groups/$groupId/attendees/$attendeeId'
|
||||||
|
| '/_authenticated/groups/$groupId/attendees/new'
|
||||||
fileRoutesById: FileRoutesById
|
fileRoutesById: FileRoutesById
|
||||||
}
|
}
|
||||||
export interface RootRouteChildren {
|
export interface RootRouteChildren {
|
||||||
@@ -381,6 +394,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRouteImport
|
preLoaderRoute: typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRouteImport
|
||||||
parentRoute: typeof AuthenticatedRoute
|
parentRoute: typeof AuthenticatedRoute
|
||||||
}
|
}
|
||||||
|
'/_authenticated/groups/$groupId/attendees/new': {
|
||||||
|
id: '/_authenticated/groups/$groupId/attendees/new'
|
||||||
|
path: '/groups/$groupId/attendees/new'
|
||||||
|
fullPath: '/groups/$groupId/attendees/new'
|
||||||
|
preLoaderRoute: typeof AuthenticatedGroupsGroupIdAttendeesNewRouteImport
|
||||||
|
parentRoute: typeof AuthenticatedRoute
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +416,7 @@ interface AuthenticatedRouteChildren {
|
|||||||
AuthenticatedGroupsGroupIdAnalyticsRoute: typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
AuthenticatedGroupsGroupIdAnalyticsRoute: typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||||
AuthenticatedGroupsGroupIdIndexRoute: typeof AuthenticatedGroupsGroupIdIndexRoute
|
AuthenticatedGroupsGroupIdIndexRoute: typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||||
AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute: typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute: typeof AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute
|
||||||
|
AuthenticatedGroupsGroupIdAttendeesNewRoute: typeof AuthenticatedGroupsGroupIdAttendeesNewRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
||||||
@@ -413,6 +434,8 @@ const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
|||||||
AuthenticatedGroupsGroupIdIndexRoute: AuthenticatedGroupsGroupIdIndexRoute,
|
AuthenticatedGroupsGroupIdIndexRoute: AuthenticatedGroupsGroupIdIndexRoute,
|
||||||
AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute:
|
AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute:
|
||||||
AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute,
|
AuthenticatedGroupsGroupIdAttendeesAttendeeIdRoute,
|
||||||
|
AuthenticatedGroupsGroupIdAttendeesNewRoute:
|
||||||
|
AuthenticatedGroupsGroupIdAttendeesNewRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { useParams } from '@tanstack/react-router'
|
||||||
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
import { AddAttendeePage } from '../../../../../features/groups/add/AddAttendeePage'
|
||||||
|
import { AddAttendeeProvider } from '../../../../../features/groups/add/AddAttendeeProvider'
|
||||||
|
|
||||||
|
export const Route = createFileRoute('/_authenticated/groups/$groupId/attendees/new')({
|
||||||
|
component: () => {
|
||||||
|
const { groupId } = useParams({ from: '/_authenticated/groups/$groupId/attendees/new' })
|
||||||
|
return (
|
||||||
|
<AddAttendeeProvider groupId={groupId}>
|
||||||
|
<AddAttendeePage />
|
||||||
|
</AddAttendeeProvider>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user