import { Button, FormControl, FormErrorMessage, FormHelperText, FormLabel, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, Select, Textarea, useToast, } from "@chakra-ui/react"; import { zodResolver } from "@hookform/resolvers/zod"; import UserSelector from "components/common/UserSelector"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; import { getToastOptions } from "utils/objects"; import { trpc } from "utils/trpc"; import { suggestionFullSchema, SUGGESTION_DESCRIPTION_LIMIT, } from "utils/validators/suggestion"; import * as z from "zod"; interface Props { userPlusMembershipTier: number; } type FormData = z.infer; const SuggestionModal: React.FC = ({ userPlusMembershipTier }) => { const toast = useToast(); const [isOpen, setIsOpen] = useState(false); const { handleSubmit, errors, register, watch, control } = useForm({ resolver: zodResolver(suggestionFullSchema), }); const utils = trpc.useQueryUtils(); const { mutate, status } = trpc.useMutation("plus.suggestion", { onSuccess() { toast(getToastOptions("New suggestion submitted", "success")); utils.invalidateQuery(["plus.suggestions"]); setIsOpen(false); }, onError(error) { toast(getToastOptions(error.message, "error")); }, }); const watchDescription = watch("description", ""); return ( <> {isOpen && ( setIsOpen(false)} size="xl" closeOnOverlayClick={false} > Adding a new suggestion
mutate(data))}> Tier ( )} /> User ( )} /> {errors.suggestedId?.message} Region If the player isn't from either region then choose the one they play most commonly with. Description