Fix TypeScript errors in revenue and support API

This commit is contained in:
Manohar Gupta 2026-05-10 22:47:38 +05:30
parent 0f7e778413
commit 43ee05d661
2 changed files with 19 additions and 17 deletions

View file

@ -98,8 +98,8 @@ export default function AdminRevenue() {
<div
className="w-full bg-emerald-500 rounded-t"
style={{
height: data.mrr > 0 ? `${(parseFloat(h.revenue) / (data.mrr * 1.2)) * 100}%` : "0%",
minHeight: parseFloat(h.revenue) > 0 ? "4px" : "0"
height: data.mrr > 0 ? `${(h.revenue / (data.mrr * 1.2)) * 100}%` : "0%",
minHeight: h.revenue > 0 ? "4px" : "0"
}}
/>
<div className="text-[8px] text-gray-500">{h.month}</div>

View file

@ -11,22 +11,24 @@ export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const status = searchParams.get("status") || "all";
let query = `
let tickets;
if (status === "all") {
tickets = await sql`
SELECT t.*, f.name as family_name
FROM support_tickets t
LEFT JOIN families f ON f.id = t.family_id
ORDER BY t.created_at DESC
`;
} else {
tickets = await sql`
SELECT t.*, f.name as family_name
FROM support_tickets t
LEFT JOIN families f ON f.id = t.family_id
WHERE t.status = ${status}
ORDER BY t.created_at DESC
`;
const params: string[] = [];
if (status !== "all") {
query += ` WHERE t.status = $1`;
params.push(status);
}
query += ` ORDER BY t.created_at DESC`;
const tickets = await sql(query, ...params);
return NextResponse.json({
tickets: tickets.map((t: any) => ({
id: t.id,
@ -45,7 +47,7 @@ export async function GET(request: Request) {
}
}
// Create/update ticket
// Update ticket status
export async function PATCH(request: Request) {
try {
const authHeader = request.headers.get("authorization");