import { getGenres, getPubs, getResponses, getStories, getSubsComplete } from "app/lib/get"
import { DataTable } from "app/ui/tables/data-table"
import { columns } from "./columns"
import { Pub, Response, Story, Sub } from "@prisma/client"
import CreateSubmissionDialog from "./create"

export type SubComplete = Sub & {
  pub: Pub,
  story: Story,
  response: Response
}
export default async function Page() {

  const subs: Array<SubComplete> = await getSubsComplete()
  const stories = await getStories()
  const pubs = await getPubs()
  const responses = await getResponses()
  const genres = await getGenres()

  return (
    <div className="container">
      <DataTable data={subs} columns={columns} tableName="sub"
        stories={stories}
        pubs={pubs}
        responses={responses}
        genres={genres}
      >
        <CreateSubmissionDialog
          stories={stories}
          pubs={pubs}
          responses={responses}
        />
      </DataTable>
    </div>
  )
}
