<?php
declare(strict_types=1);

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

$db = Database::getInstance();

$productId = (int)($_GET['product_id'] ?? 0);

$stmt = $db->prepare("
    SELECT *
    FROM retail_product_sections
    WHERE product_id = :pid
    ORDER BY priority ASC
");
$stmt->execute(['pid'=>$productId]);

Response::success('Sections fetched', [
    'sections'=>$stmt->fetchAll(PDO::FETCH_ASSOC)
]);
