Skip to content

Commit dbce3c1

Browse files
author
rebeca
committed
fix merge conflits space
1 parent 2db6847 commit dbce3c1

File tree

1 file changed

+85
-85
lines changed

1 file changed

+85
-85
lines changed

react/components/SKUSelector/components/SKUSelector.tsx

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -141,68 +141,68 @@ const parseOptionNameToDisplayOption =
141141
hideImpossibleCombinations: boolean
142142
disableUnavailableSelectOptions: boolean
143143
}) =>
144-
(variationValue: {
145-
name: string
146-
originalName: string
147-
}): DisplayOption | null => {
148-
const isSelected = selectedVariations[variationName] === variationValue.name
149-
const image = imagesMap?.[variationName]?.[variationValue.name]
150-
151-
const newSelectedVariation = clone(selectedVariations)
152-
153-
newSelectedVariation[variationName] = isSelected
154-
? null
155-
: variationValue.name
156-
157-
const possibleItems = findListItemsWithSelectedVariations(
158-
skuItems,
159-
newSelectedVariation
160-
)
144+
(variationValue: {
145+
name: string
146+
originalName: string
147+
}): DisplayOption | null => {
148+
const isSelected = selectedVariations[variationName] === variationValue.name
149+
const image = imagesMap?.[variationName]?.[variationValue.name]
150+
151+
const newSelectedVariation = clone(selectedVariations)
152+
153+
newSelectedVariation[variationName] = isSelected
154+
? null
155+
: variationValue.name
156+
157+
const possibleItems = findListItemsWithSelectedVariations(
158+
skuItems,
159+
newSelectedVariation
160+
)
161161

162-
if (possibleItems.length > 0) {
163-
// This is a valid combination option
164-
const [item] = possibleItems
165-
const callbackFn = onSelectItemMemo({
166-
name: variationName,
167-
value: variationValue.name,
168-
skuId: item.itemId,
169-
isMainAndImpossible: false,
170-
possibleItems,
171-
})
172-
173-
return {
174-
label: variationValue.name,
175-
originalName: variationValue.originalName,
176-
onSelectItem: callbackFn,
177-
image,
178-
available: showItemAsAvailable({
162+
if (possibleItems.length > 0) {
163+
// This is a valid combination option
164+
const [item] = possibleItems
165+
const callbackFn = onSelectItemMemo({
166+
name: variationName,
167+
value: variationValue.name,
168+
skuId: item.itemId,
169+
isMainAndImpossible: false,
179170
possibleItems,
180-
selectedVariations,
181-
variationCount,
182-
isSelected,
183-
}),
184-
impossible: false,
185-
disabled: disableUnavailableSelectOptions,
171+
})
172+
173+
return {
174+
label: variationValue.name,
175+
originalName: variationValue.originalName,
176+
onSelectItem: callbackFn,
177+
image,
178+
available: showItemAsAvailable({
179+
possibleItems,
180+
selectedVariations,
181+
variationCount,
182+
isSelected,
183+
}),
184+
impossible: false,
185+
disabled: disableUnavailableSelectOptions,
186+
}
186187
}
187-
}
188188

189-
if (!hideImpossibleCombinations) {
190-
// This is a impossible combination and will only appear if the prop allows.
191-
return {
192-
label: variationValue.name,
193-
originalName: variationValue.originalName,
194-
// eslint-disable-next-line @typescript-eslint/no-empty-function
195-
onSelectItem: () => {},
196-
image,
197-
available: true,
198-
impossible: true,
199-
disabled: disableUnavailableSelectOptions,
189+
if (!hideImpossibleCombinations) {
190+
// This is a impossible combination and will only appear if the prop allows.
191+
return {
192+
label: variationValue.name,
193+
originalName: variationValue.originalName,
194+
// eslint-disable-next-line @typescript-eslint/no-empty-function
195+
onSelectItem: () => {},
196+
image,
197+
available: true,
198+
impossible: true,
199+
disabled: disableUnavailableSelectOptions,
200+
}
200201
}
201-
}
202202

203-
// This is a impossible combination and will be hidden.
204-
return null
205-
}
203+
// This is a impossible combination and will be hidden.
204+
return null
205+
}
206206

207207
const variationNameToDisplayVariation =
208208
({
@@ -224,33 +224,33 @@ const variationNameToDisplayVariation =
224224
variationCount: number
225225
hideImpossibleCombinations: boolean
226226
disableUnavailableSelectOptions: boolean
227-
sortVariationsByLabel:boolean
227+
sortVariationsByLabel: boolean
228228
}) =>
229-
(variationName: string): DisplayVariation => {
230-
const name = variationName
231-
const { values, originalName } = variations[variationName]
232-
const options = values
233-
.map(
234-
parseOptionNameToDisplayOption({
235-
selectedVariations,
236-
variationName,
237-
skuItems,
238-
onSelectItemMemo,
239-
imagesMap,
240-
variationCount,
241-
hideImpossibleCombinations,
242-
disableUnavailableSelectOptions,
243-
})
244-
)
245-
.filter(Boolean) as DisplayOption[]
229+
(variationName: string): DisplayVariation => {
230+
const name = variationName
231+
const { values, originalName } = variations[variationName]
232+
const options = values
233+
.map(
234+
parseOptionNameToDisplayOption({
235+
selectedVariations,
236+
variationName,
237+
skuItems,
238+
onSelectItemMemo,
239+
imagesMap,
240+
variationCount,
241+
hideImpossibleCombinations,
242+
disableUnavailableSelectOptions,
243+
})
244+
)
245+
.filter(Boolean) as DisplayOption[]
246246

247-
if(sortVariationsByLabel) {
248-
options.sort((a,b)=> {
247+
if (sortVariationsByLabel) {
248+
options.sort((a,b) => {
249249
return a.label < b.label ? -1 : a.label > b.label ? 1 : 0;
250250
})
251-
}
252-
return { name, originalName, options }
253-
}
251+
}
252+
return { name, originalName, options }
253+
}
254254

255255
// Parameters are explained on PropTypes
256256
const getAvailableVariations = ({
@@ -320,12 +320,12 @@ function SKUSelector({
320320
const variationsSpacing = getValidMarginBottom(marginBottomProp)
321321
const onSelectItemMemo = useCallback(
322322
({
323-
name,
324-
value,
325-
skuId,
326-
isMainAndImpossible,
327-
possibleItems,
328-
}: CallbackItem) =>
323+
name,
324+
value,
325+
skuId,
326+
isMainAndImpossible,
327+
possibleItems,
328+
}: CallbackItem) =>
329329
() =>
330330
onSelectItem({
331331
name,

0 commit comments

Comments
 (0)