Skip to content

Commit 8dd319f

Browse files
Switch to use Command component
1 parent c910115 commit 8dd319f

File tree

5 files changed

+532
-237
lines changed

5 files changed

+532
-237
lines changed

packages/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"client-only": "^0.0.1",
7171
"clsx": "^2.1.1",
7272
"cm6-graphql": "^0.2.0",
73+
"cmdk": "1.0.0",
7374
"codemirror": "^5.65.3",
7475
"codemirror-lang-brainfuck": "^0.1.0",
7576
"codemirror-lang-elixir": "^4.0.0",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
'use client';
2+
import { Button } from "@/components/ui/button";
3+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
4+
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
5+
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
6+
import { Input } from "@/components/ui/input";
7+
import { zodResolver } from "@hookform/resolvers/zod";
8+
import { PlusCircledIcon } from "@radix-ui/react-icons";
9+
import { useForm } from "react-hook-form";
10+
import { z } from "zod";
11+
12+
const formSchema = z.object({
13+
name: z.string().min(2).max(40),
14+
});
15+
16+
17+
interface OrgCreationDialogProps {
18+
onSubmit: (data: z.infer<typeof formSchema>) => void;
19+
isOpen: boolean;
20+
onOpenChange: (isOpen: boolean) => void;
21+
}
22+
23+
export const OrgCreationDialog = ({
24+
onSubmit,
25+
isOpen,
26+
onOpenChange,
27+
}: OrgCreationDialogProps) => {
28+
const form = useForm<z.infer<typeof formSchema>>({
29+
resolver: zodResolver(formSchema),
30+
defaultValues: {
31+
name: "",
32+
},
33+
});
34+
35+
return (
36+
<Dialog
37+
open={isOpen}
38+
onOpenChange={onOpenChange}
39+
>
40+
<DialogTrigger asChild>
41+
<DropdownMenuItem
42+
onSelect={(e) => e.preventDefault()}
43+
>
44+
<Button
45+
variant="ghost"
46+
size="default"
47+
className="w-full justify-start gap-1.5 p-0"
48+
>
49+
<PlusCircledIcon className="h-5 w-5 text-muted-foreground" />
50+
Create organization
51+
</Button>
52+
</DropdownMenuItem>
53+
</DialogTrigger>
54+
<DialogContent>
55+
<DialogHeader>
56+
<DialogTitle>Create an organization</DialogTitle>
57+
<DialogDescription>Collaborate with</DialogDescription>
58+
</DialogHeader>
59+
<Form {...form}>
60+
<form onSubmit={form.handleSubmit(onSubmit)}>
61+
<FormField
62+
control={form.control}
63+
name="name"
64+
render={({ field }) => (
65+
<FormItem>
66+
<FormLabel>Organization name</FormLabel>
67+
<FormControl>
68+
<Input {...field} />
69+
</FormControl>
70+
<FormMessage />
71+
</FormItem>
72+
)}
73+
/>
74+
<Button className="mt-5" type="submit">Submit</Button>
75+
</form>
76+
</Form>
77+
</DialogContent>
78+
</Dialog>
79+
)
80+
}

0 commit comments

Comments
 (0)