import { AppShell } from "@/components/app-shell";
import { EmptyState, PageHeader, Panel, StatusDot } from "@/components/ui";
import { logoutUser } from "@/lib/user-actions";
import { getShellContext } from "@/lib/shell";
import { requireCurrentUser } from "@/lib/session";
import { requireInitialSetup } from "@/lib/setup";

export const dynamic = "force-dynamic";

export default async function SessionsPage() {
  await requireInitialSetup();
  const user = await requireCurrentUser();
  const shell = await getShellContext(user);

  return (
    <AppShell active="Overview" {...shell}>
      <PageHeader
        title="Sessions"
        description="Current login state and session controls."
        meta={<StatusDot tone="good" label="current session active" />}
        actions={
          <form action={logoutUser}>
            <button className="button" type="submit">Logout current session</button>
          </form>
        }
      />
      <Panel title="Session Management" eyebrow="HTTP-only cookie">
        <EmptyState title="Only the current session is tracked" description="A persisted session table can be added later for device-level revoke controls." />
      </Panel>
    </AppShell>
  );
}
