From 53c076f9c36f1dba24859a3add51c7408810f551 Mon Sep 17 00:00:00 2001 From: AnnaChiu95 <53097865+AnnaChiu95@users.noreply.github.com> Date: Fri, 1 Jul 2022 10:32:24 -0400 Subject: [PATCH 1/3] [QUICKORDER-26] Filter out sellers unavailable in orderForm's sales channel, Add error message when query for SKU info fails in ReviewBlock --- CHANGELOG.md | 8 ++++++++ messages/ar.json | 1 + messages/context.json | 1 + messages/en.json | 1 + messages/es.json | 1 + messages/ko.json | 1 + messages/pt.json | 1 + messages/ro.json | 1 + node/clients/search.ts | 28 ++++++++++++++++++++++++---- react/TextAreaBlock.tsx | 1 + react/UploadBlock.tsx | 1 + react/components/ReviewBlock.tsx | 24 +++++++++++++++++++----- 12 files changed, 60 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb1e1924..e072de42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Fixed checkout simulation error by filtering out sellers unavailable in orderForm's sales channel + +### Added + +- Added error message when query for SKU info fails in ReviewBlock + ## [3.9.2] - 2022-06-27 ### Added diff --git a/messages/ar.json b/messages/ar.json index 7245434e..d0348c82 100644 --- a/messages/ar.json +++ b/messages/ar.json @@ -35,6 +35,7 @@ "store/quickorder.available": "متاحة", "store/quickorder.back": "عودة", "store/quickorder.cannotBeDelivered": "لا يمكن تسليمه", + "store/quickorder.cannotGetSkuInfo": "تعذر الحصول على معلومات وحدة SKU", "store/quickorder.category.addButton": "إضافة عناصر إلى العربة", "store/quickorder.category.loading": "جاري التحميل...", "store/quickorder.category.noneSelection": "أدخل بعض الكمية على العناصر", diff --git a/messages/context.json b/messages/context.json index 02fecd4c..304c2a47 100644 --- a/messages/context.json +++ b/messages/context.json @@ -35,6 +35,7 @@ "store/quickorder.available": "store/quickorder.available", "store/quickorder.back": "store/quickorder.back", "store/quickorder.cannotBeDelivered": "store/quickorder.cannotBeDelivered", + "store/quickorder.cannotGetSkuInfo": "store/quickorder.cannotGetSkuInfo", "store/quickorder.category.addButton": "store/quickorder.category.addButton", "store/quickorder.category.loading": "store/quickorder.category.loading", "store/quickorder.category.noneSelection": "store/quickorder.category.noneSelection", diff --git a/messages/en.json b/messages/en.json index 7fee5c77..4242667a 100644 --- a/messages/en.json +++ b/messages/en.json @@ -35,6 +35,7 @@ "store/quickorder.available": "Available", "store/quickorder.back": "Back", "store/quickorder.cannotBeDelivered": "Cannot be delivered", + "store/quickorder.cannotGetSkuInfo": "Could not get SKU information", "store/quickorder.category.addButton": "Add items to Cart", "store/quickorder.category.loading": "Loading...", "store/quickorder.category.noneSelection": "Enter some quantity on the items", diff --git a/messages/es.json b/messages/es.json index 655d3c9d..b2cbfe21 100644 --- a/messages/es.json +++ b/messages/es.json @@ -35,6 +35,7 @@ "store/quickorder.available": "Disponible", "store/quickorder.back": "Atrás", "store/quickorder.cannotBeDelivered": "No se puede entregar", + "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...", "store/quickorder.category.noneSelection": "Ingresa una cantidad en los ítems", diff --git a/messages/ko.json b/messages/ko.json index f187aaf4..1c0a4d1c 100644 --- a/messages/ko.json +++ b/messages/ko.json @@ -35,6 +35,7 @@ "store/quickorder.available": "주문 가능", "store/quickorder.back": "뒤", "store/quickorder.cannotBeDelivered": "배송 불가", + "store/quickorder.cannotGetSkuInfo": "SKU 정보를 가져올 수 없습니다", "store/quickorder.category.addButton": "장바구니가 비어있습니다", "store/quickorder.category.loading": "로딩 중...", "store/quickorder.category.noneSelection": "주문 수량을 입력해주세요", diff --git a/messages/pt.json b/messages/pt.json index 0ba26768..cedb2425 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -35,6 +35,7 @@ "store/quickorder.available": "Disponível", "store/quickorder.back": "Voltar", "store/quickorder.cannotBeDelivered": "Não pode ser entregue", + "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...", "store/quickorder.category.noneSelection": "Informe alguma quantidade nos items desejados", diff --git a/messages/ro.json b/messages/ro.json index 5ae3913c..d12d0dfd 100644 --- a/messages/ro.json +++ b/messages/ro.json @@ -35,6 +35,7 @@ "store/quickorder.available": "Disponibil", "store/quickorder.back": "Inapoi", "store/quickorder.cannotBeDelivered": "Nu poate fi livrat", + "store/quickorder.cannotGetSkuInfo": "Nu s-au primit informațiile SKU", "store/quickorder.category.addButton": "Adauga articole in carucior", "store/quickorder.category.loading": "Se incarca...", "store/quickorder.category.noneSelection": "Introduceti cantitati", diff --git a/node/clients/search.ts b/node/clients/search.ts index 33cef7fb..4ac2aa71 100644 --- a/node/clients/search.ts +++ b/node/clients/search.ts @@ -57,6 +57,14 @@ export class Search extends JanusClient { const resultStr: any = {} if (res.status === 200) { + const orderForm = await this.getOrderForm(orderFormId) + const { salesChannel } = orderForm + + // filter out sellers that aren't available in current sales channel + this.sellersList = this.sellersList?.filter(seller => { + return seller.availableSalesChannels.includes(Number(salesChannel)) + }) + const refs = Object.getOwnPropertyNames(res.data) refs.forEach(id => { @@ -76,8 +84,6 @@ export class Search extends JanusClient { result = await Promise.all(promises) } - const orderForm = await this.getOrderForm(orderFormId) - // update refIdSellerMap to include list of sellers by SKU result.forEach((item: any) => { refIdSellerMap[item.refid] = item.sellers @@ -91,6 +97,8 @@ export class Search extends JanusClient { refIdSellerMap ) + if (!items.length) return items + const resItems = items.reduce((acc: any, item: any) => { const sellerInfo = { seller: item.seller, @@ -207,7 +215,12 @@ export class Search extends JanusClient { sku: skuId, refid, sellers: res.data.SkuSellers.filter((item: any) => { - return item.IsActive === true + // check if seller is available in current sales channel + const inSellersList = this.sellersList?.find(seller => { + return seller.id === item.SellerId + }) + + return item.IsActive === true && inSellersList }).map(({ SellerId }: any) => { return { id: SellerId, @@ -235,10 +248,17 @@ export class Search extends JanusClient { .filter((item: any) => { return item.isActive === true }) - .map(({ id, name }: any) => { + .map(({ id, name, availableSalesChannels }: any) => { + const availableSalesChannelsIds = availableSalesChannels.map( + (sc: { id: number }) => { + return sc.id + } + ) + return { id, name, + availableSalesChannels: availableSalesChannelsIds, } }) } diff --git a/react/TextAreaBlock.tsx b/react/TextAreaBlock.tsx index c61502f4..41ca9121 100644 --- a/react/TextAreaBlock.tsx +++ b/react/TextAreaBlock.tsx @@ -317,6 +317,7 @@ const TextAreaBlock: FunctionComponent< hiddenColumns={hiddenColumns ?? []} onReviewItems={onReviewItems} onRefidLoading={onRefidLoading} + backList={backList} />