fix: Invalidate user list cache on company creation and refresh page on popup creation
All checks were successful
Staging Build / build (push) Successful in 2m44s
All checks were successful
Staging Build / build (push) Successful in 2m44s
This commit is contained in:
@@ -286,6 +286,7 @@ export function UserDialog({ companies }: UserDialogProps) {
|
|||||||
field.onChange(created.id)
|
field.onChange(created.id)
|
||||||
setShowNewCompanyInput(false)
|
setShowNewCompanyInput(false)
|
||||||
setNewCompanyName('')
|
setNewCompanyName('')
|
||||||
|
router.refresh()
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to create company:', err)
|
console.error('Failed to create company:', err)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
'use server'
|
'use server'
|
||||||
import { createAdminClient } from '@/lib/supabase/admin'
|
import { createAdminClient } from '@/lib/supabase/admin'
|
||||||
import { revalidatePath } from 'next/cache'
|
import { revalidatePath, unstable_noStore as noStore } from 'next/cache'
|
||||||
|
|
||||||
export async function getCompanies() {
|
export async function getCompanies() {
|
||||||
|
noStore()
|
||||||
const admin = createAdminClient()
|
const admin = createAdminClient()
|
||||||
const { data, error } = await admin.from('companies').select('*')
|
const { data, error } = await admin.from('companies').select('*')
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
@@ -20,6 +21,7 @@ export async function createCompany(data: { name: string; street?: string; zip?:
|
|||||||
}).select().single()
|
}).select().single()
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
revalidatePath('/admin/companies')
|
revalidatePath('/admin/companies')
|
||||||
|
revalidatePath('/admin/users')
|
||||||
return dbData
|
return dbData
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +36,7 @@ export async function updateCompany(id: string, data: { name: string; street?: s
|
|||||||
}).eq('id', id).select().single()
|
}).eq('id', id).select().single()
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
revalidatePath('/admin/companies')
|
revalidatePath('/admin/companies')
|
||||||
|
revalidatePath('/admin/users')
|
||||||
return dbData
|
return dbData
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +45,7 @@ export async function deleteCompany(id: string) {
|
|||||||
const { error } = await admin.from('companies').delete().eq('id', id)
|
const { error } = await admin.from('companies').delete().eq('id', id)
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
revalidatePath('/admin/companies')
|
revalidatePath('/admin/companies')
|
||||||
|
revalidatePath('/admin/users')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
'use server';
|
'use server';
|
||||||
|
|
||||||
import { createAdminClient } from '@/lib/supabase/admin';
|
import { createAdminClient } from '@/lib/supabase/admin';
|
||||||
import { revalidatePath } from 'next/cache';
|
import { revalidatePath, unstable_noStore as noStore } from 'next/cache';
|
||||||
import { sendMail } from '@/utils/mail';
|
import { sendMail } from '@/utils/mail';
|
||||||
|
|
||||||
export async function getUsers() {
|
export async function getUsers() {
|
||||||
|
noStore();
|
||||||
const admin = createAdminClient();
|
const admin = createAdminClient();
|
||||||
const { data: { users }, error } = await admin.auth.admin.listUsers();
|
const { data: { users }, error } = await admin.auth.admin.listUsers();
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user