import { getApiBaseUrl, getMemberToken } from '../../_lib/api'; import Link from 'next/link'; import { GroupOptOutButton } from './GroupOptOutButton'; interface MemberGroupSummary { id: string; name: string; tenantId: string; scopes: string[]; retentionDays: number; policyVersion: string; consentStatus: 'GRANTED' | 'REVOKED' | 'PENDING'; joinedAt: string; } async function fetchGroups(token: string): Promise { const res = await fetch(`${getApiBaseUrl()}/my/groups`, { headers: { Accept: 'application/json', Authorization: `Bearer ${token}` }, cache: 'no-store', }).catch(() => null); if (!res || !res.ok) return null; return (await res.json()) as MemberGroupSummary[]; } export default async function MyGroupsPage() { const token = await getMemberToken(); if (!token) { return (

Sign in required

Complete onboarding to view your groups.

); } const groups = await fetchGroups(token); if (!groups) { return (

Couldn't load your groups

Your session may have expired. Please try signing out and back in.

); } return (

Your groups

{groups.length === 0 ? (

You haven't joined any TOWER-managed groups yet.

) : ( )}
); }