<?php
declare(strict_types=1);

require_once __DIR__ . '/../../../security/auth_guard.php';
require_once __DIR__ . '/../../../config/database.php';
require_once __DIR__ . '/../../../core/Response.php';

$db = Database::getInstance();
$data = json_decode(file_get_contents('php://input'), true);

if (empty($data['category_id'])) {
    Response::error('category_id is required', 422);
}

$categoryId = (int)$data['category_id'];

$stmt = $db->prepare("SELECT id FROM faq_categories WHERE id = :id");
$stmt->execute(['id'=>$categoryId]);
if (!$stmt->fetch()) {
    Response::error('FAQ category not found', 404);
}

$stmt = $db->prepare("
    UPDATE faq_categories
    SET status = 'Active'
    WHERE id = :id
");
$stmt->execute(['id'=>$categoryId]);

Response::success('FAQ category activated successfully');
