<?php
require_once '../config.php';
require_once '../../includes/Auth.php';
require_once '../../includes/Order.php';

$auth = new Auth();
$user = $auth->requireAuth();

$order = new Order();

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    try {
        $orders = $order->getUserOrders($user['id']);
        jsonResponse(['success' => true, 'orders' => $orders]);
    } catch (Exception $e) {
        jsonResponse(['success' => false, 'message' => $e->getMessage()], 500);
    }
} else {
    jsonResponse(['success' => false, 'message' => 'Method not allowed'], 405);
}
?>