diff --git a/src/components/LoanDurationInput.jsx b/src/components/LoanDurationInput.jsx index 5013a4f..ceb600a 100644 --- a/src/components/LoanDurationInput.jsx +++ b/src/components/LoanDurationInput.jsx @@ -1,12 +1,34 @@ 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, + }); + }; -export default LoanDurationInput; \ No newline at end of file + const minMaxDecoratedHandler = MinMaxEventMiddleware({ + event: event, + next: digitDecoratedHandler, + min: 1, + max: 360, + }); + + return minMaxDecoratedHandler; + }; + + return ( + + ); +}; + +export default LoanDurationInput;