From eafdb5929ccd0adf4cbb2b3680f76dc6c336805b Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Fri, 6 Dec 2024 11:52:09 +0200 Subject: [PATCH] test 3 --- scripts/__dropins__/storefront-order/api.js | 18 ++++++++++++----- .../chunks/requestGuestReturn.js | 20 ++----------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index 798bffe90..198dea44a 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as ie,r as ue}from"./chunks/requestGuestOrderCancel.js";import{f as i,h as y}from"./chunks/fetch-graphql.js";import{g as me,r as pe,s as ce,a as _e,b as Oe}from"./chunks/fetch-graphql.js";import{g as De}from"./chunks/getAttributesForm.js";import{R as I}from"./chunks/requestGuestReturn.js";import{g as Ee,r as Te}from"./chunks/requestGuestReturn.js";import{t as A}from"./chunks/getGuestOrder.js";import{g as ye,a as Ce}from"./chunks/getGuestOrder.js";import{g as ge}from"./chunks/getCustomerOrdersReturn.js";import{h as u}from"./chunks/network-error.js";import{P as l,a as m,G as p,O as c,B as _,R as C,b as G,c as $}from"./chunks/transform-customer-orders-returns.js";import{O,A as R}from"./chunks/getGuestOrder.graphql.js";import{g as Ae}from"./chunks/getStoreConfig.js";import{Initializer as N}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{r as $e}from"./chunks/reorderItems.js";import{a as S}from"./chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";const v=` +import{c as de,r as ie}from"./chunks/requestGuestOrderCancel.js";import{f as i,h as y}from"./chunks/fetch-graphql.js";import{g as le,r as me,s as pe,a as ce,b as _e}from"./chunks/fetch-graphql.js";import{g as Re}from"./chunks/getAttributesForm.js";import{g as he,r as Ee}from"./chunks/requestGuestReturn.js";import{t as I}from"./chunks/getGuestOrder.js";import{g as be,a as ye}from"./chunks/getGuestOrder.js";import{g as ge}from"./chunks/getCustomerOrdersReturn.js";import{h as u}from"./chunks/network-error.js";import{P as l,a as m,G as p,O as c,B as _,R as C,b as A,c as G}from"./chunks/transform-customer-orders-returns.js";import{O,A as R}from"./chunks/getGuestOrder.graphql.js";import{g as Ie}from"./chunks/getStoreConfig.js";import{Initializer as $}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{r as Ge}from"./chunks/reorderItems.js";import{a as N}from"./chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";const S=` query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { customer { orders( @@ -114,7 +114,7 @@ ${_} ${O} ${R} ${C} -`,L=(e,r)=>({id:e,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(t=>{var a,s,o,n,D,h;return{canApplyMsrp:!0,formattedPrice:"",id:t.id,quantity:t.totalQuantity,product:{canonicalUrl:((a=t.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((s=t.product)==null?void 0:s.image)??"",name:((o=t.product)==null?void 0:o.name)??"",productId:0,productType:(n=t.product)==null?void 0:n.productType,sku:((D=t.product)==null?void 0:D.sku)??""},prices:{price:{value:t.price.value,currency:t.price.currency}},configurableOptions:((h=t.selectedOptions)==null?void 0:h.map(E=>({optionLabel:E.label,valueLabel:E.value})))||[]}})}),k=e=>{var a,s,o;const r=e.coupons[0],t=(a=e.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:e.email,grandTotal:e.grandTotal.value,orderId:e.number,orderType:"checkout",otherTax:0,salesTax:e.totalTax.value,shipping:{shippingMethod:((s=e.shipping)==null?void 0:s.code)??"",shippingAmount:((o=e.shipping)==null?void 0:o.amount)??0},subtotalExcludingTax:e.subtotal.value,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:e.grandTotal.value}]:[]}},w=e=>{var t,a;const r=(a=(t=e==null?void 0:e.data)==null?void 0:t.placeOrder)==null?void 0:a.orderV2;return r?G(r):null},x=async({orderId:e,returnRef:r,queryType:t,returnsPageSize:a=50})=>await i(v,{method:"GET",cache:"force-cache",variables:{orderNumber:e,pageSize:a}}).then(s=>$(t??"orderData",s,r)).catch(u),B=` +`,v=(e,r)=>({id:e,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(t=>{var a,s,o,n,D,h;return{canApplyMsrp:!0,formattedPrice:"",id:t.id,quantity:t.totalQuantity,product:{canonicalUrl:((a=t.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((s=t.product)==null?void 0:s.image)??"",name:((o=t.product)==null?void 0:o.name)??"",productId:0,productType:(n=t.product)==null?void 0:n.productType,sku:((D=t.product)==null?void 0:D.sku)??""},prices:{price:{value:t.price.value,currency:t.price.currency}},configurableOptions:((h=t.selectedOptions)==null?void 0:h.map(E=>({optionLabel:E.label,valueLabel:E.value})))||[]}})}),L=e=>{var a,s,o;const r=e.coupons[0],t=(a=e.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:e.email,grandTotal:e.grandTotal.value,orderId:e.number,orderType:"checkout",otherTax:0,salesTax:e.totalTax.value,shipping:{shippingMethod:((s=e.shipping)==null?void 0:s.code)??"",shippingAmount:((o=e.shipping)==null?void 0:o.amount)??0},subtotalExcludingTax:e.subtotal.value,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:e.grandTotal.value}]:[]}},k=e=>{var t,a;const r=(a=(t=e==null?void 0:e.data)==null?void 0:t.placeOrder)==null?void 0:a.orderV2;return r?A(r):null},w=async({orderId:e,returnRef:r,queryType:t,returnsPageSize:a=50})=>await i(S,{method:"GET",cache:"force-cache",variables:{orderNumber:e,pageSize:a}}).then(s=>G(t??"orderData",s,r)).catch(u),x=` query ORDER_BY_TOKEN($token: String!) { guestOrderByToken(input: { token: $token }) { email @@ -211,7 +211,7 @@ ${_} ${O} ${R} ${C} -`,P=async(e,r)=>await i(B,{method:"GET",cache:"no-cache",variables:{token:e}}).then(t=>A(t,r)).catch(u),M="orderData",U=async e=>{var n;const r=typeof(e==null?void 0:e.orderRef)=="string"?e==null?void 0:e.orderRef:"",t=typeof(e==null?void 0:e.returnRef)=="string"?e==null?void 0:e.returnRef:"",a=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((n=e==null?void 0:e.orderRef)==null?void 0:n.length)>20,s=(e==null?void 0:e.orderData)??null;if(s){d.emit("order/data",{...s,returnNumber:t});return}if(!r)return;const o=a?await P(r,t):await x({orderId:r,returnRef:t,queryType:M});o?d.emit("order/data",{...o,returnNumber:t}):d.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},f=new N({init:async e=>{const r={};f.config.setConfig({...r,...e}),U(e).catch(console.error)},listeners:()=>[]}),ae=f.config,T={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},F={PLACE_ORDER:"place-order"};function g(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function b(e,r){const t=g();t.push({[e]:null}),t.push({[e]:r})}function q(e,r){g().push(a=>{const s=a.getState?a.getState():{};a.push({event:e,eventInfo:{...s,...r}})})}function Q(e,r){const t=k(r),a=L(e,r);b(T.ORDER_CONTEXT,{...t}),b(T.SHOPPING_CART_CONTEXT,{...a}),q(F.PLACE_ORDER)}const z=` +`,B=async(e,r)=>await i(x,{method:"GET",cache:"no-cache",variables:{token:e}}).then(t=>I(t,r)).catch(u),P="orderData",M=async e=>{var n;const r=typeof(e==null?void 0:e.orderRef)=="string"?e==null?void 0:e.orderRef:"",t=typeof(e==null?void 0:e.returnRef)=="string"?e==null?void 0:e.returnRef:"",a=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((n=e==null?void 0:e.orderRef)==null?void 0:n.length)>20,s=(e==null?void 0:e.orderData)??null;if(s){d.emit("order/data",{...s,returnNumber:t});return}if(!r)return;const o=a?await B(r,t):await w({orderId:r,returnRef:t,queryType:P});o?d.emit("order/data",{...o,returnNumber:t}):d.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},g=new $({init:async e=>{const r={};g.config.setConfig({...r,...e}),M(e).catch(console.error)},listeners:()=>[]}),re=g.config,T={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},U={PLACE_ORDER:"place-order"};function f(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function b(e,r){const t=f();t.push({[e]:null}),t.push({[e]:r})}function F(e,r){f().push(a=>{const s=a.getState?a.getState():{};a.push({event:e,eventInfo:{...s,...r}})})}function q(e,r){const t=L(r),a=v(e,r);b(T.ORDER_CONTEXT,{...t}),b(T.SHOPPING_CART_CONTEXT,{...a}),F(U.PLACE_ORDER)}const Q=` mutation PLACE_ORDER_MUTATION($cartId: String!) { placeOrder(input: { cart_id: $cartId }) { errors { @@ -300,7 +300,15 @@ ${C} ${_} ${O} ${R} -`,se=async e=>{if(!e)throw new Error("No cart ID found");return i(z,{variables:{cartId:e}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&y(r.errors);const t=w(r);return t&&(d.emit("order/placed",t),d.emit("cart/reset",void 0),Q(e,t)),t}).catch(u)},Y=` +`,ae=async e=>{if(!e)throw new Error("No cart ID found");return i(Q,{variables:{cartId:e}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&y(r.errors);const t=k(r);return t&&(d.emit("order/placed",t),d.emit("cart/reset",void 0),q(e,t)),t}).catch(u)},z=` + fragment OrderReturn on Return { + __typename + uid + status + number + created_at + } +`,Y=` mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { requestReturn(input: $input) { return { @@ -308,4 +316,4 @@ mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { } } } -${I}`,oe=async e=>{const r=S(e,"snakeCase",{});return await i(Y,{method:"POST",variables:{input:r}}).then(t=>{var o;if((o=t.errors)!=null&&o.length)return y(t.errors);const{created_at:a,...s}=t.data.requestReturn.return;return{...s,createdAt:a}}).catch(u)};export{ie as cancelOrder,ae as config,i as fetchGraphQl,De as getAttributesForm,Ee as getAttributesList,me as getConfig,ye as getCustomer,ge as getCustomerOrdersReturn,Ce as getGuestOrder,x as getOrderDetailsById,Ae as getStoreConfig,P as guestOrderByToken,f as initialize,se as placeOrder,pe as removeFetchGraphQlHeader,$e as reorderItems,ue as requestGuestOrderCancel,Te as requestGuestReturn,oe as requestReturn,ce as setEndpoint,_e as setFetchGraphQlHeader,Oe as setFetchGraphQlHeaders}; +${z}`,se=async e=>{const r=N(e,"snakeCase",{});return await i(Y,{method:"POST",variables:{input:r}}).then(t=>{var o;if((o=t.errors)!=null&&o.length)return y(t.errors);const{created_at:a,...s}=t.data.requestReturn.return;return{...s,createdAt:a}}).catch(u)};export{de as cancelOrder,re as config,i as fetchGraphQl,Re as getAttributesForm,he as getAttributesList,le as getConfig,be as getCustomer,ge as getCustomerOrdersReturn,ye as getGuestOrder,w as getOrderDetailsById,Ie as getStoreConfig,B as guestOrderByToken,g as initialize,ae as placeOrder,me as removeFetchGraphQlHeader,Ge as reorderItems,ie as requestGuestOrderCancel,Ee as requestGuestReturn,se as requestReturn,pe as setEndpoint,ce as setFetchGraphQlHeader,_e as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js index 02bb9da06..f5dc4656a 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 u}from"./network-error.js";import{f as s,h as i}from"./fetch-graphql.js";import{t as o}from"./transform-attributes-form.js";import{a as R}from"./convertCase.js";const c=` +import{h as o}from"./network-error.js";import{f as s,h as u}from"./fetch-graphql.js";import{t as n}from"./transform-attributes-form.js";import"@dropins/tools/event-bus.js";import{a as l}from"./convertCase.js";const m=` query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) { attributesList(entityType: $entityType) { items { @@ -33,20 +33,4 @@ import{h as u}from"./network-error.js";import{f as s,h as i}from"./fetch-graphql } } } -`,h=async n=>await s(c,{method:"GET",cache:"force-cache",variables:{entityType:n}}).then(t=>{var e,r,a;return(e=t.errors)!=null&&e.length?i(t.errors):o((a=(r=t==null?void 0:t.data)==null?void 0:r.attributesList)==null?void 0:a.items)}).catch(u),m=` - fragment OrderReturn on Return { - __typename - uid - status - number - created_at - } -`,_=` -mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { - requestReturn(input: $input) { - return { - ...OrderReturn - } - } -} -${m}`,p=async n=>{const t=R(n,"snakeCase",{});return await s(_,{method:"POST",variables:{input:t}}).then(e=>{console.log("response",e);const{created_at:r,...a}=e.data.requestGuestReturn.return;return{...a,createdAt:r}}).catch(u)};export{m as R,h as g,p as r}; +`,_=async e=>await s(m,{method:"GET",cache:"force-cache",variables:{entityType:e}}).then(t=>{var r,a,i;return(r=t.errors)!=null&&r.length?u(t.errors):n((i=(a=t==null?void 0:t.data)==null?void 0:a.attributesList)==null?void 0:i.items)}).catch(o),f=async e=>{const t=l(e,"snakeCase",{});console.log("input",t)};export{_ as g,f as r};