import { createServerComponentClient } from "@supabase/auth-helpers-nextjs"; import { Database } from "@/types/supabase"; import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import prisma from "@/lib/prisma"; import { CheckIcon } from "lucide-react"; async function getSession(supabase: any) { const { data: { session }, } = await supabase.auth.getSession(); return session; } async function fetchFeatures(projectID: string) { const supabase = createServerComponentClient({ cookies }); const session = await getSession(supabase); if (!session) redirect("/auth"); try { // prisma function to get project by projectID if user is part of the project const features = await prisma.feature.findMany({ where: { project_id: BigInt(projectID), }, }); return features; } catch (err) { console.error(err); } } export async function FeatureList({ projectID }: { projectID: string }) { const features = await fetchFeatures(projectID); return (
{features?.map((feature) => (

{feature.name}

{feature.description}

))}
); }