Fix companies actions, add assignCompanyToUser, cleanup duplicates
All checks were successful
Staging Build / build (push) Successful in 2m41s
All checks were successful
Staging Build / build (push) Successful in 2m41s
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
'use server'
|
||||||
import { createAdminClient } from '@/lib/supabase/admin'
|
import { createAdminClient } from '@/lib/supabase/admin'
|
||||||
import { revalidatePath } from 'next/cache'
|
import { revalidatePath } from 'next/cache'
|
||||||
|
|
||||||
@@ -31,3 +32,11 @@ export async function deleteCompany(id: string) {
|
|||||||
revalidatePath('/admin/companies')
|
revalidatePath('/admin/companies')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function assignCompanyToUser(userId: string, companyId: string | null) {
|
||||||
|
const admin = createAdminClient()
|
||||||
|
const { error } = await admin.from('users').update({ company_id: companyId }).eq('id', userId)
|
||||||
|
if (error) throw error
|
||||||
|
revalidatePath('/admin/users')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user