diff --git a/src/compensations/Compensations.tsx b/src/compensations/Compensations.tsx index d5c8047ea..6a8f9aa7a 100644 --- a/src/compensations/Compensations.tsx +++ b/src/compensations/Compensations.tsx @@ -15,7 +15,7 @@ import { interface CompensationsProps { compensations: CompensationsPage; - locations: CompanyLocation; + locations: CompanyLocation[]; } interface SalaryCalculatorFormState { @@ -24,7 +24,9 @@ interface SalaryCalculatorFormState { } const Compensations = ({ compensations, locations }: CompensationsProps) => { - const [selectedLocation, setSelectedLocation] = useState("trondheim"); + const [selectedLocation, setSelectedLocation] = useState( + locations[0]._id, + ); const currentYear = new Date().getFullYear(); const [salary, setSalary] = useState(null); const [formState, setFormState] = useState({ @@ -57,13 +59,9 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => { ); }; - const updateLocation = (id: string) => { - setSelectedLocation(id); - }; - const locationOptions: IOption[] = Object.values(locations).map( (companyLocation) => ({ - id: companyLocation.companyLocationName.toLowerCase(), + id: companyLocation._id, label: companyLocation.companyLocationName, }), ); @@ -76,7 +74,7 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => { label="Choose your location" options={locationOptions} selectedId={selectedLocation} - onValueChange={(selectedOption) => updateLocation(selectedOption.id)} + onValueChange={(option) => setSelectedLocation(option.id)} /> {compensations.showSalaryCalculator && ( <> diff --git a/src/compensations/CompensationsPreview.tsx b/src/compensations/CompensationsPreview.tsx index 07a2e2547..c32b56674 100644 --- a/src/compensations/CompensationsPreview.tsx +++ b/src/compensations/CompensationsPreview.tsx @@ -9,7 +9,7 @@ import { COMPENSATIONS_PAGE_QUERY } from "studio/lib/queries/pages"; interface CompensationsPreviewProps { initialCompensations: QueryResponseInitial; - initialLocation: QueryResponseInitial; + initialLocation: QueryResponseInitial; } const CompensationsPreview = ({ @@ -22,7 +22,7 @@ const CompensationsPreview = ({ { initial: initialCompensations }, ); - const { data: locationData } = useQuery( + const { data: locationData } = useQuery( COMPANY_LOCATIONS_QUERY, { initial: initialLocation }, ); diff --git a/studio/lib/payloads/companyDetails.ts b/studio/lib/payloads/companyDetails.ts index 8a69eabcb..57cefdb2a 100644 --- a/studio/lib/payloads/companyDetails.ts +++ b/studio/lib/payloads/companyDetails.ts @@ -20,5 +20,5 @@ export interface CompanyLocation { _key: string; _id: string; _updatedAt: string; - companyLocation: string; + companyLocationName: string; } diff --git a/studio/lib/payloads/compensations.ts b/studio/lib/payloads/compensations.ts index 85c17cccd..63abc1a1a 100644 --- a/studio/lib/payloads/compensations.ts +++ b/studio/lib/payloads/compensations.ts @@ -8,10 +8,10 @@ export interface Benefit { richText: PortableTextBlock[]; } -export interface BenefitsGroup { +export interface BenefitsByLocation { _key: string; location: string; - benefitsGroup: Benefit[]; + benefits: Benefit[]; } export interface SalariesPage { @@ -30,6 +30,6 @@ export interface CompensationsPage { basicTitle: string; page: string; slug: Slug; - benefitsByLocation: BenefitsGroup[]; + benefitsByLocation: BenefitsByLocation[]; showSalaryCalculator: boolean; }