subman-nextjs/src/app/publication/create.tsx

41 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-06-26 17:32:18 +00:00
"use client"
import { Dialog, DialogHeader, DialogTrigger, DialogContent, DialogClose, DialogTitle, DialogFooter, DialogDescription } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { ComponentProps } from "react";
import { Genre } from "@prisma/client";
import { createPub } from "app/lib/create";
import PubForm from "app/ui/forms/pub";
import { Plus } from "lucide-react";
2024-09-25 16:48:03 +00:00
import { useState } from "react";
2024-06-26 17:32:18 +00:00
export default function CreatePubDialog({ genres }: ComponentProps<"div"> & { genres: Genre[] }) {
2024-09-25 16:48:03 +00:00
const [isOpen, setIsOpen] = useState(false)
function closeDialog() {
setIsOpen(false)
}
2024-06-26 17:32:18 +00:00
return (
2024-09-25 16:48:03 +00:00
<Dialog open={isOpen} onOpenChange={setIsOpen}>
2024-06-26 17:32:18 +00:00
<DialogTrigger asChild>
<Button>
<span className="hidden md:block">Create new publication</span>
<Plus className="block md:hidden" />
</Button>
2024-06-26 17:32:18 +00:00
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>New publication</DialogTitle>
<DialogDescription>Create an entry for a new publication i.e. a place you intend to submit stories to.</DialogDescription>
</DialogHeader>
2024-09-25 16:48:03 +00:00
<PubForm createPub={createPub} genres={genres} closeDialog={closeDialog} />
2024-06-26 17:32:18 +00:00
<DialogFooter>
2024-09-25 16:48:03 +00:00
<Button form="pubform">Submit</Button>
2024-06-26 17:32:18 +00:00
</DialogFooter>
</DialogContent>
</Dialog>
)
}