Skip to content

Commit

Permalink
Merge pull request #171 from Josmar-jr/fix/quickorder-inactive-status…
Browse files Browse the repository at this point in the history
…-message

Fix/quickorder inactive status message
  • Loading branch information
ataideverton authored Oct 2, 2024
2 parents f10beea + 9a8f68a commit 2a035c0
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Fixed the message in the status column of the SKU table, specifically inactive skus
- Fixed the return from skuFromRefIds and improve the return from getSkuSellerInfo

## [3.15.8] - 2024-10-02
### Fixed

Expand Down
3 changes: 2 additions & 1 deletion messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "متاحة",
"store/quickorder.back": "عودة",
"store/quickorder.cannotBeDelivered": "لا يمكن تسليمه",
"store/quickorder.inactive": "غير متوفر",
"store/quickorder.cannotGetSkuInfo": "تعذر الحصول على معلومات وحدة SKU",
"store/quickorder.category.addButton": "إضافة عناصر إلى العربة",
"store/quickorder.category.loading": "جاري التحميل...",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "خطأ في إضافة المنتجات إلى عربة التسوق",
"store/toaster.cart.seeCart": "مشاهدة العربة",
"store/toaster.cart.success": "تم إضافة المنتجات بنجاح إلى عربة التسوق"
}
}
3 changes: 2 additions & 1 deletion messages/context.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "store/quickorder.available",
"store/quickorder.back": "store/quickorder.back",
"store/quickorder.cannotBeDelivered": "store/quickorder.cannotBeDelivered",
"store/quickorder.inactive": "store/quickorder.inactive",
"store/quickorder.cannotGetSkuInfo": "store/quickorder.cannotGetSkuInfo",
"store/quickorder.category.addButton": "store/quickorder.category.addButton",
"store/quickorder.category.loading": "store/quickorder.category.loading",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "store/toaster.cart.error",
"store/toaster.cart.seeCart": "store/toaster.cart.seeCart",
"store/toaster.cart.success": "store/toaster.cart.success"
}
}
1 change: 1 addition & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "Available",
"store/quickorder.back": "Back",
"store/quickorder.cannotBeDelivered": "Cannot be delivered",
"store/quickorder.inactive": "Unavailable",
"store/quickorder.cannotGetSkuInfo": "Could not get SKU information",
"store/quickorder.category.addButton": "Add items to Cart",
"store/quickorder.category.loading": "Loading...",
Expand Down
3 changes: 2 additions & 1 deletion messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "Disponible",
"store/quickorder.back": "Atrás",
"store/quickorder.cannotBeDelivered": "No se puede entregar",
"store/quickorder.inactive": "Indisponible",
"store/quickorder.cannotGetSkuInfo": "No se pudo obtener la información de SKU",
"store/quickorder.category.addButton": "Agregar ítems al carrito",
"store/quickorder.category.loading": "Cargando...",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "Error al agregar productos al carrito",
"store/toaster.cart.seeCart": "Ver el carrito",
"store/toaster.cart.success": "Productos agregados correctamente"
}
}
3 changes: 2 additions & 1 deletion messages/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "Tersedia",
"store/quickorder.back": "Kembali",
"store/quickorder.cannotBeDelivered": "Tidak dapat dikirimkan",
"store/quickorder.inactive": "Tidak tersedia",
"store/quickorder.cannotGetSkuInfo": "Tidak bisa mendapat informasi SKU",
"store/quickorder.category.addButton": "Tambahkan item ke Troli",
"store/quickorder.category.loading": "Memuat…",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "Terjadi kesalahan saat menambahkan produk ke troli",
"store/toaster.cart.seeCart": "Lihat troli",
"store/toaster.cart.success": "Produk berhasil ditambahkan ke troli"
}
}
3 changes: 2 additions & 1 deletion messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "주문 가능",
"store/quickorder.back": "",
"store/quickorder.cannotBeDelivered": "배송 불가",
"store/quickorder.inactive": "사용 불가능",
"store/quickorder.cannotGetSkuInfo": "SKU 정보를 가져올 수 없습니다",
"store/quickorder.category.addButton": "장바구니가 비어있습니다",
"store/quickorder.category.loading": "로딩 중...",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "장바구니에 담기가 실패하였습니다",
"store/toaster.cart.seeCart": "장바구니",
"store/toaster.cart.success": "장바구니에 제품을 추가했습니다"
}
}
3 changes: 2 additions & 1 deletion messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "Disponível",
"store/quickorder.back": "Voltar",
"store/quickorder.cannotBeDelivered": "Não pode ser entregue",
"store/quickorder.inactive": "Indisponível",
"store/quickorder.cannotGetSkuInfo": "Não foi possível obter informações do SKU",
"store/quickorder.category.addButton": "Adicionar itens ao carrinho",
"store/quickorder.category.loading": "Carregando...",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "Erro adicionando produtos ao carrinho",
"store/toaster.cart.seeCart": "Ver o carrinho",
"store/toaster.cart.success": "Produtos adicionados com sucesso"
}
}
3 changes: 2 additions & 1 deletion messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"store/quickorder.available": "Disponibil",
"store/quickorder.back": "Inapoi",
"store/quickorder.cannotBeDelivered": "Nu poate fi livrat",
"store/quickorder.inactive": "Indisponibil",
"store/quickorder.cannotGetSkuInfo": "Nu s-au primit informațiile SKU",
"store/quickorder.category.addButton": "Adauga articole in carucior",
"store/quickorder.category.loading": "Se incarca...",
Expand Down Expand Up @@ -63,4 +64,4 @@
"store/toaster.cart.error": "Eroare la adaugarea produselor in cos",
"store/toaster.cart.seeCart": "Vezi cos",
"store/toaster.cart.success": "Produse adaugate in cos"
}
}
22 changes: 11 additions & 11 deletions node/resolvers/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ const getSkuSellers = async (
.then((res: any) => {
const validSellers = res.data?.SkuSellers
? res.data.SkuSellers.filter((seller: any) => {
// check if seller is active and available in current sales channel
return (
seller.IsActive === true && sellersIds.has(seller.SellerId)
)
}).map(({ SellerId }: any) => {
return {
id: SellerId,
name: sellerIdNameMap.get(SellerId),
}
})
// check if seller is active and available in current sales channel
return (
seller.IsActive === true && sellersIds.has(seller.SellerId)
)
}).map(({ SellerId }: any) => {
return {
id: SellerId,
name: sellerIdNameMap.get(SellerId),
}
})
: null

return {
Expand Down Expand Up @@ -303,7 +303,7 @@ export const queries = {
} 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[] }) => ({
items = result.map((item: { sellers: any[] }) => ({
...item,
sellers: item.sellers?.filter((seller: any) =>
'availability' in seller &&
Expand Down
2 changes: 1 addition & 1 deletion node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6071,7 +6071,7 @@ static-extend@^0.1.1:
define-property "^0.2.5"
object-copy "^0.1.0"

"stats-lite@github:vtex/node-stats-lite#dist":
stats-lite@vtex/node-stats-lite#dist:
version "2.2.0"
resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797"
dependencies:
Expand Down
1 change: 1 addition & 0 deletions react/TextAreaBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ const TextAreaBlock: FunctionComponent<
reviewedItems={reviewItems}
hiddenColumns={hiddenColumns ?? []}
onReviewItems={onReviewItems}
refidLoading={refidLoading}
onRefidLoading={onRefidLoading}
backList={backList}
/>
Expand Down
39 changes: 29 additions & 10 deletions react/components/ReviewBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
onReviewItems,
hiddenColumns,
reviewedItems,
refidLoading,
onRefidLoading,
intl,
backList,
Expand Down Expand Up @@ -92,6 +93,7 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
messages.withoutPriceFulfillment,
'store/quickorder.limited': messages.limited,
'store/quickorder.cannotBeDelivered': messages.cannotBeDelivered,
'store/quickorder.inactive': messages.inactive,
'store/quickorder.ORD002': messages.ORD002,
'store/quickorder.ORD003': messages.ORD003,
'store/quickorder.ORD004': messages.ORD004,
Expand Down Expand Up @@ -125,13 +127,14 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
const validateRefids = async (refidData: any, reviewed: any) => {
let error = false

// drops sellers without stock from refidData
// drops sellers from refidData
refidData?.skuFromRefIds.items.forEach((item: any) => {
if (!item?.sellers) return
item.sellers = item.sellers.filter(
(seller: any) =>
seller?.availability === 'available' ||
seller?.availability === 'partiallyAvailable'
seller?.availability === 'partiallyAvailable' ||
seller?.availability === 'withoutStock'
)
})

Expand Down Expand Up @@ -218,6 +221,10 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
? partialStockError
: `store/quickorder.withoutStock`

if (found?.sku && found?.sellers?.length === 0) {
return 'store/quickorder.inactive'
}

ret = notfound
? 'store/quickorder.skuNotFound'
: availabilityError ?? itemRestricted
Expand Down Expand Up @@ -525,12 +532,14 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
return (
<div>
<Dropdown
options={rowData.sellers.map((item: any) => {
return {
label: item.name,
value: item.id,
}
})}
options={rowData.sellers
.filter((seller) => seller?.availability !== 'withoutStock')
.map((item: any) => {
return {
label: item.name,
value: item.id,
}
})}
value={rowData.seller}
onChange={(_: any, v: any) => {
updateLineSeller(rowData.index, v)
Expand All @@ -540,7 +549,14 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
)
}

return rowData?.sellers?.length ? rowData.sellers[0].name : ''
const hasStock = rowData?.sellers?.find(
(seller?: { availability: string; [key: string]: unknown }) =>
seller?.availability !== 'withoutStock'
)

return rowData?.sellers?.length && hasStock
? rowData.sellers[0].name
: ''
},
}
}
Expand Down Expand Up @@ -572,7 +588,10 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
)
}

return intl.formatMessage({ id: 'store/quickorder.valid' })
return (
!refidLoading &&
intl.formatMessage({ id: 'store/quickorder.valid' })
)
},
}
}
Expand Down
3 changes: 3 additions & 0 deletions react/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export const reviewMessages = defineMessages({
cannotBeDelivered: {
id: `${storePrefix}cannotBeDelivered`,
},
inactive: {
id: `${storePrefix}inactive`,
},
ORD002: {
id: `${storePrefix}ORD002`,
},
Expand Down

0 comments on commit 2a035c0

Please sign in to comment.