Loyalty - User Flow Diagram

%%{init: { "theme": "base", "themeVariables": { "primaryColor": "#038851", "primaryTextColor": "#ffffff", "primaryBorderColor": "#026139", "lineColor": "#64748b", "fontSize": "15px", "background": "transparent" } }}%%
flowchart TD
    A["Customer uses loyalty feature"] --> B["Get customer details & wallet"]
    B --> C{"Customer exists?"}
    C -->|YES| E["Get customer wallet"]
    C -->|NO| D["Create customer"]
    D --> E
    E --> F["Retrieve available programs"]
    F --> G{"Program selected?"}
    G -->|Yes| H["Validate program"]
    G -->|No| I(["Exit"])
    H --> J{"Valid?"}
    J -->|Yes| K["Apply discount to basket"]
    J -->|No| L["Show validation error"]
    K --> M["Order placed"]
    M --> N["Redeem program/ points"]

    classDef process fill:#038851,stroke:#026139,stroke-width:1px,color:#ffffff;
    classDef decision fill:#02502f,stroke:#026139,stroke-width:1px,color:#ffffff;
    classDef terminal fill:#c6ebdc,stroke:#038851,stroke-width:1px,color:#02502f;
    classDef error fill:#e6f4ee,stroke:#038851,stroke-width:1px,color:#02502f;

    class A,B,D,E,F,H,K,M,N process;
    class C,G,J decision;
    class I terminal;
    class L error;