completionId: cgen-3c530c9f04ed4b89b21d0c0f77bbebe8
cgen-3c530c9f04ed4b89b21d0c0f77bbebe8
This commit is contained in:
parent
b34275a5a6
commit
b548246671
1 changed files with 17 additions and 1 deletions
|
|
@ -4851,18 +4851,34 @@ export function createServer() {
|
|||
// Staff Members API
|
||||
app.get("/api/staff/members", async (_req, res) => {
|
||||
try {
|
||||
console.log("[Staff] GET /api/staff/members - adminSupabase initialized:", !!adminSupabase);
|
||||
|
||||
if (!adminSupabase) {
|
||||
console.error("[Staff] adminSupabase is not initialized");
|
||||
return res.status(500).json({
|
||||
error: "Supabase client not initialized",
|
||||
message: "SUPABASE_URL or SUPABASE_SERVICE_ROLE not set",
|
||||
});
|
||||
}
|
||||
|
||||
const { data, error } = await adminSupabase
|
||||
.from("staff_members")
|
||||
.select("*")
|
||||
.order("full_name", { ascending: true });
|
||||
|
||||
if (error) {
|
||||
if (isTableMissing(error)) return res.json([]);
|
||||
console.error("[Staff] Error fetching staff members:", error);
|
||||
if (isTableMissing(error)) {
|
||||
console.log("[Staff] Table not found, returning empty array");
|
||||
return res.json([]);
|
||||
}
|
||||
return res.status(500).json({ error: error.message });
|
||||
}
|
||||
|
||||
console.log("[Staff] Successfully fetched", (data || []).length, "staff members");
|
||||
return res.json(data || []);
|
||||
} catch (e: any) {
|
||||
console.error("[Staff] Unexpected error:", e);
|
||||
return res.status(500).json({ error: e?.message || String(e) });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue