inputs are coooomps

This commit is contained in:
Pablo Martin 2025-05-22 19:09:43 +02:00
parent 0a8177d2a0
commit 89649406f7
5 changed files with 90 additions and 38 deletions

View file

@ -0,0 +1,19 @@
const DurationInput = ({ onChangeCallback, loanDuration }) => {
return (
<div className="flex">
<label className="my-1" htmlFor="">
Duración
<input
className="ml-3 w-[60px] bg-white rounded-tl-md rounded-bl-md text-black text-right p-1"
value={loanDuration}
onChange={onChangeCallback}
/>
</label>
<div className="w-[60px] place-self-center p-1 rounded-tr-md rounded-br bg-gray-600 font-light">
Meses
</div>
</div>
);
};
export default DurationInput;

View file

@ -0,0 +1,19 @@
const InterestInput = ({ onChangeCallback, loanInterest }) => {
return (
<div className="flex">
<label className="my-1" htmlFor="">
Interés (TIN)
<input
className="ml-3 w-[60px] bg-white rounded-tl-md rounded-bl-md text-black text-right p-1"
value={loanInterest}
onChange={onChangeCallback}
/>
</label>
<div className="w-[60px] place-self-center p-1 rounded-tr-md rounded-br bg-gray-600 font-light">
%
</div>
</div>
);
};
export default InterestInput;

View file

@ -1,53 +1,47 @@
import { useState } from "react";
import PrincipalInput from "./PrincipalInput";
import DurationInput from "./DurationInput";
import InterestInput from "./InterestInput";
const LoanPanel = () => {
const [hasBeenInteracted, setHasBeenInteracted] = useState(false);
const [loanPrincipal, setLoanPrincipal] = useState(null);
const [loanPrincipal, setLoanPrincipal] = useState("");
const [loanDuration, setLoanDuration] = useState(12);
const [loanInterest, setLoanInterest] = useState(5);
const handleLoanPrincipalChange = (event) => {
setHasBeenInteracted(1);
setLoanPrincipal(event.target.value);
};
const handleLoanDurationChange = (event) => {
setHasBeenInteracted(1);
setLoanDuration(event.target.value);
};
const handleLoanInterestChange = (event) => {
setHasBeenInteracted(1);
setLoanInterest(event.target.value);
};
return (
<>
<div className="p-5 bg-gray-50 rounded-3xl border border-gray-400">
<form className="flex flex-col justify-end items-end my-5 text-white bg-blue-600 p-5 rounded-3xl shadow-[0_4px_0_rgba(0,255,255,1)]">
<div className="flex">
<label className="my-1" htmlFor="">
Capital prestado
</label>
<input
className="ml-3 w-[120px] w-min-0 bg-white rounded-tl-md rounded-bl-md text-black text-right p-1 !placeholder-gray-300"
value={loanPrincipal}
placeholder="1000"
/>
<div className="w-[60px] place-self-center p-1 rounded-tr-md rounded-br bg-gray-600 font-light">
</div>
</div>
<div className="flex">
<label className="my-1" htmlFor="">
Duración
<input
className="ml-3 w-[60px] bg-white rounded-tl-md rounded-bl-md text-black text-right p-1"
value={loanDuration}
/>
</label>
<div className="w-[60px] place-self-center p-1 rounded-tr-md rounded-br bg-gray-600 font-light">
Meses
</div>
</div>
<div className="flex">
<label className="my-1" htmlFor="">
Interés (TIN)
<input
className="ml-3 w-[60px] bg-white rounded-tl-md rounded-bl-md text-black text-right p-1"
value={loanInterest}
/>
</label>
<div className="w-[60px] place-self-center p-1 rounded-tr-md rounded-br bg-gray-600 font-light">
%
</div>
</div>
<PrincipalInput
onChangeCallback={handleLoanPrincipalChange}
loanPrincipal={loanPrincipal}
/>
<DurationInput
onChangeCallback={handleLoanDurationChange}
loanDuration={loanDuration}
/>
<InterestInput
onChangeCallback={handleLoanInterestChange}
loanInterest={loanInterest}
/>
</form>
{hasBeenInteracted ? <p>Someone touched meeee</p> : null}
</div>
</>
);

View file

@ -0,0 +1,20 @@
const PrincipalInput = ({onChangeCallback, loanPrincipal}) => {
return (
<div className="flex">
<label className="my-1" htmlFor="">
Capital prestado
</label>
<input
className="ml-3 w-[120px] w-min-0 bg-white rounded-tl-md rounded-bl-md text-black text-right p-1 !placeholder-gray-300"
value={loanPrincipal}
placeholder="1000"
onChange={onChangeCallback}
/>
<div className="w-[60px] place-self-center p-1 rounded-tr-md rounded-br bg-gray-600 font-light">
</div>
</div>
);
};
export default PrincipalInput;