#!/bin/bash
# ============================================================
# MediCare HMS - Frontend Build Script for cPanel
# ============================================================
# Builds the React app for production deployment
# ============================================================

set -e

echo "========================================"
echo "  Building MediCare Frontend for cPanel"
echo "========================================"

# 1. Install dependencies
echo "[1/4] Installing dependencies..."
npm install

# 2. Build for production
echo "[2/4] Building React app..."
npm run build

# 3. Copy .htaccess to build
echo "[3/4] Copying .htaccess..."
cp ../frontend/.htaccess dist/

# 4. Done
echo "[4/4] Build complete!"
echo ""
echo "Next steps:"
echo "  1. Upload the contents of 'dist/' to your cPanel"
echo "     public_html/ or a subdomain root"
echo "  2. Ensure .htaccess is present (already copied)"
echo "  3. Test your site at: https://yourdomain.com"
echo ""
echo "Note: The API proxy in .htaccess expects Node.js"
echo "      app running on localhost:5000"
echo "========================================"
