import { useState } from "react"; import { ButtonModal, ButtonBorderGradient } from "../Buttons"; import { AdjustmentsIcon, InformationCircleIcon } from "@heroicons/react/solid"; import clsx from "clsx"; const OPTIONS = [1, 5, 10]; export const Slippage = ({ slippage, setSlippage, }: { slippage: number; setSlippage: (arg: number) => void; }) => { const [input, setInput] = useState(null); const [visible, setVisible] = useState(false); const custom = !OPTIONS.includes(input || -1); const canSubmit = !custom || (custom && input && input > 0 && input < 500); const handleSave = () => { input && setSlippage(input); setVisible(false); }; return ( {slippage / 10} % } >

Slippage settings

{OPTIONS.map((e) => { return ( setInput(e)} buttonClass="bg-black p-2 uppercase font-bold h-[50px] w-full" fromColor={input === e ? "green-400" : "none"} toColor="blue-500" containerClass="w-1/3 mx-2" > {e / 10}% ); })}
setInput(10 * parseFloat(e.target.value.trim()))} placeholder="0.00 %" value={(input || 0) / 10} type="number" max={100} min={0} className="w-full h-full pr-10 text-lg font-bold text-right rounded-[5px] bg-neutral focus:outline-none" /> %
{!canSubmit && (
Slippage must be between 0 and 50
)}
Save settings
); };