#!/bin/bash

# MyRoadTrip - Quick Start Guide
# This script helps you get started with the integrated Search & Admin modules

echo "🚀 MyRoadTrip Integration - Quick Start"
echo "========================================"
echo ""

# Check if pnpm is installed
if ! command -v pnpm &> /dev/null; then
    echo "❌ pnpm not found. Installing pnpm..."
    npm install -g pnpm
    echo "✅ pnpm installed"
else
    echo "✅ pnpm found"
fi

# Check if dependencies are installed
if [ ! -d "node_modules" ]; then
    echo "📦 Installing dependencies..."
    pnpm install
    echo "✅ Dependencies installed"
else
    echo "✅ Dependencies already installed"
fi

echo ""
echo "🔥 Integration Status:"
echo "  ✅ Search module integrated"
echo "  ✅ Admin module integrated"
echo "  ✅ Auth with roles implemented"
echo "  ✅ Navigation links added"
echo ""

echo "⚠️  CRITICAL: Set yourself as admin in Firestore!"
echo "   1. Go to Firebase Console"
echo "   2. Navigate to Firestore Database"
echo "   3. Find your user in 'users' collection"
echo "   4. Add field: role = \"admin\""
echo ""

echo "🎯 Next Steps:"
echo ""
echo "1. Start Backend:"
echo "   cd apps/api && npm run dev"
echo ""
echo "2. Start Frontend (in another terminal):"
echo "   cd apps/web && npm run dev"
echo ""
echo "3. Test the integration:"
echo "   - Visit http://localhost:5173/search"
echo "   - Visit http://localhost:5173/admin (requires admin role)"
echo ""
echo "4. Test API endpoints:"
echo "   curl http://localhost:3000/api/search/feed"
echo "   curl http://localhost:3000/api/admin/stats -H 'Authorization: Bearer YOUR_TOKEN'"
echo ""

echo "📚 Documentation:"
echo "   - INTEGRATION_CHECKLIST.md - Full checklist"
echo "   - INTEGRATION_COMPLETE.md - Integration guide"
echo "   - PROMPT_5_STATUS.md - Quick status"
echo ""

read -p "Press Enter to continue..."
