2024-06-26 17:55:18 +00:00
|
|
|
|
|
|
|
"use client"
|
2024-06-30 15:36:44 +00:00
|
|
|
import { createSub } from "app/lib/create"
|
2024-06-26 17:55:18 +00:00
|
|
|
import { Dialog, DialogHeader, DialogTrigger, DialogContent, DialogClose, DialogTitle, DialogFooter, DialogDescription } from "@/components/ui/dialog";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
import { ComponentProps } from "react";
|
2024-06-30 15:36:44 +00:00
|
|
|
import { Pub, Response, Story } from "@prisma/client";
|
2024-06-26 17:55:18 +00:00
|
|
|
import SubmissionForm from "app/ui/forms/sub";
|
2024-09-24 11:32:26 +00:00
|
|
|
import { Plus } from "lucide-react";
|
2024-06-26 17:55:18 +00:00
|
|
|
|
|
|
|
|
2024-07-19 15:23:07 +00:00
|
|
|
type CreateSubDefaults = {
|
|
|
|
subId?: number,
|
|
|
|
storyId: number,
|
|
|
|
pubId: number,
|
|
|
|
submitted: Date,
|
|
|
|
responded: Date,
|
|
|
|
respoonseId: number
|
|
|
|
}
|
|
|
|
|
2024-07-23 15:40:35 +00:00
|
|
|
export default function CreateSubmissionDialog({ stories, pubs, responses, defaults }: ComponentProps<"div"> & { stories: Story[], pubs: Pub[], responses: Response[], defaults?: CreateSubDefaults }) {
|
2024-06-26 17:55:18 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog>
|
|
|
|
<DialogTrigger asChild>
|
2024-09-24 11:32:26 +00:00
|
|
|
<Button>
|
|
|
|
<span className="hidden md:block">Create new submission</span>
|
|
|
|
<Plus className="block md:hidden" />
|
|
|
|
</Button>
|
2024-06-26 17:55:18 +00:00
|
|
|
</DialogTrigger>
|
|
|
|
<DialogContent>
|
|
|
|
<DialogHeader>
|
2024-06-26 19:41:52 +00:00
|
|
|
<DialogTitle>New submission</DialogTitle>
|
2024-06-26 17:55:18 +00:00
|
|
|
<DialogDescription>Create an entry for a new story i.e. a thing you intend to submit for publication.</DialogDescription>
|
|
|
|
</DialogHeader>
|
2024-09-20 13:19:31 +00:00
|
|
|
<SubmissionForm pubs={pubs} responses={responses} stories={stories} defaults={defaults} />
|
2024-06-26 17:55:18 +00:00
|
|
|
<DialogFooter>
|
2024-06-30 15:36:44 +00:00
|
|
|
<DialogClose asChild>
|
|
|
|
</DialogClose>
|
2024-06-26 17:55:18 +00:00
|
|
|
<Button form="subform">Submit</Button>
|
|
|
|
</DialogFooter>
|
|
|
|
</DialogContent>
|
|
|
|
</Dialog>
|
|
|
|
)
|
|
|
|
}
|