# Toggle Role Status

## User Story

As a user with the appropriate role, I want to activate or deactivate a role, so that I can control which roles are available for assignment.

## Story Diagram

```mermaid
flowchart TD
    A[Open Role Detail] --> B{Current status}
    B -- ACTIVE --> C[Click Deactivate]
    B -- INACTIVE --> D[Click Reactivate]
    C --> E[Confirm]
    D --> E
    E --> F{Validation}
    F -- Role has active assignments --> G[Show error]
    F -- Valid --> H[Status changed]
```

## Scenario Patterns

- Deactivate an ACTIVE role with no active user assignments
- Reactivate an INACTIVE role
- Cannot deactivate a role that still has active user assignments

## Test Cases

- Open the detail page for an ACTIVE role with no user assignments and click Deactivate; verify the role's status changes to INACTIVE
- Open the detail page for an INACTIVE role and click Reactivate; verify the role's status changes to ACTIVE
- Open the detail page for an ACTIVE role with active user assignments and click Deactivate; verify an error is shown and the role remains ACTIVE

## Screens

- [role-detail](../../../screen/role-detail.md)

## Resolvers

- [deactivateRole](../../../resolver/deactivateRole.md)
- [reactivateRole](../../../resolver/reactivateRole.md)
