# Edit 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 edit a product's name, description, and unit of measure (when in DRAFT), so that product information stays accurate before activation.

## 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 Detail Screen]
    B --> C[Edit Product Form]
    C --> D{Validate Changes}
    D -- Product not found --> E[Show Error: Product Not Found]
    D -- UoM change on non-DRAFT --> F[Show Error: UoM Locked After Activation]
    D -- Valid --> G[Product Updated]
    G --> H[Product Detail Screen]
    E --> B
    F --> C
```

## Scenario Patterns

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

- Product manager updates name and/or description on a product in any status; changes are saved successfully.
- Product manager updates uomId on a DRAFT product; the change is saved successfully.
- Product manager attempts to update uomId on an ACTIVE or ARCHIVED product; an error is shown and the change is rejected.
- Product manager attempts to edit a product that does not exist; an error is shown.

## Test Cases

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

- Given a product in any status, when name or description is updated, then the changes are persisted.
- Given a DRAFT product, when uomId is changed, then the change is persisted.
- Given an ACTIVE product, when uomId is changed, then an error indicating UoM is locked is shown and no change is made.
- Given a non-existent product ID, when an edit is attempted, then a not-found 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-detail](../../../screen/product-detail.md)
- [product-edit-form](../../../screen/product-edit-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 -->

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