fix: add billing types and fix Supabase type casting for admin routes

- Add src/types/billing.ts with Payment, Coupon, CreditTransaction, Invoice types
- Cast all Supabase query results through 'unknown' for untyped billing tables
- All routes now build cleanly with strict TypeScript checking

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Dennis
2026-03-07 01:21:05 +01:00
parent 5ebea6b0d6
commit 4d7f00be1f
5 changed files with 107 additions and 18 deletions
+4 -2
View File
@@ -1,6 +1,7 @@
import { NextResponse } from "next/server";
import { getSupabaseAdmin } from "@/lib/admin";
import { requireAdmin } from "@/lib/apiAuth";
import type { CreditTransaction } from "@/types/billing";
export async function GET(request: Request) {
const authResult = await requireAdmin(request);
@@ -37,7 +38,7 @@ export async function GET(request: Request) {
return NextResponse.json({
organization: orgResult.data,
transactions: transactionsResult.data || [],
transactions: (transactionsResult.data || []) as unknown as CreditTransaction[],
pagination: {
page,
limit,
@@ -111,7 +112,7 @@ export async function POST(request: Request) {
}
// Insert transaction and update balance atomically
const { data: transaction, error: txError } = await supabase
const { data, error: txError } = await supabase
.from("credit_transactions")
.insert({
organization_id,
@@ -126,6 +127,7 @@ export async function POST(request: Request) {
.single();
if (txError) throw txError;
const transaction = data as unknown as CreditTransaction;
const { error: updateError } = await supabase
.from("organizations")