import { useForm } from "react-hook-form"; import { faRocketchat } from "@fortawesome/free-brands-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Popover, PopoverContent, PopoverTrigger, TextArea } from "@app/components/v2"; import { useToggle } from "@app/hooks"; import { useCreateUserWish } from "@app/hooks/api/userEngagement"; const formSchema = z.object({ text: z.string().trim().min(1) }); type TFormData = z.infer; export const WishForm = () => { const { handleSubmit, register, reset, formState: { isSubmitting, errors } } = useForm({ resolver: zodResolver(formSchema) }); const { mutateAsync } = useCreateUserWish(); const [isOpen, setIsOpen] = useToggle(false); const createWish = async (data: TFormData) => { try { await mutateAsync({ text: data.text }); createNotification({ text: "Your wish has been sent to the Infisical team!", type: "success" }); setIsOpen.off(); } catch (err) { createNotification({ text: "An error occured while sending your wish to the Infisical team.", type: "error" }); } }; return ( { setIsOpen.toggle(); reset(); }} open={isOpen} >
Make a wish