@dropins/storefront-company-management 1.0.0-beta3 → 1.0.0-beta5
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/api.js.map +1 -1
- package/chunks/getCountries.js.map +1 -1
- package/components/EditCompanyProfile/CompanyAccountFields.d.ts +1 -2
- package/components/EditCompanyProfile/LegalAddressFields.d.ts +1 -1
- package/components/Tree/Tree.d.ts +60 -0
- package/components/Tree/index.d.ts +18 -0
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/hooks/containers/useCompanyProfile.d.ts +4 -2
- package/i18n/en_US.json.d.ts +5 -1
- package/package.json +1 -1
- package/render.js +1 -1
- package/render.js.map +1 -1
package/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/checkIsCompanyEnabled/checkIsCompanyEnabled.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// import { events } from '@adobe-commerce/event-bus';\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\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 { validateCompanyEmail } from '../validateCompanyEmail';\nimport { CheckIsCompanyEnabledResponse } from '../../types/api/checkIsCompanyEnabled.types';\n\nexport const checkIsCompanyEnabled = async (): Promise<CheckIsCompanyEnabledResponse> => {\n try {\n // Use validateCompanyEmail with a dummy email to check if Company functionality is available\n await validateCompanyEmail('test@test.com');\n \n // If the validation API works (regardless of email availability), Company functionality is enabled\n return {\n companyEnabled: true\n };\n } catch (error) {\n return {\n companyEnabled: false,\n error: 'Company functionality not available'\n };\n }\n};"],"names":["initialize","config","checkIsCompanyEnabled","validateCompanyEmail"],"mappings":"qOAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/checkIsCompanyEnabled/checkIsCompanyEnabled.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// import { events } from '@adobe-commerce/event-bus';\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\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 { validateCompanyEmail } from '../validateCompanyEmail';\nimport { CheckIsCompanyEnabledResponse } from '../../types/api/checkIsCompanyEnabled.types';\n\nexport const checkIsCompanyEnabled = async (): Promise<CheckIsCompanyEnabledResponse> => {\n try {\n // Use validateCompanyEmail with a dummy email to check if Company functionality is available\n await validateCompanyEmail('test@test.com');\n \n // If the validation API works (regardless of email availability), Company functionality is enabled\n return {\n companyEnabled: true\n };\n } catch (error) {\n return {\n companyEnabled: false,\n error: 'Company functionality not available'\n };\n }\n};"],"names":["initialize","config","checkIsCompanyEnabled","validateCompanyEmail"],"mappings":"qOAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCVWC,EAAwB,SAAoD,CACnF,GAAA,CAEF,aAAMC,EAAqB,eAAe,EAGnC,CACL,eAAgB,EAClB,OACc,CACP,MAAA,CACL,eAAgB,GAChB,MAAO,qCACT,CAAA,CAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCountries.js","sources":["/@dropins/storefront-company-management/src/api/fetch-graphql/fetch-graphql.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/fetchUserPermissions/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/lib/company-permissions.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/fetchUserPermissions.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/graphql/CompanyFragment.graphql.ts","/@dropins/storefront-company-management/src/api/graphql/buildCompanyQueries.ts","/@dropins/storefront-company-management/src/api/getCompany/getCompany.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\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 *******************************************************************/\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 *******************************************************************/\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 *******************************************************************/\n\n/**\n * Permission flags interface for company operations\n */\nexport interface CompanyPermissionFlags {\n canViewAccount: boolean;\n canEditAccount: boolean;\n canViewAddress: boolean;\n canEditAddress: boolean;\n canViewContacts: boolean;\n canViewPaymentInformation: boolean;\n canViewShippingInformation: boolean;\n}\n\n/**\n * Flattens a nested permissions tree into a Set of permission IDs\n * This is a pure utility function that can be used across the application\n */\nexport const 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\n/**\n * Determines if a role is a Company Administrator\n */\nexport const isCompanyAdministrator = (role: any): boolean => {\n return role?.id === '0' || \n (typeof role?.id === 'number' && role?.id === 0) || \n role?.name === 'Company Administrator';\n};\n\n/**\n * Builds permission flags from role data\n */\nexport const buildPermissionFlags = (role: any): CompanyPermissionFlags => {\n const allowedIds = flattenIds(role?.permissions || []);\n const isAdmin = isCompanyAdministrator(role);\n\n return {\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 };\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 { GET_CUSTOMER_ROLE_PERMISSIONS } from './graphql/getCustomerRole.graphql';\nimport { flattenIds, isCompanyAdministrator } from '../../lib/company-permissions';\n\n/**\n * Fetches user permissions and returns both the allowed permission IDs and the role response\n * This is a general-purpose API function that can be used across the application\n */\nexport const fetchUserPermissions = async (): Promise<{ allowedIds: Set<string>; roleResponse: any }> => {\n return await fetchGraphQl(GET_CUSTOMER_ROLE_PERMISSIONS, { \n method: 'GET', \n cache: 'no-cache' \n })\n .then((roleResponse: any) => {\n if (roleResponse.errors?.length) {\n return handleFetchError(roleResponse.errors);\n }\n\n const role = roleResponse?.data?.customer?.role;\n const allowedIds = flattenIds(role?.permissions || []);\n \n // Treat Company Administrator as having all permissions even if the permissions tree is empty\n const isAdmin = isCompanyAdministrator(role);\n if (isAdmin) {\n [\n 'Magento_Company::view_account',\n 'Magento_Company::edit_account',\n 'Magento_Company::view_address',\n 'Magento_Company::edit_address',\n 'Magento_Company::contacts',\n 'Magento_Company::payment_information',\n 'Magento_Company::shipping_information',\n ].forEach((id) => allowedIds.add(id));\n }\n\n return { allowedIds, roleResponse };\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 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';\nimport { buildPermissionFlags } from '../../lib/company-permissions';\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 using shared utility\n const customerRole = customerData?.role;\n const permissionsFlags = buildPermissionFlags(customerRole);\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 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 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 {\n COMPANY_BASIC_INFO_FRAGMENT,\n COMPANY_LEGAL_ADDRESS_FRAGMENT,\n COMPANY_ADMIN_FRAGMENT,\n COMPANY_SALES_REPRESENTATIVE_FRAGMENT,\n} from './CompanyFragment.graphql';\n\n/**\n * Builds company fields based on user permissions\n */\nconst buildCompanyFields = (allowed: Set<string>): { fields: string[]; usedFragments: 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 const usedFragments: string[] = [];\n\n if (wantProfile) {\n fields.push('...COMPANY_BASIC_INFO_FRAGMENT');\n usedFragments.push(COMPANY_BASIC_INFO_FRAGMENT);\n }\n if (wantAddress) {\n fields.push(`legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }`);\n usedFragments.push(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 usedFragments.push(COMPANY_ADMIN_FRAGMENT);\n usedFragments.push(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 return { fields, usedFragments };\n};\n\n/**\n * Builds a dynamic company query based on user permissions\n */\nexport const buildCompanyQuery = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\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 return `${query}\\n${usedFragments.join('\\n')}`;\n};\n\n/**\n * Builds a dynamic company update mutation based on user permissions\n */\nexport const buildUpdateCompanyMutation = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company { __typename }\n }\n }\n `;\n }\n\n const mutation = `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company {\n ${fields.join('\\n ')}\n }\n }\n }\n `;\n\n return `${mutation}\\n${usedFragments.join('\\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 { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildCompanyQuery } from '../graphql/buildCompanyQueries';\nimport { handleFetchError } from '../../lib/fetch-error';\n\nexport const getCompany = async (): Promise<CompanyModel | null> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a company query that requests only allowed fields\n const GET_COMPANY_DYNAMIC = buildCompanyQuery(allowedIds);\n\n // 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 handleFetchError(companyResponse.errors);\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 return transformCompany(companyResponse);\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 *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { updateCompanyResponse, UpdateCompanyDto } from '../../types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildUpdateCompanyMutation } from '../graphql/buildCompanyQueries';\n\n\nexport const updateCompany = async (input: UpdateCompanyDto): Promise<CompanyModel> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a dynamic mutation that requests only allowed fields in response\n const UPDATE_COMPANY_DYNAMIC = buildUpdateCompanyMutation(allowedIds);\n\n // Transform input (keep original logic for what to send)\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 (only if user has edit_address permission)\n if (input.legalAddress !== undefined && allowedIds.has('Magento_Company::edit_address')) {\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 // Execute the dynamic mutation\n const response: updateCompanyResponse = await fetchGraphQl(UPDATE_COMPANY_DYNAMIC, {\n method: 'POST',\n variables: { input: transformedInput },\n });\n\n if (response.errors?.length) return handleFetchError(response.errors);\n\n // Merge back minimal customer role info so transform can compute flags\n (response as any).data.customer = roleResponse?.data?.customer;\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","handleNetworkError","error","events","handleFetchError","errors","errorMessage","e","GET_CUSTOMER_ROLE_PERMISSIONS","flattenIds","nodes","set","stack","node","child","isCompanyAdministrator","role","buildPermissionFlags","allowedIds","isAdmin","fetchUserPermissions","roleResponse","_a","_c","_b","id","VALIDATE_COMPANY_EMAIL_QUERY","validateCompanyEmail","email","response","transformCompany","companyData","customerData","legalAddress","line","customerRole","permissionsFlags","model","m","transformCountries","countries","storeConfig","countriesWithRequiredRegion","optionalZipCountries","two_letter_abbreviation","full_name_locale","country","available_regions","hasRegions","a","b","COMPANY_LEGAL_ADDRESS_FRAGMENT","COMPANY_BASIC_INFO_FRAGMENT","COMPANY_SALES_REPRESENTATIVE_FRAGMENT","COMPANY_ADMIN_FRAGMENT","buildCompanyFields","allowed","wantProfile","wantAddress","wantContacts","wantPayment","wantShipping","fields","usedFragments","buildCompanyQuery","buildUpdateCompanyMutation","getCompany","GET_COMPANY_DYNAMIC","companyResponse","companyNode","k","updateCompany","input","UPDATE_COMPANY_DYNAMIC","transformedInput","streetArray","s","street","regionValue","regionObj","GET_COUNTRIES_QUERY","getCountries","sessionStorageKey","sessionStorageCache","transformedData"],"mappings":"oHAmBO,KAAM,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECJVC,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAIhDC,EAAO,KAAK,QAAS,CACnB,OAAQ,UACR,KAAM,UACN,MAAAD,CAAA,CACD,EAEGA,CACR,EClBaE,EAAoBC,GAAuC,CACtE,MAAMC,EAAeD,EAAO,IAAKE,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMD,CAAY,CAC1B,ECLaE,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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storefront-company-management/src/lib/network-error.ts","/@dropins/storefront-company-management/src/lib/fetch-error.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/lib/company-permissions.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/fetchUserPermissions.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/graphql/CompanyFragment.graphql.ts","/@dropins/storefront-company-management/src/api/graphql/buildCompanyQueries.ts","/@dropins/storefront-company-management/src/api/getCompany/getCompany.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\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 *******************************************************************/\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 *******************************************************************/\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 *******************************************************************/\n\n/**\n * Permission flags interface for company operations\n */\nexport interface CompanyPermissionFlags {\n canViewAccount: boolean;\n canEditAccount: boolean;\n canViewAddress: boolean;\n canEditAddress: boolean;\n canViewContacts: boolean;\n canViewPaymentInformation: boolean;\n canViewShippingInformation: boolean;\n}\n\n/**\n * Flattens a nested permissions tree into a Set of permission IDs\n * This is a pure utility function that can be used across the application\n */\nexport const 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\n/**\n * Determines if a role is a Company Administrator\n */\nexport const isCompanyAdministrator = (role: any): boolean => {\n return role?.id === '0' || \n (typeof role?.id === 'number' && role?.id === 0) || \n role?.name === 'Company Administrator';\n};\n\n/**\n * Builds permission flags from role data\n */\nexport const buildPermissionFlags = (role: any): CompanyPermissionFlags => {\n const allowedIds = flattenIds(role?.permissions || []);\n const isAdmin = isCompanyAdministrator(role);\n\n return {\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 };\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 { GET_CUSTOMER_ROLE_PERMISSIONS } from './graphql/getCustomerRole.graphql';\nimport { flattenIds, isCompanyAdministrator } from '../../lib/company-permissions';\n\n/**\n * Fetches user permissions and returns both the allowed permission IDs and the role response\n * This is a general-purpose API function that can be used across the application\n */\nexport const fetchUserPermissions = async (): Promise<{ allowedIds: Set<string>; roleResponse: any }> => {\n return await fetchGraphQl(GET_CUSTOMER_ROLE_PERMISSIONS, { \n method: 'GET', \n cache: 'no-cache' \n })\n .then((roleResponse: any) => {\n if (roleResponse.errors?.length) {\n return handleFetchError(roleResponse.errors);\n }\n\n const role = roleResponse?.data?.customer?.role;\n const allowedIds = flattenIds(role?.permissions || []);\n \n // Treat Company Administrator as having all permissions even if the permissions tree is empty\n const isAdmin = isCompanyAdministrator(role);\n if (isAdmin) {\n [\n 'Magento_Company::view_account',\n 'Magento_Company::edit_account',\n 'Magento_Company::view_address',\n 'Magento_Company::edit_address',\n 'Magento_Company::contacts',\n 'Magento_Company::payment_information',\n 'Magento_Company::shipping_information',\n ].forEach((id) => allowedIds.add(id));\n }\n\n return { allowedIds, roleResponse };\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 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';\nimport { buildPermissionFlags } from '../../lib/company-permissions';\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 using shared utility\n const customerRole = customerData?.role;\n const permissionsFlags = buildPermissionFlags(customerRole);\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 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 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 {\n COMPANY_BASIC_INFO_FRAGMENT,\n COMPANY_LEGAL_ADDRESS_FRAGMENT,\n COMPANY_ADMIN_FRAGMENT,\n COMPANY_SALES_REPRESENTATIVE_FRAGMENT,\n} from './CompanyFragment.graphql';\n\n/**\n * Builds company fields based on user permissions\n */\nconst buildCompanyFields = (allowed: Set<string>): { fields: string[]; usedFragments: 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 const usedFragments: string[] = [];\n\n if (wantProfile) {\n fields.push('...COMPANY_BASIC_INFO_FRAGMENT');\n usedFragments.push(COMPANY_BASIC_INFO_FRAGMENT);\n }\n if (wantAddress) {\n fields.push(`legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }`);\n usedFragments.push(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 usedFragments.push(COMPANY_ADMIN_FRAGMENT);\n usedFragments.push(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 return { fields, usedFragments };\n};\n\n/**\n * Builds a dynamic company query based on user permissions\n */\nexport const buildCompanyQuery = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\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 return `${query}\\n${usedFragments.join('\\n')}`;\n};\n\n/**\n * Builds a dynamic company update mutation based on user permissions\n */\nexport const buildUpdateCompanyMutation = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company { __typename }\n }\n }\n `;\n }\n\n const mutation = `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company {\n ${fields.join('\\n ')}\n }\n }\n }\n `;\n\n return `${mutation}\\n${usedFragments.join('\\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 { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildCompanyQuery } from '../graphql/buildCompanyQueries';\nimport { handleFetchError } from '../../lib/fetch-error';\n\nexport const getCompany = async (): Promise<CompanyModel | null> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a company query that requests only allowed fields\n const GET_COMPANY_DYNAMIC = buildCompanyQuery(allowedIds);\n\n // 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 handleFetchError(companyResponse.errors);\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 return transformCompany(companyResponse);\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 *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { updateCompanyResponse, UpdateCompanyDto } from '../../types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildUpdateCompanyMutation } from '../graphql/buildCompanyQueries';\n\n\nexport const updateCompany = async (input: UpdateCompanyDto): Promise<CompanyModel> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a dynamic mutation that requests only allowed fields in response\n const UPDATE_COMPANY_DYNAMIC = buildUpdateCompanyMutation(allowedIds);\n\n // Transform input (keep original logic for what to send)\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 (only if user has edit_address permission)\n if (input.legalAddress !== undefined && allowedIds.has('Magento_Company::edit_address')) {\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 // Execute the dynamic mutation\n const response: updateCompanyResponse = await fetchGraphQl(UPDATE_COMPANY_DYNAMIC, {\n method: 'POST',\n variables: { input: transformedInput },\n });\n\n if (response.errors?.length) return handleFetchError(response.errors);\n\n // Merge back minimal customer role info so transform can compute flags\n (response as any).data.customer = roleResponse?.data?.customer;\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","handleNetworkError","error","events","handleFetchError","errors","errorMessage","e","GET_CUSTOMER_ROLE_PERMISSIONS","flattenIds","nodes","set","stack","node","child","isCompanyAdministrator","role","buildPermissionFlags","allowedIds","isAdmin","fetchUserPermissions","roleResponse","_a","_c","_b","id","VALIDATE_COMPANY_EMAIL_QUERY","validateCompanyEmail","email","response","transformCompany","companyData","customerData","legalAddress","line","customerRole","permissionsFlags","model","m","transformCountries","countries","storeConfig","countriesWithRequiredRegion","optionalZipCountries","two_letter_abbreviation","full_name_locale","country","available_regions","hasRegions","a","b","COMPANY_LEGAL_ADDRESS_FRAGMENT","COMPANY_BASIC_INFO_FRAGMENT","COMPANY_SALES_REPRESENTATIVE_FRAGMENT","COMPANY_ADMIN_FRAGMENT","buildCompanyFields","allowed","wantProfile","wantAddress","wantContacts","wantPayment","wantShipping","fields","usedFragments","buildCompanyQuery","buildUpdateCompanyMutation","getCompany","GET_COMPANY_DYNAMIC","companyResponse","companyNode","k","updateCompany","input","UPDATE_COMPANY_DYNAMIC","transformedInput","streetArray","s","street","regionValue","regionObj","GET_COUNTRIES_QUERY","getCountries","sessionStorageKey","sessionStorageCache","transformedData"],"mappings":"oHAmBa,KAAA,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAa,EAAE,WAAW,ECJrBC,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAIhDC,EAAO,KAAK,QAAS,CACnB,OA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,MAAAP,EAAiB,OAAe,OAAAlB,EAAiByB,EAAS,MAAM,EAE9D,MAAAuD,EAAkB7C,EAAmBV,CAAQ,EAEpC,sBAAA,QACbqD,EACA,KAAK,UAAUE,CAAe,CAChC,EAEOA,CAAA,CACR,EACA,MAAMnF,CAAkB,CAC7B"}
|
|
@@ -11,8 +11,7 @@ interface CompanyAccountFieldsProps {
|
|
|
11
11
|
};
|
|
12
12
|
errors: Record<string, string>;
|
|
13
13
|
touched: Record<string, boolean>;
|
|
14
|
-
|
|
15
|
-
onBlur: (field: string) => void;
|
|
14
|
+
onBlur: (field: string, value?: string) => void;
|
|
16
15
|
/** Optional input name prefix for DOM names (defaults to none) */
|
|
17
16
|
namePrefix?: string;
|
|
18
17
|
/** Optional field path prefix used for change/blur handlers (defaults to none) */
|
|
@@ -16,7 +16,7 @@ interface LegalAddressFieldsProps {
|
|
|
16
16
|
errors: Record<string, string>;
|
|
17
17
|
touched: Record<string, boolean>;
|
|
18
18
|
onChange: (field: string) => (value: string) => void;
|
|
19
|
-
onBlur: (field: string) => void;
|
|
19
|
+
onBlur: (field: string, value?: string) => void;
|
|
20
20
|
countryOptions: {
|
|
21
21
|
text: string;
|
|
22
22
|
value: string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
|
|
3
|
+
export interface TreeItem {
|
|
4
|
+
id: string;
|
|
5
|
+
parentId?: string | null;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RenderNodeArgs {
|
|
9
|
+
item: TreeItem;
|
|
10
|
+
level: number;
|
|
11
|
+
expanded: boolean;
|
|
12
|
+
selected: boolean;
|
|
13
|
+
hasChildren: boolean;
|
|
14
|
+
toggle: () => void;
|
|
15
|
+
select: () => void;
|
|
16
|
+
expander?: () => any;
|
|
17
|
+
checkbox?: () => any;
|
|
18
|
+
icon?: () => any;
|
|
19
|
+
}
|
|
20
|
+
export interface TreeProps {
|
|
21
|
+
items: TreeItem[];
|
|
22
|
+
rootId?: string | null;
|
|
23
|
+
className?: string;
|
|
24
|
+
expandedIds: Set<string>;
|
|
25
|
+
selectedId?: string | null;
|
|
26
|
+
selectedIds?: Set<string>;
|
|
27
|
+
onExpandedChange: (next: Set<string>) => void;
|
|
28
|
+
onSelectedChange?: (id: string | null) => void;
|
|
29
|
+
onSelectedIdsChange?: (ids: Set<string>) => void;
|
|
30
|
+
renderNode: (args: RenderNodeArgs) => any;
|
|
31
|
+
role?: 'tree' | 'list' | 'grid';
|
|
32
|
+
draggable?: (item: TreeItem) => boolean;
|
|
33
|
+
canDrop?: (dragId: string, targetId: string) => boolean;
|
|
34
|
+
onMove?: (args: {
|
|
35
|
+
id: string;
|
|
36
|
+
newParentId: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
isCheckable?: (item: TreeItem) => boolean;
|
|
39
|
+
checkedIds?: Set<string>;
|
|
40
|
+
onCheckedChange?: (next: Set<string>) => void;
|
|
41
|
+
renderExpander?: (args: {
|
|
42
|
+
expanded: boolean;
|
|
43
|
+
hasChildren: boolean;
|
|
44
|
+
toggle: () => void;
|
|
45
|
+
}) => any;
|
|
46
|
+
renderCheckbox?: (args: {
|
|
47
|
+
checked: boolean;
|
|
48
|
+
indeterminate: boolean;
|
|
49
|
+
onCheck: () => void;
|
|
50
|
+
}) => any;
|
|
51
|
+
renderIcon?: (args: {
|
|
52
|
+
item: TreeItem;
|
|
53
|
+
level: number;
|
|
54
|
+
hasChildren: boolean;
|
|
55
|
+
expanded: boolean;
|
|
56
|
+
}) => any;
|
|
57
|
+
}
|
|
58
|
+
export declare const Tree: FunctionComponent<TreeProps>;
|
|
59
|
+
export default Tree;
|
|
60
|
+
//# sourceMappingURL=Tree.d.ts.map
|
|
@@ -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 './Tree';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
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 $,Input as P,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 I,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 _e}from"../chunks/getCountries.js";import{useText as W}from"@dropins/tools/i18n.js";import*as V 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=W({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})()})]})})},Ee=t=>{const[e,l]=I(null),[u,o]=I(!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}},we=({loading:t,value:e,errors:l,touched:u,onChange:o,onBlur:n,namePrefix:r="",fieldPathPrefix:A=""})=>{const f=W({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($,{label:f.companyName,required:!0,className:"account-edit-company-profile-form__field",error:u.name&&l.name?l.name:void 0,children:a(P,{name:`${s}name`,type:"text",value:e.name,onValue:o(i("name")),onBlur:()=>n(i("name")),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:f.email,required:!0,className:"account-edit-company-profile-form__field",error:u.email&&l.email?l.email:void 0,children:a(P,{name:`${s}email`,type:"email",value:e.email,onValue:o(i("email")),onBlur:()=>n(i("email")),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:f.legalName,className:"account-edit-company-profile-form__field",children:a(P,{name:`${s}legalName`,type:"text",value:e.legalName,onValue:o(i("legalName")),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:f.vatTaxId,className:"account-edit-company-profile-form__field",children:a(P,{name:`${s}vatTaxId`,type:"text",value:e.vatTaxId,onValue:o(i("vatTaxId")),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:f.resellerId,className:"account-edit-company-profile-form__field",children:a(P,{name:`${s}resellerId`,type:"text",value:e.resellerId,onValue:o(i("resellerId")),disabled:!!t,variant:"primary",size:"medium"})})]})},Ie=({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 B;const w=W({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"}),M={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`},x={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($,{label:w.streetAddress,required:x.street,className:"account-edit-company-profile-form__field",error:o[m.street]&&u[m.street]?u[m.street]:void 0,children:a(P,{name:M.street,type:"text",value:l.street,onValue:n(m.street),onBlur:()=>r(m.street),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:`${w.streetAddress} 2`,className:"account-edit-company-profile-form__field",children:a(P,{name:M.street2,type:"text",value:l.street2,onValue:n(m.street2),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:w.city,required:x.city,className:"account-edit-company-profile-form__field",error:o[m.city]&&u[m.city]?u[m.city]:void 0,children:a(P,{name:M.city,type:"text",value:l.city,onValue:n(m.city),onBlur:()=>r(m.city),disabled:!!t,variant:"primary",size:"medium"})}),a($,{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:M.countryCode,floatingLabel:`${w.country} *`,placeholder:w.country,options:A,value:l.countryCode,handleSelect:b=>{const R=b.target;n(m.countryCode)(R.value)},onBlur:()=>r(m.countryCode),disabled:!!t||e})}),a($,{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&&((B=f.find(b=>b.value.split(",")[0]===l.regionCode))==null?void 0:B.value)||"",handleSelect:b=>{var H;const R=b.target,[D]=R.value.split(","),z=((H=f.find(T=>T.value===R.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(P,{name:M.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($,{label:w.zipPostalCode,required:x.postcode,className:"account-edit-company-profile-form__field",error:o[m.postcode]&&u[m.postcode]?u[m.postcode]:void 0,children:a(P,{name:M.postcode,type:"text",value:l.postcode,onValue:n(m.postcode),onBlur:()=>r(m.postcode),disabled:!!t,variant:"primary",size:"medium"})}),a($,{label:w.phoneNumber,required:x.telephone,className:"account-edit-company-profile-form__field",error:o[m.telephone]&&u[m.telephone]?u[m.telephone]:void 0,children:a(P,{name:M.telephone,type:"tel",value:l.telephone,onValue:n(m.telephone),onBlur:()=>r(m.telephone),disabled:!!t,variant:"primary",size:"medium"})})]})},Ve=({inLineAlertProps:t,company:e,loading:l=!1,onSubmit:u,onCancel:o})=>{var T,O,j,Y,q,y,S,te,ae,re,se,le,ne,ie;const n=W({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]=I({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:((O=(T=e==null?void 0:e.legalAddress)==null?void 0:T.street)==null?void 0:O[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:((S=(y=e==null?void 0:e.legalAddress)==null?void 0:y.region)==null?void 0:S.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]=I({}),[i,p]=I({}),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:M,isRegionRequired:m,hasRegionOptions:x,loadingCountries:B}=Ee(r.legalAddress.countryCode),b=(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,R=()=>{var k,E;const c={};let h=!0;const L=((k=e==null?void 0:e.permissionsFlags)==null?void 0:k.canEditAccount)===!0,N=((E=e==null?void 0:e.permissionsFlags)==null?void 0:E.canEditAddress)===!0;if(L){const d=b("name",r.name);d&&(c.name=d,h=!1);const _=b("email",r.email);_&&(c.email=_,h=!1)}if(N){const d=b("legalAddress.street",r.legalAddress.street);d&&(c["legalAddress.street"]=d,h=!1);const _=b("legalAddress.city",r.legalAddress.city);_&&(c["legalAddress.city"]=_,h=!1);const oe=b("legalAddress.postcode",r.legalAddress.postcode);oe&&(c["legalAddress.postcode"]=oe,h=!1);const de=b("legalAddress.telephone",r.legalAddress.telephone);de&&(c["legalAddress.telephone"]=de,h=!1);const ce=b("legalAddress.countryCode",r.legalAddress.countryCode);ce&&(c["legalAddress.countryCode"]=ce,h=!1);const me=b("legalAddress.region",r.legalAddress.region);me&&(c["legalAddress.region"]=me,h=!1)}return s(c),h},D=async c=>{var k,E;c.preventDefault();const h=((k=e==null?void 0:e.permissionsFlags)==null?void 0:k.canEditAccount)===!0,L=((E=e==null?void 0:e.permissionsFlags)==null?void 0:E.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),!!R()){if(h&&r.email!==(e==null?void 0:e.email)){const d=await Ce(r.email);if(!d.isValid){s(_=>({..._,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 E=c.split(".")[1];E==="countryCode"?(A(d=>({...d,legalAddress:{...d.legalAddress,[E]:h,region:"",regionCode:""}})),s(d=>{const _={...d};return delete _["legalAddress.region"],delete _["legalAddress.regionCode"],_}),p(d=>{const _={...d};return delete _["legalAddress.region"],delete _["legalAddress.regionCode"],_})):A(E==="region"?d=>({...d,legalAddress:{...d.legalAddress,region:h,regionCode:x?d.legalAddress.regionCode:h}}):d=>({...d,legalAddress:{...d.legalAddress,[E]:h}}))}else A(E=>({...E,[c]:h}));f[c]&&s(E=>{const d={...E};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],_=r.legalAddress[d];k=typeof _=="string"?_:""}else{const d=r[c];k=typeof d=="string"?d:""}const E=b(c,k);E&&s(d=>({...d,[c]:E}))};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(we,{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(Ie,{loading:l,loadingCountries:B,value:r.legalAddress,errors:f,touched:i,onChange:z,onBlur:H,countryOptions:w,regionOptions:M,isRegionRequired:m,hasRegionOptions:x}),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})]})]})},xe=({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 Te={EDIT_COMPANY_EVENT:"edit-company"},$e=()=>(window.adobeDataLayer||(window.adobeDataLayer=[]),window.adobeDataLayer),Me=t=>{$e().push(l=>{const u=l.getState?l.getState():{};l.push({event:t,context:u})})},Pe=(t,e)=>{if(!Te[t])return null;switch(t){case"edit-company":Me({type:"company",eventType:"edit",companyData:e});break;default:return null}},Fe=({handleSetInLineAlert:t})=>{const e=W({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]=I(null),[f,s]=I(!0),[i,p]=I(!1),[v,C]=I(!1),[w,M]=I([]),[m,x]=I({}),[B,b]=I(""),R=Q(t),D=Q(!1),z=Q(!1);Z(()=>{R.current=t},[t]);const H=F(y=>{x(y)},[]),T=F((y,S)=>{t&&(y==="success"?t({type:"success",text:S??l}):y==="error"?t({type:"error",text:S??u}):t(),p(!1))},[t,l,u]),O=F(()=>{D.current||(D.current=!0,s(!0),Ne().then(y=>{y&&(A(y),b("")),s(!1)}).catch(y=>{console.error("Failed to load company:",y),s(!1),R.current&&R.current({type:"error",text:o})}).finally(()=>{D.current=!1}))},[o]);Z(()=>{z.current||(z.current=!0,O())},[O]),Z(()=>{ge().then(y=>{M(y.availableCountries)}).catch(y=>{console.error("Failed to load countries:",y)})},[]);const j=F(()=>{C(!0),T("success",""),x({})},[T]),Y=F(y=>{y==null||y(),C(!1),x({})},[]),q=F(async y=>{try{if(p(!0),!y){T("error","No data to update");return}const S=await _e(y);A(S),C(!1),x({}),T("success"),Pe(he.EDIT_COMPANY_EVENT,{...y,companyId:r==null?void 0:r.id})}catch(S){console.error("Failed to update company:",S),T("error",S.message||n)}finally{p(!1)}},[r,T,n]);return{company:r,countries:w,createdAt:B,loading:f,submitLoading:i,showEditForm:v,inputChange:m,handleShowEditForm:j,handleHideEditForm:Y,handleUpdateCompany:q,handleInputChange:H,renderAlertMessage:T,saving:i}},Re=t=>V.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},V.createElement("g",{clipPath:"url(#clip0_841_1324)"},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),V.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"})),V.createElement("defs",null,V.createElement("clipPath",{id:"clip0_841_1324"},V.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),Se=t=>V.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},V.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"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),ke=t=>V.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},V.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"}),V.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={success:a(Se,{}),warning:a(Re,{}),error:a(ke,{})},De=()=>{const[t,e]=I({}),[l,u]=I(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=Le[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}},qe=({className:t,withHeader:e=!0,slots:l})=>{const u=W({containerTitle:"Company.CompanyProfile.containerTitle"}),{inLineAlertProps:o,handleSetInLineAlert:n}=De(),{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(xe,{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(Ve,{inLineAlertProps:o,company:r,loading:f,onSubmit:v,onCancel:p}):null]})};export{qe as CompanyProfile,qe as default};
|
|
3
|
+
import{jsx as a,jsxs as y,Fragment as K}from"@dropins/tools/preact-jsx-runtime.js";import{classes as ee,Slot as ve}from"@dropins/tools/lib.js";import{Card as J,Button as X,Field as S,Input as F,Picker as pe,Header as he,InLineAlert as Ce,ProgressSpinner as Ae,Skeleton as Ne,SkeletonRow as Q}from"@dropins/tools/components.js";import{useState as M,useEffect as B,useMemo as U,useRef as G,useCallback as R}from"@dropins/tools/preact-hooks.js";import{events as ge}from"@dropins/tools/event-bus.js";import{g as fe,v as Ee,a as _e,u as be}from"../chunks/getCountries.js";import{useText as Z}from"@dropins/tools/i18n.js";import*as L from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";const Ie=({company:t,slots:e,showEditForm:n,handleShowEditForm:u})=>{const d=Z({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(J,{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:d.noDataMessage})})})})});const i=t.permissionsFlags||{canViewAccount:!0,canViewAddress:!0,canViewContacts:!0,canViewPaymentInformation:!0,canViewShippingInformation:!0},r=[i.canViewAccount?{name:"name",label:d.companyName,value:t.name||"",legalName:t.legalName||""}:null,i.canViewAccount?{name:"email",label:d.email,value:t.email||""}:null,i.canViewAccount?{name:"vatTaxId",label:d.vatTaxId,value:t.vatTaxId||""}:null,i.canViewAccount?{name:"resellerId",label:d.resellerId,value:t.resellerId||""}:null].filter(Boolean);return a(J,{variant:"secondary",className:ee(["account-company-profile-card",["account-company-profile-card-short",n]]),children:y("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:d.editButton})}),a("div",{className:"account-company-profile-card__content",children:(()=>{var A,l;const v=y(K,{children:[r.map((s,c)=>{if(!s.value)return null;let C;return s.name==="name"&&s.legalName?C=`${s.label}: ${s.value} (${s.legalName})`:C=s.label?`${s.label}: ${s.value}`:s.value,a("p",{"data-testid":`${s.name}_${c}`,children:C},`${s.name}_${c}`)}),i.canViewAddress&&t.legalAddress&&y("div",{className:"company-legal-address",children:[a("p",{children:y("strong",{children:[d.legalAddress,":"]})}),(A=t.legalAddress.street)==null?void 0:A.map((s,c)=>a("p",{children:s},c)),y("p",{children:[t.legalAddress.city,", ",(l=t.legalAddress.region)==null?void 0:l.region," ",t.legalAddress.postcode]}),a("p",{children:t.legalAddress.countryCode}),t.legalAddress.telephone&&y("p",{children:["Phone: ",t.legalAddress.telephone]})]}),i.canViewContacts&&(t.companyAdmin||t.salesRepresentative)&&y("div",{className:"company-contacts",children:[a("p",{children:y("strong",{children:[d.contacts,":"]})}),t.companyAdmin&&y("div",{className:"company-contact",children:[a("p",{children:y("strong",{children:[d.companyAdministrator,":"]})}),y("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&&y("div",{className:"company-contact",children:[a("p",{children:y("strong",{children:[d.salesRepresentative,":"]})}),y("p",{children:[t.salesRepresentative.firstname," ",t.salesRepresentative.lastname]}),a("p",{children:t.salesRepresentative.email})]})]}),i.canViewPaymentInformation&&y("div",{className:"company-payment-methods",children:[a("p",{children:y("strong",{children:[d.paymentInformation,":"]})}),t.availablePaymentMethods&&t.availablePaymentMethods.length>0?y(K,{children:[a("p",{children:y("strong",{children:[d.availablePaymentMethods,":"]})}),a("ul",{className:"payment-methods-list",children:t.availablePaymentMethods.map((s,c)=>a("li",{children:s.title},`payment_${c}`))})]}):a("div",{className:"message message-notice notice",children:a("div",{children:d.noPaymentMethods})})]}),i.canViewShippingInformation&&y("div",{className:"company-shipping-methods",children:[a("p",{children:y("strong",{children:[d.shippingInformation,":"]})}),t.availableShippingMethods&&t.availableShippingMethods.length>0?y(K,{children:[a("p",{children:y("strong",{children:[d.availableShippingMethods,":"]})}),a("ul",{className:"shipping-methods-list",children:t.availableShippingMethods.map((s,c)=>a("li",{children:s.title},`shipping_${c}`))})]}):a("div",{className:"message message-notice notice",children:a("div",{children:d.noShippingMethods})})]})]});return e!=null&&e.CompanyData?a(ve,{name:"CompanyData",slot:e.CompanyData,context:{companyData:r,Default:v}}):v})()})]})})},we=t=>{const[e,n]=M(null),[u,d]=M(!0);B(()=>{let l=!0;return fe().then(({availableCountries:s,countriesWithRequiredRegion:c,optionalZipCountries:C})=>{l&&(n({availableCountries:s,countriesWithRequiredRegion:c,optionalZipCountries:C}),d(!1))}).catch(()=>{l&&d(!1)}),()=>{l=!1}},[]);const i=U(()=>(e==null?void 0:e.availableCountries)||[],[e]),r=U(()=>{if(!t||!e)return[];const l=e.availableCountries.find(s=>s.value===t);return!(l!=null&&l.availableRegions)||l.availableRegions.length===0?[]:l.availableRegions.map(s=>({text:s.name,value:`${s.code},${s.id}`}))},[t,e]),v=U(()=>!t||!e?!1:e.countriesWithRequiredRegion.includes(t),[t,e]),A=U(()=>r.length>0,[r]);return{countryOptions:i,regionOptions:r,isRegionRequired:v,hasRegionOptions:A,loadingCountries:u}},xe=({loading:t,value:e,errors:n,touched:u,onBlur:d,namePrefix:i="",fieldPathPrefix:r=""})=>{const v=Z({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"}),A=i?`${i}_`:"",l=s=>r?`${r}.${s}`:s;return y("div",{className:"account-edit-company-profile-form__group",children:[a(S,{label:v.companyName,required:!0,className:"account-edit-company-profile-form__field",error:u.name&&n.name?n.name:void 0,children:a(F,{name:`${A}name`,type:"text",value:e.name,onBlur:s=>{const c=s.target;d(l("name"),c.value)},disabled:!!t,variant:"primary",size:"medium",maxLength:40})}),a(S,{label:v.legalName,className:"account-edit-company-profile-form__field",children:a(F,{name:`${A}legalName`,type:"text",value:e.legalName,onBlur:s=>{const c=s.target;d(l("legalName"),c.value)},disabled:!!t,variant:"primary",size:"medium",maxLength:80})}),a(S,{label:v.email,required:!0,className:"account-edit-company-profile-form__field",error:u.email&&n.email?n.email:void 0,children:a(F,{name:`${A}email`,type:"email",value:e.email,onBlur:s=>{const c=s.target;d(l("email"),c.value)},disabled:!!t,variant:"primary",size:"medium"})}),a(S,{label:v.vatTaxId,className:"account-edit-company-profile-form__field",children:a(F,{name:`${A}vatTaxId`,type:"text",value:e.vatTaxId,onBlur:s=>{const c=s.target;d(l("vatTaxId"),c.value)},disabled:!!t,variant:"primary",size:"medium",maxLength:40})}),a(S,{label:v.resellerId,className:"account-edit-company-profile-form__field",children:a(F,{name:`${A}resellerId`,type:"text",value:e.resellerId,onBlur:s=>{const c=s.target;d(l("resellerId"),c.value)},disabled:!!t,variant:"primary",size:"medium",maxLength:40})})]})},Te=({loading:t,loadingCountries:e,value:n,errors:u,touched:d,onChange:i,onBlur:r,countryOptions:v,regionOptions:A,isRegionRequired:l,hasRegionOptions:s,namePrefix:c="legalAddress",fieldPathPrefix:C="legalAddress",requiredConfig:N})=>{var D;const b=Z({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"}),k={street:`${c}_street`,street2:`${c}_street2`,city:`${c}_city`,countryCode:`${c}_countryCode`,region:`${c}_region`,postcode:`${c}_postcode`,telephone:`${c}_telephone`},h={street:`${C}.street`,street2:`${C}.street2`,city:`${C}.city`,countryCode:`${C}.countryCode`,region:`${C}.region`,regionCode:`${C}.regionCode`,postcode:`${C}.postcode`,telephone:`${C}.telephone`},z={street:(N==null?void 0:N.street)??!0,city:(N==null?void 0:N.city)??!0,postcode:(N==null?void 0:N.postcode)??!0,telephone:(N==null?void 0:N.telephone)??!0};return y("div",{className:"account-edit-company-profile-form__section",children:[a("h3",{className:"account-edit-company-profile-form__section-title",children:b.legalAddress}),a(S,{label:b.streetAddress,required:z.street,className:"account-edit-company-profile-form__field",error:d[h.street]&&u[h.street]?u[h.street]:void 0,children:a(F,{name:k.street,type:"text",value:n.street,onBlur:p=>{const E=p.target;r(h.street,E.value)},disabled:!!t,variant:"primary",size:"medium"})}),a(S,{label:`${b.streetAddress} 2`,className:"account-edit-company-profile-form__field",children:a(F,{name:k.street2,type:"text",value:n.street2,onBlur:p=>{const E=p.target;r(h.street2,E.value)},disabled:!!t,variant:"primary",size:"medium"})}),a(S,{label:b.city,required:z.city,className:"account-edit-company-profile-form__field",error:d[h.city]&&u[h.city]?u[h.city]:void 0,children:a(F,{name:k.city,type:"text",value:n.city,onBlur:p=>{const E=p.target;r(h.city,E.value)},disabled:!!t,variant:"primary",size:"medium"})}),a(S,{label:b.country,required:!0,className:"account-edit-company-profile-form__field",error:d[h.countryCode]&&u[h.countryCode]?u[h.countryCode]:void 0,children:a(pe,{name:k.countryCode,floatingLabel:`${b.country} *`,placeholder:b.country,options:v,value:n.countryCode,handleSelect:p=>{const E=p.target;i(h.countryCode)(E.value)},onBlur:()=>r(h.countryCode),disabled:!!t||e})}),a(S,{label:b.stateProvince,required:l,className:"account-edit-company-profile-form__field",error:d["legalAddress.region"]&&u["legalAddress.region"]?u["legalAddress.region"]:void 0,children:s?a(pe,{name:"legalAddress_region",floatingLabel:`${b.stateProvince} ${l?"*":""}`,placeholder:b.stateProvince,options:A,value:n.regionCode&&((D=A.find(p=>p.value.split(",")[0]===n.regionCode))==null?void 0:D.value)||"",handleSelect:p=>{var P;const E=p.target,[W]=E.value.split(","),O=((P=A.find(H=>H.value===E.value))==null?void 0:P.text)||"";i(h.region)(O),i(h.regionCode)(W)},onBlur:()=>r(h.region),disabled:!!t||e},`region_picker_${n.countryCode}`):a(F,{name:k.region,type:"text",value:n.region,onBlur:p=>{const E=p.target;r(h.region,E.value)},disabled:!!t||e,variant:"primary",size:"medium"},`region_input_${n.countryCode}`)}),a(S,{label:b.zipPostalCode,required:z.postcode,className:"account-edit-company-profile-form__field",error:d[h.postcode]&&u[h.postcode]?u[h.postcode]:void 0,children:a(F,{name:k.postcode,type:"text",value:n.postcode,onBlur:p=>{const E=p.target;r(h.postcode,E.value)},disabled:!!t,variant:"primary",size:"medium"})}),a(S,{label:b.phoneNumber,required:z.telephone,className:"account-edit-company-profile-form__field",error:d[h.telephone]&&u[h.telephone]?u[h.telephone]:void 0,children:a(F,{name:k.telephone,type:"tel",value:n.telephone,onBlur:p=>{const E=p.target;r(h.telephone,E.value)},disabled:!!t,variant:"primary",size:"medium"})})]})},$e=({inLineAlertProps:t,company:e,loading:n=!1,onSubmit:u,onCancel:d})=>{var j,Y,q,f,T,te,ae,re,se,le,ne,oe,ie,de;const i=Z({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",companyNameLengthError:"Company.shared.validation.companyNameLengthError",legalNameLengthError:"Company.shared.validation.legalNameLengthError",vatTaxIdLengthError:"Company.shared.validation.vatTaxIdLengthError",resellerIdLengthError:"Company.shared.validation.resellerIdLengthError"}),[r,v]=M({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:((Y=(j=e==null?void 0:e.legalAddress)==null?void 0:j.street)==null?void 0:Y[0])||"",street2:((f=(q=e==null?void 0:e.legalAddress)==null?void 0:q.street)==null?void 0:f[1])||"",city:((T=e==null?void 0:e.legalAddress)==null?void 0:T.city)||"",region:((ae=(te=e==null?void 0:e.legalAddress)==null?void 0:te.region)==null?void 0:ae.region)||"",regionCode:((se=(re=e==null?void 0:e.legalAddress)==null?void 0:re.region)==null?void 0:se.regionCode)||"",countryCode:((le=e==null?void 0:e.legalAddress)==null?void 0:le.countryCode)||"",postcode:((ne=e==null?void 0:e.legalAddress)==null?void 0:ne.postcode)||"",telephone:((oe=e==null?void 0:e.legalAddress)==null?void 0:oe.telephone)||""}}),[A,l]=M({}),[s,c]=M({}),C=((ie=e==null?void 0:e.permissionsFlags)==null?void 0:ie.canEditAccount)===!0,N=((de=e==null?void 0:e.permissionsFlags)==null?void 0:de.canEditAddress)===!0,{countryOptions:b,regionOptions:k,isRegionRequired:h,hasRegionOptions:z,loadingCountries:D}=we(r.legalAddress.countryCode),p=(o,m)=>o==="name"?m.trim()?m.length>40?i.companyNameLengthError:null:i.companyNameRequired:o==="email"?m.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m)?null:i.invalidEmail:i.emailRequired:o==="legalName"?m.length>80?i.legalNameLengthError:null:o==="vatTaxId"?m.length>40?i.vatTaxIdLengthError:null:o==="resellerId"?m.length>40?i.resellerIdLengthError:null:o==="legalAddress.street"||o==="legalAddress.city"||o==="legalAddress.postcode"||o==="legalAddress.telephone"||o==="legalAddress.countryCode"?m.trim()?null:i.required:o==="legalAddress.region"&&h&&!m.trim()?i.required:null,E=()=>{var $,V;const o={};let m=!0;const x=(($=e==null?void 0:e.permissionsFlags)==null?void 0:$.canEditAccount)===!0,g=((V=e==null?void 0:e.permissionsFlags)==null?void 0:V.canEditAddress)===!0;if(x){const _=p("name",r.name);_&&(o.name=_,m=!1);const I=p("email",r.email);if(I&&(o.email=I,m=!1),r.legalName){const w=p("legalName",r.legalName);w&&(o.legalName=w,m=!1)}if(r.vatTaxId){const w=p("vatTaxId",r.vatTaxId);w&&(o.vatTaxId=w,m=!1)}if(r.resellerId){const w=p("resellerId",r.resellerId);w&&(o.resellerId=w,m=!1)}}if(g){const _=p("legalAddress.street",r.legalAddress.street);_&&(o["legalAddress.street"]=_,m=!1);const I=p("legalAddress.city",r.legalAddress.city);I&&(o["legalAddress.city"]=I,m=!1);const w=p("legalAddress.postcode",r.legalAddress.postcode);w&&(o["legalAddress.postcode"]=w,m=!1);const ce=p("legalAddress.telephone",r.legalAddress.telephone);ce&&(o["legalAddress.telephone"]=ce,m=!1);const me=p("legalAddress.countryCode",r.legalAddress.countryCode);me&&(o["legalAddress.countryCode"]=me,m=!1);const ue=p("legalAddress.region",r.legalAddress.region);ue&&(o["legalAddress.region"]=ue,m=!1)}return l(o),m},W=async o=>{var $,V;o.preventDefault();const m=(($=e==null?void 0:e.permissionsFlags)==null?void 0:$.canEditAccount)===!0,x=((V=e==null?void 0:e.permissionsFlags)==null?void 0:V.canEditAddress)===!0,g={};if(m&&(g.name=!0,g.email=!0,g.legalName=!0,g.vatTaxId=!0,g.resellerId=!0),x&&(g["legalAddress.street"]=!0,g["legalAddress.street2"]=!0,g["legalAddress.city"]=!0,g["legalAddress.region"]=!0,g["legalAddress.regionCode"]=!0,g["legalAddress.countryCode"]=!0,g["legalAddress.postcode"]=!0,g["legalAddress.telephone"]=!0),c(g),!!E()){if(m&&r.email!==(e==null?void 0:e.email)){const _=await Ee(r.email);if(!_.isValid){l(I=>({...I,email:_.error||i.emailNotAvailable}));return}}if(u){const _={};m&&(_.name=r.name,_.email=r.email,_.legalName=r.legalName,_.vatTaxId=r.vatTaxId,_.resellerId=r.resellerId),x&&(_.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(_)}}},O=(o,m)=>{if(o.startsWith("legalAddress.")){const x=o.split(".")[1];x==="countryCode"?(v(g=>({...g,legalAddress:{...g.legalAddress,[x]:m,region:"",regionCode:""}})),l(g=>{const $={...g};return delete $["legalAddress.region"],delete $["legalAddress.regionCode"],$}),c(g=>{const $={...g};return delete $["legalAddress.region"],delete $["legalAddress.regionCode"],$})):v(x==="region"?g=>({...g,legalAddress:{...g.legalAddress,region:m,regionCode:z?g.legalAddress.regionCode:m}}):g=>({...g,legalAddress:{...g.legalAddress,[x]:m}}))}else v(x=>({...x,[o]:m}))},P=o=>m=>{const x=new Set(["name","email","legalName","vatTaxId","resellerId"]),g=o.startsWith("legalAddress.");x.has(o)&&!C||g&&!N||(O(o,m),A[o]&&l(V=>{const _={...V};return delete _[o],_}))},H=(o,m)=>{const x=new Set(["name","email","legalName","vatTaxId","resellerId"]),g=o.startsWith("legalAddress.");if(x.has(o)&&!C||g&&!N)return;m!==void 0&&O(o,m),c(I=>({...I,[o]:!0}));let V=m;if(V===void 0)if(o.startsWith("legalAddress.")){const I=o.split(".")[1],w=r.legalAddress[I];V=typeof w=="string"?w:""}else{const I=r[o];V=typeof I=="string"?I:""}const _=p(o,V);l(_?I=>({...I,[o]:_}):I=>{const w={...I};return delete w[o],w})};return y(J,{variant:"secondary",className:"account-edit-company-profile",children:[a(he,{title:i.title,divider:!1,className:"account-edit-company-profile__title"}),t!=null&&t.text?a(Ce,{className:"account-edit-company-profile__notification",type:t.type,variant:"secondary",heading:t.text,icon:t.icon,"data-testid":"editCompanyInLineAlert"}):null,y("form",{className:"account-edit-company-profile-form",onSubmit:W,children:[C&&a(xe,{loading:n,value:{name:r.name,email:r.email,legalName:r.legalName,vatTaxId:r.vatTaxId,resellerId:r.resellerId},errors:A,touched:s,onBlur:H}),N&&a(Te,{loading:n,loadingCountries:D,value:r.legalAddress,errors:A,touched:s,onChange:P,onBlur:H,countryOptions:b,regionOptions:k,isRegionRequired:h,hasRegionOptions:z}),y("div",{className:"account-edit-company-profile__actions",children:[a(X,{disabled:n,type:"button",variant:"secondary",onClick:()=>d==null?void 0:d(),children:i.cancel}),a(X,{disabled:n||!C&&!N,type:"submit",variant:"primary",children:i.save})]})]}),n&&y("div",{className:"account-edit-company-profile__loading-overlay","data-testid":"editCompanyLoadingOverlay",children:[a(Ae,{size:"large"}),a("div",{className:"account-edit-company-profile__loading-text",children:i.saving})]})]})},Le=({testId:t,withCard:e=!0})=>{const n=y(Ne,{"data-testid":t||"companySkeletonLoader",children:[a(Q,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(Q,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(Q,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return e?n:a(J,{variant:"secondary",className:ee(["company-company-loaders","company-company-loaders--card-loader"]),children:n})};var ye=(t=>(t.EDIT_COMPANY_EVENT="edit-company",t))(ye||{});const Me={EDIT_COMPANY_EVENT:"edit-company"},Pe=()=>(window.adobeDataLayer||(window.adobeDataLayer=[]),window.adobeDataLayer),Ve=t=>{Pe().push(n=>{const u=n.getState?n.getState():{};n.push({event:t,context:u})})},Se=(t,e)=>{if(!Me[t])return null;switch(t){case"edit-company":Ve({type:"company",eventType:"edit",companyData:e});break;default:return null}},ke=({handleSetInLineAlert:t,editFormRef:e})=>{const n=Z({companySuccess:"Company.CompanyProfile.editCompanyProfile.companySuccess",companyError:"Company.CompanyProfile.editCompanyProfile.companyError",loadError:"Company.CompanyProfile.messages.loadError",updateError:"Company.CompanyProfile.messages.updateError"}),{companySuccess:u,companyError:d,loadError:i,updateError:r}=n,[v,A]=M(null),[l,s]=M(!0),[c,C]=M(!1),[N,b]=M(!1),[k,h]=M([]),[z,D]=M({}),p=G(t),E=G(!1),W=G(!1);B(()=>{p.current=t},[t]);const O=R(f=>{D(f)},[]),P=R((f,T)=>{t&&(f==="success"?t({type:"success",text:T??u}):f==="error"?t({type:"error",text:T??d}):t(),C(!1))},[t,u,d]),H=R(async()=>{if(E.current)return null;E.current=!0,s(!0);try{const f=await _e();return f&&A(f),s(!1),f}catch(f){return console.error("Failed to load company:",f),s(!1),p.current&&p.current({type:"error",text:i}),null}finally{E.current=!1}},[i]);B(()=>{W.current||(W.current=!0,H())},[H]),B(()=>{const f=()=>{s(!0),b(!1),D({}),H()},T=ge.on("companyContext/changed",f,{eager:!0});return()=>{T==null||T.off()}},[H]),B(()=>{fe().then(f=>{h(f.availableCountries)}).catch(f=>{console.error("Failed to load countries:",f)})},[]);const j=R(()=>{b(!0),P("success",""),D({})},[P]);B(()=>{N&&(e!=null&&e.current)&&setTimeout(()=>{var f;(f=e.current)==null||f.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},100)},[N,e]);const Y=R(f=>{f==null||f(),b(!1),D({})},[]),q=R(async f=>{try{if(C(!0),!f){P("error","No data to update");return}const T=await be(f);A(T),b(!1),D({}),P("success"),Se(ye.EDIT_COMPANY_EVENT,{...f,companyId:v==null?void 0:v.id}),ge.emit("company/updated",{company:T})}catch(T){console.error("Failed to update company:",T),P("error",T.message||r)}finally{C(!1)}},[v,P,r]);return{company:v,countries:k,loading:l,submitLoading:c,showEditForm:N,inputChange:z,handleShowEditForm:j,handleHideEditForm:Y,handleUpdateCompany:q,handleInputChange:O,renderAlertMessage:P,saving:c}},Fe=t=>L.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},L.createElement("g",{clipPath:"url(#clip0_841_1324)"},L.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),L.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"})),L.createElement("defs",null,L.createElement("clipPath",{id:"clip0_841_1324"},L.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),Re=t=>L.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},L.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"}),L.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),De=t=>L.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},L.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"}),L.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"})),ze={success:a(Re,{}),warning:a(Fe,{}),error:a(De,{})},He=()=>{const[t,e]=M({}),[n,u]=M(null),d=R(()=>{e({}),n&&(clearTimeout(n),u(null))},[n]),i=R(l=>{if(n&&(clearTimeout(n),u(null)),!(l!=null&&l.type)){e({});return}const s=ze[l.type];if(e({type:l.type,text:l.text,icon:s}),l.autoHide!==!1){const c=l.autoHideDelay||(l.type==="success"?3e3:5e3),C=setTimeout(()=>{e({}),u(null)},c);u(C)}},[n]),r=R((l,s=!0)=>{i({type:"success",text:l,autoHide:s})},[i]),v=R((l,s=!1)=>{i({type:"warning",text:l,autoHide:s})},[i]),A=R((l,s=!1)=>{i({type:"error",text:l,autoHide:s})},[i]);return B(()=>()=>{n&&clearTimeout(n)},[n]),{inLineAlertProps:t,handleSetInLineAlert:i,clearAlert:d,showSuccess:r,showWarning:v,showError:A}},Ge=({className:t,withHeader:e=!0,slots:n})=>{const u=Z({containerTitle:"Company.CompanyProfile.containerTitle"}),{inLineAlertProps:d,handleSetInLineAlert:i}=He(),r=G(null),{company:v,loading:A,saving:l,showEditForm:s,handleShowEditForm:c,handleHideEditForm:C,handleUpdateCompany:N}=ke({handleSetInLineAlert:i,editFormRef:r});return A?a("div",{"data-testid":"companyProfileLoader",children:a(Le,{withCard:!0})}):y("div",{className:ee(["account-company-profile",t]),children:[e?a(he,{title:u.containerTitle,divider:!1,className:"company-profile__title"}):null,a(Ie,{company:v,slots:n,showEditForm:s,handleShowEditForm:c}),s?a("div",{ref:r,children:a($e,{inLineAlertProps:d,company:v,loading:l,onSubmit:N,onCancel:C})}):null]})};export{Ge as CompanyProfile,Ge as default};
|
|
4
4
|
//# sourceMappingURL=CompanyProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompanyProfile.js","sources":["/@dropins/storefront-company-management/src/components/CompanyProfileCard/CompanyProfileCard.tsx","/@dropins/storefront-company-management/src/hooks/useCountries.ts","/@dropins/storefront-company-management/src/components/EditCompanyProfile/CompanyAccountFields.tsx","/@dropins/storefront-company-management/src/components/EditCompanyProfile/LegalAddressFields.tsx","/@dropins/storefront-company-management/src/components/EditCompanyProfile/EditCompanyProfile.tsx","/@dropins/storefront-company-management/src/components/CompanyLoaders/CompanyLoaders.tsx","/@dropins/storefront-company-management/src/lib/acdl.ts","/@dropins/storefront-company-management/src/hooks/containers/useCompanyProfile.tsx","../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg","../../node_modules/@adobe-commerce/elsie/src/icons/WarningWithCircle.svg","/@dropins/storefront-company-management/src/hooks/useInLineAlert.tsx","/@dropins/storefront-company-management/src/containers/CompanyProfile/CompanyProfile.tsx"],"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 *******************************************************************/\nimport { FunctionComponent } from 'preact';\nimport { Card, Button } from '@adobe-commerce/elsie/components';\nimport { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { CompanyProfileCardProps } from '../../types/companyProfile.types';\nimport './CompanyProfileCard.css';\n\nexport const CompanyProfileCard: FunctionComponent<CompanyProfileCardProps> = ({\n company,\n slots,\n showEditForm,\n handleShowEditForm,\n}) => {\n const translations = useText({\n editButton: 'Company.shared.buttons.edit',\n noDataMessage: 'Company.CompanyProfile.companyProfileCard.noDataMessage',\n companyName: 'Company.shared.fields.companyName',\n email: 'Company.shared.fields.email',\n legalName: 'Company.shared.fields.legalName',\n vatTaxId: 'Company.shared.fields.vatTaxId',\n resellerId: 'Company.shared.fields.resellerId',\n legalAddress: 'Company.shared.fields.legalAddress',\n contacts: 'Company.CompanyProfile.companyProfileCard.contacts',\n companyAdministrator: 'Company.CompanyProfile.companyProfileCard.companyAdministrator',\n salesRepresentative: 'Company.CompanyProfile.companyProfileCard.salesRepresentative',\n paymentInformation: 'Company.CompanyProfile.companyProfileCard.paymentInformation',\n shippingInformation: 'Company.CompanyProfile.companyProfileCard.shippingInformation',\n availablePaymentMethods: 'Company.CompanyProfile.companyProfileCard.availablePaymentMethods',\n availableShippingMethods: 'Company.CompanyProfile.companyProfileCard.availableShippingMethods',\n noPaymentMethods: 'Company.CompanyProfile.companyProfileCard.noPaymentMethods',\n noShippingMethods: 'Company.CompanyProfile.companyProfileCard.noShippingMethods',\n });\n \n if (!company) {\n return (\n <Card variant=\"secondary\" className=\"account-company-profile-card\">\n <div className=\"account-company-profile-card__wrapper\">\n <div className=\"account-company-profile-card__content\">\n <div className=\"account-company-profile-card__no-data\">\n <p>{translations.noDataMessage}</p>\n </div>\n </div>\n </div>\n </Card>\n );\n }\n\n const perms = company.permissionsFlags || {\n canViewAccount: true,\n canEditAccount: false,\n canViewAddress: true,\n canEditAddress: false,\n canViewContacts: true,\n canViewPaymentInformation: true,\n canViewShippingInformation: true,\n };\n\n const companyData = [\n perms.canViewAccount ? { name: 'name', label: translations.companyName, value: company.name || '' } : null,\n perms.canViewAccount ? { name: 'email', label: translations.email, value: company.email || '' } : null,\n perms.canViewAccount ? { name: 'legalName', label: translations.legalName, value: company.legalName || '' } : null,\n perms.canViewAccount ? { name: 'vatTaxId', label: translations.vatTaxId, value: company.vatTaxId || '' } : null,\n perms.canViewAccount ? { name: 'resellerId', label: translations.resellerId, value: company.resellerId || '' } : null,\n ].filter(Boolean) as { name: string; label: string; value: string }[];\n\n return (\n <Card\n variant=\"secondary\"\n className={classes([\n 'account-company-profile-card',\n [\n 'account-company-profile-card-short',\n showEditForm,\n ],\n ])}\n >\n <div className=\"account-company-profile-card__wrapper\">\n <div className=\"account-company-profile-card__actions\">\n {(company.canEditAccount || company.canEditAddress) && (\n <Button\n // @ts-ignore\n type=\"button\"\n variant=\"tertiary\"\n onClick={handleShowEditForm}\n >\n {translations.editButton}\n </Button>\n )}\n </div>\n <div className=\"account-company-profile-card__content\">\n {(() => {\n const Default = (\n <>\n {companyData.map((el, index) => {\n if (!el.value) return null;\n const value = !el.label\n ? el.value\n : `${el.label}: ${el.value}`;\n\n return (\n <p\n key={`${el.name}_${index}`}\n data-testid={`${el.name}_${index}`}\n >\n {value}\n </p>\n );\n })}\n\n {perms.canViewAddress && company.legalAddress && (\n <div className=\"company-legal-address\">\n <p><strong>{translations.legalAddress}:</strong></p>\n {company.legalAddress.street?.map((line: string, i: number) => (\n <p key={i}>{line}</p>\n ))}\n <p>\n {company.legalAddress.city}, {company.legalAddress.region?.region} {company.legalAddress.postcode}\n </p>\n <p>{company.legalAddress.countryCode}</p>\n {company.legalAddress.telephone && (\n <p>Phone: {company.legalAddress.telephone}</p>\n )}\n </div>\n )}\n\n {perms.canViewContacts && (company.companyAdmin || company.salesRepresentative) && (\n <div className=\"company-contacts\">\n <p><strong>{translations.contacts}:</strong></p>\n \n {company.companyAdmin && (\n <div className=\"company-contact\">\n <p><strong>{translations.companyAdministrator}:</strong></p>\n <p>{company.companyAdmin.firstname} {company.companyAdmin.lastname}</p>\n {company.companyAdmin.jobTitle && <p>{company.companyAdmin.jobTitle}</p>}\n <p>{company.companyAdmin.email}</p>\n </div>\n )}\n\n {company.salesRepresentative && (\n <div className=\"company-contact\">\n <p><strong>{translations.salesRepresentative}:</strong></p>\n <p>{company.salesRepresentative.firstname} {company.salesRepresentative.lastname}</p>\n <p>{company.salesRepresentative.email}</p>\n </div>\n )}\n </div>\n )}\n\n {perms.canViewPaymentInformation && (\n <div className=\"company-payment-methods\">\n <p><strong>{translations.paymentInformation}:</strong></p>\n {company.availablePaymentMethods && company.availablePaymentMethods.length > 0 ? (\n <>\n <p><strong>{translations.availablePaymentMethods}:</strong></p>\n <ul className=\"payment-methods-list\">\n {company.availablePaymentMethods.map((m, index) => (\n <li key={`payment_${index}`}>{m.title}</li>\n ))}\n </ul>\n </>\n ) : (\n <div className=\"message message-notice notice\">\n <div>{translations.noPaymentMethods}</div>\n </div>\n )}\n </div>\n )}\n\n {perms.canViewShippingInformation && (\n <div className=\"company-shipping-methods\">\n <p><strong>{translations.shippingInformation}:</strong></p>\n {company.availableShippingMethods && company.availableShippingMethods.length > 0 ? (\n <>\n <p><strong>{translations.availableShippingMethods}:</strong></p>\n <ul className=\"shipping-methods-list\">\n {company.availableShippingMethods.map((m, index) => (\n <li key={`shipping_${index}`}>{m.title}</li>\n ))}\n </ul>\n </>\n ) : (\n <div className=\"message message-notice notice\">\n <div>{translations.noShippingMethods}</div>\n </div>\n )}\n </div>\n )}\n </>\n );\n if (slots?.CompanyData) {\n return (\n <Slot name=\"CompanyData\" slot={slots.CompanyData} context={{ companyData, Default }} />\n );\n }\n return Default;\n })()}\n </div>\n </div>\n </Card>\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 { useEffect, useMemo, useState } from 'preact/hooks';\nimport { getCountries } from '../api';\nimport type { Country } from '../data/models';\n\ninterface UseCountriesResult {\n countryOptions: Country[];\n regionOptions: { text: string; value: string }[];\n isRegionRequired: boolean;\n hasRegionOptions: boolean;\n loadingCountries: boolean;\n}\n\nexport const useCountries = (selectedCountryCode: string | undefined): UseCountriesResult => {\n const [countriesData, setCountriesData] = useState<{\n availableCountries: Country[];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n } | null>(null);\n const [loadingCountries, setLoadingCountries] = useState<boolean>(true);\n\n useEffect(() => {\n let isMounted = true;\n getCountries()\n .then(({ availableCountries, countriesWithRequiredRegion, optionalZipCountries }) => {\n if (!isMounted) return;\n setCountriesData({ availableCountries, countriesWithRequiredRegion, optionalZipCountries });\n setLoadingCountries(false);\n })\n .catch(() => {\n if (!isMounted) return;\n setLoadingCountries(false);\n });\n return () => {\n isMounted = false;\n };\n }, []);\n\n const countryOptions = useMemo(() => {\n return countriesData?.availableCountries || [];\n }, [countriesData]);\n\n const regionOptions = useMemo(() => {\n if (!selectedCountryCode || !countriesData) return [] as { text: string; value: string }[];\n const selectedCountry = countriesData.availableCountries.find((country) => country.value === selectedCountryCode);\n if (!selectedCountry?.availableRegions || selectedCountry.availableRegions.length === 0) return [];\n return selectedCountry.availableRegions.map((region) => ({ text: region.name, value: `${region.code},${region.id}` }));\n }, [selectedCountryCode, countriesData]);\n\n const isRegionRequired = useMemo(() => {\n if (!selectedCountryCode || !countriesData) return false;\n return countriesData.countriesWithRequiredRegion.includes(selectedCountryCode);\n }, [selectedCountryCode, countriesData]);\n\n const hasRegionOptions = useMemo(() => regionOptions.length > 0, [regionOptions]);\n\n return {\n countryOptions,\n regionOptions,\n isRegionRequired,\n hasRegionOptions,\n loadingCountries,\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 *******************************************************************/\nimport { FunctionComponent } from 'preact';\nimport { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\ninterface CompanyAccountFieldsProps {\n loading?: boolean;\n value: {\n name: string;\n email: string;\n legalName: string;\n vatTaxId: string;\n resellerId: string;\n };\n errors: Record<string, string>;\n touched: Record<string, boolean>;\n onChange: (field: string) => (value: string) => void;\n onBlur: (field: string) => void;\n /** Optional input name prefix for DOM names (defaults to none) */\n namePrefix?: string;\n /** Optional field path prefix used for change/blur handlers (defaults to none) */\n fieldPathPrefix?: string;\n}\n\nexport const CompanyAccountFields: FunctionComponent<CompanyAccountFieldsProps> = ({\n loading,\n value,\n errors,\n touched,\n onChange,\n onBlur,\n namePrefix = '',\n fieldPathPrefix = '',\n}) => {\n const translations = useText({\n companyName: 'Company.shared.fields.companyName',\n email: 'Company.shared.fields.email',\n legalName: 'Company.shared.fields.legalName',\n vatTaxId: 'Company.shared.fields.vatTaxId',\n resellerId: 'Company.shared.fields.resellerId',\n });\n const prefix = namePrefix ? `${namePrefix}_` : '';\n const path = (f: string) => (fieldPathPrefix ? `${fieldPathPrefix}.${f}` : f);\n return (\n <div className=\"account-edit-company-profile-form__group\">\n <Field \n label={translations.companyName} \n required\n className=\"account-edit-company-profile-form__field\"\n error={touched.name && errors.name ? errors.name : undefined}\n >\n <Input\n name={`${prefix}name`}\n type=\"text\"\n value={value.name}\n onValue={onChange(path('name'))}\n onBlur={() => onBlur(path('name'))}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.email} \n required\n className=\"account-edit-company-profile-form__field\"\n error={touched.email && errors.email ? errors.email : undefined}\n >\n <Input\n name={`${prefix}email`}\n type=\"email\"\n value={value.email}\n onValue={onChange(path('email'))}\n onBlur={() => onBlur(path('email'))}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field label={translations.legalName} className=\"account-edit-company-profile-form__field\">\n <Input\n name={`${prefix}legalName`}\n type=\"text\"\n value={value.legalName}\n onValue={onChange(path('legalName'))}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field label={translations.vatTaxId} className=\"account-edit-company-profile-form__field\">\n <Input\n name={`${prefix}vatTaxId`}\n type=\"text\"\n value={value.vatTaxId}\n onValue={onChange(path('vatTaxId'))}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field label={translations.resellerId} className=\"account-edit-company-profile-form__field\">\n <Input\n name={`${prefix}resellerId`}\n type=\"text\"\n value={value.resellerId}\n onValue={onChange(path('resellerId'))}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n </div>\n );\n};\n\nexport default CompanyAccountFields;\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 { FunctionComponent } from 'preact';\nimport { Field, Input, Picker } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\ninterface LegalAddressFieldsProps {\n loading?: boolean;\n loadingCountries: boolean;\n value: {\n street: string;\n street2: string;\n city: string;\n region: string;\n regionCode: string;\n countryCode: string;\n postcode: string;\n telephone: string;\n };\n errors: Record<string, string>;\n touched: Record<string, boolean>;\n onChange: (field: string) => (value: string) => void;\n onBlur: (field: string) => void;\n countryOptions: { text: string; value: string }[];\n regionOptions: { text: string; value: string }[];\n isRegionRequired: boolean;\n hasRegionOptions: boolean;\n /**\n * Optional input name prefix for DOM names (defaults to 'legal_address')\n */\n namePrefix?: string;\n /**\n * Optional field path prefix used for change/blur handlers (defaults to 'legal_address')\n */\n fieldPathPrefix?: string;\n /**\n * Optional per-field required overrides for non-edit flows\n */\n requiredConfig?: Partial<{\n street: boolean;\n city: boolean;\n postcode: boolean;\n telephone: boolean;\n }>;\n}\n\nexport const LegalAddressFields: FunctionComponent<LegalAddressFieldsProps> = ({\n loading,\n loadingCountries,\n value,\n errors,\n touched,\n onChange,\n onBlur,\n countryOptions,\n regionOptions,\n isRegionRequired,\n hasRegionOptions,\n namePrefix = 'legalAddress',\n fieldPathPrefix = 'legalAddress',\n requiredConfig,\n}) => {\n const translations = useText({\n legalAddress: 'Company.shared.fields.legalAddress',\n streetAddress: 'Company.shared.fields.streetAddress',\n city: 'Company.shared.fields.city',\n country: 'Company.shared.fields.country',\n stateProvince: 'Company.shared.fields.stateProvince',\n zipPostalCode: 'Company.shared.fields.zipPostalCode',\n phoneNumber: 'Company.shared.fields.phoneNumber',\n });\n const names = {\n street: `${namePrefix}_street`,\n street2: `${namePrefix}_street2`,\n city: `${namePrefix}_city`,\n countryCode: `${namePrefix}_countryCode`,\n region: `${namePrefix}_region`,\n postcode: `${namePrefix}_postcode`,\n telephone: `${namePrefix}_telephone`,\n } as const;\n\n const paths = {\n street: `${fieldPathPrefix}.street`,\n street2: `${fieldPathPrefix}.street2`,\n city: `${fieldPathPrefix}.city`,\n countryCode: `${fieldPathPrefix}.countryCode`,\n region: `${fieldPathPrefix}.region`,\n regionCode: `${fieldPathPrefix}.regionCode`,\n postcode: `${fieldPathPrefix}.postcode`,\n telephone: `${fieldPathPrefix}.telephone`,\n } as const;\n\n const isRequired = {\n street: requiredConfig?.street ?? true,\n city: requiredConfig?.city ?? true,\n postcode: requiredConfig?.postcode ?? true,\n telephone: requiredConfig?.telephone ?? true,\n } as const;\n\n return (\n <div className=\"account-edit-company-profile-form__section\">\n <h3 className=\"account-edit-company-profile-form__section-title\">{translations.legalAddress}</h3>\n\n <Field \n label={translations.streetAddress} \n required={isRequired.street}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.street] && errors[paths.street] ? errors[paths.street] : undefined}\n >\n <Input\n name={names.street}\n type=\"text\"\n value={value.street}\n onValue={onChange(paths.street)}\n onBlur={() => onBlur(paths.street)}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={`${translations.streetAddress} 2`} \n className=\"account-edit-company-profile-form__field\"\n >\n <Input\n name={names.street2}\n type=\"text\"\n value={value.street2}\n onValue={onChange(paths.street2)}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.city} \n required={isRequired.city}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.city] && errors[paths.city] ? errors[paths.city] : undefined}\n >\n <Input\n name={names.city}\n type=\"text\"\n value={value.city}\n onValue={onChange(paths.city)}\n onBlur={() => onBlur(paths.city)}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.country} \n required\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.countryCode] && errors[paths.countryCode] ? errors[paths.countryCode] : undefined}\n >\n <Picker\n name={names.countryCode}\n floatingLabel={`${translations.country} *`}\n placeholder={translations.country}\n options={countryOptions}\n value={value.countryCode}\n handleSelect={(event: Event) => {\n const target = event.target as HTMLSelectElement;\n onChange(paths.countryCode)(target.value);\n }}\n onBlur={() => onBlur(paths.countryCode)}\n disabled={!!loading || loadingCountries}\n />\n </Field>\n\n <Field \n label={translations.stateProvince} \n required={isRegionRequired}\n className=\"account-edit-company-profile-form__field\"\n error={touched['legalAddress.region'] && errors['legalAddress.region'] ? errors['legalAddress.region'] : undefined}\n >\n {hasRegionOptions ? (\n <Picker\n key={`region_picker_${value.countryCode}`}\n name=\"legalAddress_region\"\n floatingLabel={`${translations.stateProvince} ${isRegionRequired ? '*' : ''}`}\n placeholder={translations.stateProvince}\n options={regionOptions}\n value={value.regionCode ? (regionOptions.find(r => r.value.split(',')[0] === value.regionCode)?.value || '') : ''}\n handleSelect={(event: Event) => {\n const target = event.target as HTMLSelectElement;\n const [regionCode] = target.value.split(',');\n const regionName = regionOptions.find(r => r.value === target.value)?.text || '';\n onChange(paths.region)(regionName);\n onChange(paths.regionCode)(regionCode);\n }}\n onBlur={() => onBlur(paths.region)}\n disabled={!!loading || loadingCountries}\n />\n ) : (\n <Input\n key={`region_input_${value.countryCode}`}\n name={names.region}\n type=\"text\"\n value={value.region}\n onValue={onChange(paths.region)}\n onBlur={() => onBlur(paths.region)}\n disabled={!!loading || loadingCountries}\n variant=\"primary\"\n size=\"medium\"\n />\n )}\n </Field>\n\n <Field \n label={translations.zipPostalCode} \n required={isRequired.postcode}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.postcode] && errors[paths.postcode] ? errors[paths.postcode] : undefined}\n >\n <Input\n name={names.postcode}\n type=\"text\"\n value={value.postcode}\n onValue={onChange(paths.postcode)}\n onBlur={() => onBlur(paths.postcode)}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.phoneNumber} \n required={isRequired.telephone}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.telephone] && errors[paths.telephone] ? errors[paths.telephone] : undefined}\n >\n <Input\n name={names.telephone}\n type=\"tel\"\n value={value.telephone}\n onValue={onChange(paths.telephone)}\n onBlur={() => onBlur(paths.telephone)}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n </div>\n );\n};\n\nexport default LegalAddressFields;\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 { FunctionComponent } from 'preact';\nimport { useState } from 'preact/hooks';\nimport {\n Button,\n Card,\n Header,\n InLineAlert,\n ProgressSpinner,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { validateCompanyEmail } from '../../api';\nimport { EditCompanyProfileProps } from '../../types/companyProfile.types';\nimport './EditCompanyProfile.css';\nimport { useCountries } from '../../hooks/useCountries';\nimport { CompanyAccountFields } from './CompanyAccountFields';\nimport { LegalAddressFields } from './LegalAddressFields';\n\nexport const EditCompanyProfile: FunctionComponent<EditCompanyProfileProps> = ({\n inLineAlertProps,\n company,\n loading = false,\n onSubmit,\n onCancel,\n}) => {\n const translations = useText({\n title: 'Company.EditCompanyProfile.title',\n cancel: 'Company.shared.buttons.cancel',\n save: 'Company.shared.buttons.save',\n saving: 'Company.shared.buttons.saving',\n required: 'Company.shared.validation.required',\n invalidEmail: 'Company.shared.validation.invalidEmail',\n companyNameRequired: 'Company.shared.validation.companyNameRequired',\n emailRequired: 'Company.shared.validation.emailRequired',\n emailNotAvailable: 'Company.shared.validation.emailNotAvailable',\n });\n \n const [formData, setFormData] = useState({\n name: company?.name || '',\n email: company?.email || '',\n legalName: company?.legalName || '',\n vatTaxId: company?.vatTaxId || '',\n resellerId: company?.resellerId || '',\n legalAddress: {\n street: company?.legalAddress?.street?.[0] || '',\n street2: company?.legalAddress?.street?.[1] || '',\n city: company?.legalAddress?.city || '',\n region: company?.legalAddress?.region?.region || '',\n regionCode: company?.legalAddress?.region?.regionCode || '',\n countryCode: company?.legalAddress?.countryCode || '',\n postcode: company?.legalAddress?.postcode || '',\n telephone: company?.legalAddress?.telephone || '',\n },\n });\n\n const [errors, setErrors] = useState<Record<string, string>>({});\n const [touched, setTouched] = useState<Record<string, boolean>>({});\n\n // Permission flags for editing\n // Strictly gate by granular permissions; do not fallback to overall canEdit here\n const canEditAccount = company?.permissionsFlags?.canEditAccount === true;\n const canEditAddress = company?.permissionsFlags?.canEditAddress === true;\n \n // Country and region data via hook\n const {\n countryOptions,\n regionOptions,\n isRegionRequired,\n hasRegionOptions,\n loadingCountries,\n } = useCountries(formData.legalAddress.countryCode);\n\n // Validation functions\n const validateField = (name: string, value: string): string | null => {\n if (name === 'name') {\n if (!value.trim()) return translations.companyNameRequired;\n return null;\n }\n if (name === 'email') {\n if (!value.trim()) return translations.emailRequired;\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!emailRegex.test(value)) return translations.invalidEmail;\n return null;\n }\n if (\n name === 'legalAddress.street' ||\n name === 'legalAddress.city' ||\n name === 'legalAddress.postcode' ||\n name === 'legalAddress.telephone' ||\n name === 'legalAddress.countryCode'\n ) {\n if (!value.trim()) return translations.required;\n return null;\n }\n if (name === 'legalAddress.region') {\n if (isRegionRequired && !value.trim()) return translations.required;\n return null;\n }\n return null;\n };\n\n const validateForm = (): boolean => {\n const newErrors: Record<string, string> = {};\n let isValid = true;\n\n // Determine permissions for editing\n const canEditAccount = company?.permissionsFlags?.canEditAccount === true;\n const canEditAddress = company?.permissionsFlags?.canEditAddress === true;\n\n // Validate required account fields only if editing account is allowed\n if (canEditAccount) {\n const nameError = validateField('name', formData.name);\n if (nameError) {\n newErrors.name = nameError;\n isValid = false;\n }\n\n const emailError = validateField('email', formData.email);\n if (emailError) {\n newErrors.email = emailError;\n isValid = false;\n }\n }\n\n // Validate required address fields only if editing address is allowed\n if (canEditAddress) {\n const streetError = validateField('legalAddress.street', formData.legalAddress.street);\n if (streetError) {\n newErrors['legalAddress.street'] = streetError;\n isValid = false;\n }\n\n const cityError = validateField('legalAddress.city', formData.legalAddress.city);\n if (cityError) {\n newErrors['legalAddress.city'] = cityError;\n isValid = false;\n }\n\n const postcodeError = validateField('legalAddress.postcode', formData.legalAddress.postcode);\n if (postcodeError) {\n newErrors['legalAddress.postcode'] = postcodeError;\n isValid = false;\n }\n\n const telephoneError = validateField('legalAddress.telephone', formData.legalAddress.telephone);\n if (telephoneError) {\n newErrors['legalAddress.telephone'] = telephoneError;\n isValid = false;\n }\n\n const countryError = validateField('legalAddress.countryCode', formData.legalAddress.countryCode);\n if (countryError) {\n newErrors['legalAddress.countryCode'] = countryError;\n isValid = false;\n }\n\n // Validate region field\n const regionError = validateField('legalAddress.region', formData.legalAddress.region);\n if (regionError) {\n newErrors['legalAddress.region'] = regionError;\n isValid = false;\n }\n }\n\n setErrors(newErrors);\n return isValid;\n };\n\n const handleSubmit = async (event: Event) => {\n event.preventDefault();\n \n // Mark only editable fields as touched\n // Use granular permission flags defined for this session\n const canEditAccount = company?.permissionsFlags?.canEditAccount === true;\n const canEditAddress = company?.permissionsFlags?.canEditAddress === true;\n const touchedFields: Record<string, boolean> = {};\n if (canEditAccount) {\n touchedFields.name = true;\n touchedFields.email = true;\n touchedFields.legalName = true;\n touchedFields.vatTaxId = true;\n touchedFields.resellerId = true;\n }\n if (canEditAddress) {\n touchedFields['legalAddress.street'] = true;\n touchedFields['legalAddress.street2'] = true;\n touchedFields['legalAddress.city'] = true;\n touchedFields['legalAddress.region'] = true;\n touchedFields['legalAddress.regionCode'] = true;\n touchedFields['legalAddress.countryCode'] = true;\n touchedFields['legalAddress.postcode'] = true;\n touchedFields['legalAddress.telephone'] = true;\n }\n setTouched(touchedFields);\n\n if (!validateForm()) {\n return;\n }\n\n // Check if email has changed and validate availability (only if allowed to edit account)\n if (canEditAccount && formData.email !== company?.email) {\n const emailValidation = await validateCompanyEmail(formData.email);\n if (!emailValidation.isValid) {\n setErrors(prev => ({\n ...prev,\n email: emailValidation.error || translations.emailNotAvailable,\n }));\n return;\n }\n }\n\n if (onSubmit) {\n // Transform form data to match API expectations\n const transformedData: any = {};\n if (canEditAccount) {\n transformedData.name = formData.name;\n transformedData.email = formData.email;\n transformedData.legalName = formData.legalName;\n transformedData.vatTaxId = formData.vatTaxId;\n transformedData.resellerId = formData.resellerId;\n }\n if (canEditAddress) {\n transformedData.legalAddress = {\n street: [formData.legalAddress.street, formData.legalAddress.street2].filter(Boolean),\n city: formData.legalAddress.city,\n region: {\n region: formData.legalAddress.region,\n regionCode: formData.legalAddress.regionCode,\n },\n countryCode: formData.legalAddress.countryCode,\n postcode: formData.legalAddress.postcode,\n telephone: formData.legalAddress.telephone,\n };\n }\n await onSubmit(transformedData);\n }\n };\n\n const handleInputChange = (field: string) => (value: string) => {\n // Permission guard: block changes to forbidden fields even if events fire\n const accountFields = new Set(['name', 'email', 'legalName', 'vatTaxId', 'resellerId']);\n const isAddress = field.startsWith('legalAddress.');\n const isAccount = accountFields.has(field);\n if ((isAccount && !canEditAccount) || (isAddress && !canEditAddress)) {\n return;\n }\n if (field.startsWith('legalAddress.')) {\n const addressField = field.split('.')[1];\n \n // Special handling for country change - reset region when country changes\n if (addressField === 'countryCode') {\n setFormData(prev => ({\n ...prev,\n legalAddress: {\n ...prev.legalAddress,\n [addressField]: value,\n region: '', // Reset region text\n regionCode: '', // Reset region code\n },\n }));\n \n // Clear region errors when country changes\n setErrors(prev => {\n const newErrors = { ...prev };\n delete newErrors['legalAddress.region'];\n delete newErrors['legalAddress.regionCode'];\n return newErrors;\n });\n \n // Clear region touched state when country changes\n setTouched(prev => {\n const newTouched = { ...prev };\n delete newTouched['legalAddress.region'];\n delete newTouched['legalAddress.regionCode'];\n return newTouched;\n });\n } else if (addressField === 'region') {\n // Handle region field (both text input and dropdown use this)\n setFormData(prev => ({\n ...prev,\n legalAddress: {\n ...prev.legalAddress,\n region: value,\n // For text input regions, use the same value for regionCode\n // For dropdown regions, this gets overridden in the handleSelect\n regionCode: hasRegionOptions ? prev.legalAddress.regionCode : value,\n },\n }));\n } else {\n setFormData(prev => ({\n ...prev,\n legalAddress: {\n ...prev.legalAddress,\n [addressField]: value,\n },\n }));\n }\n } else {\n setFormData(prev => ({ ...prev, [field]: value }));\n }\n \n // Clear error when user starts typing\n if (errors[field]) {\n setErrors(prev => {\n const newErrors = { ...prev };\n delete newErrors[field];\n return newErrors;\n });\n }\n };\n\n const handleBlur = (field: string) => {\n // Prevent marking forbidden fields as touched\n const accountFields = new Set(['name', 'email', 'legalName', 'vatTaxId', 'resellerId']);\n const isAddress = field.startsWith('legalAddress.');\n const isAccount = accountFields.has(field);\n if ((isAccount && !canEditAccount) || (isAddress && !canEditAddress)) {\n return;\n }\n setTouched(prev => ({ ...prev, [field]: true }));\n \n let value = '';\n if (field.startsWith('legalAddress.')) {\n const addressField = field.split('.')[1];\n const addressValue = formData.legalAddress[addressField as keyof typeof formData.legalAddress];\n value = typeof addressValue === 'string' ? addressValue : '';\n } else {\n const fieldValue = formData[field as keyof typeof formData];\n value = typeof fieldValue === 'string' ? fieldValue : '';\n }\n \n const error = validateField(field, value);\n \n if (error) {\n setErrors(prev => ({ ...prev, [field]: error }));\n }\n };\n\n return (\n <Card variant=\"secondary\" className={'account-edit-company-profile'}>\n <Header\n title={translations.title}\n divider={false}\n className={'account-edit-company-profile__title'}\n />\n {inLineAlertProps?.text ? (\n <InLineAlert\n className=\"account-edit-company-profile__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n data-testid=\"editCompanyInLineAlert\"\n />\n ) : null}\n <form\n className=\"account-edit-company-profile-form\"\n onSubmit={handleSubmit}\n >\n {canEditAccount && (\n <CompanyAccountFields\n loading={loading}\n value={{\n name: formData.name,\n email: formData.email,\n legalName: formData.legalName,\n vatTaxId: formData.vatTaxId,\n resellerId: formData.resellerId,\n }}\n errors={errors}\n touched={touched}\n onChange={handleInputChange}\n onBlur={handleBlur}\n />\n )}\n\n {/* Legal Address Section */}\n {canEditAddress && (\n <LegalAddressFields\n loading={loading}\n loadingCountries={loadingCountries}\n value={formData.legalAddress}\n errors={errors}\n touched={touched}\n onChange={handleInputChange}\n onBlur={handleBlur}\n countryOptions={countryOptions}\n regionOptions={regionOptions}\n isRegionRequired={isRegionRequired}\n hasRegionOptions={hasRegionOptions}\n />\n )}\n\n <div className=\"account-edit-company-profile__actions\">\n <Button\n disabled={loading}\n // @ts-ignore\n type=\"button\"\n variant=\"secondary\"\n onClick={() => onCancel?.()}\n >\n {translations.cancel}\n </Button>\n <Button disabled={loading || (!canEditAccount && !canEditAddress)} type=\"submit\" variant=\"primary\">\n {translations.save}\n </Button>\n </div>\n </form>\n \n {/* Loading overlay that covers the entire form */}\n {loading && (\n <div \n className=\"account-edit-company-profile__loading-overlay\"\n data-testid=\"editCompanyLoadingOverlay\"\n >\n <ProgressSpinner size=\"large\" />\n <div className=\"account-edit-company-profile__loading-text\">\n {translations.saving}\n </div>\n </div>\n )}\n </Card>\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 { Skeleton, SkeletonRow, Card } from '@adobe-commerce/elsie/components';\nimport './CompanyLoaders.css';\nimport { classes } from '@adobe-commerce/elsie/lib';\n\nexport const CompanyCardLoader = ({\n testId,\n withCard = true,\n}: {\n testId?: string;\n withCard?: boolean;\n}) => {\n const defaultSkeleton = (\n <Skeleton data-testid={testId || 'companySkeletonLoader'}>\n <SkeletonRow\n variant=\"heading\"\n size=\"xlarge\"\n fullWidth={false}\n lines={1}\n />\n <SkeletonRow variant=\"heading\" size=\"xlarge\" fullWidth={true} lines={1} />\n <SkeletonRow variant=\"heading\" size=\"xlarge\" fullWidth={true} lines={1} />\n </Skeleton>\n );\n\n if (withCard) {\n return defaultSkeleton;\n }\n\n return (\n <Card\n variant=\"secondary\"\n className={classes([\n 'company-company-loaders',\n 'company-company-loaders--card-loader',\n ])}\n >\n {defaultSkeleton}\n </Card>\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 *******************************************************************/\ndeclare global {\n interface Window {\n adobeDataLayer: any[];\n }\n}\n\nenum EventsList {\n EDIT_COMPANY_EVENT = 'edit-company',\n}\n\nconst EVENTS_MAPPING = {\n EDIT_COMPANY_EVENT: EventsList.EDIT_COMPANY_EVENT,\n};\n\n/**\n * Set and return the Adobe Client Data Layer (ACDL)\n * @returns ACDL instance or an empty array if it doesn't exist\n */\nconst getAdobeDataLayer = () => {\n if (!window.adobeDataLayer) {\n window.adobeDataLayer = [];\n }\n return window.adobeDataLayer;\n};\n\n/**\n * Sets a context in the Adobe Client Data Layer (ACDL)\n * @param context - The context object to set\n */\nconst setContext = (context: Record<string, any>) => {\n const adobeDataLayer = getAdobeDataLayer();\n adobeDataLayer.push({\n context,\n });\n};\n\n/**\n * Pushes an event to the Adobe Client Data Layer (ACDL)\n * @param event - The event object to push\n */\nconst pushEvent = (event: Record<string, any>) => {\n const adobeDataLayer = getAdobeDataLayer();\n \n adobeDataLayer.push((acdl: any) => {\n const state = acdl.getState ? acdl.getState() : {};\n \n acdl.push({\n event,\n context: state,\n });\n });\n};\n\n/**\n * Publishes events to the Adobe Client Data Layer (ACDL)\n * @param eventType - The type of event to publish\n * @param eventParams - Parameters associated with the event\n * @returns null if the event type is not recognized\n */\nconst publishEvents = (eventType: string, eventParams: any) => {\n if (!EVENTS_MAPPING[eventType as keyof typeof EVENTS_MAPPING]) {\n return null;\n }\n\n switch (eventType) {\n case EventsList.EDIT_COMPANY_EVENT:\n pushEvent({\n type: 'company',\n eventType: 'edit',\n companyData: eventParams,\n });\n break;\n default:\n return null;\n }\n};\n\nexport { EventsList, publishEvents, pushEvent, setContext };","/********************************************************************\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 { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { getCompany, updateCompany, getCountries } from '../../api';\nimport { CompanyModel } from '../../data/models';\nimport { Country } from '../../data/models/country';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { EventsList, publishEvents } from '../../lib/acdl';\n\nexport interface UseCompanyProfileProps {\n handleSetInLineAlert?: (alert?: { type: 'success' | 'error'; text: string }) => void;\n}\n\nexport const useCompanyProfile = ({ \n handleSetInLineAlert \n}: UseCompanyProfileProps) => {\n const translations = useText({\n companySuccess: 'Company.CompanyProfile.editCompanyProfile.companySuccess',\n companyError: 'Company.CompanyProfile.editCompanyProfile.companyError',\n loadError: 'Company.CompanyProfile.messages.loadError',\n updateError: 'Company.CompanyProfile.messages.updateError',\n });\n const { companySuccess, companyError, loadError, updateError } = translations;\n\n const [company, setCompany] = useState<CompanyModel | null>(null);\n const [loading, setLoading] = useState<boolean>(true);\n const [submitLoading, setSubmitLoading] = useState<boolean>(false);\n const [showEditForm, setShowEditForm] = useState<boolean>(false);\n const [countries, setCountries] = useState<Country[]>([]);\n const [inputChange, setInputChange] = useState<Record<string, string | number | boolean>>({});\n const [createdAt, setCreatedAt] = useState<string>('');\n\n // Keep stable references to avoid re-creating callbacks/effects and double fetch\n const alertFnRef = useRef<UseCompanyProfileProps['handleSetInLineAlert']>(handleSetInLineAlert);\n const inFlightRef = useRef<boolean>(false);\n const didInitialFetchRef = useRef<boolean>(false);\n useEffect(() => {\n alertFnRef.current = handleSetInLineAlert;\n }, [handleSetInLineAlert]);\n\n const handleInputChange = useCallback(\n (value: Record<string, string | number | boolean>) => {\n setInputChange(value);\n },\n []\n );\n\n const renderAlertMessage = useCallback(\n (type: 'success' | 'error', message?: string) => {\n if (!handleSetInLineAlert) return;\n\n if (type === 'success') {\n handleSetInLineAlert({\n type: 'success',\n text: message ?? companySuccess,\n });\n } else if (type === 'error') {\n handleSetInLineAlert({\n type: 'error',\n text: message ?? companyError,\n });\n } else {\n handleSetInLineAlert();\n }\n\n setSubmitLoading(false);\n },\n [handleSetInLineAlert, companySuccess, companyError]\n );\n\n const fetchCompany = useCallback(() => {\n if (inFlightRef.current) {\n return;\n }\n inFlightRef.current = true;\n setLoading(true);\n \n getCompany()\n .then((companyData: CompanyModel | null) => {\n if (companyData) {\n setCompany(companyData);\n setCreatedAt('');\n }\n setLoading(false);\n })\n .catch((error) => {\n console.error('Failed to load company:', error);\n setLoading(false);\n // Use stable ref to avoid changing dependencies\n if (alertFnRef.current) {\n alertFnRef.current({ type: 'error', text: loadError });\n }\n })\n .finally(() => {\n inFlightRef.current = false;\n });\n }, [loadError]);\n\n useEffect(() => {\n if (!didInitialFetchRef.current) {\n didInitialFetchRef.current = true;\n fetchCompany();\n }\n // Intentionally depend only on loadError through fetchCompany to avoid re-fetching on alert changes\n }, [fetchCompany]);\n\n useEffect(() => {\n getCountries().then((countriesResponse) => {\n setCountries(countriesResponse.availableCountries);\n }).catch((error) => {\n console.error('Failed to load countries:', error);\n });\n }, []);\n\n const handleShowEditForm = useCallback(() => {\n setShowEditForm(true);\n renderAlertMessage('success', ''); // Clear any existing alerts\n setInputChange({});\n }, [renderAlertMessage]);\n\n const handleHideEditForm = useCallback((clearStates?: () => void) => {\n clearStates?.();\n setShowEditForm(false);\n setInputChange({});\n }, []);\n\n const handleUpdateCompany = useCallback(async (data: Partial<CompanyModel>) => {\n try {\n setSubmitLoading(true);\n \n if (!data) {\n renderAlertMessage('error', 'No data to update');\n return;\n }\n \n const updatedCompany = await updateCompany(data as any);\n \n // Permissions are now correctly set by transformCompany based on role data\n \n setCompany(updatedCompany);\n setShowEditForm(false);\n setInputChange({});\n \n renderAlertMessage('success');\n \n // Publish analytics event\n publishEvents(EventsList.EDIT_COMPANY_EVENT, {\n ...data,\n companyId: company?.id,\n });\n \n // No need to refresh - updateCompany already returns complete updated data\n \n } catch (error: any) {\n console.error('Failed to update company:', error);\n renderAlertMessage('error', error.message || updateError);\n } finally {\n setSubmitLoading(false);\n }\n }, [company, renderAlertMessage, updateError]);\n\n return {\n // Core data\n company,\n countries,\n createdAt,\n \n // Loading states\n loading,\n submitLoading,\n \n // UI states\n showEditForm,\n \n // Form data\n inputChange,\n \n // Actions\n handleShowEditForm,\n handleHideEditForm,\n handleUpdateCompany,\n handleInputChange,\n renderAlertMessage,\n \n // Legacy support (deprecated - use submitLoading instead)\n saving: submitLoading,\n };\n};\n","import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.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\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\" }))));\nexport default SvgWarning;\n","import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n","import * as React from \"react\";\nconst SvgWarningWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.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\" }));\nexport default SvgWarningWithCircle;\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 { useState, useCallback, useEffect } from 'preact/hooks';\nimport { InLineAlertProps } from '../types/companyProfile.types';\nimport {\n CheckWithCircle as Success,\n Warning,\n WarningWithCircle as Error,\n} from '@adobe-commerce/elsie/icons';\n\nexport type AlertType = 'success' | 'warning' | 'error';\n\nexport interface AlertOptions {\n type: AlertType;\n text: string;\n autoHide?: boolean;\n autoHideDelay?: number;\n}\n\nexport interface UseInLineAlertReturn {\n inLineAlertProps: InLineAlertProps;\n handleSetInLineAlert: (notification?: AlertOptions) => void;\n clearAlert: () => void;\n showSuccess: (text: string, autoHide?: boolean) => void;\n showWarning: (text: string, autoHide?: boolean) => void;\n showError: (text: string, autoHide?: boolean) => void;\n}\n\nconst iconsList = {\n success: <Success />,\n warning: <Warning />,\n error: <Error />,\n};\n\nexport const useInLineAlert = (): UseInLineAlertReturn => {\n const [inLineAlertProps, setInLineAlertProps] = useState<InLineAlertProps>({});\n const [autoHideTimer, setAutoHideTimer] = useState<ReturnType<typeof setTimeout> | null>(null);\n\n const clearAlert = useCallback(() => {\n setInLineAlertProps({});\n if (autoHideTimer) {\n clearTimeout(autoHideTimer);\n setAutoHideTimer(null);\n }\n }, [autoHideTimer]);\n\n const handleSetInLineAlert = useCallback(\n (notification?: AlertOptions) => {\n // Clear existing timer\n if (autoHideTimer) {\n clearTimeout(autoHideTimer);\n setAutoHideTimer(null);\n }\n\n if (!notification?.type) {\n setInLineAlertProps({});\n return;\n }\n\n const icon = iconsList[notification.type];\n\n setInLineAlertProps({\n type: notification.type,\n text: notification.text,\n icon,\n });\n\n // Auto-hide if requested\n if (notification.autoHide !== false) {\n const delay = notification.autoHideDelay || (notification.type === 'success' ? 3000 : 5000);\n const timer = setTimeout(() => {\n setInLineAlertProps({});\n setAutoHideTimer(null);\n }, delay);\n setAutoHideTimer(timer);\n }\n },\n [autoHideTimer]\n );\n\n const showSuccess = useCallback(\n (text: string, autoHide: boolean = true) => {\n handleSetInLineAlert({ type: 'success', text, autoHide });\n },\n [handleSetInLineAlert]\n );\n\n const showWarning = useCallback(\n (text: string, autoHide: boolean = false) => {\n handleSetInLineAlert({ type: 'warning', text, autoHide });\n },\n [handleSetInLineAlert]\n );\n\n const showError = useCallback(\n (text: string, autoHide: boolean = false) => {\n handleSetInLineAlert({ type: 'error', text, autoHide });\n },\n [handleSetInLineAlert]\n );\n\n // Cleanup timer on unmount\n useEffect(() => {\n return () => {\n if (autoHideTimer) {\n clearTimeout(autoHideTimer);\n }\n };\n }, [autoHideTimer]);\n\n return {\n inLineAlertProps,\n handleSetInLineAlert,\n clearAlert,\n showSuccess,\n showWarning,\n showError,\n };\n};\n\nexport default useInLineAlert;\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 { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { Header } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { CompanyProfileCard } from '../../components/CompanyProfileCard';\nimport { EditCompanyProfile } from '../../components/EditCompanyProfile';\nimport { CompanyCardLoader } from '../../components/CompanyLoaders';\nimport { useCompanyProfile } from '../../hooks/containers/useCompanyProfile';\nimport { useInLineAlert } from '../../hooks/useInLineAlert';\nimport { CompanyProfileProps } from '../../types/companyProfile.types';\n\nexport const CompanyProfile: Container<CompanyProfileProps> = ({\n className,\n withHeader = true,\n slots,\n}) => {\n const translations = useText({\n containerTitle: 'Company.CompanyProfile.containerTitle',\n });\n const { inLineAlertProps, handleSetInLineAlert } = useInLineAlert();\n const {\n company,\n loading,\n saving,\n showEditForm,\n handleShowEditForm,\n handleHideEditForm,\n handleUpdateCompany,\n } = useCompanyProfile({ handleSetInLineAlert });\n\n if (loading)\n return (\n <div data-testid=\"companyProfileLoader\">\n <CompanyCardLoader withCard />\n </div>\n );\n\n return (\n <div className={classes(['account-company-profile', className])}>\n {withHeader ? (\n <Header\n title={translations.containerTitle}\n divider={false}\n className={'company-profile__title'}\n />\n ) : null}\n <CompanyProfileCard\n company={company}\n slots={slots}\n showEditForm={showEditForm}\n handleShowEditForm={handleShowEditForm}\n />\n {showEditForm ? (\n <EditCompanyProfile\n inLineAlertProps={inLineAlertProps}\n company={company}\n loading={saving}\n onSubmit={handleUpdateCompany}\n onCancel={handleHideEditForm}\n />\n ) : null}\n </div>\n );\n};\n"],"names":["CompanyProfileCard","company","slots","showEditForm","handleShowEditForm","translations","useText","jsx","Card","perms","companyData","classes","jsxs","Button","Default","Fragment","el","index","value","_a","line","i","_b","m","Slot","useCountries","selectedCountryCode","countriesData","setCountriesData","useState","loadingCountries","setLoadingCountries","useEffect","isMounted","getCountries","availableCountries","countriesWithRequiredRegion","optionalZipCountries","countryOptions","useMemo","regionOptions","selectedCountry","country","region","isRegionRequired","hasRegionOptions","CompanyAccountFields","loading","errors","touched","onChange","onBlur","namePrefix","fieldPathPrefix","prefix","path","f","Field","Input","LegalAddressFields","requiredConfig","names","paths","isRequired","Picker","event","target","r","regionCode","regionName","EditCompanyProfile","inLineAlertProps","onSubmit","onCancel","formData","setFormData","_d","_c","_e","_g","_f","_i","_h","_j","_k","_l","setErrors","setTouched","canEditAccount","_m","canEditAddress","_n","validateField","name","validateForm","newErrors","isValid","nameError","emailError","streetError","cityError","postcodeError","telephoneError","countryError","regionError","handleSubmit","touchedFields","emailValidation","validateCompanyEmail","prev","transformedData","handleInputChange","field","accountFields","isAddress","addressField","newTouched","handleBlur","addressValue","fieldValue","error","Header","InLineAlert","ProgressSpinner","CompanyCardLoader","testId","withCard","defaultSkeleton","Skeleton","SkeletonRow","EventsList","EVENTS_MAPPING","getAdobeDataLayer","pushEvent","acdl","state","publishEvents","eventType","eventParams","useCompanyProfile","handleSetInLineAlert","companySuccess","companyError","loadError","updateError","setCompany","setLoading","submitLoading","setSubmitLoading","setShowEditForm","countries","setCountries","inputChange","setInputChange","createdAt","setCreatedAt","alertFnRef","useRef","inFlightRef","didInitialFetchRef","useCallback","renderAlertMessage","type","message","fetchCompany","getCompany","countriesResponse","handleHideEditForm","clearStates","handleUpdateCompany","data","updatedCompany","updateCompany","SvgWarning","props","React","SvgCheckWithCircle","SvgWarningWithCircle","iconsList","Success","Warning","Error","useInLineAlert","setInLineAlertProps","autoHideTimer","setAutoHideTimer","clearAlert","notification","icon","delay","timer","showSuccess","text","autoHide","showWarning","showError","CompanyProfile","className","withHeader","saving"],"mappings":"grBAuBO,MAAMA,GAAiE,CAAC,CAC7E,QAAAC,EACA,MAAAC,EACA,aAAAC,EACA,mBAAAC,CACF,IAAM,CACJ,MAAMC,EAAeC,EAAQ,CAC3B,WAAY,8BACZ,cAAe,0DACf,YAAa,oCACb,MAAO,8BACP,UAAW,kCACX,SAAU,iCACV,WAAY,mCACZ,aAAc,qCACd,SAAU,qDACV,qBAAsB,iEACtB,oBAAqB,gEACrB,mBAAoB,+DACpB,oBAAqB,gEACrB,wBAAyB,oEACzB,yBAA0B,qEAC1B,iBAAkB,6DAClB,kBAAmB,6DAAA,CACpB,EAED,GAAI,CAACL,EACH,OACEM,EAACC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|
|
1
|
+
{"version":3,"file":"CompanyProfile.js","sources":["/@dropins/storefront-company-management/src/components/CompanyProfileCard/CompanyProfileCard.tsx","/@dropins/storefront-company-management/src/hooks/useCountries.ts","/@dropins/storefront-company-management/src/components/EditCompanyProfile/CompanyAccountFields.tsx","/@dropins/storefront-company-management/src/components/EditCompanyProfile/LegalAddressFields.tsx","/@dropins/storefront-company-management/src/components/EditCompanyProfile/EditCompanyProfile.tsx","/@dropins/storefront-company-management/src/components/CompanyLoaders/CompanyLoaders.tsx","/@dropins/storefront-company-management/src/lib/acdl.ts","/@dropins/storefront-company-management/src/hooks/containers/useCompanyProfile.tsx","../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg","../../node_modules/@adobe-commerce/elsie/src/icons/WarningWithCircle.svg","/@dropins/storefront-company-management/src/hooks/useInLineAlert.tsx","/@dropins/storefront-company-management/src/containers/CompanyProfile/CompanyProfile.tsx"],"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 *******************************************************************/\nimport { FunctionComponent } from 'preact';\nimport { Card, Button } from '@adobe-commerce/elsie/components';\nimport { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { CompanyProfileCardProps } from '../../types/companyProfile.types';\nimport './CompanyProfileCard.css';\n\nexport const CompanyProfileCard: FunctionComponent<CompanyProfileCardProps> = ({\n company,\n slots,\n showEditForm,\n handleShowEditForm,\n}) => {\n const translations = useText({\n editButton: 'Company.shared.buttons.edit',\n noDataMessage: 'Company.CompanyProfile.companyProfileCard.noDataMessage',\n companyName: 'Company.shared.fields.companyName',\n email: 'Company.shared.fields.email',\n legalName: 'Company.shared.fields.legalName',\n vatTaxId: 'Company.shared.fields.vatTaxId',\n resellerId: 'Company.shared.fields.resellerId',\n legalAddress: 'Company.shared.fields.legalAddress',\n contacts: 'Company.CompanyProfile.companyProfileCard.contacts',\n companyAdministrator: 'Company.CompanyProfile.companyProfileCard.companyAdministrator',\n salesRepresentative: 'Company.CompanyProfile.companyProfileCard.salesRepresentative',\n paymentInformation: 'Company.CompanyProfile.companyProfileCard.paymentInformation',\n shippingInformation: 'Company.CompanyProfile.companyProfileCard.shippingInformation',\n availablePaymentMethods: 'Company.CompanyProfile.companyProfileCard.availablePaymentMethods',\n availableShippingMethods: 'Company.CompanyProfile.companyProfileCard.availableShippingMethods',\n noPaymentMethods: 'Company.CompanyProfile.companyProfileCard.noPaymentMethods',\n noShippingMethods: 'Company.CompanyProfile.companyProfileCard.noShippingMethods',\n });\n \n if (!company) {\n return (\n <Card variant=\"secondary\" className=\"account-company-profile-card\">\n <div className=\"account-company-profile-card__wrapper\">\n <div className=\"account-company-profile-card__content\">\n <div className=\"account-company-profile-card__no-data\">\n <p>{translations.noDataMessage}</p>\n </div>\n </div>\n </div>\n </Card>\n );\n }\n\n const perms = company.permissionsFlags || {\n canViewAccount: true,\n canEditAccount: false,\n canViewAddress: true,\n canEditAddress: false,\n canViewContacts: true,\n canViewPaymentInformation: true,\n canViewShippingInformation: true,\n };\n\n const companyData = [\n perms.canViewAccount ? { \n name: 'name', \n label: translations.companyName, \n value: company.name || '',\n legalName: company.legalName || ''\n } : null,\n perms.canViewAccount ? { name: 'email', label: translations.email, value: company.email || '' } : null,\n perms.canViewAccount ? { name: 'vatTaxId', label: translations.vatTaxId, value: company.vatTaxId || '' } : null,\n perms.canViewAccount ? { name: 'resellerId', label: translations.resellerId, value: company.resellerId || '' } : null,\n ].filter(Boolean) as { name: string; label: string; value: string; legalName?: string }[];\n\n return (\n <Card\n variant=\"secondary\"\n className={classes([\n 'account-company-profile-card',\n [\n 'account-company-profile-card-short',\n showEditForm,\n ],\n ])}\n >\n <div className=\"account-company-profile-card__wrapper\">\n <div className=\"account-company-profile-card__actions\">\n {(company.canEditAccount || company.canEditAddress) && (\n <Button\n // @ts-ignore\n type=\"button\"\n variant=\"tertiary\"\n onClick={handleShowEditForm}\n >\n {translations.editButton}\n </Button>\n )}\n </div>\n <div className=\"account-company-profile-card__content\">\n {(() => {\n const Default = (\n <>\n {companyData.map((el, index) => {\n if (!el.value) return null;\n \n let value;\n if (el.name === 'name' && el.legalName) {\n // Show company name with legal name in parentheses\n value = `${el.label}: ${el.value} (${el.legalName})`;\n } else {\n value = !el.label\n ? el.value\n : `${el.label}: ${el.value}`;\n }\n\n return (\n <p\n key={`${el.name}_${index}`}\n data-testid={`${el.name}_${index}`}\n >\n {value}\n </p>\n );\n })}\n\n {perms.canViewAddress && company.legalAddress && (\n <div className=\"company-legal-address\">\n <p><strong>{translations.legalAddress}:</strong></p>\n {company.legalAddress.street?.map((line: string, i: number) => (\n <p key={i}>{line}</p>\n ))}\n <p>\n {company.legalAddress.city}, {company.legalAddress.region?.region} {company.legalAddress.postcode}\n </p>\n <p>{company.legalAddress.countryCode}</p>\n {company.legalAddress.telephone && (\n <p>Phone: {company.legalAddress.telephone}</p>\n )}\n </div>\n )}\n\n {perms.canViewContacts && (company.companyAdmin || company.salesRepresentative) && (\n <div className=\"company-contacts\">\n <p><strong>{translations.contacts}:</strong></p>\n \n {company.companyAdmin && (\n <div className=\"company-contact\">\n <p><strong>{translations.companyAdministrator}:</strong></p>\n <p>{company.companyAdmin.firstname} {company.companyAdmin.lastname}</p>\n {company.companyAdmin.jobTitle && <p>{company.companyAdmin.jobTitle}</p>}\n <p>{company.companyAdmin.email}</p>\n </div>\n )}\n\n {company.salesRepresentative && (\n <div className=\"company-contact\">\n <p><strong>{translations.salesRepresentative}:</strong></p>\n <p>{company.salesRepresentative.firstname} {company.salesRepresentative.lastname}</p>\n <p>{company.salesRepresentative.email}</p>\n </div>\n )}\n </div>\n )}\n\n {perms.canViewPaymentInformation && (\n <div className=\"company-payment-methods\">\n <p><strong>{translations.paymentInformation}:</strong></p>\n {company.availablePaymentMethods && company.availablePaymentMethods.length > 0 ? (\n <>\n <p><strong>{translations.availablePaymentMethods}:</strong></p>\n <ul className=\"payment-methods-list\">\n {company.availablePaymentMethods.map((m, index) => (\n <li key={`payment_${index}`}>{m.title}</li>\n ))}\n </ul>\n </>\n ) : (\n <div className=\"message message-notice notice\">\n <div>{translations.noPaymentMethods}</div>\n </div>\n )}\n </div>\n )}\n\n {perms.canViewShippingInformation && (\n <div className=\"company-shipping-methods\">\n <p><strong>{translations.shippingInformation}:</strong></p>\n {company.availableShippingMethods && company.availableShippingMethods.length > 0 ? (\n <>\n <p><strong>{translations.availableShippingMethods}:</strong></p>\n <ul className=\"shipping-methods-list\">\n {company.availableShippingMethods.map((m, index) => (\n <li key={`shipping_${index}`}>{m.title}</li>\n ))}\n </ul>\n </>\n ) : (\n <div className=\"message message-notice notice\">\n <div>{translations.noShippingMethods}</div>\n </div>\n )}\n </div>\n )}\n </>\n );\n if (slots?.CompanyData) {\n return (\n <Slot name=\"CompanyData\" slot={slots.CompanyData} context={{ companyData, Default }} />\n );\n }\n return Default;\n })()}\n </div>\n </div>\n </Card>\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 { useEffect, useMemo, useState } from 'preact/hooks';\nimport { getCountries } from '../api';\nimport type { Country } from '../data/models';\n\ninterface UseCountriesResult {\n countryOptions: Country[];\n regionOptions: { text: string; value: string }[];\n isRegionRequired: boolean;\n hasRegionOptions: boolean;\n loadingCountries: boolean;\n}\n\nexport const useCountries = (selectedCountryCode: string | undefined): UseCountriesResult => {\n const [countriesData, setCountriesData] = useState<{\n availableCountries: Country[];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n } | null>(null);\n const [loadingCountries, setLoadingCountries] = useState<boolean>(true);\n\n useEffect(() => {\n let isMounted = true;\n getCountries()\n .then(({ availableCountries, countriesWithRequiredRegion, optionalZipCountries }) => {\n if (!isMounted) return;\n setCountriesData({ availableCountries, countriesWithRequiredRegion, optionalZipCountries });\n setLoadingCountries(false);\n })\n .catch(() => {\n if (!isMounted) return;\n setLoadingCountries(false);\n });\n return () => {\n isMounted = false;\n };\n }, []);\n\n const countryOptions = useMemo(() => {\n return countriesData?.availableCountries || [];\n }, [countriesData]);\n\n const regionOptions = useMemo(() => {\n if (!selectedCountryCode || !countriesData) return [] as { text: string; value: string }[];\n const selectedCountry = countriesData.availableCountries.find((country) => country.value === selectedCountryCode);\n if (!selectedCountry?.availableRegions || selectedCountry.availableRegions.length === 0) return [];\n return selectedCountry.availableRegions.map((region) => ({ text: region.name, value: `${region.code},${region.id}` }));\n }, [selectedCountryCode, countriesData]);\n\n const isRegionRequired = useMemo(() => {\n if (!selectedCountryCode || !countriesData) return false;\n return countriesData.countriesWithRequiredRegion.includes(selectedCountryCode);\n }, [selectedCountryCode, countriesData]);\n\n const hasRegionOptions = useMemo(() => regionOptions.length > 0, [regionOptions]);\n\n return {\n countryOptions,\n regionOptions,\n isRegionRequired,\n hasRegionOptions,\n loadingCountries,\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 *******************************************************************/\nimport { FunctionComponent } from 'preact';\nimport { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\ninterface CompanyAccountFieldsProps {\n loading?: boolean;\n value: {\n name: string;\n email: string;\n legalName: string;\n vatTaxId: string;\n resellerId: string;\n };\n errors: Record<string, string>;\n touched: Record<string, boolean>;\n onBlur: (field: string, value?: string) => void;\n /** Optional input name prefix for DOM names (defaults to none) */\n namePrefix?: string;\n /** Optional field path prefix used for change/blur handlers (defaults to none) */\n fieldPathPrefix?: string;\n}\n\nexport const CompanyAccountFields: FunctionComponent<CompanyAccountFieldsProps> = ({\n loading,\n value,\n errors,\n touched,\n onBlur,\n namePrefix = '',\n fieldPathPrefix = '',\n}) => {\n const translations = useText({\n companyName: 'Company.shared.fields.companyName',\n email: 'Company.shared.fields.email',\n legalName: 'Company.shared.fields.legalName',\n vatTaxId: 'Company.shared.fields.vatTaxId',\n resellerId: 'Company.shared.fields.resellerId',\n });\n const prefix = namePrefix ? `${namePrefix}_` : '';\n const path = (f: string) => (fieldPathPrefix ? `${fieldPathPrefix}.${f}` : f);\n return (\n <div className=\"account-edit-company-profile-form__group\">\n <Field \n label={translations.companyName} \n required\n className=\"account-edit-company-profile-form__field\"\n error={touched.name && errors.name ? errors.name : undefined}\n >\n <Input\n name={`${prefix}name`}\n type=\"text\"\n value={value.name}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(path('name'), target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n maxLength={40}\n />\n </Field>\n\n <Field label={translations.legalName} className=\"account-edit-company-profile-form__field\">\n <Input\n name={`${prefix}legalName`}\n type=\"text\"\n value={value.legalName}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(path('legalName'), target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n maxLength={80}\n />\n </Field>\n\n <Field \n label={translations.email} \n required\n className=\"account-edit-company-profile-form__field\"\n error={touched.email && errors.email ? errors.email : undefined}\n >\n <Input\n name={`${prefix}email`}\n type=\"email\"\n value={value.email}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(path('email'), target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field label={translations.vatTaxId} className=\"account-edit-company-profile-form__field\">\n <Input\n name={`${prefix}vatTaxId`}\n type=\"text\"\n value={value.vatTaxId}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(path('vatTaxId'), target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n maxLength={40}\n />\n </Field>\n\n <Field label={translations.resellerId} className=\"account-edit-company-profile-form__field\">\n <Input\n name={`${prefix}resellerId`}\n type=\"text\"\n value={value.resellerId}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(path('resellerId'), target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n maxLength={40}\n />\n </Field>\n </div>\n );\n};\n\nexport default CompanyAccountFields;\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 { FunctionComponent } from 'preact';\nimport { Field, Input, Picker } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\ninterface LegalAddressFieldsProps {\n loading?: boolean;\n loadingCountries: boolean;\n value: {\n street: string;\n street2: string;\n city: string;\n region: string;\n regionCode: string;\n countryCode: string;\n postcode: string;\n telephone: string;\n };\n errors: Record<string, string>;\n touched: Record<string, boolean>;\n onChange: (field: string) => (value: string) => void;\n onBlur: (field: string, value?: string) => void;\n countryOptions: { text: string; value: string }[];\n regionOptions: { text: string; value: string }[];\n isRegionRequired: boolean;\n hasRegionOptions: boolean;\n /**\n * Optional input name prefix for DOM names (defaults to 'legal_address')\n */\n namePrefix?: string;\n /**\n * Optional field path prefix used for change/blur handlers (defaults to 'legal_address')\n */\n fieldPathPrefix?: string;\n /**\n * Optional per-field required overrides for non-edit flows\n */\n requiredConfig?: Partial<{\n street: boolean;\n city: boolean;\n postcode: boolean;\n telephone: boolean;\n }>;\n}\n\nexport const LegalAddressFields: FunctionComponent<LegalAddressFieldsProps> = ({\n loading,\n loadingCountries,\n value,\n errors,\n touched,\n onChange,\n onBlur,\n countryOptions,\n regionOptions,\n isRegionRequired,\n hasRegionOptions,\n namePrefix = 'legalAddress',\n fieldPathPrefix = 'legalAddress',\n requiredConfig,\n}) => {\n const translations = useText({\n legalAddress: 'Company.shared.fields.legalAddress',\n streetAddress: 'Company.shared.fields.streetAddress',\n city: 'Company.shared.fields.city',\n country: 'Company.shared.fields.country',\n stateProvince: 'Company.shared.fields.stateProvince',\n zipPostalCode: 'Company.shared.fields.zipPostalCode',\n phoneNumber: 'Company.shared.fields.phoneNumber',\n });\n const names = {\n street: `${namePrefix}_street`,\n street2: `${namePrefix}_street2`,\n city: `${namePrefix}_city`,\n countryCode: `${namePrefix}_countryCode`,\n region: `${namePrefix}_region`,\n postcode: `${namePrefix}_postcode`,\n telephone: `${namePrefix}_telephone`,\n } as const;\n\n const paths = {\n street: `${fieldPathPrefix}.street`,\n street2: `${fieldPathPrefix}.street2`,\n city: `${fieldPathPrefix}.city`,\n countryCode: `${fieldPathPrefix}.countryCode`,\n region: `${fieldPathPrefix}.region`,\n regionCode: `${fieldPathPrefix}.regionCode`,\n postcode: `${fieldPathPrefix}.postcode`,\n telephone: `${fieldPathPrefix}.telephone`,\n } as const;\n\n const isRequired = {\n street: requiredConfig?.street ?? true,\n city: requiredConfig?.city ?? true,\n postcode: requiredConfig?.postcode ?? true,\n telephone: requiredConfig?.telephone ?? true,\n } as const;\n\n return (\n <div className=\"account-edit-company-profile-form__section\">\n <h3 className=\"account-edit-company-profile-form__section-title\">{translations.legalAddress}</h3>\n\n <Field \n label={translations.streetAddress} \n required={isRequired.street}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.street] && errors[paths.street] ? errors[paths.street] : undefined}\n >\n <Input\n name={names.street}\n type=\"text\"\n value={value.street}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(paths.street, target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={`${translations.streetAddress} 2`} \n className=\"account-edit-company-profile-form__field\"\n >\n <Input\n name={names.street2}\n type=\"text\"\n value={value.street2}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(paths.street2, target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.city} \n required={isRequired.city}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.city] && errors[paths.city] ? errors[paths.city] : undefined}\n >\n <Input\n name={names.city}\n type=\"text\"\n value={value.city}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(paths.city, target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.country} \n required\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.countryCode] && errors[paths.countryCode] ? errors[paths.countryCode] : undefined}\n >\n <Picker\n name={names.countryCode}\n floatingLabel={`${translations.country} *`}\n placeholder={translations.country}\n options={countryOptions}\n value={value.countryCode}\n handleSelect={(event: Event) => {\n const target = event.target as HTMLSelectElement;\n onChange(paths.countryCode)(target.value);\n }}\n onBlur={() => onBlur(paths.countryCode)}\n disabled={!!loading || loadingCountries}\n />\n </Field>\n\n <Field \n label={translations.stateProvince} \n required={isRegionRequired}\n className=\"account-edit-company-profile-form__field\"\n error={touched['legalAddress.region'] && errors['legalAddress.region'] ? errors['legalAddress.region'] : undefined}\n >\n {hasRegionOptions ? (\n <Picker\n key={`region_picker_${value.countryCode}`}\n name=\"legalAddress_region\"\n floatingLabel={`${translations.stateProvince} ${isRegionRequired ? '*' : ''}`}\n placeholder={translations.stateProvince}\n options={regionOptions}\n value={value.regionCode ? (regionOptions.find(r => r.value.split(',')[0] === value.regionCode)?.value || '') : ''}\n handleSelect={(event: Event) => {\n const target = event.target as HTMLSelectElement;\n const [regionCode] = target.value.split(',');\n const regionName = regionOptions.find(r => r.value === target.value)?.text || '';\n onChange(paths.region)(regionName);\n onChange(paths.regionCode)(regionCode);\n }}\n onBlur={() => onBlur(paths.region)}\n disabled={!!loading || loadingCountries}\n />\n ) : (\n <Input\n key={`region_input_${value.countryCode}`}\n name={names.region}\n type=\"text\"\n value={value.region}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(paths.region, target.value);\n }}\n disabled={!!loading || loadingCountries}\n variant=\"primary\"\n size=\"medium\"\n />\n )}\n </Field>\n\n <Field \n label={translations.zipPostalCode} \n required={isRequired.postcode}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.postcode] && errors[paths.postcode] ? errors[paths.postcode] : undefined}\n >\n <Input\n name={names.postcode}\n type=\"text\"\n value={value.postcode}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(paths.postcode, target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n\n <Field \n label={translations.phoneNumber} \n required={isRequired.telephone}\n className=\"account-edit-company-profile-form__field\"\n error={touched[paths.telephone] && errors[paths.telephone] ? errors[paths.telephone] : undefined}\n >\n <Input\n name={names.telephone}\n type=\"tel\"\n value={value.telephone}\n onBlur={(e: Event) => {\n const target = e.target as HTMLInputElement;\n onBlur(paths.telephone, target.value);\n }}\n disabled={!!loading}\n variant=\"primary\"\n size=\"medium\"\n />\n </Field>\n </div>\n );\n};\n\nexport default LegalAddressFields;\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 { FunctionComponent } from 'preact';\nimport { useState } from 'preact/hooks';\nimport {\n Button,\n Card,\n Header,\n InLineAlert,\n ProgressSpinner,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { validateCompanyEmail } from '../../api';\nimport { EditCompanyProfileProps } from '../../types/companyProfile.types';\nimport './EditCompanyProfile.css';\nimport { useCountries } from '../../hooks/useCountries';\nimport { CompanyAccountFields } from './CompanyAccountFields';\nimport { LegalAddressFields } from './LegalAddressFields';\n\nexport const EditCompanyProfile: FunctionComponent<EditCompanyProfileProps> = ({\n inLineAlertProps,\n company,\n loading = false,\n onSubmit,\n onCancel,\n}) => {\n const translations = useText({\n title: 'Company.EditCompanyProfile.title',\n cancel: 'Company.shared.buttons.cancel',\n save: 'Company.shared.buttons.save',\n saving: 'Company.shared.buttons.saving',\n required: 'Company.shared.validation.required',\n invalidEmail: 'Company.shared.validation.invalidEmail',\n companyNameRequired: 'Company.shared.validation.companyNameRequired',\n emailRequired: 'Company.shared.validation.emailRequired',\n emailNotAvailable: 'Company.shared.validation.emailNotAvailable',\n companyNameLengthError: 'Company.shared.validation.companyNameLengthError',\n legalNameLengthError: 'Company.shared.validation.legalNameLengthError',\n vatTaxIdLengthError: 'Company.shared.validation.vatTaxIdLengthError',\n resellerIdLengthError: 'Company.shared.validation.resellerIdLengthError',\n });\n \n const [formData, setFormData] = useState({\n name: company?.name || '',\n email: company?.email || '',\n legalName: company?.legalName || '',\n vatTaxId: company?.vatTaxId || '',\n resellerId: company?.resellerId || '',\n legalAddress: {\n street: company?.legalAddress?.street?.[0] || '',\n street2: company?.legalAddress?.street?.[1] || '',\n city: company?.legalAddress?.city || '',\n region: company?.legalAddress?.region?.region || '',\n regionCode: company?.legalAddress?.region?.regionCode || '',\n countryCode: company?.legalAddress?.countryCode || '',\n postcode: company?.legalAddress?.postcode || '',\n telephone: company?.legalAddress?.telephone || '',\n },\n });\n\n const [errors, setErrors] = useState<Record<string, string>>({});\n const [touched, setTouched] = useState<Record<string, boolean>>({});\n\n // Permission flags for editing\n // Strictly gate by granular permissions; do not fallback to overall canEdit here\n const canEditAccount = company?.permissionsFlags?.canEditAccount === true;\n const canEditAddress = company?.permissionsFlags?.canEditAddress === true;\n \n // Country and region data via hook\n const {\n countryOptions,\n regionOptions,\n isRegionRequired,\n hasRegionOptions,\n loadingCountries,\n } = useCountries(formData.legalAddress.countryCode);\n\n // Validation functions\n const validateField = (name: string, value: string): string | null => {\n if (name === 'name') {\n if (!value.trim()) return translations.companyNameRequired;\n if (value.length > 40) return translations.companyNameLengthError;\n return null;\n }\n if (name === 'email') {\n if (!value.trim()) return translations.emailRequired;\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!emailRegex.test(value)) return translations.invalidEmail;\n return null;\n }\n if (name === 'legalName') {\n if (value.length > 80) return translations.legalNameLengthError;\n return null;\n }\n if (name === 'vatTaxId') {\n if (value.length > 40) return translations.vatTaxIdLengthError;\n return null;\n }\n if (name === 'resellerId') {\n if (value.length > 40) return translations.resellerIdLengthError;\n return null;\n }\n if (\n name === 'legalAddress.street' ||\n name === 'legalAddress.city' ||\n name === 'legalAddress.postcode' ||\n name === 'legalAddress.telephone' ||\n name === 'legalAddress.countryCode'\n ) {\n if (!value.trim()) return translations.required;\n return null;\n }\n if (name === 'legalAddress.region') {\n if (isRegionRequired && !value.trim()) return translations.required;\n return null;\n }\n return null;\n };\n\n const validateForm = (): boolean => {\n const newErrors: Record<string, string> = {};\n let isValid = true;\n\n // Determine permissions for editing\n const canEditAccount = company?.permissionsFlags?.canEditAccount === true;\n const canEditAddress = company?.permissionsFlags?.canEditAddress === true;\n\n // Validate required account fields only if editing account is allowed\n if (canEditAccount) {\n const nameError = validateField('name', formData.name);\n if (nameError) {\n newErrors.name = nameError;\n isValid = false;\n }\n\n const emailError = validateField('email', formData.email);\n if (emailError) {\n newErrors.email = emailError;\n isValid = false;\n }\n\n // Validate optional fields if they have values\n if (formData.legalName) {\n const legalNameError = validateField('legalName', formData.legalName);\n if (legalNameError) {\n newErrors.legalName = legalNameError;\n isValid = false;\n }\n }\n\n if (formData.vatTaxId) {\n const vatTaxIdError = validateField('vatTaxId', formData.vatTaxId);\n if (vatTaxIdError) {\n newErrors.vatTaxId = vatTaxIdError;\n isValid = false;\n }\n }\n\n if (formData.resellerId) {\n const resellerIdError = validateField('resellerId', formData.resellerId);\n if (resellerIdError) {\n newErrors.resellerId = resellerIdError;\n isValid = false;\n }\n }\n }\n\n // Validate required address fields only if editing address is allowed\n if (canEditAddress) {\n const streetError = validateField('legalAddress.street', formData.legalAddress.street);\n if (streetError) {\n newErrors['legalAddress.street'] = streetError;\n isValid = false;\n }\n\n const cityError = validateField('legalAddress.city', formData.legalAddress.city);\n if (cityError) {\n newErrors['legalAddress.city'] = cityError;\n isValid = false;\n }\n\n const postcodeError = validateField('legalAddress.postcode', formData.legalAddress.postcode);\n if (postcodeError) {\n newErrors['legalAddress.postcode'] = postcodeError;\n isValid = false;\n }\n\n const telephoneError = validateField('legalAddress.telephone', formData.legalAddress.telephone);\n if (telephoneError) {\n newErrors['legalAddress.telephone'] = telephoneError;\n isValid = false;\n }\n\n const countryError = validateField('legalAddress.countryCode', formData.legalAddress.countryCode);\n if (countryError) {\n newErrors['legalAddress.countryCode'] = countryError;\n isValid = false;\n }\n\n // Validate region field\n const regionError = validateField('legalAddress.region', formData.legalAddress.region);\n if (regionError) {\n newErrors['legalAddress.region'] = regionError;\n isValid = false;\n }\n }\n\n setErrors(newErrors);\n return isValid;\n };\n\n const handleSubmit = async (event: Event) => {\n event.preventDefault();\n \n // Mark only editable fields as touched\n // Use granular permission flags defined for this session\n const canEditAccount = company?.permissionsFlags?.canEditAccount === true;\n const canEditAddress = company?.permissionsFlags?.canEditAddress === true;\n const touchedFields: Record<string, boolean> = {};\n if (canEditAccount) {\n touchedFields.name = true;\n touchedFields.email = true;\n touchedFields.legalName = true;\n touchedFields.vatTaxId = true;\n touchedFields.resellerId = true;\n }\n if (canEditAddress) {\n touchedFields['legalAddress.street'] = true;\n touchedFields['legalAddress.street2'] = true;\n touchedFields['legalAddress.city'] = true;\n touchedFields['legalAddress.region'] = true;\n touchedFields['legalAddress.regionCode'] = true;\n touchedFields['legalAddress.countryCode'] = true;\n touchedFields['legalAddress.postcode'] = true;\n touchedFields['legalAddress.telephone'] = true;\n }\n setTouched(touchedFields);\n\n if (!validateForm()) {\n return;\n }\n\n // Check if email has changed and validate availability (only if allowed to edit account)\n if (canEditAccount && formData.email !== company?.email) {\n const emailValidation = await validateCompanyEmail(formData.email);\n if (!emailValidation.isValid) {\n setErrors(prev => ({\n ...prev,\n email: emailValidation.error || translations.emailNotAvailable,\n }));\n return;\n }\n }\n\n if (onSubmit) {\n // Transform form data to match API expectations\n const transformedData: any = {};\n if (canEditAccount) {\n transformedData.name = formData.name;\n transformedData.email = formData.email;\n transformedData.legalName = formData.legalName;\n transformedData.vatTaxId = formData.vatTaxId;\n transformedData.resellerId = formData.resellerId;\n }\n if (canEditAddress) {\n transformedData.legalAddress = {\n street: [formData.legalAddress.street, formData.legalAddress.street2].filter(Boolean),\n city: formData.legalAddress.city,\n region: {\n region: formData.legalAddress.region,\n regionCode: formData.legalAddress.regionCode,\n },\n countryCode: formData.legalAddress.countryCode,\n postcode: formData.legalAddress.postcode,\n telephone: formData.legalAddress.telephone,\n };\n }\n await onSubmit(transformedData);\n }\n };\n\n // Common form update logic\n const updateFormData = (field: string, value: string) => {\n if (field.startsWith('legalAddress.')) {\n const addressField = field.split('.')[1];\n \n // Special handling for country change - reset region when country changes\n if (addressField === 'countryCode') {\n setFormData(prev => ({\n ...prev,\n legalAddress: {\n ...prev.legalAddress,\n [addressField]: value,\n region: '', // Reset region text\n regionCode: '', // Reset region code\n },\n }));\n \n // Clear region errors when country changes\n setErrors(prev => {\n const newErrors = { ...prev };\n delete newErrors['legalAddress.region'];\n delete newErrors['legalAddress.regionCode'];\n return newErrors;\n });\n \n // Clear region touched state when country changes\n setTouched(prev => {\n const newTouched = { ...prev };\n delete newTouched['legalAddress.region'];\n delete newTouched['legalAddress.regionCode'];\n return newTouched;\n });\n } else if (addressField === 'region') {\n // Handle region field (both text input and dropdown use this)\n setFormData(prev => ({\n ...prev,\n legalAddress: {\n ...prev.legalAddress,\n region: value,\n // For text input regions, use the same value for regionCode\n // For dropdown regions, this gets overridden in the handleSelect\n regionCode: hasRegionOptions ? prev.legalAddress.regionCode : value,\n },\n }));\n } else {\n setFormData(prev => ({\n ...prev,\n legalAddress: {\n ...prev.legalAddress,\n [addressField]: value,\n },\n }));\n }\n } else {\n setFormData(prev => ({ ...prev, [field]: value }));\n }\n };\n\n const handleInputChange = (field: string) => (value: string) => {\n // Permission guard: block changes to forbidden fields even if events fire\n const accountFields = new Set(['name', 'email', 'legalName', 'vatTaxId', 'resellerId']);\n const isAddress = field.startsWith('legalAddress.');\n const isAccount = accountFields.has(field);\n if ((isAccount && !canEditAccount) || (isAddress && !canEditAddress)) {\n return;\n }\n \n updateFormData(field, value);\n \n // Clear error when user starts typing\n if (errors[field]) {\n setErrors(prev => {\n const newErrors = { ...prev };\n delete newErrors[field];\n return newErrors;\n });\n }\n };\n\n const handleBlur = (field: string, value?: string) => {\n // Permission guard: block changes to forbidden fields even if events fire\n const accountFields = new Set(['name', 'email', 'legalName', 'vatTaxId', 'resellerId']);\n const isAddress = field.startsWith('legalAddress.');\n const isAccount = accountFields.has(field);\n if ((isAccount && !canEditAccount) || (isAddress && !canEditAddress)) {\n return;\n }\n \n // Update form state if value is provided\n if (value !== undefined) {\n updateFormData(field, value);\n }\n \n setTouched(prev => ({ ...prev, [field]: true }));\n \n // Get current value for validation\n let currentValue = value;\n if (currentValue === undefined) {\n if (field.startsWith('legalAddress.')) {\n const addressField = field.split('.')[1];\n const addressValue = formData.legalAddress[addressField as keyof typeof formData.legalAddress];\n currentValue = typeof addressValue === 'string' ? addressValue : '';\n } else {\n const fieldValue = formData[field as keyof typeof formData];\n currentValue = typeof fieldValue === 'string' ? fieldValue : '';\n }\n }\n \n const error = validateField(field, currentValue);\n \n if (error) {\n setErrors(prev => ({ ...prev, [field]: error }));\n } else {\n setErrors(prev => {\n const newErrors = { ...prev };\n delete newErrors[field];\n return newErrors;\n });\n }\n };\n\n return (\n <Card variant=\"secondary\" className={'account-edit-company-profile'}>\n <Header\n title={translations.title}\n divider={false}\n className={'account-edit-company-profile__title'}\n />\n {inLineAlertProps?.text ? (\n <InLineAlert\n className=\"account-edit-company-profile__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n data-testid=\"editCompanyInLineAlert\"\n />\n ) : null}\n <form\n className=\"account-edit-company-profile-form\"\n onSubmit={handleSubmit}\n >\n {canEditAccount && (\n <CompanyAccountFields\n loading={loading}\n value={{\n name: formData.name,\n email: formData.email,\n legalName: formData.legalName,\n vatTaxId: formData.vatTaxId,\n resellerId: formData.resellerId,\n }}\n errors={errors}\n touched={touched}\n onBlur={handleBlur}\n />\n )}\n\n {/* Legal Address Section */}\n {canEditAddress && (\n <LegalAddressFields\n loading={loading}\n loadingCountries={loadingCountries}\n value={formData.legalAddress}\n errors={errors}\n touched={touched}\n onChange={handleInputChange}\n onBlur={handleBlur}\n countryOptions={countryOptions}\n regionOptions={regionOptions}\n isRegionRequired={isRegionRequired}\n hasRegionOptions={hasRegionOptions}\n />\n )}\n\n <div className=\"account-edit-company-profile__actions\">\n <Button\n disabled={loading}\n // @ts-ignore\n type=\"button\"\n variant=\"secondary\"\n onClick={() => onCancel?.()}\n >\n {translations.cancel}\n </Button>\n <Button disabled={loading || (!canEditAccount && !canEditAddress)} type=\"submit\" variant=\"primary\">\n {translations.save}\n </Button>\n </div>\n </form>\n \n {/* Loading overlay that covers the entire form */}\n {loading && (\n <div \n className=\"account-edit-company-profile__loading-overlay\"\n data-testid=\"editCompanyLoadingOverlay\"\n >\n <ProgressSpinner size=\"large\" />\n <div className=\"account-edit-company-profile__loading-text\">\n {translations.saving}\n </div>\n </div>\n )}\n </Card>\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 { Skeleton, SkeletonRow, Card } from '@adobe-commerce/elsie/components';\nimport './CompanyLoaders.css';\nimport { classes } from '@adobe-commerce/elsie/lib';\n\nexport const CompanyCardLoader = ({\n testId,\n withCard = true,\n}: {\n testId?: string;\n withCard?: boolean;\n}) => {\n const defaultSkeleton = (\n <Skeleton data-testid={testId || 'companySkeletonLoader'}>\n <SkeletonRow\n variant=\"heading\"\n size=\"xlarge\"\n fullWidth={false}\n lines={1}\n />\n <SkeletonRow variant=\"heading\" size=\"xlarge\" fullWidth={true} lines={1} />\n <SkeletonRow variant=\"heading\" size=\"xlarge\" fullWidth={true} lines={1} />\n </Skeleton>\n );\n\n if (withCard) {\n return defaultSkeleton;\n }\n\n return (\n <Card\n variant=\"secondary\"\n className={classes([\n 'company-company-loaders',\n 'company-company-loaders--card-loader',\n ])}\n >\n {defaultSkeleton}\n </Card>\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 *******************************************************************/\ndeclare global {\n interface Window {\n adobeDataLayer: any[];\n }\n}\n\nenum EventsList {\n EDIT_COMPANY_EVENT = 'edit-company',\n}\n\nconst EVENTS_MAPPING = {\n EDIT_COMPANY_EVENT: EventsList.EDIT_COMPANY_EVENT,\n};\n\n/**\n * Set and return the Adobe Client Data Layer (ACDL)\n * @returns ACDL instance or an empty array if it doesn't exist\n */\nconst getAdobeDataLayer = () => {\n if (!window.adobeDataLayer) {\n window.adobeDataLayer = [];\n }\n return window.adobeDataLayer;\n};\n\n/**\n * Sets a context in the Adobe Client Data Layer (ACDL)\n * @param context - The context object to set\n */\nconst setContext = (context: Record<string, any>) => {\n const adobeDataLayer = getAdobeDataLayer();\n adobeDataLayer.push({\n context,\n });\n};\n\n/**\n * Pushes an event to the Adobe Client Data Layer (ACDL)\n * @param event - The event object to push\n */\nconst pushEvent = (event: Record<string, any>) => {\n const adobeDataLayer = getAdobeDataLayer();\n \n adobeDataLayer.push((acdl: any) => {\n const state = acdl.getState ? acdl.getState() : {};\n \n acdl.push({\n event,\n context: state,\n });\n });\n};\n\n/**\n * Publishes events to the Adobe Client Data Layer (ACDL)\n * @param eventType - The type of event to publish\n * @param eventParams - Parameters associated with the event\n * @returns null if the event type is not recognized\n */\nconst publishEvents = (eventType: string, eventParams: any) => {\n if (!EVENTS_MAPPING[eventType as keyof typeof EVENTS_MAPPING]) {\n return null;\n }\n\n switch (eventType) {\n case EventsList.EDIT_COMPANY_EVENT:\n pushEvent({\n type: 'company',\n eventType: 'edit',\n companyData: eventParams,\n });\n break;\n default:\n return null;\n }\n};\n\nexport { EventsList, publishEvents, pushEvent, setContext };","/********************************************************************\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 { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { events } from '@adobe-commerce/event-bus';\nimport { getCompany, updateCompany, getCountries } from '../../api';\nimport { CompanyModel } from '../../data/models';\nimport { Country } from '../../data/models/country';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { EventsList, publishEvents } from '../../lib/acdl';\n\nexport interface UseCompanyProfileProps {\n handleSetInLineAlert?: (alert?: { type: 'success' | 'error'; text: string }) => void;\n editFormRef?: { current: HTMLDivElement | null };\n}\n\nexport const useCompanyProfile = ({ \n handleSetInLineAlert,\n editFormRef\n}: UseCompanyProfileProps) => {\n const translations = useText({\n companySuccess: 'Company.CompanyProfile.editCompanyProfile.companySuccess',\n companyError: 'Company.CompanyProfile.editCompanyProfile.companyError',\n loadError: 'Company.CompanyProfile.messages.loadError',\n updateError: 'Company.CompanyProfile.messages.updateError',\n });\n const { companySuccess, companyError, loadError, updateError } = translations;\n\n const [company, setCompany] = useState<CompanyModel | null>(null);\n const [loading, setLoading] = useState<boolean>(true);\n const [submitLoading, setSubmitLoading] = useState<boolean>(false);\n const [showEditForm, setShowEditForm] = useState<boolean>(false);\n const [countries, setCountries] = useState<Country[]>([]);\n const [inputChange, setInputChange] = useState<Record<string, string | number | boolean>>({});\n\n // Keep stable references to avoid re-creating callbacks/effects and double fetch\n const alertFnRef = useRef<UseCompanyProfileProps['handleSetInLineAlert']>(handleSetInLineAlert);\n const inFlightRef = useRef<boolean>(false);\n const didInitialFetchRef = useRef<boolean>(false);\n useEffect(() => {\n alertFnRef.current = handleSetInLineAlert;\n }, [handleSetInLineAlert]);\n\n const handleInputChange = useCallback(\n (value: Record<string, string | number | boolean>) => {\n setInputChange(value);\n },\n []\n );\n\n const renderAlertMessage = useCallback(\n (type: 'success' | 'error', message?: string) => {\n if (!handleSetInLineAlert) return;\n\n if (type === 'success') {\n handleSetInLineAlert({\n type: 'success',\n text: message ?? companySuccess,\n });\n } else if (type === 'error') {\n handleSetInLineAlert({\n type: 'error',\n text: message ?? companyError,\n });\n } else {\n handleSetInLineAlert();\n }\n\n setSubmitLoading(false);\n },\n [handleSetInLineAlert, companySuccess, companyError]\n );\n\n const fetchCompany = useCallback(async (): Promise<CompanyModel | null> => {\n if (inFlightRef.current) {\n return null;\n }\n inFlightRef.current = true;\n setLoading(true);\n \n try {\n const companyData = await getCompany();\n if (companyData) {\n setCompany(companyData);\n }\n setLoading(false);\n return companyData;\n } catch (error) {\n console.error('Failed to load company:', error);\n setLoading(false);\n if (alertFnRef.current) {\n alertFnRef.current({ type: 'error', text: loadError });\n }\n return null;\n } finally {\n inFlightRef.current = false;\n }\n }, [loadError]);\n\n useEffect(() => {\n if (!didInitialFetchRef.current) {\n didInitialFetchRef.current = true;\n fetchCompany();\n }\n // Intentionally depend only on loadError through fetchCompany to avoid re-fetching on alert changes\n }, [fetchCompany]);\n\n // Re-fetch company when company context changes/restores (e.g., user switches company)\n useEffect(() => {\n const onCompanyContextChanged = () => {\n setLoading(true);\n setShowEditForm(false);\n setInputChange({});\n // Re-fetch with updated GraphQL headers\n fetchCompany();\n };\n\n const subChanged = events.on('companyContext/changed', onCompanyContextChanged, { eager: true });\n\n return () => {\n subChanged?.off();\n };\n }, [fetchCompany]);\n\n useEffect(() => {\n getCountries().then((countriesResponse) => {\n setCountries(countriesResponse.availableCountries);\n }).catch((error) => {\n console.error('Failed to load countries:', error);\n });\n }, []);\n\n const handleShowEditForm = useCallback(() => {\n setShowEditForm(true);\n renderAlertMessage('success', ''); // Clear any existing alerts\n setInputChange({});\n }, [renderAlertMessage]);\n\n // Auto-scroll to edit form when it becomes visible\n useEffect(() => {\n if (showEditForm && editFormRef?.current) {\n setTimeout(() => {\n editFormRef.current?.scrollIntoView({\n behavior: 'smooth',\n block: 'start',\n inline: 'nearest'\n });\n }, 100);\n }\n }, [showEditForm, editFormRef]);\n\n const handleHideEditForm = useCallback((clearStates?: () => void) => {\n clearStates?.();\n setShowEditForm(false);\n setInputChange({});\n }, []);\n\n const handleUpdateCompany = useCallback(async (data: Partial<CompanyModel>) => {\n try {\n setSubmitLoading(true);\n \n if (!data) {\n renderAlertMessage('error', 'No data to update');\n return;\n }\n \n const updatedCompany = await updateCompany(data as any);\n \n // Permissions are now correctly set by transformCompany based on role data\n \n setCompany(updatedCompany);\n setShowEditForm(false);\n setInputChange({});\n \n renderAlertMessage('success');\n \n // Publish analytics event\n publishEvents(EventsList.EDIT_COMPANY_EVENT, {\n ...data,\n companyId: company?.id,\n });\n \n // No need to refresh - updateCompany already returns complete updated data\n \n // Notify other components that company was updated (emit complete data if available)\n events.emit('company/updated', { company: updatedCompany });\n \n } catch (error: any) {\n console.error('Failed to update company:', error);\n renderAlertMessage('error', error.message || updateError);\n } finally {\n setSubmitLoading(false);\n }\n }, [company, renderAlertMessage, updateError]);\n\n return {\n // Core data\n company,\n countries,\n \n // Loading states\n loading,\n submitLoading,\n \n // UI states\n showEditForm,\n \n // Form data\n inputChange,\n \n // Actions\n handleShowEditForm,\n handleHideEditForm,\n handleUpdateCompany,\n handleInputChange,\n renderAlertMessage,\n \n // Legacy support (deprecated - use submitLoading instead)\n saving: submitLoading,\n };\n};\n","import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.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\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\" }))));\nexport default SvgWarning;\n","import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n","import * as React from \"react\";\nconst SvgWarningWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.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\" }));\nexport default SvgWarningWithCircle;\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 { useState, useCallback, useEffect } from 'preact/hooks';\nimport { InLineAlertProps } from '../types/companyProfile.types';\nimport {\n CheckWithCircle as Success,\n Warning,\n WarningWithCircle as Error,\n} from '@adobe-commerce/elsie/icons';\n\nexport type AlertType = 'success' | 'warning' | 'error';\n\nexport interface AlertOptions {\n type: AlertType;\n text: string;\n autoHide?: boolean;\n autoHideDelay?: number;\n}\n\nexport interface UseInLineAlertReturn {\n inLineAlertProps: InLineAlertProps;\n handleSetInLineAlert: (notification?: AlertOptions) => void;\n clearAlert: () => void;\n showSuccess: (text: string, autoHide?: boolean) => void;\n showWarning: (text: string, autoHide?: boolean) => void;\n showError: (text: string, autoHide?: boolean) => void;\n}\n\nconst iconsList = {\n success: <Success />,\n warning: <Warning />,\n error: <Error />,\n};\n\nexport const useInLineAlert = (): UseInLineAlertReturn => {\n const [inLineAlertProps, setInLineAlertProps] = useState<InLineAlertProps>({});\n const [autoHideTimer, setAutoHideTimer] = useState<ReturnType<typeof setTimeout> | null>(null);\n\n const clearAlert = useCallback(() => {\n setInLineAlertProps({});\n if (autoHideTimer) {\n clearTimeout(autoHideTimer);\n setAutoHideTimer(null);\n }\n }, [autoHideTimer]);\n\n const handleSetInLineAlert = useCallback(\n (notification?: AlertOptions) => {\n // Clear existing timer\n if (autoHideTimer) {\n clearTimeout(autoHideTimer);\n setAutoHideTimer(null);\n }\n\n if (!notification?.type) {\n setInLineAlertProps({});\n return;\n }\n\n const icon = iconsList[notification.type];\n\n setInLineAlertProps({\n type: notification.type,\n text: notification.text,\n icon,\n });\n\n // Auto-hide if requested\n if (notification.autoHide !== false) {\n const delay = notification.autoHideDelay || (notification.type === 'success' ? 3000 : 5000);\n const timer = setTimeout(() => {\n setInLineAlertProps({});\n setAutoHideTimer(null);\n }, delay);\n setAutoHideTimer(timer);\n }\n },\n [autoHideTimer]\n );\n\n const showSuccess = useCallback(\n (text: string, autoHide: boolean = true) => {\n handleSetInLineAlert({ type: 'success', text, autoHide });\n },\n [handleSetInLineAlert]\n );\n\n const showWarning = useCallback(\n (text: string, autoHide: boolean = false) => {\n handleSetInLineAlert({ type: 'warning', text, autoHide });\n },\n [handleSetInLineAlert]\n );\n\n const showError = useCallback(\n (text: string, autoHide: boolean = false) => {\n handleSetInLineAlert({ type: 'error', text, autoHide });\n },\n [handleSetInLineAlert]\n );\n\n // Cleanup timer on unmount\n useEffect(() => {\n return () => {\n if (autoHideTimer) {\n clearTimeout(autoHideTimer);\n }\n };\n }, [autoHideTimer]);\n\n return {\n inLineAlertProps,\n handleSetInLineAlert,\n clearAlert,\n showSuccess,\n showWarning,\n showError,\n };\n};\n\nexport default useInLineAlert;\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 { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { Header } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useRef } from 'preact/hooks';\nimport { CompanyProfileCard } from '../../components/CompanyProfileCard';\nimport { EditCompanyProfile } from '../../components/EditCompanyProfile';\nimport { CompanyCardLoader } from '../../components/CompanyLoaders';\nimport { useCompanyProfile } from '../../hooks/containers/useCompanyProfile';\nimport { useInLineAlert } from '../../hooks/useInLineAlert';\nimport { CompanyProfileProps } from '../../types/companyProfile.types';\n\nexport const CompanyProfile: Container<CompanyProfileProps> = ({\n className,\n withHeader = true,\n slots,\n}) => {\n const translations = useText({\n containerTitle: 'Company.CompanyProfile.containerTitle',\n });\n const { inLineAlertProps, handleSetInLineAlert } = useInLineAlert();\n const editFormRef = useRef<HTMLDivElement>(null);\n const {\n company,\n loading,\n saving,\n showEditForm,\n handleShowEditForm,\n handleHideEditForm,\n handleUpdateCompany,\n } = useCompanyProfile({ handleSetInLineAlert, editFormRef });\n\n if (loading)\n return (\n <div data-testid=\"companyProfileLoader\">\n <CompanyCardLoader withCard />\n </div>\n );\n\n return (\n <div className={classes(['account-company-profile', className])}>\n {withHeader ? (\n <Header\n title={translations.containerTitle}\n divider={false}\n className={'company-profile__title'}\n />\n ) : null}\n <CompanyProfileCard\n company={company}\n slots={slots}\n showEditForm={showEditForm}\n handleShowEditForm={handleShowEditForm}\n />\n {showEditForm ? (\n <div ref={editFormRef}>\n <EditCompanyProfile\n inLineAlertProps={inLineAlertProps}\n company={company}\n loading={saving}\n onSubmit={handleUpdateCompany}\n onCancel={handleHideEditForm}\n />\n </div>\n ) : null}\n </div>\n );\n};\n"],"names":["CompanyProfileCard","company","slots","showEditForm","handleShowEditForm","translations","useText","jsx","Card","perms","companyData","classes","jsxs","Button","Default","Fragment","el","index","value","_a","line","i","_b","m","Slot","useCountries","selectedCountryCode","countriesData","setCountriesData","useState","loadingCountries","setLoadingCountries","useEffect","isMounted","getCountries","availableCountries","countriesWithRequiredRegion","optionalZipCountries","countryOptions","useMemo","regionOptions","selectedCountry","country","region","isRegionRequired","hasRegionOptions","CompanyAccountFields","loading","errors","touched","onBlur","namePrefix","fieldPathPrefix","prefix","path","f","Field","Input","e","target","LegalAddressFields","onChange","requiredConfig","names","paths","isRequired","Picker","event","r","regionCode","regionName","EditCompanyProfile","inLineAlertProps","onSubmit","onCancel","formData","setFormData","_d","_c","_e","_g","_f","_i","_h","_j","_k","_l","setErrors","setTouched","canEditAccount","_m","canEditAddress","_n","validateField","name","validateForm","newErrors","isValid","nameError","emailError","legalNameError","vatTaxIdError","resellerIdError","streetError","cityError","postcodeError","telephoneError","countryError","regionError","handleSubmit","touchedFields","emailValidation","validateCompanyEmail","prev","transformedData","updateFormData","field","addressField","newTouched","handleInputChange","accountFields","isAddress","handleBlur","currentValue","addressValue","fieldValue","error","Header","InLineAlert","ProgressSpinner","CompanyCardLoader","testId","withCard","defaultSkeleton","Skeleton","SkeletonRow","EventsList","EVENTS_MAPPING","getAdobeDataLayer","pushEvent","acdl","state","publishEvents","eventType","eventParams","useCompanyProfile","handleSetInLineAlert","editFormRef","companySuccess","companyError","loadError","updateError","setCompany","setLoading","submitLoading","setSubmitLoading","setShowEditForm","countries","setCountries","inputChange","setInputChange","alertFnRef","useRef","inFlightRef","didInitialFetchRef","useCallback","renderAlertMessage","type","message","fetchCompany","getCompany","onCompanyContextChanged","subChanged","events","countriesResponse","handleHideEditForm","clearStates","handleUpdateCompany","data","updatedCompany","updateCompany","SvgWarning","props","React","SvgCheckWithCircle","SvgWarningWithCircle","iconsList","Success","Warning","Error","useInLineAlert","setInLineAlertProps","autoHideTimer","setAutoHideTimer","clearAlert","notification","icon","delay","timer","showSuccess","text","autoHide","showWarning","showError","CompanyProfile","className","withHeader","saving"],"mappings":"ksBAuBO,MAAMA,GAAiE,CAAC,CAC7E,QAAAC,EACA,MAAAC,EACA,aAAAC,EACA,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C7D,UAAAC,EACA,WAAAC,EAAa,GACb,MAAA5M,CACF,IAAM,CACJ,MAAMG,EAAeC,EAAQ,CAC3B,eAAgB,uCAAA,CACjB,EACK,CAAE,iBAAAkE,EAAkB,qBAAA0E,CAAqB,EAAI4C,GAAe,EAC5D3C,EAAce,EAAuB,IAAI,EACzC,CACJ,QAAAjK,EACA,QAAA8C,EACA,OAAAgK,EACA,aAAA5M,EACA,mBAAAC,EACA,mBAAA2K,EACA,oBAAAE,CACE,EAAAhC,GAAkB,CAAE,qBAAAC,EAAsB,YAAAC,EAAa,EAEvD,OAAApG,EAEAxC,EAAC,OAAI,cAAY,uBACf,WAAC2H,GAAkB,CAAA,SAAQ,GAAC,CAC9B,CAAA,EAIFtH,EAAC,OAAI,UAAWD,GAAQ,CAAC,0BAA2BkM,CAAS,CAAC,EAC3D,SAAA,CACCC,EAAAvM,EAACwH,GAAA,CACC,MAAO1H,EAAa,eACpB,QAAS,GACT,UAAW,wBAAA,CAAA,EAEX,KACJE,EAACP,GAAA,CACC,QAAAC,EACA,MAAAC,EACA,aAAAC,EACA,mBAAAC,CAAA,CACF,EACCD,EACCI,EAAC,MAAI,CAAA,IAAK4I,EACR,SAAA5I,EAACgE,GAAA,CACC,iBAAAC,EACA,QAAAvE,EACA,QAAS8M,EACT,SAAU9B,EACV,SAAUF,CAAA,GAEd,EACE,IAAA,EACN,CAEJ","x_google_ignoreList":[8,9,10]}
|
|
@@ -6,11 +6,13 @@ export interface UseCompanyProfileProps {
|
|
|
6
6
|
type: 'success' | 'error';
|
|
7
7
|
text: string;
|
|
8
8
|
}) => void;
|
|
9
|
+
editFormRef?: {
|
|
10
|
+
current: HTMLDivElement | null;
|
|
11
|
+
};
|
|
9
12
|
}
|
|
10
|
-
export declare const useCompanyProfile: ({ handleSetInLineAlert }: UseCompanyProfileProps) => {
|
|
13
|
+
export declare const useCompanyProfile: ({ handleSetInLineAlert, editFormRef }: UseCompanyProfileProps) => {
|
|
11
14
|
company: CompanyModel | null;
|
|
12
15
|
countries: Country[];
|
|
13
|
-
createdAt: string;
|
|
14
16
|
loading: boolean;
|
|
15
17
|
submitLoading: boolean;
|
|
16
18
|
showEditForm: boolean;
|
package/i18n/en_US.json.d.ts
CHANGED
|
@@ -33,7 +33,11 @@ declare const _default: {
|
|
|
33
33
|
"emailRequired": "Email is required",
|
|
34
34
|
"emailNotAvailable": "This email is already used by another company",
|
|
35
35
|
"phoneInvalid": "Please enter a valid phone number",
|
|
36
|
-
"postalCodeInvalid": "Please enter a valid postal code"
|
|
36
|
+
"postalCodeInvalid": "Please enter a valid postal code",
|
|
37
|
+
"companyNameLengthError": "Company name must not exceed 40 characters",
|
|
38
|
+
"legalNameLengthError": "Legal name must not exceed 80 characters",
|
|
39
|
+
"vatTaxIdLengthError": "VAT/Tax ID must not exceed 40 characters",
|
|
40
|
+
"resellerIdLengthError": "Reseller ID must not exceed 40 characters"
|
|
37
41
|
},
|
|
38
42
|
"messages": {
|
|
39
43
|
"loading": "Loading...",
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-company-management", "version": "1.0.0-
|
|
1
|
+
{"name": "@dropins/storefront-company-management", "version": "1.0.0-beta5", "@dropins/tools": "1.5.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}
|
package/render.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
(function(c,t){try{if(typeof document<"u"){const o=document.createElement("style"),e=t.styleId;for(const a in t.attributes)o.setAttribute(a,t.attributes[a]);o.setAttribute("data-dropin",e),o.appendChild(document.createTextNode(c));const n=document.querySelector('style[data-dropin="sdk"]');if(n)n.after(o);else{const a=document.querySelector('link[rel="stylesheet"], style');a?a.before(o):document.head.append(o)}}}catch(o){console.error("dropin-styles (injectCodeFunction)",o)}})(".company-profile__title{margin-bottom:var(--spacing-medium)}.account-company-profile-card-short{margin-bottom:var(--spacing-small)}.account-company-profile-card .dropin-card__content{gap:0}.account-company-profile-card__wrapper{display:grid;grid-template-columns:1fr;align-items:start;gap:var(--grid-1-gutters) 0}.account-company-profile-card .account-company-profile-card__actions{margin-left:auto;display:flex;justify-content:space-between;align-items:center;gap:0 var(--grid-2-gutters)}@media (max-width: 300px){.account-company-profile-card .account-company-profile-card__actions{align-items:self-end;flex-direction:column-reverse}}.account-company-profile-card .account-company-profile-card__actions button{cursor:pointer;margin:0;padding:0}.account-company-profile-card__content p{font:var(--type-body-1-default-font);margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-xbig);padding:0}.account-company-profile-card__content p:nth-child(1),.account-company-profile-card__content p:nth-child(2){font:var(--type-body-1-strong-font);font-weight:500;margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0}.account-company-profile-card__content .company-legal-address{margin-top:var(--spacing-medium)}.account-company-profile-card__content .company-legal-address p{margin-bottom:var(--spacing-xsmall)}.account-company-profile-card__content .company-legal-address p:first-child{font:var(--type-body-1-strong-font);font-weight:500;margin-bottom:var(--spacing-small)}.account-company-profile-card__no-data{text-align:center;color:var(--color-neutral-600);font:var(--type-body-2-default-font);padding:var(--spacing-medium)}.account-company-profile-card__content .company-contacts{margin-top:var(--spacing-medium);padding-top:var(--spacing-medium);border-top:1px solid var(--color-neutral-200)}.account-company-profile-card__content .company-contacts>p:first-child{font:var(--type-body-1-strong-font);font-weight:500;margin-bottom:var(--spacing-small)}.account-company-profile-card__content .company-contact{margin-bottom:var(--spacing-medium);padding:var(--spacing-small);background-color:var(--color-neutral-50);border-radius:var(--shape-border-radius-1)}.account-company-profile-card__content .company-contact p{margin-bottom:var(--spacing-xsmall)}.account-company-profile-card__content .company-contact p:first-child{font-weight:500;color:var(--color-neutral-700)}.account-company-profile-card__content .company-payment-methods{margin-top:var(--spacing-medium);padding-top:var(--spacing-medium);border-top:1px solid var(--color-neutral-200)}.account-company-profile-card__content .company-payment-methods>p:first-child,.account-company-profile-card__content .company-payment-methods>p:nth-child(2){font:var(--type-body-1-strong-font);font-weight:500;margin-bottom:var(--spacing-small)}.account-company-profile-card__content .company-payment-methods p{margin-bottom:var(--spacing-xsmall)}.account-edit-company-profile__title{margin-bottom:var(--spacing-medium)}.account-edit-company-profile .dropin-card__content{gap:0}.account-edit-company-profile .account-edit-company-profile__notification{margin-bottom:var(--spacing-medium)}.account-edit-company-profile .account-edit-company-profile-form__field:nth-child(n+3){grid-column:span 2}.account-edit-company-profile .account-edit-company-profile__actions{display:flex;justify-content:end;align-items:center;gap:0 var(--grid-2-gutters);grid-column:span 2;margin-top:var(--spacing-medium)}.account-edit-company-profile .account-edit-company-profile__actions button{min-width:144px}.account-edit-company-profile-form{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium) var(--grid-2-gutters)}@media (max-width: 768px){.account-edit-company-profile-form{grid-template-columns:1fr}.account-edit-company-profile .account-edit-company-profile-form__field:nth-child(n+3){grid-column:span 1}.account-edit-company-profile .account-edit-company-profile__actions{grid-column:span 1;flex-direction:column;gap:var(--spacing-small)}.account-edit-company-profile .account-edit-company-profile__actions button{width:100%}}.account-edit-company-profile-form__section{grid-column:span 2;margin-top:var(--spacing-large);padding-top:var(--spacing-medium);border-top:1px solid var(--color-neutral-200)}.account-edit-company-profile-form__section-title{font:var(--type-headline-2-default-font);color:var(--color-neutral-800);margin-bottom:var(--spacing-medium);padding-bottom:var(--spacing-xsmall)}@media (max-width: 768px){.account-edit-company-profile-form__section{grid-column:span 1}}.account-edit-company-profile__loading-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:#ffffffe6;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:var(--spacing-medium);z-index:10;border-radius:var(--border-radius-medium)}.account-edit-company-profile__loading-text{font:var(--type-body-1-default-font);color:var(--color-neutral-700);font-weight:500}.account-edit-company-profile{position:relative}.company-company-loaders--card-loader{margin-bottom:var(--spacing-small)}.company-company-loaders--picker-loader div:first-child{max-width:200px}.company-company-loaders--picker-loader div:nth-child(3){max-width:400px}",{styleId:"company-management"});
|
|
4
|
-
import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as s,useEffect as l}from"@dropins/tools/preact-hooks.js";import{UIProvider as
|
|
4
|
+
import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as s,useEffect as l}from"@dropins/tools/preact-hooks.js";import{UIProvider as m}from"@dropins/tools/components.js";import{events as d}from"@dropins/tools/event-bus.js";const c={shared:{fields:{companyName:"Company Name",email:"Email",legalName:"Legal Name",vatTaxId:"VAT/Tax ID",resellerId:"Reseller ID",legalAddress:"Legal Address",streetAddress:"Street Address",city:"City",country:"Country",stateProvince:"State/Province",zipPostalCode:"ZIP/Postal Code",phoneNumber:"Phone Number",status:"Status",region:"Region",postalCode:"Postal Code"},buttons:{edit:"Edit",cancel:"Cancel",save:"Save Changes",saving:"Saving...",close:"Close",confirm:"Confirm"},validation:{required:"This field is required",invalidEmail:"Please enter a valid email address",companyNameRequired:"Company name is required",emailRequired:"Email is required",emailNotAvailable:"This email is already used by another company",phoneInvalid:"Please enter a valid phone number",postalCodeInvalid:"Please enter a valid postal code",companyNameLengthError:"Company name must not exceed 40 characters",legalNameLengthError:"Legal name must not exceed 80 characters",vatTaxIdLengthError:"VAT/Tax ID must not exceed 40 characters",resellerIdLengthError:"Reseller ID must not exceed 40 characters"},messages:{loading:"Loading...",noData:"No data available",error:"An error occurred",success:"Operation completed successfully"},ariaLabels:{editButton:"Edit company profile",cancelButton:"Cancel editing",saveButton:"Save company profile changes",closeButton:"Close dialog"}},CompanyProfile:{containerTitle:"Company Profile",editCompanyProfile:{containerTitle:"Edit Company Profile",companySuccess:"Company profile updated successfully",companyError:"Failed to update company profile",buttonSecondary:"Cancel",buttonPrimary:"Save Changes"},companyProfileCard:{noDataMessage:"Company profile not available. Please contact your administrator.",contacts:"Contacts",companyAdministrator:"Company Administrator",salesRepresentative:"Sales Representative",paymentInformation:"Payment Information",availablePaymentMethods:"Available Payment Methods",shippingInformation:"Shipping Information",availableShippingMethods:"Available Shipping Methods",noPaymentMethods:"This company has no payment methods. Please contact store administrator.",noShippingMethods:"This company has no shipping methods. Please contact store administrator.",companyDetails:"Company Details",addressInformation:"Address Information"},messages:{loadError:"Failed to load company profile",updateError:"Failed to update company profile",loadingProfile:"Loading company profile...",savingProfile:"Saving company profile..."}},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",phoneError:"Please enter a valid phone number.",postalCodeError:"Please enter a valid postal code.",lengthTextError:"Text length must be between {min} and {max} characters.",companyNameLengthError:"Company name must be between {min} and {max} characters."}},p={Company:c},h={default:p},u=({children:r})=>{const[o,n]=s("en_US");return l(()=>{const e=d.on("locale",t=>{n(t)},{eager:!0});return()=>{e==null||e.off()}},[]),a(m,{lang:o,langDefinitions:h,children:r})},P=new i(a(u,{}));export{P as render};
|
|
5
5
|
//# sourceMappingURL=render.js.map
|
package/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sources":["/@dropins/storefront-company-management/src/render/Provider.tsx","/@dropins/storefront-company-management/src/render/render.tsx"],"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\nimport { FunctionComponent } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport { UIProvider } from '@adobe-commerce/elsie/components';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\n\nimport en_US from '../i18n/en_US.json';\n\n// Langs\nconst langDefinitions = {\n default: en_US,\n};\n\ninterface CompanyProviderProps {\n children?: any;\n}\n\nexport const Provider: FunctionComponent<CompanyProviderProps> = ({\n children,\n}) => {\n const [lang, setLang] = useState<Lang>('en_US');\n\n // Events\n useEffect(() => {\n const localeEvent = events.on(\n 'locale',\n (locale: string) => {\n setLang(locale as Lang);\n },\n { eager: true }\n );\n return () => {\n localeEvent?.off();\n };\n }, []);\n\n return (\n <UIProvider lang={lang} langDefinitions={langDefinitions}>\n {children}\n </UIProvider>\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 *******************************************************************/\n\nimport { Render } from '@adobe-commerce/elsie/lib';\nimport { Provider } from './Provider';\n\nexport const render = new Render(<Provider />);\n"],"names":["langDefinitions","en_US","Provider","children","lang","setLang","useState","useEffect","localeEvent","events","locale","jsx","UIProvider","render","Render"],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.js","sources":["/@dropins/storefront-company-management/src/render/Provider.tsx","/@dropins/storefront-company-management/src/render/render.tsx"],"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\nimport { FunctionComponent } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport { UIProvider } from '@adobe-commerce/elsie/components';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\n\nimport en_US from '../i18n/en_US.json';\n\n// Langs\nconst langDefinitions = {\n default: en_US,\n};\n\ninterface CompanyProviderProps {\n children?: any;\n}\n\nexport const Provider: FunctionComponent<CompanyProviderProps> = ({\n children,\n}) => {\n const [lang, setLang] = useState<Lang>('en_US');\n\n // Events\n useEffect(() => {\n const localeEvent = events.on(\n 'locale',\n (locale: string) => {\n setLang(locale as Lang);\n },\n { eager: true }\n );\n return () => {\n localeEvent?.off();\n };\n }, []);\n\n return (\n <UIProvider lang={lang} langDefinitions={langDefinitions}>\n {children}\n </UIProvider>\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 *******************************************************************/\n\nimport { Render } from '@adobe-commerce/elsie/lib';\nimport { Provider } from './Provider';\n\nexport const render = new Render(<Provider />);\n"],"names":["langDefinitions","en_US","Provider","children","lang","setLang","useState","useEffect","localeEvent","events","locale","jsx","UIProvider","render","Render"],"mappings":"4zGA0BMA,EAAkB,CACtB,QAASC,CACX,EAMaC,EAAoD,CAAC,CAChE,SAAAC,CACF,IAAM,CACJ,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAe,OAAO,EAG9C,OAAAC,EAAU,IAAM,CACd,MAAMC,EAAcC,EAAO,GACzB,SACCC,GAAmB,CAClBL,EAAQK,CAAc,CACxB,EACA,CAAE,MAAO,EAAK,CAChB,EACA,MAAO,IAAM,CACXF,GAAA,MAAAA,EAAa,KACf,CACF,EAAG,EAAE,EAGFG,EAAAC,EAAA,CAAW,KAAAR,EAAY,gBAAAJ,EACrB,SAAAG,CACH,CAAA,CAEJ,ECtCaU,EAAS,IAAIC,EAAOH,EAACT,IAAS,CAAE"}
|