diff --git a/src/app/dashboard/settings/users/[id]/page.tsx b/src/app/dashboard/settings/users/[id]/page.tsx index 4f6e7d2..050b505 100644 --- a/src/app/dashboard/settings/users/[id]/page.tsx +++ b/src/app/dashboard/settings/users/[id]/page.tsx @@ -1,10 +1,12 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { EditUserForm } from "./edit-user-form" import { createClient } from "@/lib/supabase/server" +import { createAdminClient } from "@/lib/supabase/admin" import { notFound } from "next/navigation" export default async function EditUserPage({ params }: { params: { id: string } }) { const supabase = await createClient() + const supabaseAdmin = await createAdminClient() // Fetch profile const { data: profile } = await supabase @@ -17,8 +19,14 @@ export default async function EditUserPage({ params }: { params: { id: string } notFound() } - // We can't easily get email from profiles if it's not stored there. - // But for editing, we mostly care about name and role. + // Fetch email from auth.users using admin client + let email = undefined + if (supabaseAdmin) { + const { data: { user }, error } = await supabaseAdmin.auth.admin.getUserById(params.id) + if (user) { + email = user.email + } + } return (