import { getServerApi } from '@garage/api/server'
import { PurchaseOrderGeneralInfo } from '@/modules/purchase-orders/purchase-order-general-info'
import DashboardPage from '@/base/components/layout/dashboard/dashboard-page'

export default async function page(props: { params: Promise<{ id: string }> }) {
    const { id } = await props.params
    const api = await getServerApi()
    const response = await api.purchaseOrders.getById(id)

    const purchaseOrder = (response as any)?.data ?? response

    if (!purchaseOrder) {
        return <div className="text-muted-foreground">Purchase order not found.</div>
    }

    return (
        <DashboardPage header={null}>
            <PurchaseOrderGeneralInfo purchaseOrder={purchaseOrder} />
        </DashboardPage>
    )
}
