Nexus Admin - Commission Ledger API
cgen-0430ffb6f5c14c528a1fe3524182d843
This commit is contained in:
parent
5c4b7eaa27
commit
3371f2a53b
1 changed files with 27 additions and 0 deletions
27
api/admin/nexus/commissions.ts
Normal file
27
api/admin/nexus/commissions.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { createClient } from "@supabase/supabase-js";
|
||||
|
||||
const supabase = createClient(
|
||||
process.env.VITE_SUPABASE_URL!,
|
||||
process.env.SUPABASE_SERVICE_ROLE!
|
||||
);
|
||||
|
||||
export default async function handler(req: any, res: any) {
|
||||
if (req.method === "GET") {
|
||||
try {
|
||||
const { data: commissions, error } = await supabase
|
||||
.from("nexus_commission_ledger")
|
||||
.select("*")
|
||||
.order("period_start", { ascending: false });
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
res.status(200).json(commissions || []);
|
||||
} catch (error: any) {
|
||||
res
|
||||
.status(500)
|
||||
.json({ error: error.message || "Failed to fetch commissions" });
|
||||
}
|
||||
} else {
|
||||
res.status(405).json({ error: "Method not allowed" });
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue