feat: add document bucket auto-creation, extension defaults, and chat widget on dashboard

Auto-create documents storage bucket on first upload. Default legacy general
extensions to enabled when no toggle row exists. Add ChatWidget to dashboard
root page with open-ai-chat event support and AI assistant quick action.
Add ensureInitialized to supplier invoices route for event emission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Emil
2026-02-23 13:00:16 +01:00
co-authored by Claude Opus 4.6
parent 263c229903
commit ce66a21010
8 changed files with 86 additions and 7 deletions
@@ -1,6 +1,15 @@
import { createClient } from '@/lib/supabase/server'
import { NextResponse } from 'next/server'
// Legacy general extensions default to enabled when no toggle row exists
const LEGACY_GENERAL_EXTENSIONS = [
'receipt-ocr',
'ai-categorization',
'ai-chat',
'push-notifications',
'enable-banking',
]
export async function GET(
_request: Request,
{ params }: { params: Promise<{ sector: string; slug: string }> }
@@ -21,7 +30,14 @@ export async function GET(
.eq('extension_slug', slug)
.single()
return NextResponse.json({ data: data ?? { enabled: false } })
if (data) {
return NextResponse.json({ data })
}
// No toggle row: legacy general extensions default to enabled
const defaultEnabled =
sector === 'general' && LEGACY_GENERAL_EXTENSIONS.includes(slug)
return NextResponse.json({ data: { enabled: defaultEnabled } })
}
export async function DELETE(
@@ -12,6 +12,10 @@ vi.mock('@/lib/supabase/server', () => ({
createClient: () => Promise.resolve(mockSupabase),
}))
vi.mock('@/lib/init', () => ({
ensureInitialized: vi.fn(),
}))
const mockFindFiscalPeriod = vi.fn()
vi.mock('@/lib/bookkeeping/engine', () => ({
findFiscalPeriod: (...args: unknown[]) => mockFindFiscalPeriod(...args),
+3
View File
@@ -1,8 +1,11 @@
import { createClient } from '@/lib/supabase/server'
import { NextResponse } from 'next/server'
import { createSupplierInvoiceRegistrationEntry } from '@/lib/bookkeeping/supplier-invoice-entries'
import { ensureInitialized } from '@/lib/init'
import type { CreateSupplierInvoiceInput, SupplierInvoice, SupplierInvoiceItem } from '@/types'
ensureInitialized()
export async function GET(request: Request) {
const supabase = await createClient()