- Add API endpoints for managing group pre-registrations, including approval and rejection. - Create database migration for `group_pre_registrations` table and associated enum for status. - Implement use cases for listing, approving, and rejecting pre-registrations. - Add frontend components for displaying pre-registration details and managing approvals/rejections. - Update shared schemas to include pre-registration data structures and validation. - Remove obsolete `WaitlistNoticeCard` component and replace with `PreRegistrationNoticeCard`.
117 lines
4.7 KiB
TypeScript
117 lines
4.7 KiB
TypeScript
import { Copy, Loader2, MessageCircle, RefreshCw } from 'lucide-react'
|
|
import { Button, Input, Label, Modal } from '../../../components/ui'
|
|
import { cn } from '../../../lib/utils'
|
|
import { useGroupDetail } from './GroupDetailProvider'
|
|
|
|
export function InviteLinkModal() {
|
|
const {
|
|
isInviteModalOpen,
|
|
closeInviteModal,
|
|
group,
|
|
inviteUrl,
|
|
invitePending,
|
|
isRegeneratingInvite,
|
|
regenerateInvite,
|
|
copyInviteLink,
|
|
copyWhatsappMessage,
|
|
openWhatsapp,
|
|
} = useGroupDetail()
|
|
|
|
return (
|
|
<Modal
|
|
isOpen={isInviteModalOpen}
|
|
onClose={closeInviteModal}
|
|
title="Compartir Link de Invitación"
|
|
description="Envía este enlace a tus miembros para que completen sus datos e ingresen directamente al grupo."
|
|
maxWidth="md"
|
|
>
|
|
<div className="space-y-5">
|
|
{invitePending ? (
|
|
<div className="flex items-center justify-center py-6">
|
|
<Loader2 className="size-6 animate-spin text-accent" />
|
|
</div>
|
|
) : (
|
|
<>
|
|
<div>
|
|
<Label htmlFor="invite-link-input" className="mb-1.5 block">
|
|
Enlace único del grupo
|
|
</Label>
|
|
<div className="flex items-center gap-2">
|
|
<Input
|
|
id="invite-link-input"
|
|
readOnly
|
|
value={inviteUrl ?? ''}
|
|
className="select-text bg-primary-soft/50 font-mono text-xs"
|
|
/>
|
|
<Button
|
|
variant="outline"
|
|
onClick={() => void copyInviteLink()}
|
|
className="shrink-0 gap-1.5 px-3"
|
|
title="Copiar al portapapeles"
|
|
>
|
|
<Copy className="size-4" />
|
|
<span>Copiar</span>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="space-y-2.5 rounded-xl border border-accent/20 bg-accent-soft p-4 text-xs text-foreground/80">
|
|
<div className="flex items-center justify-between gap-2">
|
|
<p className="font-semibold text-primary">Vista previa del mensaje para WhatsApp:</p>
|
|
<Button
|
|
type="button"
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={() => void copyWhatsappMessage()}
|
|
className="h-7 shrink-0 gap-1.5 px-2 text-xs text-primary hover:text-primary/80"
|
|
title="Copiar mensaje completo al portapapeles"
|
|
>
|
|
<Copy className="size-3.5" />
|
|
<span>Copiar mensaje</span>
|
|
</Button>
|
|
</div>
|
|
<div className="whitespace-pre-line rounded-lg border border-accent/10 bg-surface/70 p-3 font-sans text-xs leading-relaxed text-foreground">
|
|
{`¡Hola! 👋 Te invito a unirte al grupo `}
|
|
<strong>{group?.name}</strong>.
|
|
{'\n\n'}
|
|
Completa tu pre-inscripción en el siguiente enlace. El profesor revisará tu solicitud:
|
|
{'\n'}
|
|
<span className="break-all text-accent underline">{inviteUrl}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col items-center gap-2.5 pt-2 sm:flex-row">
|
|
<Button
|
|
variant="primary"
|
|
onClick={() => void openWhatsapp()}
|
|
className="w-full gap-2 border-0 bg-[#25D366] text-white hover:bg-[#1EBE5D] sm:flex-1"
|
|
>
|
|
<MessageCircle className="size-4" />
|
|
<span>Abrir en WhatsApp</span>
|
|
</Button>
|
|
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={regenerateInvite}
|
|
disabled={isRegeneratingInvite}
|
|
className="w-full gap-1.5 text-xs text-foreground/60 hover:text-danger sm:w-auto"
|
|
title="Invalida el enlace anterior y genera uno nuevo"
|
|
>
|
|
<RefreshCw className={cn('size-3.5', isRegeneratingInvite && 'animate-spin')} />
|
|
<span>Regenerar enlace</span>
|
|
</Button>
|
|
</div>
|
|
|
|
<p className="text-center text-[11px] font-normal leading-normal text-foreground/50 sm:text-left">
|
|
Al hacer clic en <strong>Abrir en WhatsApp</strong>, el mensaje completo se copia
|
|
automáticamente al portapapeles. Si WhatsApp Web solo carga el enlace, podés pegarlo
|
|
directamente con <kbd className="rounded bg-primary-soft px-1 py-0.5 font-mono text-[10px] text-primary">Ctrl+V</kbd>{' '}
|
|
o <kbd className="rounded bg-primary-soft px-1 py-0.5 font-mono text-[10px] text-primary">Cmd+V</kbd>.
|
|
</p>
|
|
</>
|
|
)}
|
|
</div>
|
|
</Modal>
|
|
)
|
|
} |