"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, { SubForm } from "app/ui/forms/sub";



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

  return (
    <Dialog>
      <DialogTrigger className="w-full h-full">
        {children}
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Edit Submission</DialogTitle>
          <DialogDescription>Change response status, edit dates etc</DialogDescription>
        </DialogHeader>
        <SubmissionForm createSub={createSub} pubs={pubs} responses={responses} stories={stories} defaults={defaults} />
        <DialogFooter>
          <DialogClose asChild>
          </DialogClose>
          <Button form="subform">Submit</Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  )
}
