@dropins/storefront-company-management 1.0.0-beta7 → 1.0.0-beta8
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/checkCompanyCreditEnabled/checkCompanyCreditEnabled.d.ts +4 -0
- package/api/checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.d.ts +18 -0
- package/api/checkCompanyCreditEnabled/index.d.ts +18 -0
- package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
- package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
- package/api/getCompanyCredit/index.d.ts +18 -0
- package/api/getCompanyCreditHistory/getCompanyCreditHistory.d.ts +5 -0
- package/api/getCompanyCreditHistory/graphql/getCompanyCreditHistory.graphql.d.ts +18 -0
- package/api/getCompanyCreditHistory/index.d.ts +19 -0
- package/api/index.d.ts +3 -0
- package/api.js +8 -2
- package/api.js.map +1 -1
- package/chunks/CompanyLoaders.js +4 -0
- package/chunks/CompanyLoaders.js.map +1 -0
- package/chunks/createCompany.js +3 -3
- package/chunks/createCompany.js.map +1 -1
- package/chunks/fetch-error.js +1 -1
- package/chunks/fetch-error.js.map +1 -1
- package/chunks/getCompanyCreditHistory.js +68 -0
- package/chunks/getCompanyCreditHistory.js.map +1 -0
- package/chunks/getCustomerCompany.js +3 -3
- package/chunks/getCustomerCompany.js.map +1 -1
- package/chunks/network-error.js +4 -0
- package/chunks/network-error.js.map +1 -0
- package/chunks/updateCompany.js +3 -3
- package/chunks/updateCompany.js.map +1 -1
- package/chunks/validateCompanyEmail.js +3 -3
- package/chunks/validateCompanyEmail.js.map +1 -1
- package/components/CompanyCreditDisplay/CompanyCreditDisplay.d.ts +7 -0
- package/components/CompanyCreditDisplay/index.d.ts +19 -0
- package/components/CompanyCreditHistoryDisplay/CompanyCreditHistoryDisplay.d.ts +15 -0
- package/components/CompanyCreditHistoryDisplay/index.d.ts +19 -0
- package/components/CompanyLoaders/CompanyLoaders.d.ts +10 -0
- package/components/index.d.ts +2 -0
- package/containers/CompanyCredit/CompanyCredit.d.ts +16 -0
- package/containers/CompanyCredit/index.d.ts +19 -0
- package/containers/CompanyCredit.d.ts +3 -0
- package/containers/CompanyCredit.js +4 -0
- package/containers/CompanyCredit.js.map +1 -0
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/containers/CompanyRegistration.js +1 -1
- package/containers/CompanyRegistration.js.map +1 -1
- package/containers/CustomerCompanyInfo.js +1 -1
- package/containers/CustomerCompanyInfo.js.map +1 -1
- package/containers/index.d.ts +1 -0
- package/data/models/company-credit-history.d.ts +54 -0
- package/data/models/company-credit-info.d.ts +33 -0
- package/data/models/index.d.ts +2 -0
- package/data/transforms/index.d.ts +2 -0
- package/data/transforms/transform-company-credit-history.d.ts +5 -0
- package/data/transforms/transform-company-credit.d.ts +5 -0
- package/hooks/containers/index.d.ts +1 -0
- package/hooks/containers/useCompanyCreditHistory.d.ts +32 -0
- package/i18n/en_US.json.d.ts +43 -0
- package/package.json +1 -1
- package/render.js +4 -2
- package/render.js.map +1 -1
- package/types/api/checkCompanyCreditEnabled.types.d.ts +21 -0
- package/types/api/getCompanyCredit.types.d.ts +40 -0
- package/types/api/getCompanyCreditHistory.types.d.ts +61 -0
- package/types/api/getCompanyCreditHistoryParams.types.d.ts +53 -0
- package/chunks/useCompanyContextListener.js +0 -4
- package/chunks/useCompanyContextListener.js.map +0 -1
|
@@ -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 declare const CHECK_COMPANY_CREDIT_ENABLED = "\n query CHECK_COMPANY_CREDIT_ENABLED {\n storeConfig{\n company_credit_enabled\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=checkCompanyCreditEnabled.graphql.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 './checkCompanyCreditEnabled';
|
|
18
|
+
//# sourceMappingURL=index.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 declare const GET_COMPANY_CREDIT = "\n query GET_COMPANY_CREDIT \n {\n company {\n credit {\n available_credit {\n currency\n value\n }\n credit_limit {\n currency\n value\n }\n outstanding_balance {\n currency\n value\n }\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=getCompanyCredit.graphql.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 './getCompanyCredit';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GetCompanyCreditHistoryParams } from '../../types/api/getCompanyCreditHistoryParams.types';
|
|
2
|
+
import { CompanyCreditHistory } from '../../data/models';
|
|
3
|
+
|
|
4
|
+
export declare const getCompanyCreditHistory: (params?: GetCompanyCreditHistoryParams) => Promise<CompanyCreditHistory | null>;
|
|
5
|
+
//# sourceMappingURL=getCompanyCreditHistory.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 declare const GET_COMPANY_CREDIT_HISTORY = "\n query GET_COMPANY_CREDIT_HISTORY($filter: CompanyCreditHistoryFilterInput, $pageSize: Int, $currentPage: Int) {\n company {\n credit_history(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n ) {\n items {\n amount {\n currency\n value\n }\n balance {\n available_credit {\n currency\n value\n }\n credit_limit {\n currency\n value\n }\n outstanding_balance {\n currency\n value\n }\n }\n custom_reference_number\n date\n type\n updated_by {\n name\n type\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=getCompanyCreditHistory.graphql.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './getCompanyCreditHistory';
|
|
18
|
+
export * from '../../types/api/getCompanyCreditHistoryParams.types';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -28,4 +28,7 @@ export * from './allowCompanyRegistration';
|
|
|
28
28
|
export * from './createCompany';
|
|
29
29
|
export * from './isCompanyUser';
|
|
30
30
|
export * from './isCompanyAdmin';
|
|
31
|
+
export * from './getCompanyCredit';
|
|
32
|
+
export * from './getCompanyCreditHistory';
|
|
33
|
+
export * from './checkCompanyCreditEnabled';
|
|
31
34
|
//# sourceMappingURL=index.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{f as i}from"./chunks/fetch-graphql.js";import{g,r as
|
|
3
|
+
import{f as i}from"./chunks/fetch-graphql.js";import{g as A,r as T,s as R,a as b,b as S}from"./chunks/fetch-graphql.js";import{f as O,g as N,u as I}from"./chunks/updateCompany.js";import{g as L,v as M}from"./chunks/validateCompanyEmail.js";import{D,S as x,c as G,g as F}from"./chunks/createCompany.js";import{c as B,g as Q}from"./chunks/getCustomerCompany.js";import{a as w,i as Y}from"./chunks/isCompanyUser.js";import{g as K,a as W}from"./chunks/getCompanyCreditHistory.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/network-error.js";import"@dropins/tools/event-bus.js";import"./chunks/fetch-error.js";const u=async(e={})=>({success:!0,config:e}),c=`
|
|
4
4
|
query GET_CUSTOMER_COMPANIES_WITH_ROLES {
|
|
5
5
|
customer {
|
|
6
6
|
companies(input: {}) {
|
|
@@ -15,5 +15,11 @@ import{f as i}from"./chunks/fetch-graphql.js";import{g,r as E,s as h,a as S,b as
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
`,
|
|
18
|
+
`,y=async()=>{var e,t,a;try{const r=await i(c,{method:"POST"});if((e=r.errors)!=null&&e.length)return!1;const n=(t=r.data)==null?void 0:t.customer;if(!n)return!1;const s=((a=n.companies)==null?void 0:a.items)??[];if(!Array.isArray(s)||s.length===0)return!1;const o=n.role;return o?o.id==="0"||typeof o.id=="number"&&o.id===0||o.name==="Company Administrator":!1}catch(r){return console.error("Error checking if customer is company admin:",r),!1}};var m=(e=>(e.ALLOCATION="ALLOCATION",e.UPDATE="UPDATE",e.PURCHASE="PURCHASE",e.REIMBURSEMENT="REIMBURSEMENT",e))(m||{});const E=`
|
|
19
|
+
query CHECK_COMPANY_CREDIT_ENABLED {
|
|
20
|
+
storeConfig{
|
|
21
|
+
company_credit_enabled
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`,g=async()=>{var e,t,a;try{const r=await i(E,{method:"GET",cache:"no-cache"});return(e=r.errors)!=null&&e.length?{creditEnabled:!1,error:"Unable to check company credit configuration"}:((a=(t=r.data)==null?void 0:t.storeConfig)==null?void 0:a.company_credit_enabled)===!0?{creditEnabled:!0}:{creditEnabled:!1,error:"Company credit is not enabled in store configuration"}}catch{return{creditEnabled:!1,error:"Company credit functionality not available"}}};export{m as CompanyCreditOperationType,D as DEFAULT_COUNTRY,x as STORE_CONFIG_DEFAULTS,w as allowCompanyRegistration,g as checkCompanyCreditEnabled,B as companyEnabled,G as createCompany,i as fetchGraphQl,O as fetchUserPermissions,N as getCompany,K as getCompanyCredit,W as getCompanyCreditHistory,A as getConfig,L as getCountries,Q as getCustomerCompany,F as getStoreConfig,u as initialize,y as isCompanyAdmin,Y as isCompanyUser,T as removeFetchGraphQlHeader,R as setEndpoint,b as setFetchGraphQlHeader,S as setFetchGraphQlHeaders,I as updateCompany,M as validateCompanyEmail};
|
|
19
25
|
//# sourceMappingURL=api.js.map
|
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/isCompanyAdmin/graphql/isCompanyAdmin.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/isCompanyAdmin.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 *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES_WITH_ROLES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\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 \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES_WITH_ROLES } from './graphql/isCompanyAdmin.graphql';\n\ninterface CompanyRole {\n id: string;\n name: string;\n}\n\ninterface CompanyBasicInfo {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesWithRolesResponse {\n customer: {\n companies: {\n items: CompanyBasicInfo[];\n };\n role: CompanyRole | null;\n } | null;\n}\n\n/**\n * Check if the current authenticated customer is a company administrator in any company\n * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise\n */\nexport const isCompanyAdmin = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesWithRolesResponse>(GET_CUSTOMER_COMPANIES_WITH_ROLES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const customer = response.data?.customer;\n if (!customer) {\n return false;\n }\n\n // Check if user is part of at least one company\n const companies = customer.companies?.items ?? [];\n if (!Array.isArray(companies) || companies.length === 0) {\n return false;\n }\n\n // Check if user has admin role\n const customerRole = customer.role;\n if (!customerRole) {\n return false;\n }\n\n // Check if user is company administrator by role ID or name\n return customerRole.id === '0' || \n (typeof customerRole.id === 'number' && customerRole.id === 0) ||\n customerRole.name === 'Company Administrator';\n } catch (error) {\n console.error('Error checking if customer is company admin:', error);\n return false;\n }\n};\n"],"names":["initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","response","fetchGraphQl","_a","customer","_b","companies","_c","customerRole","error"],"mappings":"ygBAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCZWC,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC0BlDC,EAAiB,SAA8B,WACtD,GAAA,CACI,MAAAC,EAAW,MAAMC,EAAiDH,EAAmC,CACzG,OAAQ,MAAA,CACT,EAEG,IAAAI,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZ,MAAA,GAGH,MAAAC,GAAWC,EAAAJ,EAAS,OAAT,YAAAI,EAAe,SAChC,GAAI,CAACD,EACI,MAAA,GAIT,MAAME,IAAYC,EAAAH,EAAS,YAAT,YAAAG,EAAoB,QAAS,CAAC,EAChD,GAAI,CAAC,MAAM,QAAQD,CAAS,GAAKA,EAAU,SAAW,EAC7C,MAAA,GAIT,MAAME,EAAeJ,EAAS,KAC9B,OAAKI,EAKEA,EAAa,KAAO,KACnB,OAAOA,EAAa,IAAO,UAAYA,EAAa,KAAO,GAC5DA,EAAa,OAAS,wBANpB,SAOFC,EAAO,CACN,eAAA,MAAM,+CAAgDA,CAAK,EAC5D,EAAA,CAEX"}
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/isCompanyAdmin.ts","/@dropins/storefront-company-management/src/types/api/getCompanyCreditHistoryParams.types.ts","/@dropins/storefront-company-management/src/api/checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/checkCompanyCreditEnabled/checkCompanyCreditEnabled.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 *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES_WITH_ROLES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\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 \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES_WITH_ROLES } from './graphql/isCompanyAdmin.graphql';\n\ninterface CompanyRole {\n id: string;\n name: string;\n}\n\ninterface CompanyBasicInfo {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesWithRolesResponse {\n customer: {\n companies: {\n items: CompanyBasicInfo[];\n };\n role: CompanyRole | null;\n } | null;\n}\n\n/**\n * Check if the current authenticated customer is a company administrator in any company\n * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise\n */\nexport const isCompanyAdmin = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesWithRolesResponse>(GET_CUSTOMER_COMPANIES_WITH_ROLES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const customer = response.data?.customer;\n if (!customer) {\n return false;\n }\n\n // Check if user is part of at least one company\n const companies = customer.companies?.items ?? [];\n if (!Array.isArray(companies) || companies.length === 0) {\n return false;\n }\n\n // Check if user has admin role\n const customerRole = customer.role;\n if (!customerRole) {\n return false;\n }\n\n // Check if user is company administrator by role ID or name\n return customerRole.id === '0' || \n (typeof customerRole.id === 'number' && customerRole.id === 0) ||\n customerRole.name === 'Company Administrator';\n } catch (error) {\n console.error('Error checking if customer is company admin:', error);\n return false;\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\nexport enum CompanyCreditOperationType {\n ALLOCATION = 'ALLOCATION',\n UPDATE = 'UPDATE',\n PURCHASE = 'PURCHASE',\n REIMBURSEMENT = 'REIMBURSEMENT'\n}\n\nexport interface CompanyCreditHistoryFilterInput {\n /**\n * The purchase order number associated with the company credit operation.\n */\n customReferenceNumber?: string;\n\n /**\n * The type of the company credit operation.\n */\n operationType?: CompanyCreditOperationType;\n\n /**\n * The name of the person submitting the company credit operation.\n */\n updatedBy?: string;\n}\n\nexport interface GetCompanyCreditHistoryParams {\n /**\n * Filter criteria for narrowing the results of a credit history search.\n */\n filter?: CompanyCreditHistoryFilterInput;\n\n /**\n * Number of items to return per page.\n * @default 20\n */\n pageSize?: number;\n\n /**\n * Current page number.\n * @default 1\n */\n currentPage?: number;\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\nexport const CHECK_COMPANY_CREDIT_ENABLED = /* GraphQL */ `\n query CHECK_COMPANY_CREDIT_ENABLED {\n storeConfig{\n company_credit_enabled\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\nimport { CHECK_COMPANY_CREDIT_ENABLED } from \"./graphql/checkCompanyCreditEnabled.graphql\";\nimport { CheckCompanyCreditEnabledResponse } from '../../types/api/checkCompanyCreditEnabled.types';\nimport { fetchGraphQl } from '../fetch-graphql';\n\nexport const checkCompanyCreditEnabled = async (): Promise<CheckCompanyCreditEnabledResponse> => {\n try {\n const response = await fetchGraphQl(CHECK_COMPANY_CREDIT_ENABLED, {\n method: 'GET',\n cache: 'no-cache',\n });\n\n // If there are errors, return false with error message\n if (response.errors?.length) {\n return {\n creditEnabled: false,\n error: 'Unable to check company credit configuration'\n };\n }\n\n // Check if company credit is enabled in store config\n const companyCreditEnabled = response.data?.storeConfig?.company_credit_enabled;\n \n if (companyCreditEnabled === true) {\n return {\n creditEnabled: true\n };\n }\n\n // If company credit is disabled or not configured\n return {\n creditEnabled: false,\n error: 'Company credit is not enabled in store configuration'\n };\n\n } catch (error) {\n return {\n creditEnabled: false,\n error: 'Company credit functionality not available'\n };\n }\n};\n"],"names":["initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","response","fetchGraphQl","_a","customer","_b","companies","_c","customerRole","error","CompanyCreditOperationType","CHECK_COMPANY_CREDIT_ENABLED","checkCompanyCreditEnabled"],"mappings":"0mBAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCZWC,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC0BlDC,EAAiB,SAA8B,WACtD,GAAA,CACI,MAAAC,EAAW,MAAMC,EAAiDH,EAAmC,CACzG,OAAQ,MAAA,CACT,EAEG,IAAAI,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZ,MAAA,GAGH,MAAAC,GAAWC,EAAAJ,EAAS,OAAT,YAAAI,EAAe,SAChC,GAAI,CAACD,EACI,MAAA,GAIT,MAAME,IAAYC,EAAAH,EAAS,YAAT,YAAAG,EAAoB,QAAS,CAAC,EAChD,GAAI,CAAC,MAAM,QAAQD,CAAS,GAAKA,EAAU,SAAW,EAC7C,MAAA,GAIT,MAAME,EAAeJ,EAAS,KAC9B,OAAKI,EAKEA,EAAa,KAAO,KACnB,OAAOA,EAAa,IAAO,UAAYA,EAAa,KAAO,GAC5DA,EAAa,OAAS,wBANpB,SAOFC,EAAO,CACN,eAAA,MAAM,+CAAgDA,CAAK,EAC5D,EAAA,CAEX,EC7DY,IAAAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,cAAgB,gBAJNA,IAAAA,GAAA,CAAA,CAAA,ECAC,MAAAC,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECI7CC,EAA4B,SAAwD,WAC3F,GAAA,CACI,MAAAX,EAAW,MAAMC,EAAaS,EAA8B,CAChE,OAAQ,MACR,MAAO,UAAA,CACR,EAGG,OAAAR,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZ,CACL,cAAe,GACf,MAAO,8CACT,IAI2BI,GAAAF,EAAAJ,EAAS,OAAT,YAAAI,EAAe,cAAf,YAAAE,EAA4B,0BAE5B,GACpB,CACL,cAAe,EACjB,EAIK,CACL,cAAe,GACf,MAAO,sDACT,OAEc,CACP,MAAA,CACL,cAAe,GACf,MAAO,4CACT,CAAA,CAEJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsxs as t,jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{Card as o,Skeleton as i,SkeletonRow as a}from"@dropins/tools/components.js";import{classes as s}from"@dropins/tools/lib.js";const h=({testId:r,withCard:l=!0})=>{const n=t(i,{"data-testid":r||"companySkeletonLoader",children:[e(a,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(a,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(a,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return l?n:e(o,{variant:"secondary",className:s(["company-company-loaders","company-company-loaders--card-loader"]),children:n})},p=({testId:r})=>t("div",{className:"company-credit-skeleton-loader","data-testid":r||"companyCreditSkeletonLoader",children:[e(i,{children:e(a,{variant:"row",size:"small",lines:2})}),e(i,{children:e(a,{variant:"row",size:"small",lines:2})}),e(i,{children:e(a,{variant:"row",size:"small",lines:2})})]}),y=({testId:r})=>e("div",{className:"company-credit-history-skeleton-loader","data-testid":r||"companyCreditHistorySkeletonLoader",children:e(i,{children:e(a,{variant:"row",size:"small",fullWidth:!0,lines:3})})});export{h as C,p as a,y as b};
|
|
4
|
+
//# sourceMappingURL=CompanyLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompanyLoaders.js","sources":["/@dropins/storefront-company-management/src/components/CompanyLoaders/CompanyLoaders.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 { 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\nexport const CompanyUsersTableLoader = ({ testId }: { testId?: string }) => {\n return (\n <div className=\"company-users-skeleton-loader\" data-testid={testId || 'companyUsersSkeletonLoader'}>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" fullWidth={true} lines={3} />\n </Skeleton>\n </div>\n );\n};\n\nexport const CompanyCreditLoader = ({ testId }: { testId?: string }) => {\n return (\n <div className=\"company-credit-skeleton-loader\" data-testid={testId || 'companyCreditSkeletonLoader'}>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" lines={2} />\n </Skeleton>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" lines={2} />\n </Skeleton>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" lines={2} />\n </Skeleton>\n </div>\n );\n};\nexport const CompanyCreditHistoryLoader = ({ testId }: { testId?: string }) => {\n return (\n <div className=\"company-credit-history-skeleton-loader\" data-testid={testId || 'companyCreditHistorySkeletonLoader'}>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" fullWidth={true} lines={3} />\n </Skeleton>\n </div>\n );\n};\n\nexport const CompanyUserFormLoader = () => {\n return (\n <div className=\"company-user-form-skeleton-loader\" data-testid=\"companyUserFormLoader\">\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"medium\" fullWidth={true} lines={7} />\n </Skeleton>\n </div>\n );\n};\n"],"names":["CompanyCardLoader","testId","withCard","defaultSkeleton","jsxs","Skeleton","jsx","SkeletonRow","Card","classes","CompanyCreditLoader","CompanyCreditHistoryLoader"],"mappings":"wMAoBO,MAAMA,EAAoB,CAAC,CAChC,OAAAC,EACA,SAAAC,EAAW,EACb,IAGM,CACJ,MAAMC,EACJC,EAACC,EAAS,CAAA,cAAaJ,GAAU,wBAC/B,SAAA,CAAAK,EAACC,EAAA,CACC,QAAQ,UACR,KAAK,SACL,UAAW,GACX,MAAO,CAAA,CACT,EACAD,EAACC,GAAY,QAAQ,UAAU,KAAK,SAAS,UAAW,GAAM,MAAO,CAAG,CAAA,EACxED,EAACC,GAAY,QAAQ,UAAU,KAAK,SAAS,UAAW,GAAM,MAAO,CAAG,CAAA,CAAA,EAC1E,EAGF,OAAIL,EACKC,EAIPG,EAACE,EAAA,CACC,QAAQ,YACR,UAAWC,EAAQ,CACjB,0BACA,sCAAA,CACD,EAEA,SAAAN,CAAA,CACH,CAEJ,EAYaO,EAAsB,CAAC,CAAE,OAAAT,OAEjC,MAAI,CAAA,UAAU,iCAAiC,cAAaA,GAAU,8BACrE,SAAA,CAACK,EAAAD,EAAA,CACC,WAACE,EAAY,CAAA,QAAQ,MAAM,KAAK,QAAQ,MAAO,CAAA,CAAG,CACpD,CAAA,EACAD,EAACD,EACC,CAAA,SAAAC,EAACC,EAAY,CAAA,QAAQ,MAAM,KAAK,QAAQ,MAAO,CAAA,CAAG,CACpD,CAAA,EACAD,EAACD,EACC,CAAA,SAAAC,EAACC,EAAY,CAAA,QAAQ,MAAM,KAAK,QAAQ,MAAO,CAAG,CAAA,CACpD,CAAA,CAAA,EACF,EAGSI,EAA6B,CAAC,CAAE,OAAAV,KAEzCK,EAAC,OAAI,UAAU,yCAAyC,cAAaL,GAAU,qCAC3E,WAACI,EACC,CAAA,SAAAC,EAACC,GAAY,QAAQ,MAAM,KAAK,QAAQ,UAAW,GAAM,MAAO,EAAG,EACrE,CACJ,CAAA"}
|
package/chunks/createCompany.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{h as
|
|
3
|
+
import{h as c}from"./network-error.js";import{h as a}from"./fetch-error.js";import{f as s}from"./fetch-graphql.js";import{t as l}from"./validateCompanyEmail.js";const g=`
|
|
4
4
|
query getStoreConfig {
|
|
5
5
|
storeConfig {
|
|
6
6
|
default_country
|
|
7
7
|
store_code
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`,
|
|
10
|
+
`,u="US",o={defaultCountry:u,storeCode:""},T=async()=>await s(g,{method:"GET"}).then(e=>{var n;return(n=e.errors)!=null&&n.length?a(e.errors):p(e)}).catch(c),p=e=>{var r;if(!((r=e==null?void 0:e.data)!=null&&r.storeConfig))return o;const{default_country:n,store_code:t}=e.data.storeConfig;return{defaultCountry:n||o.defaultCountry,storeCode:t||o.storeCode}},m=`
|
|
11
11
|
mutation CreateCompany($input: CompanyCreateInput!) {
|
|
12
12
|
createCompany(input: $input) {
|
|
13
13
|
company {
|
|
@@ -40,5 +40,5 @@ import{h as a,a as l}from"./fetch-error.js";import{f as d}from"./fetch-graphql.j
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
`,
|
|
43
|
+
`,_=e=>{var t;const n={};if(e.regionCode&&e.regionCode.trim())n.region_code=e.regionCode.trim(),e.regionId&&(n.region_id=typeof e.regionId=="string"?parseInt(e.regionId,10):e.regionId);else if(e.region&&typeof e.region=="string"&&e.region.includes(",")){const[r,i]=e.region.split(",");n.region_code=r.trim(),n.region_id=parseInt(i.trim(),10)}else if(e.region&&e.region.trim()){const r=e.region.trim();if(/^\d+$/.test(r))throw new Error("Region selection error: Missing region code. Please ensure regions are properly loaded.");n.region=r,n.region_code=r}if(!n.region_code)throw new Error("Region code is required. Please select a state/province or enter a region name.");return{company_name:e.companyName,company_email:e.companyEmail,legal_name:e.legalName,vat_tax_id:e.vatTaxId,reseller_id:e.resellerId,legal_address:{street:Array.isArray(e.street)?e.street.filter(r=>r&&r.trim()!==""):[e.street].filter(r=>r&&r.trim()!==""),city:e.city,region:n,postcode:e.postcode,country_id:e.countryCode,telephone:e.addressTelephone},company_admin:{email:e.adminEmail,firstname:e.adminFirstname,lastname:e.adminLastname,job_title:e.adminJobTitle,telephone:e.adminWorkTelephone,gender:e.adminGender?typeof e.adminGender=="string"?parseInt(e.adminGender,10):e.adminGender:void 0,custom_attributes:((t=e.adminCustomAttributes)==null?void 0:t.map(r=>({attribute_code:r.attribute_code,value:r.value})))||[]}}},E=async e=>{var n;try{const t=_(e),r=await s(m,{method:"POST",variables:{input:t}});return(n=r.errors)!=null&&n.length?{success:!1,errors:r.errors.map(d=>d.message)}:{success:!0,company:l(r)}}catch(t){return console.error("Failed to create company:",t),{success:!1,errors:["Failed to create company. Please try again."]}}};export{u as D,o as S,E as c,T as g};
|
|
44
44
|
//# sourceMappingURL=createCompany.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCompany.js","sources":["/@dropins/storefront-company-management/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-company-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-company-management/src/api/createCompany/graphql/createCompany.graphql.ts","/@dropins/storefront-company-management/src/data/transforms/company.ts","/@dropins/storefront-company-management/src/api/createCompany/createCompany.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\nexport const GET_STORE_CONFIG_QUERY = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\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\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_STORE_CONFIG_QUERY } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/company-management/lib/network-error';\nimport { handleFetchError } from '@/company-management/lib/fetch-error';\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { transformStoreConfig } from '@/company-management/data/transforms';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfigModel = {\n defaultCountry: DEFAULT_COUNTRY,\n storeCode: '',\n};\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG_QUERY, {\n method: 'GET',\n })\n .then((response: GetStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(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 *******************************************************************/\n\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/company-management/api/getStoreConfig/getStoreConfig';\n\nexport const transformStoreConfig = (\n response: GetStoreConfigResponse\n): StoreConfigModel => {\n if (!response?.data?.storeConfig) return STORE_CONFIG_DEFAULTS;\n\n const { default_country, store_code } = response.data.storeConfig;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n storeCode: store_code || STORE_CONFIG_DEFAULTS.storeCode,\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\nexport const CREATE_COMPANY_MUTATION = /* GraphQL */ `\n mutation CreateCompany($input: CompanyCreateInput!) {\n createCompany(input: $input) {\n company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n legal_address {\n street\n city\n region {\n region_code\n region\n region_id\n }\n postcode\n country_code\n telephone\n }\n company_admin {\n id\n firstname\n lastname\n email\n job_title\n telephone\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\nimport { CompanyFormData } from '../models/company';\nimport { CompanyCreateInput } from '@/company-management/api/createCompany';\n\nexport const transformFormDataToCreateInput = (formData: CompanyFormData): CompanyCreateInput => {\n // Build region object - ensure we have at least one region field\n const regionInput: any = {};\n \n // Handle region data based on what we receive from the form\n if (formData.regionCode && formData.regionCode.trim()) {\n // We have regionCode (preferred path)\n regionInput.region_code = formData.regionCode.trim();\n if (formData.regionId) {\n regionInput.region_id = typeof formData.regionId === 'string' ? parseInt(formData.regionId, 10) : formData.regionId;\n }\n } else if (formData.region && typeof formData.region === 'string' && formData.region.includes(',')) {\n // Dropdown selection: parse \"AL,4\" format as fallback\n const [regionCode, regionId] = formData.region.split(',');\n regionInput.region_code = regionCode.trim();\n regionInput.region_id = parseInt(regionId.trim(), 10);\n } else if (formData.region && formData.region.trim()) {\n const regionValue = formData.region.trim();\n // Check if this is a numeric regionId (from dropdown) or text region name\n if (/^\\d+$/.test(regionValue)) {\n // This is likely a regionId from dropdown, but we only have the ID\n // We need both region_code and region_id for GraphQL, but we can't proceed without region_code\n throw new Error('Region selection error: Missing region code. Please ensure regions are properly loaded.');\n } else {\n // Text input: free-form region name (countries without predefined regions)\n regionInput.region = regionValue;\n regionInput.region_code = regionValue;\n }\n }\n \n // Ensure we have at least region_code (required by GraphQL)\n if (!regionInput.region_code) {\n throw new Error('Region code is required. Please select a state/province or enter a region name.');\n }\n\n return {\n company_name: formData.companyName,\n company_email: formData.companyEmail,\n legal_name: formData.legalName,\n vat_tax_id: formData.vatTaxId,\n reseller_id: formData.resellerId,\n legal_address: {\n street: Array.isArray(formData.street) \n ? formData.street.filter((line: string) => line && line.trim() !== '') // Remove empty lines\n : [formData.street].filter((line: string) => line && line.trim() !== ''), // Handle case where street is not an array\n city: formData.city,\n region: regionInput,\n postcode: formData.postcode,\n country_id: formData.countryCode,\n telephone: formData.addressTelephone,\n },\n company_admin: {\n email: formData.adminEmail,\n firstname: formData.adminFirstname?.trim() || '',\n lastname: formData.adminLastname?.trim() || '',\n job_title: formData.adminJobTitle,\n telephone: formData.adminWorkTelephone,\n gender: formData.adminGender ? (typeof formData.adminGender === 'string' ? parseInt(formData.adminGender, 10) : formData.adminGender) : undefined,\n custom_attributes: formData.adminCustomAttributes?.map(attr => ({\n attribute_code: attr.attribute_code,\n value: attr.value,\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\nimport { fetchGraphQl } from '@/company-management/api/fetch-graphql';\nimport { CREATE_COMPANY_MUTATION } from './graphql/createCompany.graphql';\nimport { CompanyRegistrationModel } from '@/company-management/data/models/company';\nimport { transformFormDataToCreateInput } from '@/company-management/data/transforms/company';\nimport { transformCreateCompanyResponse } from '@/company-management/data/transforms/transform-company';\n\nexport interface CompanyCreateInput {\n company_name: string;\n company_email: string;\n legal_name?: string;\n vat_tax_id?: string;\n reseller_id?: string;\n legal_address: {\n street: string[];\n city: string;\n region: {\n region_code: string;\n region?: string;\n region_id?: number;\n };\n postcode: string;\n country_id: string;\n telephone?: string;\n };\n company_admin: {\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string;\n telephone?: string;\n gender?: number;\n custom_attributes?: Array<{\n attribute_code: string;\n value: string;\n }>;\n };\n}\n\n\nexport const createCompany = async (formData: any): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }> => {\n try {\n const input = transformFormDataToCreateInput(formData);\n const response = await fetchGraphQl(CREATE_COMPANY_MUTATION, {\n method: 'POST',\n variables: { input },\n });\n\n if (response.errors?.length) {\n return {\n success: false,\n errors: response.errors.map((error: any) => error.message),\n };\n }\n\n // Transform the GraphQL response using the dedicated transformer\n const transformedCompany = transformCreateCompanyResponse(response);\n\n return {\n success: true,\n company: transformedCompany,\n };\n } catch (error) {\n console.error('Failed to create company:', error);\n return {\n success: false,\n errors: ['Failed to create company. Please try again.'],\n };\n }\n};"],"names":["GET_STORE_CONFIG_QUERY","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","fetchGraphQl","response","_a","handleFetchError","transformStoreConfig","handleNetworkError","default_country","store_code","CREATE_COMPANY_MUTATION","transformFormDataToCreateInput","formData","regionInput","regionCode","regionId","regionValue","line","_b","_c","attr","createCompany","input","error","transformCreateCompanyResponse"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"createCompany.js","sources":["/@dropins/storefront-company-management/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-company-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-company-management/src/api/createCompany/graphql/createCompany.graphql.ts","/@dropins/storefront-company-management/src/data/transforms/company.ts","/@dropins/storefront-company-management/src/api/createCompany/createCompany.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\nexport const GET_STORE_CONFIG_QUERY = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\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\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_STORE_CONFIG_QUERY } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/company-management/lib/network-error';\nimport { handleFetchError } from '@/company-management/lib/fetch-error';\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { transformStoreConfig } from '@/company-management/data/transforms';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfigModel = {\n defaultCountry: DEFAULT_COUNTRY,\n storeCode: '',\n};\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG_QUERY, {\n method: 'GET',\n })\n .then((response: GetStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(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 *******************************************************************/\n\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/company-management/api/getStoreConfig/getStoreConfig';\n\nexport const transformStoreConfig = (\n response: GetStoreConfigResponse\n): StoreConfigModel => {\n if (!response?.data?.storeConfig) return STORE_CONFIG_DEFAULTS;\n\n const { default_country, store_code } = response.data.storeConfig;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n storeCode: store_code || STORE_CONFIG_DEFAULTS.storeCode,\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\nexport const CREATE_COMPANY_MUTATION = /* GraphQL */ `\n mutation CreateCompany($input: CompanyCreateInput!) {\n createCompany(input: $input) {\n company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n legal_address {\n street\n city\n region {\n region_code\n region\n region_id\n }\n postcode\n country_code\n telephone\n }\n company_admin {\n id\n firstname\n lastname\n email\n job_title\n telephone\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\nimport { CompanyFormData } from '../models/company';\nimport { CompanyCreateInput } from '@/company-management/api/createCompany';\n\nexport const transformFormDataToCreateInput = (formData: CompanyFormData): CompanyCreateInput => {\n // Build region object - ensure we have at least one region field\n const regionInput: any = {};\n \n // Handle region data based on what we receive from the form\n if (formData.regionCode && formData.regionCode.trim()) {\n // We have regionCode (preferred path)\n regionInput.region_code = formData.regionCode.trim();\n if (formData.regionId) {\n regionInput.region_id = typeof formData.regionId === 'string' ? parseInt(formData.regionId, 10) : formData.regionId;\n }\n } else if (formData.region && typeof formData.region === 'string' && formData.region.includes(',')) {\n // Dropdown selection: parse \"AL,4\" format as fallback\n const [regionCode, regionId] = formData.region.split(',');\n regionInput.region_code = regionCode.trim();\n regionInput.region_id = parseInt(regionId.trim(), 10);\n } else if (formData.region && formData.region.trim()) {\n const regionValue = formData.region.trim();\n // Check if this is a numeric regionId (from dropdown) or text region name\n if (/^\\d+$/.test(regionValue)) {\n // This is likely a regionId from dropdown, but we only have the ID\n // We need both region_code and region_id for GraphQL, but we can't proceed without region_code\n throw new Error('Region selection error: Missing region code. Please ensure regions are properly loaded.');\n } else {\n // Text input: free-form region name (countries without predefined regions)\n regionInput.region = regionValue;\n regionInput.region_code = regionValue;\n }\n }\n \n // Ensure we have at least region_code (required by GraphQL)\n if (!regionInput.region_code) {\n throw new Error('Region code is required. Please select a state/province or enter a region name.');\n }\n\n return {\n company_name: formData.companyName,\n company_email: formData.companyEmail,\n legal_name: formData.legalName,\n vat_tax_id: formData.vatTaxId,\n reseller_id: formData.resellerId,\n legal_address: {\n street: Array.isArray(formData.street) \n ? formData.street.filter((line: string) => line && line.trim() !== '') // Remove empty lines\n : [formData.street].filter((line: string) => line && line.trim() !== ''), // Handle case where street is not an array\n city: formData.city,\n region: regionInput,\n postcode: formData.postcode,\n country_id: formData.countryCode,\n telephone: formData.addressTelephone,\n },\n company_admin: {\n email: formData.adminEmail,\n firstname: formData.adminFirstname,\n lastname: formData.adminLastname,\n job_title: formData.adminJobTitle,\n telephone: formData.adminWorkTelephone,\n gender: formData.adminGender ? (typeof formData.adminGender === 'string' ? parseInt(formData.adminGender, 10) : formData.adminGender) : undefined,\n custom_attributes: formData.adminCustomAttributes?.map(attr => ({\n attribute_code: attr.attribute_code,\n value: attr.value,\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\nimport { fetchGraphQl } from '@/company-management/api/fetch-graphql';\nimport { CREATE_COMPANY_MUTATION } from './graphql/createCompany.graphql';\nimport { CompanyRegistrationModel } from '@/company-management/data/models/company';\nimport { transformFormDataToCreateInput } from '@/company-management/data/transforms/company';\nimport { transformCreateCompanyResponse } from '@/company-management/data/transforms/transform-company';\n\nexport interface CompanyCreateInput {\n company_name: string;\n company_email: string;\n legal_name?: string;\n vat_tax_id?: string;\n reseller_id?: string;\n legal_address: {\n street: string[];\n city: string;\n region: {\n region_code: string;\n region?: string;\n region_id?: number;\n };\n postcode: string;\n country_id: string;\n telephone?: string;\n };\n company_admin: {\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string;\n telephone?: string;\n gender?: number;\n custom_attributes?: Array<{\n attribute_code: string;\n value: string;\n }>;\n };\n}\n\n\nexport const createCompany = async (formData: any): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }> => {\n try {\n const input = transformFormDataToCreateInput(formData);\n const response = await fetchGraphQl(CREATE_COMPANY_MUTATION, {\n method: 'POST',\n variables: { input },\n });\n\n if (response.errors?.length) {\n return {\n success: false,\n errors: response.errors.map((error: any) => error.message),\n };\n }\n\n // Transform the GraphQL response using the dedicated transformer\n const transformedCompany = transformCreateCompanyResponse(response);\n\n return {\n success: true,\n company: transformedCompany,\n };\n } catch (error) {\n console.error('Failed to create company:', error);\n return {\n success: false,\n errors: ['Failed to create company. Please try again.'],\n };\n }\n};"],"names":["GET_STORE_CONFIG_QUERY","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","fetchGraphQl","response","_a","handleFetchError","transformStoreConfig","handleNetworkError","default_country","store_code","CREATE_COMPANY_MUTATION","transformFormDataToCreateInput","formData","regionInput","regionCode","regionId","regionValue","line","attr","createCompany","input","error","transformCreateCompanyResponse"],"mappings":"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"}
|
package/chunks/fetch-error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
|
|
3
|
+
const s=r=>{const e=r.map(o=>o.message).join(" ");throw Error(e)};export{s as h};
|
|
4
4
|
//# sourceMappingURL=fetch-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-error.js","sources":["/@dropins/storefront-company-management/src/lib/
|
|
1
|
+
{"version":3,"file":"fetch-error.js","sources":["/@dropins/storefront-company-management/src/lib/fetch-error.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/** 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"],"names":["handleFetchError","errors","errorMessage","e"],"mappings":"AAiBa,MAAAA,EAAoBC,GAAuC,CAChE,MAAAC,EAAeD,EAAO,IAAKE,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMD,CAAY,CAC1B"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{h as R}from"./network-error.js";import{f as z}from"./fetch-graphql.js";const G=c=>{var r,n,l,e,t,d,u,a,_,y,o,g,b,v,f,C,h,p,i,T,E,I,P,D;return{credit:{available_credit:{currency:((e=(l=(n=(r=c==null?void 0:c.data)==null?void 0:r.company)==null?void 0:n.credit)==null?void 0:l.available_credit)==null?void 0:e.currency)||"",value:((a=(u=(d=(t=c==null?void 0:c.data)==null?void 0:t.company)==null?void 0:d.credit)==null?void 0:u.available_credit)==null?void 0:a.value)||0},credit_limit:{currency:((g=(o=(y=(_=c==null?void 0:c.data)==null?void 0:_.company)==null?void 0:y.credit)==null?void 0:o.credit_limit)==null?void 0:g.currency)||"",value:((C=(f=(v=(b=c==null?void 0:c.data)==null?void 0:b.company)==null?void 0:v.credit)==null?void 0:f.credit_limit)==null?void 0:C.value)||0},outstanding_balance:{currency:((T=(i=(p=(h=c==null?void 0:c.data)==null?void 0:h.company)==null?void 0:p.credit)==null?void 0:i.outstanding_balance)==null?void 0:T.currency)||"",value:((D=(P=(I=(E=c==null?void 0:c.data)==null?void 0:E.company)==null?void 0:I.credit)==null?void 0:P.outstanding_balance)==null?void 0:D.value)||0}}}},N=c=>{var n,l,e,t,d,u;const r=(l=(n=c==null?void 0:c.data)==null?void 0:n.company)==null?void 0:l.credit_history;return{items:((e=r==null?void 0:r.items)==null?void 0:e.map(a=>{var _,y,o,g,b,v,f,C,h,p,i,T,E,I,P,D;return{amount:{currency:((_=a==null?void 0:a.amount)==null?void 0:_.currency)||"",value:((y=a==null?void 0:a.amount)==null?void 0:y.value)||0},balance:{availableCredit:{currency:((g=(o=a==null?void 0:a.balance)==null?void 0:o.available_credit)==null?void 0:g.currency)||"",value:((v=(b=a==null?void 0:a.balance)==null?void 0:b.available_credit)==null?void 0:v.value)||0},creditLimit:{currency:((C=(f=a==null?void 0:a.balance)==null?void 0:f.credit_limit)==null?void 0:C.currency)||"",value:((p=(h=a==null?void 0:a.balance)==null?void 0:h.credit_limit)==null?void 0:p.value)||0},outstandingBalance:{currency:((T=(i=a==null?void 0:a.balance)==null?void 0:i.outstanding_balance)==null?void 0:T.currency)||"",value:((I=(E=a==null?void 0:a.balance)==null?void 0:E.outstanding_balance)==null?void 0:I.value)||0}},customReferenceNumber:(a==null?void 0:a.custom_reference_number)||void 0,date:(a==null?void 0:a.date)||"",type:(a==null?void 0:a.operation_type)||"",updatedBy:{name:((P=a==null?void 0:a.updated_by)==null?void 0:P.name)||"",type:((D=a==null?void 0:a.updated_by)==null?void 0:D.type)||""}}}))||[],pageInfo:{currentPage:((t=r==null?void 0:r.page_info)==null?void 0:t.current_page)||1,pageSize:((d=r==null?void 0:r.page_info)==null?void 0:d.page_size)||20,totalPages:((u=r==null?void 0:r.page_info)==null?void 0:u.total_pages)||0},totalCount:(r==null?void 0:r.total_count)||0}},S=`
|
|
4
|
+
query GET_COMPANY_CREDIT
|
|
5
|
+
{
|
|
6
|
+
company {
|
|
7
|
+
credit {
|
|
8
|
+
available_credit {
|
|
9
|
+
currency
|
|
10
|
+
value
|
|
11
|
+
}
|
|
12
|
+
credit_limit {
|
|
13
|
+
currency
|
|
14
|
+
value
|
|
15
|
+
}
|
|
16
|
+
outstanding_balance {
|
|
17
|
+
currency
|
|
18
|
+
value
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`,A=async()=>await z(S,{method:"GET",cache:"no-cache"}).then(c=>{var n;return(n=c.errors)!=null&&n.length?null:G(c)}).catch(R),O=`
|
|
24
|
+
query GET_COMPANY_CREDIT_HISTORY($filter: CompanyCreditHistoryFilterInput, $pageSize: Int, $currentPage: Int) {
|
|
25
|
+
company {
|
|
26
|
+
credit_history(
|
|
27
|
+
filter: $filter
|
|
28
|
+
pageSize: $pageSize
|
|
29
|
+
currentPage: $currentPage
|
|
30
|
+
) {
|
|
31
|
+
items {
|
|
32
|
+
amount {
|
|
33
|
+
currency
|
|
34
|
+
value
|
|
35
|
+
}
|
|
36
|
+
balance {
|
|
37
|
+
available_credit {
|
|
38
|
+
currency
|
|
39
|
+
value
|
|
40
|
+
}
|
|
41
|
+
credit_limit {
|
|
42
|
+
currency
|
|
43
|
+
value
|
|
44
|
+
}
|
|
45
|
+
outstanding_balance {
|
|
46
|
+
currency
|
|
47
|
+
value
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
custom_reference_number
|
|
51
|
+
date
|
|
52
|
+
type
|
|
53
|
+
updated_by {
|
|
54
|
+
name
|
|
55
|
+
type
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
page_info {
|
|
59
|
+
current_page
|
|
60
|
+
page_size
|
|
61
|
+
total_pages
|
|
62
|
+
}
|
|
63
|
+
total_count
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`,M=async(c={})=>{const{filter:r,pageSize:n=20,currentPage:l=1}=c,e=r?{custom_reference_number:r.customReferenceNumber,operation_type:r.operationType,updated_by:r.updatedBy}:null;return await z(O,{method:"GET",cache:"no-cache",variables:{filter:e,pageSize:n,currentPage:l}}).then(t=>{var u;return(u=t.errors)!=null&&u.length?null:N(t)}).catch(R)};export{M as a,A as g};
|
|
68
|
+
//# sourceMappingURL=getCompanyCreditHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCompanyCreditHistory.js","sources":["/@dropins/storefront-company-management/src/data/transforms/transform-company-credit.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company-credit-history.ts","/@dropins/storefront-company-management/src/api/getCompanyCredit/graphql/getCompanyCredit.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyCredit/getCompanyCredit.ts","/@dropins/storefront-company-management/src/api/getCompanyCreditHistory/graphql/getCompanyCreditHistory.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyCreditHistory/getCompanyCreditHistory.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 { CompanyCreditResponse } from '@/company-management/types/api/getCompanyCredit.types';\nimport { CompanyCreditInfo } from '@/company-management/data/models/company-credit-info';\n\nexport const transformCompanyCredit = (\n response: CompanyCreditResponse\n): CompanyCreditInfo => {\n return {\n credit: {\n available_credit: {\n currency: response?.data?.company?.credit?.available_credit?.currency || '',\n value: response?.data?.company?.credit?.available_credit?.value || 0,\n },\n credit_limit: {\n currency: response?.data?.company?.credit?.credit_limit?.currency || '',\n value: response?.data?.company?.credit?.credit_limit?.value || 0,\n },\n outstanding_balance: {\n currency: response?.data?.company?.credit?.outstanding_balance?.currency || '',\n value: response?.data?.company?.credit?.outstanding_balance?.value || 0,\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\nimport { CompanyCreditHistoryResponse } from '@/company-management/types/api/getCompanyCreditHistory.types';\nimport { CompanyCreditHistory } from '@/company-management/data/models/company-credit-history';\n\nexport const transformCompanyCreditHistory = (\n response: CompanyCreditHistoryResponse\n): CompanyCreditHistory => {\n const creditHistory = response?.data?.company?.credit_history;\n\n return {\n items: creditHistory?.items?.map(item => ({\n amount: {\n currency: item?.amount?.currency || '',\n value: item?.amount?.value || 0,\n },\n balance: {\n availableCredit: {\n currency: item?.balance?.available_credit?.currency || '',\n value: item?.balance?.available_credit?.value || 0,\n },\n creditLimit: {\n currency: item?.balance?.credit_limit?.currency || '',\n value: item?.balance?.credit_limit?.value || 0,\n },\n outstandingBalance: {\n currency: item?.balance?.outstanding_balance?.currency || '',\n value: item?.balance?.outstanding_balance?.value || 0,\n },\n },\n customReferenceNumber: item?.custom_reference_number || undefined,\n date: item?.date || '',\n type: item?.operation_type || '',\n updatedBy: {\n name: item?.updated_by?.name || '',\n type: item?.updated_by?.type || '',\n },\n })) || [],\n pageInfo: {\n currentPage: creditHistory?.page_info?.current_page || 1,\n pageSize: creditHistory?.page_info?.page_size || 20,\n totalPages: creditHistory?.page_info?.total_pages || 0,\n },\n totalCount: creditHistory?.total_count || 0,\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\nexport const GET_COMPANY_CREDIT = /* GraphQL */ `\n query GET_COMPANY_CREDIT \n {\n company {\n credit {\n available_credit {\n currency\n value\n }\n credit_limit {\n currency\n value\n }\n outstanding_balance {\n currency\n value\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\nimport { GET_COMPANY_CREDIT } from \"./graphql/getCompanyCredit.graphql\";\nimport { CompanyCreditResponse } from '@/company-management/types/api/getCompanyCredit.types';\nimport { transformCompanyCredit } from '@/company-management/data/transforms';\nimport { handleNetworkError } from '@/company-management/lib';\nimport { CompanyCreditInfo } from '@/company-management/data/models';\nimport { fetchGraphQl } from '../fetch-graphql';\n\nexport const getCompanyCredit = async (): Promise<CompanyCreditInfo | null> => {\n\n return await fetchGraphQl(GET_COMPANY_CREDIT, {\n method: 'GET',\n cache: 'no-cache',\n })\n .then((response: CompanyCreditResponse) => {\n if (response.errors?.length) {\n return null;\n }\n\n const transformedData = transformCompanyCredit(response);\n\n return transformedData;\n })\n .catch(handleNetworkError);\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\nexport const GET_COMPANY_CREDIT_HISTORY = /* GraphQL */ `\n query GET_COMPANY_CREDIT_HISTORY($filter: CompanyCreditHistoryFilterInput, $pageSize: Int, $currentPage: Int) {\n company {\n credit_history(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n ) {\n items {\n amount {\n currency\n value\n }\n balance {\n available_credit {\n currency\n value\n }\n credit_limit {\n currency\n value\n }\n outstanding_balance {\n currency\n value\n }\n }\n custom_reference_number\n date\n type\n updated_by {\n name\n type\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\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\nimport { GET_COMPANY_CREDIT_HISTORY } from \"./graphql/getCompanyCreditHistory.graphql\";\nimport { CompanyCreditHistoryResponse } from '@/company-management/types/api/getCompanyCreditHistory.types';\nimport { GetCompanyCreditHistoryParams } from '@/company-management/types/api/getCompanyCreditHistoryParams.types';\nimport { transformCompanyCreditHistory } from '@/company-management/data/transforms';\nimport { handleNetworkError } from '@/company-management/lib';\nimport { CompanyCreditHistory } from '@/company-management/data/models';\nimport { fetchGraphQl } from '../fetch-graphql';\n\nexport const getCompanyCreditHistory = async (params: GetCompanyCreditHistoryParams = {}): Promise<CompanyCreditHistory | null> => {\n const { filter, pageSize = 20, currentPage = 1 } = params;\n\n // Transform camelCase filter to snake_case for GraphQL\n const graphqlFilter = filter ? {\n custom_reference_number: filter.customReferenceNumber,\n operation_type: filter.operationType,\n updated_by: filter.updatedBy,\n } : null;\n\n return await fetchGraphQl(GET_COMPANY_CREDIT_HISTORY, {\n method: 'GET',\n cache: 'no-cache',\n variables: {\n filter: graphqlFilter,\n pageSize,\n currentPage,\n },\n })\n .then((response: CompanyCreditHistoryResponse) => {\n if (response.errors?.length) {\n return null;\n }\n\n const transformedData = transformCompanyCreditHistory(response);\n\n return transformedData;\n })\n .catch(handleNetworkError);\n};\n"],"names":["transformCompanyCredit","response","_d","_c","_b","_a","_h","_g","_f","_e","_l","_k","_j","_i","_p","_o","_n","_m","_t","_s","_r","_q","_x","_w","_v","_u","transformCompanyCreditHistory","creditHistory","item","GET_COMPANY_CREDIT","getCompanyCredit","fetchGraphQl","handleNetworkError","GET_COMPANY_CREDIT_HISTORY","getCompanyCreditHistory","params","filter","pageSize","currentPage","graphqlFilter"],"mappings":"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"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{h as
|
|
3
|
+
import{h as l}from"./network-error.js";import{h as m}from"./fetch-error.js";import{f as i}from"./fetch-graphql.js";const d=o=>{var a,e,c;const r=(a=o==null?void 0:o.data)==null?void 0:a.customer,n=(e=o==null?void 0:o.data)==null?void 0:e.company;if(!r||!n)return null;const t={companyName:(n==null?void 0:n.name)??"",jobTitle:(r==null?void 0:r.job_title)??"",workPhoneNumber:(r==null?void 0:r.telephone)??"",userRole:((c=r==null?void 0:r.role)==null?void 0:c.name)??""};return t.companyName?t:null},h=`
|
|
4
4
|
query GET_COMPANY_ENABLED {
|
|
5
5
|
storeConfig {
|
|
6
6
|
company_enabled
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,f=async()=>{var
|
|
9
|
+
`,f=async()=>{var n,t,a;const o=await i(h,{method:"POST"});if((n=o==null?void 0:o.errors)!=null&&n.length)throw new Error(((t=o.errors[0])==null?void 0:t.message)||"Failed to load store configuration");const r=(a=o==null?void 0:o.data)==null?void 0:a.storeConfig;if(!r)throw new Error("Invalid response: missing storeConfig");return!!r.company_enabled},E=`
|
|
10
10
|
query GET_CUSTOMER_COMPANY_INFO {
|
|
11
11
|
customer {
|
|
12
12
|
id
|
|
@@ -22,5 +22,5 @@ import{h as i,a as m}from"./fetch-error.js";import{f as l}from"./fetch-graphql.j
|
|
|
22
22
|
name
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
`,
|
|
25
|
+
`,C=async()=>{var o;try{if(!await f())return null;const n=await i(E,{method:"GET",cache:"no-cache"});return(o=n.errors)!=null&&o.length?m(n.errors):d(n)}catch(r){return console.error("Failed to fetch customer company info:",r),l(r)}};export{f as c,C as g};
|
|
26
26
|
//# sourceMappingURL=getCustomerCompany.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomerCompany.js","sources":["/@dropins/storefront-company-management/src/data/transforms/transform-customer-company-info.ts","/@dropins/storefront-company-management/src/api/companyEnabled/graphql/companyEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/companyEnabled/companyEnabled.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/getCustomerCompany.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 *******************************************************************/\nimport { CustomerCompanyInfo } from '../models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\n\n/**\n * Transforms GraphQL response to CustomerCompanyInfo model\n * @param response - GraphQL response containing customer and company data\n * @returns Transformed customer company info or null if data is incomplete\n */\nexport const transformCustomerCompanyInfo = (response: GetCustomerCompanyInfoResponse): CustomerCompanyInfo | null => {\n const customer = response?.data?.customer;\n const company = response?.data?.company;\n \n if (!customer || !company) {\n return null;\n }\n\n const companyInfo: CustomerCompanyInfo = {\n companyName: company?.name ?? '',\n jobTitle: customer?.job_title ?? '',\n workPhoneNumber: customer?.telephone ?? '',\n userRole: customer?.role?.name ?? '',\n };\n\n // Only return data if we have at least a company name\n return companyInfo.companyName ? companyInfo : null;\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\nexport const GET_COMPANY_ENABLED = /* GraphQL */ `\n query GET_COMPANY_ENABLED {\n storeConfig {\n company_enabled\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 \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_COMPANY_ENABLED } from './graphql/companyEnabled.graphql';\n\nexport const companyEnabled = async (): Promise<boolean> => { \n const response = await fetchGraphQl(GET_COMPANY_ENABLED, { method: 'POST' });\n\n if ((response as any)?.errors?.length) {\n throw new Error((response as any).errors[0]?.message || 'Failed to load store configuration');\n }\n\n const node = (response as any)?.data?.storeConfig;\n if (!node) {\n throw new Error('Invalid response: missing storeConfig');\n }\n\n return Boolean(node.company_enabled);\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\nexport const GET_CUSTOMER_COMPANY_INFO = `\n query GET_CUSTOMER_COMPANY_INFO {\n customer {\n id\n job_title\n telephone\n role {\n id\n name\n }\n }\n company {\n id\n name\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 { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { companyEnabled } from '../companyEnabled';\nimport { GET_CUSTOMER_COMPANY_INFO } from './graphql/getCustomerCompanyInfo.graphql';\nimport { CustomerCompanyInfo } from '../../data/models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\nimport { transformCustomerCompanyInfo } from '../../data/transforms/transform-customer-company-info';\n\n/**\n * Gets customer company information for display on account information page\n * This is a simplified API that only returns the essential company info needed\n * for the customer account page, without requiring full company permissions\n */\nexport const getCustomerCompany = async (): Promise<CustomerCompanyInfo | null> => {\n try {\n // First check if company functionality is enabled\n const isCompanyEnabled = await companyEnabled();\n if (!isCompanyEnabled) {\n return null;\n }\n\n // Fetch customer company information\n const response: GetCustomerCompanyInfoResponse = await fetchGraphQl(GET_CUSTOMER_COMPANY_INFO, { \n method: 'GET', \n cache: 'no-cache' \n });\n\n if (response.errors?.length) {\n return handleFetchError(response.errors);\n }\n\n // Transform the response using the transformer\n return transformCustomerCompanyInfo(response);\n\n } catch (error) {\n console.error('Failed to fetch customer company info:', error);\n return handleNetworkError(error as Error);\n }\n};\n"],"names":["transformCustomerCompanyInfo","response","customer","_a","company","_b","companyInfo","_c","GET_COMPANY_ENABLED","companyEnabled","fetchGraphQl","node","GET_CUSTOMER_COMPANY_INFO","getCustomerCompany","handleFetchError","error","handleNetworkError"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCustomerCompany.js","sources":["/@dropins/storefront-company-management/src/data/transforms/transform-customer-company-info.ts","/@dropins/storefront-company-management/src/api/companyEnabled/graphql/companyEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/companyEnabled/companyEnabled.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/getCustomerCompany.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 *******************************************************************/\nimport { CustomerCompanyInfo } from '../models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\n\n/**\n * Transforms GraphQL response to CustomerCompanyInfo model\n * @param response - GraphQL response containing customer and company data\n * @returns Transformed customer company info or null if data is incomplete\n */\nexport const transformCustomerCompanyInfo = (response: GetCustomerCompanyInfoResponse): CustomerCompanyInfo | null => {\n const customer = response?.data?.customer;\n const company = response?.data?.company;\n \n if (!customer || !company) {\n return null;\n }\n\n const companyInfo: CustomerCompanyInfo = {\n companyName: company?.name ?? '',\n jobTitle: customer?.job_title ?? '',\n workPhoneNumber: customer?.telephone ?? '',\n userRole: customer?.role?.name ?? '',\n };\n\n // Only return data if we have at least a company name\n return companyInfo.companyName ? companyInfo : null;\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\nexport const GET_COMPANY_ENABLED = /* GraphQL */ `\n query GET_COMPANY_ENABLED {\n storeConfig {\n company_enabled\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 \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_COMPANY_ENABLED } from './graphql/companyEnabled.graphql';\n\nexport const companyEnabled = async (): Promise<boolean> => { \n const response = await fetchGraphQl(GET_COMPANY_ENABLED, { method: 'POST' });\n\n if ((response as any)?.errors?.length) {\n throw new Error((response as any).errors[0]?.message || 'Failed to load store configuration');\n }\n\n const node = (response as any)?.data?.storeConfig;\n if (!node) {\n throw new Error('Invalid response: missing storeConfig');\n }\n\n return Boolean(node.company_enabled);\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\nexport const GET_CUSTOMER_COMPANY_INFO = `\n query GET_CUSTOMER_COMPANY_INFO {\n customer {\n id\n job_title\n telephone\n role {\n id\n name\n }\n }\n company {\n id\n name\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 { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { companyEnabled } from '../companyEnabled';\nimport { GET_CUSTOMER_COMPANY_INFO } from './graphql/getCustomerCompanyInfo.graphql';\nimport { CustomerCompanyInfo } from '../../data/models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\nimport { transformCustomerCompanyInfo } from '../../data/transforms/transform-customer-company-info';\n\n/**\n * Gets customer company information for display on account information page\n * This is a simplified API that only returns the essential company info needed\n * for the customer account page, without requiring full company permissions\n */\nexport const getCustomerCompany = async (): Promise<CustomerCompanyInfo | null> => {\n try {\n // First check if company functionality is enabled\n const isCompanyEnabled = await companyEnabled();\n if (!isCompanyEnabled) {\n return null;\n }\n\n // Fetch customer company information\n const response: GetCustomerCompanyInfoResponse = await fetchGraphQl(GET_CUSTOMER_COMPANY_INFO, { \n method: 'GET', \n cache: 'no-cache' \n });\n\n if (response.errors?.length) {\n return handleFetchError(response.errors);\n }\n\n // Transform the response using the transformer\n return transformCustomerCompanyInfo(response);\n\n } catch (error) {\n console.error('Failed to fetch customer company info:', error);\n return handleNetworkError(error as Error);\n }\n};\n"],"names":["transformCustomerCompanyInfo","response","customer","_a","company","_b","companyInfo","_c","GET_COMPANY_ENABLED","companyEnabled","fetchGraphQl","node","GET_CUSTOMER_COMPANY_INFO","getCustomerCompany","handleFetchError","error","handleNetworkError"],"mappings":"mHAwBa,MAAAA,EAAgCC,GAAyE,WAC9G,MAAAC,GAAWC,EAAAF,GAAA,YAAAA,EAAU,OAAV,YAAAE,EAAgB,SAC3BC,GAAUC,EAAAJ,GAAA,YAAAA,EAAU,OAAV,YAAAI,EAAgB,QAE5B,GAAA,CAACH,GAAY,CAACE,EACT,OAAA,KAGT,MAAME,EAAmC,CACvC,aAAaF,GAAA,YAAAA,EAAS,OAAQ,GAC9B,UAAUF,GAAA,YAAAA,EAAU,YAAa,GACjC,iBAAiBA,GAAA,YAAAA,EAAU,YAAa,GACxC,WAAUK,EAAAL,GAAA,YAAAA,EAAU,OAAV,YAAAK,EAAgB,OAAQ,EACpC,EAGO,OAAAD,EAAY,YAAcA,EAAc,IACjD,ECxBaE,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECGpCC,EAAiB,SAA8B,WAC1D,MAAMR,EAAW,MAAMS,EAAaF,EAAqB,CAAE,OAAQ,OAAQ,EAEtE,IAAAL,EAAAF,GAAA,YAAAA,EAAkB,SAAlB,MAAAE,EAA0B,OAC7B,MAAM,IAAI,QAAOE,EAAAJ,EAAiB,OAAO,CAAC,IAAzB,YAAAI,EAA4B,UAAW,oCAAoC,EAGxF,MAAAM,GAAQJ,EAAAN,GAAA,YAAAA,EAAkB,OAAlB,YAAAM,EAAwB,YACtC,GAAI,CAACI,EACG,MAAA,IAAI,MAAM,uCAAuC,EAGlD,MAAA,EAAQA,EAAK,eACtB,EChBaC,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECa5BC,EAAqB,SAAiD,OAC7E,GAAA,CAGF,GAAI,CADqB,MAAMJ,EAAe,EAErC,OAAA,KAIH,MAAAR,EAA2C,MAAMS,EAAaE,EAA2B,CAC7F,OAAQ,MACR,MAAO,UAAA,CACR,EAEG,OAAAT,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZW,EAAiBb,EAAS,MAAM,EAIlCD,EAA6BC,CAAQ,QAErCc,EAAO,CACN,eAAA,MAAM,yCAA0CA,CAAK,EACtDC,EAAmBD,CAAc,CAAA,CAE5C"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as r}from"@dropins/tools/event-bus.js";const n=o=>{throw o instanceof DOMException&&o.name==="AbortError"||r.emit("error",{source:"company",type:"network",error:o}),o};export{n as h};
|
|
4
|
+
//# sourceMappingURL=network-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-error.js","sources":["/@dropins/storefront-company-management/src/lib/network-error.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 *******************************************************************/\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"],"names":["handleNetworkError","error","events"],"mappings":"qDAsBa,MAAAA,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAIhDC,EAAO,KAAK,QAAS,CACnB,OAAQ,UACR,KAAM,UACN,MAAAD,CAAA,CACD,EAEGA,CACR"}
|