diff --git a/studio/schemas/objects/compensations/benefitsByLocation.ts b/studio/schemas/objects/compensations/benefitsByLocation.ts index 2ca07b2a1..cf06767f1 100644 --- a/studio/schemas/objects/compensations/benefitsByLocation.ts +++ b/studio/schemas/objects/compensations/benefitsByLocation.ts @@ -2,8 +2,10 @@ import { defineField } from "sanity"; import { location, locationID } from "../locations"; import { companyLocationNameID } from "studio/schemas/documents/companyLocation"; import { benefitId } from "studio/schemas/documents/benefit"; -import { checkForDuplicateLocations, DocumentWithLocation } from "./utils/validation"; - +import { + checkForDuplicateLocations, + DocumentWithLocation, +} from "./utils/validation"; export const benefitsByLocation = defineField({ name: "benefitsByLocation", diff --git a/studio/schemas/objects/compensations/utils/validation.ts b/studio/schemas/objects/compensations/utils/validation.ts index 27d84d302..3f1bd0796 100644 --- a/studio/schemas/objects/compensations/utils/validation.ts +++ b/studio/schemas/objects/compensations/utils/validation.ts @@ -1,27 +1,27 @@ interface LocationReference { - _ref: string; - _type: string; - title?: string; - } - - export interface DocumentWithLocation { - location: LocationReference; - } - - /** - * Checks for duplicate location references in the documents array. - * Ensures each location has a unique document entry. - * - * @param {DocumentWithLocation[] | undefined} documents - The array of documents, each with one or more locations. - * @returns {string | true} - Returns an error message if duplicate locations are found, or true if all are unique. - */ - export const checkForDuplicateLocations = ( - documents: DocumentWithLocation[] | undefined, - ): boolean => { - if (!documents) return true; - const locationRefs = documents - .map((entry) => entry.location?._ref) - .filter(Boolean); - const uniqueRefs = new Set(locationRefs); - return uniqueRefs.size === locationRefs.length; - }; \ No newline at end of file + _ref: string; + _type: string; + title?: string; +} + +export interface DocumentWithLocation { + location: LocationReference; +} + +/** + * Checks for duplicate location references in the documents array. + * Ensures each location has a unique document entry. + * + * @param {DocumentWithLocation[] | undefined} documents - The array of documents, each with one or more locations. + * @returns {string | true} - Returns an error message if duplicate locations are found, or true if all are unique. + */ +export const checkForDuplicateLocations = ( + documents: DocumentWithLocation[] | undefined, +): boolean => { + if (!documents) return true; + const locationRefs = documents + .map((entry) => entry.location?._ref) + .filter(Boolean); + const uniqueRefs = new Set(locationRefs); + return uniqueRefs.size === locationRefs.length; +};