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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user