This commit is contained in:
counterweight 2025-05-23 23:38:03 +02:00
parent a4efd1fd93
commit 99b7066b83
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -11,40 +11,48 @@ const LoanPanel = () => {
const [loanDuration, setLoanDuration] = useState(12);
const [loanInterest, setLoanInterest] = useState(5);
const sanitizeInputToIntWithinRange = ({ value, min, max }) => {
const onlyDigitsValue = sanitizeInputAsOnlyDigits({ value });
const inRangeValue = sanitizeInputIntoRange({
value: onlyDigitsValue,
min: min,
max: max,
});
return inRangeValue;
};
const handleLoanPrincipalChange = (event) => {
setHasBeenInteracted(1);
const inputValue = event.target.value;
const onlyDigitsValue = sanitizeInputAsOnlyDigits({ value: inputValue });
const inRangeValue = sanitizeInputIntoRange({
value: onlyDigitsValue,
const sanitizedInputValue = sanitizeInputToIntWithinRange({
value: inputValue,
min: 0,
max: 1_000_000,
});
setLoanPrincipal(inRangeValue);
setLoanPrincipal(sanitizedInputValue);
};
const handleLoanDurationChange = (event) => {
setHasBeenInteracted(1);
const inputValue = event.target.value;
const onlyDigitsValue = sanitizeInputAsOnlyDigits({ value: inputValue });
const inRangeValue = sanitizeInputIntoRange({
value: onlyDigitsValue,
const sanitizedInputValue = sanitizeInputToIntWithinRange({
value: inputValue,
min: 1,
max: 360,
});
setLoanDuration(inRangeValue);
setLoanDuration(sanitizedInputValue);
};
const handleLoanInterestChange = (event) => {
setHasBeenInteracted(1);
const inputValue = event.target.value;
const onlyDigitsValue = sanitizeInputAsOnlyDigits({ value: inputValue });
const inRangeValue = sanitizeInputIntoRange({
value: onlyDigitsValue,
const sanitizedInputValue = sanitizeInputToIntWithinRange({
value: inputValue,
min: 0,
max: 50,
});
setLoanInterest(inRangeValue);
setLoanInterest(sanitizedInputValue);
};
return (