duration sanitized

This commit is contained in:
Pablo Martin 2025-05-23 00:38:27 +02:00
parent 21cc74d363
commit 9b406cda51

View file

@ -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 }) => {
<BaseInput const decoratedChangeHandler = (event) => {
label="Duración" const digitDecoratedHandler = () => {
value={loanDuration} OnlyDigitsEventMiddleware({
onChangeCallback={onChangeCallback} event: event,
suffix="Meses" next: onChangeCallback,
/> });
); };
export default LoanDurationInput; const minMaxDecoratedHandler = MinMaxEventMiddleware({
event: event,
next: digitDecoratedHandler,
min: 1,
max: 360,
});
return minMaxDecoratedHandler;
};
return (
<BaseInput
label="Duración"
value={loanDuration}
onChangeCallback={decoratedChangeHandler}
suffix="Meses"
/>
);
};
export default LoanDurationInput;