Page - Kill Switch

abstract

Emergency trading halt panel — shows current kill-switch status (active/inactive), provides activate/deactivate controls with a required reason field, and displays the audit log of all previous activations.

Route

PropertyValue
Path/kill-switch
Filefrontend/src/app/kill-switch/page.tsx
Auth RequiredNo
LayoutRoot layout with sidebar
Dynamic SegmentNone

Component Tree

KillSwitchPage (page.tsx)
├── AppHeader (title="Kill Switch")
├── Status Card
│   ├── Status Badge (ACTIVE / INACTIVE)
│   ├── Reason text (if active)
│   └── Activated at timestamp (if active)
├── Control Card
│   ├── Textarea: reason (required for activation)
│   ├── Button: "Activate Kill Switch" (red, disabled if reason empty)
│   └── Button: "Deactivate" (shown only when active)
├── Error Alert (if any API error)
└── Audit Log Table
    └── Columns: Action, Reason, Timestamp

Data Layer

Server State — Direct fetch

CallAPITriggered When
killSwitchApi.getStatus()GET /api/v1/kill-switchOn mount
killSwitchApi.getLogs()GET /api/v1/kill-switch/logsOn mount
killSwitchApi.activate(reason)POST /api/v1/kill-switch/activateActivate button
killSwitchApi.deactivate()POST /api/v1/kill-switch/deactivateDeactivate button

After activate/deactivate: load() is called to refresh status + logs.

Local State — useState

VariableTypeInitialPurpose
statusKillSwitchStatus | nullnullCurrent kill-switch state
logsKillSwitchLog[][]Audit log entries
reasonstring""Activation reason textarea
loadingbooleanfalseButton loading state
errorstring | nullnullError display

Page Lifecycle

Validation & Conditions

Render Conditions

ConditionWhat Shows
status.is_active === trueRed "ACTIVE" badge; deactivate button visible
status.is_active === falseGreen "INACTIVE" badge; activate form visible
reason.trim() === ""Activate button disabled
loading === trueSpinner on active button
error !== nullError Alert card below controls
RoleLink
Backend APIAPI-Kill-Switch
StoreStore - TradingStore
PagePage - Dashboard (KillSwitchBanner)