Skip to content

Stores — state management and API wrappers

This document describes the stores under app/frontend/src/stores. The project uses zustand for client state with both simple UI stores and domain stores that wrap API calls.

Store pattern summary

  • Implementation: each store uses create from zustand. Many domain stores follow a pattern of items, loading, error, and action methods (fetchAll, create, update, remove).
  • API interaction: stores call fetchApi from helpers/ApiHelper.
  • UI stores: small stores like useDialogStore manage transient UI state (open dialogs, modals). useAuthStore uses persist middleware to save auth state.

Key stores

  • useAuthStore.tsx — persisted auth state: user, access_token, access_token_expires, plus login/logout.
  • useDialogStore.ts — small UI store for global dialog management (open/close, payload).
  • UsersStore.tsx — manages users list, current me, and user CRUD operations.
  • RoomsStore.tsx — room list and room-specific actions.
  • RolesStore.tsx, PermissionsStore.tsx — role/permission lists and role/permission-specific actions.
  • EventsStore.tsx, EventTypesStore.tsx — event/event-type list and event/type-specific actions.
  • TasksStore.tsx, TaskTypesStore.tsx — task/task-type list and task/type-specific actions.
  • DisplaysStore.tsx — display lists and display-specific actions.