@dropins/storefront-company-management 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.
- package/LICENSE.md +128 -0
- package/api/checkIsCompanyEnabled/checkIsCompanyEnabled.d.ts +4 -0
- package/api/checkIsCompanyEnabled/index.d.ts +18 -0
- package/api/fetch-graphql/fetch-graphql.d.ts +24 -0
- package/api/fetch-graphql/index.d.ts +18 -0
- package/api/getCompany/getCompany.d.ts +5 -0
- package/api/getCompany/graphql/getCustomerRole.graphql.d.ts +18 -0
- package/api/getCompany/index.d.ts +18 -0
- package/api/getCountries/getCountries.d.ts +9 -0
- package/api/getCountries/graphql/getCountries.graphql.d.ts +18 -0
- package/api/getCountries/index.d.ts +18 -0
- package/api/graphql/CompanyFragment.graphql.d.ts +22 -0
- package/api/index.d.ts +24 -0
- package/api/initialize/index.d.ts +18 -0
- package/api/initialize/initialize.d.ts +25 -0
- package/api/updateCompany/graphql/updateCompany.graphql.d.ts +2 -0
- package/api/updateCompany/index.d.ts +18 -0
- package/api/updateCompany/updateCompany.d.ts +5 -0
- package/api/validateCompanyEmail/graphql/validateCompanyEmail.graphql.d.ts +18 -0
- package/api/validateCompanyEmail/index.d.ts +18 -0
- package/api/validateCompanyEmail/validateCompanyEmail.d.ts +4 -0
- package/api.d.ts +1 -0
- package/api.js +4 -0
- package/api.js.map +1 -0
- package/chunks/getCountries.js +135 -0
- package/chunks/getCountries.js.map +1 -0
- package/components/CompanyLoaders/CompanyLoaders.d.ts +6 -0
- package/components/CompanyLoaders/index.d.ts +18 -0
- package/components/CompanyProfileCard/CompanyProfileCard.d.ts +5 -0
- package/components/CompanyProfileCard/index.d.ts +19 -0
- package/components/EditCompanyProfile/CompanyAccountFields.d.ts +23 -0
- package/components/EditCompanyProfile/EditCompanyProfile.d.ts +5 -0
- package/components/EditCompanyProfile/LegalAddressFields.d.ts +50 -0
- package/components/EditCompanyProfile/index.d.ts +19 -0
- package/components/index.d.ts +20 -0
- package/containers/CompanyProfile/CompanyProfile.d.ts +5 -0
- package/containers/CompanyProfile/index.d.ts +19 -0
- package/containers/CompanyProfile.d.ts +3 -0
- package/containers/CompanyProfile.js +4 -0
- package/containers/CompanyProfile.js.map +1 -0
- package/containers/index.d.ts +18 -0
- package/data/models/company-address.d.ts +29 -0
- package/data/models/company.d.ts +65 -0
- package/data/models/country.d.ts +26 -0
- package/data/models/index.d.ts +20 -0
- package/data/transforms/index.d.ts +19 -0
- package/data/transforms/transform-company.d.ts +6 -0
- package/data/transforms/transform-countries.d.ts +10 -0
- package/hooks/containers/index.d.ts +18 -0
- package/hooks/containers/useCompanyProfile.d.ts +25 -0
- package/hooks/index.d.ts +19 -0
- package/hooks/useCountries.d.ts +15 -0
- package/hooks/useInLineAlert.d.ts +20 -0
- package/i18n/en_US.json.d.ts +96 -0
- package/lib/acdl.d.ts +43 -0
- package/lib/convertCase.d.ts +20 -0
- package/lib/convertToBoolean.d.ts +18 -0
- package/lib/convertToInputDateFormat.d.ts +18 -0
- package/lib/cookies.d.ts +18 -0
- package/lib/fetch-error.d.ts +21 -0
- package/lib/index.d.ts +25 -0
- package/lib/network-error.d.ts +6 -0
- package/lib/validationFields.d.ts +33 -0
- package/package.json +1 -0
- package/render/Provider.d.ts +8 -0
- package/render/index.d.ts +18 -0
- package/render/render.d.ts +4 -0
- package/render.d.ts +1 -0
- package/render.js +5 -0
- package/render.js.map +1 -0
- package/types/api/checkIsCompanyEnabled.types.d.ts +21 -0
- package/types/api/getCompany.types.d.ts +83 -0
- package/types/api/getCountries.types.d.ts +37 -0
- package/types/api/updateCompany.types.d.ts +73 -0
- package/types/api/validateCompanyEmail.types.d.ts +26 -0
- package/types/index.d.ts +23 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as T}from"@dropins/tools/event-bus.js";import{FetchGraphQL as I}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:U,setFetchGraphQlHeader:q,removeFetchGraphQlHeader:x,setFetchGraphQlHeaders:$,fetchGraphQl:p,getConfig:j}=new I().getMethods(),w=`
|
|
4
|
+
query validateCompanyEmail($email: String!) {
|
|
5
|
+
isCompanyEmailAvailable(email: $email) {
|
|
6
|
+
is_email_available
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`,Q=async e=>{try{const a=await p(w,{variables:{email:e}});return a.errors?{isValid:!1,error:"Unable to validate email"}:{isValid:a.data.isCompanyEmailAvailable.is_email_available,error:a.data.isCompanyEmailAvailable.is_email_available?void 0:"This email is already used by another company"}}catch{return{isValid:!1,error:"Unable to validate email"}}},E=e=>{var A;if(!(e!=null&&e.data))throw new Error("Invalid response: missing data");const a="updateCompany"in e.data?(A=e.data.updateCompany)==null?void 0:A.company:e.data.company;if(!a)throw new Error("Invalid response: missing company data");const n="customer"in e.data?e.data.customer:void 0,o=a.legal_address?{street:Array.isArray(a.legal_address.street)?a.legal_address.street.filter(r=>r&&r.trim()!==""):[],city:(a.legal_address.city||"").trim(),region:a.legal_address.region?{region:(a.legal_address.region.region||"").trim(),regionCode:(a.legal_address.region.region_code||"").trim(),regionId:a.legal_address.region.region_id?Number(a.legal_address.region.region_id):0}:void 0,countryCode:(a.legal_address.country_code||"").toUpperCase().trim(),postcode:(a.legal_address.postcode||"").trim(),telephone:a.legal_address.telephone?a.legal_address.telephone.trim():void 0}:void 0,t=n==null?void 0:n.role,s=((r=[])=>{const m=new Set,g=[...r];for(;g.length;){const c=g.pop();if(c&&(typeof c.id=="string"&&m.add(c.id),Array.isArray(c.children)&&c.children.length))for(const h of c.children)g.push(h)}return m})((t==null?void 0:t.permissions)||[]),l=(t==null?void 0:t.id)==="0"||typeof(t==null?void 0:t.id)=="number"&&t.id===0||(t==null?void 0:t.name)==="Company Administrator",i={canViewAccount:l||s.has("Magento_Company::view_account"),canEditAccount:l||s.has("Magento_Company::edit_account"),canViewAddress:l||s.has("Magento_Company::view_address"),canEditAddress:l||s.has("Magento_Company::edit_address"),canViewContacts:l||s.has("Magento_Company::contacts"),canViewPaymentInformation:l||s.has("Magento_Company::payment_information"),canViewShippingInformation:l||s.has("Magento_Company::shipping_information")},d={id:(a.id||"").toString(),name:(a.name||"").trim(),email:(a.email||"").trim().toLowerCase(),legalName:a.legal_name?a.legal_name.trim():void 0,vatTaxId:a.vat_tax_id?a.vat_tax_id.trim():void 0,resellerId:a.reseller_id?a.reseller_id.trim():void 0,legalAddress:o,companyAdmin:a.company_admin?{id:(a.company_admin.id||"").toString(),firstname:(a.company_admin.firstname||"").trim(),lastname:(a.company_admin.lastname||"").trim(),email:(a.company_admin.email||"").trim().toLowerCase(),jobTitle:a.company_admin.job_title?a.company_admin.job_title.trim():void 0}:void 0,salesRepresentative:a.sales_representative?{firstname:(a.sales_representative.firstname||"").trim(),lastname:(a.sales_representative.lastname||"").trim(),email:(a.sales_representative.email||"").trim().toLowerCase()}:void 0,availablePaymentMethods:Array.isArray(a.available_payment_methods)?a.available_payment_methods.filter(r=>r&&typeof r.code=="string"&&typeof r.title=="string").map(r=>({code:r.code.trim(),title:r.title.trim()})).filter(r=>r.code.length>0&&r.title.length>0):void 0,availableShippingMethods:Array.isArray(a.available_shipping_methods)?a.available_shipping_methods.filter(r=>r&&typeof r.code=="string"&&typeof r.title=="string").map(r=>({code:r.code.trim(),title:r.title.trim()})).filter(r=>r.code.length>0&&r.title.length>0):void 0,canEditAccount:i.canEditAccount,canEditAddress:i.canEditAddress,permissionsFlags:i,customerRole:t,customerStatus:n==null?void 0:n.status};if(i.canViewAccount){if(!d.id)throw new Error("Company ID is required");if(!d.name)throw new Error("Company name is required");if(!d.email)throw new Error("Company email is required")}return d},O=e=>{var s,l;if(!((l=(s=e==null?void 0:e.data)==null?void 0:s.countries)!=null&&l.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:a,storeConfig:n}=e.data,o=n==null?void 0:n.countries_with_required_region.split(","),t=n==null?void 0:n.optional_zip_countries.split(",");return{availableCountries:a.filter(({two_letter_abbreviation:i,full_name_locale:d})=>!!(i&&d)).map(i=>{const{two_letter_abbreviation:d,full_name_locale:A,available_regions:r}=i,m=Array.isArray(r)&&r.length>0;return{value:d,text:A,availableRegions:m?r:void 0}}).sort((i,d)=>i.text.localeCompare(d.text)),countriesWithRequiredRegion:o,optionalZipCountries:t}},P=`
|
|
10
|
+
query GET_CUSTOMER_ROLE_PERMISSIONS {
|
|
11
|
+
customer {
|
|
12
|
+
role {
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
permissions {
|
|
16
|
+
id
|
|
17
|
+
children {
|
|
18
|
+
id
|
|
19
|
+
children {
|
|
20
|
+
id
|
|
21
|
+
children {
|
|
22
|
+
id
|
|
23
|
+
children { id }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
status
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`,u=`
|
|
33
|
+
fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {
|
|
34
|
+
street
|
|
35
|
+
city
|
|
36
|
+
region {
|
|
37
|
+
region
|
|
38
|
+
region_code
|
|
39
|
+
region_id
|
|
40
|
+
}
|
|
41
|
+
country_code
|
|
42
|
+
postcode
|
|
43
|
+
telephone
|
|
44
|
+
}
|
|
45
|
+
`,v=`
|
|
46
|
+
fragment COMPANY_BASIC_INFO_FRAGMENT on Company {
|
|
47
|
+
id
|
|
48
|
+
name
|
|
49
|
+
email
|
|
50
|
+
legal_name
|
|
51
|
+
vat_tax_id
|
|
52
|
+
reseller_id
|
|
53
|
+
}
|
|
54
|
+
`,M=`
|
|
55
|
+
fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {
|
|
56
|
+
firstname
|
|
57
|
+
lastname
|
|
58
|
+
email
|
|
59
|
+
}
|
|
60
|
+
`,N=`
|
|
61
|
+
fragment COMPANY_ADMIN_FRAGMENT on Customer {
|
|
62
|
+
id
|
|
63
|
+
firstname
|
|
64
|
+
lastname
|
|
65
|
+
email
|
|
66
|
+
job_title
|
|
67
|
+
}
|
|
68
|
+
`,G=`
|
|
69
|
+
fragment COMPANY_FULL_FRAGMENT on Company {
|
|
70
|
+
...COMPANY_BASIC_INFO_FRAGMENT
|
|
71
|
+
legal_address {
|
|
72
|
+
...COMPANY_LEGAL_ADDRESS_FRAGMENT
|
|
73
|
+
}
|
|
74
|
+
company_admin {
|
|
75
|
+
...COMPANY_ADMIN_FRAGMENT
|
|
76
|
+
}
|
|
77
|
+
sales_representative {
|
|
78
|
+
...COMPANY_SALES_REPRESENTATIVE_FRAGMENT
|
|
79
|
+
}
|
|
80
|
+
available_payment_methods {
|
|
81
|
+
code
|
|
82
|
+
title
|
|
83
|
+
}
|
|
84
|
+
available_shipping_methods {
|
|
85
|
+
code
|
|
86
|
+
title
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
${v}
|
|
90
|
+
${u}
|
|
91
|
+
${N}
|
|
92
|
+
${M}
|
|
93
|
+
`,R=(e=[])=>{const a=new Set,n=[...e];for(;n.length;){const o=n.pop();if(o&&(typeof o.id=="string"&&a.add(o.id),Array.isArray(o.children)&&o.children.length))for(const t of o.children)n.push(t)}return a},F=e=>{const a=e.has("Magento_Company::view_account"),n=e.has("Magento_Company::view_address"),o=e.has("Magento_Company::contacts"),t=e.has("Magento_Company::payment_information"),_=e.has("Magento_Company::shipping_information"),s=[...a?["...COMPANY_BASIC_INFO_FRAGMENT"]:[]];if(n&&s.push("legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }"),o&&(s.push("company_admin { ...COMPANY_ADMIN_FRAGMENT }"),s.push("sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }")),t&&s.push("available_payment_methods { code title }"),_&&s.push("available_shipping_methods { code title }"),s.length===0)return`
|
|
94
|
+
query GET_COMPANY_DYNAMIC {
|
|
95
|
+
company { __typename }
|
|
96
|
+
}
|
|
97
|
+
`;const l=`
|
|
98
|
+
query GET_COMPANY_DYNAMIC {
|
|
99
|
+
company {
|
|
100
|
+
${s.join(`
|
|
101
|
+
`)}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`,i=a?[v]:[];return s.some(d=>d.startsWith("legal_address"))&&i.push(u),s.some(d=>d.startsWith("company_admin"))&&i.push(N),s.some(d=>d.startsWith("sales_representative"))&&i.push(M),`${l}
|
|
105
|
+
${i.join(`
|
|
106
|
+
`)}`};let y=null,f=null;const k=()=>{f=null},B=async(e=!0)=>e&&f?f:y||(y=(async()=>{var a,n,o,t,_,s;try{const l=await p(P,{method:"GET",cache:"no-cache"});if((a=l.errors)!=null&&a.length)return null;const i=(o=(n=l==null?void 0:l.data)==null?void 0:n.customer)==null?void 0:o.role,d=R((i==null?void 0:i.permissions)||[]);((i==null?void 0:i.id)==="0"||typeof(i==null?void 0:i.id)=="number"&&(i==null?void 0:i.id)===0||(i==null?void 0:i.name)==="Company Administrator")&&["Magento_Company::view_account","Magento_Company::view_address","Magento_Company::contacts","Magento_Company::payment_information","Magento_Company::shipping_information"].forEach(C=>d.add(C));const r=F(d),m=await p(r,{method:"GET",cache:"no-cache"});if((t=m.errors)!=null&&t.length)return null;const g=(_=m==null?void 0:m.data)==null?void 0:_.company;if(!(g&&Object.keys(g).some(C=>C!=="__typename")))return null;m.data.customer=(s=l==null?void 0:l.data)==null?void 0:s.customer;const h=E(m);return f=h,h}catch{return null}finally{y=null}})(),y),S=e=>{throw e instanceof DOMException&&e.name==="AbortError"||T.emit("error",{source:"company",type:"network",error:e}),e},b=e=>{const a=e.map(n=>n.message).join(" ");throw Error(a)},Y=`
|
|
107
|
+
mutation UPDATE_COMPANY($input: CompanyUpdateInput!) {
|
|
108
|
+
updateCompany(input: $input) {
|
|
109
|
+
company {
|
|
110
|
+
...COMPANY_FULL_FRAGMENT
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
${G}
|
|
115
|
+
`,W=async e=>{const a={};if(e.name!==void 0&&(a.company_name=e.name),e.email!==void 0&&(a.company_email=e.email),e.legalName!==void 0&&(a.legal_name=e.legalName),e.vatTaxId!==void 0&&(a.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(a.reseller_id=e.resellerId),e.legalAddress!==void 0){let n;Array.isArray(e.legalAddress.street)?(n=[...e.legalAddress.street],e.legalAddress.street2&&n.push(e.legalAddress.street2)):n=[e.legalAddress.street,e.legalAddress.street2].filter(t=>typeof t=="string"&&t.trim().length>0),n=n.filter(t=>t&&typeof t=="string"&&t.trim().length>0);let o;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const t=e.legalAddress.region;t.region===t.regionCode?o={region:t.region,region_code:t.regionCode,region_id:0}:o={region:t.region,region_code:t.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?o={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(o={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});a.legal_address={street:n,city:e.legalAddress.city,region:o,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}return await p(Y,{method:"POST",variables:{input:a}}).then(n=>{var o;return(o=n.errors)!=null&&o.length?b(n.errors):E(n)}).catch(S)},L=`
|
|
116
|
+
query getCountries {
|
|
117
|
+
countries {
|
|
118
|
+
id
|
|
119
|
+
two_letter_abbreviation
|
|
120
|
+
three_letter_abbreviation
|
|
121
|
+
full_name_locale
|
|
122
|
+
full_name_english
|
|
123
|
+
available_regions {
|
|
124
|
+
id
|
|
125
|
+
code
|
|
126
|
+
name
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
storeConfig {
|
|
130
|
+
countries_with_required_region
|
|
131
|
+
optional_zip_countries
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`,H=async()=>{const e="_company_countries",a=sessionStorage.getItem(e);return a?JSON.parse(a):await p(L,{method:"GET"}).then(n=>{var t;if((t=n.errors)!=null&&t.length)return b(n.errors);const o=O(n);return sessionStorage.setItem(e,JSON.stringify(o)),o}).catch(S)};export{B as a,q as b,x as c,$ as d,j as e,p as f,H as g,k as r,U as s,W as u,Q as v};
|
|
135
|
+
//# sourceMappingURL=getCountries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCountries.js","sources":["/@dropins/storefront-company-management/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-company-management/src/api/validateCompanyEmail/graphql/validateCompanyEmail.graphql.ts","/@dropins/storefront-company-management/src/api/validateCompanyEmail/validateCompanyEmail.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company.ts","/@dropins/storefront-company-management/src/data/transforms/transform-countries.ts","/@dropins/storefront-company-management/src/api/getCompany/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/api/graphql/CompanyFragment.graphql.ts","/@dropins/storefront-company-management/src/api/getCompany/getCompany.ts","/@dropins/storefront-company-management/src/lib/network-error.ts","/@dropins/storefront-company-management/src/lib/fetch-error.ts","/@dropins/storefront-company-management/src/api/updateCompany/graphql/updateCompany.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompany/updateCompany.ts","/@dropins/storefront-company-management/src/api/getCountries/graphql/getCountries.graphql.ts","/@dropins/storefront-company-management/src/api/getCountries/getCountries.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const VALIDATE_COMPANY_EMAIL_QUERY = /* GraphQL */ `\n query validateCompanyEmail($email: String!) {\n isCompanyEmailAvailable(email: $email) {\n is_email_available\n }\n }\n`;","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { VALIDATE_COMPANY_EMAIL_QUERY } from './graphql/validateCompanyEmail.graphql';\nimport { ValidateCompanyEmailQuery, ValidateCompanyEmailResponse } from '../../types/api/validateCompanyEmail.types';\n\nexport const validateCompanyEmail = async (email: string): Promise<ValidateCompanyEmailResponse> => {\n try {\n const response = await fetchGraphQl<ValidateCompanyEmailQuery>(VALIDATE_COMPANY_EMAIL_QUERY, {\n variables: { email },\n });\n\n if (response.errors) {\n return {\n isValid: false,\n error: 'Unable to validate email'\n };\n }\n\n return {\n isValid: response.data.isCompanyEmailAvailable.is_email_available,\n error: response.data.isCompanyEmailAvailable.is_email_available \n ? undefined \n : 'This email is already used by another company'\n };\n } catch (error) {\n return {\n isValid: false,\n error: 'Unable to validate email'\n };\n }\n};","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { updateCompanyResponse } from '../../types/api/updateCompany.types';\nimport { CompanyModel } from '../models/company';\n\nexport const transformCompany = (\n response: getCompanyResponse | updateCompanyResponse\n): CompanyModel => {\n // Validate response structure\n if (!response?.data) {\n throw new Error('Invalid response: missing data');\n }\n\n // Handle both getCompany and updateCompany response structures\n const companyData: any = 'updateCompany' in response.data \n ? response.data.updateCompany?.company \n : response.data.company;\n \n if (!companyData) {\n throw new Error('Invalid response: missing company data');\n }\n \n const customerData = 'customer' in response.data ? response.data.customer : undefined;\n\n // Transform legal address with validation\n const legalAddress = companyData.legal_address ? {\n street: Array.isArray(companyData.legal_address.street) \n ? companyData.legal_address.street.filter((line: string) => line && line.trim() !== '') \n : [],\n city: (companyData.legal_address.city || '').trim(),\n region: companyData.legal_address.region ? {\n region: (companyData.legal_address.region.region || '').trim(),\n regionCode: (companyData.legal_address.region.region_code || '').trim(),\n regionId: companyData.legal_address.region.region_id ? Number(companyData.legal_address.region.region_id) : 0,\n } : undefined,\n countryCode: (companyData.legal_address.country_code || '').toUpperCase().trim(),\n postcode: (companyData.legal_address.postcode || '').trim(),\n telephone: companyData.legal_address.telephone ? \n companyData.legal_address.telephone.trim() : undefined,\n } : undefined;\n\n // Determine permissions\n const customerRole = customerData?.role;\n const flattenPermissionIds = (nodes: any[] = []): Set<string> => {\n const set = new Set<string>();\n const stack = [...nodes];\n while (stack.length) {\n const node = stack.pop();\n if (!node) continue;\n if (typeof node.id === 'string') set.add(node.id);\n if (Array.isArray(node.children) && node.children.length) {\n for (const child of node.children) stack.push(child);\n }\n }\n return set;\n };\n\n const allowedIds = flattenPermissionIds(customerRole?.permissions || []);\n const isAdmin = customerRole?.id === '0' ||\n (typeof customerRole?.id === 'number' && customerRole.id === 0) ||\n customerRole?.name === 'Company Administrator';\n\n const permissionsFlags = {\n canViewAccount: isAdmin || allowedIds.has('Magento_Company::view_account'),\n canEditAccount: isAdmin || allowedIds.has('Magento_Company::edit_account'),\n canViewAddress: isAdmin || allowedIds.has('Magento_Company::view_address'),\n canEditAddress: isAdmin || allowedIds.has('Magento_Company::edit_address'),\n canViewContacts: isAdmin || allowedIds.has('Magento_Company::contacts'),\n canViewPaymentInformation: isAdmin || allowedIds.has('Magento_Company::payment_information'),\n canViewShippingInformation: isAdmin || allowedIds.has('Magento_Company::shipping_information'),\n } as const;\n\n // Build the model with proper validation\n const model: CompanyModel = {\n id: (companyData.id || '').toString(),\n name: (companyData.name || '').trim(),\n email: (companyData.email || '').trim().toLowerCase(),\n legalName: companyData.legal_name ? companyData.legal_name.trim() : undefined,\n vatTaxId: companyData.vat_tax_id ? companyData.vat_tax_id.trim() : undefined,\n resellerId: companyData.reseller_id ? companyData.reseller_id.trim() : undefined,\n legalAddress,\n companyAdmin: companyData.company_admin ? {\n id: (companyData.company_admin.id || '').toString(),\n firstname: (companyData.company_admin.firstname || '').trim(),\n lastname: (companyData.company_admin.lastname || '').trim(),\n email: (companyData.company_admin.email || '').trim().toLowerCase(),\n jobTitle: companyData.company_admin.job_title ? companyData.company_admin.job_title.trim() : undefined,\n } : undefined,\n\n // Transform sales representative\n salesRepresentative: companyData.sales_representative ? {\n firstname: (companyData.sales_representative.firstname || '').trim(),\n lastname: (companyData.sales_representative.lastname || '').trim(),\n email: (companyData.sales_representative.email || '').trim().toLowerCase(),\n } : undefined,\n\n // New comprehensive payment methods with code and title\n availablePaymentMethods: Array.isArray(companyData.available_payment_methods)\n ? companyData.available_payment_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n\n // New available shipping methods\n availableShippingMethods: Array.isArray(companyData.available_shipping_methods)\n ? companyData.available_shipping_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n \n // Computed permission flags (single source of truth)\n canEditAccount: permissionsFlags.canEditAccount,\n canEditAddress: permissionsFlags.canEditAddress,\n permissionsFlags,\n customerRole,\n customerStatus: customerData?.status,\n };\n\n // Validate only when profile fields are permitted\n if (permissionsFlags.canViewAccount) {\n if (!model.id) {\n throw new Error('Company ID is required');\n }\n if (!model.name) {\n throw new Error('Company name is required');\n }\n if (!model.email) {\n throw new Error('Company email is required');\n }\n }\n\n return model;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../models/country';\n\nexport const transformCountries = (\n response: CountriesFormResponse\n): {\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n} => {\n if (!response?.data?.countries?.length) {\n return {\n availableCountries: [],\n countriesWithRequiredRegion: [],\n optionalZipCountries: [],\n };\n }\n\n const { countries, storeConfig } = response.data;\n\n const countriesWithRequiredRegion =\n storeConfig?.countries_with_required_region.split(',');\n const optionalZipCountries = storeConfig?.optional_zip_countries.split(',');\n\n const availableCountries = countries\n .filter(({ two_letter_abbreviation, full_name_locale }) =>\n Boolean(two_letter_abbreviation && full_name_locale)\n )\n .map((country) => {\n const { two_letter_abbreviation, full_name_locale, available_regions } = country;\n\n const hasRegions = Array.isArray(available_regions) && available_regions.length > 0;\n return {\n value: two_letter_abbreviation,\n text: full_name_locale,\n availableRegions: hasRegions ? available_regions : undefined,\n };\n })\n .sort((a, b) => a.text.localeCompare(b.text));\n\n return {\n availableCountries,\n countriesWithRequiredRegion,\n optionalZipCountries,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const GET_CUSTOMER_ROLE_PERMISSIONS = /* GraphQL */ `\n query GET_CUSTOMER_ROLE_PERMISSIONS {\n customer {\n role {\n id\n name\n permissions {\n id\n children {\n id\n children {\n id\n children {\n id\n children { id }\n }\n }\n }\n }\n }\n status\n }\n }\n`;\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const COMPANY_LEGAL_ADDRESS_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {\n street\n city\n region {\n region\n region_code\n region_id\n }\n country_code\n postcode\n telephone\n }\n`;\n\nexport const COMPANY_BASIC_INFO_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_BASIC_INFO_FRAGMENT on Company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n }\n`;\n\nexport const COMPANY_SALES_REPRESENTATIVE_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {\n firstname\n lastname\n email\n }\n`;\n\nexport const COMPANY_ADMIN_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_ADMIN_FRAGMENT on Customer {\n id\n firstname\n lastname\n email\n job_title\n }\n`;\n\nexport const COMPANY_FULL_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_FULL_FRAGMENT on Company {\n ...COMPANY_BASIC_INFO_FRAGMENT\n legal_address {\n ...COMPANY_LEGAL_ADDRESS_FRAGMENT\n }\n company_admin {\n ...COMPANY_ADMIN_FRAGMENT\n }\n sales_representative {\n ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT\n }\n available_payment_methods {\n code\n title\n }\n available_shipping_methods {\n code\n title\n }\n }\n ${COMPANY_BASIC_INFO_FRAGMENT}\n ${COMPANY_LEGAL_ADDRESS_FRAGMENT}\n ${COMPANY_ADMIN_FRAGMENT}\n ${COMPANY_SALES_REPRESENTATIVE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { GET_CUSTOMER_ROLE_PERMISSIONS } from './graphql/getCustomerRole.graphql';\nimport {\n COMPANY_BASIC_INFO_FRAGMENT,\n COMPANY_LEGAL_ADDRESS_FRAGMENT,\n COMPANY_ADMIN_FRAGMENT,\n COMPANY_SALES_REPRESENTATIVE_FRAGMENT,\n} from '../graphql/CompanyFragment.graphql';\n\nconst flattenIds = (nodes: any[] = []): Set<string> => {\n const set = new Set<string>();\n const stack = [...nodes];\n while (stack.length) {\n const node = stack.pop();\n if (!node) continue;\n if (typeof node.id === 'string') set.add(node.id);\n if (Array.isArray(node.children) && node.children.length) {\n for (const child of node.children) stack.push(child);\n }\n }\n return set;\n};\n\nconst buildCompanyQuery = (allowed: Set<string>): string => {\n const wantProfile = allowed.has('Magento_Company::view_account');\n const wantAddress = allowed.has('Magento_Company::view_address');\n const wantContacts = allowed.has('Magento_Company::contacts');\n const wantPayment = allowed.has('Magento_Company::payment_information');\n const wantShipping = allowed.has('Magento_Company::shipping_information');\n\n const fields: string[] = [\n ...(wantProfile ? ['...COMPANY_BASIC_INFO_FRAGMENT'] : []),\n ];\n\n if (wantAddress) {\n fields.push(`legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }`);\n }\n if (wantContacts) {\n fields.push(`company_admin { ...COMPANY_ADMIN_FRAGMENT }`);\n fields.push(`sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }`);\n }\n if (wantPayment) {\n fields.push(`available_payment_methods { code title }`);\n }\n if (wantShipping) {\n fields.push(`available_shipping_methods { code title }`);\n }\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n query GET_COMPANY_DYNAMIC {\n company { __typename }\n }\n `;\n }\n\n const query = `\n query GET_COMPANY_DYNAMIC {\n company {\n ${fields.join('\\n ')}\n }\n }\n `;\n\n const usedFragments: string[] = wantProfile ? [COMPANY_BASIC_INFO_FRAGMENT] : [];\n if (fields.some((f) => f.startsWith('legal_address'))) usedFragments.push(COMPANY_LEGAL_ADDRESS_FRAGMENT);\n if (fields.some((f) => f.startsWith('company_admin'))) usedFragments.push(COMPANY_ADMIN_FRAGMENT);\n if (fields.some((f) => f.startsWith('sales_representative'))) usedFragments.push(COMPANY_SALES_REPRESENTATIVE_FRAGMENT);\n\n return `${query}\\n${usedFragments.join('\\n')}`;\n};\n\n// Prevent duplicate, concurrent requests across re-mounts (e.g., dev StrictMode)\nlet inflightGetCompany: Promise<CompanyModel | null> | null = null;\nlet cachedCompany: CompanyModel | null = null;\n\nexport const resetCompanyCache = (): void => {\n cachedCompany = null;\n};\n\nexport const getCompany = async (useCache: boolean = true): Promise<CompanyModel | null> => {\n if (useCache && cachedCompany) {\n return cachedCompany;\n }\n if (inflightGetCompany) {\n return inflightGetCompany;\n }\n\n inflightGetCompany = (async () => {\n try {\n // Step 1: fetch role permissions to know which fields are allowed\n const roleResponse: any = await fetchGraphQl(GET_CUSTOMER_ROLE_PERMISSIONS, { method: 'GET', cache: 'no-cache' });\n if (roleResponse.errors?.length) return null;\n\n const role = roleResponse?.data?.customer?.role;\n const allowedIds = flattenIds(role?.permissions || []);\n // Treat Company Administrator as having all view permissions even if the permissions tree is empty\n const isAdmin = role?.id === '0' || (typeof role?.id === 'number' && role?.id === 0) || role?.name === 'Company Administrator';\n if (isAdmin) {\n [\n 'Magento_Company::view_account',\n 'Magento_Company::view_address',\n 'Magento_Company::contacts',\n 'Magento_Company::payment_information',\n 'Magento_Company::shipping_information',\n ].forEach((id) => allowedIds.add(id));\n }\n\n // Step 2: build a company query that requests only allowed fields\n const GET_COMPANY_DYNAMIC = buildCompanyQuery(allowedIds);\n\n // Step 3: fetch company with dynamic selection\n const companyResponse: getCompanyResponse = await fetchGraphQl(GET_COMPANY_DYNAMIC, { method: 'GET', cache: 'no-cache' });\n if (companyResponse.errors?.length) return null;\n\n const companyNode: any = companyResponse?.data?.company;\n const hasAnyCompanyField = companyNode && Object.keys(companyNode).some((k) => k !== '__typename');\n if (!hasAnyCompanyField) {\n return null;\n }\n\n // Merge back minimal customer role info so transform can compute flags\n (companyResponse as any).data.customer = roleResponse?.data?.customer;\n\n const result = transformCompany(companyResponse);\n cachedCompany = result;\n return result;\n } catch (e) {\n return null;\n } finally {\n // Release inflight handle; subsequent calls can run again\n inflightGetCompany = null;\n }\n })();\n\n return inflightGetCompany;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n */\nexport const handleNetworkError = (error: Error) => {\n const isAbortError =\n error instanceof DOMException && error.name === 'AbortError';\n\n if (!isAbortError) {\n // @ts-ignore\n events.emit('error', {\n source: 'company',\n type: 'network',\n error,\n });\n }\n throw error;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { COMPANY_FULL_FRAGMENT } from '../../graphql/CompanyFragment.graphql';\n\nexport const UPDATE_COMPANY = /* GraphQL */ `\n mutation UPDATE_COMPANY($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company {\n ...COMPANY_FULL_FRAGMENT\n }\n }\n }\n ${COMPANY_FULL_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { UPDATE_COMPANY } from './graphql/updateCompany.graphql';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { updateCompanyResponse, UpdateCompanyDto } from '../../types';\n\nexport const updateCompany = async (input: UpdateCompanyDto): Promise<CompanyModel> => {\n // Transform field names to match GraphQL schema expectations\n const transformedInput: Record<string, unknown> = {};\n \n // Map frontend field names to GraphQL schema field names\n if (input.name !== undefined) {\n transformedInput.company_name = input.name;\n }\n if (input.email !== undefined) {\n transformedInput.company_email = input.email;\n }\n if (input.legalName !== undefined) {\n transformedInput.legal_name = input.legalName;\n }\n if (input.vatTaxId !== undefined) {\n transformedInput.vat_tax_id = input.vatTaxId;\n }\n if (input.resellerId !== undefined) {\n transformedInput.reseller_id = input.resellerId;\n }\n \n // Transform legal address\n if (input.legalAddress !== undefined) {\n // Handle street field - ensure it's always a flat array of strings\n let streetArray: string[];\n if (Array.isArray(input.legalAddress.street)) {\n // If street is already an array, use it directly and add street_2 if present\n streetArray = [...input.legalAddress.street];\n if (input.legalAddress.street2) {\n streetArray.push(input.legalAddress.street2);\n }\n } else {\n // If street is a string, create array normally with type guard\n streetArray = [input.legalAddress.street, input.legalAddress.street2].filter(\n (s): s is string => typeof s === 'string' && s.trim().length > 0\n );\n }\n \n // Remove any empty strings and ensure all elements are strings\n streetArray = streetArray.filter(street => street && typeof street === 'string' && street.trim().length > 0);\n \n // Handle region - different approaches for dropdown vs custom regions\n let regionValue: { region: string; region_code: string; region_id?: number } | undefined;\n if (input.legalAddress.region && typeof input.legalAddress.region === 'object') {\n const regionObj = input.legalAddress.region;\n \n // Check if this is a custom region (region === regionCode) or predefined region\n if (regionObj.region === regionObj.regionCode) {\n // Custom region - send as object with region_id: 0\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n region_id: 0\n };\n } else {\n // Predefined region - send as object\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n };\n }\n } else if (input.legalAddress.regionCode && input.legalAddress.region !== input.legalAddress.regionCode) {\n // If we have different region and regionCode (dropdown case)\n regionValue = {\n region: input.legalAddress.region || input.legalAddress.regionCode,\n region_code: input.legalAddress.regionCode,\n };\n } else if (input.legalAddress.region) {\n // If we only have region string (fallback case)\n regionValue = {\n region: input.legalAddress.region,\n region_code: input.legalAddress.region,\n region_id: 0\n };\n }\n \n transformedInput.legal_address = {\n street: streetArray,\n city: input.legalAddress.city,\n region: regionValue,\n country_id: input.legalAddress.countryCode, // GraphQL expects country_id, not countryCode\n postcode: input.legalAddress.postcode,\n telephone: input.legalAddress.telephone,\n };\n }\n \n // Do not copy any other fields; only send explicitly allowed/mapped fields from the form\n\n return await fetchGraphQl(UPDATE_COMPANY, {\n method: 'POST',\n variables: { input: transformedInput },\n })\n .then((response: updateCompanyResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformCompany(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const GET_COUNTRIES_QUERY = `\n query getCountries {\n countries {\n id\n two_letter_abbreviation\n three_letter_abbreviation\n full_name_locale\n full_name_english\n available_regions {\n id\n code\n name\n }\n }\n storeConfig {\n countries_with_required_region\n optional_zip_countries\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { GET_COUNTRIES_QUERY } from './graphql/getCountries.graphql';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCountries } from '../../data/transforms/transform-countries';\nimport { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../../data/models/country';\n\nexport const getCountries = async (): Promise<{\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n}> => {\n const sessionStorageKey = '_company_countries';\n\n const sessionStorageCache = sessionStorage.getItem(sessionStorageKey);\n\n if (sessionStorageCache) {\n return JSON.parse(sessionStorageCache);\n }\n\n return await fetchGraphQl(GET_COUNTRIES_QUERY, {\n method: 'GET',\n })\n .then((response: CountriesFormResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n const transformedData = transformCountries(response);\n\n sessionStorage.setItem(\n sessionStorageKey,\n JSON.stringify(transformedData)\n );\n\n return transformedData;\n })\n .catch(handleNetworkError);\n};\n"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","VALIDATE_COMPANY_EMAIL_QUERY","validateCompanyEmail","email","response","transformCompany","companyData","_a","customerData","legalAddress","line","customerRole","allowedIds","nodes","set","stack","node","child","isAdmin","permissionsFlags","model","m","transformCountries","_b","countries","storeConfig","countriesWithRequiredRegion","optionalZipCountries","two_letter_abbreviation","full_name_locale","country","available_regions","hasRegions","a","b","GET_CUSTOMER_ROLE_PERMISSIONS","COMPANY_LEGAL_ADDRESS_FRAGMENT","COMPANY_BASIC_INFO_FRAGMENT","COMPANY_SALES_REPRESENTATIVE_FRAGMENT","COMPANY_ADMIN_FRAGMENT","COMPANY_FULL_FRAGMENT","flattenIds","buildCompanyQuery","allowed","wantProfile","wantAddress","wantContacts","wantPayment","wantShipping","fields","query","usedFragments","f","inflightGetCompany","cachedCompany","resetCompanyCache","getCompany","useCache","roleResponse","role","_c","id","GET_COMPANY_DYNAMIC","companyResponse","_d","companyNode","_e","k","_f","result","handleNetworkError","error","events","handleFetchError","errors","errorMessage","e","UPDATE_COMPANY","updateCompany","input","transformedInput","streetArray","s","street","regionValue","regionObj","GET_COUNTRIES_QUERY","getCountries","sessionStorageKey","sessionStorageCache","transformedData"],"mappings":"oHAoBO,KAAM,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECXVC,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECI7CC,EAAuB,M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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECQtBC,EAAe,SAItB,CACJ,MAAMC,EAAoB,qBAEpBC,EAAsB,eAAe,QAAQD,CAAiB,EAEpE,OAAIC,EACK,KAAK,MAAMA,CAAmB,EAGhC,MAAM3F,EAAawF,EAAqB,CAC7C,OAAQ,KAAA,CACT,EACE,KAAMlF,GAAoC,OACzC,IAAIG,EAAAH,EAAS,SAAT,MAAAG,EAAiB,OAAQ,OAAOkE,EAAiBrE,EAAS,MAAM,EAEpE,MAAMsF,EAAkBpE,EAAmBlB,CAAQ,EAEnD,sBAAe,QACboF,EACA,KAAK,UAAUE,CAAe,CAAA,EAGzBA,CACT,CAAC,EACA,MAAMpB,CAAkB,CAC7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './CompanyLoaders';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './CompanyProfileCard';
|
|
18
|
+
export { CompanyProfileCard as default } from './CompanyProfileCard';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
|
|
3
|
+
interface CompanyAccountFieldsProps {
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
value: {
|
|
6
|
+
name: string;
|
|
7
|
+
email: string;
|
|
8
|
+
legalName: string;
|
|
9
|
+
vatTaxId: string;
|
|
10
|
+
resellerId: string;
|
|
11
|
+
};
|
|
12
|
+
errors: Record<string, string>;
|
|
13
|
+
touched: Record<string, boolean>;
|
|
14
|
+
onChange: (field: string) => (value: string) => void;
|
|
15
|
+
onBlur: (field: string) => void;
|
|
16
|
+
/** Optional input name prefix for DOM names (defaults to none) */
|
|
17
|
+
namePrefix?: string;
|
|
18
|
+
/** Optional field path prefix used for change/blur handlers (defaults to none) */
|
|
19
|
+
fieldPathPrefix?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const CompanyAccountFields: FunctionComponent<CompanyAccountFieldsProps>;
|
|
22
|
+
export default CompanyAccountFields;
|
|
23
|
+
//# sourceMappingURL=CompanyAccountFields.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
|
|
3
|
+
interface LegalAddressFieldsProps {
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
loadingCountries: boolean;
|
|
6
|
+
value: {
|
|
7
|
+
street: string;
|
|
8
|
+
street2: string;
|
|
9
|
+
city: string;
|
|
10
|
+
region: string;
|
|
11
|
+
regionCode: string;
|
|
12
|
+
countryCode: string;
|
|
13
|
+
postcode: string;
|
|
14
|
+
telephone: string;
|
|
15
|
+
};
|
|
16
|
+
errors: Record<string, string>;
|
|
17
|
+
touched: Record<string, boolean>;
|
|
18
|
+
onChange: (field: string) => (value: string) => void;
|
|
19
|
+
onBlur: (field: string) => void;
|
|
20
|
+
countryOptions: {
|
|
21
|
+
text: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}[];
|
|
24
|
+
regionOptions: {
|
|
25
|
+
text: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}[];
|
|
28
|
+
isRegionRequired: boolean;
|
|
29
|
+
hasRegionOptions: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Optional input name prefix for DOM names (defaults to 'legal_address')
|
|
32
|
+
*/
|
|
33
|
+
namePrefix?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Optional field path prefix used for change/blur handlers (defaults to 'legal_address')
|
|
36
|
+
*/
|
|
37
|
+
fieldPathPrefix?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional per-field required overrides for non-edit flows
|
|
40
|
+
*/
|
|
41
|
+
requiredConfig?: Partial<{
|
|
42
|
+
street: boolean;
|
|
43
|
+
city: boolean;
|
|
44
|
+
postcode: boolean;
|
|
45
|
+
telephone: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export declare const LegalAddressFields: FunctionComponent<LegalAddressFieldsProps>;
|
|
49
|
+
export default LegalAddressFields;
|
|
50
|
+
//# sourceMappingURL=LegalAddressFields.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './EditCompanyProfile';
|
|
18
|
+
export { EditCompanyProfile as default } from './EditCompanyProfile';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './CompanyLoaders';
|
|
18
|
+
export * from './CompanyProfileCard';
|
|
19
|
+
export * from './EditCompanyProfile';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './CompanyProfile';
|
|
18
|
+
export { CompanyProfile as default } from './CompanyProfile';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as a,jsxs as g,Fragment as J}from"@dropins/tools/preact-jsx-runtime.js";import{classes as ee,Slot as fe}from"@dropins/tools/lib.js";import{Card as G,Button as X,Field as M,Input as R,Picker as ue,Header as pe,InLineAlert as ye,ProgressSpinner as ve,Skeleton as Ae,SkeletonRow as K}from"@dropins/tools/components.js";import{useState as V,useEffect as Z,useMemo as U,useRef as Q,useCallback as F}from"@dropins/tools/preact-hooks.js";import{g as ge,v as Ce,a as Ne,u as Ee,r as _e}from"../chunks/getCountries.js";import{useText as O}from"@dropins/tools/i18n.js";import*as x from"@dropins/tools/preact-compat.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const be=({company:t,slots:e,showEditForm:l,handleShowEditForm:u})=>{const o=O({editButton:"Company.shared.buttons.edit",noDataMessage:"Company.CompanyProfile.companyProfileCard.noDataMessage",companyName:"Company.shared.fields.companyName",email:"Company.shared.fields.email",legalName:"Company.shared.fields.legalName",vatTaxId:"Company.shared.fields.vatTaxId",resellerId:"Company.shared.fields.resellerId",legalAddress:"Company.shared.fields.legalAddress",contacts:"Company.CompanyProfile.companyProfileCard.contacts",companyAdministrator:"Company.CompanyProfile.companyProfileCard.companyAdministrator",salesRepresentative:"Company.CompanyProfile.companyProfileCard.salesRepresentative",paymentInformation:"Company.CompanyProfile.companyProfileCard.paymentInformation",shippingInformation:"Company.CompanyProfile.companyProfileCard.shippingInformation",availablePaymentMethods:"Company.CompanyProfile.companyProfileCard.availablePaymentMethods",availableShippingMethods:"Company.CompanyProfile.companyProfileCard.availableShippingMethods",noPaymentMethods:"Company.CompanyProfile.companyProfileCard.noPaymentMethods",noShippingMethods:"Company.CompanyProfile.companyProfileCard.noShippingMethods"});if(!t)return a(G,{variant:"secondary",className:"account-company-profile-card",children:a("div",{className:"account-company-profile-card__wrapper",children:a("div",{className:"account-company-profile-card__content",children:a("div",{className:"account-company-profile-card__no-data",children:a("p",{children:o.noDataMessage})})})})});const n=t.permissionsFlags||{canViewAccount:!0,canViewAddress:!0,canViewContacts:!0,canViewPaymentInformation:!0,canViewShippingInformation:!0},r=[n.canViewAccount?{name:"name",label:o.companyName,value:t.name||""}:null,n.canViewAccount?{name:"email",label:o.email,value:t.email||""}:null,n.canViewAccount?{name:"legalName",label:o.legalName,value:t.legalName||""}:null,n.canViewAccount?{name:"vatTaxId",label:o.vatTaxId,value:t.vatTaxId||""}:null,n.canViewAccount?{name:"resellerId",label:o.resellerId,value:t.resellerId||""}:null].filter(Boolean);return a(G,{variant:"secondary",className:ee(["account-company-profile-card",["account-company-profile-card-short",l]]),children:g("div",{className:"account-company-profile-card__wrapper",children:[a("div",{className:"account-company-profile-card__actions",children:(t.canEditAccount||t.canEditAddress)&&a(X,{type:"button",variant:"tertiary",onClick:u,children:o.editButton})}),a("div",{className:"account-company-profile-card__content",children:(()=>{var f,s;const A=g(J,{children:[r.map((i,p)=>{if(!i.value)return null;const v=i.label?`${i.label}: ${i.value}`:i.value;return a("p",{"data-testid":`${i.name}_${p}`,children:v},`${i.name}_${p}`)}),n.canViewAddress&&t.legalAddress&&g("div",{className:"company-legal-address",children:[a("p",{children:g("strong",{children:[o.legalAddress,":"]})}),(f=t.legalAddress.street)==null?void 0:f.map((i,p)=>a("p",{children:i},p)),g("p",{children:[t.legalAddress.city,", ",(s=t.legalAddress.region)==null?void 0:s.region," ",t.legalAddress.postcode]}),a("p",{children:t.legalAddress.countryCode}),t.legalAddress.telephone&&g("p",{children:["Phone: ",t.legalAddress.telephone]})]}),n.canViewContacts&&(t.companyAdmin||t.salesRepresentative)&&g("div",{className:"company-contacts",children:[a("p",{children:g("strong",{children:[o.contacts,":"]})}),t.companyAdmin&&g("div",{className:"company-contact",children:[a("p",{children:g("strong",{children:[o.companyAdministrator,":"]})}),g("p",{children:[t.companyAdmin.firstname," ",t.companyAdmin.lastname]}),t.companyAdmin.jobTitle&&a("p",{children:t.companyAdmin.jobTitle}),a("p",{children:t.companyAdmin.email})]}),t.salesRepresentative&&g("div",{className:"company-contact",children:[a("p",{children:g("strong",{children:[o.salesRepresentative,":"]})}),g("p",{children:[t.salesRepresentative.firstname," ",t.salesRepresentative.lastname]}),a("p",{children:t.salesRepresentative.email})]})]}),n.canViewPaymentInformation&&g("div",{className:"company-payment-methods",children:[a("p",{children:g("strong",{children:[o.paymentInformation,":"]})}),t.availablePaymentMethods&&t.availablePaymentMethods.length>0?g(J,{children:[a("p",{children:g("strong",{children:[o.availablePaymentMethods,":"]})}),a("ul",{className:"payment-methods-list",children:t.availablePaymentMethods.map((i,p)=>a("li",{children:i.title},`payment_${p}`))})]}):a("div",{className:"message message-notice notice",children:a("div",{children:o.noPaymentMethods})})]}),n.canViewShippingInformation&&g("div",{className:"company-shipping-methods",children:[a("p",{children:g("strong",{children:[o.shippingInformation,":"]})}),t.availableShippingMethods&&t.availableShippingMethods.length>0?g(J,{children:[a("p",{children:g("strong",{children:[o.availableShippingMethods,":"]})}),a("ul",{className:"shipping-methods-list",children:t.availableShippingMethods.map((i,p)=>a("li",{children:i.title},`shipping_${p}`))})]}):a("div",{className:"message message-notice notice",children:a("div",{children:o.noShippingMethods})})]})]});return e!=null&&e.CompanyData?a(fe,{name:"CompanyData",slot:e.CompanyData,context:{companyData:r,Default:A}}):A})()})]})})},we=t=>{const[e,l]=V(null),[u,o]=V(!0);Z(()=>{let s=!0;return ge().then(({availableCountries:i,countriesWithRequiredRegion:p,optionalZipCountries:v})=>{s&&(l({availableCountries:i,countriesWithRequiredRegion:p,optionalZipCountries:v}),o(!1))}).catch(()=>{s&&o(!1)}),()=>{s=!1}},[]);const n=U(()=>(e==null?void 0:e.availableCountries)||[],[e]),r=U(()=>{if(!t||!e)return[];const s=e.availableCountries.find(i=>i.value===t);return!(s!=null&&s.availableRegions)||s.availableRegions.length===0?[]:s.availableRegions.map(i=>({text:i.name,value:`${i.code},${i.id}`}))},[t,e]),A=U(()=>!t||!e?!1:e.countriesWithRequiredRegion.includes(t),[t,e]),f=U(()=>r.length>0,[r]);return{countryOptions:n,regionOptions:r,isRegionRequired:A,hasRegionOptions:f,loadingCountries:u}},Ie=({loading:t,value:e,errors:l,touched:u,onChange:o,onBlur:n,namePrefix:r="",fieldPathPrefix:A=""})=>{const f=O({companyName:"Company.shared.fields.companyName",email:"Company.shared.fields.email",legalName:"Company.shared.fields.legalName",vatTaxId:"Company.shared.fields.vatTaxId",resellerId:"Company.shared.fields.resellerId"}),s=r?`${r}_`:"",i=p=>A?`${A}.${p}`:p;return g("div",{className:"account-edit-company-profile-form__group",children:[a(M,{label:f.companyName,required:!0,className:"account-edit-company-profile-form__field",error:u.name&&l.name?l.name:void 0,children:a(R,{name:`${s}name`,type:"text",value:e.name,onValue:o(i("name")),onBlur:()=>n(i("name")),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:f.email,required:!0,className:"account-edit-company-profile-form__field",error:u.email&&l.email?l.email:void 0,children:a(R,{name:`${s}email`,type:"email",value:e.email,onValue:o(i("email")),onBlur:()=>n(i("email")),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:f.legalName,className:"account-edit-company-profile-form__field",children:a(R,{name:`${s}legalName`,type:"text",value:e.legalName,onValue:o(i("legalName")),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:f.vatTaxId,className:"account-edit-company-profile-form__field",children:a(R,{name:`${s}vatTaxId`,type:"text",value:e.vatTaxId,onValue:o(i("vatTaxId")),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:f.resellerId,className:"account-edit-company-profile-form__field",children:a(R,{name:`${s}resellerId`,type:"text",value:e.resellerId,onValue:o(i("resellerId")),disabled:!!t,variant:"primary",size:"medium"})})]})},Ve=({loading:t,loadingCountries:e,value:l,errors:u,touched:o,onChange:n,onBlur:r,countryOptions:A,regionOptions:f,isRegionRequired:s,hasRegionOptions:i,namePrefix:p="legalAddress",fieldPathPrefix:v="legalAddress",requiredConfig:C})=>{var W;const w=O({legalAddress:"Company.shared.fields.legalAddress",streetAddress:"Company.shared.fields.streetAddress",city:"Company.shared.fields.city",country:"Company.shared.fields.country",stateProvince:"Company.shared.fields.stateProvince",zipPostalCode:"Company.shared.fields.zipPostalCode",phoneNumber:"Company.shared.fields.phoneNumber"}),P={street:`${p}_street`,street2:`${p}_street2`,city:`${p}_city`,countryCode:`${p}_countryCode`,region:`${p}_region`,postcode:`${p}_postcode`,telephone:`${p}_telephone`},m={street:`${v}.street`,street2:`${v}.street2`,city:`${v}.city`,countryCode:`${v}.countryCode`,region:`${v}.region`,regionCode:`${v}.regionCode`,postcode:`${v}.postcode`,telephone:`${v}.telephone`},T={street:(C==null?void 0:C.street)??!0,city:(C==null?void 0:C.city)??!0,postcode:(C==null?void 0:C.postcode)??!0,telephone:(C==null?void 0:C.telephone)??!0};return g("div",{className:"account-edit-company-profile-form__section",children:[a("h3",{className:"account-edit-company-profile-form__section-title",children:w.legalAddress}),a(M,{label:w.streetAddress,required:T.street,className:"account-edit-company-profile-form__field",error:o[m.street]&&u[m.street]?u[m.street]:void 0,children:a(R,{name:P.street,type:"text",value:l.street,onValue:n(m.street),onBlur:()=>r(m.street),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:`${w.streetAddress} 2`,className:"account-edit-company-profile-form__field",children:a(R,{name:P.street2,type:"text",value:l.street2,onValue:n(m.street2),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:w.city,required:T.city,className:"account-edit-company-profile-form__field",error:o[m.city]&&u[m.city]?u[m.city]:void 0,children:a(R,{name:P.city,type:"text",value:l.city,onValue:n(m.city),onBlur:()=>r(m.city),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:w.country,required:!0,className:"account-edit-company-profile-form__field",error:o[m.countryCode]&&u[m.countryCode]?u[m.countryCode]:void 0,children:a(ue,{name:P.countryCode,floatingLabel:`${w.country} *`,placeholder:w.country,options:A,value:l.countryCode,handleSelect:_=>{const S=_.target;n(m.countryCode)(S.value)},onBlur:()=>r(m.countryCode),disabled:!!t||e})}),a(M,{label:w.stateProvince,required:s,className:"account-edit-company-profile-form__field",error:o["legalAddress.region"]&&u["legalAddress.region"]?u["legalAddress.region"]:void 0,children:i?a(ue,{name:"legalAddress_region",floatingLabel:`${w.stateProvince} ${s?"*":""}`,placeholder:w.stateProvince,options:f,value:l.regionCode&&((W=f.find(_=>_.value.split(",")[0]===l.regionCode))==null?void 0:W.value)||"",handleSelect:_=>{var H;const S=_.target,[D]=S.value.split(","),z=((H=f.find($=>$.value===S.value))==null?void 0:H.text)||"";n(m.region)(z),n(m.regionCode)(D)},onBlur:()=>r(m.region),disabled:!!t||e},`region_picker_${l.countryCode}`):a(R,{name:P.region,type:"text",value:l.region,onValue:n(m.region),onBlur:()=>r(m.region),disabled:!!t||e,variant:"primary",size:"medium"},`region_input_${l.countryCode}`)}),a(M,{label:w.zipPostalCode,required:T.postcode,className:"account-edit-company-profile-form__field",error:o[m.postcode]&&u[m.postcode]?u[m.postcode]:void 0,children:a(R,{name:P.postcode,type:"text",value:l.postcode,onValue:n(m.postcode),onBlur:()=>r(m.postcode),disabled:!!t,variant:"primary",size:"medium"})}),a(M,{label:w.phoneNumber,required:T.telephone,className:"account-edit-company-profile-form__field",error:o[m.telephone]&&u[m.telephone]?u[m.telephone]:void 0,children:a(R,{name:P.telephone,type:"tel",value:l.telephone,onValue:n(m.telephone),onBlur:()=>r(m.telephone),disabled:!!t,variant:"primary",size:"medium"})})]})},xe=({inLineAlertProps:t,company:e,loading:l=!1,onSubmit:u,onCancel:o})=>{var $,B,j,Y,q,y,I,te,ae,re,se,le,ne,ie;const n=O({title:"Company.EditCompanyProfile.title",cancel:"Company.shared.buttons.cancel",save:"Company.shared.buttons.save",saving:"Company.shared.buttons.saving",required:"Company.shared.validation.required",invalidEmail:"Company.shared.validation.invalidEmail",companyNameRequired:"Company.shared.validation.companyNameRequired",emailRequired:"Company.shared.validation.emailRequired",emailNotAvailable:"Company.shared.validation.emailNotAvailable"}),[r,A]=V({name:(e==null?void 0:e.name)||"",email:(e==null?void 0:e.email)||"",legalName:(e==null?void 0:e.legalName)||"",vatTaxId:(e==null?void 0:e.vatTaxId)||"",resellerId:(e==null?void 0:e.resellerId)||"",legalAddress:{street:((B=($=e==null?void 0:e.legalAddress)==null?void 0:$.street)==null?void 0:B[0])||"",street2:((Y=(j=e==null?void 0:e.legalAddress)==null?void 0:j.street)==null?void 0:Y[1])||"",city:((q=e==null?void 0:e.legalAddress)==null?void 0:q.city)||"",region:((I=(y=e==null?void 0:e.legalAddress)==null?void 0:y.region)==null?void 0:I.region)||"",regionCode:((ae=(te=e==null?void 0:e.legalAddress)==null?void 0:te.region)==null?void 0:ae.regionCode)||"",countryCode:((re=e==null?void 0:e.legalAddress)==null?void 0:re.countryCode)||"",postcode:((se=e==null?void 0:e.legalAddress)==null?void 0:se.postcode)||"",telephone:((le=e==null?void 0:e.legalAddress)==null?void 0:le.telephone)||""}}),[f,s]=V({}),[i,p]=V({}),v=((ne=e==null?void 0:e.permissionsFlags)==null?void 0:ne.canEditAccount)===!0,C=((ie=e==null?void 0:e.permissionsFlags)==null?void 0:ie.canEditAddress)===!0,{countryOptions:w,regionOptions:P,isRegionRequired:m,hasRegionOptions:T,loadingCountries:W}=we(r.legalAddress.countryCode),_=(c,h)=>c==="name"?h.trim()?null:n.companyNameRequired:c==="email"?h.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h)?null:n.invalidEmail:n.emailRequired:c==="legalAddress.street"||c==="legalAddress.city"||c==="legalAddress.postcode"||c==="legalAddress.telephone"||c==="legalAddress.countryCode"?h.trim()?null:n.required:c==="legalAddress.region"&&m&&!h.trim()?n.required:null,S=()=>{var k,b;const c={};let h=!0;const L=((k=e==null?void 0:e.permissionsFlags)==null?void 0:k.canEditAccount)===!0,N=((b=e==null?void 0:e.permissionsFlags)==null?void 0:b.canEditAddress)===!0;if(L){const d=_("name",r.name);d&&(c.name=d,h=!1);const E=_("email",r.email);E&&(c.email=E,h=!1)}if(N){const d=_("legalAddress.street",r.legalAddress.street);d&&(c["legalAddress.street"]=d,h=!1);const E=_("legalAddress.city",r.legalAddress.city);E&&(c["legalAddress.city"]=E,h=!1);const oe=_("legalAddress.postcode",r.legalAddress.postcode);oe&&(c["legalAddress.postcode"]=oe,h=!1);const de=_("legalAddress.telephone",r.legalAddress.telephone);de&&(c["legalAddress.telephone"]=de,h=!1);const ce=_("legalAddress.countryCode",r.legalAddress.countryCode);ce&&(c["legalAddress.countryCode"]=ce,h=!1);const me=_("legalAddress.region",r.legalAddress.region);me&&(c["legalAddress.region"]=me,h=!1)}return s(c),h},D=async c=>{var k,b;c.preventDefault();const h=((k=e==null?void 0:e.permissionsFlags)==null?void 0:k.canEditAccount)===!0,L=((b=e==null?void 0:e.permissionsFlags)==null?void 0:b.canEditAddress)===!0,N={};if(h&&(N.name=!0,N.email=!0,N.legalName=!0,N.vatTaxId=!0,N.resellerId=!0),L&&(N["legalAddress.street"]=!0,N["legalAddress.street2"]=!0,N["legalAddress.city"]=!0,N["legalAddress.region"]=!0,N["legalAddress.regionCode"]=!0,N["legalAddress.countryCode"]=!0,N["legalAddress.postcode"]=!0,N["legalAddress.telephone"]=!0),p(N),!!S()){if(h&&r.email!==(e==null?void 0:e.email)){const d=await Ce(r.email);if(!d.isValid){s(E=>({...E,email:d.error||n.emailNotAvailable}));return}}if(u){const d={};h&&(d.name=r.name,d.email=r.email,d.legalName=r.legalName,d.vatTaxId=r.vatTaxId,d.resellerId=r.resellerId),L&&(d.legalAddress={street:[r.legalAddress.street,r.legalAddress.street2].filter(Boolean),city:r.legalAddress.city,region:{region:r.legalAddress.region,regionCode:r.legalAddress.regionCode},countryCode:r.legalAddress.countryCode,postcode:r.legalAddress.postcode,telephone:r.legalAddress.telephone}),await u(d)}}},z=c=>h=>{const L=new Set(["name","email","legalName","vatTaxId","resellerId"]),N=c.startsWith("legalAddress.");if(!(L.has(c)&&!v||N&&!C)){if(c.startsWith("legalAddress.")){const b=c.split(".")[1];b==="countryCode"?(A(d=>({...d,legalAddress:{...d.legalAddress,[b]:h,region:"",regionCode:""}})),s(d=>{const E={...d};return delete E["legalAddress.region"],delete E["legalAddress.regionCode"],E}),p(d=>{const E={...d};return delete E["legalAddress.region"],delete E["legalAddress.regionCode"],E})):A(b==="region"?d=>({...d,legalAddress:{...d.legalAddress,region:h,regionCode:T?d.legalAddress.regionCode:h}}):d=>({...d,legalAddress:{...d.legalAddress,[b]:h}}))}else A(b=>({...b,[c]:h}));f[c]&&s(b=>{const d={...b};return delete d[c],d})}},H=c=>{const h=new Set(["name","email","legalName","vatTaxId","resellerId"]),L=c.startsWith("legalAddress.");if(h.has(c)&&!v||L&&!C)return;p(d=>({...d,[c]:!0}));let k="";if(c.startsWith("legalAddress.")){const d=c.split(".")[1],E=r.legalAddress[d];k=typeof E=="string"?E:""}else{const d=r[c];k=typeof d=="string"?d:""}const b=_(c,k);b&&s(d=>({...d,[c]:b}))};return g(G,{variant:"secondary",className:"account-edit-company-profile",children:[a(pe,{title:n.title,divider:!1,className:"account-edit-company-profile__title"}),t!=null&&t.text?a(ye,{className:"account-edit-company-profile__notification",type:t.type,variant:"secondary",heading:t.text,icon:t.icon,"data-testid":"editCompanyInLineAlert"}):null,g("form",{className:"account-edit-company-profile-form",onSubmit:D,children:[v&&a(Ie,{loading:l,value:{name:r.name,email:r.email,legalName:r.legalName,vatTaxId:r.vatTaxId,resellerId:r.resellerId},errors:f,touched:i,onChange:z,onBlur:H}),C&&a(Ve,{loading:l,loadingCountries:W,value:r.legalAddress,errors:f,touched:i,onChange:z,onBlur:H,countryOptions:w,regionOptions:P,isRegionRequired:m,hasRegionOptions:T}),g("div",{className:"account-edit-company-profile__actions",children:[a(X,{disabled:l,type:"button",variant:"secondary",onClick:()=>o==null?void 0:o(),children:n.cancel}),a(X,{disabled:l||!v&&!C,type:"submit",variant:"primary",children:n.save})]})]}),l&&g("div",{className:"account-edit-company-profile__loading-overlay","data-testid":"editCompanyLoadingOverlay",children:[a(ve,{size:"large"}),a("div",{className:"account-edit-company-profile__loading-text",children:n.saving})]})]})},Te=({testId:t,withCard:e=!0})=>{const l=g(Ae,{"data-testid":t||"companySkeletonLoader",children:[a(K,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return e?l:a(G,{variant:"secondary",className:ee(["company-company-loaders","company-company-loaders--card-loader"]),children:l})};var he=(t=>(t.EDIT_COMPANY_EVENT="edit-company",t))(he||{});const $e={EDIT_COMPANY_EVENT:"edit-company"},Me=()=>(window.adobeDataLayer||(window.adobeDataLayer=[]),window.adobeDataLayer),Pe=t=>{Me().push(l=>{const u=l.getState?l.getState():{};l.push({event:t,context:u})})},Re=(t,e)=>{if(!$e[t])return null;switch(t){case"edit-company":Pe({type:"company",eventType:"edit",companyData:e});break;default:return null}},Fe=({handleSetInLineAlert:t})=>{const e=O({companySuccess:"Company.CompanyProfile.editCompanyProfile.companySuccess",companyError:"Company.CompanyProfile.editCompanyProfile.companyError",loadError:"Company.CompanyProfile.messages.loadError",updateError:"Company.CompanyProfile.messages.updateError"}),{companySuccess:l,companyError:u,loadError:o,updateError:n}=e,[r,A]=V(null),[f,s]=V(!0),[i,p]=V(!1),[v,C]=V(!1),[w,P]=V([]),[m,T]=V({}),[W,_]=V(""),S=Q(t),D=Q(!1),z=Q(!1);Z(()=>{S.current=t},[t]);const H=F(y=>{T(y)},[]),$=F((y,I)=>{t&&(y==="success"?t({type:"success",text:I??l}):y==="error"?t({type:"error",text:I??u}):t(),p(!1))},[t,l,u]),B=F(()=>{D.current||(D.current=!0,s(!0),Ne(!0).then(y=>{y&&(A(y),_("")),s(!1)}).catch(y=>{console.error("Failed to load company:",y),s(!1),S.current&&S.current({type:"error",text:o})}).finally(()=>{D.current=!1}))},[o]);Z(()=>{z.current||(z.current=!0,B())},[B]),Z(()=>{ge().then(y=>{P(y.availableCountries)}).catch(y=>{console.error("Failed to load countries:",y)})},[]);const j=F(()=>{C(!0),$("success",""),T({})},[$]),Y=F(y=>{y==null||y(),C(!1),T({})},[]),q=F(async y=>{try{if(p(!0),!y){$("error","No data to update");return}const I=await Ee(y);r&&(I.canEditAccount=r.canEditAccount,I.canEditAddress=r.canEditAddress,I.customerRole=r.customerRole,I.customerStatus=r.customerStatus),A(I),C(!1),T({}),$("success"),Re(he.EDIT_COMPANY_EVENT,{...y,companyId:r==null?void 0:r.id}),_e(),B()}catch(I){console.error("Failed to update company:",I),$("error",I.message||n)}finally{p(!1)}},[r,$,B,n]);return{company:r,countries:w,createdAt:W,loading:f,submitLoading:i,showEditForm:v,inputChange:m,handleShowEditForm:j,handleHideEditForm:Y,handleUpdateCompany:q,handleInputChange:H,renderAlertMessage:$,saving:i}},Se=t=>x.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},x.createElement("g",{clipPath:"url(#clip0_841_1324)"},x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),x.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"})),x.createElement("defs",null,x.createElement("clipPath",{id:"clip0_841_1324"},x.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ke=t=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},x.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"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Le=t=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},x.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"}),x.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"})),De={success:a(ke,{}),warning:a(Se,{}),error:a(Le,{})},ze=()=>{const[t,e]=V({}),[l,u]=V(null),o=F(()=>{e({}),l&&(clearTimeout(l),u(null))},[l]),n=F(s=>{if(l&&(clearTimeout(l),u(null)),!(s!=null&&s.type)){e({});return}const i=De[s.type];if(e({type:s.type,text:s.text,icon:i}),s.autoHide!==!1){const p=s.autoHideDelay||(s.type==="success"?3e3:5e3),v=setTimeout(()=>{e({}),u(null)},p);u(v)}},[l]),r=F((s,i=!0)=>{n({type:"success",text:s,autoHide:i})},[n]),A=F((s,i=!1)=>{n({type:"warning",text:s,autoHide:i})},[n]),f=F((s,i=!1)=>{n({type:"error",text:s,autoHide:i})},[n]);return Z(()=>()=>{l&&clearTimeout(l)},[l]),{inLineAlertProps:t,handleSetInLineAlert:n,clearAlert:o,showSuccess:r,showWarning:A,showError:f}},Ue=({className:t,withHeader:e=!0,slots:l})=>{const u=O({containerTitle:"Company.CompanyProfile.containerTitle"}),{inLineAlertProps:o,handleSetInLineAlert:n}=ze(),{company:r,loading:A,saving:f,showEditForm:s,handleShowEditForm:i,handleHideEditForm:p,handleUpdateCompany:v}=Fe({handleSetInLineAlert:n});return A?a("div",{"data-testid":"companyProfileLoader",children:a(Te,{withCard:!0})}):g("div",{className:ee(["account-company-profile",t]),children:[e?a(pe,{title:u.containerTitle,divider:!1,className:"company-profile__title"}):null,a(be,{company:r,slots:l,showEditForm:s,handleShowEditForm:i}),s?a(xe,{inLineAlertProps:o,company:r,loading:f,onSubmit:v,onCancel:p}):null]})};export{Ue as CompanyProfile,Ue as default};
|
|
4
|
+
//# sourceMappingURL=CompanyProfile.js.map
|