Skip to content

Commit

Permalink
feat(Compensations): display pension from Sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Sep 12, 2024
1 parent c01fd85 commit f5230dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/compensations/Compensations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => {
{salary !== null ? (
<div aria-live="polite">
<Text> Du vil få en årlig lønn på {salary}</Text>
<Text>
Du vil få en årlig pensjon på omtrent {calculatePension(salary)}
</Text>
{compensations.pensionPercent && (
<Text>
Du vil få en årlig pensjon på omtrent{" "}
{calculatePension(salary, compensations.pensionPercent)}
</Text>
)}
</div>
) : null}
</>
Expand Down
7 changes: 5 additions & 2 deletions src/compensations/utils/calculateSalary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ export function calculateSalary(
return salaryPayscale[currentYear][adjustedYear];
}

export function calculatePension(salary: number): number {
return Math.round(salary * 0.07);
export function calculatePension(
salary: number,
pensionPercent: number,
): number {
return Math.round(salary * (pensionPercent / 100));
}

export function maxExperience(thisYear: number): number {
Expand Down
1 change: 1 addition & 0 deletions studio/lib/payloads/compensations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface CompensationsPage {
basicTitle: string;
page: string;
slug: Slug;
pensionPercent?: number;
benefitsByLocation: BenefitsByLocation[];
showSalaryCalculator: boolean;
}

0 comments on commit f5230dc

Please sign in to comment.