"use client"

import { useT } from "@/components/locale-provider"
import { DataTable } from "@/components/ui/data-table"
import type { PersonRow } from "@/lib/services/people"
import { peopleColumns } from "./columns"
import { PeopleSearch } from "./people-search"

/**
 * The rows arrive already narrowed by the page, because the search term lives
 * in the url. Sorting and paging stay here: they concern only the person
 * looking, and nobody sends a link to page three.
 */
export function PeopleTable({ rows }: { rows: PersonRow[] }) {
  const t = useT()

  return (
    <DataTable
      columns={peopleColumns(t)}
      data={rows}
      empty={t("people.none")}
      toolbar={() => <PeopleSearch />}
    />
  )
}
