"use client" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog" import { z } from "zod" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form" import { Input } from "@/components/ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { Loader2, UserPlus, X } from "lucide-react" import { useState, useTransition } from "react" import { Sandbox } from "@/lib/types" import { Button } from "@/components/ui/button" import Avatar from "@/components/ui/avatar" import { shareSandbox } from "@/lib/actions" import { toast } from "sonner" const formSchema = z.object({ email: z.string().email(), }) export default function ShareSandboxModal({ open, setOpen, data, }: { open: boolean setOpen: (open: boolean) => void data: Sandbox }) { const [loading, setLoading] = useState(false) const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { email: "", }, }) async function onSubmit(values: z.infer) { // if (!user.isSignedIn) return // const sandboxData = { type: selected, userId: user.user.id, ...values } // setLoading(true) // const id = await createSandbox(sandboxData) console.log(values) setLoading(true) const res = await shareSandbox(data.id, values.email) if (!res) { toast.error("Failed to share.") } setLoading(false) } return (
Share Sandbox
( )} />
Manage Access
Ishaan Dey
) }