<?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"]);

$sql = "INSERT INTO custom_fields (project_id, name, type)
        VALUES (?, ?, ?)";
sqlsrv_query($conn, $sql, [
    $data["project_id"],
    $data["name"],
    $data["type"]
]);

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