@dropins/storefront-account 0.1.0-alpha9 → 1.0.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts +1 -1
  2. package/api/fragments.d.ts +4 -0
  3. package/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts +1 -1
  4. package/api/getCountries/getCountries.d.ts +6 -2
  5. package/api/getCountries/graphql/getCountries.graphql.d.ts +1 -1
  6. package/api/getCustomer/graphql/getCustomer.graphql.d.ts +1 -1
  7. package/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts +1 -1
  8. package/api/getOrderHistoryList/getOrderHistoryList.d.ts +2 -2
  9. package/api/getOrderHistoryList/graphql/getOrderHistoryList.graphql.d.ts +1 -1
  10. package/api/getRegions/getRegions.d.ts +4 -1
  11. package/api/getStoreConfig/getStoreConfig.d.ts +4 -0
  12. package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +2 -0
  13. package/api/getStoreConfig/index.d.ts +2 -0
  14. package/api/graphql/CustomerAddressFragment.graphql.d.ts +2 -0
  15. package/api/graphql/CustomerFragment.graphql.d.ts +2 -0
  16. package/api/graphql/OrderSummaryFragment.graphql.d.ts +2 -0
  17. package/api/index.d.ts +4 -0
  18. package/api/initialize/initialize.d.ts +7 -1
  19. package/api/removeCustomerAddress/graphql/removeCustomerAddress.graphql.d.ts +1 -1
  20. package/api/updateCustomer/graphql/updateCustomer.graphql.d.ts +2 -0
  21. package/api/updateCustomer/index.d.ts +2 -0
  22. package/api/updateCustomer/updateCustomer.d.ts +2 -0
  23. package/api/updateCustomerAddress/graphql/updateCustomerAddress.graphql.d.ts +1 -1
  24. package/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts +2 -0
  25. package/api/updateCustomerEmail/index.d.ts +2 -0
  26. package/api/updateCustomerEmail/updateCustomerEmail.d.ts +5 -0
  27. package/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts +2 -0
  28. package/api/updateCustomerPassword/index.d.ts +2 -0
  29. package/api/updateCustomerPassword/updateCustomerPassword.d.ts +4 -0
  30. package/api.js +3 -9
  31. package/chunks/CustomerInformationCard.js +3 -0
  32. package/chunks/getOrderHistoryList.js +123 -76
  33. package/chunks/getStoreConfig.js +12 -0
  34. package/chunks/removeCustomerAddress.js +90 -4
  35. package/chunks/updateCustomer.js +57 -0
  36. package/components/ChangePassword/ChangePassword.d.ts +5 -0
  37. package/components/ChangePassword/index.d.ts +3 -0
  38. package/components/CustomerInformationCard/CustomerInformationCard.d.ts +5 -0
  39. package/components/CustomerInformationCard/index.d.ts +3 -0
  40. package/components/EditCustomerInformation/EditCustomerInformation.d.ts +5 -0
  41. package/components/EditCustomerInformation/index.d.ts +3 -0
  42. package/components/Form/Form.d.ts +4 -3
  43. package/components/index.d.ts +3 -0
  44. package/configs/defaultAttributePreset.config.d.ts +1 -0
  45. package/configs/mockDefaultAddress.config.d.ts +9 -40
  46. package/configs/mockOrdersList.config.d.ts +110 -2
  47. package/containers/AddressForm.js +3 -1
  48. package/containers/Addresses.js +3 -1
  49. package/containers/CustomerInformation/CustomerInformation.d.ts +5 -0
  50. package/containers/CustomerInformation/index.d.ts +3 -0
  51. package/containers/CustomerInformation.d.ts +3 -0
  52. package/containers/CustomerInformation.js +3 -0
  53. package/containers/OrdersList.js +3 -1
  54. package/containers/index.d.ts +1 -0
  55. package/data/models/customer-address.d.ts +3 -3
  56. package/data/models/customer.d.ts +9 -2
  57. package/data/models/index.d.ts +1 -0
  58. package/data/models/order-history-list.d.ts +20 -4
  59. package/data/models/region.d.ts +1 -0
  60. package/data/models/store-config.d.ts +6 -0
  61. package/data/transforms/index.d.ts +1 -0
  62. package/data/transforms/transform-countries.d.ts +6 -2
  63. package/data/transforms/transform-customer-address.d.ts +0 -1
  64. package/data/transforms/transform-order-history-list.d.ts +2 -2
  65. package/data/transforms/transform-store-config.d.ts +5 -0
  66. package/hooks/components/useChangePassword.d.ts +26 -0
  67. package/hooks/components/useForm.d.ts +7 -5
  68. package/hooks/components/usePasswordValidationMessage.d.ts +16 -0
  69. package/hooks/containers/useAddressForm.d.ts +18 -7
  70. package/hooks/containers/useAddresses.d.ts +3 -1
  71. package/hooks/containers/useCustomerInformation.d.ts +50 -0
  72. package/hooks/containers/useGetStoreConfigs.d.ts +7 -0
  73. package/hooks/containers/useOrderSelectList.d.ts +2 -0
  74. package/hooks/containers/useOrdersList.d.ts +8 -3
  75. package/hooks/useInLineAlert.d.ts +7 -0
  76. package/hooks/useIsMobile.d.ts +2 -0
  77. package/i18n/en_US.json.d.ts +109 -43
  78. package/lib/areRequiredFieldsValid.d.ts +6 -0
  79. package/lib/getFieldsConfig.d.ts +1 -22
  80. package/lib/getFormValuesFromRef.d.ts +5 -0
  81. package/lib/initializeFormDataAndErrors.d.ts +10 -0
  82. package/lib/normalizeAttributes.d.ts +1 -1
  83. package/lib/normalizeGetAddressData.d.ts +6 -0
  84. package/lib/prepareNormalizedData.d.ts +21 -0
  85. package/lib/sortingAddressesList.d.ts +5 -0
  86. package/lib/transformDefaultValuesAddresses.d.ts +11 -0
  87. package/lib/transformSessionData.d.ts +6 -0
  88. package/lib/validationChangePassword.d.ts +17 -0
  89. package/lib/validationFields.d.ts +2 -1
  90. package/lib/validationUniqueSymbolsPassword.d.ts +2 -0
  91. package/package.json +1 -1
  92. package/render.js +5 -3
  93. package/types/addressForm.types.d.ts +11 -6
  94. package/types/addresses.types.d.ts +41 -7
  95. package/types/api/getCountries.types.d.ts +4 -0
  96. package/types/api/getCustomer.types.d.ts +10 -0
  97. package/types/api/getCustomerAddress.type.d.ts +5 -1
  98. package/types/api/getOrderHistoryList.types.d.ts +17 -0
  99. package/types/api/storeConfig.types.d.ts +14 -0
  100. package/types/api/updateCustomerPassword.types.d.ts +15 -0
  101. package/types/customerInformation.types.d.ts +61 -0
  102. package/types/form.types.d.ts +24 -8
  103. package/types/index.d.ts +4 -1
  104. package/types/notification.types.d.ts +19 -0
  105. package/types/ordersList.types.d.ts +18 -2
  106. package/chunks/AddressFormWrapper.js +0 -1
  107. package/chunks/AddressFormWrapper2.js +0 -1
  108. package/chunks/checkIsFunction.js +0 -1
  109. package/chunks/convertCase.js +0 -1
  110. package/chunks/transform-customer-address.js +0 -1
  111. package/chunks/updateCustomerAddress.js +0 -78
  112. package/hooks/api/useCountryRegionOptions.d.ts +0 -7
  113. package/types/translations.types.d.ts +0 -9
