From b3433149310c437c8d141441d73118787f0497a2 Mon Sep 17 00:00:00 2001 From: zias Date: Mon, 2 Mar 2026 16:42:15 +0100 Subject: [PATCH] feat:admin --- apps/web/package.json | 1 + .../homepage/EventRegistrationForm.tsx | 39 +- apps/web/src/components/homepage/Footer.tsx | 25 + apps/web/src/routeTree.gen.ts | 42 +- apps/web/src/routes/admin.tsx | 463 ++++++++++++++++++ apps/web/src/routes/login.tsx | 272 ++++++++++ bun.lock | 1 + packages/api/package.json | 1 + packages/api/src/index.ts | 16 + packages/api/src/routers/index.ts | 302 +++++++++++- packages/auth/src/index.ts | 8 + packages/db/local.db-shm | Bin 32768 -> 32768 bytes packages/db/local.db-wal | Bin 0 -> 247232 bytes packages/db/package.json | 7 + packages/db/src/schema/admin-requests.ts | 23 + packages/db/src/schema/auth.ts | 1 + packages/db/src/schema/index.ts | 2 + packages/db/src/schema/registrations.ts | 23 + turbo.json | 3 +- 19 files changed, 1221 insertions(+), 8 deletions(-) create mode 100644 apps/web/src/routes/admin.tsx create mode 100644 apps/web/src/routes/login.tsx create mode 100644 packages/db/src/schema/admin-requests.ts create mode 100644 packages/db/src/schema/registrations.ts diff --git a/apps/web/package.json b/apps/web/package.json index c248634..f592c65 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -5,6 +5,7 @@ "scripts": { "build": "vite build", "serve": "vite preview", + "dev": "vite dev", "dev:bare": "vite dev" }, "dependencies": { diff --git a/apps/web/src/components/homepage/EventRegistrationForm.tsx b/apps/web/src/components/homepage/EventRegistrationForm.tsx index 475e08c..18e22d6 100644 --- a/apps/web/src/components/homepage/EventRegistrationForm.tsx +++ b/apps/web/src/components/homepage/EventRegistrationForm.tsx @@ -1,6 +1,9 @@ "use client"; +import { useMutation } from "@tanstack/react-query"; import { useState } from "react"; +import { toast } from "sonner"; +import { orpc } from "@/utils/orpc"; export default function EventRegistrationForm() { const [formData, setFormData] = useState({ @@ -12,9 +15,34 @@ export default function EventRegistrationForm() { experience: "", }); + const submitMutation = useMutation({ + ...orpc.submitRegistration.mutationOptions(), + onSuccess: () => { + toast.success("Registratie succesvol!"); + setFormData({ + firstName: "", + lastName: "", + email: "", + phone: "", + artForm: "", + experience: "", + }); + }, + onError: (error) => { + toast.error(`Er is iets misgegaan: ${error.message}`); + }, + }); + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - console.log("Form submitted:", formData); + submitMutation.mutate({ + firstName: formData.firstName, + lastName: formData.lastName, + email: formData.email, + phone: formData.phone || undefined, + artForm: formData.artForm, + experience: formData.experience || undefined, + }); }; const handleChange = ( @@ -57,6 +85,7 @@ export default function EventRegistrationForm() { value={formData.firstName} onChange={handleChange} placeholder="Jouw voornaam" + required className="border-white/30 border-b bg-transparent pb-2 font-['Intro',sans-serif] text-lg text-white placeholder:text-white/40 focus:border-white focus:outline-none" /> @@ -75,6 +104,7 @@ export default function EventRegistrationForm() { value={formData.lastName} onChange={handleChange} placeholder="Jouw achternaam" + required className="border-white/30 border-b bg-transparent pb-2 font-['Intro',sans-serif] text-lg text-white placeholder:text-white/40 focus:border-white focus:outline-none" /> @@ -96,6 +126,7 @@ export default function EventRegistrationForm() { value={formData.email} onChange={handleChange} placeholder="jouw@email.nl" + required className="border-white/30 border-b bg-transparent pb-2 font-['Intro',sans-serif] text-lg text-white placeholder:text-white/40 focus:border-white focus:outline-none" /> @@ -134,6 +165,7 @@ export default function EventRegistrationForm() { value={formData.artForm} onChange={handleChange} placeholder="Muziek, Theater, Dans, etc." + required className="border-white/30 border-b bg-transparent pb-2 font-['Intro',sans-serif] text-lg text-white placeholder:text-white/40 focus:border-white focus:outline-none" /> @@ -164,9 +196,10 @@ export default function EventRegistrationForm() {

diff --git a/apps/web/src/components/homepage/Footer.tsx b/apps/web/src/components/homepage/Footer.tsx index 740096e..26ed7ff 100644 --- a/apps/web/src/components/homepage/Footer.tsx +++ b/apps/web/src/components/homepage/Footer.tsx @@ -1,4 +1,21 @@ +"use client"; + +import { Link } from "@tanstack/react-router"; +import { useEffect, useState } from "react"; +import { authClient } from "@/lib/auth-client"; + export default function Footer() { + const [isAdmin, setIsAdmin] = useState(false); + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + authClient.getSession().then((session) => { + const user = session.data?.user as { role?: string } | undefined; + setIsAdmin(user?.role === "admin"); + setIsLoading(false); + }); + }, []); + return (