Skip to content

Commit

Permalink
compensation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anemne committed Dec 13, 2024
1 parent 99773a5 commit 911acc7
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 28 deletions.
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"degreeOptions": {
"bachelor": "Bachelor",
"master": "Master"
}
},
"no_compensation_data": "Whoops, the accounts seem to be on holiday. {city}, huh..."
},
"employee_card": {
"show": "Showing",
Expand Down
4 changes: 3 additions & 1 deletion messages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"degreeOptions": {
"bachelor": "Bachelor",
"master": "Master"
}
},
"test": "test",
"no_compensation_data": "Woops, regnskapet er på avveie. {city} altså..."
},
"custom_link": {
"visit_cv": "Gå til mini-CV",
Expand Down
3 changes: 2 additions & 1 deletion messages/se.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"degreeOptions": {
"bachelor": "Bachelor",
"master": "Master"
}
},
"no_compensation_data": "Hoppsan, bokföringen är på villovägar. {city} alltså..."
},
"custom_link": {
"visit_cv": "Besök mini-CV",
Expand Down
25 changes: 20 additions & 5 deletions src/components/compensations/CompensationSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { useTranslations } from "next-intl";
import { useState } from "react";

import {
Expand All @@ -24,9 +25,14 @@ export default function CompensationSelector({
locations,
locale,
}: CompensationsProps) {
const t = useTranslations("compensation_calculator");

const [selectedLocation, setSelectedLocation] = useState<string>(
locations[0]._id,
);
const [selectedLocationLabel, setSelectedLocationLabel] = useState<string>(
locations[0].companyLocationName,
);

const locationOptions: IOption[] = locations.map((companyLocation) => ({
id: companyLocation._id,
Expand All @@ -44,18 +50,27 @@ export default function CompensationSelector({

return (
<div className={styles.compensationWrapper}>
{yearlyBonusesForLocation && (
<YearlyBonuses bonuses={yearlyBonusesForLocation} locale={locale} />
)}
<RadioButtonGroup
id="location-group"
label="Velg lokasjon"
options={locationOptions}
selectedId={selectedLocation}
onValueChange={(option) => setSelectedLocation(option.id)}
onValueChange={(option) => {
setSelectedLocation(option.id);
setSelectedLocationLabel(option.label);
}}
/>

<BenefitsByLocation benefits={benefitsFilteredByLocation} />
{yearlyBonusesForLocation && (
<YearlyBonuses bonuses={yearlyBonusesForLocation} locale={locale} />
)}
{benefitsFilteredByLocation.length > 0 ? (
<BenefitsByLocation benefits={benefitsFilteredByLocation} />
) : (
<span>
{t("no_compensation_data", { city: selectedLocationLabel })}
</span>
)}
</div>
);
}
28 changes: 15 additions & 13 deletions src/components/compensations/Compensations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ export default async function Compensations({
language,
}: CompensationsProps) {
return (
<div className={styles.wrapper}>
<Text className={styles.text} type="h1">
{compensations.basicTitle}
</Text>
<div className={styles.outerWrapper}>
<div className={styles.wrapper}>
<Text className={styles.text} type="h1">
{compensations.basicTitle}
</Text>

<CompensationCalculator
section={compensations.compensationCalculator}
language={language}
/>
<CompensationCalculator
section={compensations.compensationCalculator}
language={language}
/>

<CompensationSelector
compensations={compensations}
locations={locations}
locale={locale}
/>
<CompensationSelector
compensations={compensations}
locations={locations}
locale={locale}
/>
</div>
</div>
);
}
15 changes: 11 additions & 4 deletions src/components/compensations/compensations.module.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
.outerWrapper {
width: 100%;
display: flex;
justify-content: center;
}

.wrapper {
display: flex;
flex-direction: column;
padding: 10rem 5rem;
gap: 5rem;
justify-content: center;
gap: 3rem;
width: 100%;
max-width: var(--max-content-width-large);
}

.text {
max-width: var(--max-content-width-large);
align-self: center;
}

.compensationWrapper {
display: flex;
flex-direction: column;
max-width: var(--max-content-width-large);
align-self: center;
gap: 2rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
flex-direction: column;
gap: 5rem;
max-width: var(--max-content-width-medium);
padding-top: 4rem;
}

.benefitWrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export default async function CompensationCalculator({
)}
</div>
<Handbook
title={section.handbookBlock.handbookTitle}
description={section.handbookBlock.handbookDescription}
title={section.handbookBlock?.handbookTitle}
description={section.handbookBlock?.handbookDescription}
language={language}
link={section.handbookBlock.handbookLink}
link={section.handbookBlock?.handbookLink}
sectionBackground={section.background}
/>
</div>
Expand Down

0 comments on commit 911acc7

Please sign in to comment.