Skip to content

Commit

Permalink
Add new files
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarMerino committed Sep 17, 2024
1 parent 1d10801 commit e5ced49
Show file tree
Hide file tree
Showing 19 changed files with 264 additions and 0 deletions.

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

15 changes: 15 additions & 0 deletions scripts/__dropins__/storefront-checkout/chunks/fixtures.js

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import{k as _,M as y,d as h,l as g,x as l}from"./fixtures.js";import{t as m}from"./transform-shipping-methods.js";import"@dropins/tools/event-bus.js";const I=`
mutation estimateShippingMethods(
$cartId: String!
$address: EstimateAddressInput!
) {
estimateShippingMethods(
input: {
cart_id: $cartId
address: $address
}
) {
carrier_title
carrier_code
method_title
method_code
available
amount {
currency
value
}
price_excl_tax {
currency
value
}
price_incl_tax {
currency
value
}
error_message
}
}
`,M=t=>t?!!t.id&&!!t.code&&!!t.name:!1,S=t=>{if(t)return t.filter(M).map(e=>{const{id:a,code:n,name:i}=e;return{id:a,code:n,name:i}})};var f=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(f||{}),v=(t=>(t.City="city",t.Company="company",t.Country="country_id",t.FirstName="firstname",t.LastName="lastname",t.PostCode="postcode",t.Region="region",t.RegionId="region_id",t.SaveInAddressBook="save_in_address_book",t.Street="street",t.Telephone="telephone",t.Vat="vat_id",t))(v||{});const L=async t=>{const e=_.cartId,{criteria:a}=t||{},{country_code:n,region_id:i,region_name:s,zip:r}=a||{};if(!e)throw new y;if(!n)throw new h;const o=typeof i=="string"?parseInt(i,10):i,c=i||s?{...o&&{region_id:o},...s&&{region_code:s}}:void 0,u={country_code:n,...r&&{postcode:r},...c&&{region:c}};return await g({type:"mutation",query:I,options:{variables:{cartId:e,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:m})},d=`
query getRegions($countryCode: String!) {
country(id: $countryCode) {
id
available_regions {
id
code
name
}
}
}`,N=async(t,e)=>(l.value.addressType=e,g({type:"query",query:d,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:S})),p="-",R=`
`,E=2e3,w=(t,e)=>Object.keys(e).filter(a=>a.startsWith(t)).sort((a,n)=>parseInt(a.replace(`${t}${p}`,""),10)-parseInt(n.replace(`${t}${p}`,""),10)).map(a=>e[a]);export{f as A,E as D,p as M,v as a,w as b,R as c,L as e,N as g};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import{a as r,g as s,u as e,k as l,M as n,l as o}from"./fixtures.js";import"@dropins/tools/event-bus.js";import{C as m,t as c}from"./getCart.graphql.js";const u=a=>!!(a!=null&&a.is_email_available),E=`
query isEmailAvailable($email: String!) {
isEmailAvailable(email: $email) {
is_email_available
}
}
`,h=a=>{if(!(!a||a.length===0))throw Error(a.map(t=>t.message).join(" "))},A=async a=>{if(!a)throw new r;const{data:t,errors:i}=await s(E,{method:"GET",cache:"no-cache",variables:{email:a}}).catch(e);return i&&h(i),u(t.isEmailAvailable)},p=`
mutation setGuestEmail($cartId: String!, $email: String!) {
setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
cart {
id
...CheckoutData
}
}
}
${m}
`,C=async a=>{const t=l.cartId;if(!t)throw new n;return await o({type:"mutation",query:p,options:{variables:{cartId:t,email:a}},path:"setGuestEmailOnCart.cart",signalType:"cart",transformer:c})};export{A as i,C as s};
13 changes: 13 additions & 0 deletions scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import{k as e,M as r,b as n,l as s}from"./fixtures.js";import{C as o,t as i}from"./getCart.graphql.js";const m=`
mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) {
setPaymentMethodOnCart(
input: { cart_id: $cartId, payment_method: { code: $paymentMethod } }
) {
cart {
id
...CheckoutData
}
}
}
${o}
`,h=async t=>{const a=e.cartId;if(!a)throw new r;if(!t)throw new n;return await s({type:"mutation",query:m,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:i})};export{h as s};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import{a as s,b as p,M as u,c as _}from"./getMultilineValues.js";import{k as g,M as I,l}from"./fixtures.js";import{C,t as h}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const A=/^\d+$/,T=t=>{if(A.test(t))return parseInt(t,10)},m=`
mutation setShippingAddress($cartId: String!, $address: CartAddressInput!, $pickup_location_code: String) {
setShippingAddressesOnCart(
input: {
cart_id: $cartId,
shipping_addresses: [{ address: $address, pickup_location_code: $pickup_location_code }]
}
) {
cart {
id
...CheckoutData
}
}
}
${C}
`,y=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],$=t=>{const a={city:t[s.City],company:t[s.Company],country_code:t[s.Country],firstname:t[s.FirstName],lastname:t[s.LastName],postcode:t[s.PostCode],save_in_address_book:!0,street:p(s.Street,t),telephone:t[s.Telephone],vat_id:t[s.Vat]},r=t[s.Region],c=T(r);c?a.region_id=c:a.region=r;const d=Object.keys(t).filter(e=>!e.startsWith("street")).filter(e=>!y.includes(e)).filter(e=>e!=="country_id").map(e=>{const[n,i]=e.split(u);if(!i)return{attribute_code:n,value:t[e]};const o=p(n,t).join(_);return{attribute_code:n,value:o}}).filter((e,n,i)=>n===i.findIndex(o=>o.attribute_code===e.attribute_code));return d.length>0&&(a.custom_attributes=d),a},k=async({signal:t,...a})=>{const r=g.cartId;if(!r)throw new I;return await l({type:"mutation",query:m,options:{signal:t,variables:{cartId:r,...a}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:h})};export{y as S,$ as p,k as s};

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './ServerError/index'
import _default from './ServerError/index'
export default _default

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Container } from '@dropins/tools/types/elsie/src/lib';

interface ServerErrorProps {
onServerError?: () => void;
}
export declare const ServerError: Container<ServerErrorProps>;
export {};
//# sourceMappingURL=ServerError.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/********************************************************************
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
*******************************************************************/
export * from './ServerError';
export { ServerError as default } from './ServerError';
//# sourceMappingURL=index.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/********************************************************************
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
*******************************************************************/
export declare const serverErrorSignal: import('@preact/signals-core').Signal<string | undefined>;
//# sourceMappingURL=ServerErrorSignal.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/********************************************************************
* ADOBE CONFIDENTIAL:
* __________________
*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
*******************************************************************/
export * from './isUnexpectedError';
//# sourceMappingURL=index.d.ts.map
Loading

0 comments on commit e5ced49

Please sign in to comment.