Skip to content

UI Context Providers

Directory: ui/src/context/

Three React context providers managing different aspects of state.

GroupContext

File: context/GroupContext.jsx

Manages all group-related state using useReducer.

State Shape

js
{
    isOpen: false,           // Group UI open
    groupData: null,         // Current group info
    dashboard: null,         // Dashboard data
    members: [],             // Group members
    tasks: [],               // Active tasks
    cooldowns: {},           // Active cooldowns
    pendingInvite: null,     // Incoming invite
    joinRequests: [],        // Pending join requests
    instructions: [],        // Active instructions
    reputation: null,        // XP/level data
    notifications: [],       // In-UI toast notifications
    gpsData: [],             // GPS/blip data
    history: [],             // Activity history
    alliances: [],           // Alliance list
    turfs: [],               // Territory list
    mail: [],                // Mailbox messages
    vehicles: [],            // Garage vehicles
    spawns: [],              // Spawn points
}

Actions

ActionDescription
OPENOpen group UI with data
CLOSEClose group UI
GROUP_SYNCFull group state update
GROUP_DISBANDEDGroup disbanded
INVITE_RECEIVEDInvite received
INVITE_ACCEPTED / INVITE_DENIEDInvite response
TASK_CREATED / TASK_ACTIVATED / TASK_COMPLETED / TASK_FAILEDTask lifecycle
REP_SYNC / LEVEL_UPReputation updates
ADD_NOTIFICATION / REMOVE_NOTIFICATIONToast notifications
COOLDOWN_SET / COOLDOWN_RESULTCooldown events

TabletContext

File: context/TabletContext.jsx

Manages tablet settings and open/close state.

State Shape

js
{
    isOpen: false,
    theme: 'dark',
    wallpaper: null,
    accentColor: '#00ff88',
    secondaryColor: '#00d4ff',
    textColor: '#c8d8e8',
    backgroundColor: '#060a0f',
    fontFamily: "'Inter', sans-serif",
    fontSize: 13,
    uiScale: 100,
    borderRadius: 12,
    // ... all settings
}

Provides

  • All setting values
  • themeColors — derived from base theme + custom colors
  • updateSetting(key, value) — single update
  • updateSettings({...}) — batch update
  • resetSettings() — reset to defaults
  • openTablet() / closeTablet() / toggleTablet()

DB Sync

  • Loads from localStorage on init (instant)
  • Loads from DB async on mount (overrides if different)
  • Saves to both localStorage and DB on every change

AppContext

File: context/AppContext.jsx

Manages app registration and window lifecycle.

State Shape

js
{
    registeredApps: {},      // { appId: appDefinition }
    windows: [],             // Array of window objects
    focusedWindowId: null,
    zIndexCounter: 100,
}

Window Object

js
{
    id: 'app_1234567890_abc123',
    appId: 'calculator',
    title: 'Calculator',
    iconComponent: CalculatorIcon,
    color: '#3498db',
    x: 80, y: 40,
    width: 320, height: 480,
    minWidth: 280, minHeight: 400,
    isMaximized: false,
    isMinimized: false,
    isFocused: true,
    zIndex: 101,
    component: CalculatorApp,
    props: {},
}

Actions

ActionDescription
REGISTER_APPRegister app in registry
UNREGISTER_APPRemove app from registry
OPEN_APPCreate new window (or focus if singleton)
CLOSE_WINDOWRemove window
FOCUS_WINDOWBring window to front
MINIMIZE_WINDOWMinimize window
MAXIMIZE_WINDOWToggle maximize
MOVE_WINDOWUpdate window position
RESIZE_WINDOWUpdate window size
UPDATE_WINDOW_PROPSUpdate window component props
MINIMIZE_ALLMinimize all windows

AIFAZI — FiveM Resources