-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add salary calculator based on legacy site
Co-authored-by: Ane <[email protected]>
- Loading branch information
Showing
9 changed files
with
229 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/components/forms/radioButtonGroup/radioButtonGroup.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.fieldset{ | ||
border: 0 none; | ||
padding: 0; | ||
} | ||
|
||
.wrapper { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/salaryAndBenefits/components/salaryCalculator/SalaryCalculator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import styles from "./salaryCalculator.module.css"; | ||
import InputField from "src/components/forms/inputField/InputField"; | ||
import { | ||
IOption, | ||
RadioButtonGroup, | ||
} from "src/components/forms/radioButtonGroup/RadioButtonGroup"; | ||
import Button from "src/components/buttons/Button"; | ||
|
||
export type Degree = "bachelor" | "master"; | ||
|
||
const degreeOptions: IOption[] = [ | ||
{ | ||
id: "bachelor", | ||
label: "Bachelor", | ||
currentSelected: true, | ||
disabled: false, | ||
}, | ||
{ id: "master", label: "Master", currentSelected: false, disabled: false }, | ||
]; | ||
|
||
interface SalaryCalculatorProps { | ||
examinationYear: number; | ||
minExaminationYear: number; | ||
maxExaminationYear: number; | ||
onDegreeChanged: (degree: Degree) => void; | ||
onExaminationYearChanged: (examinationYear: number) => void; | ||
onSubmit: (event: React.FormEvent) => void; | ||
} | ||
|
||
export default function SalaryCalculator({ | ||
examinationYear, | ||
minExaminationYear, | ||
maxExaminationYear, | ||
onDegreeChanged, | ||
onExaminationYearChanged, | ||
onSubmit, | ||
}: SalaryCalculatorProps) { | ||
return ( | ||
<form | ||
aria-label="salary calculator" | ||
className={styles.calculator} | ||
onSubmit={onSubmit} | ||
> | ||
<RadioButtonGroup | ||
id="degree-group" | ||
label="Choose your degree" | ||
options={degreeOptions} | ||
onValueChange={(value) => | ||
(value.id === "bachelor" || value.id === "master") && | ||
onDegreeChanged(value.id) | ||
} | ||
/> | ||
<InputField | ||
label="year" | ||
name="examinationYear" | ||
type="number" | ||
max={maxExaminationYear} | ||
min={minExaminationYear} | ||
value={examinationYear} | ||
onChange={(_name, value) => onExaminationYearChanged(parseInt(value))} | ||
required | ||
/> | ||
<Button type="secondary" size="small"> | ||
Submit | ||
</Button> | ||
</form> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/salaryAndBenefits/components/salaryCalculator/salaryCalculator.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.calculator{ | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { payscale } from "./salaryData"; | ||
|
||
interface PayScale { | ||
[year: number]: { | ||
[examinationYear: number]: number; | ||
}; | ||
} | ||
|
||
const salaryPayscale: PayScale = payscale; | ||
|
||
export function calculateSalary( | ||
currentYear: number, | ||
examinationYear: number, | ||
degree: string | ||
): number { | ||
|
||
const degreeValue = degree === "bachelor" ? 1 : 0; | ||
const adjustedYear = (examinationYear + degreeValue); | ||
return salaryPayscale[currentYear][adjustedYear]; | ||
} | ||
|
||
export function calculatePension(salary: number): number { | ||
return Math.round(salary * 0.07); | ||
} | ||
|
||
export function maxExperience(thisYear: number): number { | ||
const years = Object.keys(salaryPayscale[thisYear]).map(Number) | ||
return Math.min(...years); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export const payscale = { | ||
2024: { | ||
2024 : 600000, | ||
2023 : 635833, | ||
2022 : 681829, | ||
2021 : 734982, | ||
2020 : 789982, | ||
2019 : 838539, | ||
2018 : 879553, | ||
2017 : 916886, | ||
2016 : 949000, | ||
2015 : 977333, | ||
2014 : 1005324, | ||
2013 : 1031405, | ||
2012 : 1064738, | ||
2011 : 1091489, | ||
2010 : 1113742, | ||
2009 : 1138742, | ||
2008 : 1166667, | ||
2007 : 1192460, | ||
2006 : 1210126, | ||
2005 : 1233560, | ||
2004 : 1264767, | ||
2003 : 1289780, | ||
2002 : 1299680, | ||
2001 : 1295953, | ||
2000 : 1305501, | ||
1999 : 1328501, | ||
1998 : 1349349, | ||
1997 : 1365121, | ||
1996 : 1384832, | ||
1995 : 1399711, | ||
1994 : 1422069, | ||
1993 : 1429358, | ||
1992 : 1452891, | ||
1991 : 1458021, | ||
1990 : 1467321, | ||
1989 : 1484721 | ||
} | ||
} ; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters