# Create User Account

## User Story

As a user with the appropriate role, I want to create a new user account with name, email, and optionally one or more roles, so that new employees can access the system.

## Story Diagram

```mermaid
flowchart TD
    A[Open User List] --> B[Click Create]
    B --> C[Enter name and email]
    C --> D[Select roles - optional, multiple allowed]
    D --> E[Submit]
    E --> F{Validation}
    F -- Email already exists --> G[Show duplicate email error]
    F -- Required field missing --> H[Show validation error]
    F -- Valid --> I[User created with ACTIVE status]
    I --> J[Display initial password dialog]
    J --> K[Admin copies password and confirms]
    K --> L[Navigate to user list]
```

## Scenario Patterns

- Create user with all required fields and one or more roles; initial password is displayed in a dialog
- Create user with no roles assigned; user is created and roles can be assigned later
- Duplicate email address is rejected with an error
- Submission with missing required fields is blocked by validation

## Test Cases

- Submit the form with valid name, email, and one or more roles; verify the user appears in the list with ACTIVE status
- Submit the form with valid name and email but no roles; verify the user is created with ACTIVE status
- Submit the form with an email address already assigned to another user; verify an error is shown and no user is created
- Submit the form with the name field empty; verify a validation error is shown and submission is blocked

## Screens

- [user-list](../../../screen/user-list.md)
- [user-create-form](../../../screen/user-create-form.md)

## Resolvers

- [createUser](../../../resolver/createUser.md)
