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

This commit is contained in:
DanielS
2026-06-25 02:37:45 +02:00
parent b537ca50cf
commit 7cad819df8
3 changed files with 8 additions and 2 deletions

View File

@@ -286,6 +286,7 @@ export function UserDialog({ companies }: UserDialogProps) {
field.onChange(created.id)
setShowNewCompanyInput(false)
setNewCompanyName('')
router.refresh()
}
} catch (err) {
console.error('Failed to create company:', err)

View File

@@ -1,8 +1,9 @@
'use server'
import { createAdminClient } from '@/lib/supabase/admin'
import { revalidatePath } from 'next/cache'
import { revalidatePath, unstable_noStore as noStore } from 'next/cache'
export async function getCompanies() {
noStore()
const admin = createAdminClient()
const { data, error } = await admin.from('companies').select('*')
if (error) throw error
@@ -20,6 +21,7 @@ export async function createCompany(data: { name: string; street?: string; zip?:
}).select().single()
if (error) throw error
revalidatePath('/admin/companies')
revalidatePath('/admin/users')
return dbData
}
@@ -34,6 +36,7 @@ export async function updateCompany(id: string, data: { name: string; street?: s
}).eq('id', id).select().single()
if (error) throw error
revalidatePath('/admin/companies')
revalidatePath('/admin/users')
return dbData
}
@@ -42,6 +45,7 @@ export async function deleteCompany(id: string) {
const { error } = await admin.from('companies').delete().eq('id', id)
if (error) throw error
revalidatePath('/admin/companies')
revalidatePath('/admin/users')
return true
}

View File

@@ -1,10 +1,11 @@
'use server';
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';
export async function getUsers() {
noStore();
const admin = createAdminClient();
const { data: { users }, error } = await admin.auth.admin.listUsers();
if (error) throw error;