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 to show product name on autocomplete options #166

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
"changeProcessCWD": true
}
]
}
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [3.15.3] - 2024-06-10

### Changed

- Adjust autocomplete list to show product name rather than just the product sku name

## [3.15.2] - 2024-06-10

## [3.15.1] - 2024-05-27
Expand Down Expand Up @@ -587,4 +591,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Add css handles to selected sku on AutoComplete block.
- Add css handles to selected sku on AutoComplete block.
4 changes: 3 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
},
"free": true,
"type": "free",
"availableCountries": ["*"]
"availableCountries": [
"*"
]
},
"$schema": "https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema"
}
32 changes: 15 additions & 17 deletions react/components/QuickOrderAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ const CustomOption = (props: any) => {
)
}

const buttonClasses = `${
handles.customOptionButton
} bn w-100 tl pointer pa4 f6 ${roundedBottom ? 'br2 br--bottom' : ''} ${
highlightOption || selected ? 'bg-muted-5' : 'bg-base'
}`
const buttonClasses = `${handles.customOptionButton
} bn w-100 tl pointer pa4 f6 ${roundedBottom ? 'br2 br--bottom' : ''} ${highlightOption || selected ? 'bg-muted-5' : 'bg-base'
}`

const thumb = value.thumb ? value.thumb : ''

Expand Down Expand Up @@ -116,17 +114,17 @@ const QuickOrderAutocomplete: FunctionComponent<
value: !term.length
? []
: optionsResult
.filter((item: any) => {
return !!item.items[0].images[0].imageUrl
})
.map((item: any) => {
return {
value: item.items[0].itemId,
label: item.items[0].name,
slug: item.linkText,
thumb: getImageSrc(item.items[0].images[0].imageUrl),
}
}),
.filter((item: any) => {
return !!item.items[0].images[0].imageUrl
})
.map((item: any) => {
return {
value: item.productId,
rayssamfreitas marked this conversation as resolved.
Show resolved Hide resolved
label: item.productName,
slug: item.linkText,
thumb: getImageSrc(item.items[0].images[0].imageUrl),
}
}),
lastSearched: {
value: lastSearched,
label: 'Last searched products',
Expand Down Expand Up @@ -156,7 +154,7 @@ const QuickOrderAutocomplete: FunctionComponent<
setTerm(nterm)
}
},
onSearch: () => () => {},
onSearch: () => () => { },
onClear: () => setTerm(''),
placeholder: intl.formatMessage(messages.placeholder),
value: term,
Expand Down
2 changes: 2 additions & 0 deletions react/queries/autocomplete.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ query Autocomplete($inputValue: String!) {
productSuggestions(fullText: $inputValue, hideUnavailableItems: true)
@context(provider: "vtex.search-graphql") {
products {
productName
productId
items {
itemId
name
Expand Down