duration sanitized
This commit is contained in:
parent
21cc74d363
commit
9b406cda51
1 changed files with 31 additions and 9 deletions
|
|
@ -1,12 +1,34 @@
|
||||||
import BaseInput from "./BaseInput";
|
import BaseInput from "./BaseInput";
|
||||||
|
import OnlyDigitsEventMiddleware from "../eventMiddlewares/OnlyDigitsEventMiddleware";
|
||||||
|
import MinMaxEventMiddleware from "../eventMiddlewares/MinMaxEventMiddleware";
|
||||||
|
|
||||||
const LoanDurationInput = ({ onChangeCallback, loanDuration }) => (
|
const LoanDurationInput = ({ onChangeCallback, loanDuration }) => {
|
||||||
|
const decoratedChangeHandler = (event) => {
|
||||||
|
const digitDecoratedHandler = () => {
|
||||||
|
OnlyDigitsEventMiddleware({
|
||||||
|
event: event,
|
||||||
|
next: onChangeCallback,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const minMaxDecoratedHandler = MinMaxEventMiddleware({
|
||||||
|
event: event,
|
||||||
|
next: digitDecoratedHandler,
|
||||||
|
min: 1,
|
||||||
|
max: 360,
|
||||||
|
});
|
||||||
|
|
||||||
|
return minMaxDecoratedHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
<BaseInput
|
<BaseInput
|
||||||
label="Duración"
|
label="Duración"
|
||||||
value={loanDuration}
|
value={loanDuration}
|
||||||
onChangeCallback={onChangeCallback}
|
onChangeCallback={decoratedChangeHandler}
|
||||||
suffix="Meses"
|
suffix="Meses"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default LoanDurationInput;
|
export default LoanDurationInput;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue