Skip to content

Admin

System administration console — users, roles, permissions, integrations, audit logs, currencies, cities, locations, and operational daily stats.

Scope

The Admin module is the back-office control centre. It does not include finance configuration (GL mapping, GST rate, invoice numbering) — those live under Finance → Settings.

Pages

  • src/pages/admin/Admin.tsx — the single-page tabbed admin console. Mounted at /admin.

Route guard (src/App.tsx:176):

<ProtectedRoute allowedRoles={['admin']} requiredPermissions={['admin.view']}>
  <Admin />
</ProtectedRoute>

Double-gated route

/admin is gated by both an allowedRoles=['admin'] check and the admin.view permission. This is intentional so that a permission mis-grant cannot expose the admin console to a non-admin tier role. See docs/PERMISSIONS.md §6.16.

Tabs & surface area

The console is a flat <Tabs> component (src/pages/admin/Admin.tsx:154) with the following panes:

Tab Component Purpose
Dashboard inline + OnlineUsers Daily stats per module (bookings, payments, finance, customers, groups, visa) with a date picker. Right rail shows live online users. Hits GET /admin/daily-stats?date=YYYY-MM-DD.
Audit Logs inline + Timeline Filterable audit log table (time, user, action, entity, IP) with a side-rail timeline of the 10 most recent actions. Powered by fetchAuditLogs() in src/services/auditLogService.ts.
Currency Settings CurrencySettings CRUD for the currency master.
City Settings CitySettings CRUD for the service-cities master.
Locations LocationSettings India locations hierarchy (state → district → taluk).
Settings inline Read-only snapshots of approval policies (finance approval required, ticket exception approval, name-update deadline) and system flags (default currency, audit logging, email notifications). Also hosts a Booking Number Decoder that parses the millis timestamp embedded in BK-<timestamp> IDs.
Permissions PermissionsMatrix Interactive role × permission grid + per-user overrides. Writes via /permissions/... endpoints.
Integrations IntegrationSettings Email provider (Resend), WhatsApp Cloud API, SMS (legacy), Google Drive OAuth.

Settings tab is informational

The tiles under the Settings tab read like configurable toggles but currently render status badges only. Live config for approval thresholds and email toggles is not yet editable from this screen.

Audience

Primary: CEO, GM, IT_ADMIN — seeded every permission (see supabase/migrations/20260416020000_remove_permission_bypass.sql).

Secondary: ADMIN_HR holds most admin grants. Functional managers hold admin.view only if explicitly granted.

Permissions

Gate Permission Source
Route /admin admin.view + role admin src/App.tsx:176
Permissions matrix edits admin.permissions.edit src/lib/api.ts:12550, :12597
User CRUD admin.users.create, admin.users.edit, admin.users.delete src/lib/api.ts:13022, :13063, :13201
Audit log view admin.view (legacy) → admin.audit.view (granular, seeded not yet wired) docs/PERMISSIONS.md §4.4
Currency / cities / locations edits admin.edit (legacy) → admin.currency.*, admin.cities.*, admin.locations.view docs/PERMISSIONS.md §4.4
Integrations edits admin.editadmin.integrations.edit, admin.integrations.test docs/PERMISSIONS.md §4.4

Privilege escalation gate

admin.permissions.edit is the most sensitive permission in the system — holders can grant themselves any other permission. It is granted only to super-admins and audited.

API endpoints hit

  • GET /admin/daily-stats?date=... — aggregate daily stats for the dashboard tile.
  • GET /audit-logs — via auditLogService.fetchAuditLogs().
  • GET /users, POST /users, PATCH /users/:id, DELETE /users/:id — user management.
  • GET /permissions, POST /permissions/roles/:roleId/grants, POST /permissions/users/:userId/grants.
  • GET /online-users — live presence feed rendered in OnlineUsers.
  • Finance settingsdocs/features/finance/index.md (GL mapping, GST, voucher prefixes).
  • Security settingsdocs/features/settings.md (2FA, push notifications, active sessions — per-user, not global).
  • People (employees)docs/features/people.md for the staff directory (route /people/employees is also gated by admin.view).