Skip to content

Commit

Permalink
Update order, account and auth dropins
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferri0 committed Dec 11, 2024
1 parent 2915c6e commit 47f46a7
Show file tree
Hide file tree
Showing 7 changed files with 413 additions and 22 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"dependencies": {
"@adobe/magento-storefront-event-collector": "^1.8.0",
"@adobe/magento-storefront-events-sdk": "^1.8.0",
"@dropins/storefront-account": "1.0.0-beta3",
"@dropins/storefront-auth": "1.0.0-beta2",
"@dropins/storefront-account": "1.0.0-beta4",
"@dropins/storefront-auth": "1.0.0-beta3",
"@dropins/storefront-cart": "1.0.0-beta2",
"@dropins/storefront-checkout": "1.0.0-beta3",
"@dropins/storefront-order": "1.0.0-beta4",
"@dropins/storefront-order": "1.0.0-beta6",
"@dropins/storefront-pdp": "1.0.0-beta3",
"@dropins/tools": "^0.37.0"
}
Expand Down
127 changes: 127 additions & 0 deletions scripts/__dropins__/storefront-account/LICENSE.md

Large diffs are not rendered by default.

127 changes: 127 additions & 0 deletions scripts/__dropins__/storefront-auth/LICENSE.md

Large diffs are not rendered by default.

