import React from "react"; import { useForm } from "react-hook-form"; import * as yup from "yup"; import { yupResolver } from "@hookform/resolvers/yup"; import { FormControlWithError } from "../form/FormControlWithError"; import { Stack, Text, Input, ButtonGroup, Button } from "@chakra-ui/react"; export interface INFTFormValues { type: "nft"; amount: number; collectionKey: string; } interface INFTFormProps { defaultValues?: any; onSubmit: (data: any) => void; onBack: () => void; } const validationSchema = yup .object({ collectionKey: yup.string().required(), }) .required(); export const NFTForm: React.FC = ({ onSubmit, onBack, defaultValues = {}, }) => { const { handleSubmit, setValue, register, watch, formState: { errors }, } = useForm({ mode: "onChange", resolver: yupResolver(validationSchema), defaultValues, }); const { collectionKey } = watch(); const inputBg = { bg: "gray.200", _dark: { bg: "gray.800" } }; const handleOnSubmit = (data: any) => { onSubmit({ type: "nft", amount: 1, // Hardcoded 1 for now ...data, }); }; return (
); };