#!/bin/bash

# Create Stripe Products for all tiers
echo "Creating Stripe products for Mawidi subscription tiers..."

# Tier 1: Starter
echo "Creating Tier 1: Starter Plan..."
PRODUCT_TIER1=$(stripe products create \
  -d name="Starter Plan" \
  -d description="Basic WhatsApp appointment management" \
  -d 'metadata[tier_id]'=tier1 \
  --format=json | grep -o '"id": "[^"]*' | cut -d'"' -f4)
echo "✅ Tier 1 Product ID: $PRODUCT_TIER1"

# Tier 2: Professional
echo "Creating Tier 2: Professional Plan..."
PRODUCT_TIER2=$(stripe products create \
  -d name="Professional Plan" \
  -d description="Advanced features for growing practices" \
  -d 'metadata[tier_id]'=tier2 \
  --format=json | grep -o '"id": "[^"]*' | cut -d'"' -f4)
echo "✅ Tier 2 Product ID: $PRODUCT_TIER2"

# Tier 3: Business
echo "Creating Tier 3: Business Plan..."
PRODUCT_TIER3=$(stripe products create \
  -d name="Business Plan" \
  -d description="Comprehensive solution for busy clinics" \
  -d 'metadata[tier_id]'=tier3 \
  --format=json | grep -o '"id": "[^"]*' | cut -d'"' -f4)
echo "✅ Tier 3 Product ID: $PRODUCT_TIER3"

# Tier 4: Enterprise
echo "Creating Tier 4: Enterprise Plan..."
PRODUCT_TIER4=$(stripe products create \
  -d name="Enterprise Plan" \
  -d description="Full-featured for large organizations" \
  -d 'metadata[tier_id]'=tier4 \
  --format=json | grep -o '"id": "[^"]*' | cut -d'"' -f4)
echo "✅ Tier 4 Product ID: $PRODUCT_TIER4"

# Tier 5: Ultimate
echo "Creating Tier 5: Ultimate Plan..."
PRODUCT_TIER5=$(stripe products create \
  -d name="Ultimate Plan" \
  -d description="Maximum capabilities and support" \
  -d 'metadata[tier_id]'=tier5 \
  --format=json | grep -o '"id": "[^"]*' | cut -d'"' -f4)
echo "✅ Tier 5 Product ID: $PRODUCT_TIER5"

echo ""
echo "📦 All products created successfully!"
echo ""
echo "Next: Create prices for these products..."
echo "Run: ./scripts/create-stripe-prices.sh"
