Skip to content

feat(web): Rules page with admin-only enable/disable toggle #70

Closed

Description

@vianbas

Follow-up to #68 (#69). That issue added GET /rules (any role) and PATCH /rules/{id}, which is admin-only and enforced server-side. This issue adds the web UI for those endpoints.

Scope

  • A new /rules route and a Rules nav item, visible to every signed-in user.
  • Rules table:
    • A semantic table with a caption showing name, condition, severity, status (enabled/disabled) and created time.
    • The condition is rendered readably, for example amount_minor gte 500000 shown as "Amount ≥ 500,000 minor units".
    • Rules carry no currency, so an amount threshold is shown as integer minor units with grouping. It is never converted to a major-unit decimal. currency and direction values are shown as literals.
  • Admins:
    • Each row has an Enable/Disable control with an accessible name that includes the rule's name. The control is disabled while its request is pending.
    • After a change, the rules query is refreshed.
    • Errors are shown as a non-fatal inline message. A 403 says the role is insufficient; a 404 says the rule no longer exists.
  • Operators: they see the same table read-only. There are no toggles, and a short note says that only admins can change rules.
  • The server remains the enforcement point. The UI only hides controls, and a 403 is still handled.
  • Data goes through useApiFetch and requestJson, with query keys under a new queryKeys.rules. Loading, empty and error states are reused from the existing components.

Acceptance criteria

  • An admin can disable and re-enable a rule. An operator sees no controls.
  • A 403 or 404 on toggle produces a readable message.
  • Accessible: table caption and headers, labelled controls, and status shown as text rather than colour only.
  • Vitest coverage for the hook and the role-based rendering, including toggle success and the 403 and 404 cases.
  • Lint, typecheck, test and build all pass.

Dependencies

Out of scope

  • Creating, deleting or editing rules beyond the enabled flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions