#!/bin/bash

# Welcome script for Module 07 students
# This runs automatically when Codespace is ready

# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
PURPLE='\033[0;35m'
NC='\033[0m'

# ASCII Art Banner
cat << "EOF"
 __  __           _       _        ___ _____ 
|  \/  | ___   __| |_   _| | ___  / _ \___  |
| |\/| |/ _ \ / _` | | | | |/ _ \| | | | / / 
| |  | | (_) | (_| | |_| | |  __/| |_| |/ /  
|_|  |_|\___/ \__,_|\__,_|_|\___| \___//_/   
                                              
Building Web Applications with AI 🚀
EOF

echo ""
echo -e "${BLUE}Welcome to Module 07!${NC}"
echo -e "${GREEN}Your Codespace is ready for AI-powered development${NC}"
echo ""

# Check GitHub Copilot
echo -e "${YELLOW}Checking environment...${NC}"
echo -n "✓ GitHub Copilot: "
if code --list-extensions 2>/dev/null | grep -q "GitHub.copilot"; then
    echo -e "${GREEN}Active${NC}"
else
    echo -e "${RED}Not found${NC}"
fi

# Check Node.js
echo -n "✓ Node.js: "
node_version=$(node --version 2>/dev/null)
echo -e "${GREEN}$node_version${NC}"

# Check Python
echo -n "✓ Python: "
python_version=$(python --version 2>/dev/null)
echo -e "${GREEN}$python_version${NC}"

# Check ports
echo -n "✓ Available ports: "
echo -e "${GREEN}5173 (frontend), 8000 (backend)${NC}"

echo ""
echo -e "${PURPLE}📚 Quick Start Guide${NC}"
echo "========================"
echo ""
echo "1. Start with Exercise 1:"
echo -e "   ${BLUE}cd exercises/exercise-1-todo/starter${NC}"
echo -e "   ${BLUE}code README.md${NC}"
echo ""
echo "2. Use split terminals:"
echo "   • Terminal 1: Frontend (npm run dev)"
echo "   • Terminal 2: Backend (uvicorn main:app --reload)"
echo ""
echo "3. Let Copilot help you:"
echo "   • Write clear comments"
echo "   • Press Tab to accept suggestions"
echo "   • Use Ctrl+Enter for more options"
echo ""
echo -e "${YELLOW}💡 Pro Tips:${NC}"
echo "• Check the PORTS tab for URLs"
echo "• Save your best Copilot prompts"
echo "• Commit your progress frequently"
echo ""
echo -e "${GREEN}Ready to build amazing apps with AI! 🎉${NC}"
echo ""
echo "Type 'cd exercises/exercise-1-todo/starter' to begin..."
echo ""

# Create a quick help command
cat > ~/.module07-help << 'HELP'
echo "Module 07 Quick Commands:"
echo "========================"
echo ""
echo "Exercise 1 - Todo App:"
echo "  cd exercises/exercise-1-todo/starter"
echo ""
echo "Exercise 2 - Notes App:"
echo "  cd exercises/exercise-2-notes/starter"
echo ""
echo "Exercise 3 - Recipe AI:"
echo "  cd exercises/exercise-3-recipes/starter"
echo ""
echo "Start Frontend: npm run dev"
echo "Start Backend: uvicorn main:app --reload"
echo ""
echo "Copilot Tips:"
echo "  • Tab: Accept suggestion"
echo "  • Esc: Dismiss suggestion"
echo "  • Alt+]: Next suggestion"
echo "  • Ctrl+Enter: Open Copilot"
HELP

chmod +x ~/.module07-help
echo "alias m7help='~/.module07-help'" >> ~/.bashrc

# Create shortcuts
echo "alias ex1='cd /workspaces/\$RepositoryName/exercises/exercise-1-todo/starter'" >> ~/.bashrc
echo "alias ex2='cd /workspaces/\$RepositoryName/exercises/exercise-2-notes/starter'" >> ~/.bashrc
echo "alias ex3='cd /workspaces/\$RepositoryName/exercises/exercise-3-recipes/starter'" >> ~/.bashrc

echo -e "${BLUE}Shortcuts created: ex1, ex2, ex3, m7help${NC}"