#!/bin/bash

# End-to-End Happy-Path Demo-Script
# Ziel: Registrierung -> Request -> Offer -> Deal -> Review

set -e

echo "Starte Happy-Path Demo..."

# 1. Registrierung
echo "1. Registrierung"
curl -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Demo User",
    "email": "demo@example.com",
    "password": "demopassword123"
  }' | jq .

# 2. Login
echo "2. Login"
curl -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "demo@example.com",
    "password": "demopassword123"
  }' | jq .

# 3. Request erstellen
echo "3. Request erstellen"
curl -X POST http://localhost:3000/api/requests \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Hilfe bei Gartenarbeit",
    "description": "Ich brauche Hilfe beim Rasenmähen.",
    "category": "garten"
  }' | jq .

# 4. Offer anbieten
echo "4. Offer anbieten"
curl -X POST http://localhost:3000/api/offers \
  -H "Content-Type: application/json" \
  -d '{
    "requestId": "REQUEST_ID",
    "description": "Ich helfe gerne mit.",
    "price": 20
  }' | jq .

# 5. Deal akzeptieren
echo "5. Deal akzeptieren"
curl -X POST http://localhost:3000/api/deals \
  -H "Content-Type: application/json" \
  -d '{
    "offerId": "OFFER_ID",
    "requestId": "REQUEST_ID"
  }' | jq .

# 6. Review abgeben
echo "6. Review abgeben"
curl -X POST http://localhost:3000/api/reviews \
  -H "Content-Type: application/json" \
  -d '{
    "dealId": "DEAL_ID",
    "rating": 5,
    "comment": "Sehr gute Hilfe!"
  }' | jq .

echo "Happy-Path Demo abgeschlossen."