Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add breakdown table, redesign results #84

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/models/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export default interface Projection {
interestApplied: number;
totalPaid: number;
totalInterestApplied: number;
threshold: number;
}
10 changes: 3 additions & 7 deletions components/layout.tsx → components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from "react";
import Footer from "./ui/organisms/footer";
import Header from "./ui/organisms/header";
import Footer from "./ui/organisms/Footer";
import Header from "./ui/organisms/Header";

interface LayoutProps {
children?: ReactNode | undefined;
Expand All @@ -11,11 +11,7 @@ function Layout({ children, className }: LayoutProps) {
return (
<div className={className}>
<Header />
<main className="flex justify-center">
<div className="p-8 m-8 max-w-7xl w-full bg-white shadow-lg">
{children}
</div>
</main>
<main className="container mx-auto my-8">{children}</main>
<Footer />
</div>
);
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions components/ui/atoms/Container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import classNames from "classnames";

export type ContainerProps = {
children?: React.ReactNode;
className?: string;
};

export const Container = ({ className, children }: ContainerProps) => {
return (
<div
className={classNames(
"mx-0 p-8 sm:mx-8 max-w-7xl bg-white shadow-lg",
className
)}
>
{children}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef } from "react";
import Tooltip from "./tooltip";
import Tooltip from "./Tooltip";
import ReactDatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { ReactDatePickerProps } from "react-datepicker";
Expand Down Expand Up @@ -44,7 +44,7 @@ const DatePicker = forwardRef<ReactDatePicker, DatePickerProps>(
)}
</>
);
},
}
);

export default DatePicker;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Highlight = (props: HighlightProps) => {
const { children } = props;

return (
<span className="font-bold background bg-slate-500 px-1 mx-0.5 py-0.5 text-white rounded whitespace-nowrap">
<span className="font-semibold bg-slate-200 px-1 mx-0.5 py-px rounded whitespace-nowrap">
{children}
</span>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef } from "react";
import Tooltip from "./tooltip";
import Tooltip from "./Tooltip";

interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
id: string;
Expand All @@ -14,7 +14,7 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {

const Input = forwardRef<HTMLInputElement, InputProps>(function InputGroup(
props: InputProps,
ref,
ref
) {
const {
id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef } from "react";
import Tooltip from "./tooltip";
import Tooltip from "./Tooltip";

interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
id: string;
Expand All @@ -15,7 +15,7 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {

const InputGroup = forwardRef<HTMLInputElement, InputProps>(function InputGroup(
props: InputProps,
ref,
ref
) {
const {
id,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
getLabelsForGroupedDataCallback,
groupDataEveryNthPeriod,
} from "./graphUtils";
import currencyFormatter from "../../../utils/currencyFormatter";
import { currencyFormatter } from "../../../utils/currencyFormatter";
import { DateTime } from "luxon";

ChartJS.register(
Expand All @@ -30,7 +30,7 @@ ChartJS.register(
LineElement,
Title,
Tooltip,
Legend,
Legend
);

interface BalanceGraphProps {
Expand All @@ -49,11 +49,11 @@ const BalanceGraph = (props: BalanceGraphProps) => {
this: Scale<CoreScaleOptions>,
tickValue: string | number,
index: number,
ticks: Tick[],
ticks: Tick[]
): string {
return getLabelsForGroupedDataCallback(
props.results.results,
this.getLabelForValue(index),
this.getLabelForValue(index)
);
},
autoSkip: false,
Expand All @@ -77,7 +77,7 @@ const BalanceGraph = (props: BalanceGraphProps) => {
}

if (context.parsed.y !== null) {
label += currencyFormatter().format(context.parsed.y);
label += currencyFormatter.format(context.parsed.y);
}

return label;
Expand Down Expand Up @@ -109,7 +109,7 @@ const BalanceGraph = (props: BalanceGraphProps) => {
const dataSetsPerLoanType = props.loanTypes.map((loanType, index) => ({
label: LoanTypeToDescription(loanType),
data: groupedData.data.map(
(x) => x.projections.find((p) => p.loanType == loanType)?.debtRemaining,
(x) => x.projections.find((p) => p.loanType == loanType)?.debtRemaining
),
borderColor: colors[index],
backgroundColor: backgroundColors[index],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from "react";
import { DateTime } from "luxon";
import LoanType from "../../../models/loanType";
import { Results } from "../../../api/models/results";
import Highlight from "../atoms/highlight";
import currencyFormatter from "../../../utils/currencyFormatter";
import Highlight from "../atoms/Highlight";
import { currencyFormatter } from "../../../utils/currencyFormatter";
import { RepaymentStatusToDescription } from "../../../models/repaymentStatus";

interface LoanRepaymentNarrativeProps {
Expand Down Expand Up @@ -48,7 +48,7 @@ const LoanRepaymentNarrative: NextPage<LoanRepaymentNarrativeProps> = ({

const explainer = (
<>
Will be{" "}
The loan will be{" "}
{RepaymentStatusToDescription(
periodCompleteProjection.repaymentStatus
).toLowerCase()}{" "}
Expand All @@ -58,7 +58,7 @@ const LoanRepaymentNarrative: NextPage<LoanRepaymentNarrativeProps> = ({

return (
<>
<p className="leading-7">
<p className="mb-3">
{paidOffDiff().years > 0 && paidOffDiff().months > 0 && (
<>
{explainer}
Expand All @@ -83,14 +83,14 @@ const LoanRepaymentNarrative: NextPage<LoanRepaymentNarrativeProps> = ({
<Highlight>{periodComplete.periodDate.toFormat("LLLL yyyy")}</Highlight>
.
</p>
<p className="mt-3 leading-7">
<p>
There is{" "}
<Highlight>
{currencyFormatter().format(periodCompleteProjection.totalPaid)}
{currencyFormatter.format(periodCompleteProjection.totalPaid)}
</Highlight>{" "}
remaining to pay, with{" "}
<Highlight>
{currencyFormatter().format(
{currencyFormatter.format(
periodCompleteProjection.totalInterestApplied
)}
</Highlight>{" "}
Expand Down
Loading
Loading