"use client"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { useMediaQuery } from "@/hooks/use-media-query"; import React, { useEffect } from "react"; import { FileUploader } from "@/components/file-uploader"; import { Calendar } from "@/components/ui/calendar"; import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/utils"; import { OfferCredentials, OfferValidator } from "@/lib/validators/offer"; import { zodResolver } from "@hookform/resolvers/zod"; import { format } from "date-fns"; import { CalendarIcon } from "lucide-react"; import { useForm } from "react-hook-form"; import { BsMarkdown } from "react-icons/bs"; import { toast } from "sonner"; import { createOfferAction } from "./actions"; function CreateDealModal() { const [open, setOpen] = React.useState(false); const isDesktop = useMediaQuery("(min-width: 768px)"); if (isDesktop) { return ( Create Offer Create an offer. setOpen(false)} /> ); } return ( Create Offer Create an offer. setOpen(false)} /> ); } interface ProfileFormProps extends React.ComponentProps<"form"> { close: () => void; } function ProfileForm({ className, close }: ProfileFormProps) { const currentDate = new Date(); const form = useForm({ resolver: zodResolver(OfferValidator), defaultValues: { title: "", creditAmount: "0", description: "", content: "", expiryDate: new Date(currentDate.getTime() + 7 * 24 * 60 * 60 * 1000), }, }); useEffect(() => { console.log(form.formState.errors); }, [form.formState.errors]); const onSubmit = async (data: OfferCredentials) => { console.log("running"); // try { await createOfferAction(data); console.log("ok"); toast.success("Success", { description: "Successfully created offer!", }); // } catch (err) { // if (err instanceof Error) toast.error(err.message); // } }; return (
( Title )} />
( Amount )} />
( Description )} /> ( Content