update slider amount prop type

This commit is contained in:
saml33 2022-08-18 14:25:30 +10:00
parent b82259d17f
commit 0f7a1b2ad4
3 changed files with 9 additions and 9 deletions

View File

@ -177,7 +177,7 @@ function BorrowModal({ isOpen, onClose, token }: ModalCombinedProps) {
<p className="text-th-fgd-3">0.00x</p> <p className="text-th-fgd-3">0.00x</p>
</div> </div>
<BorrowLeverageSlider <BorrowLeverageSlider
amount={new Decimal(inputAmount)} amount={inputAmount}
tokenMax={tokenMax} tokenMax={tokenMax}
onChange={(x) => setInputAmount(x)} onChange={(x) => setInputAmount(x)}
/> />

View File

@ -4,7 +4,7 @@ import mangoStore from '../../store/state'
import Decimal from 'decimal.js' import Decimal from 'decimal.js'
type LeverageSliderProps = { type LeverageSliderProps = {
amount: Decimal amount: string
inputToken?: string inputToken?: string
outputToken?: string outputToken?: string
onChange: (x: string) => void onChange: (x: string) => void
@ -15,11 +15,11 @@ const LeverageSlider = ({
leverageMax, leverageMax,
onChange, onChange,
}: { }: {
amount: Decimal amount: string
leverageMax: number leverageMax: number
onChange: (x: any) => any onChange: (x: any) => any
}) => { }) => {
const [value, setValue] = useState<Decimal>(new Decimal(0)) const [value, setValue] = useState('')
const inputEl = useRef<HTMLInputElement>(null) const inputEl = useRef<HTMLInputElement>(null)
useEffect(() => { useEffect(() => {
@ -31,7 +31,7 @@ const LeverageSlider = ({
target.style.backgroundSize = target.style.backgroundSize =
max - min === 0 max - min === 0
? '0% 100%' ? '0% 100%'
: ((value.toNumber() - min) * 100) / (max - min) + '% 100%' : ((parseFloat(value) - min) * 100) / (max - min) + '% 100%'
} }
}, [leverageMax, value]) }, [leverageMax, value])
@ -49,7 +49,7 @@ const LeverageSlider = ({
target.style.backgroundSize = ((val - min) * 100) / (max - min) + '% 100%' target.style.backgroundSize = ((val - min) * 100) / (max - min) + '% 100%'
onChange(e.target.value) onChange(e.target.value)
setValue(new Decimal(e.target.value)) setValue(e.target.value)
} }
return ( return (
@ -64,7 +64,7 @@ const LeverageSlider = ({
step={0.000001} step={0.000001}
className="w-full" className="w-full"
onChange={handleSliderChange} onChange={handleSliderChange}
value={value.toNumber()} value={value}
></input> ></input>
</> </>
) )
@ -116,7 +116,7 @@ export const BorrowLeverageSlider = ({
tokenMax, tokenMax,
onChange, onChange,
}: { }: {
amount: Decimal amount: string
tokenMax: number tokenMax: number
onChange: (x: any) => any onChange: (x: any) => any
}) => { }) => {

View File

@ -320,7 +320,7 @@ const Swap = () => {
<p className="text-th-fgd-1">0.00x</p> <p className="text-th-fgd-1">0.00x</p>
</div> </div>
<SwapLeverageSlider <SwapLeverageSlider
amount={amountIn} amount={amountIn.toString()}
inputToken={inputToken} inputToken={inputToken}
outputToken={outputToken} outputToken={outputToken}
onChange={(x) => setAmountInformValue(x)} onChange={(x) => setAmountInformValue(x)}