Skip to content

Commit

Permalink
OY-4900: Korvataan lodashin _fp-funktiot tavallisilla lodash-funktioilla
Browse files Browse the repository at this point in the history
  • Loading branch information
heidilm committed Sep 3, 2024
1 parent be1612f commit 808de0b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/app/src/components/NumberInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import _fp from 'lodash/fp';
import { identity, isNaN, isNil, isNumber, noop, toString } from 'lodash';

import { Input, InputProps } from '#/src/components/virkailija';
import { parseFloatComma } from '#/src/utils';
Expand All @@ -14,25 +14,25 @@ type NumberInputProps = {
} & InputProps;

const floatToCommaStr = (value?: number | null) =>
_fp.isNil(value) ? '' : _fp.toString(value).replace('.', ',');
isNil(value) ? '' : toString(value).replace('.', ',');

const NumberInput = ({
onBlur = _fp.noop,
min = 0,
onBlur = noop,
min,
max,
fallbackValue = null,
parseValue = _fp.identity,
parseValue = identity,
...props
}: NumberInputProps) => {
const usedOnBlur = e => {
const value: string = e?.target?.value;
const floatValue = parseValue(value);
if (_fp.isNaN(floatValue) || _fp.isNil(floatValue)) {
if (isNaN(floatValue) || isNil(floatValue)) {
e.target.value = fallbackValue;
} else {
if (_fp.isNumber(max) && floatValue > max) {
if (isNumber(max) && floatValue > max) {
e.target.value = max;
} else if (_fp.isNumber(min) && floatValue < min) {
} else if (isNumber(min) && floatValue < min) {
e.target.value = min;
} else {
e.target.value = floatToCommaStr(floatValue);
Expand Down

0 comments on commit 808de0b

Please sign in to comment.