<?php
require_once __DIR__ . "/../auth/require-auth.php";
require_once __DIR__ . "/../services/db.php";

$taskId = $_GET["task"];

$sql = "SELECT d.*, t.title AS depends_on_title
        FROM task_dependencies d
        JOIN tasks t ON d.depends_on_task_id = t.id
        WHERE d.task_id = ?";
$stmt = sqlsrv_query($conn, $sql, [$taskId]);

$items = [];
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
    $items[] = $row;
}

echo json_encode($items);
