29240738fa
- Fix VAT declaration ruta mappings to match SKV 4700 form correctly (ruta 05 = total taxable sales, ruta 10/11/12 = output VAT per rate) - Add INK2 declaration report for aktiebolag with SRU export - Add full archive ZIP export for 7-year retention compliance - Add AI consent gate requiring user approval before AI extension API calls - Add DPA and privacy policy public pages - Add audit trail API routes - Update VAT registration threshold from 80k to 120k kr in onboarding - Update CLAUDE.md documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { createClient } from '@/lib/supabase/server'
|
|
import { NextResponse } from 'next/server'
|
|
import { getAuditLog } from '@/lib/core/audit/audit-service'
|
|
import type { AuditAction } from '@/types'
|
|
|
|
export async function GET(request: Request) {
|
|
const supabase = await createClient()
|
|
const { data: { user } } = await supabase.auth.getUser()
|
|
|
|
if (!user) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { searchParams } = new URL(request.url)
|
|
|
|
const filters = {
|
|
action: (searchParams.get('action') as AuditAction) || undefined,
|
|
table_name: searchParams.get('table_name') || undefined,
|
|
record_id: searchParams.get('record_id') || undefined,
|
|
from_date: searchParams.get('from_date') || undefined,
|
|
to_date: searchParams.get('to_date') || undefined,
|
|
page: searchParams.has('page') ? Number(searchParams.get('page')) : undefined,
|
|
pageSize: searchParams.has('page_size') ? Number(searchParams.get('page_size')) : undefined,
|
|
}
|
|
|
|
try {
|
|
const result = await getAuditLog(supabase, user.id, filters)
|
|
return NextResponse.json({ data: result.data, count: result.count })
|
|
} catch (err) {
|
|
return NextResponse.json(
|
|
{ error: err instanceof Error ? err.message : 'Failed to fetch audit log' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|