Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add saved search preview label for dimensionRange attribute #5535

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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