#!/bin/bash

echo "CF Deployer UI - Quick Start"
echo "============================"
echo ""

# Check if Node.js is installed
if ! command -v node &> /dev/null; then
    echo "Error: Node.js is not installed"
    echo "Please install Node.js 20.x or higher from https://nodejs.org"
    exit 1
fi

echo "Node.js version: $(node --version)"
echo "npm version: $(npm --version)"
echo ""

# Check if node_modules exists
if [ ! -d "node_modules" ]; then
    echo "Installing dependencies..."
    npm install
    echo ""
fi

# Ask for backend URL
read -p "Enter backend URL (default: http://localhost:8080): " BACKEND_URL
BACKEND_URL=${BACKEND_URL:-http://localhost:8080}

echo ""
echo "Starting development server..."
echo "Backend URL: $BACKEND_URL"
echo ""
echo "The app will be available at: http://localhost:4200"
echo "Press Ctrl+C to stop"
echo ""

# Start dev server
npm start
