fix: ensure AI provider config is saved correctly in admin
URGENT FIX: Admin form was not properly saving AI provider configuration, causing 'AI_PROVIDER_TAGS is not configured' error even after setting OpenAI. Changes: - admin-settings-form.tsx: Added validation and error handling - admin-settings.ts: Filter empty values before saving to DB - setup-openai.ts: Script to initialize OpenAI as default provider This fixes the critical bug where users couldn't use the app after configuring OpenAI in the admin interface. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,16 +39,23 @@ export async function getSystemConfig() {
|
||||
|
||||
export async function updateSystemConfig(data: Record<string, string>) {
|
||||
await checkAdmin()
|
||||
|
||||
|
||||
try {
|
||||
const operations = Object.entries(data).map(([key, value]) =>
|
||||
// Filter out empty values but keep 'false' as valid
|
||||
const filteredData = Object.fromEntries(
|
||||
Object.entries(data).filter(([key, value]) => value !== '' && value !== null && value !== undefined)
|
||||
)
|
||||
|
||||
console.log('Updating system config:', filteredData)
|
||||
|
||||
const operations = Object.entries(filteredData).map(([key, value]) =>
|
||||
prisma.systemConfig.upsert({
|
||||
where: { key },
|
||||
update: { value },
|
||||
create: { key, value }
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
await prisma.$transaction(operations)
|
||||
revalidatePath('/admin/settings')
|
||||
return { success: true }
|
||||
|
||||
Reference in New Issue
Block a user