<?php
require_once '../includes/auth.php';

$auth = new Auth();
$auth->requireLogin();

echo "<h1>品牌管理測試頁面</h1>";
echo "<p>當前用戶: " . $_SESSION['username'] . "</p>";

// Test API call
echo "<h2>測試API調用</h2>";
echo "<button onclick='testAPI()'>測試API</button>";
echo "<div id='result'></div>";

echo "<script>
async function testAPI() {
    try {
        const response = await fetch('/api/brands.php', {
            credentials: 'same-origin'
        });
        const result = await response.json();
        document.getElementById('result').innerHTML = '<pre>' + JSON.stringify(result, null, 2) + '</pre>';
    } catch (error) {
        document.getElementById('result').innerHTML = '錯誤: ' + error.message;
    }
}
</script>";
?>