127 changes: 127 additions & 0 deletions scripts/__dropins__/storefront-order/LICENSE.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 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 H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as m,h as _}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as ee,a as te,r as re}from"./chunks/requestGuestReturn.js";import{g as oe,a as ne}from"./chunks/getGuestOrder.js";import{g as ie}from"./chunks/getCustomerOrdersReturn.js";import{a as T}from"./chunks/initialize.js";import{c as pe,g as ue,b as de,i as le}from"./chunks/initialize.js";import{g as me}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as D,PRICE_DETAILS_FRAGMENT as A,GIFT_CARD_DETAILS_FRAGMENT as g,ORDER_ITEM_DETAILS_FRAGMENT as O,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as h,ORDER_SUMMARY_FRAGMENT as f,ADDRESS_FRAGMENT as C}from"./fragments.js";import{a as Te,c as Re,r as De}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,c;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((c=e.selectedOptions)==null?void 0:c.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotalExclTax.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=E();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){E().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=`
import{c as V,r as Y}from"./chunks/requestGuestOrderCancel.js";import{f as R,h as A}from"./chunks/fetch-graphql.js";import{g as j,r as J,s as K,a as W,b as Z}from"./chunks/fetch-graphql.js";import{g as te}from"./chunks/getAttributesForm.js";import{g as oe,a as ae,r as ne}from"./chunks/requestGuestReturn.js";import{g as ue,a as ce}from"./chunks/getGuestOrder.js";import{g as le}from"./chunks/getCustomerOrdersReturn.js";import{a as D}from"./chunks/initialize.js";import{c as de,g as Te,b as Ee,i as me}from"./chunks/initialize.js";import{g as Re}from"./chunks/getStoreConfig.js";import{h as g}from"./chunks/network-error.js";import{events as d}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as O,PRICE_DETAILS_FRAGMENT as h,GIFT_CARD_DETAILS_FRAGMENT as f,ORDER_ITEM_DETAILS_FRAGMENT as x,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as C,ORDER_SUMMARY_FRAGMENT as b,ADDRESS_FRAGMENT as G}from"./fragments.js";import{a as De,c as ge,r as Oe}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const m=(t,r)=>t+r.amount.value,M=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var o,a,n,s,u,c,i,l;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:(o=e.product)==null?void 0:o.canonicalUrl,mainImageUrl:((a=e.product)==null?void 0:a.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((u=e.product)==null?void 0:u.sku)??"",topLevelSku:(c=e.product)==null?void 0:c.sku},prices:{price:{value:e.price.value,currency:e.price.currency,regularPrice:((i=e.regularPrice)==null?void 0:i.value)??e.price.value}},configurableOptions:((l=e.selectedOptions)==null?void 0:l.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}}),prices:{subtotalExcludingTax:{value:r.subtotalExclTax.value,currency:r.subtotalExclTax.currency},subtotalIncludingTax:{value:r.subtotalInclTax.value,currency:r.subtotalInclTax.currency}},discountAmount:r.discounts.reduce(m,0)}),I=t=>{var o,a,n;const r=t.coupons[0],e=(o=t.payments)==null?void 0:o[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((a=t.shipping)==null?void 0:a.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotalExclTax.value,subtotalIncludingTax:t.subtotalInclTax.value,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value,orderId:t.number}]:[],discountAmount:t.discounts.reduce(m,0),taxAmount:t.totalTax.value}},N=t=>{var e,o;const r=(o=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:o.orderV2;return r?D(r):null},T={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},v={PLACE_ORDER:"place-order"};function _(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function E(t,r){const e=_();e.push({[t]:null}),e.push({[t]:r})}function L(t){_().push(e=>{const o=e.getState?e.getState():{};e.push({event:t,eventInfo:{...o}})})}function y(t,r){const e=I(r),o=M(t,r);E(T.ORDER_CONTEXT,{...e}),E(T.SHOPPING_CART_CONTEXT,{...o}),L(v.PLACE_ORDER)}const S=`
mutation PLACE_ORDER_MUTATION($cartId: String!) {
placeOrder(input: { cart_id: $cartId }) {
errors {
Expand Down Expand Up @@ -83,11 +83,11 @@ import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as m,h a
}
}
}
${D}
${A}
${g}
${O}
${h}
${f}
${x}
${C}
`,$=async t=>{if(!t)throw new Error("No cart ID found");return m(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(R)};export{H as cancelOrder,pe as config,Te as confirmCancelOrder,Re as confirmGuestReturn,m as fetchGraphQl,W as getAttributesForm,ee as getAttributesList,V as getConfig,oe as getCustomer,ie as getCustomerOrdersReturn,ne as getGuestOrder,ue as getOrderDetailsById,me as getStoreConfig,de as guestOrderByToken,le as initialize,$ as placeOrder,Y as removeFetchGraphQlHeader,De as reorderItems,q as requestGuestOrderCancel,te as requestGuestReturn,re as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders};
${b}
${G}
`,H=async t=>{if(!t)throw new Error("No cart ID found");return R(S,{variables:{cartId:t}}).then(r=>{var o;(o=r.errors)!=null&&o.length&&A(r.errors);const e=N(r);return e&&(d.emit("order/placed",e),d.emit("cart/reset",void 0),y(t,e)),e}).catch(g)};export{V as cancelOrder,de as config,De as confirmCancelOrder,ge as confirmGuestReturn,R as fetchGraphQl,te as getAttributesForm,oe as getAttributesList,j as getConfig,ue as getCustomer,le as getCustomerOrdersReturn,ce as getGuestOrder,Te as getOrderDetailsById,Re as getStoreConfig,Ee as guestOrderByToken,me as initialize,H as placeOrder,J as removeFetchGraphQlHeader,Oe as reorderItems,Y as requestGuestOrderCancel,ae as requestGuestReturn,ne as requestReturn,K as setEndpoint,W as setFetchGraphQlHeader,Z as setFetchGraphQlHeaders};
14 changes: 12 additions & 2 deletions scripts/__dropins__/storefront-order/data/models/acdl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ShoppingCartItem = {
product: Product;
configurableOptions?: Array<ConfigurableOption>;
quantity: number;
discountAmount?: number;
};
type Price = {
value: number;
Expand All @@ -28,6 +29,11 @@ type Product = {
productId: number;
name: string;
sku: string;
/**
* For simple, downloadable, and virtual products with no configurable options topLevelSku is the same
* as the product SKU.
* For grouped, bundled, and configurable products topLevelSku is the parent product SKU of the associated item.
*/
topLevelSku?: string | null;
specialToDate?: string | null;
specialFromDate?: string | null;
Expand Down Expand Up @@ -55,15 +61,16 @@ type Product = {
mainImageUrl?: string | null;
};
type ConfigurableOption = {
id?: number;
id: number;
optionLabel: string;
valueId?: number;
valueId: number;
valueLabel: string;
};
type Payment = {
paymentMethodCode: string;
paymentMethodName: string;
total: number;
orderId?: string;
};
type Shipping = {
shippingMethod?: string;
Expand All @@ -81,6 +88,7 @@ export type ShoppingCartContext = {
giftMessageSelected?: boolean;
giftWrappingSelected?: boolean;
source?: string;
discountAmount?: number;
};
export type OrderContext = {
appliedCouponCode: string;
Expand All @@ -94,6 +102,8 @@ export type OrderContext = {
shipping?: Shipping;
subtotalExcludingTax: number;
subtotalIncludingTax: number;
discountAmount?: number;
taxAmount?: number;
};
export {};
//# sourceMappingURL=acdl.d.ts.map

0 comments on commit 47f46a7

Please sign in to comment.