@@ -1,9 +1,67 @@
1
- import{f as a,h as o,a as s}from"./convertCase.js";import{a as d}from"./transform-customer-address.js";const n=`
1
+ /*! Copyright 2024 Adobe
2
+ All Rights Reserved. */
3
+ 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=`
4
+ query GET_ATTRIBUTES_FORM($formCode: String!) {
5
+ attributesForm(formCode: $formCode) {
6
+ items {
7
+ code
8
+ default_value
9
+ entity_type
10
+ frontend_class
11
+ frontend_input
12
+ is_required
13
+ is_unique
14
+ label
15
+ options {
16
+ is_default
17
+ label
18
+ value
19
+ }
20
+ ... on CustomerAttributeMetadata {
21
+ multiline_count
22
+ sort_order
23
+ validate_rules {
24
+ name
25
+ value
26
+ }
27
+ }
28
+ }
29
+ errors {
30
+ type
31
+ message
32
+ }
33
+ }
34
+ }
35
+ `,A=`
36
+ query GET_ATTRIBUTES_FORM_SHORT {
37
+ attributesForm(formCode: "customer_register_address") {
38
+ items {
39
+ frontend_input
40
+ label
41
+ code
42
+ ... on CustomerAttributeMetadata {
43
+ multiline_count
44
+ sort_order
45
+ }
46
+ }
47
+ }
48
+ }
49
+ `,_=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=`
50
+ mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {
51
+ createCustomerAddress(input: $input) {
52
+ firstname
53
+ }
54
+ }
55
+ `,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=`
2
56
  query GET_CUSTOMER_ADDRESS {
3
57
  customer {
4
58
  addresses {
5
59
  firstname
6
60
  lastname
61
+ middlename
62
+ fax
63
+ prefix
64
+ suffix
7
65
  city
8
66
  company
9
67
  country_code
@@ -28,8 +86,36 @@ import{f as a,h as o,a as s}from"./convertCase.js";import{a as d}from"./transfor
28
86
  }
29
87
  }
30
88
  }
31
- `,h=async()=>await a(n,{method:"GET",cache:"force-cache"}).then(r=>{var e;return(e=r.errors)!=null&&e.length?o(r.errors):d(r)}).catch(s),i=`
89
+ `,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=`
90
+ query GET_COUNTRIES_QUERY {
91
+ countries {
92
+ two_letter_abbreviation
93
+ full_name_locale
94
+ }
95
+ storeConfig {
96
+ countries_with_required_region
97
+ optional_zip_countries
98
+ }
99
+ }
100
+ `,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=`
101
+ query GET_REGIONS($countryCode: String!) {
102
+ country(id: $countryCode) {
103
+ id
104
+ available_regions {
105
+ id
106
+ code
107
+ name
108
+ }
109
+ }
110
+ }
111
+ `,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=`
112
+ mutation UPDATE_CUSTOMER_ADDRESS($id: Int!, $input: CustomerAddressInput) {
113
+ updateCustomerAddress(id: $id, input: $input) {
114
+ firstname
115
+ }
116
+ }
117
+ `,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=`
32
118
  mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) {
33
- deleteCustomerAddress(id:$id)
119
+ deleteCustomerAddress(id: $id)
34
120
  }
35
- `,l=async r=>await a(i,{method:"POST",variables:{id:r}}).then(e=>{var t;return(t=e.errors)!=null&&t.length?o(e.errors):e.data.deleteCustomerAddress}).catch(s);export{h as g,l as r};
121
+ `,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};
@@ -0,0 +1,57 @@
1
+ /*! Copyright 2024 Adobe
2
+ All Rights Reserved. */
3
+ import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";import{c as y}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as V}from"@dropins/tools/lib.js";const B=t=>{var r,u,i,d,f,o,e,E,h,S,T,g,w,O,A,P,M,R,U,N,n,b,$,G,c,I;const m=(i=(u=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:u.custom_attributes)==null?void 0:i.reduce((v,x)=>(v[D(x.code)]=x.value??"",v),{}),a={email:((f=(d=t==null?void 0:t.data)==null?void 0:d.customer)==null?void 0:f.email)||"",firstName:((e=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:e.firstname)||"",lastName:((h=(E=t==null?void 0:t.data)==null?void 0:E.customer)==null?void 0:h.lastname)||"",middleName:((T=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:T.middlename)||"",gender:((w=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:w.gender)||"1",dateOfBirth:((A=(O=t==null?void 0:t.data)==null?void 0:O.customer)==null?void 0:A.date_of_birth)||"",prefix:((M=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:M.prefix)||"",suffix:((U=(R=t==null?void 0:t.data)==null?void 0:R.customer)==null?void 0:U.suffix)||"",createdAt:((n=(N=t==null?void 0:t.data)==null?void 0:N.customer)==null?void 0:n.created_at)||"",...m};return V(a,(I=(c=(G=($=(b=y)==null?void 0:b.getConfig())==null?void 0:$.models)==null?void 0:G.CustomerDataModelShort)==null?void 0:c.transformer)==null?void 0:I.call(c,t.data))},k=`
4
+ fragment BASIC_CUSTOMER_INFO_FRAGMENT on Customer {
5
+ date_of_birth
6
+ email
7
+ firstname
8
+ gender
9
+ lastname
10
+ middlename
11
+ prefix
12
+ suffix
13
+ created_at
14
+ }
15
+ `,L=`
16
+ query GET_CUSTOMER {
17
+ customer {
18
+ ...BASIC_CUSTOMER_INFO_FRAGMENT
19
+ custom_attributes {
20
+ ... on AttributeValue {
21
+ code
22
+ value
23
+ }
24
+ code
25
+ }
26
+ }
27
+ }
28
+ ${k}
29
+ `,J=async()=>await l(L,{method:"GET",cache:"no-cache"}).then(t=>{var m;return(m=t.errors)!=null&&m.length?C(t.errors):B(t)}).catch(_),H=`
30
+ mutation CHANGE_CUSTOMER_PASSWORD(
31
+ $currentPassword: String!
32
+ $newPassword: String!
33
+ ) {
34
+ changeCustomerPassword(
35
+ currentPassword: $currentPassword
36
+ newPassword: $newPassword
37
+ ) {
38
+ email
39
+ }
40
+ }
41
+ `,X=async({currentPassword:t,newPassword:m})=>await l(H,{method:"POST",variables:{currentPassword:t,newPassword:m}}).then(a=>{var r,u,i;return(r=a.errors)!=null&&r.length?C(a.errors):((i=(u=a==null?void 0:a.data)==null?void 0:u.changeCustomerPassword)==null?void 0:i.email)||""}).catch(_),W=`
42
+ mutation UPDATE_CUSTOMER_EMAIL($email: String!, $password: String!) {
43
+ updateCustomerEmail(email: $email, password: $password) {
44
+ customer {
45
+ email
46
+ }
47
+ }
48
+ }
49
+ `,Y=async({email:t,password:m})=>await l(W,{method:"POST",variables:{email:t,password:m}}).then(a=>{var r,u,i,d;return(r=a.errors)!=null&&r.length?C(a.errors):((d=(i=(u=a==null?void 0:a.data)==null?void 0:u.updateCustomerEmail)==null?void 0:i.customer)==null?void 0:d.email)||""}).catch(_),q=`
50
+ mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) {
51
+ updateCustomerV2(input: $input) {
52
+ customer {
53
+ email
54
+ }
55
+ }
56
+ }
57
+ `,Z=async t=>await l(q,{method:"POST",variables:{input:F(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(m=>{var a,r,u,i;return(a=m.errors)!=null&&a.length?C(m.errors):((i=(u=(r=m==null?void 0:m.data)==null?void 0:r.updateCustomerV2)==null?void 0:u.customer)==null?void 0:i.email)||""}).catch(_);export{Y as a,Z as b,J as g,X as u};
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { ChangePasswordProps } from '../../types';
3
+
4
+ export declare const ChangePassword: FunctionComponent<ChangePasswordProps>;
5
+ //# sourceMappingURL=ChangePassword.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './ChangePassword';
2
+ export { ChangePassword as default } from './ChangePassword';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { CustomerInformationCardProps } from '../../types';
3
+
4
+ export declare const CustomerInformationCard: FunctionComponent<CustomerInformationCardProps>;
5
+ //# sourceMappingURL=CustomerInformationCard.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './CustomerInformationCard';
2
+ export { CustomerInformationCard as default } from './CustomerInformationCard';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { EditCustomerInformationProps } from '../../types';
3
+
4
+ export declare const EditCustomerInformation: FunctionComponent<EditCustomerInformationProps>;
5
+ //# sourceMappingURL=EditCustomerInformation.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './EditCustomerInformation';
2
+ export { EditCustomerInformation as default } from './EditCustomerInformation';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
- import { FunctionComponent } from 'preact';
2
- import { FormProps } from '../../types';
1
+ import { FormProps, FormRef } from '../../types';
3
2
 
4
- export declare const Form: FunctionComponent<FormProps>;
3
+ export declare const Form: import('preact').FunctionComponent<import('preact/compat').PropsWithoutRef<FormProps> & {
4
+ ref?: import('preact').Ref<FormRef> | undefined;
5
+ }>;
5
6
  //# sourceMappingURL=Form.d.ts.map
@@ -10,4 +10,7 @@ export * from './OrdersListCard';
10
10
  export * from './AccountLoaders';
11
11
  export * from './AddressesWrapper';
12
12
  export * from './AddressFormWrapper';
13
+ export * from './ChangePassword';
14
+ export * from './EditCustomerInformation';
15
+ export * from './CustomerInformationCard';
13
16
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export declare const defaultAttributePreset: string[];
2
+ export declare const defaultAccountAttributePreset: string[];
2
3
  //# sourceMappingURL=defaultAttributePreset.config.d.ts.map
@@ -91,9 +91,13 @@ export declare const mockDefaultAddress: {
91
91
  vatId: string;
92
92
  postcode: string;
93
93
  street: string;
94
- street_2: string;
94
+ streetMultiline_2: string;
95
95
  defaultShipping: boolean;
96
96
  defaultBilling: boolean;
97
+ fax: string;
98
+ middlename: string;
99
+ prefix: string;
100
+ suffix: string;
97
101
  };
98
102
  export declare const mockResponseAddressWithText: {
99
103
  firstname: string;
@@ -114,45 +118,10 @@ export declare const mockResponseAddressWithText: {
114
118
  default_shipping: boolean;
115
119
  default_billing: boolean;
116
120
  custom_attributesV2: never[];
117
- };
118
- export declare const mockResponseAddressEmpty: {
119
- firstname: string;
120
- lastname: string;
121
- city: string;
122
- company: string;
123
- country_code: string;
124
- region: {
125
- region: string;
126
- region_code: string;
127
- region_id: string;
128
- };
129
- telephone: string;
130
- id: string;
131
- vat_id: string;
132
- postcode: string;
133
- street: string[];
134
- default_shipping: boolean;
135
- default_billing: boolean;
136
- custom_attributesV2: never[];
137
- };
138
- export declare const mockDefaultAddressEmpty: {
139
- firstname: string;
140
- lastname: string;
141
- city: string;
142
- company: string;
143
- countryCode: string;
144
- region: {
145
- region: string;
146
- regionCode: string;
147
- regionId: string;
148
- };
149
- telephone: string;
150
- id: string;
151
- vatId: string;
152
- postcode: string;
153
- street: string;
154
- defaultShipping: boolean;
155
- defaultBilling: boolean;
121
+ fax: string;
122
+ middlename: string;
123
+ prefix: string;
124
+ suffix: string;
156
125
  };
157
126
  export declare const mockResponseCountries: {
158
127
  two_letter_abbreviation: string;
@@ -8,7 +8,7 @@ export declare const mockOrdersListResponse: {
8
8
  };
9
9
  total_count: number;
10
10
  date_of_first_order: string;
11
- items: {
11
+ items: ({
12
12
  token: string;
13
13
  email: string;
14
14
  shipping_method: string;
@@ -23,6 +23,7 @@ export declare const mockOrdersListResponse: {
23
23
  region_code: string;
24
24
  region_id: string;
25
25
  };
26
+ shipments: never[];
26
27
  telephone: string;
27
28
  id: string;
28
29
  vat_id: string;
@@ -90,7 +91,114 @@ export declare const mockOrdersListResponse: {
90
91
  };
91
92
  discounts: never[];
92
93
  };
93
- }[];
94
+ shipments?: undefined;
95
+ quantityInvoiced?: undefined;
96
+ } | {
97
+ token: string;
98
+ email: string;
99
+ shipping_method: string;
100
+ shipments: {
101
+ id: string;
102
+ tracking: {
103
+ title: string;
104
+ number: string;
105
+ carrier: string;
106
+ }[];
107
+ }[];
108
+ shipping_address: {
109
+ firstname: string;
110
+ lastname: string;
111
+ city: string;
112
+ company: string;
113
+ country_code: string;
114
+ region: {
115
+ region: string;
116
+ region_code: string;
117
+ region_id: string;
118
+ };
119
+ telephone: string;
120
+ id: string;
121
+ vat_id: string;
122
+ postcode: string;
123
+ street: string[];
124
+ default_shipping: boolean;
125
+ default_billing: boolean;
126
+ custom_attributesV2: never[];
127
+ shipments?: undefined;
128
+ };
129
+ billing_address: {
130
+ firstname: string;
131
+ lastname: string;
132
+ city: string;
133
+ company: string;
134
+ country_code: string;
135
+ region: {
136
+ region: string;
137
+ region_code: string;
138
+ region_id: string;
139
+ };
140
+ telephone: string;
141
+ id: string;
142
+ vat_id: string;
143
+ postcode: string;
144
+ street: string[];
145
+ default_shipping: boolean;
146
+ default_billing: boolean;
147
+ custom_attributesV2: never[];
148
+ };
149
+ payment_methods: {
150
+ name: string;
151
+ }[];
152
+ number: string;
153
+ quantityInvoiced: number;
154
+ id: string;
155
+ order_date: string;
156
+ carrier: string;
157
+ status: string;
158
+ items: ({
159
+ status: string;
160
+ quantityOrdered: number;
161
+ product_name: string;
162
+ id: string;
163
+ product: {
164
+ small_image: {
165
+ url: string;
166
+ };
167
+ };
168
+ quantityInvoiced?: undefined;
169
+ } | {
170
+ status: string;
171
+ quantityOrdered: number;
172
+ quantityInvoiced: number;
173
+ product_name: string;
174
+ id: string;
175
+ product: {
176
+ small_image: {
177
+ url: string;
178
+ };
179
+ };
180
+ })[];
181
+ total: {
182
+ grand_total: {
183
+ value: number;
184
+ currency: string;
185
+ };
186
+ subtotal: {
187
+ currency: string;
188
+ value: number;
189
+ };
190
+ taxes: never[];
191
+ total_tax: {
192
+ currency: string;
193
+ value: number;
194
+ };
195
+ total_shipping: {
196
+ currency: string;
197
+ value: number;
198
+ };
199
+ discounts: never[];
200
+ };
201
+ })[];
94
202
  };
95
203
  };
96
204
  };
@@ -1 +1,3 @@
1
- import{A as x,A as F}from"../chunks/AddressFormWrapper.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"../chunks/AddressFormWrapper2.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import"../chunks/updateCustomerAddress.js";import"../chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";export{x as AddressForm,F as default};
1
+ /*! Copyright 2024 Adobe
2
+ All Rights Reserved. */
3
+ import{A as l,A as u}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";export{l as AddressForm,u as default};
@@ -1 +1,3 @@
1
- import{jsx as i,jsxs as C,Fragment as X}from"@dropins/tools/preact-jsx-runtime.js";import{classes as M}from"@dropins/tools/lib.js";import{C as K}from"../chunks/AddressFormWrapper2.js";import*as z from"@dropins/tools/preact-compat.js";import{useCallback as I,useMemo as Y}from"@dropins/tools/preact-compat.js";import{Card as j,Button as x,Tag as W,Icon as Z,Modal as D,ProgressSpinner as ee,Header as ie}from"@dropins/tools/components.js";import{Fragment as se}from"@dropins/tools/preact.js";import{useState as v,useCallback as h,useEffect as te}from"@dropins/tools/preact-hooks.js";import{u as q,g as re}from"../chunks/updateCustomerAddress.js";import"@dropins/tools/event-bus.js";import{e as de}from"../chunks/convertCase.js";import{g as ne,r as oe}from"../chunks/removeCustomerAddress.js";import{S as le,c as ae,E as ce}from"../chunks/checkIsFunction.js";import{A as H}from"../chunks/AddressFormWrapper.js";import{useText as S}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-customer-address.js";const G=({minifiedView:t,keysSortOrder:n,addressData:e,loading:l,setAddressId:s,handleRenderModal:c,handleRenderForm:d})=>{const r={minifiedView:{},fullSizeView:{}};r.minifiedView=S({actionRemove:"Account.Addresses.minifiedView.addressCard.actionRemove",actionEdit:"Account.Addresses.minifiedView.addressCard.actionEdit",cardLabelShipping:"Account.Addresses.minifiedView.addressCard.cardLabelShipping",cardLabelBilling:"Account.Addresses.minifiedView.addressCard.cardLabelBilling"}),r.fullSizeView=S({actionRemove:"Account.Addresses.fullSizeView.addressCard.actionRemove",actionEdit:"Account.Addresses.fullSizeView.addressCard.actionEdit",cardLabelShipping:"Account.Addresses.fullSizeView.addressCard.cardLabelShipping",cardLabelBilling:"Account.Addresses.fullSizeView.addressCard.cardLabelBilling"});const p=I(()=>{s==null||s(e==null?void 0:e.id),c==null||c()},[c,e==null?void 0:e.id,s]),g=I(()=>{s==null||s(e==null?void 0:e.id),d==null||d()},[d,e==null?void 0:e.id,s]),w=Y(()=>{if(!n)return[];const{region:o,...u}=e,a={...u,...o};return n.filter(({name:m})=>a[m]).map(m=>({name:m.name,orderNumber:m.orderNumber,value:a[m.name],label:m.label}))},[e,n]);return i(j,{variant:"secondary",className:"dropin-address-card","data-testid":"addressCard",children:l?i(K,{}):C(X,{children:[C("div",{className:"dropin-address-card__action",children:[c?i(x,{variant:"tertiary",onClick:p,"data-testid":"removeButton",children:t?r.minifiedView.actionRemove:r.fullSizeView.actionRemove}):null,d?i(x,{variant:"tertiary",onClick:g,className:"dropin-address-card__action--editbutton","data-testid":"editButton",children:t?r.minifiedView.actionEdit:r.fullSizeView.actionEdit}):null]}),i("div",{className:"dropin-address-card__description",children:w.map((o,u)=>{const a=o.label?`${o.label}: ${o==null?void 0:o.value}`:o==null?void 0:o.value;return i("p",{"data-testid":`${o.name}_${u}`,children:a},u)})}),e!=null&&e.defaultShipping||e!=null&&e.defaultBilling?C("div",{className:"dropin-address-card__labels",children:[e!=null&&e.defaultShipping?i(W,{label:t?r.minifiedView.cardLabelShipping.toLocaleUpperCase():r.fullSizeView.cardLabelShipping.toLocaleUpperCase()}):null,e!=null&&e.defaultBilling?i(W,{label:t?r.minifiedView.cardLabelBilling.toLocaleUpperCase():r.fullSizeView.cardLabelBilling.toLocaleUpperCase()}):null]}):null]})})},ue=t=>z.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...t},z.createElement("g",{id:"Large"},z.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),z.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},z.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),z.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),me=({className:t,addNewAddress:n,minifiedView:e,routeAddressesPage:l})=>{const s={minifiedView:{},fullSizeView:{}};return s.minifiedView=S({viewAllAddressesButton:"Account.Addresses.minifiedView.viewAllAddressesButton"}),s.fullSizeView=S({addNewAddressButton:"Account.Addresses.fullSizeView.addNewAddressButton"}),C("button",{className:M(["dropin-actions-address",["dropin-actions-address--viewall",e],["dropin-actions-address--address",!e],t]),"data-testid":"showRouteFullAddress",onClick:l,children:[i("span",{className:"dropin-actions-address--title","data-testid":"addressActionsText",children:e&&!n?s.minifiedView.viewAllAddressesButton:s.fullSizeView.addNewAddressButton}),i(Z,{source:e&&!n?le:ue,size:"32"})]})},fe=({minifiedView:t,keysSortOrder:n,addressData:e,open:l,submitLoading:s,onRemoveAddress:c,closeModal:d})=>{const r={minifiedView:{},fullSizeView:{}};return r.minifiedView=S({title:"Account.Addresses.minifiedView.removeAddressModal.title",description:"Account.Addresses.minifiedView.removeAddressModal.description",actionCancel:"Account.Addresses.minifiedView.removeAddressModal.actionCancel",actionConfirm:"Account.Addresses.minifiedView.removeAddressModal.actionConfirm"}),r.fullSizeView=S({title:"Account.Addresses.fullSizeView.removeAddressModal.title",description:"Account.Addresses.fullSizeView.removeAddressModal.description",actionCancel:"Account.Addresses.fullSizeView.removeAddressModal.actionCancel",actionConfirm:"Account.Addresses.fullSizeView.removeAddressModal.actionConfirm"}),l?C(D,{title:i("h3",{children:t?r.minifiedView.title:r.fullSizeView.title}),className:"dropin-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:d,children:[s?i("div",{className:"dropin-address-modal__spinner","data-testid":"progressSpinner",children:i(ee,{stroke:"4",size:"large"})}):null,i("p",{children:t?r.minifiedView.description:r.fullSizeView.description}),i(G,{minifiedView:t,addressData:e,keysSortOrder:n}),C("div",{className:"dropin-address-modal__wrapper--buttons",children:[i(x,{type:"button",onClick:d,variant:"secondary",disabled:s,children:t?r.minifiedView.actionCancel:r.fullSizeView.actionCancel}),i(x,{disabled:s,onClick:c,children:t?r.minifiedView.actionConfirm:r.fullSizeView.actionConfirm})]})]}):null},pe=async(t,n)=>{if(n.length===1){const d=n[0],p=Object.values(d.region).every(w=>!!w)?{}:{region:{...d.region,regionId:0}};return!!await q({addressId:Number(d==null?void 0:d.id),defaultShipping:!1,defaultBilling:!1,...p})}const e=n.filter(d=>d.id!==t&&(d.defaultBilling||d.defaultShipping)||d.id!==t),l=n[n.length-1],s=e[0]||((l==null?void 0:l.id)!==t?l:null);return!s||!s.id?!1:!!await q({addressId:+s.id,defaultShipping:!0,defaultBilling:!0})},Ae=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],we=({minifiedView:t,routeAddressesPage:n,onSuccess:e})=>{const[l,s]=v(!1),[c,d]=v(!1),[r,p]=v(!1),[g,w]=v(!1),[o,u]=v(!1),[a,m]=v(""),[_,N]=v([]),[T,E]=v([]),A=h(async()=>{p(!0),Promise.all([re("shortRequest"),ne()]).then(b=>{const[k,f]=b;if(k){const U=k.map(({name:y,orderNumber:J,label:Q})=>({name:de(y),orderNumber:J,label:Ae.includes(y)?null:Q}));E(U)}if(f)if(t){const U=f.filter(y=>!!y.defaultShipping||!!y.defaultBilling);N(U)}else N(f)}).finally(()=>{p(!1)})},[t]);te(()=>{A()},[A]);const V=h(b=>{m(b),u(!1)},[]),B=h(()=>{d(!0)},[]),L=h(()=>{m(""),d(!1),s(!1)},[]),O=h(()=>{s(!0)},[]),$=h(async()=>{w(!0),await pe(a,_),oe(+a).then(()=>{A(),L()}).finally(()=>{w(!1)})},[_,a,L,A]),F=h(()=>{u(!1)},[]),R=h(()=>{ae(n)&&t&&!o?window.location.href=n():(u(!0),m(""))},[o,n,t]),P=h(async()=>{await A(),await(e==null?void 0:e())},[A,e]);return{keysSortOrder:T,submitLoading:g,isModalRendered:l,isFormRendered:c,loading:r,addNewAddress:o,addressesList:_,addressId:a,handleRenderForm:B,handleRenderModal:O,removeAddress:$,onCloseBtnClick:L,setEditingAddressId:V,closeNewAddressForm:F,redirectToAddressesRoute:R,handleOnSuccess:P}},ge=({className:t,withHeader:n=!0,minifiedView:e=!1,withActionsInMinifiedView:l=!1,withActionsInFullSizeView:s=!0,inputsDefaultValueSet:c,showShippingCheckBox:d=!0,showBillingCheckBox:r=!0,shippingCheckBoxValue:p=!0,billingCheckBoxValue:g=!0,routeAddressesPage:w,onSuccess:o,onError:u})=>{const a={minifiedView:{},fullSizeView:{}};a.minifiedView=S({containerTitle:"Account.Addresses.minifiedView.containerTitle",editAddressFormTitle:"Account.Addresses.minifiedView.editAddressFormTitle",viewAllAddressesButton:"Account.Addresses.minifiedView.viewAllAddressesButton"}),a.fullSizeView=S({containerTitle:"Account.Addresses.fullSizeView.containerTitle",editAddressFormTitle:"Account.Addresses.fullSizeView.editAddressFormTitle",newAddressFormTitle:"Account.Addresses.fullSizeView.newAddressFormTitle",viewAllAddressesButton:"Account.Addresses.fullSizeView.viewAllAddressesButton"});const{keysSortOrder:m,submitLoading:_,isModalRendered:N,isFormRendered:T,loading:E,addNewAddress:A,addressesList:V,addressId:B,handleRenderForm:L,handleRenderModal:O,removeAddress:$,onCloseBtnClick:F,handleOnSuccess:R,setEditingAddressId:P,closeNewAddressForm:b,redirectToAddressesRoute:k}=we({minifiedView:e,routeAddressesPage:w,onSuccess:o});return C("div",{children:[i("div",{children:n?i(ie,{title:e?a.minifiedView.containerTitle:a.fullSizeView.containerTitle,divider:!e,className:e?"dropin-addresses-header":""}):null}),C("div",{className:M(["dropin-addresses-wrapper",t]),"data-testid":"addressesIdWrapper",children:[i(fe,{minifiedView:e,addressData:V.find(f=>f.id===B),keysSortOrder:m,submitLoading:_,open:N,closeModal:F,onRemoveAddress:$}),E?i(K,{testId:"addressSkeletonLoader",withCard:!1}):i(ce,{isEmpty:!V.length,typeList:"address",minifiedView:e}),V.map(f=>i(se,{children:B===f.id&&T?i(j,{variant:"secondary",style:{marginBottom:20},children:i(H,{isOpen:B===f.id&&T,addressFormId:B,inputsDefaultValueSet:f,addressesFormTitle:e?a.minifiedView.editAddressFormTitle:a.fullSizeView.editAddressFormTitle,showShippingCheckBox:d,showBillingCheckBox:r,shippingCheckBoxValue:p,billingCheckBoxValue:g,onCloseBtnClick:F,onSuccess:R,onError:u})}):i(G,{minifiedView:e,addressData:f,keysSortOrder:m,loading:E,setAddressId:P,handleRenderModal:e&&l||!e&&s?O:void 0,handleRenderForm:e&&l||!e&&s?L:void 0},f.id)},f.id)),i("div",{className:"dropin-addresses__footer",children:A?i("div",{className:M(["dropin-addresses-form__footer__wrapper",["dropin-addresses-form__footer__wrapper-show",A]]),children:i(j,{variant:"secondary",children:i(H,{isOpen:A,addressesFormTitle:a.fullSizeView.newAddressFormTitle,inputsDefaultValueSet:c,showShippingCheckBox:!!V.length,showBillingCheckBox:!!V.length,shippingCheckBoxValue:p,billingCheckBoxValue:g,onCloseBtnClick:b,onSuccess:R,onError:u})})}):i(me,{minifiedView:e,addNewAddress:A,routeAddressesPage:k})})]})]})},ke=({className:t,withHeader:n,minifiedView:e,withActionsInMinifiedView:l,withActionsInFullSizeView:s,inputsDefaultValueSet:c,showShippingCheckBox:d,showBillingCheckBox:r,shippingCheckBoxValue:p,billingCheckBoxValue:g,routeAddressesPage:w,onSuccess:o,onError:u})=>i("div",{className:M(["dropin-addresses",t]),"data-testid":"addressesid",children:i(ge,{className:t,withHeader:n,minifiedView:e,withActionsInMinifiedView:l,withActionsInFullSizeView:s,inputsDefaultValueSet:c,billingCheckBoxValue:g,shippingCheckBoxValue:p,showBillingCheckBox:r,showShippingCheckBox:d,routeAddressesPage:w,onSuccess:o,onError:u})});export{ke as Addresses,ke as default};
1
+ /*! Copyright 2024 Adobe
2
+ All Rights Reserved. */
3
+ import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B}from"@dropins/tools/lib.js";import{a as C}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";const O=({hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,forwardFormRef:a,showSaveCheckBox:c,saveCheckBoxValue:f,selectShipping:n,selectBilling:l,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,showShippingCheckBox:W,showBillingCheckBox:b,shippingCheckBoxValue:g,billingCheckBoxValue:k,onAddressData:q,routeAddressesPage:w,onSuccess:y,onError:z})=>s("div",{className:B(["account-addresses",r]),"data-testid":"addressesid",children:s(C,{hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,onAddressData:q,forwardFormRef:a,selectShipping:n,selectBilling:l,showSaveCheckBox:c,saveCheckBoxValue:f,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,billingCheckBoxValue:k,shippingCheckBoxValue:g,showBillingCheckBox:b,showShippingCheckBox:W,routeAddressesPage:w,onSuccess:y,onError:z})});export{O as Addresses,O as default};
@@ -0,0 +1,5 @@
1
+ import { CustomerInformationProps } from '../../types';
2
+ import { Container } from '@dropins/tools/types/elsie/src/lib';
3
+
4
+ export declare const CustomerInformation: Container<CustomerInformationProps>;
5
+ //# sourceMappingURL=CustomerInformation.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './CustomerInformation';
2
+ export { CustomerInformation as default } from './CustomerInformation';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './CustomerInformation/index'
2
+ import _default from './CustomerInformation/index'
3
+ export default _default
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2024 Adobe
2
+ All Rights Reserved. */
3
+ import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ce}from"../chunks/getStoreConfig.js";import{u as Pe,g as pe,b as ee,a as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length<e.minLength?t?{...l,icon:"error",status:"error"}:{...l,icon:"pending",status:"pending"}:l},[e,r.messageLengthPassword,a==null?void 0:a.length,t]);return{isValidUniqueSymbols:n,defaultLengthMessage:P}},Ae=({handleHideChangePassword:e,handleSetInLineAlert:t,inLineAlertProps:a})=>{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Je=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Je as CustomerInformation,Je as default};
@@ -1 +1,3 @@
1
- import{jsx as i,jsxs as L,Fragment as x}from"@dropins/tools/preact-jsx-runtime.js";import{classes as g,Slot as b}from"@dropins/tools/lib.js";import{P as T,C as Y}from"../chunks/AddressFormWrapper2.js";import"@dropins/tools/preact-compat.js";import{Card as k,Icon as y,Image as M,Header as F,Picker as H}from"@dropins/tools/components.js";import{S as C,c as E,E as P}from"../chunks/checkIsFunction.js";import{useText as h}from"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";import{useState as O,useEffect as $,useMemo as B,useCallback as z}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as J}from"../chunks/getOrderHistoryList.js";import"../chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-customer-address.js";const D={size:"32",stroke:"2"},I=({minifiedView:s,orderNumber:r,orderToken:e,routeOrdersList:t,routeOrderDetails:n})=>{const u={minifiedView:{},fullSizeView:{}};return u.minifiedView=h({viewAllOrdersButton:"Account.OrdersList.minifiedView.viewAllOrdersButton"}),t?i("a",{className:g(["dropin-orders-list-action",["dropin-orders-list-action--minifiedView",s]]),"data-testid":"ordersListActionButtonMinifiedView",href:t(),children:i(k,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:L("div",{className:"dropin-orders-list-action__card-wrapper",children:[i("p",{children:u.minifiedView.viewAllOrdersButton}),i(y,{source:C,...D})]})})}):i("a",{href:E(n)?n(r,e):"#",className:"dropin-orders-list-action","data-testid":"ordersListActionButton",children:i(y,{source:C,...D})})},_=({minifiedView:s,item:r,withThumbnails:e,children:t,slots:n,...u})=>{var f,d,o,c;const a={minifiedView:{},fullSizeView:{}};return a.minifiedView=h({orderNumber:"Account.OrdersList.minifiedView.OrdersListCard.orderNumber",itemsAmount:"Account.OrdersList.minifiedView.OrdersListCard.itemsAmount"}),a.fullSizeView=h({orderNumber:"Account.OrdersList.fullSizeView.OrdersListCard.orderNumber",itemsAmount:"Account.OrdersList.fullSizeView.OrdersListCard.itemsAmount"}),L(k,{...u,className:g(["dropin-orders-list-card",["dropin-orders-list-card--full",((f=r==null?void 0:r.items)==null?void 0:f.length)>6]]),variant:"secondary",children:[i("div",{className:"dropin-orders-list-card--content",children:n!=null&&n.OrdersListCard?i(b,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):L(x,{children:[i("div",{children:r==null?void 0:r.status}),i("p",{children:r==null?void 0:r.orderDate}),L("p",{children:[s?a.minifiedView.orderNumber:a.fullSizeView.orderNumber," ",r.number]}),L("p",{children:["$",(d=r==null?void 0:r.total)==null?void 0:d.grandTotal.value]}),L("p",{children:[(o=r==null?void 0:r.items)==null?void 0:o.length," ",s?a.minifiedView.itemsAmount:a.fullSizeView.itemsAmount]})]})}),e&&((c=r==null?void 0:r.items)!=null&&c.length)?i("div",{className:"dropin-orders-list-card--images","data-testid":"ordersListCardImages",children:r.items.map((l,m)=>{var p;const A=(p=l==null?void 0:l.product)==null?void 0:p.smallImage.url,w=l==null?void 0:l.productName;return i(M,{src:A,width:65,height:65,alt:w},l.id+m)})}):null,i("div",{className:"dropin-orders-list-card--actions",children:t})]})},j=({ordersInMinifiedView:s,minifiedView:r,pageSize:e,selectedDate:t,handleSetFirstOrderDate:n})=>{const[u,a]=O([]),[f,d]=O({}),[o,c]=O(!1);return $(()=>{a([]),c(!0),J(r?s:e,t).then(l=>{!l||!l.items||(d(l.pageInfo),a(l.items),n(l.dateOfFirstOrder))}).finally(()=>{c(!1)})},[n,r,s,e,t]),{loading:o,orderHistoryListItems:u,pageInfo:f}},v=(s,r=1)=>{const e=new Date,t=new Date(e);switch(s){case"sixMonthsAgo":{t.setMonth(t.getMonth()-r);break}case"oneYearAgo":{t.setFullYear(t.getFullYear()-r);break}default:return""}return{from:t==null?void 0:t.toISOString().split("T")[0],to:`${e==null?void 0:e.toISOString().split("T")[0]} 23:59:59`}},R=s=>{const r=[],e=new Date().getFullYear();for(let t=s;t<=e-1;t++)r.push({value:`{"from":"${t}-01-01","to":"${t+1}-01-01 23:59:59"}`,text:t.toString()});return r},W=()=>{const s=h({pastSixMonths:"Account.OrdersList.fullSizeView.OrdersListSelectDate.pastSixMonths",currentYear:"Account.OrdersList.fullSizeView.OrdersListSelectDate.currentYear",viewAll:"Account.OrdersList.fullSizeView.OrdersListSelectDate.viewAll"}),[r,e]=O(),[t,n]=O(JSON.stringify(v("sixMonthsAgo",6))),u=B(()=>{const d=[{value:JSON.stringify(v("sixMonthsAgo",6)),text:s.pastSixMonths},{value:JSON.stringify(v("oneYearAgo",1)),text:s.currentYear},{value:"",text:s.viewAll}];if(r){const c=new Date(r).getFullYear();d==null||d.splice(2,0,...R(c))}return d},[s,r]),a=z(d=>{e(d)},[]),f=z(d=>{const c=d.target.value;n(c)},[]);return{selectableDateList:u,selectedDate:t,handleSelectDate:f,handleSetFirstOrderDate:a}},q=({className:s,withHeader:r=!0,minifiedView:e=!1,withThumbnails:t=!0,withFilter:n=!0,ordersInMinifiedView:u=1,pageSize:a=10,routeOrdersList:f,routeOrderDetails:d,slots:o})=>{const c={minifiedView:{},fullSizeView:{}};c.minifiedView=h({containerTitle:"Account.OrdersList.minifiedView.containerTitle"}),c.fullSizeView=h({containerTitle:"Account.OrdersList.fullSizeView.containerTitle",titleSelectOrder:"Account.OrdersList.fullSizeView.titleSelectOrder"});const{selectableDateList:l,selectedDate:m,handleSelectDate:A,handleSetFirstOrderDate:w}=W(),{loading:p,orderHistoryListItems:N}=j({minifiedView:e,pageSize:a,ordersInMinifiedView:u,selectedDate:m,handleSetFirstOrderDate:w});return L("div",{children:[r?i(F,{title:e?c.minifiedView.containerTitle:c.fullSizeView.containerTitle,divider:!e,className:e?"dropin-orders-list-header":""}):null,L("div",{className:g(["dropin-orders-list",s]),children:[!e&&n?i("div",{className:"dropin-orders-list--date-select",children:p?i(T,{"data-testid":"selectPickerLoader"}):L(x,{children:[i("span",{children:c.fullSizeView.titleSelectOrder}),i(H,{value:m,name:"orderDatePicker",options:l,handleSelect:A})]})}):null,p?i(Y,{testId:"orderSkeletonLoader",withCard:!1}):i(P,{isEmpty:!N.length,typeList:"orders",minifiedView:e}),N.map((S,V)=>i(_,{minifiedView:e,item:S,withThumbnails:t,slots:o,children:o!=null&&o.OrdersListAction?i(b,{"data-testid":`ordersListActionSlot_${V}`,name:"OrdersListAction",slot:o==null?void 0:o.OrdersListAction,context:{orderHistoryListItem:S}}):i(I,{minifiedView:e,orderNumber:S.number,orderToken:S.token,routeOrderDetails:d})},V)),e?i(I,{minifiedView:e,routeOrdersList:f}):null]})]})},ar=({className:s,withHeader:r,minifiedView:e,withThumbnails:t,withFilter:n,ordersInMinifiedView:u,pageSize:a,routeOrdersList:f,routeOrderDetails:d,slots:o})=>i("div",{className:g(["dropin-orders-list",s]),"data-testid":"ordersListId",children:i(q,{className:s,withHeader:r,minifiedView:e,withThumbnails:t,withFilter:n,ordersInMinifiedView:u,pageSize:a,routeOrdersList:f,routeOrderDetails:d,slots:o})});export{ar as OrdersList,ar as default};
1
+ /*! Copyright 2024 Adobe
2
+ All Rights Reserved. */
3
+ import{jsx as s,jsxs as u,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as j}from"@dropins/tools/lib.js";import{S as B,c as m,E as U,C as Q}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as G,Icon as F,ContentGrid as R,Image as J,Header as X,Picker as Z,Pagination as rr}from"@dropins/tools/components.js";import{useText as z}from"@dropins/tools/i18n.js";import{useState as S,useEffect as P,useMemo as tr,useCallback as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as sr}from"../chunks/getOrderHistoryList.js";import{g as er}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const V={size:"32",stroke:"2"},W=({minifiedView:a,orderNumber:c,orderToken:r,routeOrdersList:e,routeOrderDetails:L})=>{const n=a?"minifiedView":"fullSizeView",h=z({viewAllOrdersButton:`Account.${n}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${n}.OrdersList.ariaLabelLink`});return e?s("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",a]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(G,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:u("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:h.viewAllOrdersButton}),s(F,{source:B,...V})]})})}):s("a",{"aria-label":`${h.ariaLabelLink} ${c??r}`,href:m(L)?L(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(F,{source:B,...V})})},ar=()=>{const[a,c]=S(window.innerWidth<768);return P(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),a},cr=({placeholderImage:a,minifiedView:c,item:r,withThumbnails:e,children:L,slots:n,routeTracking:h,routeOrderProduct:O,routeReturnDetails:A,...b})=>{var p,$,_,k,w,I,x,f,M;const o=c?"minifiedView":"fullSizeView",g=z({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=ar(),y=m(O);return u(G,{variant:"secondary",...b,className:C(["account-orders-list-card",["account-orders-list-card--full",((p=r==null?void 0:r.items)==null?void 0:p.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(j,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):u(N,{children:[s("div",{children:r==null?void 0:r.status}),u("p",{children:[g.deliveryDateText," ",r==null?void 0:r.orderDate]}),u("p",{children:[g.orderNumber," ",r.number]}),($=r==null?void 0:r.shipments)==null?void 0:$.map(t=>{var l;return(l=t==null?void 0:t.tracking)==null?void 0:l.map(i=>{const v=h==null?void 0:h(i);return u("p",{"data-testid":i.number,children:[s("span",{children:`${g.carrier} ${i.carrier.toLocaleUpperCase()} `}),v?s("a",{href:v,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:i.number}):s("span",{className:"account-orders-list-card__content--track_number",children:i.number})]},t.id)})}),r!=null&&r.returns&&((_=r.returns)!=null&&_.length)?u("p",{"data-testid":r.number,children:[u("span",{children:[g.returnsText," "]}),(k=r==null?void 0:r.returns)==null?void 0:k.map(t=>s("span",{"data-testid":t.number,children:u("a",{href:(A==null?void 0:A({orderNumber:r.number,orderToken:r.token,returnNumber:t.number}))??"#",className:"account-orders-list-card__content--return_number",children:[t.number," "]})},t.uid))]},r.id):null,u("p",{children:["$",(w=r==null?void 0:r.total)==null?void 0:w.grandTotal.value]}),u("p",{"data-testid":"itemsAmount",children:[(I=r==null?void 0:r.items)!=null&&I.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((t,l)=>{const i=(l==null?void 0:l.quantityOrdered)||0;return t+i},0):0," ",g.itemsAmount]}),(f=r==null?void 0:r.items)==null?void 0:f.map((t,l)=>{if(l>=0&&l<10)return u("p",{className:"account-orders-list-card__content--product-name",children:[u("span",{className:"account-orders-list-card__content--quantity",children:[(t==null?void 0:t.quantityOrdered)>1?t==null?void 0:t.quantityOrdered:null," "]}),t==null?void 0:t.productName.replaceAll("-"," ")]},`${l}_${t.id}`);if(l===11)return s("p",{children:"..."},"ellipsis")})]})}),e&&((M=r==null?void 0:r.items)!=null&&M.length)?s(R,{maxColumns:d?3:9,emptyGridContent:s(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:r.items.map((t,l)=>{var Y,D,E,H,q;const i=(E=(D=(Y=t==null?void 0:t.product)==null?void 0:Y.smallImage)==null?void 0:D.url)!=null&&E.length?(q=(H=t==null?void 0:t.product)==null?void 0:H.smallImage)==null?void 0:q.url:a,v=(t==null?void 0:t.productName)??"";return y?s("a",{href:(O==null?void 0:O(t))??"",target:"_blank",rel:"noreferrer",children:s(J,{src:i,width:65,height:65,alt:v})},t.id+l):s(J,{src:i,width:65,height:65,alt:v},t.id+l)})}):null,s("div",{className:"account-orders-list-card__actions",children:L})]})},nr=({ordersInMinifiedView:a,minifiedView:c,pageSize:r,selectedDate:e,selectedPage:L,handleSetFirstOrderDate:n})=>{const[h,O]=S([]),[A,b]=S({totalPages:1,currentPage:1,pageSize:1}),[o,g]=S(!1),[d,y]=S("");return P(()=>{er().then(p=>{y(p.baseMediaUrl)})},[]),P(()=>{g(!0),sr(c?a:r,e,L).then(p=>{!p||!p.items||(b(p.pageInfo),O(p.items),n==null||n(p.dateOfFirstOrder))}).finally(()=>{g(!1)})},[n,c,a,r,e,L]),{loading:o,orderHistoryListItems:h,pageInfo:A,placeholderImage:d}},T=(a,c=1)=>{const r=new Date,e=new Date(r);switch(a){case"sixMonthsAgo":{e.setMonth(e.getMonth()-c);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-c);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},or=a=>{const c=[],r=new Date().getFullYear();for(let e=a;e<=r-1;e++)c.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return c},dr=()=>{const a=z({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=S(),[e,L]=S(JSON.stringify(T("sixMonthsAgo",6))),[n,h]=S(1);P(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[n]);const O=tr(()=>{const o=[{value:JSON.stringify(T("sixMonthsAgo",6)),text:a.pastSixMonths},{value:JSON.stringify(T("oneYearAgo",1)),text:a.currentYear},{value:"viewAll",text:a.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...or(d))}return o},[a,c]),A=K(o=>{r(o)},[]),b=K(o=>{const d=o.target.value;L(d),h(1)},[]);return{selectableDateList:O,selectedDate:e,selectedPage:n,handleSelectDate:b,setSelectedPage:h,handleSetFirstOrderDate:A}},ir=({className:a,withHeader:c=!0,minifiedView:r=!1,withThumbnails:e=!0,withFilter:L=!0,ordersInMinifiedView:n=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>{const y=r?"minifiedView":"fullSizeView",p=z({containerTitle:`Account.${y}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${y}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:I,handleSetFirstOrderDate:x}=dr(),{pageInfo:f,loading:M,orderHistoryListItems:t,placeholderImage:l}=nr({minifiedView:r,pageSize:h,ordersInMinifiedView:n,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:x});return u("div",{children:[c?s(X,{"aria-label":p.containerTitle,role:"region",title:p.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,u("div",{className:C(["account-orders-list",a]),children:[!r&&L?u("div",{className:"account-orders-list__date-select",children:[s("span",{children:p.dateOrderPlaced}),s(Z,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,M?s(N,{children:Array.from(Array(f==null?void 0:f.pageSize).keys()).map(i=>s(Q,{testId:"orderSkeletonLoader",withCard:!1},i))}):s(N,{children:t.length?s(N,{children:t.map((i,v)=>s(cr,{placeholderImage:l,routeTracking:o,routeOrderProduct:g,routeReturnDetails:b,minifiedView:r,item:i,withThumbnails:e,slots:d,children:d!=null&&d.OrdersListAction?s(j,{"data-testid":`ordersListActionSlot_${v}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:i}}):s(W,{minifiedView:r,orderNumber:i.number,orderToken:i.token,routeOrderDetails:A})},v))}):s(U,{isEmpty:!t.length,typeList:"orders",minifiedView:r})}),!r&&(f==null?void 0:f.totalPages)>1?s(rr,{totalPages:f==null?void 0:f.totalPages,currentPage:w,onChange:I}):null,r?s(W,{minifiedView:r,routeOrdersList:O}):null]})]})},_r=({className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>s("div",{className:C(["account-orders-list",a]),"data-testid":"ordersListId",children:s(ir,{className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})});export{_r as OrdersList,_r as default};
@@ -1,4 +1,5 @@
1
1
  export * from './AddressForm';
2
2
  export * from './Addresses';
3
3
  export * from './OrdersList';
4
+ export * from './CustomerInformation';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export interface CustomerAddressesModel {
2
- firstname?: string;
3
- lastname?: string;
2
+ firstName?: string;
3
+ lastName?: string;
4
4
  city?: string;
5
5
  company?: string;
6
6
  countryCode?: string;
@@ -14,7 +14,7 @@ export interface CustomerAddressesModel {
14
14
  vatId?: string;
15
15
  postcode?: string;
16
16
  street?: string;
17
- street_2?: string;
17
+ streetMultiline_2?: string;
18
18
  defaultShipping?: boolean;
19
19
  defaultBilling?: boolean;
20
20
  }