42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
|
|
"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";
|
|
import { Plus } from "lucide-react";
|
|
import { useState } from "react";
|
|
|
|
|
|
|
|
export default function CreateSubmissionDialog({ stories, pubs, responses }: ComponentProps<"div"> & { stories: Story[], pubs: Pub[], responses: Response[] }) {
|
|
|
|
const [isOpen, setIsOpen] = useState(false)
|
|
function closeDialog() {
|
|
setIsOpen(false)
|
|
}
|
|
|
|
return (
|
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
|
<DialogTrigger asChild>
|
|
<Button>
|
|
<span className="hidden md:block">Create new submission</span>
|
|
<Plus className="block md:hidden" />
|
|
</Button>
|
|
</DialogTrigger>
|
|
<DialogContent className="text-xs md:text-sm">
|
|
<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 pubs={pubs} responses={responses} stories={stories} closeDialog={closeDialog} />
|
|
<DialogFooter>
|
|
<Button form="subform">Submit</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|