Skip to content

Commit

Permalink
test 6
Browse files Browse the repository at this point in the history
  • Loading branch information
KostiantynFandeliuk committed Dec 6, 2024
1 parent 10b40cd commit 4023433
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
29 changes: 20 additions & 9 deletions scripts/__dropins__/storefront-order/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{c as ae,r as se}from"./chunks/requestGuestOrderCancel.js";import{f as i,h as I}from"./chunks/fetch-graphql.js";import{g as de,r as ne,s as ie,a as ue,b as le}from"./chunks/fetch-graphql.js";import{g as pe}from"./chunks/getAttributesForm.js";import{g as _e,a as Oe,r as De}from"./chunks/requestGuestReturn.js";import{t as f}from"./chunks/getGuestOrder.js";import{g as Re,a as be}from"./chunks/getGuestOrder.js";import{g as Te}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 y,b as A,c as G}from"./chunks/transform-customer-orders-returns.js";import{O,A as D}from"./chunks/getGuestOrder.graphql.js";import{g as Ce}from"./chunks/getStoreConfig.js";import{Initializer as $}from"@dropins/tools/lib.js";import{events as n}from"@dropins/tools/event-bus.js";import{r as Ie}from"./chunks/reorderItems.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"./chunks/convertCase.js";const N=`
import{c as oe,r as ne}from"./chunks/requestGuestOrderCancel.js";import{f as i,h as y}from"./chunks/fetch-graphql.js";import{g as ie,r as ue,s as le,a as me,b as pe}from"./chunks/fetch-graphql.js";import{g as _e}from"./chunks/getAttributesForm.js";import{g as he,a as De,r as Re}from"./chunks/requestGuestReturn.js";import{t as g}from"./chunks/getGuestOrder.js";import{g as Te,a as be}from"./chunks/getGuestOrder.js";import{g as Ce}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 A}from"./chunks/transform-customer-orders-returns.js";import{O,A as h}from"./chunks/getGuestOrder.graphql.js";import{g as fe}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"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"./chunks/convertCase.js";const N=`
query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) {
customer {
orders(
Expand Down Expand Up @@ -112,9 +112,9 @@ ${p}
${c}
${_}
${O}
${D}
${y}
`,v=(e,t)=>({id:e,totalQuantity:t.totalQuantity,possibleOnepageCheckout:!0,items:t.items.map(r=>{var a,s,o,d,h,R;return{canApplyMsrp:!0,formattedPrice:"",id:r.id,quantity:r.totalQuantity,product:{canonicalUrl:((a=r.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((s=r.product)==null?void 0:s.image)??"",name:((o=r.product)==null?void 0:o.name)??"",productId:0,productType:(d=r.product)==null?void 0:d.productType,sku:((h=r.product)==null?void 0:h.sku)??""},prices:{price:{value:r.price.value,currency:r.price.currency}},configurableOptions:((R=r.selectedOptions)==null?void 0:R.map(b=>({optionLabel:b.label,valueLabel:b.value})))||[]}})}),L=e=>{var a,s,o;const t=e.coupons[0],r=(a=e.payments)==null?void 0:a[0];return{appliedCouponCode:(t==null?void 0:t.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:r?[{paymentMethodCode:(r==null?void 0:r.code)||"",paymentMethodName:(r==null?void 0:r.name)||"",total:e.grandTotal.value}]:[]}},S=e=>{var r,a;const t=(a=(r=e==null?void 0:e.data)==null?void 0:r.placeOrder)==null?void 0:a.orderV2;return t?A(t):null},k=async({orderId:e,returnRef:t,queryType:r,returnsPageSize:a=50})=>await i(N,{method:"GET",cache:"force-cache",variables:{orderNumber:e,pageSize:a}}).then(s=>G(r??"orderData",s,t)).catch(u),w=`
${h}
${C}
`,S=(e,r)=>({id:e,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(t=>{var a,s,o,n,D,R;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:((R=t.selectedOptions)==null?void 0:R.map(E=>({optionLabel:E.label,valueLabel:E.value})))||[]}})}),v=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}]:[]}},L=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},w=async({orderId:e,returnRef:r,queryType:t,returnsPageSize:a=50})=>await i(N,{method:"GET",cache:"force-cache",variables:{orderNumber:e,pageSize:a}}).then(s=>A(t??"orderData",s,r)).catch(u),k=`
query ORDER_BY_TOKEN($token: String!) {
guestOrderByToken(input: { token: $token }) {
email
Expand Down Expand Up @@ -209,9 +209,9 @@ ${p}
${c}
${_}
${O}
${D}
${y}
`,x=async(e,t)=>await i(w,{method:"GET",cache:"no-cache",variables:{token:e}}).then(r=>f(r,t)).catch(u),B="orderData",P=async e=>{var d;const t=typeof(e==null?void 0:e.orderRef)=="string"?e==null?void 0:e.orderRef:"",r=typeof(e==null?void 0:e.returnRef)=="string"?e==null?void 0:e.returnRef:"",a=t&&typeof(e==null?void 0:e.orderRef)=="string"&&((d=e==null?void 0:e.orderRef)==null?void 0:d.length)>20,s=(e==null?void 0:e.orderData)??null;if(s){n.emit("order/data",{...s,returnNumber:r});return}if(!t)return;const o=a?await x(t,r):await k({orderId:t,returnRef:r,queryType:B});o?n.emit("order/data",{...o,returnNumber:r}):n.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},C=new $({init:async e=>{const t={};C.config.setConfig({...t,...e}),P(e).catch(console.error)},listeners:()=>[]}),Z=C.config,E={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},M={PLACE_ORDER:"place-order"};function g(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function T(e,t){const r=g();r.push({[e]:null}),r.push({[e]:t})}function F(e,t){g().push(a=>{const s=a.getState?a.getState():{};a.push({event:e,eventInfo:{...s,...t}})})}function U(e,t){const r=L(t),a=v(e,t);T(E.ORDER_CONTEXT,{...r}),T(E.SHOPPING_CART_CONTEXT,{...a}),F(M.PLACE_ORDER)}const q=`
${h}
${C}
`,x=async(e,r)=>await i(k,{method:"GET",cache:"no-cache",variables:{token:e}}).then(t=>g(t,r)).catch(u),B="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 x(r,t):await w({orderId:r,returnRef:t,queryType:B});o?d.emit("order/data",{...o,returnNumber:t}):d.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},I=new $({init:async e=>{const r={};I.config.setConfig({...r,...e}),M(e).catch(console.error)},listeners:()=>[]}),ee=I.config,T={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},P={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 U(e,r){f().push(a=>{const s=a.getState?a.getState():{};a.push({event:e,eventInfo:{...s,...r}})})}function F(e,r){const t=v(r),a=S(e,r);b(T.ORDER_CONTEXT,{...t}),b(T.SHOPPING_CART_CONTEXT,{...a}),U(P.PLACE_ORDER)}const q=`
mutation PLACE_ORDER_MUTATION($cartId: String!) {
placeOrder(input: { cart_id: $cartId }) {
errors {
Expand Down Expand Up @@ -299,5 +299,16 @@ ${y}
${c}
${_}
${O}
${D}
`,ee=async e=>{if(!e)throw new Error("No cart ID found");return i(q,{variables:{cartId:e}}).then(t=>{var a;(a=t.errors)!=null&&a.length&&I(t.errors);const r=S(t);return r&&(n.emit("order/placed",r),n.emit("cart/reset",void 0),U(e,r)),r}).catch(u)};export{ae as cancelOrder,Z as config,i as fetchGraphQl,pe as getAttributesForm,_e as getAttributesList,de as getConfig,Re as getCustomer,Te as getCustomerOrdersReturn,be as getGuestOrder,k as getOrderDetailsById,Ce as getStoreConfig,x as guestOrderByToken,C as initialize,ee as placeOrder,ne as removeFetchGraphQlHeader,Ie as reorderItems,se as requestGuestOrderCancel,Oe as requestGuestReturn,De as requestReturn,ie as setEndpoint,ue as setFetchGraphQlHeader,le as setFetchGraphQlHeaders};
${h}
`,te=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=L(r);return t&&(d.emit("order/placed",t),d.emit("cart/reset",void 0),F(e,t)),t}).catch(u)},z=`
mutation CONFIRM_RETURN_GUEST_ORDER($input: ConfirmReturnInput!) {
confirmReturn(input: $input) {
return {
__typename
status
uid
number
created_at
}
}
}`,re=async e=>await i(z,{method:"POST",variables:{input:e}}).then(r=>{var t;return(t=r.errors)!=null&&t.length?y(r.errors):r.data}).catch(u);export{oe as cancelOrder,ee as config,re as confirmReturn,i as fetchGraphQl,_e as getAttributesForm,he as getAttributesList,ie as getConfig,Te as getCustomer,Ce as getCustomerOrdersReturn,be as getGuestOrder,w as getOrderDetailsById,fe as getStoreConfig,x as guestOrderByToken,I as initialize,te as placeOrder,ue as removeFetchGraphQlHeader,Ge as reorderItems,ne as requestGuestOrderCancel,De as requestGuestReturn,Re as requestReturn,le as setEndpoint,me as setFetchGraphQlHeader,pe as setFetchGraphQlHeaders};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export declare const confirmReturn: (input: any) => Promise<{
uid: string;
number: string;
status: string;
createdAt: string;
}>;
//# sourceMappingURL=confirmReturn.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const CONFIRM_RETURN_GUEST_ORDER = "\nmutation CONFIRM_RETURN_GUEST_ORDER($input: ConfirmReturnInput!) {\n confirmReturn(input: $input) {\n return {\n __typename\n status\n uid\n number\n created_at\n }\n }\n}";
//# sourceMappingURL=confirmReturn.graphql.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './confirmReturn';
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions scripts/__dropins__/storefront-order/api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export * from './reorderItems';
export * from './requestGuestOrderCancel';
export * from './requestReturn';
export * from './requestGuestReturn';
export * from './confirmReturn';
//# sourceMappingURL=index.d.ts.map
Loading

0 comments on commit 4023433

Please sign in to comment.