Fix TypeScript errors in revenue and support API
This commit is contained in:
parent
0f7e778413
commit
43ee05d661
2 changed files with 19 additions and 17 deletions
|
|
@ -98,8 +98,8 @@ export default function AdminRevenue() {
|
||||||
<div
|
<div
|
||||||
className="w-full bg-emerald-500 rounded-t"
|
className="w-full bg-emerald-500 rounded-t"
|
||||||
style={{
|
style={{
|
||||||
height: data.mrr > 0 ? `${(parseFloat(h.revenue) / (data.mrr * 1.2)) * 100}%` : "0%",
|
height: data.mrr > 0 ? `${(h.revenue / (data.mrr * 1.2)) * 100}%` : "0%",
|
||||||
minHeight: parseFloat(h.revenue) > 0 ? "4px" : "0"
|
minHeight: h.revenue > 0 ? "4px" : "0"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="text-[8px] text-gray-500">{h.month}</div>
|
<div className="text-[8px] text-gray-500">{h.month}</div>
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,24 @@ export async function GET(request: Request) {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const status = searchParams.get("status") || "all";
|
const status = searchParams.get("status") || "all";
|
||||||
|
|
||||||
let query = `
|
let tickets;
|
||||||
SELECT t.*, f.name as family_name
|
if (status === "all") {
|
||||||
FROM support_tickets t
|
tickets = await sql`
|
||||||
LEFT JOIN families f ON f.id = t.family_id
|
SELECT t.*, f.name as family_name
|
||||||
`;
|
FROM support_tickets t
|
||||||
const params: string[] = [];
|
LEFT JOIN families f ON f.id = t.family_id
|
||||||
|
ORDER BY t.created_at DESC
|
||||||
if (status !== "all") {
|
`;
|
||||||
query += ` WHERE t.status = $1`;
|
} else {
|
||||||
params.push(status);
|
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
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
query += ` ORDER BY t.created_at DESC`;
|
|
||||||
|
|
||||||
const tickets = await sql(query, ...params);
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
tickets: tickets.map((t: any) => ({
|
tickets: tickets.map((t: any) => ({
|
||||||
id: t.id,
|
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) {
|
export async function PATCH(request: Request) {
|
||||||
try {
|
try {
|
||||||
const authHeader = request.headers.get("authorization");
|
const authHeader = request.headers.get("authorization");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue