Skip to content

Commit

Permalink
added order and account 7
Browse files Browse the repository at this point in the history
  • Loading branch information
KostiantynFandeliuk committed Dec 3, 2024
1 parent 198e15b commit 970bf1a
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion 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 GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n";
export declare const GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n base_media_url\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n";
//# sourceMappingURL=getStoreConfig.graphql.d.ts.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{t as u,k as i,f as _,l as p}from"./removeCustomerAddress.js";const f=(e,r="en-US",s={})=>{const t={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},a=new Date(e);return isNaN(a.getTime())?"Invalid Date":new Intl.DateTimeFormat(r,t).format(a)},g=e=>{var d,c;if(!((c=(d=e.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:r,page_info:s,total_count:n,date_of_first_order:t}=e.data.customer.orders,{returns:a}=e.data.customer;return{items:r.map(o=>{const l={...o,returns:a==null?void 0:a.items.filter(m=>m.order.id===o.id),order_date:f(o.order_date),shipping_address:u(o.shipping_address),billing_address:u(o.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(n,"camelCase",{}),dateOfFirstOrder:i(t,"camelCase",{})}},y=`
import{t as u,m as i,f as _,l as p}from"./removeCustomerAddress.js";const f=(e,t="en-US",a={})=>{const s={...{day:"2-digit",month:"2-digit",year:"numeric"},...a},r=new Date(e);return isNaN(r.getTime())?"Invalid Date":new Intl.DateTimeFormat(t,s).format(r)},g=e=>{var d,c;if(!((c=(d=e.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:t,page_info:a,total_count:o,date_of_first_order:s}=e.data.customer.orders,{returns:r}=e.data.customer;return{items:t.map(n=>{const l={...n,returns:r==null?void 0:r.items.filter(m=>m.order.id===n.id),order_date:f(n.order_date),shipping_address:u(n.shipping_address),billing_address:u(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(a,"camelCase",{}),totalCount:i(o,"camelCase",{}),dateOfFirstOrder:i(s,"camelCase",{})}},y=`
fragment AddressesList on OrderAddress {
city
company
Expand Down Expand Up @@ -123,4 +123,4 @@ fragment OrderSummary on OrderTotal {
}
${y}
${O}
`,h={sort_direction:"DESC",sort_field:"CREATED_AT"},E=async(e,r,s)=>{const n=r.includes("viewAll")?{}:{order_date:JSON.parse(r)};return await _(S,{method:"GET",cache:"no-cache",variables:{pageSize:e,currentPage:s,filter:n,sort:h}}).then(t=>(console.log("response.errors",t.errors),g(t))).catch(p)};export{E as g};
`,h={sort_direction:"DESC",sort_field:"CREATED_AT"},E=async(e,t,a)=>{const o=t.includes("viewAll")?{}:{order_date:JSON.parse(t)};return await _(S,{method:"GET",cache:"no-cache",variables:{pageSize:e,currentPage:a,filter:o,sort:h}}).then(s=>g(s)).catch(p)};export{E as g};
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
Expand Up @@ -119,4 +119,4 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr
mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) {
deleteCustomerAddress(id:$id)
}
`,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,_ as l,S as m,f as n,p as o,J as r,k as s,$ as t,Y 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,f as k,_ as l,g as m,S as n,p as o,J as r,k as s,$ as t,Y as u};
20 changes: 6 additions & 14 deletions scripts/__dropins__/storefront-account/chunks/updateCustomer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{m as G,f as d,n as l,l as e,k as M}from"./removeCustomerAddress.js";const $=t=>{var r,m,u,c,i,_,h,C,f,o,E,n,g,T,S,w,O,P,b,A,R;const a=(u=(m=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:m.custom_attributes)==null?void 0:u.reduce((U,N)=>(U[G(N.code)]=N.value??"",U),{});return{email:((i=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:i.email)||"",firstName:((h=(_=t==null?void 0:t.data)==null?void 0:_.customer)==null?void 0:h.firstname)||"",lastName:((f=(C=t==null?void 0:t.data)==null?void 0:C.customer)==null?void 0:f.lastname)||"",middleName:((E=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:E.middlename)||"",gender:((g=(n=t==null?void 0:t.data)==null?void 0:n.customer)==null?void 0:g.gender)||"1",dateOfBirth:((S=(T=t==null?void 0:t.data)==null?void 0:T.customer)==null?void 0:S.date_of_birth)||"",prefix:((O=(w=t==null?void 0:t.data)==null?void 0:w.customer)==null?void 0:O.prefix)||"",suffix:((b=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:b.suffix)||"",createdAt:((R=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:R.created_at)||"",...a}},I=t=>{var a,r,m,u;return{minLength:+((r=(a=t==null?void 0:t.data)==null?void 0:a.storeConfig)==null?void 0:r.minimum_password_length)||3,requiredCharacterClasses:+((u=(m=t==null?void 0:t.data)==null?void 0:m.storeConfig)==null?void 0:u.required_character_classes_number)||0}},y=`
import{n as N,f as c,k as l,l as C,m as $}from"./removeCustomerAddress.js";const v=t=>{var a,u,r,i,d,f,h,_,e,E,o,S,T,w,P,g,O,A,U,b,n;const m=(r=(u=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:u.custom_attributes)==null?void 0:r.reduce((M,R)=>(M[N(R.code)]=R.value??"",M),{});return{email:((d=(i=t==null?void 0:t.data)==null?void 0:i.customer)==null?void 0:d.email)||"",firstName:((h=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:h.firstname)||"",lastName:((e=(_=t==null?void 0:t.data)==null?void 0:_.customer)==null?void 0:e.lastname)||"",middleName:((o=(E=t==null?void 0:t.data)==null?void 0:E.customer)==null?void 0:o.middlename)||"",gender:((T=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:T.gender)||"1",dateOfBirth:((P=(w=t==null?void 0:t.data)==null?void 0:w.customer)==null?void 0:P.date_of_birth)||"",prefix:((O=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:O.prefix)||"",suffix:((U=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:U.suffix)||"",createdAt:((n=(b=t==null?void 0:t.data)==null?void 0:b.customer)==null?void 0:n.created_at)||"",...m}},x=`
fragment BasicCustomerInfo on Customer {
date_of_birth
email
Expand All @@ -12,7 +12,7 @@ import{m as G,f as d,n as l,l as e,k as M}from"./removeCustomerAddress.js";const
suffix
created_at
}
`,v=`
`,G=`
query GET_CUSTOMER {
customer {
...BasicCustomerInfo
Expand All @@ -25,34 +25,26 @@ import{m as G,f as d,n as l,l as e,k as M}from"./removeCustomerAddress.js";const
}
}
}
${y}`,B=async()=>await d(v,{method:"GET",cache:"no-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):$(t)}).catch(e),x=`
${x}`,B=async()=>await c(G,{method:"GET",cache:"no-cache"}).then(t=>{var m;return(m=t.errors)!=null&&m.length?l(t.errors):v(t)}).catch(C),I=`
mutation CHANGE_CUSTOMER_PASSWORD($currentPassword: String!, $newPassword: String!) {
changeCustomerPassword(currentPassword: $currentPassword, newPassword: $newPassword) {
email
}
}
`,L=async({currentPassword:t,newPassword:a})=>await d(x,{method:"POST",variables:{currentPassword:t,newPassword:a}}).then(r=>{var m,u,c;return(m=r.errors)!=null&&m.length?l(r.errors):((c=(u=r==null?void 0:r.data)==null?void 0:u.changeCustomerPassword)==null?void 0:c.email)||""}).catch(e),D=`
query GET_STORE_CONFIG {
storeConfig {
autocomplete_on_storefront
minimum_password_length
required_character_classes_number
}
}
`,k=async()=>await d(D,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):I(t)}).catch(e),q=`
`,k=async({currentPassword:t,newPassword:m})=>await c(I,{method:"POST",variables:{currentPassword:t,newPassword:m}}).then(a=>{var u,r,i;return(u=a.errors)!=null&&u.length?l(a.errors):((i=(r=a==null?void 0:a.data)==null?void 0:r.changeCustomerPassword)==null?void 0:i.email)||""}).catch(C),y=`
mutation UPDATE_CUSTOMER_EMAIL($email: String! $password: String!) {
updateCustomerEmail(email:$email password:$password) {
customer {
email
}
}
}
`,H=async({email:t,password:a})=>await d(q,{method:"POST",variables:{email:t,password:a}}).then(r=>{var m,u,c,i;return(m=r.errors)!=null&&m.length?l(r.errors):((i=(c=(u=r==null?void 0:r.data)==null?void 0:u.updateCustomerEmail)==null?void 0:c.customer)==null?void 0:i.email)||""}).catch(e),F=`
`,F=async({email:t,password:m})=>await c(y,{method:"POST",variables:{email:t,password:m}}).then(a=>{var u,r,i,d;return(u=a.errors)!=null&&u.length?l(a.errors):((d=(i=(r=a==null?void 0:a.data)==null?void 0:r.updateCustomerEmail)==null?void 0:i.customer)==null?void 0:d.email)||""}).catch(C),D=`
mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) {
updateCustomerV2(input:$input) {
customer {
email
}
}
}
`,W=async t=>await d(F,{method:"POST",variables:{input:M(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(a=>{var r,m,u,c;return(r=a.errors)!=null&&r.length?l(a.errors):((c=(u=(m=a==null?void 0:a.data)==null?void 0:m.updateCustomerV2)==null?void 0:u.customer)==null?void 0:c.email)||""}).catch(e);export{k as a,H as b,W as c,B as g,L as u};
`,L=async t=>await c(D,{method:"POST",variables:{input:$(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(m=>{var a,u,r,i;return(a=m.errors)!=null&&a.length?l(m.errors):((i=(r=(u=m==null?void 0:m.data)==null?void 0:u.updateCustomerV2)==null?void 0:r.customer)==null?void 0:i.email)||""}).catch(C);export{F as a,L as b,B as g,k as u};

Large diffs are not rendered by default.

Loading

0 comments on commit 970bf1a

Please sign in to comment.