diff --git a/messages/en.json b/messages/en.json index 946a1d472..8ce9cc52f 100644 --- a/messages/en.json +++ b/messages/en.json @@ -47,8 +47,7 @@ "degreeOptions": { "bachelor": "Bachelor", "master": "Master" - }, - "no_compensation_data": "Whoops, the accounts seem to be on holiday. {city}, huh..." + } }, "employee_card": { "show": "Showing", diff --git a/messages/no.json b/messages/no.json index 803a181e7..45652d68d 100644 --- a/messages/no.json +++ b/messages/no.json @@ -44,8 +44,7 @@ "bachelor": "Bachelor", "master": "Master" }, - "test": "test", - "no_compensation_data": "Woops, regnskapet er på avveie. {city} altså..." + "test": "test" }, "custom_link": { "visit_cv": "Gå til mini-CV", diff --git a/messages/se.json b/messages/se.json index 3b5342ea5..d784bbc9a 100644 --- a/messages/se.json +++ b/messages/se.json @@ -43,8 +43,7 @@ "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", diff --git a/src/components/compensations/CompensationSelector.tsx b/src/components/compensations/CompensationSelector.tsx index d1b2bd4a1..4174bd11c 100644 --- a/src/components/compensations/CompensationSelector.tsx +++ b/src/components/compensations/CompensationSelector.tsx @@ -1,5 +1,4 @@ "use client"; -import { useTranslations } from "next-intl"; import { useState } from "react"; import { @@ -25,20 +24,20 @@ export default function CompensationSelector({ locations, locale, }: CompensationsProps) { - const t = useTranslations("compensation_calculator"); + const hasBenefits = (id: string) => + compensations.benefitsByLocation.some((b) => b.location._ref === id); + + const locationOptions: IOption[] = locations + .map((companyLocation) => ({ + id: companyLocation._id, + label: companyLocation.companyLocationName, + })) + .filter((l) => hasBenefits(l.id)); const [selectedLocation, setSelectedLocation] = useState( - locations[0]._id, - ); - const [selectedLocationLabel, setSelectedLocationLabel] = useState( - locations[0].companyLocationName, + locationOptions[0]?.id, ); - const locationOptions: IOption[] = locations.map((companyLocation) => ({ - id: companyLocation._id, - label: companyLocation.companyLocationName, - })); - const benefitsFilteredByLocation = compensations.benefitsByLocation.find( (benefit) => benefit.location._ref === selectedLocation, @@ -57,20 +56,13 @@ export default function CompensationSelector({ selectedId={selectedLocation} onValueChange={(option) => { setSelectedLocation(option.id); - setSelectedLocationLabel(option.label); }} /> {yearlyBonusesForLocation && ( )} - {benefitsFilteredByLocation.length > 0 ? ( - - ) : ( - - {t("no_compensation_data", { city: selectedLocationLabel })} - - )} + ); }