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
All checks were successful
Staging Build / build (push) Successful in 2m36s
This commit is contained in:
@@ -52,3 +52,27 @@ export async function assignCompanyToUser(userId: string, companyId: string | nu
|
||||
revalidatePath('/admin/users')
|
||||
return true
|
||||
}
|
||||
|
||||
export async function getEndCustomersByCompany(companyId: string) {
|
||||
const admin = createAdminClient()
|
||||
|
||||
// 1. Get all partners of this company
|
||||
const { data: partners, error: partnersError } = await admin
|
||||
.from('users')
|
||||
.select('id')
|
||||
.eq('company_id', companyId)
|
||||
if (partnersError) throw partnersError
|
||||
|
||||
if (!partners || partners.length === 0) return []
|
||||
|
||||
const partnerIds = partners.map((p) => p.id)
|
||||
|
||||
// 2. Get all end customers belonging to these partners
|
||||
const { data: customers, error: customersError } = await admin
|
||||
.from('end_customers')
|
||||
.select('*')
|
||||
.in('partner_id', partnerIds)
|
||||
if (customersError) throw customersError
|
||||
|
||||
return customers || []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user