Skip to content

Commit

Permalink
Merge pull request #169 from giurigaud/fix/quickorder
Browse files Browse the repository at this point in the history
fix: return from skuFromRefIds
  • Loading branch information
ataideverton authored Oct 2, 2024
2 parents 54b6848 + 96644e3 commit d47b294
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed

- Fixed the return from skuFromRefIds and improve the return from getSkuSellerInfo

## [3.15.7] - 2024-09-26

Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@gocommerce/utils": "^0.7.3",
"@vtex/api": "6.46.1",
"@vtex/api": "6.47.0",
"atob": "^2.1.2",
"axios": "^0.19.0",
"camelcase": "^5.0.0",
Expand Down
22 changes: 17 additions & 5 deletions node/resolvers/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ const getSkuSellerInfo = (simulationResults: any, result: any) => {

if (Object.keys(simulationResults).length !== 0) {
items = result.map((item: any) => {
const skuInfoBySeller = item.sellers?.map((seller: any) => {
const skuInfoBySeller = item.sellers?.flatMap((seller: any) => {
if (!simulationResults[item.sku]) {
return null
return [];
}

const currSeller = simulationResults[item.sku].sellers.find(
Expand All @@ -210,7 +210,7 @@ const getSkuSellerInfo = (simulationResults: any, result: any) => {

return {
...item,
sellers: item.sellers ? skuInfoBySeller : null,
sellers: skuInfoBySeller,
}
})
}
Expand Down Expand Up @@ -297,8 +297,20 @@ export const queries = {
},
ctx
).then(simulationResults => {
// include SKU's availability and unit multiplier info in given seller
items = getSkuSellerInfo(simulationResults, result)
if (Object.keys(simulationResults).length !== 0) {
// include SKU's availability and unit multiplier info in given seller
items = getSkuSellerInfo(simulationResults, result)
} else {
// ensures that each item in the result array has a sellers array that only includes sellers with a defined and non-null availability property.
// If no such sellers exist, the sellers array will be empty.
items = result.map((item: { sellers: any[] }) => ({
...item,
sellers: item.sellers?.filter((seller: any) =>
'availability' in seller &&
seller.availability !== null
) || []
}))
}
})
} catch (error) {
logger.error({
Expand Down
10 changes: 5 additions & 5 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1863,10 +1863,10 @@
resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.0.tgz#8b63ab7f1aa5321248aad5ac890a485656dcea4d"
integrity sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg==

"@vtex/api@6.46.1":
version "6.46.1"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.46.1.tgz#55a8755ae48f5400e7f1ed1921cd547950bb7a2a"
integrity sha512-geoxVvyWoQpOQ70Zmx3M8SBkRoGOS/bp9Gy26M+iCue63jofVSwmFz1zf66EaHA1PKOJNRgQPFwY+oeDE1U2lQ==
"@vtex/api@6.47.0":
version "6.47.0"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.47.0.tgz#6910455d593d8bb76f1f4f2b7660023853fda35e"
integrity sha512-t9gt7Q89EMbSj3rLhho+49Fv+/lQgiy8EPVRgtmmXFp1J4v8hIAZF7GPjCPie111KVs4eG0gfZFpmhA5dafKNA==
dependencies:
"@types/koa" "^2.11.0"
"@types/koa-compose" "^3.2.3"
Expand Down Expand Up @@ -6071,7 +6071,7 @@ static-extend@^0.1.1:
define-property "^0.2.5"
object-copy "^0.1.0"

stats-lite@vtex/node-stats-lite#dist:
"stats-lite@github:vtex/node-stats-lite#dist":
version "2.2.0"
resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797"
dependencies:
Expand Down

0 comments on commit d47b294

Please sign in to comment.