import React, { useState } from "react"; import { Box, Button, Flex, Input, Stack, Text, useRadioGroup, } from "@chakra-ui/react"; import { useFormContext } from "react-hook-form"; import { FormControlWithError } from "./FormControlWithError"; import { RadioCard } from "./RadioCard"; export interface ITokenIntervalFormProps { interval: number; } export const TokenIntervalInputs = () => { const { watch, formState: { errors }, register, setValue, } = useFormContext(); const [isManualEntry, setIsManualEntry] = useState(false); const { getRootProps, getRadioProps } = useRadioGroup({ name: "interval", onChange: (value) => setValue("interval", +value), }); const interval = watch("interval"); const group = getRootProps(); const intervalOptions = [ { value: 1800, heading: "30 Minutes" }, { value: 3600, heading: "1 Hour" }, { value: 10800, heading: "3 Hours" }, { value: 43200, heading: "12 Hours" }, { value: 86400, heading: "1 Day" }, { value: 259200, heading: "3 Days" }, ]; return ( <> {intervalOptions.map(({ value, heading }) => { const radio = getRadioProps({ value }); return ( {heading} ); })} {!isManualEntry && ( )} {isManualEntry && ( <> Any value less than 15 Minutes (900 seconds) will result in the initial price dropping fast. )} ); };