# Deploy FINAL dos 19 endpoints restantes
Write-Host "Deployando os 19 endpoints finais..." -ForegroundColor Cyan

$endpoints = @(
    "availability-create",
    "availability-update",
    "availability-delete",
    "exceptions-delete",
    "waitlist-remove",
    "reports-export-csv",
    "reports-integrity-check",
    "doctor-occupancy",
    "doctor-delay-suggestion",
    "patients-preferences",
    "patients-portal",
    "analytics-demand-curve",
    "analytics-ranking-reasons",
    "analytics-monthly-no-show",
    "analytics-specialty-heatmap",
    "analytics-custom-report",
    "system-health-check",
    "system-cache-rebuild",
    "system-cron-runner"
)

$total = $endpoints.Count
$current = 0
$success = 0
$failed = 0

foreach ($endpoint in $endpoints) {
    $current++
    Write-Host "[$current/$total] Deploying $endpoint..." -ForegroundColor Yellow
    
    pnpx supabase functions deploy $endpoint --no-verify-jwt 2>&1 | Out-Null
    
    if ($LASTEXITCODE -eq 0) {
        Write-Host "  OK $endpoint deployed" -ForegroundColor Green
        $success++
    } else {
        Write-Host "  FAIL $endpoint failed" -ForegroundColor Red
        $failed++
    }
}

Write-Host ""
Write-Host "Deploy concluido!" -ForegroundColor Cyan
Write-Host "Sucesso: $success" -ForegroundColor Green
Write-Host "Falhas: $failed" -ForegroundColor Red

Write-Host ""
Write-Host "Verificando status final..." -ForegroundColor Cyan
pnpx supabase functions list
