import { createAdminClient } from '@/lib/supabase/admin'; import { User } from '@supabase/supabase-js'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; // I might need to install badge, but I'll check/skip for now or use plain HTML export default async function UsersPage() { // We need to handle the case where SERVICE_ROLE_KEY is missing gracefully-ish or just fail let users: User[] = []; let errorMsg = ''; try { if (!process.env.SUPABASE_SERVICE_ROLE_KEY) { throw new Error("SUPABASE_SERVICE_ROLE_KEY is missing in .env.local"); } const supabase = createAdminClient(); const { data, error } = await supabase.auth.admin.listUsers(); if (error) throw error; users = data.users || []; } catch (e: any) { console.error("Error fetching users:", e); errorMsg = e.message; } return (

Users

User List {errorMsg ? (
Error: {errorMsg}.
Make sure SUPABASE_SERVICE_ROLE_KEY is set in .env.local
) : ( Email Created At Last Sign In Status {users.map((user) => ( {user.email} {new Date(user.created_at).toLocaleDateString()} {user.last_sign_in_at ? new Date(user.last_sign_in_at).toLocaleDateString() : 'Never'} {user.confirmed_at ? ( Confirmed ) : ( Pending )} ))} {users.length === 0 && ( No users found. )}
)}
); }