Skip to content

Commit

Permalink
feat: Add config for max contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdudley committed Jan 5, 2024
1 parent a6d48d7 commit afa900c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { formatMoney, formatPercentage } from "./formatting";
import { Percentage } from "./Percentage";
import { DatePicker } from "@mui/x-date-pickers";
import { getMaxContribution } from "./constants";

export default function Form() {
// Form fields
Expand All @@ -29,7 +30,7 @@ export default function Form() {
>(0);
const [targetContribution, setTargetContribution] = React.useState<
number | undefined
>(22500);
>(getMaxContribution());

// Calculated fields
const paycheckAmount = getPaycheckAmount(annualSalary, paycheckFrequency);
Expand Down Expand Up @@ -155,7 +156,7 @@ export default function Form() {
<InputAdornment position="start">$</InputAdornment>
),
}}
helperText="Note: The annual maximum for 2023 is $22,500."
helperText={`Note: The annual maximum for ${new Date().getFullYear()} is $${getMaxContribution()}.`}
/>
</Grid>
<Grid item xs={12} md={6}>
Expand Down
11 changes: 11 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function getMaxContribution() {
const year = new Date().getFullYear();

if (year === 2023) {
return 22500;
} else if (year === 2024) {
return 23000;
}

return 23000;
}

0 comments on commit afa900c

Please sign in to comment.