diff --git a/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js b/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js index 3d1d4ae9f..f5838e4df 100644 --- a/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js +++ b/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{g as p,F as o}from"./getFormValues.js";const d=t=>t&&t.charAt(0).toLocaleUpperCase()+t.slice(1).toLocaleLowerCase(),l={PENDING:"pending",AUTHORIZED:"authorized",PARTIALLY_AUTHORIZED:"partiallyAuthorized",RECEIVED:"received",PARTIALLY_RECEIVED:"partiallyReceived",APPROVED:"approved",PARTIALLY_APPROVED:"partiallyApproved",REJECTED:"rejected",PARTIALLY_REJECTED:"partiallyRejected",DENIED:"denied",PROCESSED_AND_CLOSED:"processedAndClosed",CLOSED:"closed"},u=(t,e)=>({id:`${t.id}_${t.fieldType}_${e+1}`,name:`${t.name}_${t.fieldType}_${e+1}`,code:`${t.code}_${t.fieldType}_${e+1}`,customUpperCode:`${t.customUpperCode}_${t.fieldType}_${e+1}`}),E=t=>{const e={};return!t||typeof t!="object"||Object.keys(t).length===0||Object.keys(t).forEach(n=>{if(/_(\d+)$/.exec(n)){const a=n==null?void 0:n.replace(/_\d+$/,"");e[a]=t[n]}else e[n]=t[n]}),e},A=(t,e)=>t.map(n=>({...n,...u(n,e)})),f=(t,e)=>t==null?void 0:t.flatMap(n=>Array.from({length:e},(s,a)=>({...n,...u(n,a)}))),m=t=>{const e=[],n=[];return Object.entries(t).forEach(([s,a])=>{const i=s.lastIndexOf("_"),c=s.slice(0,i),r=s.slice(i+1);r===o.MULTISELECT||r===o.SELECT?e.push({attributeCode:c,value:a}):n.push({attributeCode:c,value:a})}),{selectedCustomAttributes:e,enteredCustomAttributes:n}},_=t=>typeof t!="string"?"":(console.log("str formatReturnStatus",t),l[t]??d(t)),L=t=>{var n;const e=[];if(t!=null&&t.current.length)for(const{current:s}of t.current){if(!s)continue;const a=s.name.replace(/_\d+$/,""),i=((n=s==null?void 0:s.dataset)==null?void 0:n.quantity)??1,c=p(s),r=E(c);e.push({orderItemUid:a,quantityToReturn:+i,...m(r)})}return e},R=t=>{var e;return(e=t==null?void 0:t.items)!=null&&e.length?[...(t==null?void 0:t.items)??[]].sort((n,s)=>{const a=n.quantityShipped-n.quantityReturnRequested===0,i=s.quantityShipped-s.quantityReturnRequested===0;return a&&!i?1:!a&&i?-1:0}):[]};export{d as c,_ as f,A as m,L as p,f as r,R as s}; +import{g as p,F as o}from"./getFormValues.js";const d=t=>t&&t.charAt(0).toLocaleUpperCase()+t.slice(1).toLocaleLowerCase(),l={PENDING:"pending",AUTHORIZED:"authorized",PARTIALLY_AUTHORIZED:"partiallyAuthorized",RECEIVED:"received",PARTIALLY_RECEIVED:"partiallyReceived",APPROVED:"approved",PARTIALLY_APPROVED:"partiallyApproved",REJECTED:"rejected",PARTIALLY_REJECTED:"partiallyRejected",DENIED:"denied",PROCESSED_AND_CLOSED:"processedAndClosed",CLOSED:"closed"},u=(t,e)=>({id:`${t.id}_${t.fieldType}_${e+1}`,name:`${t.name}_${t.fieldType}_${e+1}`,code:`${t.code}_${t.fieldType}_${e+1}`,customUpperCode:`${t.customUpperCode}_${t.fieldType}_${e+1}`}),E=t=>{const e={};return!t||typeof t!="object"||Object.keys(t).length===0||Object.keys(t).forEach(n=>{if(/_(\d+)$/.exec(n)){const a=n==null?void 0:n.replace(/_\d+$/,"");e[a]=t[n]}else e[n]=t[n]}),e},A=(t,e)=>t.map(n=>({...n,...u(n,e)})),f=(t,e)=>t==null?void 0:t.flatMap(n=>Array.from({length:e},(s,a)=>({...n,...u(n,a)}))),m=t=>{const e=[],n=[];return Object.entries(t).forEach(([s,a])=>{const i=s.lastIndexOf("_"),c=s.slice(0,i),r=s.slice(i+1);r===o.MULTISELECT||r===o.SELECT?e.push({attributeCode:c,value:a}):n.push({attributeCode:c,value:a})}),{selectedCustomAttributes:e,enteredCustomAttributes:n}},_=t=>typeof t!="string"?"":(console.log("str formatReturnStatus",t),l[t]||d(t)),L=t=>{var n;const e=[];if(t!=null&&t.current.length)for(const{current:s}of t.current){if(!s)continue;const a=s.name.replace(/_\d+$/,""),i=((n=s==null?void 0:s.dataset)==null?void 0:n.quantity)??1,c=p(s),r=E(c);e.push({orderItemUid:a,quantityToReturn:+i,...m(r)})}return e},R=t=>{var e;return(e=t==null?void 0:t.items)!=null&&e.length?[...(t==null?void 0:t.items)??[]].sort((n,s)=>{const a=n.quantityShipped-n.quantityReturnRequested===0,i=s.quantityShipped-s.quantityReturnRequested===0;return a&&!i?1:!a&&i?-1:0}):[]};export{d as c,_ as f,A as m,L as p,f as r,R as s};