Skip to content

Instantly share code, notes, and snippets.

@intojs
Created December 1, 2019 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intojs/e7f28e4919d226d1c8865a0ae9c09804 to your computer and use it in GitHub Desktop.
Save intojs/e7f28e4919d226d1c8865a0ae9c09804 to your computer and use it in GitHub Desktop.
Loan Calculator Component
export const LoanCalculator: FC = () => {
const [loanCalculation, setLoanCalculation] = useState<CalculateLoanRes | null>(null);
const onSubmit = async (values: LoanCalculatorFormValues) => {
const {
email,
loanAmount,
loanTerm,
lifeInsuranceOptIn,
} = values;
const calculation: CalculateLoanRes = await calculateLoan({
emailAddress: email,
loanAmount,
loanTerm,
lifeInsuranceOptIn,
});
setLoanCalculation(calculation);
};
return (
<>
<h1 className='mt-5'>Loan calculator</h1>
<hr/>
{
loanCalculation
? <Calculation calculation={loanCalculation}/>
: <LoanCalculatorForm submit={onSubmit}/>
}
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment