<?php
include '../includes/auth.php';
include '../includes/db.php';

$event_id = $_GET['event_id'] ?? null;

if ($event_id) {
    $heats_stmt = $pdo->prepare("
        SELECT heat_number, heat_name 
        FROM event_heat_settings 
        WHERE event_id = ? 
        ORDER BY heat_number
    ");
    $heats_stmt->execute([$event_id]);
    $heats = $heats_stmt->fetchAll(PDO::FETCH_ASSOC);
    
    header('Content-Type: application/json');
    echo json_encode($heats);
} else {
    header('Content-Type: application/json');
    echo json_encode([]);
}
?>