#!/bin/bash
# Quick Start Script for Payment Gateway App
# This script helps you quickly test the Payment Gateway functionality

set -e

echo "🚀 Payment Gateway Quick Start"
echo "================================"
echo ""

# Check if we're in the right directory
if [ ! -f "mix.exs" ]; then
    echo "❌ Error: Please run this script from the CloudLayer root directory"
    exit 1
fi

# Ask if user wants to enable Payment Gateway
echo "Do you want to enable the Payment Gateway module?"
echo "1) Yes - Enable at compile-time and runtime"
echo "2) No - Run without Payment Gateway"
read -p "Choose option (1 or 2): " choice

if [ "$choice" = "1" ]; then
    echo ""
    echo "✅ Enabling Payment Gateway..."
    export INCLUDE_PAYMENT_GATEWAY=true
    export ENABLE_PAYMENT_GATEWAY=true
    
    echo ""
    echo "📦 Installing dependencies..."
    mix deps.get
    
    echo ""
    echo "🔨 Compiling application..."
    mix compile
    
    echo ""
    echo "✨ Payment Gateway is enabled!"
    echo ""
    echo "Available endpoints:"
    echo "  - Main App: http://localhost:4000"
    echo "  - Payment Gateway: http://localhost:4001/pgpayments"
    echo "  - PG API: http://localhost:4001/api/pgpayments/*"
    echo ""
    echo "Starting server..."
    mix phx.server
else
    echo ""
    echo "Running without Payment Gateway..."
    echo ""
    echo "Available endpoints:"
    echo "  - Main App: http://localhost:4000"
    echo ""
    echo "Starting server..."
    mix phx.server
fi
