'use client'; import { X } from 'lucide-react'; import { toast } from 'sonner'; import { useRef } from 'react'; import { useRouter } from 'next/navigation'; import { Popover, PopoverClose, PopoverContent, PopoverTrigger, } from '@/components/ui/popover'; import { useAction } from '@/hooks/use-action'; import { createBoard } from '@/actions/create-board'; import { Button } from '@/components//ui/button'; import { useProModal } from '@/hooks/use-pro-modal'; import { FormInput } from './form-input'; import { FormSubmit } from './form-submit'; import { FormPicker } from './form-picker'; import Link from 'next/link'; interface FormPopoverProps { children: React.ReactNode; side?: 'left' | 'right' | 'top' | 'bottom'; align?: 'center' | 'start' | 'end'; sideOffset?: number; } export const FormPopover = ({ children, side = 'bottom', align, sideOffset = 0, }: FormPopoverProps) => { const proModal = useProModal(); const router = useRouter(); const closeRef = useRef(null); const { execute, fieldErrors } = useAction(createBoard, { onSuccess: (data) => { toast.success('Board created'); closeRef.current?.click(); router.push(`/board/${data.id}`); }, onError: (error) => { toast.error(error); proModal.onOpen(); }, }); const onSubmit = (formData: FormData) => { const title = formData.get('title') as string; const image = formData.get('image') as string; execute({ title, image }); }; return ( {children}
Create board

Images Provided by{' '} Unsplash

Create
); };