import Link from 'next/link'; import { createClient } from '@supabase/supabase-js'; import { UserCircle, FileText, CreditCard, Shield } from 'lucide-react'; import { getTranslations } from 'next-intl/server'; import { PortalLoginForm } from '@kit/site-builder/components'; import { Button } from '@kit/ui/button'; import { Card, CardContent } from '@kit/ui/card'; interface Props { params: Promise<{ slug: string }>; } export default async function MemberPortalPage({ params }: Props) { const { slug } = await params; const t = await getTranslations('portal'); const supabase = createClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_KEY!, ); const { data: account } = await supabase .from('accounts') .select('id, name') .eq('slug', slug) .single(); if (!account) return
{t('home.orgNotFound')}
; // Check if user is already logged in const { data: { user }, } = await supabase.auth.getUser(); if (user) { // Check if this user is a member of this club const { data: member } = await supabase .from('members') .select('id, first_name, last_name, status') .eq('account_id', account.id) .eq('user_id', user.id) .maybeSingle(); if (member) { // Logged in member — show portal dashboard return (

{t('home.membersArea')} — {String(account.name)}

{String(member.first_name)} {String(member.last_name)}

{t('home.welcomeUser', { name: String(member.first_name) })}

{t('home.profile')}

{t('home.profileDesc')}

{t('home.documents')}

{t('home.documentsDesc')}

{t('home.memberCard')}

{t('home.memberCardDesc')}

); } } // Not logged in or not a member — show login form return (

{t('home.membersArea')}

); }