feat: list end customers in companies admin and improve dark/light mode contrast across all admin components
All checks were successful
Staging Build / build (push) Successful in 2m36s

This commit is contained in:
DanielS
2026-06-25 02:11:07 +02:00
parent bf27c62f62
commit ef9422908d
11 changed files with 222 additions and 240 deletions

View File

@@ -231,38 +231,3 @@ export async function updateUserProfile(id: string, data: { first_name: string |
revalidatePath('/admin/users');
}
export async function getUsersByCompany(companyId: string) {
const admin = createAdminClient();
const { data: dbUsers, error: dbError } = await admin
.from('users')
.select('id, role')
.eq('company_id', companyId);
if (dbError) throw dbError;
if (dbUsers.length === 0) return [];
const { data: { users }, error } = await admin.auth.admin.listUsers();
if (error) throw error;
const authUserMap = new Map(users.map((u) => [u.id, u]));
const userIds = dbUsers.map((u) => u.id);
const { data: dbProfiles } = await admin
.from('profiles')
.select('id, first_name, last_name')
.in('id', userIds);
const profileMap = new Map((dbProfiles || []).map((p) => [p.id, p]));
return dbUsers.map((u) => {
const authUser = authUserMap.get(u.id);
const profile = profileMap.get(u.id);
return {
id: u.id,
email: authUser?.email || '',
role: u.role,
first_name: profile?.first_name || '',
last_name: profile?.last_name || '',
};
});
}