diff --git a/src/components/FeesPanel/FeesPanel.tsx b/src/components/FeesPanel/FeesPanel.tsx new file mode 100644 index 0000000..d3c88c0 --- /dev/null +++ b/src/components/FeesPanel/FeesPanel.tsx @@ -0,0 +1,127 @@ +import { Panel, PrimaryButton, Stack, Text, TextField } from "@fluentui/react"; +import React from "react"; +import { MortgageFees } from "../MortgageDetails/MortgageDetails.mapper"; + +interface FeesPanelProps { + fees: MortgageFees; + setFees: React.Dispatch>; + isPanelOpen: boolean; + setIsPanelOpen: React.Dispatch>; +} + +export const FeesPanel: React.FC = (props: FeesPanelProps) => { + const { fees, setFees, isPanelOpen, setIsPanelOpen } = props; + + return ( + setIsPanelOpen(false)} + headerText="Mortgage Fees" + onRenderFooterContent={() => ( + { + setIsPanelOpen(false); + }} + > + Close + + )} + > + + + These are the fees associated with taking out a mortgage on + a property. They are estimates and can vary depending on the + lender and the property. + + + + setFees({ + ...fees, + valuationFee: parseFloat(newValue!), + }) + } + /> + + + setFees({ + ...fees, + surveyFee: parseFloat(newValue!), + }) + } + /> + + + setFees({ + ...fees, + legalFee: parseFloat(newValue!), + }) + } + /> + + + setFees({ + ...fees, + searchFee: parseFloat(newValue!), + }) + } + /> + + + setFees({ + ...fees, + registerOfDeedsFee: parseFloat(newValue!), + }) + } + /> + + + setFees({ + ...fees, + landRegistryFee: parseFloat(newValue!), + }) + } + /> + +
+ + {/* { + setIsPanelOpen(false); + }} + > + Close + */} +
+
+ ); +}; diff --git a/src/components/MortgageComparison/MortgageComparison.tsx b/src/components/MortgageComparison/MortgageComparison.tsx index f88cab9..ff342b8 100644 --- a/src/components/MortgageComparison/MortgageComparison.tsx +++ b/src/components/MortgageComparison/MortgageComparison.tsx @@ -1,9 +1,11 @@ -import { Icon, Link, Stack, Text } from "@fluentui/react"; +import { Icon, Link, PrimaryButton, Stack, Text } from "@fluentui/react"; import React from "react"; import { InterestRate } from "../InterestRate/InterestRate"; import { MaxLoanInput } from "../MaxLoanInput/MaxLoanInput"; import { TermInput } from "../TermInput/TermInput"; import { MortgageDetails } from "../MortgageDetails/MortgageDetails"; +import { MortgageFees } from "../MortgageDetails/MortgageDetails.mapper"; +import { FeesPanel } from "../FeesPanel/FeesPanel"; export interface MortgageComparisonProps {} @@ -18,6 +20,18 @@ export const MortgageComparison: React.FC = () => { const [term, setTerm] = React.useState(35); + const [fees, setFees] = React.useState({ + valuationFee: 185, + surveyFee: 600, + // legalFee: 3382.5, + legalFee: 3400, + searchFee: 250, + registerOfDeedsFee: 100, + landRegistryFee: 975, + }); + + const [isPanelOpen, setIsPanelOpen] = React.useState(false); + const containerStackStyles = { root: { alignItems: "center" }, }; @@ -33,10 +47,18 @@ export const MortgageComparison: React.FC = () => { useGlobalInterestRate={useGlobalInterestRate} setUseGlobalInterestRate={setUseGlobalInterestRate} /> + + + + setIsPanelOpen(true)}> + View/Edit Fees + + = () => { /> = () => { /> @@ -77,11 +101,19 @@ export const MortgageComparison: React.FC = () => { buying me a coffee! {" "} + + ); }; interface MortgageOptionProps { + fees: MortgageFees; id: number; interestRate: number | undefined; useGlobalInterestRate: boolean; @@ -92,7 +124,8 @@ interface MortgageOptionProps { const MortgageOption: React.FC = ( props: MortgageOptionProps ) => { - const { id, interestRate, useGlobalInterestRate, maxLoan, term } = props; + const { fees, id, interestRate, useGlobalInterestRate, maxLoan, term } = + props; return ( @@ -100,6 +133,7 @@ const MortgageOption: React.FC = (

Option {id}

= ( props: MortgageDetailsProps ) => { - const { interestRate, maxLoan, term } = props; + const { fees, interestRate, maxLoan, term } = props; console.log(interestRate); const [localInterestRate, setLocalInterestRate] = React.useState( interestRate ?? 4.0 @@ -36,15 +37,6 @@ export const MortgageDetails: React.FC = ( }; const containerStackTokens = { childrenGap: 30 }; - const fees: MortgageFees = { - valuationFee: 185, - surveyFee: 600, - legalFee: 3382.5, - searchFee: 250, - registerOfDeedsFee: 100, - landRegistryFee: 975, - }; - const handleLoanAmountChange = (newValue: string | undefined) => { if (newValue === undefined) { return;