# Create Attribute

<!-- User story defining a specific requirement within a business flow.
The name of the story should start with the actor followed by `--` and the story name.
 -->

<!-- This section should contain the following subsections in order: -->
<!-- 1. ## User Story (required) -->
<!-- 2. ## Story Diagram (required) -->
<!-- 3. ## Scenario Patterns (required) -->
<!-- 4. ## Test Cases (required) -->
<!-- 5. ## Screens (required) -->
<!-- 6. ## Resolvers (required) -->

## User Story

<!-- Define the user story in the format:
As a [role], I want [goal], so that [benefit].
 -->

As a product manager, I want to create a new attribute with a unique code and name, so that the attribute can be used to define variant axes for products.

## Story Diagram

<!-- Mermaid flowchart showing user interactions with screens.
Focus on actors, UI screens, and business outcomes.
Avoid technical details (APIs, databases, endpoints).
 -->

<!-- Code block requirements: -->
<!-- Minimum 1 mermaid code blocks required -->

```mermaid
flowchart TD
    A([Product Manager]) --> B[Attribute List Screen]
    B --> C[Create Attribute Form]
    C --> D{Validate Inputs}
    D -- Duplicate code --> E[Show Error: Code Already Exists]
    D -- Missing required field --> F[Show Error: Required Field Missing]
    D -- Valid --> G[Attribute Created]
    G --> H[Attribute Detail Screen]
    E --> C
    F --> C
```

## Scenario Patterns

<!-- List requirements: -->
<!-- Minimum 1 unordered lists required -->
<!-- Minimum 1 items per list -->

- Product manager fills in code and name, submits the form, and the attribute is created.
- If the code already exists, an error is shown and the attribute is not created.
- If any required field (code, name) is missing, an error is shown and the attribute is not created.

## Test Cases

<!-- List requirements: -->
<!-- Minimum 1 items per list -->

- Given valid inputs, when the form is submitted, then an attribute is created with the given code and name.
- Given a duplicate code, when the form is submitted, then an error indicating the code already exists is shown.
- Given a missing required field, when the form is submitted, then a validation error is shown.

## Screens

<!-- Link to screen docs that implement this story's UI.
 -->

<!-- List requirements: -->
<!-- Minimum 1 unordered lists required -->
<!-- Minimum 1 items per list -->

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

## Resolvers

<!-- Link to resolver docs that implement this story's backend operations.
Write "None" if this story does not require any resolvers.
 -->

<!-- List requirements: -->
<!-- Minimum 1 items per list -->

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