# Create Product

<!-- 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 product with a unique SKU and unit of measure, so that the product is available for cataloging in DRAFT status.

## 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[Product List Screen]
    B --> C[Create Product 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[Product Created in DRAFT]
    G --> H[Product 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, name, description, and uomId, submits the form, and the product is created in DRAFT status.
- If the code already exists, an error is shown and the product is not created.
- If any required field (code, name, uomId) is missing, an error is shown and the product is not created.

## Test Cases

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

- Given valid inputs, when the form is submitted, then a product is created with status DRAFT.
- 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 -->

- [product-list](../../../screen/product-list.md)
- [product-create-form](../../../screen/product-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 -->

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