@echo off
REM LuckyChit Backend Setup and Test Script for Windows
REM This script installs dependencies and tests the WhatsApp & Reminder features

echo.
echo ===================================
echo   LuckyChit Backend Setup Script
echo ===================================
echo.

REM Check if Node.js is installed
where node >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo Error: Node.js is not installed
    echo Please install Node.js from https://nodejs.org/
    pause
    exit /b 1
)

echo Node.js version:
node --version
echo NPM version:
npm --version
echo.

REM Install dependencies
echo Installing dependencies...
call npm install

if %ERRORLEVEL% EQU 0 (
    echo Dependencies installed successfully
) else (
    echo Failed to install dependencies
    pause
    exit /b 1
)

echo.
echo Checking new packages...
call npm list node-cron 2>nul | findstr "node-cron"
call npm list moment-timezone 2>nul | findstr "moment-timezone"
echo.

REM Check if .env file exists
if not exist .env (
    echo .env file not found
    echo Creating .env from env.example...
    if exist env.example (
        copy env.example .env >nul
        echo .env file created
        echo Please update .env with your database credentials
    ) else (
        echo env.example not found
        echo Please create .env file manually
    )
) else (
    echo .env file exists
)

echo.
echo ===================================
echo   Setup Complete!
echo ===================================
echo.
echo Next Steps:
echo   1. Update .env file with your database credentials
echo   2. Run: npm run dev
echo   3. Test APIs at: http://localhost:3000/api
echo.
echo New Features:
echo   - WhatsApp Share: http://localhost:3000/api/share
echo   - Notifications: http://localhost:3000/api/notifications
echo   - Payment Reminders: Automated at 9:00 AM IST daily
echo.
echo Documentation:
echo   - WHATSAPP_USAGE_EXAMPLES.md
echo   - API_DOCUMENTATION.md
echo.
echo Ready to launch!
echo.
pause

