diff --git a/src/components/dashboard/AdminDashboard.astro b/src/components/dashboard/AdminDashboard.astro new file mode 100644 index 0000000..e2c9caf --- /dev/null +++ b/src/components/dashboard/AdminDashboard.astro @@ -0,0 +1,183 @@ +--- +// Admin Dashboard Component +import { Authentication } from "../../scripts/pocketbase/Authentication"; +import { Get } from "../../scripts/pocketbase/Get"; + +const auth = Authentication.getInstance(); +const get = Get.getInstance(); + +// Fetch some basic stats for the admin dashboard +let userCount = 0; +let officerCount = 0; +let eventCount = 0; +let reimbursementCount = 0; + +try { + if (auth.isAuthenticated()) { + const userResponse = await get.getList("users", 1, 1); + userCount = userResponse.totalItems; + + const officerResponse = await get.getList("officers", 1, 1); + officerCount = officerResponse.totalItems; + + const eventResponse = await get.getList("events", 1, 1); + eventCount = eventResponse.totalItems; + + const reimbursementResponse = await get.getList("reimbursement", 1, 1); + reimbursementCount = reimbursementResponse.totalItems; + } +} catch (error) { + console.error("Error fetching admin dashboard data:", error); +} +--- + +
{userCount}
+Total registered users
+{officerCount}
+Active officers
+{eventCount}
+Total events
+{reimbursementCount}
+Total reimbursements
+Time | +User | +Action | +Details | +
---|---|---|---|
Just now | +Admin | +Login | +Administrator logged in | +
10 min ago | +System | +Update | +Event request status changed | +
1 hour ago | +Jane Doe | +Create | +New reimbursement request submitted | +