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

$data = json_decode(file_get_contents("php://input"), true);

requireProjectRole($conn, $data["project_id"], ["owner", "member"]);

$sql = "INSERT INTO task_dependencies (task_id, depends_on_task_id)
        VALUES (?, ?)";
sqlsrv_query($conn, $sql, [
    $data["task_id"],
    $data["depends_on_task_id"]
]);

echo json_encode(["success" => true]);
