<?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 = "UPDATE subtasks
        SET title = ?, is_completed = ?
        WHERE id = ?";
sqlsrv_query($conn, $sql, [
    $data["title"],
    $data["is_completed"],
    $data["id"]
]);

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