// PBI-11 / ST-1138: Mobile Solo Paneel — wraps de bestaande SoloBoard zonder
// content-aanpassingen. 3-koloms-kanban blijft (overflow-x scrollt zijwaarts).
// TaskDetailDialog krijgt full-screen-mobile via gedeelde
// entityDialogContentClasses (beslissing A in docs/plans/PBI-11-mobile-shell.md;
// ingebouwd via ST-1133/T-317).

import { notFound } from 'next/navigation'
import { getAccessibleProduct } from '@/lib/product-access'
import { requireSession } from '@/lib/auth-guard'
import { getSoloWorkspaceSnapshot } from '@/lib/solo-workspace-server'
import { SoloBoard } from '@/components/solo/solo-board'
import { SoloHydrationWrapper } from '@/components/solo/solo-hydration-wrapper'
import { NoActiveSprint } from '@/components/solo/no-active-sprint'

interface Props {
  params: Promise<{ id: string }>
}

export default async function MobileSoloProductPage({ params }: Props) {
  const { id } = await params
  const session = await requireSession()

  const product = await getAccessibleProduct(id, session.userId)
  if (!product) notFound()

  const initialData = await getSoloWorkspaceSnapshot(id, session.userId)

  if (!initialData) {
    return (
      <div className="flex flex-col h-full">
        <NoActiveSprint productId={id} productName={product.name} />
      </div>
    )
  }

  return (
    <SoloHydrationWrapper initialData={initialData}>
      <SoloBoard
        key={initialData.sprint.id}
        productId={id}
        sprintGoal={initialData.sprint.sprint_goal}
        isDemo={session.isDemo ?? false}
        repoUrl={product.repo_url}
      />
    </SoloHydrationWrapper>
  )
}
