import { getMemberToken, getApiBaseUrl } from '../../_lib/api'; import { DeleteAccountButton } from './DeleteAccountButton'; import { MemberLogoutButton } from './MemberLogoutButton'; import { ProfileForm } from './ProfileForm'; import Link from 'next/link'; interface FullProfile { id: string; jid: string; displayName: string | null; avatar: string | null; hometown: string | null; currentLocation: string | null; interests: string[]; language: string; digestPreference: string; directoryVisible: boolean; createdAt: string; } interface GroupSummary { id: string; name: string; joinedAt: string; consentStatus: string; } async function fetchDashboard(token: string) { const res = await fetch(`${getApiBaseUrl()}/my/dashboard`, { headers: { Authorization: `Bearer ${token}` }, cache: 'no-store', }).catch(() => null); if (!res || !res.ok) return null; return res.json() as Promise<{ profile: FullProfile; groups: GroupSummary[] }>; } export default async function SettingsPage() { const token = await getMemberToken(); if (!token) { return (

Sign in required

Complete onboarding to manage your account.

); } const data = await fetchDashboard(token); return (

Profile & settings

← Dashboard
{/* Profile edit */}

Your profile

{data ? ( ) : (

Could not load profile data.

)}
{/* Privacy center — consent records */} {data && data.groups.length > 0 && (

Privacy center

You gave consent to receive messages from these groups. You can opt out at any time.

{data.groups.map((g) => (

{g.name}

Since {new Date(g.joinedAt).toLocaleDateString()} · {g.consentStatus === 'GRANTED' ? 'Active' : 'Revoked'}

{g.consentStatus === 'GRANTED' && (
)}
))}
)} {/* Session */}

Session

Sign out of your member portal. Your consent records are kept until you delete your account.

{/* Danger zone */}

Delete your account

This permanently deletes your TOWER user record, all consent records, opt-out history, and sessions. The messages themselves stay in their original groups. This cannot be undone.

); }