diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js index e50d158c2..7c67a5b32 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as n}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql.js";import{t as E}from"./transform-attributes-form.js";import{a as R}from"./convertCase.js";const T=` +import{h as s}from"./network-error.js";import{f as i,h as o}from"./fetch-graphql.js";import{t as E}from"./transform-attributes-form.js";import{a as R}from"./convertCase.js";const _=` query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) { attributesList(entityType: $entityType) { items { @@ -33,7 +33,7 @@ import{h as n}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql } } } -`,y=async a=>await s(T,{method:"GET",cache:"force-cache",variables:{entityType:a}}).then(e=>{var t,r,u;return(t=e.errors)!=null&&t.length?o(e.errors):E((u=(r=e==null?void 0:e.data)==null?void 0:r.attributesList)==null?void 0:u.items)}).catch(n),c=` +`,f=async u=>await i(_,{method:"GET",cache:"force-cache",variables:{entityType:u}}).then(e=>{var t,r,a;return(t=e.errors)!=null&&t.length?o(e.errors):E((a=(r=e==null?void 0:e.data)==null?void 0:r.attributesList)==null?void 0:a.items)}).catch(s),c=` fragment OrderReturn on Return { __typename uid @@ -41,7 +41,7 @@ import{h as n}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql number created_at } -`,_=` +`,T=` mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { requestReturn(input: $input) { return { @@ -49,7 +49,7 @@ mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { } } } -${c}`,f=async a=>{const e=R(a,"snakeCase",{});return await s(_,{method:"POST",variables:{input:e}}).then(t=>{var i;if((i=t.errors)!=null&&i.length)return o(t.errors);const{created_at:r,...u}=t.data.requestReturn.return;return{...u,createdAt:r}}).catch(n)},l=` +${c}`,y=async u=>{const e=R(u,"snakeCase",{});return await i(T,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return o(t.errors);const{created_at:r,...a}=t.data.requestReturn.return;return{...a,createdAt:r}}).catch(s)},d=` mutation REQUEST_RETURN_GUEST_ORDER($input: RequestGuestReturnInput!) { requestGuestReturn(input: $input) { return { @@ -57,4 +57,4 @@ mutation REQUEST_RETURN_GUEST_ORDER($input: RequestGuestReturnInput!) { } } } -${c}`,U=async a=>{const e=R(a,"snakeCase",{});return console.log("input",e),await s(l,{method:"POST",variables:{input:e}}).then(t=>{var r,u;return console.log("response",t),console.log(" response.data.requestGuestReturn.return",(u=(r=t==null?void 0:t.data)==null?void 0:r.requestGuestReturn)==null?void 0:u.return),null}).catch(n)};export{U as a,y as g,f as r}; +${c}`,U=async u=>{const e=R(u,"snakeCase",{});return await i(d,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return o(t.errors);const{created_at:r,...a}=t.data.requestGuestReturn.return;return{...a,createdAt:r}}).catch(s)};export{U as a,f as g,y as r}; diff --git a/scripts/__dropins__/storefront-order/containers/CreateReturn.js b/scripts/__dropins__/storefront-order/containers/CreateReturn.js index c58922a07..4749cc9d2 100644 --- a/scripts/__dropins__/storefront-order/containers/CreateReturn.js +++ b/scripts/__dropins__/storefront-order/containers/CreateReturn.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as H}from"@dropins/tools/lib.js";import{Icon as $,Header as W,InLineAlert as j,Button as M,Checkbox as V,CartItem as Z,Image as D}from"@dropins/tools/components.js";import{useState as w,useRef as U,useEffect as q,useCallback as Q}from"@dropins/tools/preact-hooks.js";import{u as G,a as z}from"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{u as J}from"../chunks/useGetStoreConfig.js";import{createRef as K,Fragment as X}from"@dropins/tools/preact.js";import{s as Y,p as I,r as ee,m as te}from"../chunks/returnOrdersHelper.js";import{events as ne}from"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getQueryParam.js";import{g as re,r as se,a as ae}from"../chunks/requestGuestReturn.js";import{s as ie}from"../chunks/setTaxStatus.js";import{S as ce,C as ue}from"../chunks/CartSummaryItem.js";import{a as oe}from"../chunks/OrderLoaders.js";import{useText as le}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/transform-attributes-form.js";import"../chunks/convertCase.js";const de=a=>_.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("g",{clipPath:"url(#clip0_841_1324)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_841_1324"},_.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),pe=a=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),me=({onSuccess:a,onError:s,handleSetInLineAlert:i,orderData:d})=>{const[k,L]=w(!1),[o,R]=w({id:"",email:"",...d}),[v,x]=w("products"),[g,l]=w(!0),[m,f]=w([]),[O,t]=w([]),[h,e]=w([]),c=U([]);c.current.length!==m.length&&(c.current=m.map((n,p)=>c.current[p]||K())),q(()=>{const n=ne.on("order/data",p=>{var u;R(p);const C=Y(p);e(C),L(((u=A("orderRef"))==null?void 0:u.length)>20),l(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),q(()=>{re("RMA_ITEM").then(n=>{n!=null&&n.length&&(t(n),l(!1))})},[]);const y=Q(n=>{f(p=>p.findIndex(u=>(u==null?void 0:u.productSku)===(n==null?void 0:n.productSku))>-1?p.filter(u=>(u==null?void 0:u.productSku)!==(n==null?void 0:n.productSku)):[...p,n])},[]),S=Q(n=>{x(n),i(),n==="products"&&f([])},[i]),E=Q((n,p)=>{const C=m.map(u=>u.productSku===p?{...u,currentReturnOrderQuantity:n}:u);f(C)},[m]),F=Q(async(n,p)=>{if(!p)return;l(!0);const C={orderUid:o.id,contactEmail:o.email},u=I(c);console.log("{ ...orderReturnInfo, items }",{...C,items:u}),k?ae({token:A("orderRef"),contactEmail:C.contactEmail,items:u,commentText:"."}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}):se({...C,items:u}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}),l(!1)},[S,s,a,i,o,k]);return{order:o,steps:v,loading:g,formsRef:c,attributesList:O,selectedProductList:m,itemsEligibleForReturn:h,handleSelectedProductList:y,handleSetQuantity:E,handleChangeStep:S,onSubmit:F}},he={success:pe,warning:de,error:ce},ge=()=>{const[a,s]=w({type:"success",heading:""}),i=Q(d=>{if(!(d!=null&&d.type)){s({type:"success",heading:""});return}const k=r($,{source:he[d.type]});s({...d,icon:k})},[]);return{inLineAlertProps:a,handleSetInLineAlert:i}},We=({className:a,orderData:s,slots:i,onSuccess:d,onError:k,routeReturnSuccess:L,showConfigurableOptions:o})=>{const R=le({headerText:"Order.CreateReturn.headerText",successTitle:"Order.CreateReturn.success.title",successMessage:"Order.CreateReturn.success.message",sender:"Order.CreateReturn.giftCard.sender",recipient:"Order.CreateReturn.giftCard.recipient",message:"Order.CreateReturn.giftCard.message",outOfStock:"Order.CreateReturn.stockStatus.outOfStock",nextStep:"Order.CreateReturn.buttons.nextStep",backStep:"Order.CreateReturn.buttons.backStep",submit:"Order.CreateReturn.buttons.submit",backStore:"Order.CreateReturn.buttons.backStore",downloadableCount:"Order.CreateReturn.downloadableCount",returnedItems:"Order.CreateReturn.returnedItems",configurationsListQuantity:"Order.CreateReturn.configurationsList.quantity"}),{inLineAlertProps:v,handleSetInLineAlert:x}=ge(),g=J(),{order:l,itemsEligibleForReturn:m,formsRef:f,attributesList:O,steps:t,loading:h,selectedProductList:e,handleSelectedProductList:c,handleSetQuantity:y,handleChangeStep:S,onSubmit:E}=me({orderData:s,onSuccess:d,onError:k,handleSetInLineAlert:x});if(h)return r("div",{children:r(oe,{})});if(!h&&!O.length)return r("div",{});const F=(g==null?void 0:g.baseMediaUrl)??"";console.log("itemsEligibleForReturn",m);const n={products:r(be,{itemsEligibleForReturn:m,placeholderImage:F,taxConfig:ie((g==null?void 0:g.shoppingCartDisplayPrice)??0),slots:i,translations:R,loading:h,selectedProductList:e,handleSelectedProductList:c,showConfigurableOptions:o,handleSetQuantity:y,handleChangeStep:S}),attributes:r(ke,{placeholderImage:F,slots:i,formsRef:f,loading:h,fieldsConfig:O,selectedProductList:e,handleChangeStep:S,translations:R,onSubmit:E}),success:r(fe,{translations:R,routeReturnSuccess:L,orderData:l}),error:null};return N("div",{className:B(["order-create-return",a]),children:[r(W,{title:R.headerText}),v.heading?r(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...v}):null,n[t]]})},fe=({routeReturnSuccess:a,translations:s,orderData:i})=>N("div",{className:"order-return-order-message",children:[r("p",{className:"order-return-order-message__title",children:s.successTitle}),r("p",{className:"order-return-order-message__subtitle",children:s.successMessage}),r(M,{href:(a==null?void 0:a(i))??"#",children:s.backStore})]}),be=({placeholderImage:a,itemsEligibleForReturn:s,slots:i,loading:d,taxConfig:k,translations:L,selectedProductList:o,handleSelectedProductList:R,showConfigurableOptions:v,handleSetQuantity:x,handleChangeStep:g})=>N("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((l,m)=>{const{quantityReturnRequested:f,quantityShipped:O,eligibleForReturn:t}=l;console.log("item",l);const h=o.some(y=>(y==null?void 0:y.productSku)===l.productSku&&l.eligibleForReturn),e=O===f&&t,c=O-f===0?f:O-f;return N("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(V,{"data-testid":`key_${m}`,name:`key_${m}`,checked:h,disabled:e,onChange:()=>{R({...l,currentReturnOrderQuantity:1})}}),r(ue,{placeholderImage:a,loading:d,product:{...l,totalQuantity:c||1},itemType:"",taxConfig:k,translations:L,showConfigurableOptions:v,disabledIncrementer:!h,onQuantity:c>1?y=>{x(y,l.productSku)}:void 0}),r(H,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:i==null?void 0:i.ReturnOrderItem})]},l.id)}),r("li",{className:"order-return-order-product-list__item",children:r(M,{type:"button",onClick:()=>g("attributes"),disabled:!o.length,children:L.nextStep})})]}),ke=({placeholderImage:a,slots:s,formsRef:i,selectedProductList:d,loading:k,fieldsConfig:L,translations:o,handleChangeStep:R,onSubmit:v})=>{const{formData:x,errors:g,formRef:l,handleChange:m,handleBlur:f,handleSubmit:O}=G({fieldsConfig:ee(L,d==null?void 0:d.length),onSubmit:v});return N("form",{className:"order-return-reason-form",ref:l,onSubmit:O,name:"returnReasonForm",children:[d.map((t,h)=>{var p,C,u,b,P,T;const e=t==null?void 0:t.giftCard,c=t==null?void 0:t.product,y=te(L,h),S=`${t==null?void 0:t.id}_${h}`,E=(t==null?void 0:t.currentReturnOrderQuantity)??1,F={...t!=null&&t.currentReturnOrderQuantity?{[o.configurationsListQuantity]:E}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[o.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[o.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[o.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[o.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[o.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(p=t==null?void 0:t.downloadableLinks)==null?void 0:p.count} ${o.downloadableCount}`]:(C=t==null?void 0:t.downloadableLinks)==null?void 0:C.result}:{}},n=(b=(u=c==null?void 0:c.thumbnail)==null?void 0:u.url)!=null&&b.length?c.thumbnail.url:a;return N(X,{children:[r(Z,{loading:k,title:r("div",{"data-testid":"product-name",children:(P=t==null?void 0:t.product)==null?void 0:P.name}),sku:r("div",{children:c==null?void 0:c.sku}),image:r(D,{src:n,alt:((T=c==null?void 0:c.thumbnail)==null?void 0:T.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:F}),r("form",{name:S,ref:i==null?void 0:i.current[h],"data-quantity":E,children:r(z,{className:"className",loading:k,fields:y,onChange:m,onBlur:f,errors:g,values:x})})]},t.id)}),r(H,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:R},children:N("div",{className:"order-return-reason-form__actions",children:[r(M,{variant:"secondary",type:"button",onClick:()=>{R("products")},children:o.backStep}),r(M,{children:o.submit})]})})]})};export{We as CreateReturn,We as default}; +import{jsx as r,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as H}from"@dropins/tools/lib.js";import{Icon as $,Header as W,InLineAlert as j,Button as M,Checkbox as V,CartItem as Z,Image as D}from"@dropins/tools/components.js";import{useState as w,useRef as U,useEffect as q,useCallback as F}from"@dropins/tools/preact-hooks.js";import{u as G,a as z}from"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{u as J}from"../chunks/useGetStoreConfig.js";import{createRef as K,Fragment as X}from"@dropins/tools/preact.js";import{s as Y,p as I,r as ee,m as te}from"../chunks/returnOrdersHelper.js";import{events as ne}from"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getQueryParam.js";import{g as re,r as se,a as ae}from"../chunks/requestGuestReturn.js";import{s as ie}from"../chunks/setTaxStatus.js";import{S as ce,C as ue}from"../chunks/CartSummaryItem.js";import{a as oe}from"../chunks/OrderLoaders.js";import{useText as le}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/transform-attributes-form.js";import"../chunks/convertCase.js";const de=a=>_.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("g",{clipPath:"url(#clip0_841_1324)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_841_1324"},_.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),pe=a=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),me=({onSuccess:a,onError:s,handleSetInLineAlert:i,orderData:l})=>{const[k,L]=w(!1),[o,R]=w({id:"",email:"",...l}),[v,x]=w("products"),[h,d]=w(!0),[g,f]=w([]),[C,t]=w([]),[m,e]=w([]),c=U([]);c.current.length!==g.length&&(c.current=g.map((n,p)=>c.current[p]||K())),q(()=>{const n=ne.on("order/data",p=>{var u;R(p);const O=Y(p);e(O),L(((u=A("orderRef"))==null?void 0:u.length)>20),d(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),q(()=>{re("RMA_ITEM").then(n=>{n!=null&&n.length&&(t(n),d(!1))})},[]);const y=F(n=>{f(p=>p.findIndex(u=>(u==null?void 0:u.productSku)===(n==null?void 0:n.productSku))>-1?p.filter(u=>(u==null?void 0:u.productSku)!==(n==null?void 0:n.productSku)):[...p,n])},[]),S=F(n=>{x(n),i(),n==="products"&&f([])},[i]),E=F((n,p)=>{const O=g.map(u=>u.productSku===p?{...u,currentReturnOrderQuantity:n}:u);f(O)},[g]),Q=F(async(n,p)=>{if(!p)return;d(!0);const O={orderUid:o.id,contactEmail:o.email},u=I(c);k?ae({token:A("orderRef"),contactEmail:O.contactEmail,items:u,commentText:"."}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}):se({...O,items:u}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}),d(!1)},[S,s,a,i,o,k]);return{order:o,steps:v,loading:h,formsRef:c,attributesList:C,selectedProductList:g,itemsEligibleForReturn:m,handleSelectedProductList:y,handleSetQuantity:E,handleChangeStep:S,onSubmit:Q}},he={success:pe,warning:de,error:ce},ge=()=>{const[a,s]=w({type:"success",heading:""}),i=F(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const k=r($,{source:he[l.type]});s({...l,icon:k})},[]);return{inLineAlertProps:a,handleSetInLineAlert:i}},We=({className:a,orderData:s,slots:i,onSuccess:l,onError:k,routeReturnSuccess:L,showConfigurableOptions:o})=>{const R=le({headerText:"Order.CreateReturn.headerText",successTitle:"Order.CreateReturn.success.title",successMessage:"Order.CreateReturn.success.message",sender:"Order.CreateReturn.giftCard.sender",recipient:"Order.CreateReturn.giftCard.recipient",message:"Order.CreateReturn.giftCard.message",outOfStock:"Order.CreateReturn.stockStatus.outOfStock",nextStep:"Order.CreateReturn.buttons.nextStep",backStep:"Order.CreateReturn.buttons.backStep",submit:"Order.CreateReturn.buttons.submit",backStore:"Order.CreateReturn.buttons.backStore",downloadableCount:"Order.CreateReturn.downloadableCount",returnedItems:"Order.CreateReturn.returnedItems",configurationsListQuantity:"Order.CreateReturn.configurationsList.quantity"}),{inLineAlertProps:v,handleSetInLineAlert:x}=ge(),h=J(),{order:d,itemsEligibleForReturn:g,formsRef:f,attributesList:C,steps:t,loading:m,selectedProductList:e,handleSelectedProductList:c,handleSetQuantity:y,handleChangeStep:S,onSubmit:E}=me({orderData:s,onSuccess:l,onError:k,handleSetInLineAlert:x});if(m)return r("div",{children:r(oe,{})});if(!m&&!C.length)return r("div",{});const Q=(h==null?void 0:h.baseMediaUrl)??"",n={products:r(be,{itemsEligibleForReturn:g,placeholderImage:Q,taxConfig:ie((h==null?void 0:h.shoppingCartDisplayPrice)??0),slots:i,translations:R,loading:m,selectedProductList:e,handleSelectedProductList:c,showConfigurableOptions:o,handleSetQuantity:y,handleChangeStep:S}),attributes:r(ke,{placeholderImage:Q,slots:i,formsRef:f,loading:m,fieldsConfig:C,selectedProductList:e,handleChangeStep:S,translations:R,onSubmit:E}),success:r(fe,{translations:R,routeReturnSuccess:L,orderData:d}),error:null};return N("div",{className:B(["order-create-return",a]),children:[r(W,{title:R.headerText}),v.heading?r(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...v}):null,n[t]]})},fe=({routeReturnSuccess:a,translations:s,orderData:i})=>N("div",{className:"order-return-order-message",children:[r("p",{className:"order-return-order-message__title",children:s.successTitle}),r("p",{className:"order-return-order-message__subtitle",children:s.successMessage}),r(M,{href:(a==null?void 0:a(i))??"#",children:s.backStore})]}),be=({placeholderImage:a,itemsEligibleForReturn:s,slots:i,loading:l,taxConfig:k,translations:L,selectedProductList:o,handleSelectedProductList:R,showConfigurableOptions:v,handleSetQuantity:x,handleChangeStep:h})=>N("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((d,g)=>{const{quantityReturnRequested:f,quantityShipped:C,eligibleForReturn:t}=d,m=o.some(y=>(y==null?void 0:y.productSku)===d.productSku&&d.eligibleForReturn),e=C===f&&t,c=C-f===0?f:C-f;return N("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(V,{"data-testid":`key_${g}`,name:`key_${g}`,checked:m,disabled:e,onChange:()=>{R({...d,currentReturnOrderQuantity:1})}}),r(ue,{placeholderImage:a,loading:l,product:{...d,totalQuantity:c||1},itemType:"",taxConfig:k,translations:L,showConfigurableOptions:v,disabledIncrementer:!m,onQuantity:c>1?y=>{x(y,d.productSku)}:void 0}),r(H,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:i==null?void 0:i.ReturnOrderItem})]},d.id)}),r("li",{className:"order-return-order-product-list__item",children:r(M,{type:"button",onClick:()=>h("attributes"),disabled:!o.length,children:L.nextStep})})]}),ke=({placeholderImage:a,slots:s,formsRef:i,selectedProductList:l,loading:k,fieldsConfig:L,translations:o,handleChangeStep:R,onSubmit:v})=>{const{formData:x,errors:h,formRef:d,handleChange:g,handleBlur:f,handleSubmit:C}=G({fieldsConfig:ee(L,l==null?void 0:l.length),onSubmit:v});return N("form",{className:"order-return-reason-form",ref:d,onSubmit:C,name:"returnReasonForm",children:[l.map((t,m)=>{var p,O,u,b,P,T;const e=t==null?void 0:t.giftCard,c=t==null?void 0:t.product,y=te(L,m),S=`${t==null?void 0:t.id}_${m}`,E=(t==null?void 0:t.currentReturnOrderQuantity)??1,Q={...t!=null&&t.currentReturnOrderQuantity?{[o.configurationsListQuantity]:E}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[o.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[o.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[o.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[o.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[o.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(p=t==null?void 0:t.downloadableLinks)==null?void 0:p.count} ${o.downloadableCount}`]:(O=t==null?void 0:t.downloadableLinks)==null?void 0:O.result}:{}},n=(b=(u=c==null?void 0:c.thumbnail)==null?void 0:u.url)!=null&&b.length?c.thumbnail.url:a;return N(X,{children:[r(Z,{loading:k,title:r("div",{"data-testid":"product-name",children:(P=t==null?void 0:t.product)==null?void 0:P.name}),sku:r("div",{children:c==null?void 0:c.sku}),image:r(D,{src:n,alt:((T=c==null?void 0:c.thumbnail)==null?void 0:T.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:Q}),r("form",{name:S,ref:i==null?void 0:i.current[m],"data-quantity":E,children:r(z,{className:"className",loading:k,fields:y,onChange:g,onBlur:f,errors:h,values:x})})]},t.id)}),r(H,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:R},children:N("div",{className:"order-return-reason-form__actions",children:[r(M,{variant:"secondary",type:"button",onClick:()=>{R("products")},children:o.backStep}),r(M,{children:o.submit})]})})]})};export{We as CreateReturn,We as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js index 570cc213c..e1daad603 100644 --- a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js +++ b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as i,jsxs as S,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $,VComponent as R,Slot as G}from"@dropins/tools/lib.js";import{Card as A,Header as x,Accordion as V,AccordionSection as B,ContentGrid as M,Image as U}from"@dropins/tools/components.js";import{useState as q,useEffect as tn}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as sn}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as ln}from"@dropins/tools/event-bus.js";import{C as rn}from"../chunks/OrderLoaders.js";import{u as hn}from"../chunks/useIsMobile.js";import{Text as H,useText as un}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";var j=(s=>(s.PENDING="pending",s.SHIPPING="shipping",s.COMPLETE="complete",s.PROCESSING="processing",s.HOLD="on hold",s.CANCELED="Canceled",s.SUSPECTED_FRAUD="suspected fraud",s.PAYMENT_REVIEW="payment review",s))(j||{});const dn=({orderData:s})=>{const[r,h]=q(!0),[n,u]=q(s),[l,m]=q(!1);return tn(()=>{const d=ln.on("order/data",g=>{u(g),m(g==null?void 0:g.isVirtual),h(!1)},{eager:!0});return s!=null&&s.id&&h(!1),()=>{d==null||d.off()}},[s]),{loading:r,order:n,isVirtualProduct:l}},en=({value:s,variant:r="primary",size:h="medium",icon:n,className:u,children:l,disabled:m=!1,active:d=!1,activeChildren:g,activeIcon:b,href:e,...C})=>{let c="dropin-button";(n&&!l||n&&d&&!g||!n&&d&&b)&&(c="dropin-iconButton"),d&&g&&(c="dropin-button"),u=$([c,`${c}--${h}`,`${c}--${r}`,[`${c}--${r}--disabled`,m],l&&n&&`${c}--with-icon`,!l&&g&&n&&`${c}--with-icon`,d&&b&&`${c}--with-icon`,u]);const I=$(["dropin-button-icon",`dropin-button-icon--${r}`,[`dropin-button-icon--${r}--disabled`,m],n==null?void 0:n.props.className]),o=e?{node:i("a",{}),role:"link",href:e,...C,disabled:m,active:d,onKeyDown:y=>{m&&y.preventDefault()},tabIndex:m?-1:0}:{node:i("button",{}),role:"button",...C,value:s,disabled:m,active:d};return S(R,{...o,className:u,children:[n&&!d&&i(R,{node:n,className:I}),b&&d&&i(R,{node:b,className:I}),l&&!d&&(typeof l=="string"?i("span",{children:l}):l),d&&g&&(typeof g=="string"?i("span",{children:g}):g)]})},cn=({placeholderImage:s,slots:r,collapseThreshold:h,translations:n,returnData:u,routeTracking:l,routeProductDetails:m})=>{var b;const d=hn(),g=m?"a":"span";return console.log("returnData.items",u),console.log("returnData.items",u.items),S(A,{variant:"secondary",className:$(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[i(x,{title:n.returnOrderCardTitle}),S("div",{children:[(b=u==null?void 0:u.tracking)==null?void 0:b.map((e,C)=>{var y,N;const c={title:"",number:(e==null?void 0:e.trackingNumber)??"",carrier:((y=e==null?void 0:e.carrier)==null?void 0:y.label)??""},I=l==null?void 0:l(c),o=I?()=>{window.open(I,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",children:[S("div",{children:[`${n.carrier} `,`${(N=c.carrier)==null?void 0:N.toLocaleUpperCase()} | `,c.number]}),o?i(en,{onClick:o,children:n.trackButton}):null]},`${c.number}_${C}`)}),r!=null&&r.ReturnItemsDetails?i(G,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:r==null?void 0:r.ReturnItemsDetails,context:{items:u.items}}):null,i(V,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(B,{defaultOpen:h>=u.items.length,title:i(H,{id:"Order.ShippingStatusCard.itemText",plural:u.items.reduce((e,C)=>e+C.requestQuantity,0),fields:{count:u.items.reduce((e,C)=>e+C.requestQuantity,0)}}),children:i(M,{maxColumns:d?3:9,emptyGridContent:i(w,{}),className:$(["order-shipping-status-card__images",["order-shipping-status-card__images-3",d]]),children:u.items.map((e,C)=>{var o,y,N,T;const c=(o=e.thumbnail)==null?void 0:o.label,I=(N=(y=e.thumbnail)==null?void 0:y.url)!=null&&N.length?(T=e.thumbnail)==null?void 0:T.url:s;return i(g,{href:(m==null?void 0:m(e))??"#","data-testid":`${C}${e.uid}`,children:i(U,{alt:c,src:I,width:85,height:114})},`${C}${e.uid}`)})})})})]})]})},mn=({placeholderImage:s,translations:r,slots:h,orderData:n,collapseThreshold:u=10,routeProductDetails:l,routeTracking:m})=>{var N,T,F,Q,K,W,Y;const d=!!(n!=null&&n.returnNumber),g=n==null?void 0:n.returnNumber,b=l?"a":"span",e=(N=n==null?void 0:n.status)==null?void 0:N.toLocaleLowerCase(),c=((T=n==null?void 0:n.shipments)==null?void 0:T.length)===1&&(e==null?void 0:e.includes(j.COMPLETE)),I=(F=n==null?void 0:n.shipments)==null?void 0:F.every(p=>p.tracking.length===0),o=(Q=n==null?void 0:n.items)==null?void 0:Q.filter(p=>(p==null?void 0:p.quantityShipped)===0||(p==null?void 0:p.quantityShipped)<(p==null?void 0:p.quantityOrdered)),y=(K=n==null?void 0:n.items)==null?void 0:K.reduce((p,f)=>{const a=f.quantityOrdered-f.quantityShipped;return p+(a>0?a:0)},0);if(console.log("0",0),d&&(n!=null&&n.returns.length)){console.log("1",1);const p=n.returns.find(f=>f.returnNumber===g);return!p||p.tracking.length===0?null:(console.log("2",2),i(cn,{placeholderImage:s,slots:h,collapseThreshold:u,translations:r,returnData:p,routeTracking:m,routeProductDetails:l}))}return!n||e!=null&&e.includes(j.CANCELED)?null:(W=n==null?void 0:n.shipments)!=null&&W.length?I&&!(o!=null&&o.length)&&c?null:S(w,{children:[(Y=n==null?void 0:n.shipments)==null?void 0:Y.map(({tracking:p,items:f,id:a},pn)=>{console.log("5",5),console.log("items",f);const E=f.reduce((t,O)=>t+((O==null?void 0:O.quantityShipped)??O.orderItem.quantityShipped??0),0);return console.log("accordionValue",E),S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:r.shippingCardTitle}),p==null?void 0:p.map(t=>{var _;const O=m==null?void 0:m(t),L=O?()=>{window.open(O,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",role:"status",children:[S("div",{className:"order-shipping-status-card__header--content",children:[S("p",{children:[r.carrier," ",(_=t==null?void 0:t.carrier)==null?void 0:_.toLocaleUpperCase()," | ",t==null?void 0:t.number]}),i("p",{children:t==null?void 0:t.title})]}),h!=null&&h.DeliveryTrackActions?i(G,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:h==null?void 0:h.DeliveryTrackActions,context:{trackInformation:t}}):L?i(en,{onClick:L,children:r.trackButton}):null]},t.number)}),c?null:i(V,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(B,{"data-position":pn+1,defaultOpen:u>=(f==null?void 0:f.length),title:i(H,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:E,fields:{count:E}}),children:i(M,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:f==null?void 0:f.map(t=>{var _,z,J,X,Z,v,P,k,D,nn;const O=(J=(z=(_=t==null?void 0:t.orderItem)==null?void 0:_.product)==null?void 0:z.thumbnail)==null?void 0:J.label,L=(P=(v=(Z=(X=t==null?void 0:t.orderItem)==null?void 0:X.product)==null?void 0:Z.thumbnail)==null?void 0:v.url)!=null&&P.length?(nn=(D=(k=t==null?void 0:t.orderItem)==null?void 0:k.product)==null?void 0:D.thumbnail)==null?void 0:nn.url:s;return i(b,{href:(l==null?void 0:l(t))??"#",children:i(U,{alt:O,src:L,width:85,height:114})},t.id)})})})}),h!=null&&h.DeliveryTimeLine?i(G,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:h==null?void 0:h.DeliveryTimeLine,context:{}}):null]},a)}),o!=null&&o.length?S(A,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[i(x,{title:r.notYetShippedTitle}),i(V,{actionIconPosition:"right",children:i(B,{defaultOpen:u>=(o==null?void 0:o.length),title:i(H,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:y,fields:{count:y}}),children:i(M,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:o==null?void 0:o.map(p=>{var f,a;return i(b,{href:(l==null?void 0:l(p))??"#",children:i(U,{alt:(f=p.thumbnail)==null?void 0:f.label,src:((a=p.thumbnail)==null?void 0:a.url)||"",width:85,height:114})},p.id)})})})})]}):null]}):S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:r.shippingInfoTitle}),i("div",{className:"order-shipping-status-card__header",children:S("div",{className:"order-shipping-status-card__header--content",children:[n!=null&&n.carrier?i("p",{children:n==null?void 0:n.carrier}):null,i("p",{children:r.noInfoTitle})]})})]})},wn=({slots:s,className:r,collapseThreshold:h,orderData:n,routeOrderDetails:u,routeTracking:l,routeProductDetails:m})=>{const{loading:d,order:g,isVirtualProduct:b}=dn({orderData:n}),e=sn(),C=un({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",returnOrderCardTitle:"Order.ShippingStatusCard.returnOrderCardTitle",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",noInfoTitle:"Order.ShippingStatusCard.noInfoTitle",returnNumber:"Order.ShippingStatusCard.returnNumber",orderNumber:"Order.ShippingStatusCard.orderNumber",trackButton:"Order.ShippingStatusCard.trackButton"});if(!d&&b)return null;const c=(e==null?void 0:e.baseMediaUrl)??"";return i("div",{className:$(["order-shipping-status",r]),children:!d&&g?i(mn,{placeholderImage:c,translations:C,routeOrderDetails:u,routeTracking:l,slots:s,orderData:g,collapseThreshold:h,routeProductDetails:m}):i(rn,{withCard:!1})})};export{wn as ShippingStatus,wn as default}; +import{jsx as i,jsxs as S,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $,VComponent as E,Slot as q}from"@dropins/tools/lib.js";import{Card as A,Header as x,Accordion as G,AccordionSection as V,ContentGrid as B,Image as M}from"@dropins/tools/components.js";import{useState as R,useEffect as tn}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as sn}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as rn}from"@dropins/tools/event-bus.js";import{C as ln}from"../chunks/OrderLoaders.js";import{u as hn}from"../chunks/useIsMobile.js";import{Text as U,useText as un}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";var H=(s=>(s.PENDING="pending",s.SHIPPING="shipping",s.COMPLETE="complete",s.PROCESSING="processing",s.HOLD="on hold",s.CANCELED="Canceled",s.SUSPECTED_FRAUD="suspected fraud",s.PAYMENT_REVIEW="payment review",s))(H||{});const dn=({orderData:s})=>{const[l,h]=R(!0),[n,c]=R(s),[r,m]=R(!1);return tn(()=>{const u=rn.on("order/data",o=>{c(o),m(o==null?void 0:o.isVirtual),h(!1)},{eager:!0});return s!=null&&s.id&&h(!1),()=>{u==null||u.off()}},[s]),{loading:l,order:n,isVirtualProduct:r}},en=({value:s,variant:l="primary",size:h="medium",icon:n,className:c,children:r,disabled:m=!1,active:u=!1,activeChildren:o,activeIcon:b,href:e,...C})=>{let d="dropin-button";(n&&!r||n&&u&&!o||!n&&u&&b)&&(d="dropin-iconButton"),u&&o&&(d="dropin-button"),c=$([d,`${d}--${h}`,`${d}--${l}`,[`${d}--${l}--disabled`,m],r&&n&&`${d}--with-icon`,!r&&o&&n&&`${d}--with-icon`,u&&b&&`${d}--with-icon`,c]);const I=$(["dropin-button-icon",`dropin-button-icon--${l}`,[`dropin-button-icon--${l}--disabled`,m],n==null?void 0:n.props.className]),g=e?{node:i("a",{}),role:"link",href:e,...C,disabled:m,active:u,onKeyDown:y=>{m&&y.preventDefault()},tabIndex:m?-1:0}:{node:i("button",{}),role:"button",...C,value:s,disabled:m,active:u};return S(E,{...g,className:c,children:[n&&!u&&i(E,{node:n,className:I}),b&&u&&i(E,{node:b,className:I}),r&&!u&&(typeof r=="string"?i("span",{children:r}):r),u&&o&&(typeof o=="string"?i("span",{children:o}):o)]})},cn=({placeholderImage:s,slots:l,collapseThreshold:h,translations:n,returnData:c,routeTracking:r,routeProductDetails:m})=>{var b;const u=hn(),o=m?"a":"span";return S(A,{variant:"secondary",className:$(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[i(x,{title:n.returnOrderCardTitle}),S("div",{children:[(b=c==null?void 0:c.tracking)==null?void 0:b.map((e,C)=>{var y,N;const d={title:"",number:(e==null?void 0:e.trackingNumber)??"",carrier:((y=e==null?void 0:e.carrier)==null?void 0:y.label)??""},I=r==null?void 0:r(d),g=I?()=>{window.open(I,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",children:[S("div",{children:[`${n.carrier} `,`${(N=d.carrier)==null?void 0:N.toLocaleUpperCase()} | `,d.number]}),g?i(en,{onClick:g,children:n.trackButton}):null]},`${d.number}_${C}`)}),l!=null&&l.ReturnItemsDetails?i(q,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:l==null?void 0:l.ReturnItemsDetails,context:{items:c.items}}):null,i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{defaultOpen:h>=c.items.length,title:i(U,{id:"Order.ShippingStatusCard.itemText",plural:c.items.reduce((e,C)=>e+C.requestQuantity,0),fields:{count:c.items.reduce((e,C)=>e+C.requestQuantity,0)}}),children:i(B,{maxColumns:u?3:9,emptyGridContent:i(w,{}),className:$(["order-shipping-status-card__images",["order-shipping-status-card__images-3",u]]),children:c.items.map((e,C)=>{var g,y,N,_;const d=(g=e.thumbnail)==null?void 0:g.label,I=(N=(y=e.thumbnail)==null?void 0:y.url)!=null&&N.length?(_=e.thumbnail)==null?void 0:_.url:s;return i(o,{href:(m==null?void 0:m(e))??"#","data-testid":`${C}${e.uid}`,children:i(M,{alt:d,src:I,width:85,height:114})},`${C}${e.uid}`)})})})})]})]})},mn=({placeholderImage:s,translations:l,slots:h,orderData:n,collapseThreshold:c=10,routeProductDetails:r,routeTracking:m})=>{var N,_,j,F,Q,K,W;const u=!!(n!=null&&n.returnNumber),o=n==null?void 0:n.returnNumber,b=r?"a":"span",e=(N=n==null?void 0:n.status)==null?void 0:N.toLocaleLowerCase(),d=((_=n==null?void 0:n.shipments)==null?void 0:_.length)===1&&(e==null?void 0:e.includes(H.COMPLETE)),I=(j=n==null?void 0:n.shipments)==null?void 0:j.every(p=>p.tracking.length===0),g=(F=n==null?void 0:n.items)==null?void 0:F.filter(p=>(p==null?void 0:p.quantityShipped)===0||(p==null?void 0:p.quantityShipped)<(p==null?void 0:p.quantityOrdered)),y=(Q=n==null?void 0:n.items)==null?void 0:Q.reduce((p,f)=>{const T=f.quantityOrdered-f.quantityShipped;return p+(T>0?T:0)},0);if(u&&(n!=null&&n.returns.length)){const p=n.returns.find(f=>f.returnNumber===o);return!p||p.tracking.length===0?null:i(cn,{placeholderImage:s,slots:h,collapseThreshold:c,translations:l,returnData:p,routeTracking:m,routeProductDetails:r})}return!n||e!=null&&e.includes(H.CANCELED)?null:(K=n==null?void 0:n.shipments)!=null&&K.length?I&&!(g!=null&&g.length)&&d?null:S(w,{children:[(W=n==null?void 0:n.shipments)==null?void 0:W.map(({tracking:p,items:f,id:T},pn)=>{const Y=f.reduce((t,O)=>t+((O==null?void 0:O.quantityShipped)??O.orderItem.quantityShipped??0),0);return S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:l.shippingCardTitle}),p==null?void 0:p.map(t=>{var a;const O=m==null?void 0:m(t),L=O?()=>{window.open(O,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",role:"status",children:[S("div",{className:"order-shipping-status-card__header--content",children:[S("p",{children:[l.carrier," ",(a=t==null?void 0:t.carrier)==null?void 0:a.toLocaleUpperCase()," | ",t==null?void 0:t.number]}),i("p",{children:t==null?void 0:t.title})]}),h!=null&&h.DeliveryTrackActions?i(q,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:h==null?void 0:h.DeliveryTrackActions,context:{trackInformation:t}}):L?i(en,{onClick:L,children:l.trackButton}):null]},t.number)}),d?null:i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{"data-position":pn+1,defaultOpen:c>=(f==null?void 0:f.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:Y,fields:{count:Y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:f==null?void 0:f.map(t=>{var a,z,J,X,Z,v,P,k,D,nn;const O=(J=(z=(a=t==null?void 0:t.orderItem)==null?void 0:a.product)==null?void 0:z.thumbnail)==null?void 0:J.label,L=(P=(v=(Z=(X=t==null?void 0:t.orderItem)==null?void 0:X.product)==null?void 0:Z.thumbnail)==null?void 0:v.url)!=null&&P.length?(nn=(D=(k=t==null?void 0:t.orderItem)==null?void 0:k.product)==null?void 0:D.thumbnail)==null?void 0:nn.url:s;return i(b,{href:(r==null?void 0:r(t))??"#",children:i(M,{alt:O,src:L,width:85,height:114})},t.id)})})})}),h!=null&&h.DeliveryTimeLine?i(q,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:h==null?void 0:h.DeliveryTimeLine,context:{}}):null]},T)}),g!=null&&g.length?S(A,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[i(x,{title:l.notYetShippedTitle}),i(G,{actionIconPosition:"right",children:i(V,{defaultOpen:c>=(g==null?void 0:g.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:y,fields:{count:y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:g==null?void 0:g.map(p=>{var f,T;return i(b,{href:(r==null?void 0:r(p))??"#",children:i(M,{alt:(f=p.thumbnail)==null?void 0:f.label,src:((T=p.thumbnail)==null?void 0:T.url)||"",width:85,height:114})},p.id)})})})})]}):null]}):S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:l.shippingInfoTitle}),i("div",{className:"order-shipping-status-card__header",children:S("div",{className:"order-shipping-status-card__header--content",children:[n!=null&&n.carrier?i("p",{children:n==null?void 0:n.carrier}):null,i("p",{children:l.noInfoTitle})]})})]})},wn=({slots:s,className:l,collapseThreshold:h,orderData:n,routeOrderDetails:c,routeTracking:r,routeProductDetails:m})=>{const{loading:u,order:o,isVirtualProduct:b}=dn({orderData:n}),e=sn(),C=un({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",returnOrderCardTitle:"Order.ShippingStatusCard.returnOrderCardTitle",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",noInfoTitle:"Order.ShippingStatusCard.noInfoTitle",returnNumber:"Order.ShippingStatusCard.returnNumber",orderNumber:"Order.ShippingStatusCard.orderNumber",trackButton:"Order.ShippingStatusCard.trackButton"});if(!u&&b)return null;const d=(e==null?void 0:e.baseMediaUrl)??"";return i("div",{className:$(["order-shipping-status",l]),children:!u&&o?i(mn,{placeholderImage:d,translations:C,routeOrderDetails:c,routeTracking:r,slots:s,orderData:o,collapseThreshold:h,routeProductDetails:m}):i(ln,{withCard:!1})})};export{wn as ShippingStatus,wn as default}; diff --git a/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts b/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts index 8d50b9855..b9227060f 100644 --- a/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts @@ -24,14 +24,24 @@ export interface ReturnProps { status: string; created_at: string; } +interface ErrorsProps { + message: string; +} export interface RequestReturnResponse { data: { requestReturn: { return: ReturnProps; }; }; - errors?: { - message: string; - }[]; + errors?: ErrorsProps[]; +} +export interface RequestGuestReturnResponse { + data: { + requestGuestReturn: { + return: ReturnProps; + }; + }; + errors?: ErrorsProps[]; } +export {}; //# sourceMappingURL=requestReturn.types.d.ts.map \ No newline at end of file