/**
 * Orders Page - List and detail view
 */

import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import OrderList from '../components/orders/OrderList';
import OrderDetail from '../components/orders/OrderDetail';

export default function OrdersPage({ initialData }) {
    const [selectedOrderId, setSelectedOrderId] = useState(null);

    if (selectedOrderId) {
        return (
            <OrderDetail
                orderId={selectedOrderId}
                onBack={() => setSelectedOrderId(null)}
            />
        );
    }

    return (
        <OrderList
            onSelectOrder={(orderId) => setSelectedOrderId(orderId)}
        />
    );
}
