
"use client"
import { createSub } from "app/lib/create"
import { Dialog, DialogHeader, DialogTrigger, DialogContent, DialogClose, DialogTitle, DialogFooter, DialogDescription } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { ComponentProps } from "react";
import { Pub, Response, Story } from "@prisma/client";
import SubmissionForm from "app/ui/forms/sub";


export default function CreateSubmissionDialog({ stories, pubs, responses }: ComponentProps<"div"> & { stories: Story[], pubs: Pub[], responses: Response[] }) {

  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button>Create new submission</Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>New submission</DialogTitle>
          <DialogDescription>Create an entry for a new story i.e. a thing you intend to submit for publication.</DialogDescription>
        </DialogHeader>
        <SubmissionForm createSub={createSub} pubs={pubs} responses={responses} stories={stories} />
        <DialogFooter>
          <DialogClose asChild>
          </DialogClose>
          <Button form="subform">Submit</Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  )
}
