From 4a5b91301c140b3b2250b8b9b6b2f0ec23ab32ac Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Wed, 4 Sep 2024 15:49:22 +0200 Subject: [PATCH 1/2] refactor(companyLocation): consistent plural form of company locations --- studio/schemas/deskStructure.ts | 4 ++-- studio/schemas/documents/companyLocations.ts | 6 +++--- studio/schemas/objects/compensations/bonusesByLocation.ts | 4 ++-- studio/schemas/objects/locations.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index 50079f3b8..14302ad57 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -17,7 +17,7 @@ import { soMeLinksID } from "./documents/socialMediaProfiles"; import { companyInfoID } from "./documents/companyInfo"; import { legalDocumentID } from "./documents/legalDocuments"; import { compensationsId } from "./documents/compensations"; -import { companyLocationsID } from "./documents/companyLocations"; +import { companyLocationID } from "./documents/companyLocations"; export default (S: StructureBuilder) => S.list() @@ -43,7 +43,7 @@ export default (S: StructureBuilder) => .title("Company Locations") .icon(PinIcon) .child( - S.documentTypeList(companyLocationsID).title( + S.documentTypeList(companyLocationID).title( "Company Locations", ), ), diff --git a/studio/schemas/documents/companyLocations.ts b/studio/schemas/documents/companyLocations.ts index cfc5f1ce2..c56f010a6 100644 --- a/studio/schemas/documents/companyLocations.ts +++ b/studio/schemas/documents/companyLocations.ts @@ -1,16 +1,16 @@ import { defineField, defineType } from "sanity"; -export const companyLocationsID = "companyLocations"; export const companyLocationID = "companyLocation"; +export const companyLocationNameID = "companyLocationName"; const companyLocations = defineType({ - name: companyLocationsID, + name: companyLocationID, type: "document", title: "Location", description: "Content related to an individual location within the company", fields: [ defineField({ - name: companyLocationID, + name: companyLocationNameID, type: "string", title: "Location", }), diff --git a/studio/schemas/objects/compensations/bonusesByLocation.ts b/studio/schemas/objects/compensations/bonusesByLocation.ts index afed9f86a..adda16b2b 100644 --- a/studio/schemas/objects/compensations/bonusesByLocation.ts +++ b/studio/schemas/objects/compensations/bonusesByLocation.ts @@ -1,6 +1,6 @@ import { defineField } from "sanity"; import { location, locationID } from "../locations"; -import { companyLocationID } from "studio/schemas/documents/companyLocations"; +import { companyLocationNameID } from "studio/schemas/documents/companyLocations"; export const bonusesByLocation = defineField({ name: "bonusesByLocation", @@ -37,7 +37,7 @@ export const bonusesByLocation = defineField({ preview: { select: { averageBonus: "averageBonus", - location: `${locationID}.${companyLocationID}`, + location: `${locationID}.${companyLocationNameID}`, }, prepare({ averageBonus, location }) { return { diff --git a/studio/schemas/objects/locations.ts b/studio/schemas/objects/locations.ts index ed889e922..6ac65b182 100644 --- a/studio/schemas/objects/locations.ts +++ b/studio/schemas/objects/locations.ts @@ -1,5 +1,5 @@ import { defineField } from "sanity"; -import { companyLocationsID } from "../documents/companyLocations"; +import { companyLocationID } from "../documents/companyLocations"; export const locationsID = "locations"; export const locationID = "location"; @@ -10,7 +10,7 @@ export const location = defineField({ title: "Select a location", description: "Select the office location this content applies to. If it applies to all locations, you can leave this field empty.", - to: [{ type: companyLocationsID }], + to: [{ type: companyLocationID }], options: { disableNew: true, }, From 8cfc7b8c6daec69192c7a93e53756e31718bec9c Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Thu, 5 Sep 2024 08:07:34 +0200 Subject: [PATCH 2/2] refactor(companyLocation): singular file and constant name --- studio/schema.ts | 4 ++-- studio/schemas/deskStructure.ts | 2 +- .../documents/{companyLocations.ts => companyLocation.ts} | 4 ++-- studio/schemas/objects/compensations/bonusesByLocation.ts | 2 +- studio/schemas/objects/locations.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename studio/schemas/documents/{companyLocations.ts => companyLocation.ts} (86%) diff --git a/studio/schema.ts b/studio/schema.ts index d61e9d8ed..22f7db9fd 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -12,7 +12,7 @@ import posts from "./schemas/documents/post"; import categories from "./schemas/fields/categories"; import legalDocument from "./schemas/documents/legalDocuments"; import benefit from "./schemas/documents/benefit"; -import companyLocations from "./schemas/documents/companyLocations"; +import companyLocation from "./schemas/documents/companyLocation"; import compensations from "./schemas/documents/compensations"; import siteSettings from "./schemas/documents/siteSettings"; @@ -33,6 +33,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { legalDocument, compensations, benefit, - companyLocations, + companyLocation, ], }; diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index 14302ad57..6344eb43c 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -17,7 +17,7 @@ import { soMeLinksID } from "./documents/socialMediaProfiles"; import { companyInfoID } from "./documents/companyInfo"; import { legalDocumentID } from "./documents/legalDocuments"; import { compensationsId } from "./documents/compensations"; -import { companyLocationID } from "./documents/companyLocations"; +import { companyLocationID } from "./documents/companyLocation"; export default (S: StructureBuilder) => S.list() diff --git a/studio/schemas/documents/companyLocations.ts b/studio/schemas/documents/companyLocation.ts similarity index 86% rename from studio/schemas/documents/companyLocations.ts rename to studio/schemas/documents/companyLocation.ts index c56f010a6..91352c7c7 100644 --- a/studio/schemas/documents/companyLocations.ts +++ b/studio/schemas/documents/companyLocation.ts @@ -3,7 +3,7 @@ import { defineField, defineType } from "sanity"; export const companyLocationID = "companyLocation"; export const companyLocationNameID = "companyLocationName"; -const companyLocations = defineType({ +const companyLocation = defineType({ name: companyLocationID, type: "document", title: "Location", @@ -17,4 +17,4 @@ const companyLocations = defineType({ ], }); -export default companyLocations; +export default companyLocation; diff --git a/studio/schemas/objects/compensations/bonusesByLocation.ts b/studio/schemas/objects/compensations/bonusesByLocation.ts index adda16b2b..93d7aee2a 100644 --- a/studio/schemas/objects/compensations/bonusesByLocation.ts +++ b/studio/schemas/objects/compensations/bonusesByLocation.ts @@ -1,6 +1,6 @@ import { defineField } from "sanity"; import { location, locationID } from "../locations"; -import { companyLocationNameID } from "studio/schemas/documents/companyLocations"; +import { companyLocationNameID } from "studio/schemas/documents/companyLocation"; export const bonusesByLocation = defineField({ name: "bonusesByLocation", diff --git a/studio/schemas/objects/locations.ts b/studio/schemas/objects/locations.ts index 6ac65b182..315aec545 100644 --- a/studio/schemas/objects/locations.ts +++ b/studio/schemas/objects/locations.ts @@ -1,5 +1,5 @@ import { defineField } from "sanity"; -import { companyLocationID } from "../documents/companyLocations"; +import { companyLocationID } from "../documents/companyLocation"; export const locationsID = "locations"; export const locationID = "location";