Skip to content

Commit

Permalink
fix: add saved search preview label for dimensionRange attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
nickskalkin committed Jan 26, 2024
1 parent b7d1341 commit ee3cf95
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions _schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14750,6 +14750,7 @@ input PreviewSavedSearchAttributes {
atAuction: Boolean
attributionClass: [String]
colors: [String]
dimensionRange: String
height: String
inquireableOnly: Boolean
locationCities: [String]
Expand Down
3 changes: 3 additions & 0 deletions src/schema/v2/previewSavedSearch/previewSavedSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const previewSavedSearchArgs: GraphQLFieldConfigArgumentMap = {
colors: {
type: new GraphQLList(GraphQLString),
},
dimensionRange: {
type: GraphQLString,
},
height: {
type: GraphQLString,
},
Expand Down
24 changes: 24 additions & 0 deletions src/schema/v2/previewSavedSearch/searchCriteriaLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { round } from "lodash"
import gql from "lib/gql"
import { DEFAULT_LENGTH_UNIT_PREFERENCE, camelCaseKeys } from "lib/helpers"

export const DIMENSION_RANGES = {
"*-16.0": "SMALL",
"16.0-40.0": "MEDIUM",
"40.0-*": "LARGE",
}

export const SIZES_IN_CM = {
SMALL: "Small (under 40cm)",
MEDIUM: "Medium (40 – 100cm)",
Expand Down Expand Up @@ -95,6 +101,7 @@ export const resolveSearchCriteriaLabels = async (
artistSeriesIDs,
attributionClass,
additionalGeneIDs,
dimensionRange,
priceRange,
sizes,
width,
Expand Down Expand Up @@ -127,6 +134,7 @@ export const resolveSearchCriteriaLabels = async (
labels.push(getMediumLabels(additionalGeneIDs))
labels.push(getPriceLabel(priceRange))
labels.push(getSizeLabels(sizes, metric))
labels.push(getDimensionRangeLabel(dimensionRange, metric))
labels.push(getCustomSizeLabels({ height, metric, width }))
labels.push(
getWaysToBuyLabels({
Expand Down Expand Up @@ -251,6 +259,22 @@ function getSizeLabels(sizes: string[], metric) {
})
}

const getDimensionRangeLabel = (dimensionRange: string, metric: string) => {
if (!dimensionRange) return

const dimensionRangeValue = DIMENSION_RANGES[dimensionRange]

return {
name: "Size", // Or should this be "Dimension range"?
displayValue:
metric === "cm"
? SIZES_IN_CM[dimensionRangeValue]
: SIZES_IN_INCHES[dimensionRangeValue],
value: dimensionRange,
field: "dimensionRange",
}
}

const convertToCentimeters = (element: number) => {
return Math.round(element * ONE_IN_TO_CM)
}
Expand Down

0 comments on commit ee3cf95

Please sign in to comment.