managing rsvps

This commit is contained in:
briannelson95
2025-06-28 20:23:22 -04:00
parent dee9066c91
commit 28efa115ad
19 changed files with 568 additions and 197 deletions

View File

@@ -1,3 +1,7 @@
import AddFirstGuestBookEntryClient from '@/components/AddFirstGuestBookEntryClient'
import AddGuestBookEntryModal from '@/components/AddGuestBookEntryModal'
import CreateEventClient from '@/components/CreateEventClient'
import DashboardNavbar from '@/components/DashboardNavbar'
import EventInfoQuickView from '@/components/EventInfoQuickView'
import GuestBookQuickView from '@/components/GuestBookQuickView'
import { prisma } from '@/lib/prisma'
@@ -9,32 +13,21 @@ import React from 'react'
export default async function DashboardPage() {
const events = await queries.fetchEvents();
const guestBookEntries = await queries.fetchGuestBookEntries(5);
const session = await getServerSession()
const session = await getServerSession();
const user = await prisma.user.findUnique({
where: { email: session?.user.email }
})
// console.log(events)
return (
<div className='max-w-[100rem] mx-auto'>
<div className='grid grid-cols-5 grid-rows-5 gap-4'>
<div className='row-span-5 bg-[#00000008] rounded-xl p-6'>
<div className='py-4'>
<h2 className='text-lg font-semibold'>Hello, {user?.username}</h2>
</div>
<div className='bg-brand-primary-800 p-4 rounded-lg'>Overview</div>
</div>
<div className='col-span-3 row-span-3 bg-[#00000008] rounded-xl p-6 relative'>
<div className='grid grid-cols-7 gap-4'>
<div className='col-span-5 row-span-3 bg-[#00000008] rounded-xl p-6 relative'>
<div>
<div className='w-full flex items-center justify-between'>
<h2 className='text-lg font-semibold py-4'>Your Events</h2>
<button
className='btn btn-primary h-fit'
>
Create Event
</button>
<CreateEventClient />
</div>
{!events.length && <>You don&apos;t have any events yet. Create your first event.</>}
<div className='grid grid-cols-3'>
{events.map((item) => (
<EventInfoQuickView key={item.id} {...item} />
@@ -45,7 +38,7 @@ export default async function DashboardPage() {
View all
</Link>
</div>
<div className='row-span-5 col-start-5 bg-[#00000008] rounded-xl p-6'>
<div className='row-span-5 col-start-6 col-span-2 bg-[#00000008] rounded-xl p-6'>
<div className='py-4 flex justify-between'>
<h2 className='text-lg font-semibold'>Guest Book</h2>
<Link
@@ -56,34 +49,12 @@ export default async function DashboardPage() {
</Link>
</div>
<div className='space-y-2'>
{!guestBookEntries.length && <AddFirstGuestBookEntryClient />}
{guestBookEntries.map(entry => (
<GuestBookQuickView key={entry.id} {...entry} />
))}
</div>
</div>
</div>
{/* <div className='border rounded-lg max-w-6xl mx-auto p-6 space-y-4'>
<h2 className='text-xl font-bold'>Your Events</h2>
{events.map((item) => (
<Link key={item.id} href={`/events/${item.id}`} >
<div className='hover:cursor-pointer border rounded-xl p-2'>
<p>ID: {item.id}</p>
<p>Name: <strong>{item.name}</strong></p>
<p>Date: {item.date ? item.date.toISOString() : 'null'}</p>
<p>Location: {item.location ? item.location : 'null'}</p>
<p>Created By: {item.creator.username}</p>
<p>Created At: {item.createdAt.toISOString()}</p>
</div>
</Link>
))}
<Link
href={'/events'}
className='underline'
>
See all events
</Link>
</div> */}
</div>
)
}

View File

@@ -9,16 +9,13 @@ export default async function SingleEventPage({ params }: { params: { eventId: s
console.log(data)
return (
<div>
<div className='max-w-[100rem] mx-auto'>
{data ? (
// @ts-ignore
<EventInfoDisplay event={data} />
) : (
<p className="text-center text-gray-500 mt-10">Event not found.</p>
)}
{data?.name && (
<HeadingWithEdit title={data?.name} eventId={data.id} />
)}
</div>
)
}

View File

@@ -1,32 +0,0 @@
'use client'
import { useState } from 'react';
import { useRouter } from 'next/navigation';
export default function CreateEventPage() {
const [name, setName] = useState('');
const router = useRouter();
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
const res = await fetch('/api/events', {
method: 'POST',
body: JSON.stringify({ name }),
});
const data = await res.json();
router.push(`/events/${data.id}`);
}
return (
<form onSubmit={handleSubmit} className="max-w-md space-y-4">
<h2 className="text-xl font-bold">Create Event</h2>
<input
type="text"
placeholder="Event Name"
className="input input-bordered w-full"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<button className="btn btn-primary">Create</button>
</form>
);
}

View File

@@ -1,19 +1,22 @@
'use client'
import { SessionProvider, useSession } from 'next-auth/react'
import { SessionProvider } from 'next-auth/react'
import { redirect } from 'next/navigation'
import { ReactNode } from 'react'
import Navbar from '@/components/Navbar'
import DashboardNavbar from '@/components/DashboardNavbar'
export default function AuthLayout({ children }: { children: ReactNode }) {
return (
<>
<SessionProvider>
<Navbar />
<main className="p-4">
{/* Could also add a private header here */}
{children}
<main className="p-4 max-w-[100rem] mx-auto">
<div className='grid grid-cols-5 gap-4'>
<DashboardNavbar />
<section className="col-span-4">
{children}
</section>
</div>
</main>
</SessionProvider>
</>