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

v3 - show historic bonus for selected location (web) #614

Merged
merged 1 commit into from
Sep 12, 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
8 changes: 8 additions & 0 deletions src/compensations/Compensations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
IOption,
RadioButtonGroup,
} from "src/components/forms/radioButtonGroup/RadioButtonGroup";
import YearlyBonuses from "./components/yearlyBonuses/YearlyBonuses";
import BenefitsByLocation from "./components/benefitsByLocation/BenefitsByLocation";

interface CompensationsProps {
Expand Down Expand Up @@ -70,6 +71,10 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => {
(benefit) => benefit.location._ref === selectedLocation,
)?.benefits || [];

const yearlyBonusesForLocation = compensations.bonusesByLocation.find(
(b) => b.location._ref === selectedLocation,
)?.yearlyBonuses;
mathiazom marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className={styles.wrapper}>
<Text type="h1">{compensations.basicTitle}</Text>
Expand Down Expand Up @@ -102,6 +107,9 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => {
) : null}
</>
)}
{yearlyBonusesForLocation && (
<YearlyBonuses bonuses={yearlyBonusesForLocation} />
)}
<BenefitsByLocation benefits={benefitsFilteredByLocation} />
</div>
);
Expand Down
43 changes: 43 additions & 0 deletions src/compensations/components/yearlyBonuses/YearlyBonuses.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { BonusPage } from "studio/lib/payloads/compensations";
import Text from "../../../components/text/Text";
import styles from "./yearlyBonuses.module.css";

interface YearlyBonusesProps {
bonuses: BonusPage[];
}

const YearlyBonuses = ({ bonuses }: YearlyBonusesProps) => {
return (
<div className={styles.wrapper}>
<Text type={"h3"}>Historisk bonus</Text>
<table className={styles.table}>
<thead>
<tr>
<th>
<Text>År</Text>
</th>
<th className={styles.bonusHeader}>
<Text>Beløp</Text>
</th>
</tr>
</thead>
<tbody>
{bonuses
.sort((a, b) => b.year - a.year)
.map((bonus) => (
<tr key={bonus._key}>
<th>
<Text type={"small"}>{bonus.year}</Text>
</th>
<td className={styles.bonusCell}>
<Text type={"small"}>{bonus.bonus}</Text>
</td>
</tr>
))}
</tbody>
</table>
</div>
);
};

export default YearlyBonuses;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.wrapper {
display: flex;
flex-direction: column;
gap: 1rem;
}

.table {
text-align: left;
max-width: 500px;
}

.bonusHeader,
.bonusCell {
text-align: right;
}
15 changes: 9 additions & 6 deletions studio/lib/payloads/compensations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PortableTextBlock } from "src/components/richText/RichText";
import { Slug } from "./global";
import { Reference, Slug } from "./global";

export interface Benefit {
_type: string;
Expand All @@ -21,6 +21,13 @@ export interface SalariesPage {
salaries: string;
}

export interface BonusesByLocationPage {
_type: string;
_key: string;
location: Reference;
mathiazom marked this conversation as resolved.
Show resolved Hide resolved
yearlyBonuses: BonusPage[];
}

export interface BonusPage {
_type: string;
_key: string;
Expand All @@ -39,10 +46,6 @@ export interface CompensationsPage {
slug: Slug;
pensionPercent?: number;
benefitsByLocation: BenefitsByLocation[];
bonusesByLocation: BonusesByLocationPage[];
showSalaryCalculator: boolean;
}

export interface Reference {
_type: "reference";
_ref: string;
}
5 changes: 5 additions & 0 deletions studio/lib/payloads/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export interface Slug {
_type: string;
current: string;
}

export interface Reference {
_type: "reference";
_ref: string;
}