From 93789dde2de5f3a6d48f908a08a22a5b3fdddf15 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Tue, 3 Sep 2024 10:50:43 +0200 Subject: [PATCH] feat(compensations): per-location salaries --- studio/schemas/documents/compensations.ts | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/studio/schemas/documents/compensations.ts b/studio/schemas/documents/compensations.ts index 6e8f0ca14..c17669b5a 100644 --- a/studio/schemas/documents/compensations.ts +++ b/studio/schemas/documents/compensations.ts @@ -4,6 +4,8 @@ import seo from "../objects/seo"; import { title } from "../fields/text"; import { benefitId } from "./benefit"; import MultiLineDescription from "../../components/MultiLineDescription"; +import { locationId } from "./location"; +import { SalariesInput } from "../../components/SalaryCsvInput/SalariesInput"; export const compensationsId = "compensations"; @@ -28,6 +30,74 @@ const compensations = defineType({ type: "boolean", initialValue: true, }), + defineField({ + name: "salaries", + title: "Salaries", + description: "Per-location salaries", + type: "array", + of: [ + { + title: "Location Salaries", + description: "Yearly salary data for a specific location", + type: "object", + fields: [ + defineField({ + name: "location", + title: "Location", + type: "reference", + to: [{ type: locationId }], + }), + defineField({ + name: "yearlySalaries", + title: "Yearly Salaries", + description: "Salary tiers for each year", + type: "array", + options: { + sortable: false, + }, + of: [ + { + type: "object", + fields: [ + defineField({ + name: "year", + title: "Year", + type: "number", + validation: (Rule) => Rule.required().min(2018), + }), + defineField({ + name: "salaries", + title: "Salaries", + type: "string", + components: { + input: SalariesInput, + }, + }), + ], + preview: { + select: { + title: "year", + salaries: "salaries", + }, + }, + }, + ], + }), + ], + preview: { + select: { + location: "location.basicTitle", + }, + prepare({ location }) { + return { + title: location, + subtitle: "Location Salaries", + }; + }, + }, + }, + ], + }), defineField({ name: "benefits", title: "Benefits",