Skip to content

Commit

Permalink
fix(currency-input): Fix currency input type to not allow null
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomateus committed Nov 27, 2023
1 parent 62e7844 commit 5663501
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lib/components/input/currency/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { formatInput, reverseFormatInput } from './format';
import { Input, InputProps } from '..';

export type CurrencyInputProps = {
value?: number | null | undefined;
value?: number;
placeholder?: string;
onChange?: (value: number | null) => void;
onChange?: (value: number) => void;
} & Omit<InputProps, 'onChange' | 'value' | 'ref'>

const CurrencyInput = ({
Expand Down Expand Up @@ -38,7 +38,7 @@ const CurrencyInput = ({

useEffect(() => {
if (shadowValue === '' && value) {
onChange?.(null)
onChange?.(0);
} else if (shadowValue) {
onChange?.(reverseFormatInput(shadowValue));
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/input/currency/input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const CurrencyInputStory = ({
prefix,
error
}: CurrencyInputProps) => {
const [newValue, setValue] = useState<number | null>(Number);
const [newValue, setValue] = useState<number>(Number);

const handleOnChange = (value: number | null) => {
const handleOnChange = (value: number) => {
setValue(value)
onChange?.(value);
}
Expand Down

0 comments on commit 5663501

Please sign in to comment.