diff --git a/sites/mainweb/app/(portal)/admin/page.tsx b/sites/mainweb/app/(portal)/admin/page.tsx index 62699d1..5e47bfd 100644 --- a/sites/mainweb/app/(portal)/admin/page.tsx +++ b/sites/mainweb/app/(portal)/admin/page.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useSession, signOut } from 'next-auth/react'; +import { useSession } from 'next-auth/react'; import { trpc } from '@/lib/trpc'; import { useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; @@ -8,6 +8,8 @@ import Background from '@/components/portal/Background'; import QRCode from 'qrcode'; import Link from 'next/link'; import { LiquidGlass } from '@/components/portal/LiquidGlass'; +import { QRCodeModal } from '@/components/portal/QRCodeModal'; +import { EventFormModal } from '@/components/portal/EventFormModal'; type AdminView = 'events' | 'members' | 'admins'; @@ -34,14 +36,7 @@ export default function AdminPage() { const [qrCodeDataURL, setQrCodeDataURL] = useState(''); const [selectedEvent, setSelectedEvent] = useState(null); - // Event form state - const [eventForm, setEventForm] = useState({ - title: '', - description: '', - location: '', - eventDate: '', - maxCheckIns: '', - }); + // Queries const { data: adminStatus, isLoading: adminLoading } = trpc.admin.isAdmin.useQuery(undefined, { @@ -55,13 +50,6 @@ export default function AdminPage() { const createEventMutation = trpc.events.create.useMutation({ onSuccess: (newEvent) => { if (newEvent) { - setEventForm({ - title: '', - description: '', - location: '', - eventDate: '', - maxCheckIns: '', - }); setShowCreateEvent(false); generateQRCode(newEvent.qrCode); setSelectedEvent(newEvent as unknown as Event); @@ -69,6 +57,7 @@ export default function AdminPage() { }, }); + const toggleCheckInMutation = trpc.events.toggleCheckIn.useMutation({ onSuccess: () => { utils.events.listAll.invalidate(); @@ -104,10 +93,10 @@ export default function AdminPage() { try { const url = await QRCode.toDataURL(qrCode, { width: 400, - margin: 2, + margin: 3, color: { - dark: '#00A8A8', - light: '#0a0a0a', + dark: '#000000', + light: '#ffffff', }, }); setQrCodeDataURL(url); @@ -117,13 +106,13 @@ export default function AdminPage() { } }; - const handleCreateEvent = () => { + const handleCreateEvent = (formData: { title: string; description: string; location: string; eventDate: string }) => { createEventMutation.mutate({ - title: eventForm.title, - description: eventForm.description || undefined, - location: eventForm.location || undefined, - eventDate: new Date(eventForm.eventDate), - maxCheckIns: eventForm.maxCheckIns ? parseInt(eventForm.maxCheckIns) : undefined, + title: formData.title, + description: formData.description || undefined, + location: formData.location || undefined, + eventDate: new Date(formData.eventDate), + maxCheckIns: undefined, // Always unlimited }); }; @@ -150,195 +139,23 @@ export default function AdminPage() { {/* CREATE EVENT MODAL */} {showCreateEvent && ( -
-
setShowCreateEvent(false)} - /> -
-
-
-

- Create Event -

-

- Configure QR Protocols -

-
- -
- -
-
- - setEventForm({ ...eventForm, title: e.target.value })} - className="w-full bg-black/40 border border-white/10 rounded-xl px-6 py-4 text-white text-base focus:border-[#00A8A8] focus:outline-none transition-all font-mono" - placeholder="e.g., Weekly_Workshop_01" - /> -
- -
- -