@dropins/storefront-company-management 1.0.0-alpha2000 → 1.0.0-alpha2002
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/createCompanyUser/createCompanyUser.d.ts +9 -0
- package/api/createCompanyUser/graphql/createCompanyUser.graphql.d.ts +18 -0
- package/api/{getCompanyUsers/graphql → createCompanyUser}/index.d.ts +1 -1
- package/api/getCompanyRoles/getCompanyRoles.d.ts +8 -0
- package/api/getCompanyRoles/graphql/getCompanyRoles.graphql.d.ts +18 -0
- package/api/{deleteCompanyUser/graphql → getCompanyRoles}/index.d.ts +1 -1
- package/api/getCompanyUser/getCompanyUser.d.ts +9 -0
- package/api/getCompanyUser/graphql/getCompanyUser.graphql.d.ts +18 -0
- package/api/{updateCompanyUserStatus/graphql → getCompanyUser}/index.d.ts +1 -1
- package/api/index.d.ts +8 -3
- package/api/isCompanyUserEmailAvailable/graphql/isCompanyUserEmailAvailable.graphql.d.ts +18 -0
- package/api/isCompanyUserEmailAvailable/index.d.ts +18 -0
- package/api/isCompanyUserEmailAvailable/isCompanyUserEmailAvailable.d.ts +7 -0
- package/api/updateCompanyUser/graphql/updateCompanyUser.graphql.d.ts +18 -0
- package/api/updateCompanyUser/index.d.ts +18 -0
- package/api/updateCompanyUser/updateCompanyUser.d.ts +9 -0
- package/api.js +1 -1
- package/api.js.map +1 -1
- package/chunks/fetchUserPermissions.js +1 -1
- package/chunks/{getCountries.js → updateCompany.js} +3 -3
- package/chunks/updateCompany.js.map +1 -0
- package/chunks/updateCompanyUserStatus.js +80 -0
- package/chunks/updateCompanyUserStatus.js.map +1 -0
- package/chunks/useInLineAlert.js +1 -1
- package/chunks/useInLineAlert.js.map +1 -1
- package/components/CompanyLoaders/CompanyLoaders.d.ts +1 -0
- package/components/CompanyUserForm/CompanyUserForm.d.ts +10 -0
- package/components/CompanyUserForm/index.d.ts +18 -0
- package/components/index.d.ts +1 -0
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/containers/CompanyUsers.js +1 -1
- package/containers/CompanyUsers.js.map +1 -1
- package/containers/CustomerCompanyInfo.js +1 -1
- package/containers/CustomerCompanyInfo.js.map +1 -1
- package/data/models/company-role.d.ts +35 -0
- package/data/models/company-user.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-roles.d.ts +9 -0
- package/data/transforms/transform-company-user.d.ts +18 -0
- package/hooks/containers/index.d.ts +1 -0
- package/hooks/containers/useCompanyUsers.d.ts +33 -0
- package/hooks/useCompanyRoles.d.ts +8 -0
- package/hooks/useCompanyUserForm.d.ts +29 -0
- package/i18n/en_US.json.d.ts +47 -2
- package/lib/index.d.ts +1 -0
- package/package.json +1 -1
- package/render.js +3 -3
- package/render.js.map +1 -1
- package/types/api/companyUsers.types.d.ts +1 -1
- package/types/api/createCompanyUser.types.d.ts +31 -0
- package/types/api/getCompanyUser.types.d.ts +20 -0
- package/types/api/index.d.ts +4 -0
- package/types/api/isCompanyUserEmailAvailable.types.d.ts +20 -0
- package/types/api/updateCompanyUser.types.d.ts +27 -0
- package/types/api/updateCompanyUserStatus.types.d.ts +1 -1
- package/types/companyForm.types.d.ts +29 -0
- package/types/index.d.ts +1 -0
- package/chunks/getCompanyUsers.js +0 -45
- package/chunks/getCompanyUsers.js.map +0 -1
- package/chunks/getCountries.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateCompanyUserInput, CreateCompanyUserResult } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new company user with the provided information
|
|
5
|
+
* @param input - User information including email, name, job title, and role
|
|
6
|
+
* @returns Promise resolving to created user result or null if creation failed
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCompanyUser(input: CreateCompanyUserInput): Promise<CreateCompanyUserResult | null>;
|
|
9
|
+
//# sourceMappingURL=createCompanyUser.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 CREATE_COMPANY_USER = "\n mutation createCompanyUser($input: CompanyUserCreateInput!) {\n createCompanyUser(input: $input) { __typename user { id structure_id email firstname lastname } }\n }\n";
|
|
18
|
+
//# sourceMappingURL=createCompanyUser.graphql.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export
|
|
17
|
+
export * from './createCompanyUser';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CompanyRoleModel } from '../../data/models';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves all available company roles
|
|
5
|
+
* @returns Promise resolving to array of CompanyRoleModel
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCompanyRoles(): Promise<CompanyRoleModel[]>;
|
|
8
|
+
//# sourceMappingURL=getCompanyRoles.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_ROLES = "\n query getCompanyRoles {\n company {\n roles {\n items { id name }\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=getCompanyRoles.graphql.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export
|
|
17
|
+
export * from './getCompanyRoles';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompanyUserModel } from '../../data/models';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a specific company user by their ID
|
|
5
|
+
* @param id - The ID of the company user to retrieve (will be base64 encoded)
|
|
6
|
+
* @returns Promise resolving to CompanyUserModel or null if user not found
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCompanyUser(id: string): Promise<CompanyUserModel | null>;
|
|
9
|
+
//# sourceMappingURL=getCompanyUser.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_USER = "\n query getCompanyUser($id: ID!) {\n company {\n user(id: $id) {\n id\n email\n firstname\n lastname\n job_title\n telephone\n status\n role { id name }\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=getCompanyUser.graphql.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export
|
|
17
|
+
export * from './getCompanyUser';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -18,12 +18,17 @@ export * from './initialize';
|
|
|
18
18
|
export * from './fetch-graphql';
|
|
19
19
|
export * from './fetchUserPermissions';
|
|
20
20
|
export * from './checkIsCompanyEnabled';
|
|
21
|
+
export * from './createCompanyUser';
|
|
21
22
|
export * from './deleteCompanyUser';
|
|
22
23
|
export * from './getCompany';
|
|
24
|
+
export * from './getCompanyRoles';
|
|
25
|
+
export * from './getCompanyUser';
|
|
26
|
+
export * from './getCompanyUsers';
|
|
27
|
+
export * from './getCountries';
|
|
28
|
+
export * from './getCustomerCompany';
|
|
29
|
+
export * from './isCompanyUserEmailAvailable';
|
|
23
30
|
export * from './updateCompany';
|
|
31
|
+
export * from './updateCompanyUser';
|
|
24
32
|
export * from './updateCompanyUserStatus';
|
|
25
|
-
export * from './getCountries';
|
|
26
33
|
export * from './validateCompanyEmail';
|
|
27
|
-
export * from './getCustomerCompany';
|
|
28
|
-
export * from './getCompanyUsers';
|
|
29
34
|
//# 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 IS_COMPANY_USER_EMAIL_AVAILABLE = "\n query isCompanyUserEmailAvailable($email: String!) {\n isCompanyUserEmailAvailable(email: $email) { is_email_available }\n }\n";
|
|
18
|
+
//# sourceMappingURL=isCompanyUserEmailAvailable.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 './isCompanyUserEmailAvailable';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if an email address is available for use by a new company user
|
|
3
|
+
* @param email - The email address to check for availability
|
|
4
|
+
* @returns Promise resolving to boolean indicating availability or null if check failed
|
|
5
|
+
*/
|
|
6
|
+
export declare function isCompanyUserEmailAvailable(email: string): Promise<boolean | null>;
|
|
7
|
+
//# sourceMappingURL=isCompanyUserEmailAvailable.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 UPDATE_COMPANY_USER = "\n mutation updateCompanyUser($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) { __typename user { id } }\n }\n";
|
|
18
|
+
//# sourceMappingURL=updateCompanyUser.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 './updateCompanyUser';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UpdateCompanyUserInput } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates an existing company user with the provided information
|
|
5
|
+
* @param input - User information including ID and fields to update
|
|
6
|
+
* @returns Promise resolving to boolean indicating success
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateCompanyUser(input: UpdateCompanyUserInput): Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=updateCompanyUser.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{f as p,g as m,r as n,s as i,a as
|
|
3
|
+
import{f as p,g as m,r as n,s as i,a as C,b as c}from"./chunks/fetch-error.js";import{f as l}from"./chunks/fetchUserPermissions.js";import{c as d,g as f}from"./chunks/getCustomerCompany.js";import{c as h,d as U,g as x,a as b,b as v,i as E,u as G,e as Q}from"./chunks/updateCompanyUserStatus.js";import{g as H,a as k,u as z}from"./chunks/updateCompany.js";import{v as I}from"./chunks/validateCompanyEmail.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";const r=async(e={})=>({success:!0,config:e});export{d as checkIsCompanyEnabled,h as createCompanyUser,U as deleteCompanyUser,p as fetchGraphQl,l as fetchUserPermissions,H as getCompany,x as getCompanyRoles,b as getCompanyUser,v as getCompanyUsers,m as getConfig,k as getCountries,f as getCustomerCompany,r as initialize,E as isCompanyUserEmailAvailable,n as removeFetchGraphQlHeader,i as setEndpoint,C as setFetchGraphQlHeader,c as setFetchGraphQlHeaders,z as updateCompany,G as updateCompanyUser,Q as updateCompanyUserStatus,I as validateCompanyEmail};
|
|
4
4
|
//# 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"],"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"],"names":["initialize","config"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.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"],"names":["initialize","config"],"mappings":"oeAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF"}
|
|
@@ -23,5 +23,5 @@ import{f as r,h,c as _}from"./fetch-error.js";const p=`
|
|
|
23
23
|
status
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
`,d=(n=[])=>{const a=new Set,t=[...n];for(;t.length;){const i=t.pop();if(i&&(typeof i.id=="string"&&a.add(i.id),Array.isArray(i.children)&&i.children.length))for(const s of i.children)t.push(s)}return a},e=n=>(n==null?void 0:n.id)==="0"||typeof(n==null?void 0:n.id)=="number"&&(n==null?void 0:n.id)===0||(n==null?void 0:n.name)==="Company Administrator",g=n=>{const a=d((n==null?void 0:n.permissions)||[]),t=e(n);return{canViewAccount:t||a.has("Magento_Company::view_account"),canEditAccount:t||a.has("Magento_Company::edit_account"),canViewAddress:t||a.has("Magento_Company::view_address"),canEditAddress:t||a.has("Magento_Company::edit_address"),canViewContacts:t||a.has("Magento_Company::contacts"),canViewPaymentInformation:t||a.has("Magento_Company::payment_information"),canViewShippingInformation:t||a.has("Magento_Company::shipping_information")}},f=async()=>await r(p,{method:"GET",cache:"no-cache"}).then(n=>{var s,c,o;if((s=n.errors)!=null&&s.length)return h(n.errors);const a=(o=(c=n==null?void 0:n.data)==null?void 0:c.customer)==null?void 0:o.role,t=d((a==null?void 0:a.permissions)||[]);return e(a)&&["Magento_Company::view_account","Magento_Company::edit_account","Magento_Company::view_address","Magento_Company::edit_address","Magento_Company::contacts","Magento_Company::payment_information","Magento_Company::shipping_information","Magento_Company::users_view","Magento_Company::users_edit"].forEach(m=>t.add(m)),{allowedIds:t,roleResponse:n}}).catch(_);export{g as b,f};
|
|
26
|
+
`,d=(n=[])=>{const a=new Set,t=[...n];for(;t.length;){const i=t.pop();if(i&&(typeof i.id=="string"&&a.add(i.id),Array.isArray(i.children)&&i.children.length))for(const s of i.children)t.push(s)}return a},e=n=>(n==null?void 0:n.id)==="0"||typeof(n==null?void 0:n.id)=="number"&&(n==null?void 0:n.id)===0||(n==null?void 0:n.name)==="Company Administrator",g=n=>{const a=d((n==null?void 0:n.permissions)||[]),t=e(n);return{canViewAccount:t||a.has("Magento_Company::view_account"),canEditAccount:t||a.has("Magento_Company::edit_account"),canViewAddress:t||a.has("Magento_Company::view_address"),canEditAddress:t||a.has("Magento_Company::edit_address"),canViewContacts:t||a.has("Magento_Company::contacts"),canViewPaymentInformation:t||a.has("Magento_Company::payment_information"),canViewShippingInformation:t||a.has("Magento_Company::shipping_information")}},f=async()=>await r(p,{method:"GET",cache:"no-cache"}).then(n=>{var s,c,o;if((s=n.errors)!=null&&s.length)return h(n.errors);const a=(o=(c=n==null?void 0:n.data)==null?void 0:c.customer)==null?void 0:o.role,t=d((a==null?void 0:a.permissions)||[]);return e(a)&&["Magento_Company::view_account","Magento_Company::edit_account","Magento_Company::view_address","Magento_Company::edit_address","Magento_Company::contacts","Magento_Company::payment_information","Magento_Company::shipping_information","Magento_Company::users_view","Magento_Company::users_edit"].forEach(m=>t.add(m)),{allowedIds:t,roleResponse:n}}).catch(_);export{g as b,f,e as i};
|
|
27
27
|
//# sourceMappingURL=fetchUserPermissions.js.map
|
|
@@ -65,7 +65,7 @@ ${r.join(`
|
|
|
65
65
|
}
|
|
66
66
|
`}
|
|
67
67
|
${r.join(`
|
|
68
|
-
`)}`},O=async()=>await y().then(async({allowedIds:e,roleResponse:a})=>{var i,s,t;const r=b(e),o=await c(r,{method:"GET",cache:"no-cache"});if((i=o.errors)!=null&&i.length)return g(o.errors);const n=(s=o==null?void 0:o.data)==null?void 0:s.company;return n&&Object.keys(n).some(m=>m!=="__typename")?(o.data.customer=(t=a==null?void 0:a.data)==null?void 0:t.customer,p(o)):null}).catch(A),
|
|
68
|
+
`)}`},O=async()=>await y().then(async({allowedIds:e,roleResponse:a})=>{var i,s,t;const r=b(e),o=await c(r,{method:"GET",cache:"no-cache"});if((i=o.errors)!=null&&i.length)return g(o.errors);const n=(s=o==null?void 0:o.data)==null?void 0:s.company;return n&&Object.keys(n).some(m=>m!=="__typename")?(o.data.customer=(t=a==null?void 0:a.data)==null?void 0:t.customer,p(o)):null}).catch(A),T=`
|
|
69
69
|
query getCountries {
|
|
70
70
|
countries {
|
|
71
71
|
id
|
|
@@ -84,5 +84,5 @@ ${r.join(`
|
|
|
84
84
|
optional_zip_countries
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
`,
|
|
88
|
-
//# sourceMappingURL=
|
|
87
|
+
`,w=async()=>{const e="_company_countries",a=sessionStorage.getItem(e);return a?JSON.parse(a):await c(T,{method:"GET"}).then(r=>{var n;if((n=r.errors)!=null&&n.length)return g(r.errors);const o=f(r);return sessionStorage.setItem(e,JSON.stringify(o)),o}).catch(A)},Y=async e=>await y().then(async({allowedIds:a,roleResponse:r})=>{var i,s;const o=I(a),n={};if(e.name!==void 0&&(n.company_name=e.name),e.email!==void 0&&(n.company_email=e.email),e.legalName!==void 0&&(n.legal_name=e.legalName),e.vatTaxId!==void 0&&(n.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(n.reseller_id=e.resellerId),e.legalAddress!==void 0&&a.has("Magento_Company::edit_address")){let t;Array.isArray(e.legalAddress.street)?(t=[...e.legalAddress.street],e.legalAddress.street2&&t.push(e.legalAddress.street2)):t=[e.legalAddress.street,e.legalAddress.street2].filter(d=>typeof d=="string"&&d.trim().length>0),t=t.filter(d=>d&&typeof d=="string"&&d.trim().length>0);let m;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const d=e.legalAddress.region;d.region===d.regionCode?m={region:d.region,region_code:d.regionCode,region_id:0}:m={region:d.region,region_code:d.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?m={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(m={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});n.legal_address={street:t,city:e.legalAddress.city,region:m,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}const l=await c(o,{method:"POST",variables:{input:n}});return(i=l.errors)!=null&&i.length?g(l.errors):(l.data.customer=(s=r==null?void 0:r.data)==null?void 0:s.customer,p(l))}).catch(A);export{w as a,O as g,Y as u};
|
|
88
|
+
//# sourceMappingURL=updateCompany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompany.js","sources":["/@dropins/storefront-company-management/src/data/transforms/transform-company.ts","/@dropins/storefront-company-management/src/data/transforms/transform-countries.ts","/@dropins/storefront-company-management/src/api/graphql/CompanyFragment.graphql.ts","/@dropins/storefront-company-management/src/api/graphql/buildCompanyQueries.ts","/@dropins/storefront-company-management/src/api/getCompany/getCompany.ts","/@dropins/storefront-company-management/src/api/getCountries/graphql/getCountries.graphql.ts","/@dropins/storefront-company-management/src/api/getCountries/getCountries.ts","/@dropins/storefront-company-management/src/api/updateCompany/updateCompany.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 { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { updateCompanyResponse } from '../../types/api/updateCompany.types';\nimport { CompanyModel } from '../models/company';\nimport { buildPermissionFlags } from '../../lib/company-permissions';\n\nexport const transformCompany = (\n response: getCompanyResponse | updateCompanyResponse\n): CompanyModel => {\n // Validate response structure\n if (!response?.data) {\n throw new Error('Invalid response: missing data');\n }\n\n // Handle both getCompany and updateCompany response structures\n const companyData: any = 'updateCompany' in response.data \n ? response.data.updateCompany?.company \n : response.data.company;\n \n if (!companyData) {\n throw new Error('Invalid response: missing company data');\n }\n \n const customerData = 'customer' in response.data ? response.data.customer : undefined;\n\n // Transform legal address with validation\n const legalAddress = companyData.legal_address ? {\n street: Array.isArray(companyData.legal_address.street) \n ? companyData.legal_address.street.filter((line: string) => line && line.trim() !== '') \n : [],\n city: (companyData.legal_address.city || '').trim(),\n region: companyData.legal_address.region ? {\n region: (companyData.legal_address.region.region || '').trim(),\n regionCode: (companyData.legal_address.region.region_code || '').trim(),\n regionId: companyData.legal_address.region.region_id ? Number(companyData.legal_address.region.region_id) : 0,\n } : undefined,\n countryCode: (companyData.legal_address.country_code || '').toUpperCase().trim(),\n postcode: (companyData.legal_address.postcode || '').trim(),\n telephone: companyData.legal_address.telephone ? \n companyData.legal_address.telephone.trim() : undefined,\n } : undefined;\n\n // Determine permissions using shared utility\n const customerRole = customerData?.role;\n const permissionsFlags = buildPermissionFlags(customerRole);\n\n // Build the model with proper validation\n const model: CompanyModel = {\n id: (companyData.id || '').toString(),\n name: (companyData.name || '').trim(),\n email: (companyData.email || '').trim().toLowerCase(),\n legalName: companyData.legal_name ? companyData.legal_name.trim() : undefined,\n vatTaxId: companyData.vat_tax_id ? companyData.vat_tax_id.trim() : undefined,\n resellerId: companyData.reseller_id ? companyData.reseller_id.trim() : undefined,\n legalAddress,\n companyAdmin: companyData.company_admin ? {\n id: (companyData.company_admin.id || '').toString(),\n firstname: (companyData.company_admin.firstname || '').trim(),\n lastname: (companyData.company_admin.lastname || '').trim(),\n email: (companyData.company_admin.email || '').trim().toLowerCase(),\n jobTitle: companyData.company_admin.job_title ? companyData.company_admin.job_title.trim() : undefined,\n } : undefined,\n\n // Transform sales representative\n salesRepresentative: companyData.sales_representative ? {\n firstname: (companyData.sales_representative.firstname || '').trim(),\n lastname: (companyData.sales_representative.lastname || '').trim(),\n email: (companyData.sales_representative.email || '').trim().toLowerCase(),\n } : undefined,\n\n // New comprehensive payment methods with code and title\n availablePaymentMethods: Array.isArray(companyData.available_payment_methods)\n ? companyData.available_payment_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n\n // New available shipping methods\n availableShippingMethods: Array.isArray(companyData.available_shipping_methods)\n ? companyData.available_shipping_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n \n // Computed permission flags (single source of truth)\n canEditAccount: permissionsFlags.canEditAccount,\n canEditAddress: permissionsFlags.canEditAddress,\n permissionsFlags,\n customerRole,\n customerStatus: customerData?.status,\n };\n\n // Validate only when profile fields are permitted\n if (permissionsFlags.canViewAccount) {\n if (!model.id) {\n throw new Error('Company ID is required');\n }\n if (!model.name) {\n throw new Error('Company name is required');\n }\n if (!model.email) {\n throw new Error('Company email is required');\n }\n }\n\n return model;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../models/country';\n\nexport const transformCountries = (\n response: CountriesFormResponse\n): {\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n} => {\n if (!response?.data?.countries?.length) {\n return {\n availableCountries: [],\n countriesWithRequiredRegion: [],\n optionalZipCountries: [],\n };\n }\n\n const { countries, storeConfig } = response.data;\n\n const countriesWithRequiredRegion =\n storeConfig?.countries_with_required_region.split(',');\n const optionalZipCountries = storeConfig?.optional_zip_countries.split(',');\n\n const availableCountries = countries\n .filter(({ two_letter_abbreviation, full_name_locale }) =>\n Boolean(two_letter_abbreviation && full_name_locale)\n )\n .map((country) => {\n const { two_letter_abbreviation, full_name_locale, available_regions } = country;\n\n const hasRegions = Array.isArray(available_regions) && available_regions.length > 0;\n return {\n value: two_letter_abbreviation,\n text: full_name_locale,\n availableRegions: hasRegions ? available_regions : undefined,\n };\n })\n .sort((a, b) => a.text.localeCompare(b.text));\n\n return {\n availableCountries,\n countriesWithRequiredRegion,\n optionalZipCountries,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const COMPANY_LEGAL_ADDRESS_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {\n street\n city\n region {\n region\n region_code\n region_id\n }\n country_code\n postcode\n telephone\n }\n`;\n\nexport const COMPANY_BASIC_INFO_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_BASIC_INFO_FRAGMENT on Company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n }\n`;\n\nexport const COMPANY_SALES_REPRESENTATIVE_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {\n firstname\n lastname\n email\n }\n`;\n\nexport const COMPANY_ADMIN_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_ADMIN_FRAGMENT on Customer {\n firstname\n lastname\n email\n job_title\n }\n`;\n\nexport const COMPANY_FULL_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_FULL_FRAGMENT on Company {\n ...COMPANY_BASIC_INFO_FRAGMENT\n legal_address {\n ...COMPANY_LEGAL_ADDRESS_FRAGMENT\n }\n company_admin {\n ...COMPANY_ADMIN_FRAGMENT\n }\n sales_representative {\n ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT\n }\n available_payment_methods {\n code\n title\n }\n available_shipping_methods {\n code\n title\n }\n }\n ${COMPANY_BASIC_INFO_FRAGMENT}\n ${COMPANY_LEGAL_ADDRESS_FRAGMENT}\n ${COMPANY_ADMIN_FRAGMENT}\n ${COMPANY_SALES_REPRESENTATIVE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport {\n COMPANY_BASIC_INFO_FRAGMENT,\n COMPANY_LEGAL_ADDRESS_FRAGMENT,\n COMPANY_ADMIN_FRAGMENT,\n COMPANY_SALES_REPRESENTATIVE_FRAGMENT,\n} from './CompanyFragment.graphql';\n\n/**\n * Builds company fields based on user permissions\n */\nconst buildCompanyFields = (allowed: Set<string>): { fields: string[]; usedFragments: string[] } => {\n const wantProfile = allowed.has('Magento_Company::view_account');\n const wantAddress = allowed.has('Magento_Company::view_address');\n const wantContacts = allowed.has('Magento_Company::contacts');\n const wantPayment = allowed.has('Magento_Company::payment_information');\n const wantShipping = allowed.has('Magento_Company::shipping_information');\n\n const fields: string[] = [];\n const usedFragments: string[] = [];\n\n if (wantProfile) {\n fields.push('...COMPANY_BASIC_INFO_FRAGMENT');\n usedFragments.push(COMPANY_BASIC_INFO_FRAGMENT);\n }\n if (wantAddress) {\n fields.push(`legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }`);\n usedFragments.push(COMPANY_LEGAL_ADDRESS_FRAGMENT);\n }\n if (wantContacts) {\n fields.push(`company_admin { ...COMPANY_ADMIN_FRAGMENT }`);\n fields.push(`sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }`);\n usedFragments.push(COMPANY_ADMIN_FRAGMENT);\n usedFragments.push(COMPANY_SALES_REPRESENTATIVE_FRAGMENT);\n }\n if (wantPayment) {\n fields.push(`available_payment_methods { code title }`);\n }\n if (wantShipping) {\n fields.push(`available_shipping_methods { code title }`);\n }\n\n return { fields, usedFragments };\n};\n\n/**\n * Builds a dynamic company query based on user permissions\n */\nexport const buildCompanyQuery = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n query GET_COMPANY_DYNAMIC {\n company { __typename }\n }\n `;\n }\n\n const query = `\n query GET_COMPANY_DYNAMIC {\n company {\n ${fields.join('\\n ')}\n }\n }\n `;\n\n return `${query}\\n${usedFragments.join('\\n')}`;\n};\n\n/**\n * Builds a dynamic company update mutation based on user permissions\n */\nexport const buildUpdateCompanyMutation = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company { __typename }\n }\n }\n `;\n }\n\n const mutation = `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company {\n ${fields.join('\\n ')}\n }\n }\n }\n `;\n\n return `${mutation}\\n${usedFragments.join('\\n')}`;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildCompanyQuery } from '../graphql/buildCompanyQueries';\nimport { handleFetchError } from '../../lib/fetch-error';\n\nexport const getCompany = async (): Promise<CompanyModel | null> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a company query that requests only allowed fields\n const GET_COMPANY_DYNAMIC = buildCompanyQuery(allowedIds);\n\n // Fetch company with dynamic selection\n const companyResponse: getCompanyResponse = await fetchGraphQl(GET_COMPANY_DYNAMIC, { method: 'GET', cache: 'no-cache' });\n if (companyResponse.errors?.length) return handleFetchError(companyResponse.errors);\n\n const companyNode: any = companyResponse?.data?.company;\n const hasAnyCompanyField = companyNode && Object.keys(companyNode).some((k) => k !== '__typename');\n if (!hasAnyCompanyField) {\n return null;\n }\n\n // Merge back minimal customer role info so transform can compute flags\n (companyResponse as any).data.customer = roleResponse?.data?.customer;\n\n return transformCompany(companyResponse);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const GET_COUNTRIES_QUERY = `\n query getCountries {\n countries {\n id\n two_letter_abbreviation\n three_letter_abbreviation\n full_name_locale\n full_name_english\n available_regions {\n id\n code\n name\n }\n }\n storeConfig {\n countries_with_required_region\n optional_zip_countries\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { GET_COUNTRIES_QUERY } from './graphql/getCountries.graphql';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCountries } from '../../data/transforms/transform-countries';\nimport { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../../data/models/country';\n\nexport const getCountries = async (): Promise<{\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n}> => {\n const sessionStorageKey = '_company_countries';\n\n const sessionStorageCache = sessionStorage.getItem(sessionStorageKey);\n\n if (sessionStorageCache) {\n return JSON.parse(sessionStorageCache);\n }\n\n return await fetchGraphQl(GET_COUNTRIES_QUERY, {\n method: 'GET',\n })\n .then((response: CountriesFormResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n const transformedData = transformCountries(response);\n\n sessionStorage.setItem(\n sessionStorageKey,\n JSON.stringify(transformedData)\n );\n\n return transformedData;\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { updateCompanyResponse, UpdateCompanyDto } from '../../types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildUpdateCompanyMutation } from '../graphql/buildCompanyQueries';\n\n\nexport const updateCompany = async (input: UpdateCompanyDto): Promise<CompanyModel> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a dynamic mutation that requests only allowed fields in response\n const UPDATE_COMPANY_DYNAMIC = buildUpdateCompanyMutation(allowedIds);\n\n // Transform input (keep original logic for what to send)\n const transformedInput: Record<string, unknown> = {};\n \n // Map frontend field names to GraphQL schema field names\n if (input.name !== undefined) {\n transformedInput.company_name = input.name;\n }\n if (input.email !== undefined) {\n transformedInput.company_email = input.email;\n }\n if (input.legalName !== undefined) {\n transformedInput.legal_name = input.legalName;\n }\n if (input.vatTaxId !== undefined) {\n transformedInput.vat_tax_id = input.vatTaxId;\n }\n if (input.resellerId !== undefined) {\n transformedInput.reseller_id = input.resellerId;\n }\n \n // Transform legal address (only if user has edit_address permission)\n if (input.legalAddress !== undefined && allowedIds.has('Magento_Company::edit_address')) {\n // Handle street field - ensure it's always a flat array of strings\n let streetArray: string[];\n if (Array.isArray(input.legalAddress.street)) {\n // If street is already an array, use it directly and add street_2 if present\n streetArray = [...input.legalAddress.street];\n if (input.legalAddress.street2) {\n streetArray.push(input.legalAddress.street2);\n }\n } else {\n // If street is a string, create array normally with type guard\n streetArray = [input.legalAddress.street, input.legalAddress.street2].filter(\n (s): s is string => typeof s === 'string' && s.trim().length > 0\n );\n }\n \n // Remove any empty strings and ensure all elements are strings\n streetArray = streetArray.filter(street => street && typeof street === 'string' && street.trim().length > 0);\n \n // Handle region - different approaches for dropdown vs custom regions\n let regionValue: { region: string; region_code: string; region_id?: number } | undefined;\n if (input.legalAddress.region && typeof input.legalAddress.region === 'object') {\n const regionObj = input.legalAddress.region;\n \n // Check if this is a custom region (region === regionCode) or predefined region\n if (regionObj.region === regionObj.regionCode) {\n // Custom region - send as object with region_id: 0\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n region_id: 0\n };\n } else {\n // Predefined region - send as object\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n };\n }\n } else if (input.legalAddress.regionCode && input.legalAddress.region !== input.legalAddress.regionCode) {\n // If we have different region and regionCode (dropdown case)\n regionValue = {\n region: input.legalAddress.region || input.legalAddress.regionCode,\n region_code: input.legalAddress.regionCode,\n };\n } else if (input.legalAddress.region) {\n // If we only have region string (fallback case)\n regionValue = {\n region: input.legalAddress.region,\n region_code: input.legalAddress.region,\n region_id: 0\n };\n }\n \n transformedInput.legal_address = {\n street: streetArray,\n city: input.legalAddress.city,\n region: regionValue,\n country_id: input.legalAddress.countryCode, // GraphQL expects country_id, not countryCode\n postcode: input.legalAddress.postcode,\n telephone: input.legalAddress.telephone,\n };\n }\n\n // Execute the dynamic mutation\n const response: updateCompanyResponse = await fetchGraphQl(UPDATE_COMPANY_DYNAMIC, {\n method: 'POST',\n variables: { input: transformedInput },\n });\n\n if (response.errors?.length) return handleFetchError(response.errors);\n\n // Merge back minimal customer role info so transform can compute flags\n (response as any).data.customer = roleResponse?.data?.customer;\n\n return transformCompany(response);\n })\n .catch(handleNetworkError);\n};\n"],"names":["transformCompany","response","companyData","_a","customerData","legalAddress","line","customerRole","permissionsFlags","buildPermissionFlags","model","m","transformCountries","_b","countries","storeConfig","countriesWithRequiredRegion","optionalZipCountries","two_letter_abbreviation","full_name_locale","country","available_regions","hasRegions","a","b","COMPANY_LEGAL_ADDRESS_FRAGMENT","COMPANY_BASIC_INFO_FRAGMENT","COMPANY_SALES_REPRESENTATIVE_FRAGMENT","COMPANY_ADMIN_FRAGMENT","buildCompanyFields","allowed","wantProfile","wantAddress","wantContacts","wantPayment","wantShipping","fields","usedFragments","buildCompanyQuery","buildUpdateCompanyMutation","getCompany","fetchUserPermissions","allowedIds","roleResponse","GET_COMPANY_DYNAMIC","companyResponse","fetchGraphQl","handleFetchError","companyNode","k","_c","handleNetworkError","GET_COUNTRIES_QUERY","getCountries","sessionStorageKey","sessionStorageCache","transformedData","updateCompany","input","UPDATE_COMPANY_DYNAMIC","transformedInput","streetArray","s","street","regionValue","regionObj"],"mappings":"wGAqBa,MAAAA,EACXC,GACiB,OAEb,GAAA,EAACA,GAAA,MAAAA,EAAU,MACP,MAAA,IAAI,MAAM,gCAAgC,EAI5C,MAAAC,EAAmB,kBAAmBD,EAAS,MACjDE,EAAAF,EAAS,KAAK,gBAAd,YAAAE,EAA6B,QAC7BF,EAAS,KAAK,QAElB,GAAI,CAACC,EACG,MAAA,IAAI,MAAM,wCAAwC,EAG1D,MAAME,EAAe,aAAcH,EAAS,KAAOA,EAAS,KAAK,SAAW,OAGtEI,EAAeH,EAAY,cAAgB,CAC/C,OAAQ,MAAM,QAAQA,EAAY,cAAc,MAAM,EAClDA,EAAY,cAAc,OAAO,OAAQI,GAAiBA,GAAQA,EAAK,KAAW,IAAA,EAAE,EACpF,CAAC,EACL,MAAOJ,EAAY,cAAc,MAAQ,IAAI,KAAK,EAClD,OAAQA,EAAY,cAAc,OAAS,CACzC,QAASA,EAAY,cAAc,OAAO,QAAU,IAAI,KAAK,EAC7D,YAAaA,EAAY,cAAc,OAAO,aAAe,IAAI,KAAK,EACtE,SAAUA,EAAY,cAAc,OAAO,UAAY,OAAOA,EAAY,cAAc,OAAO,SAAS,EAAI,CAAA,EAC1G,OACJ,aAAcA,EAAY,cAAc,cAAgB,IAAI,cAAc,KAAK,EAC/E,UAAWA,EAAY,cAAc,UAAY,IAAI,KAAK,EAC1D,UAAWA,EAAY,cAAc,UACnCA,EAAY,cAAc,UAAU,OAAS,MAAA,EAC7C,OAGEK,EAAeH,GAAA,YAAA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OAAQC,EAAU,OAClB,YAAaA,EAAU,UACzB,CACF,MACSP,EAAM,aAAa,YAAcA,EAAM,aAAa,SAAWA,EAAM,aAAa,WAE7EM,EAAA,CACZ,OAAQN,EAAM,aAAa,QAAUA,EAAM,aAAa,WACxD,YAAaA,EAAM,aAAa,UAClC,EACSA,EAAM,aAAa,SAEdM,EAAA,CACZ,OAAQN,EAAM,aAAa,OAC3B,YAAaA,EAAM,aAAa,OAChC,UAAW,CACb,GAGFE,EAAiB,cAAgB,CAC/B,OAAQC,EACR,KAAMH,EAAM,aAAa,KACzB,OAAQM,EACR,WAAYN,EAAM,aAAa,YAC/B,SAAUA,EAAM,aAAa,SAC7B,UAAWA,EAAM,aAAa,SAChC,CAAA,CAII,MAAAzD,EAAkC,MAAM6C,EAAaa,EAAwB,CACjF,OAAQ,OACR,UAAW,CAAE,MAAOC,CAAiB,CAAA,CACtC,EAED,OAAIzD,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OAAe4C,EAAiB9C,EAAS,MAAM,GAGnEA,EAAiB,KAAK,UAAWY,EAAA8B,GAAA,YAAAA,EAAc,OAAd,YAAA9B,EAAoB,SAE/Cb,EAAiBC,CAAQ,EAAA,CACjC,EACA,MAAMkD,CAAkB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{f as l,h as m,c as d}from"./fetch-error.js";import{i as y}from"./fetchUserPermissions.js";const f=e=>{try{return btoa(e)}catch(t){throw new Error(`Failed to encode base64: ${t}`)}},h=e=>{try{return atob(e)}catch{return e}},p=e=>{if(!e||typeof e!="string")throw new Error("User ID must be a non-empty string");return f(e)},_=e=>!e||typeof e!="string"?e:h(e),C=`
|
|
4
|
+
mutation createCompanyUser($input: CompanyUserCreateInput!) {
|
|
5
|
+
createCompanyUser(input: $input) { __typename user { id structure_id email firstname lastname } }
|
|
6
|
+
}
|
|
7
|
+
`;async function v(e){const t={email:e.email,firstname:e.firstName,lastname:e.lastName,job_title:e.jobTitle,telephone:e.telephone,role_id:e.roleId,status:e.status,target_id:e.targetId};return await l(C,{variables:{input:t}}).then(a=>{var n,s,o;if((n=a.errors)!=null&&n.length)return m(a.errors);const r=(o=(s=a==null?void 0:a.data)==null?void 0:s.createCompanyUser)==null?void 0:o.user;return r?{id:r.id,structureId:r.structure_id}:null}).catch(d)}const U=`
|
|
8
|
+
mutation DELETE_COMPANY_USER($id: ID!) {
|
|
9
|
+
deleteCompanyUserV2(id: $id) {
|
|
10
|
+
success
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`,O=async e=>{var a,r;const{id:t}=e;if(!t)throw new Error("User ID is required to delete a company user");try{const n=p(t),s=await l(U,{method:"POST",cache:"no-cache",variables:{id:n}}).catch(d);return(a=s.errors)!=null&&a.length&&m(s.errors),(r=s.data)!=null&&r.deleteCompanyUserV2?{success:s.data.deleteCompanyUserV2.success}:{success:!1}}catch{return{success:!1}}},g=e=>{if(!Array.isArray(e))throw new Error("Invalid response: expected array of roles");return e.map(t=>{if(!t||typeof t.id!="string"||typeof t.name!="string")throw new Error("Invalid response: missing required role data");return{id:t.id,name:t.name}})},E=e=>{if(!e)throw new Error("Invalid response: missing user data");return{id:e.id,email:e.email,firstName:e.firstname,lastName:e.lastname,jobTitle:e.job_title,telephone:e.telephone,status:e.status,role:e.role,isCompanyAdmin:y(e.role)}},A=`
|
|
14
|
+
query getCompanyRoles {
|
|
15
|
+
company {
|
|
16
|
+
roles {
|
|
17
|
+
items { id name }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;async function R(){return await l(A,{method:"GET"}).then(e=>{var a,r,n,s;if((a=e.errors)!=null&&a.length)return m(e.errors);const t=((s=(n=(r=e==null?void 0:e.data)==null?void 0:r.company)==null?void 0:n.roles)==null?void 0:s.items)??[];return g(t)}).catch(d)}const I=`
|
|
22
|
+
query getCompanyUser($id: ID!) {
|
|
23
|
+
company {
|
|
24
|
+
user(id: $id) {
|
|
25
|
+
id
|
|
26
|
+
email
|
|
27
|
+
firstname
|
|
28
|
+
lastname
|
|
29
|
+
job_title
|
|
30
|
+
telephone
|
|
31
|
+
status
|
|
32
|
+
role { id name }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;async function M(e){const t=p(e);return await l(I,{variables:{id:t}}).then(a=>{var n,s,o;if((n=a.errors)!=null&&n.length)return m(a.errors);const r=(o=(s=a==null?void 0:a.data)==null?void 0:s.company)==null?void 0:o.user;return r?E(r):null}).catch(d)}const S=`
|
|
37
|
+
query COMPANY_USERS($pageSize: Int!, $currentPage: Int!, $filter: CompanyUsersFilterInput) {
|
|
38
|
+
company {
|
|
39
|
+
users(pageSize: $pageSize, currentPage: $currentPage, filter: $filter) {
|
|
40
|
+
items {
|
|
41
|
+
id
|
|
42
|
+
firstname
|
|
43
|
+
lastname
|
|
44
|
+
email
|
|
45
|
+
role {
|
|
46
|
+
name
|
|
47
|
+
}
|
|
48
|
+
status
|
|
49
|
+
team {
|
|
50
|
+
name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
page_info {
|
|
54
|
+
page_size
|
|
55
|
+
current_page
|
|
56
|
+
total_pages
|
|
57
|
+
}
|
|
58
|
+
total_count
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`,Y=async(e={})=>{var n,s,o,u;const{pageSize:t=20,currentPage:a=1,filter:r}=e;try{const i=await l(S,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:a,filter:r}}).catch(d);return(n=i.errors)!=null&&n.length&&m(i.errors),(u=(o=(s=i.data)==null?void 0:s.company)==null?void 0:o.users)!=null&&u.items?{users:i.data.company.users.items.map(c=>({id:_(c.id),firstName:c.firstname,lastName:c.lastname,email:c.email,role:c.role.name,status:c.status,...c.team&&{team:c.team.name}})),pageInfo:{pageSize:i.data.company.users.page_info.page_size,currentPage:i.data.company.users.page_info.current_page,totalPages:i.data.company.users.page_info.total_pages},totalCount:i.data.company.users.total_count}:{users:[],pageInfo:{pageSize:t,currentPage:a,totalPages:1}}}catch{return{users:[],pageInfo:{pageSize:t,currentPage:a,totalPages:1}}}},T=`
|
|
63
|
+
query isCompanyUserEmailAvailable($email: String!) {
|
|
64
|
+
isCompanyUserEmailAvailable(email: $email) { is_email_available }
|
|
65
|
+
}
|
|
66
|
+
`;async function D(e){return await l(T,{variables:{email:e}}).then(t=>{var a,r,n;return(a=t.errors)!=null&&a.length?m(t.errors):((n=(r=t==null?void 0:t.data)==null?void 0:r.isCompanyUserEmailAvailable)==null?void 0:n.is_email_available)??null}).catch(d)}const b=`
|
|
67
|
+
mutation updateCompanyUser($input: CompanyUserUpdateInput!) {
|
|
68
|
+
updateCompanyUser(input: $input) { __typename user { id } }
|
|
69
|
+
}
|
|
70
|
+
`;async function V(e){const t={id:p(e.id),email:e.email,firstname:e.firstName,lastname:e.lastName,job_title:e.jobTitle,telephone:e.telephone,role_id:e.roleId,status:e.status};return await l(b,{variables:{input:t}}).then(a=>{var r,n,s,o;return(r=a.errors)!=null&&r.length?m(a.errors):!!((o=(s=(n=a==null?void 0:a.data)==null?void 0:n.updateCompanyUser)==null?void 0:s.user)!=null&&o.id)}).catch(d)}const w=`
|
|
71
|
+
mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {
|
|
72
|
+
updateCompanyUser(input: $input) {
|
|
73
|
+
user {
|
|
74
|
+
id
|
|
75
|
+
status
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`,q=async e=>{var r,n,s;const{id:t,status:a}=e;if(!t)throw new Error("User ID is required to update company user status");if(!a||a!=="ACTIVE"&&a!=="INACTIVE")throw new Error("Valid status (ACTIVE or INACTIVE) is required to update company user status");try{const o=p(t),u=await l(w,{method:"POST",cache:"no-cache",variables:{input:{id:o,status:a}}}).catch(d);return(r=u.errors)!=null&&r.length&&m(u.errors),(s=(n=u.data)==null?void 0:n.updateCompanyUser)!=null&&s.user?{success:!0,user:{id:u.data.updateCompanyUser.user.id,status:u.data.updateCompanyUser.user.status}}:{success:!1}}catch{return{success:!1}}};export{M as a,Y as b,v as c,O as d,q as e,R as g,D as i,V as u};
|
|
80
|
+
//# sourceMappingURL=updateCompanyUserStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompanyUserStatus.js","sources":["/@dropins/storefront-company-management/src/lib/encoding.ts","/@dropins/storefront-company-management/src/api/createCompanyUser/graphql/createCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/createCompanyUser/createCompanyUser.ts","/@dropins/storefront-company-management/src/api/deleteCompanyUser/graphql/deleteCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/deleteCompanyUser/deleteCompanyUser.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company-roles.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company-user.ts","/@dropins/storefront-company-management/src/api/getCompanyRoles/graphql/getCompanyRoles.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyRoles/getCompanyRoles.ts","/@dropins/storefront-company-management/src/api/getCompanyUser/graphql/getCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyUser/getCompanyUser.ts","/@dropins/storefront-company-management/src/api/getCompanyUsers/graphql/companyUsers.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyUsers/getCompanyUsers.ts","/@dropins/storefront-company-management/src/api/isCompanyUserEmailAvailable/graphql/isCompanyUserEmailAvailable.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyUserEmailAvailable/isCompanyUserEmailAvailable.ts","/@dropins/storefront-company-management/src/api/updateCompanyUser/graphql/updateCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyUser/updateCompanyUser.ts","/@dropins/storefront-company-management/src/api/updateCompanyUserStatus/graphql/updateCompanyUserStatus.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyUserStatus/updateCompanyUserStatus.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/**\n * Encodes a string to base64\n * @param value - The string to encode\n * @returns The base64 encoded string\n * @throws Error if encoding fails\n */\nexport const encodeBase64 = (value: string): string => {\n try {\n return btoa(value);\n } catch (error) {\n throw new Error(`Failed to encode base64: ${error}`);\n }\n};\n\n/**\n * Decodes a base64 encoded string\n * @param encoded - The base64 encoded string to decode\n * @returns The decoded string, or the original string if decoding fails\n */\nexport const decodeBase64 = (encoded: string): string => {\n try {\n return atob(encoded);\n } catch {\n // Return original if decoding fails (graceful fallback)\n return encoded;\n }\n};\n\n/**\n * Safely encodes a user ID to base64 for API transmission\n * @param userId - The user ID to encode\n * @returns The base64 encoded user ID\n * @throws Error if userId is empty or encoding fails\n */\nexport const encodeUserId = (userId: string): string => {\n if (!userId || typeof userId !== 'string') {\n throw new Error('User ID must be a non-empty string');\n }\n \n return encodeBase64(userId);\n};\n\n/**\n * Safely decodes a base64 encoded user ID from API response\n * @param encodedUserId - The base64 encoded user ID\n * @returns The decoded user ID, or the original string if decoding fails\n */\nexport const decodeUserId = (encodedUserId: string): string => {\n if (!encodedUserId || typeof encodedUserId !== 'string') {\n return encodedUserId;\n }\n \n return decodeBase64(encodedUserId);\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_USER = /* GraphQL */ `\n mutation createCompanyUser($input: CompanyUserCreateInput!) {\n createCompanyUser(input: $input) { __typename user { id structure_id email firstname lastname } }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { CreateCompanyUserInput, CreateCompanyUserResult } from '@/company-management/types';\nimport { CREATE_COMPANY_USER } from './graphql/createCompanyUser.graphql';\n\n/**\n * Creates a new company user with the provided information\n * @param input - User information including email, name, job title, and role\n * @returns Promise resolving to created user result or null if creation failed\n */\nexport async function createCompanyUser(input: CreateCompanyUserInput): Promise<CreateCompanyUserResult | null> {\n const transformedInput = {\n email: input.email,\n firstname: input.firstName,\n lastname: input.lastName,\n job_title: input.jobTitle,\n telephone: input.telephone,\n role_id: input.roleId,\n status: input.status,\n target_id: input.targetId,\n };\n\n return await fetchGraphQl<{ createCompanyUser?: { user?: { id: string; structure_id?: string } } }>(CREATE_COMPANY_USER, { variables: { input: transformedInput } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const user = res?.data?.createCompanyUser?.user;\n if (!user) return null;\n \n return {\n id: user.id,\n structureId: user.structure_id,\n };\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const DELETE_COMPANY_USER_MUTATION = /* GraphQL */ `\n mutation DELETE_COMPANY_USER($id: ID!) {\n deleteCompanyUserV2(id: $id) {\n success\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 { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, encodeUserId } from '@/company-management/lib';\nimport { DELETE_COMPANY_USER_MUTATION } from './graphql/deleteCompanyUser.graphql';\nimport { DeleteCompanyUserMutation, DeleteCompanyUserParams, DeleteCompanyUserResponse } from '@/company-management/types';\n\n/**\n * Deletes a company user by their ID\n * @param params - The parameters containing user ID\n * @param params.id - The ID of the user to delete (will be base64 encoded)\n * @returns Promise<DeleteCompanyUserResponse> - Object containing success status\n */\nexport const deleteCompanyUser = async (params: DeleteCompanyUserParams): Promise<DeleteCompanyUserResponse> => {\n const { id } = params;\n \n if (!id) {\n throw new Error('User ID is required to delete a company user');\n }\n\n try {\n const encodedId = encodeUserId(id);\n \n const response = await fetchGraphQl<DeleteCompanyUserMutation>(\n DELETE_COMPANY_USER_MUTATION,\n {\n method: 'POST',\n cache: 'no-cache',\n variables: {\n id: encodedId\n }\n }\n ).catch(handleNetworkError);\n\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n if (!response.data?.deleteCompanyUserV2) {\n return {\n success: false\n };\n }\n\n return {\n success: response.data.deleteCompanyUserV2.success\n };\n } catch (error) {\n // Both handleNetworkError and handleFetchError throw errors\n // We return failure status as fallback\n return {\n success: false\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 { CompanyRoleModel } from '@/company-management/data/models/company-role';\n\ninterface CompanyRoleResponse {\n id: string;\n name: string;\n}\n\nexport const transformCompanyRoles = (responses: CompanyRoleResponse[]): CompanyRoleModel[] => {\n if (!Array.isArray(responses)) {\n throw new Error('Invalid response: expected array of roles');\n }\n\n return responses.map((response) => {\n if (!response || typeof response.id !== 'string' || typeof response.name !== 'string') {\n throw new Error('Invalid response: missing required role data');\n }\n\n return {\n id: response.id,\n name: response.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 *******************************************************************/\n\nimport { CompanyUserModel } from '@/company-management/data/models/company-user';\nimport { isCompanyAdministrator } from '@/company-management/lib';\n\ninterface CompanyUserResponse {\n id: string;\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string | null;\n telephone?: string | null;\n status?: string | null;\n role?: {\n id: string;\n name: string;\n } | null;\n}\n\nexport const transformCompanyUser = (response: CompanyUserResponse): CompanyUserModel => {\n if (!response) {\n throw new Error('Invalid response: missing user data');\n }\n\n return {\n id: response.id,\n email: response.email,\n firstName: response.firstname,\n lastName: response.lastname,\n jobTitle: response.job_title,\n telephone: response.telephone,\n status: response.status,\n role: response.role,\n isCompanyAdmin: isCompanyAdministrator(response.role),\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_ROLES = /* GraphQL */ `\n query getCompanyRoles {\n company {\n roles {\n items { id 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 *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { CompanyRoleModel } from '@/company-management/data/models';\nimport { transformCompanyRoles } from '@/company-management/data/transforms';\nimport { GET_COMPANY_ROLES } from './graphql/getCompanyRoles.graphql';\n\n/**\n * Retrieves all available company roles\n * @returns Promise resolving to array of CompanyRoleModel\n */\nexport async function getCompanyRoles(): Promise<CompanyRoleModel[]> {\n return await fetchGraphQl<{ company?: { roles?: { items?: { id: string; name: string }[] } } }>(GET_COMPANY_ROLES, { method: 'GET' })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const roles = res?.data?.company?.roles?.items ?? [];\n \n return transformCompanyRoles(roles);\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\nexport const GET_COMPANY_USER = /* GraphQL */ `\n query getCompanyUser($id: ID!) {\n company {\n user(id: $id) {\n id\n email\n firstname\n lastname\n job_title\n telephone\n status\n role { id 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 *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, encodeUserId } from '@/company-management/lib';\nimport { CompanyUserModel } from '@/company-management/data/models';\nimport { transformCompanyUser } from '@/company-management/data/transforms';\nimport { GET_COMPANY_USER } from './graphql/getCompanyUser.graphql';\n\n/**\n * Retrieves a specific company user by their ID\n * @param id - The ID of the company user to retrieve (will be base64 encoded)\n * @returns Promise resolving to CompanyUserModel or null if user not found\n */\nexport async function getCompanyUser(id: string): Promise<CompanyUserModel | null> {\n const encodedId = encodeUserId(id);\n \n return await fetchGraphQl<{ company: { user?: { id: string; email: string; firstname: string; lastname: string; job_title?: string | null; telephone?: string | null; status?: string | null; role?: { id: string; name: string } | null } } }>(GET_COMPANY_USER, { variables: { id: encodedId } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const user = res?.data?.company?.user;\n if (!user) return null;\n \n return transformCompanyUser(user);\n })\n .catch(handleNetworkError);\n}\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const COMPANY_USERS_QUERY = /* GraphQL */ `\n query COMPANY_USERS($pageSize: Int!, $currentPage: Int!, $filter: CompanyUsersFilterInput) {\n company {\n users(pageSize: $pageSize, currentPage: $currentPage, filter: $filter) {\n items {\n id\n firstname\n lastname\n email\n role {\n name\n }\n status\n team {\n name\n }\n }\n page_info {\n page_size\n current_page\n total_pages\n }\n total_count\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, decodeUserId } from '@/company-management/lib';\nimport { COMPANY_USERS_QUERY } from './graphql/companyUsers.graphql';\nimport { CompanyUsersQuery, CompanyUser, CompanyUsersParams, CompanyUsersResponse } from '@/company-management/types';\n\n/**\n * Fetches the list of company users with pagination and optional filtering\n * @param params - Query parameters\n * @param params.pageSize - Number of items per page (default: 20)\n * @param params.currentPage - Current page number (default: 1)\n * @param params.filter - Optional filter to apply (e.g., { status: 'ACTIVE' })\n * @returns Promise<CompanyUsersResponse> - Object containing array of company users and pagination info\n */\nexport const getCompanyUsers = async (params: CompanyUsersParams = {}): Promise<CompanyUsersResponse> => {\n const { pageSize = 20, currentPage = 1, filter } = params;\n\n try {\n const response = await fetchGraphQl<CompanyUsersQuery>(\n COMPANY_USERS_QUERY,\n {\n method: 'GET',\n cache: 'no-cache',\n variables: {\n pageSize,\n currentPage,\n filter\n }\n }\n ).catch(handleNetworkError);\n\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n if (!response.data?.company?.users?.items) {\n return {\n users: [],\n pageInfo: {\n pageSize,\n currentPage,\n totalPages: 1\n }\n };\n }\n\n // Transform the GraphQL response to CompanyUser interface\n const users: CompanyUser[] = response.data.company.users.items.map((item) => {\n return {\n id: decodeUserId(item.id),\n firstName: item.firstname,\n lastName: item.lastname,\n email: item.email,\n role: item.role.name,\n status: item.status,\n ...(item.team && { team: item.team.name })\n };\n });\n\n return {\n users,\n pageInfo: {\n pageSize: response.data.company.users.page_info.page_size,\n currentPage: response.data.company.users.page_info.current_page,\n totalPages: response.data.company.users.page_info.total_pages\n },\n totalCount: response.data.company.users.total_count\n };\n } catch (error) {\n // Both handleNetworkError and handleFetchError throw errors\n // We return empty users array with default page info as fallback\n return {\n users: [],\n pageInfo: {\n pageSize,\n currentPage,\n totalPages: 1\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\nexport const IS_COMPANY_USER_EMAIL_AVAILABLE = /* GraphQL */ `\n query isCompanyUserEmailAvailable($email: String!) {\n isCompanyUserEmailAvailable(email: $email) { is_email_available }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { IS_COMPANY_USER_EMAIL_AVAILABLE } from './graphql/isCompanyUserEmailAvailable.graphql';\n\n/**\n * Checks if an email address is available for use by a new company user\n * @param email - The email address to check for availability\n * @returns Promise resolving to boolean indicating availability or null if check failed\n */\nexport async function isCompanyUserEmailAvailable(email: string): Promise<boolean | null> {\n return await fetchGraphQl<{ isCompanyUserEmailAvailable?: { is_email_available: boolean } }>(IS_COMPANY_USER_EMAIL_AVAILABLE, { variables: { email } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return res?.data?.isCompanyUserEmailAvailable?.is_email_available ?? null;\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\nexport const UPDATE_COMPANY_USER = /* GraphQL */ `\n mutation updateCompanyUser($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) { __typename user { id } }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, encodeUserId } from '@/company-management/lib';\nimport { UpdateCompanyUserInput } from '@/company-management/types';\nimport { UPDATE_COMPANY_USER } from './graphql/updateCompanyUser.graphql';\n\n/**\n * Updates an existing company user with the provided information\n * @param input - User information including ID and fields to update\n * @returns Promise resolving to boolean indicating success\n */\nexport async function updateCompanyUser(input: UpdateCompanyUserInput): Promise<boolean> {\n const transformedInput = {\n id: encodeUserId(input.id),\n email: input.email,\n firstname: input.firstName,\n lastname: input.lastName,\n job_title: input.jobTitle,\n telephone: input.telephone,\n role_id: input.roleId,\n status: input.status,\n };\n\n return await fetchGraphQl<{ updateCompanyUser?: { user?: { id: string } } }>(UPDATE_COMPANY_USER, { variables: { input: transformedInput } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return !!res?.data?.updateCompanyUser?.user?.id;\n })\n .catch(handleNetworkError);\n}\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const UPDATE_COMPANY_USER_STATUS_MUTATION = /* GraphQL */ `\n mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) {\n user {\n id\n status\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, encodeUserId } from '@/company-management/lib';\nimport { UPDATE_COMPANY_USER_STATUS_MUTATION } from './graphql/updateCompanyUserStatus.graphql';\nimport {\n UpdateCompanyUserStatusMutation,\n UpdateCompanyUserStatusParams,\n UpdateCompanyUserStatusResponse,\n} from '@/company-management/types';\n\n/**\n * Updates a company user's status (Active/Inactive)\n * @param params - The parameters containing user ID and new status\n * @param params.id - The ID of the user to update (will be base64 encoded)\n * @param params.status - The new status for the user (ACTIVE or INACTIVE)\n * @returns Promise<UpdateCompanyUserStatusResponse> - Object containing success status and updated user data\n */\nexport const updateCompanyUserStatus = async (params: UpdateCompanyUserStatusParams): Promise<UpdateCompanyUserStatusResponse> => {\n const { id, status } = params;\n \n if (!id) {\n throw new Error('User ID is required to update company user status');\n }\n \n if (!status || (status !== 'ACTIVE' && status !== 'INACTIVE')) {\n throw new Error('Valid status (ACTIVE or INACTIVE) is required to update company user status');\n }\n\n try {\n const encodedId = encodeUserId(id);\n \n const response = await fetchGraphQl<UpdateCompanyUserStatusMutation>(\n UPDATE_COMPANY_USER_STATUS_MUTATION,\n {\n method: 'POST',\n cache: 'no-cache',\n variables: {\n input: {\n id: encodedId,\n status\n }\n }\n }\n ).catch(handleNetworkError);\n\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n if (!response.data?.updateCompanyUser?.user) {\n return {\n success: false\n };\n }\n\n return {\n success: true,\n user: {\n id: response.data.updateCompanyUser.user.id,\n status: response.data.updateCompanyUser.user.status\n }\n };\n } catch (error) {\n // Both handleNetworkError and handleFetchError throw errors\n // We return failure status as fallback\n return {\n success: false\n };\n }\n};\n"],"names":["encodeBase64","value","error","decodeBase64","encoded","encodeUserId","userId","decodeUserId","encodedUserId","CREATE_COMPANY_USER","createCompanyUser","input","transformedInput","fetchGraphQl","res","_a","handleFetchError","user","_c","_b","handleNetworkError","DELETE_COMPANY_USER_MUTATION","deleteCompanyUser","params","id","encodedId","response","transformCompanyRoles","responses","transformCompanyUser","isCompanyAdministrator","GET_COMPANY_ROLES","getCompanyRoles","roles","_d","GET_COMPANY_USER","getCompanyUser","COMPANY_USERS_QUERY","getCompanyUsers","pageSize","currentPage","filter","item","IS_COMPANY_USER_EMAIL_AVAILABLE","isCompanyUserEmailAvailable","email","UPDATE_COMPANY_USER","updateCompanyUser","UPDATE_COMPANY_USER_STATUS_MUTATION","updateCompanyUserStatus","status"],"mappings":"iGAuBa,MAAAA,EAAgBC,GAA0B,CACjD,GAAA,CACF,OAAO,KAAKA,CAAK,QACVC,EAAO,CACd,MAAM,IAAI,MAAM,4BAA4BA,CAAK,EAAE,CAAA,CAEvD,EAOaC,EAAgBC,GAA4B,CACnD,GAAA,CACF,OAAO,KAAKA,CAAO,CAAA,MACb,CAEC,OAAAA,CAAA,CAEX,EAQaC,EAAgBC,GAA2B,CACtD,GAAI,CAACA,GAAU,OAAOA,GAAW,SACzB,MAAA,IAAI,MAAM,oCAAoC,EAGtD,OAAON,EAAaM,CAAM,CAC5B,EAOaC,EAAgBC,GACvB,CAACA,GAAiB,OAAOA,GAAkB,SACtCA,EAGFL,EAAaK,CAAa,ECpDtBC,EAAoC;AAAA;AAAA;AAAA;AAAA,ECSjD,eAAsBC,EAAkBC,EAAwE,CAC9G,MAAMC,EAAmB,CACvB,MAAOD,EAAM,MACb,UAAWA,EAAM,UACjB,SAAUA,EAAM,SAChB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EAA0B,MAAO1B,GAAoF,WAC1H,KAAA,CAAE,GAAAC,EAAI,OAAA0B,CAAA,EAAW3B,EAEvB,GAAI,CAACC,EACG,MAAA,IAAI,MAAM,mDAAmD,EAGrE,GAAI,CAAC0B,GAAWA,IAAW,UAAYA,IAAW,WAC1C,MAAA,IAAI,MAAM,6EAA6E,EAG3F,GAAA,CACI,MAAAzB,EAAYpB,EAAamB,CAAE,EAE3BE,EAAW,MAAMb,EACrBmC,EACA,CACE,OAAQ,OACR,MAAO,WACP,UAAW,CACT,MAAO,CACL,GAAIvB,EACJ,OAAAyB,CAAA,CACF,CACF,CACF,EACA,MAAM9B,CAAkB,EAM1B,OAJIL,EAAAW,EAAS,SAAT,MAAAX,EAAiB,QACnBC,EAAiBU,EAAS,MAAM,GAG7BR,GAAAC,EAAAO,EAAS,OAAT,YAAAP,EAAe,oBAAf,MAAAD,EAAkC,KAMhC,CACL,QAAS,GACT,KAAM,CACJ,GAAIQ,EAAS,KAAK,kBAAkB,KAAK,GACzC,OAAQA,EAAS,KAAK,kBAAkB,KAAK,MAAA,CAEjD,EAXS,CACL,QAAS,EACX,OAUY,CAGP,MAAA,CACL,QAAS,EACX,CAAA,CAEJ"}
|
package/chunks/useInLineAlert.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as r,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import{Skeleton as m,SkeletonRow as i,Card as C}from"@dropins/tools/components.js";import{classes as y}from"@dropins/tools/lib.js";import{useState as u,useCallback as c,useEffect as L}from"@dropins/tools/preact-hooks.js";import*as t from"@dropins/tools/preact-compat.js";const Z=({testId:s,withCard:a=!0})=>{const n=k(m,{"data-testid":s||"companySkeletonLoader",children:[r(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),r(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),r(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return a?n:r(C,{variant:"secondary",className:y(["company-company-loaders","company-company-loaders--card-loader"]),children:n})},A=({testId:s})=>r("div",{className:"company-users-skeleton-loader","data-testid":s||"companyUsersSkeletonLoader",children:r(m,{children:r(i,{variant:"row",size:"small",fullWidth:!0,lines:3})})}),_=()=>r("div",{className:"company-user-form-skeleton-loader","data-testid":"companyUserFormLoader",children:r(m,{children:r(i,{variant:"row",size:"medium",fullWidth:!0,lines:7})})}),E=s=>t.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("g",{clipPath:"url(#clip0_841_1324)"},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_841_1324"},t.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),x=s=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),H=s=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),S={success:r(x,{}),warning:r(E,{}),error:r(H,{})},z=()=>{const[s,a]=u({}),[n,d]=u(null),h=c(()=>{a({}),n&&(clearTimeout(n),d(null))},[n]),o=c(e=>{if(n&&(clearTimeout(n),d(null)),!(e!=null&&e.type)){a({});return}const l=S[e.type];if(a({type:e.type,text:e.text,icon:l}),e.autoHide!==!1){const w=e.autoHideDelay||(e.type==="success"?3e3:5e3),v=setTimeout(()=>{a({}),d(null)},w);d(v)}},[n]),p=c((e,l=!0)=>{o({type:"success",text:e,autoHide:l})},[o]),g=c((e,l=!1)=>{o({type:"warning",text:e,autoHide:l})},[o]),f=c((e,l=!1)=>{o({type:"error",text:e,autoHide:l})},[o]);return L(()=>()=>{n&&clearTimeout(n)},[n]),{inLineAlertProps:s,handleSetInLineAlert:o,clearAlert:h,showSuccess:p,showWarning:g,showError:f}};export{Z as C,_ as a,A as b,z as u};
|
|
4
4
|
//# sourceMappingURL=useInLineAlert.js.map
|