From fe0d224757507e55675b58815299048023b51331 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Tue, 12 Nov 2024 23:13:39 +0200 Subject: [PATCH] test bug? 13 --- .../getCustomerOrdersReturn.d.ts | 2 +- .../storefront-order/chunks/getCustomerOrdersReturn.js | 10 +++++----- .../storefront-order/containers/OrderProductList.js | 2 +- .../storefront-order/containers/ReturnsList.js | 2 +- .../hooks/containers/useReturnsList.d.ts | 3 ++- scripts/__dropins__/storefront-order/reload | 2 +- .../storefront-order/types/returnsList.types.d.ts | 4 +++- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts b/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts index d426ae440f..7c1c1f422a 100644 --- a/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts +++ b/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts @@ -1,4 +1,4 @@ import { CustomerOrdersReturnModel } from '../../data/models'; -export declare const getCustomerOrdersReturn: () => Promise; +export declare const getCustomerOrdersReturn: (pageSize?: number) => Promise; //# sourceMappingURL=getCustomerOrdersReturn.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js index e5c626a509..5397f567da 100644 --- a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js @@ -1,7 +1,7 @@ -import{h as R}from"./network-error.js";import{f as e,h as E}from"./fetch-graphql.js";import{R as _,P as T,a as o,G as s,O as c,t as u}from"./transform-order-details.js";const h=` -query GET_CUSTOMER_ORDERS_RETURN { +import{h as R}from"./network-error.js";import{f as E,h as _}from"./fetch-graphql.js";import{R as T,P as o,a as s,G as c,O as u,t as h}from"./transform-order-details.js";const n=` +query GET_CUSTOMER_ORDERS_RETURN($pageSize: Int) { customer { - returns { + returns(pageSize: $pageSize) { page_info { page_size total_pages @@ -11,9 +11,9 @@ query GET_CUSTOMER_ORDERS_RETURN { } } } -${_} ${T} ${o} ${s} ${c} -`,A=async()=>await e(h,{method:"GET",cache:"force-cache"}).then(r=>{var t,a;return(t=r.errors)!=null&&t.length?E(r.errors):u((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{A as g}; +${u} +`,G=async(e=50)=>await E(n,{method:"GET",cache:"force-cache",variables:{pageSize:e}}).then(r=>{var t,a;return(t=r.errors)!=null&&t.length?_(r.errors):h((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{G as g}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderProductList.js b/scripts/__dropins__/storefront-order/containers/OrderProductList.js index 7cfd929e74..7cf1388d4a 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderProductList.js +++ b/scripts/__dropins__/storefront-order/containers/OrderProductList.js @@ -1 +1 @@ -import{jsx as s,jsxs as h}from"@dropins/tools/preact-jsx-runtime.js";import{Card as y,Header as T}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as I}from"@dropins/tools/lib.js";import{useState as g,useEffect as x,useMemo as S}from"@dropins/tools/preact-hooks.js";import{events as N}from"@dropins/tools/event-bus.js";import{s as b}from"../chunks/setTaxStatus.js";import{g as k}from"../chunks/getStoreConfig.js";import{Fragment as v}from"@dropins/tools/preact.js";import"@dropins/tools/preact-compat.js";import{e as G}from"../chunks/returnOrdersHelper.js";import{O as j}from"../chunks/OrderLoaders.js";import{C as q}from"../chunks/CartSummaryItem.js";import{useText as w}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/form.types.js";const E=({orderData:d})=>{const[a,t]=g(!0),[u,c]=g(d),[m,l]=g({taxIncluded:!1,taxExcluded:!1});return x(()=>{k().then(e=>{if(e){const n=b(e==null?void 0:e.shoppingCartDisplayPrice);l(n)}}).finally(()=>{t(!1)})},[]),x(()=>{const e=N.on("order/data",n=>{c(n)},{eager:!0});return()=>{e==null||e.off()}},[]),{loading:a,taxConfig:m,order:u}},F=({loading:d,taxConfig:a,order:t=null,withHeader:u=!0,showConfigurableOptions:c,routeProductDetails:m})=>{const l=!!(t!=null&&t.returnNumber),e=t==null?void 0:t.returnNumber,n=w({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",returned:"Order.OrderProductListContent.returnedTitle",refunded:"Order.OrderProductListContent.refundedTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),L=S(()=>{if(!t)return[];const{modifyOrder:r,returnedList:f}=G(t);if(!l){console.log("1 ---- returnedList ---- 1",f);const o=r==null?void 0:r.filter(i=>i.quantityCanceled),O=r==null?void 0:r.filter(i=>!i.quantityCanceled);return[{type:"returned",list:f,title:n.returned},{type:"cancelled",list:o,title:n.cancelled},{type:"allItems",list:O,title:n.allOrders}].filter(i=>{var P;return((P=i==null?void 0:i.list)==null?void 0:P.length)>0})}const p=t.returns.find(o=>o.returnNumber===e),C=p==null?void 0:p.items;return console.log("2 ---- returnItems ---- 2",C),[{type:"returned",list:f,title:n.returned}]},[t,l,n,e]);return t?L.every(r=>r.list.length===0)?null:s(y,{variant:"secondary",className:"order-order-product-list-content",children:L.map((r,f)=>{var C;const p=r.list.reduce((o,{totalQuantity:O})=>O+o,0);return h(v,{children:[u?s(T,{title:`${r.title} (${p})`}):null,s("ul",{className:"order-order-product-list-content__items",children:(C=r.list)==null?void 0:C.map(o=>s("li",{"data-testid":"order-product-list-content-item",children:s(q,{loading:d,product:o,itemType:r.type,taxConfig:a,translations:n,showConfigurableOptions:c,routeProductDetails:m})},o.id))})]},f)})}):s(j,{})},Z=({className:d,orderData:a,withHeader:t,showConfigurableOptions:u,routeProductDetails:c})=>{const{loading:m,taxConfig:l,order:e}=E({orderData:a});return s("div",{className:I(["order-order-product-list",d]),children:s(F,{loading:m,taxConfig:l,order:e,withHeader:t,showConfigurableOptions:u,routeProductDetails:c})})};export{Z as OrderProductList,Z as default}; +import{jsx as o,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{Card as P,Header as x}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as h}from"@dropins/tools/lib.js";import{useState as O,useEffect as g,useMemo as y}from"@dropins/tools/preact-hooks.js";import{events as T}from"@dropins/tools/event-bus.js";import{s as S}from"../chunks/setTaxStatus.js";import{g as I}from"../chunks/getStoreConfig.js";import{Fragment as k}from"@dropins/tools/preact.js";import"@dropins/tools/preact-compat.js";import{e as N}from"../chunks/returnOrdersHelper.js";import{O as b}from"../chunks/OrderLoaders.js";import{C as v}from"../chunks/CartSummaryItem.js";import{useText as G}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/form.types.js";const j=({orderData:s})=>{const[l,n]=O(!0),[a,c]=O(s),[u,d]=O({taxIncluded:!1,taxExcluded:!1});return g(()=>{I().then(t=>{if(t){const i=S(t==null?void 0:t.shoppingCartDisplayPrice);d(i)}}).finally(()=>{n(!1)})},[]),g(()=>{const t=T.on("order/data",i=>{c(i)},{eager:!0});return()=>{t==null||t.off()}},[]),{loading:l,taxConfig:u,order:a}},q=({loading:s,taxConfig:l,order:n=null,withHeader:a=!0,showConfigurableOptions:c,routeProductDetails:u})=>{const d=!!(n!=null&&n.returnNumber),t=G({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",returned:"Order.OrderProductListContent.returnedTitle",refunded:"Order.OrderProductListContent.refundedTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),i=y(()=>{if(!n)return[];const{modifyOrder:e,returnedList:m}=N(n);if(!d){const C=e==null?void 0:e.filter(r=>r.quantityCanceled),f=e==null?void 0:e.filter(r=>!r.quantityCanceled);return[{type:"returned",list:m,title:t.returned},{type:"cancelled",list:C,title:t.cancelled},{type:"allItems",list:f,title:t.allOrders}].filter(r=>{var p;return((p=r==null?void 0:r.list)==null?void 0:p.length)>0})}return[{type:"returned",list:m,title:t.returned}]},[n,d,t]);return n?i.every(e=>e.list.length===0)?null:o(P,{variant:"secondary",className:"order-order-product-list-content",children:i.map((e,m)=>{var f;const C=e.list.reduce((r,{totalQuantity:p})=>p+r,0);return L(k,{children:[a?o(x,{title:`${e.title} (${C})`}):null,o("ul",{className:"order-order-product-list-content__items",children:(f=e.list)==null?void 0:f.map(r=>o("li",{"data-testid":"order-product-list-content-item",children:o(v,{loading:s,product:r,itemType:e.type,taxConfig:l,translations:t,showConfigurableOptions:c,routeProductDetails:u})},r.id))})]},m)})}):o(b,{})},W=({className:s,orderData:l,withHeader:n,showConfigurableOptions:a,routeProductDetails:c})=>{const{loading:u,taxConfig:d,order:t}=j({orderData:l});return o("div",{className:h(["order-order-product-list",s]),children:o(q,{loading:u,taxConfig:d,order:t,withHeader:n,showConfigurableOptions:a,routeProductDetails:c})})};export{W as OrderProductList,W as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ReturnsList.js b/scripts/__dropins__/storefront-order/containers/ReturnsList.js index 3cba825243..b2722d5fbb 100644 --- a/scripts/__dropins__/storefront-order/containers/ReturnsList.js +++ b/scripts/__dropins__/storefront-order/containers/ReturnsList.js @@ -1 +1 @@ -import{jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as S}from"@dropins/tools/lib.js";import{useState as i,useEffect as $,useCallback as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as I}from"../chunks/getCustomerOrdersReturn.js";import"@dropins/tools/preact.js";import{u as y}from"../chunks/useIsMobile.js";import"@dropins/tools/preact-compat.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as M}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";import"../chunks/returnOrdersHelper.js";import"../chunks/form.types.js";import"../chunks/OrderLoaders.js";const f={totalPages:1,currentPage:1,pageSize:1},T=()=>{const[s,n]=i(!0),[o,t]=i([]),[u,a]=i(f),[m,d]=i(1);$(()=>{I().then(r=>{t((r==null?void 0:r.ordersReturn)??[]),a((r==null?void 0:r.pageInfo)??f)}).finally(()=>{n(!1)})},[]);const l=h(r=>{d(r)},[]);return{pageInfo:u,selectedPage:m,loading:s,orderReturns:o,handleSetSelectPage:l}},X=({slots:s,withReturnsListButton:n,className:o,minifiedView:t,withHeader:u,withThumbnails:a,returnsInMinifiedView:m,routeReturnDetails:d,routeOrderDetails:l,routeTracking:r,routeReturnsList:g,routeProductDetails:p})=>{const{pageInfo:L,selectedPage:R,handleSetSelectPage:O,loading:b,orderReturns:P}=T(),w=y(),e=t?"minifiedView":"fullSizeView",N=M({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return c("div",{className:S(["order-returns-list",o]),children:c(A,{minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:s,selectedPage:R,handleSetSelectPage:O,pageInfo:L,withReturnsListButton:n,isMobile:w,orderReturns:P,translations:N,withHeader:u,returnsInMinifiedView:m,withThumbnails:a,minifiedView:t,routeReturnDetails:d,routeOrderDetails:l,routeTracking:r,routeReturnsList:g,routeProductDetails:p,loading:b})})};export{X as default}; +import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as h}from"@dropins/tools/lib.js";import{useState as n,useEffect as I,useCallback as S}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as y}from"../chunks/getCustomerOrdersReturn.js";import"@dropins/tools/preact.js";import{u as A}from"../chunks/useIsMobile.js";import"@dropins/tools/preact-compat.js";import{R as M}from"../chunks/ReturnsListContent.js";import{useText as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";import"../chunks/returnOrdersHelper.js";import"../chunks/form.types.js";import"../chunks/OrderLoaders.js";const p={totalPages:1,currentPage:1,pageSize:1},V=({returnPageSize:t})=>{const[o,u]=n(!0),[i,a]=n([]),[m,s]=n(p),[d,l]=n(1);I(()=>{y(t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),s((r==null?void 0:r.pageInfo)??p)}).finally(()=>{u(!1)})},[t]);const c=S(r=>{l(r)},[]);return{pageInfo:m,selectedPage:d,loading:o,orderReturns:i,handleSetSelectPage:c}},Y=({slots:t,withReturnsListButton:o,className:u,minifiedView:i,withHeader:a,withThumbnails:m,returnPageSize:s,returnsInMinifiedView:d,routeReturnDetails:l,routeOrderDetails:c,routeTracking:r,routeReturnsList:L,routeProductDetails:g})=>{const{pageInfo:R,selectedPage:O,handleSetSelectPage:b,loading:w,orderReturns:N}=V({returnPageSize:s}),P=A(),e=i?"minifiedView":"fullSizeView",$=T({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:h(["order-returns-list",u]),children:f(M,{returnPageSize:s,minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:t,selectedPage:O,handleSetSelectPage:b,pageInfo:R,withReturnsListButton:o,isMobile:P,orderReturns:N,translations:$,withHeader:a,returnsInMinifiedView:d,withThumbnails:m,minifiedView:i,routeReturnDetails:l,routeOrderDetails:c,routeTracking:r,routeReturnsList:L,routeProductDetails:g,loading:w})})};export{Y as default}; diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useReturnsList.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useReturnsList.d.ts index 5d6fff8d0a..1b11a83db8 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useReturnsList.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useReturnsList.d.ts @@ -1,6 +1,7 @@ import { OrdersReturnPropsModel } from '../../data/models'; +import { UseReturnsListProps } from '../../types'; -export declare const useReturnsList: () => { +export declare const useReturnsList: ({ returnPageSize }: UseReturnsListProps) => { pageInfo: { totalPages: number; currentPage: number; diff --git a/scripts/__dropins__/storefront-order/reload b/scripts/__dropins__/storefront-order/reload index e5df6d1851..14a13b5f7b 100644 --- a/scripts/__dropins__/storefront-order/reload +++ b/scripts/__dropins__/storefront-order/reload @@ -1 +1 @@ -{"at":1731442315052} \ No newline at end of file +{"at":1731445995222} \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts b/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts index 02bc1b5ed4..17cf40f211 100644 --- a/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts @@ -19,6 +19,7 @@ export interface ReturnsListProps { returnOrderItem: OrdersReturnPropsModel; }>; }; + returnPageSize?: number; withReturnsListButton?: boolean; returnsInMinifiedView?: number; className?: string; @@ -38,7 +39,7 @@ export interface ReturnsListProps { routeProductDetails?: (orderItem?: OrderItemModel) => string; withThumbnails?: boolean; } -export interface ReturnsListContentProps extends Omit { +export interface ReturnsListContentProps extends Omit { minifiedViewKey: 'minifiedView' | 'fullSizeView'; orderReturns?: OrdersReturnPropsModel[] | []; translations: Record; @@ -51,6 +52,7 @@ export interface ReturnsListContentProps extends Omit