Skip to content

Commit

Permalink
test fix address chnage issue
Browse files Browse the repository at this point in the history
  • Loading branch information
KostiantynFandeliuk committed Dec 4, 2024
1 parent ce647b4 commit 87eb063
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 62 deletions.
2 changes: 2 additions & 0 deletions scripts/__dropins__/storefront-account/api.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
@@ -1,2 +1,2 @@
export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BasicCustomerInfo on Customer {\n date_of_birth\n dob\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n";
export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BasicCustomerInfo on Customer {\n date_of_birth\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n";
//# sourceMappingURL=CustomerFragment.graphql.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n";
export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n middlename\n fax\n prefix\n suffix\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n";
//# sourceMappingURL=getCustomerAddress.graphql.d.ts.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{t as u,k as i,f as _,l as f,m as p}from"./removeCustomerAddress.js";const g=(r,a="en-US",s={})=>{const t={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},e=new Date(r);return isNaN(e.getTime())?"Invalid Date":new Intl.DateTimeFormat(a,t).format(e)},y=r=>{var d,c;if(!((c=(d=r.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:a,page_info:s,total_count:o,date_of_first_order:t}=r.data.customer.orders,{returns:e}=r.data.customer;return{items:a.map(n=>{const l={...n,returns:e==null?void 0:e.items.filter(m=>m.order.id===n.id),order_date:g(n.order_date),shipping_address:u(n.shipping_address),billing_address:u(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(o,"camelCase",{}),dateOfFirstOrder:i(t,"camelCase",{})}},h=`
fragment AddressesList on OrderAddress {
city
Expand Down
12 changes: 12 additions & 0 deletions scripts/__dropins__/storefront-account/chunks/getStoreConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{f as h,k as o,l as m}from"./removeCustomerAddress.js";const u=r=>{var a,t,c,e,i,_;return{baseMediaUrl:(t=(a=r==null?void 0:r.data)==null?void 0:a.storeConfig)==null?void 0:t.base_media_url,minLength:+((e=(c=r==null?void 0:r.data)==null?void 0:c.storeConfig)==null?void 0:e.minimum_password_length)||3,requiredCharacterClasses:+((_=(i=r==null?void 0:r.data)==null?void 0:i.storeConfig)==null?void 0:_.required_character_classes_number)||0}},d=`
query GET_STORE_CONFIG {
storeConfig {
base_media_url
autocomplete_on_storefront
minimum_password_length
required_character_classes_number
}
}
`,f=async()=>await h(d,{method:"GET",cache:"force-cache"}).then(r=>{var a;return(a=r.errors)!=null&&a.length?o(r.errors):u(r)}).catch(m);export{f as g};
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}from"@dropins/tools/fetch-graphql.js";const b=t=>t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),A=t=>t.replace(/([A-Z])/g,e=>`_${e.toLowerCase()}`),a=(t,e,r)=>{const n=["string","boolean","number"],o=e==="camelCase"?b:A;return Array.isArray(t)?t.map(i=>n.includes(typeof i)||i===null?i:typeof i=="object"?a(i,e,r):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,_])=>{const u=r&&r[c]?r[c]:o(c);return i[u]=n.includes(typeof _)||_===null?_:a(_,e,r),i},{}):t},{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:s,getConfig:k}=new T().getMethods(),p=`
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}from"@dropins/tools/fetch-graphql.js";const S=t=>t.replace(/_([a-z])/g,(n,e)=>e.toUpperCase()),p=t=>t.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),g=(t,n,e)=>{const r=["string","boolean","number"],o=n==="camelCase"?S:p;return Array.isArray(t)?t.map(i=>r.includes(typeof i)||i===null?i:typeof i=="object"?g(i,n,e):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,a])=>{const u=e&&e[c]?e[c]:o(c);return i[u]=r.includes(typeof a)||a===null?a:g(a,n,e),i},{}):t},{setEndpoint:k,setFetchGraphQlHeader:H,removeFetchGraphQlHeader:J,setFetchGraphQlHeaders:K,fetchGraphQl:s,getConfig:L}=new C().getMethods(),T=`
query GET_ATTRIBUTES_FORM($formCode: String!) {
attributesForm(formCode: $formCode) {
items {
Expand Down Expand Up @@ -30,7 +32,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
}
}
}
`,R=`
`,A=`
query GET_ATTRIBUTES_FORM_SHORT {
attributesForm(formCode: "customer_register_address") {
items {
Expand All @@ -44,18 +46,22 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
}
}
}
`,f=t=>{throw t instanceof DOMException&&t.name==="AbortError"||C.emit("error",{source:"auth",type:"network",error:t}),t},h=t=>{const e=t.map(r=>r.message).join(" ");throw Error(e)},S=t=>{let e=[];for(const r of t)if(!(r.frontend_input!=="MULTILINE"||r.multiline_count<2))for(let n=2;n<=r.multiline_count;n++){const o={...r,is_required:!1,name:`${r.code}_multiline_${n}`,code:`${r.code}_multiline_${n}`,id:`${r.code}_multiline_${n}`};e.push(o)}return e},y=t=>{var i,c,_;const e=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!e.length)return[];const r=(_=e.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:_.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),n=S(r);return r.concat(n).map(u=>{var g;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":b(u.code),m=(g=u.options)==null?void 0:g.map(E=>({isDefault:E.is_default,text:E.label,value:E.value}));return a({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const e={};for(const r in t){const n=t[r];!Array.isArray(n)||n.length===0||(r==="custom_attributesV2"?n.forEach(o=>{typeof o=="object"&&"value"in o&&(e[o==null?void 0:o.code]=o==null?void 0:o.value)}):n.length>1?n.forEach((o,i)=>{i===0?e[r]=o:e[`${r}_multiline_${i+1}`]=o}):e[r]=n[0])}return e},d=t=>{var e,r,n;return a({firstname:(t==null?void 0:t.firstname)||"",lastname:(t==null?void 0:t.lastname)||"",city:(t==null?void 0:t.city)||"",company:(t==null?void 0:t.company)||"",country_code:(t==null?void 0:t.country_code)||"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)||"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)||"",region_id:((n=t==null?void 0:t.region)==null?void 0:n.region_id)||""},telephone:(t==null?void 0:t.telephone)||"",id:(t==null?void 0:t.id)||"",vat_id:(t==null?void 0:t.vat_id)||"",postcode:(t==null?void 0:t.postcode)||"",default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},O=t=>{var r,n;const e=((n=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:n.addresses)||[];return e.length?e.map(d).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},$=t=>{var c,_;if(!((_=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&_.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:e,storeConfig:r}=t.data,n=r==null?void 0:r.countries_with_required_region.split(","),o=r==null?void 0:r.optional_zip_countries.split(",");return{availableCountries:e.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:n,optionalZipCountries:o}},N=t=>{var r,n;return(n=(r=t==null?void 0:t.data)==null?void 0:r.country)!=null&&n.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:_}=o;return!!(i&&c&&_)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},H=async t=>await s(t!=="shortRequest"?p:R,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):y(e)}).catch(f),G=`
`,_=t=>{throw t instanceof DOMException&&t.name==="AbortError"||b.emit("error",{source:"auth",type:"network",error:t}),t},f=t=>{const n=t.map(e=>e.message).join(" ");throw Error(n)},y=t=>{let n=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let r=2;r<=e.multiline_count;r++){const o={...e,is_required:!1,name:`${e.code}_multiline_${r}`,code:`${e.code}_multiline_${r}`,id:`${e.code}_multiline_${r}`};n.push(o)}return n},R=t=>{var i,c,a;const n=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!n.length)return[];const e=(a=n.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:a.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),r=y(e);return e.concat(r).map(u=>{var E;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":S(u.code),m=(E=u.options)==null?void 0:E.map(h=>({isDefault:h.is_default,text:h.label,value:h.value}));return g({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const n={};for(const e in t){const r=t[e];!Array.isArray(r)||r.length===0||(e==="custom_attributesV2"?r.forEach(o=>{typeof o=="object"&&"value"in o&&(n[o==null?void 0:o.code]=o==null?void 0:o.value)}):r.length>1?r.forEach((o,i)=>{i===0?n[e]=o:n[`${e}_multiline_${i+1}`]=o}):n[e]=r[0])}return n},N=t=>({prefix:(t==null?void 0:t.prefix)??"",suffix:(t==null?void 0:t.suffix)??"",firstname:(t==null?void 0:t.firstname)??"",lastname:(t==null?void 0:t.lastname)??"",middlename:(t==null?void 0:t.middlename)??""}),O=t=>({id:(t==null?void 0:t.id)??"",vat_id:(t==null?void 0:t.vat_id)??"",postcode:(t==null?void 0:t.postcode)??"",country_code:(t==null?void 0:t.country_code)??""}),I=t=>({company:(t==null?void 0:t.company)??"",telephone:(t==null?void 0:t.telephone)??"",fax:(t==null?void 0:t.fax)??""}),$=t=>{var e,r,o;return g({...N(t),...O(t),...I(t),city:(t==null?void 0:t.city)??"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)??"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)??"",region_id:((o=t==null?void 0:t.region)==null?void 0:o.region_id)??""},default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},G=t=>{var r,o;const n=((o=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:o.addresses)||[];return n.length?n.map($).sort((i,c)=>(Number(c.defaultBilling)||Number(c.defaultShipping))-(Number(i.defaultBilling)||Number(i.defaultShipping))):[]},M=t=>{var c,a;if(!((a=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&a.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:n,storeConfig:e}=t.data,r=e==null?void 0:e.countries_with_required_region.split(","),o=e==null?void 0:e.optional_zip_countries.split(",");return{availableCountries:n.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:r,optionalZipCountries:o}},U=t=>{var e,r;return(r=(e=t==null?void 0:t.data)==null?void 0:e.country)!=null&&r.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:a}=o;return!!(i&&c&&a)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},P=async t=>{const n=`_account_attributesForm_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(t!=="shortRequest"?T:A,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=R(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},w=`
mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {
createCustomerAddress(input:$input) {
firstname
}
}
`,L=async t=>await s(G,{method:"POST",variables:{input:a(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(e=>{var r,n,o;return(r=e.errors)!=null&&r.length?h(e.errors):((o=(n=e==null?void 0:e.data)==null?void 0:n.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(f),I=`
`,d=async t=>await s(w,{method:"POST",variables:{input:g(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(n=>{var e,r,o;return(e=n.errors)!=null&&e.length?f(n.errors):((o=(r=n==null?void 0:n.data)==null?void 0:r.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(_),x=`
query GET_CUSTOMER_ADDRESS {
customer {
addresses {
firstname
lastname
middlename
fax
prefix
suffix
city
company
country_code
Expand All @@ -80,7 +86,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
}
}
}
`,P=async()=>await s(I,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):O(t)}).catch(f),M=`
`,z=async()=>await s(x,{method:"GET",cache:"no-cache"}).then(t=>{var n;return(n=t.errors)!=null&&n.length?f(t.errors):G(t)}).catch(_),F=`
query GET_COUNTRIES_QUERY {
countries {
two_letter_abbreviation
Expand All @@ -91,7 +97,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
optional_zip_countries
}
}
`,z=async()=>await s(M,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):$(t)}).catch(f),U=`
`,Z=async()=>{const t="_account_countries",n=sessionStorage.getItem(t);return n?JSON.parse(n):await s(F,{method:"GET",cache:"no-cache"}).then(e=>{var o;if((o=e.errors)!=null&&o.length)return f(e.errors);const r=M(e);return sessionStorage.setItem(t,JSON.stringify(r)),r}).catch(_)},q=`
query GET_REGIONS($countryCode: String!) {
country(id: $countryCode) {
id
Expand All @@ -102,15 +108,15 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
}
}
}
`,Z=async t=>await s(U,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):N(e)}).catch(f),w=`
`,W=async t=>{const n=`_account_regions_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(q,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=U(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},V=`
mutation UPDATE_CUSTOMER_ADDRESS($id: Int!,
$input: CustomerAddressInput) {
updateCustomerAddress(id:$id, input:$input) {
firstname
}
}
`,K=async t=>{const{addressId:e,...r}=t;return e?await s(w,{method:"POST",variables:{id:e,input:a(r,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(n=>{var o,i,c;return(o=n.errors)!=null&&o.length?h(n.errors):((c=(i=n==null?void 0:n.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(f):""},q=`
`,Y=async t=>{const{addressId:n,...e}=t;return n?await s(V,{method:"POST",variables:{id:n,input:g(e,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(r=>{var o,i,c;return(o=r.errors)!=null&&o.length?f(r.errors):((c=(i=r==null?void 0:r.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(_):""},B=`
mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) {
deleteCustomerAddress(id:$id)
}
`,W=async t=>await s(q,{method:"POST",variables:{id:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):e.data.deleteCustomerAddress}).catch(f);export{B as a,j as b,H as c,L as d,P as e,s as f,k as g,z as h,Z as i,W as j,a as k,h as l,f as m,b as n,A as o,Q as r,x as s,d as t,K as u};
`,X=async t=>await s(B,{method:"POST",variables:{id:t}}).then(n=>{var e;return(e=n.errors)!=null&&e.length?f(n.errors):n.data.deleteCustomerAddress}).catch(_);export{H as a,K as b,P as c,d,z as e,s as f,L as g,Z as h,W as i,X as j,g as k,f as l,_ as m,S as n,p as o,J as r,k as s,$ as t,Y as u};
Loading

0 comments on commit 87eb063

Please sign in to comment.