Commit 7125562c authored by aballerr's avatar aballerr Committed by GitHub

fix: fixing issue with decimal in price range (#4784)

* fixing issue with decimal in price range
parent 1361f996
...@@ -2,7 +2,6 @@ import { Row } from 'nft/components/Flex' ...@@ -2,7 +2,6 @@ import { Row } from 'nft/components/Flex'
import { NumericInput } from 'nft/components/layout/Input' import { NumericInput } from 'nft/components/layout/Input'
import { useIsMobile } from 'nft/hooks' import { useIsMobile } from 'nft/hooks'
import { useCollectionFilters } from 'nft/hooks/useCollectionFilters' import { useCollectionFilters } from 'nft/hooks/useCollectionFilters'
import { isNumber } from 'nft/utils/numbers'
import { scrollToTop } from 'nft/utils/scrollToTop' import { scrollToTop } from 'nft/utils/scrollToTop'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { FocusEventHandler, FormEvent } from 'react' import { FocusEventHandler, FormEvent } from 'react'
...@@ -50,7 +49,7 @@ export const PriceRange = () => { ...@@ -50,7 +49,7 @@ export const PriceRange = () => {
defaultValue={minPrice} defaultValue={minPrice}
onChange={(v: FormEvent<HTMLInputElement>) => { onChange={(v: FormEvent<HTMLInputElement>) => {
scrollToTop() scrollToTop()
setMinPrice(isNumber(v.currentTarget.value) ? parseFloat(v.currentTarget.value) : '') setMinPrice(v.currentTarget.value)
}} }}
onFocus={handleFocus} onFocus={handleFocus}
value={minPrice} value={minPrice}
...@@ -74,7 +73,7 @@ export const PriceRange = () => { ...@@ -74,7 +73,7 @@ export const PriceRange = () => {
value={maxPrice} value={maxPrice}
onChange={(v: FormEvent<HTMLInputElement>) => { onChange={(v: FormEvent<HTMLInputElement>) => {
scrollToTop() scrollToTop()
setMaxPrice(isNumber(v.currentTarget.value) ? parseFloat(v.currentTarget.value) : '') setMaxPrice(v.currentTarget.value)
}} }}
onFocus={handleFocus} onFocus={handleFocus}
onBlur={handleBlur} onBlur={handleBlur}
......
...@@ -29,6 +29,10 @@ export const NumericInput = forwardRef<HTMLInputElement, BoxProps>((props, ref) ...@@ -29,6 +29,10 @@ export const NumericInput = forwardRef<HTMLInputElement, BoxProps>((props, ref)
autoComplete="off" autoComplete="off"
type="text" type="text"
onInput={(v: FormEvent<HTMLInputElement>) => { onInput={(v: FormEvent<HTMLInputElement>) => {
if (v.currentTarget.value === '.') {
v.currentTarget.value = '0.'
}
v.currentTarget.value = v.currentTarget.value =
!!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0 !!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
? v.currentTarget.value ? v.currentTarget.value
......
...@@ -25,8 +25,8 @@ export type Trait = { ...@@ -25,8 +25,8 @@ export type Trait = {
interface State { interface State {
traits: Trait[] traits: Trait[]
markets: string[] markets: string[]
minPrice: number | '' minPrice: string
maxPrice: number | '' maxPrice: string
minRarity: number | '' minRarity: number | ''
maxRarity: number | '' maxRarity: number | ''
marketCount: Record<string, number> marketCount: Record<string, number>
...@@ -43,8 +43,8 @@ type Actions = { ...@@ -43,8 +43,8 @@ type Actions = {
addTrait: (trait: Trait) => void addTrait: (trait: Trait) => void
removeTrait: (trait: Trait) => void removeTrait: (trait: Trait) => void
reset: () => void reset: () => void
setMinPrice: (price: number | '') => void setMinPrice: (price: string) => void
setMaxPrice: (price: number | '') => void setMaxPrice: (price: string) => void
setMinRarity: (range: number | '') => void setMinRarity: (range: number | '') => void
setMaxRarity: (range: number | '') => void setMaxRarity: (range: number | '') => void
setBuyNow: (bool: boolean) => void setBuyNow: (bool: boolean) => void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment