e11f70b347
* refactor: optimize page loading and data fetching * fix: resolve recurring production runtime errors * feat: add MCP company and customer updates * fix: handle year-end tax adjustments * feat: harden annual report compliance * fix: expand invoice logo and font support * fix: sanitize API route error responses * fix: sanitize user-facing error messages * feat: persist onboarding and tax assessment notices * fix: reduce cloud backup audit churn * feat: refine invoice editor layout * fix: show saved tax adjustments in INK2 * fix: complete annual report API mappings * docs: record operational safeguards and decisions * fix: harden annual report review findings * fix: adjust column span for description based on VAT registration * New css class name
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { withRouteContext } from '@/lib/api/with-route-context'
|
|
import { getErrorMessage as getUserErrorMessage } from '@/lib/errors/get-error-message'
|
|
|
|
/**
|
|
* GET /api/import/sie
|
|
* List all SIE imports for the user
|
|
*/
|
|
export const GET = withRouteContext(
|
|
'sie_import.list',
|
|
async (request, { supabase, companyId }) => {
|
|
// Parse query params
|
|
const { searchParams } = new URL(request.url)
|
|
const limit = parseInt(searchParams.get('limit') || '20', 10)
|
|
const offset = parseInt(searchParams.get('offset') || '0', 10)
|
|
const status = searchParams.get('status')
|
|
|
|
let query = supabase
|
|
.from('sie_imports')
|
|
.select('*', { count: 'exact' })
|
|
.eq('company_id', companyId)
|
|
.order('created_at', { ascending: false })
|
|
.range(offset, offset + limit - 1)
|
|
|
|
if (status) {
|
|
query = query.eq('status', status)
|
|
}
|
|
|
|
const { data, error, count } = await query
|
|
|
|
if (error) {
|
|
return NextResponse.json({ error: getUserErrorMessage(error) }, { status: 500 })
|
|
}
|
|
|
|
return NextResponse.json({
|
|
data,
|
|
count,
|
|
limit,
|
|
offset,
|
|
})
|
|
},
|
|
)
|