diff --git a/src/app/api/participants/[id]/route.ts b/src/app/api/participants/[id]/route.ts index 3dc79c5..2cc878f 100644 --- a/src/app/api/participants/[id]/route.ts +++ b/src/app/api/participants/[id]/route.ts @@ -4,15 +4,15 @@ import { auth } from "@clerk/nextjs/server"; import { db } from "~/db"; import { participants } from "~/db/schema"; -export async function DELETE(request: Request, { params }: { params: { id: string } }) { + +export async function DELETE(request: Request, { params }: any) { const { userId } = await auth(); if (!userId) { return new NextResponse("Unauthorized", { status: 401 }); } - const { id } = await params; - const participantId = parseInt(id); + const participantId = parseInt(params.id); try { const result = await db diff --git a/src/app/dashboard/participants/page.tsx b/src/app/dashboard/participants/page.tsx index a22c635..5dbab1d 100644 --- a/src/app/dashboard/participants/page.tsx +++ b/src/app/dashboard/participants/page.tsx @@ -1,18 +1,24 @@ 'use client'; +import { PlusIcon, Trash2Icon } from "lucide-react"; import { useEffect, useState } from "react"; import { Button } from "~/components/ui/button"; -import { Card, CardHeader, CardTitle, CardContent } from "~/components/ui/card"; +import { + Card, + CardContent, + CardHeader, + CardTitle, + CardDescription, + CardFooter +} from "~/components/ui/card"; import { Input } from "~/components/ui/input"; import { Label } from "~/components/ui/label"; -import { PlusIcon, Trash2Icon } from "lucide-react"; import { Select, - SelectTrigger, - SelectValue, SelectContent, SelectItem, - SelectLabel, + SelectTrigger, + SelectValue } from "~/components/ui/select"; interface Study { @@ -51,7 +57,13 @@ export default function Participants() { const fetchParticipants = async (studyId: number) => { try { + console.log(`Fetching participants for studyId: ${studyId}`); const response = await fetch(`/api/participants?studyId=${studyId}`); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); setParticipants(data); } catch (error) { @@ -115,26 +127,42 @@ export default function Participants() { return (
+ No participants found for this study. Add one above to get started. +
++ Please select a study to view its participants. +
+