@dropins/storefront-quote-management 0.0.1-alpha5 → 0.0.1-alpha8
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/graphql/NegotiableQuoteFragment.d.ts +1 -1
- package/api/graphql/SearchResultPageInfoFragment.d.ts +10 -0
- package/api/{getQuoteData/getQuoteData.d.ts → graphql/SortFieldsFragment.d.ts} +2 -2
- package/api/index.d.ts +1 -1
- package/api/initialize/initialize.d.ts +0 -1
- package/{components/ActionsBar/index.d.ts → api/negotiableQuotes/graphql/NegotiableQuotesQuery.d.ts} +2 -3
- package/api/{getQuoteData → negotiableQuotes}/index.d.ts +1 -1
- package/api/negotiableQuotes/negotiableQuotes.d.ts +39 -0
- package/api.js +4 -16
- package/api.js.map +1 -1
- package/chunks/NegotiableQuoteFragment.js +56 -0
- package/chunks/NegotiableQuoteFragment.js.map +1 -0
- package/chunks/negotiableQuotes.js +47 -0
- package/chunks/negotiableQuotes.js.map +1 -0
- package/chunks/requestNegotiableQuote.js +3 -111
- package/chunks/requestNegotiableQuote.js.map +1 -1
- package/components/QuotesListTable/QuotesListTable.d.ts +29 -0
- package/components/{TabbedContent → QuotesListTable}/index.d.ts +2 -2
- package/components/index.d.ts +1 -6
- package/containers/QuotesListTable/QuotesListTable.d.ts +72 -0
- package/{components/ItemsQuoted → containers/QuotesListTable}/index.d.ts +2 -2
- package/containers/QuotesListTable.d.ts +3 -0
- package/containers/QuotesListTable.js +4 -0
- package/containers/QuotesListTable.js.map +1 -0
- package/containers/RequestNegotiableQuoteForm.js +1 -1
- package/containers/RequestNegotiableQuoteForm.js.map +1 -1
- package/containers/index.d.ts +1 -2
- package/data/models/__fixtures__/negotiableQuotesListModel.d.ts +5 -0
- package/data/models/customer-model.d.ts +0 -1
- package/data/models/index.d.ts +1 -0
- package/data/models/negotiable-quote-model.d.ts +61 -27
- package/data/transforms/__fixtures__/negotiableQuoteData.d.ts +117 -94
- package/data/transforms/transform-quote.d.ts +4 -1
- package/i18n/en_US.json.d.ts +14 -55
- package/lib/state.d.ts +0 -1
- package/package.json +1 -1
- package/render.js +3 -4
- package/render.js.map +1 -1
- package/types/state.types.d.ts +0 -1
- package/api/getQuoteData/graphql/QuoteDataQuery.d.ts +0 -2
- package/chunks/RequestNegotiableQuoteForm.js +0 -4
- package/chunks/RequestNegotiableQuoteForm.js.map +0 -1
- package/components/ActionsBar/ActionsBar.d.ts +0 -14
- package/components/ItemsQuoted/ItemsQuoted.d.ts +0 -9
- package/components/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +0 -18
- package/components/ManageNegotiableQuote/__fixtures__/ManageNegotiableQuoteProps.d.ts +0 -4
- package/components/ManageNegotiableQuote/index.d.ts +0 -11
- package/components/ProductListTable/ProductListTable.d.ts +0 -13
- package/components/ProductListTable/index.d.ts +0 -11
- package/components/QuotePricesSummary/QuotePricesSummary.d.ts +0 -16
- package/components/QuotePricesSummary/index.d.ts +0 -11
- package/components/TabbedContent/TabbedContent.d.ts +0 -10
- package/containers/ItemsQuoted/ItemsQuoted.d.ts +0 -25
- package/containers/ItemsQuoted/index.d.ts +0 -11
- package/containers/ItemsQuoted.d.ts +0 -3
- package/containers/ItemsQuoted.js +0 -4
- package/containers/ItemsQuoted.js.map +0 -1
- package/containers/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +0 -48
- package/containers/ManageNegotiableQuote/index.d.ts +0 -11
- package/containers/ManageNegotiableQuote.d.ts +0 -3
- package/containers/ManageNegotiableQuote.js +0 -4
- package/containers/ManageNegotiableQuote.js.map +0 -1
- package/data/models/__fixtures__/negotiableQuoteModel.d.ts +0 -4
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export declare const NEGOTIABLE_QUOTE_FRAGMENT = "\n fragment NegotiableQuoteFragment on NegotiableQuote {\n uid\n\
|
|
17
|
+
export declare const NEGOTIABLE_QUOTE_FRAGMENT = "\n fragment NegotiableQuoteFragment on NegotiableQuote {\n uid\n name\n created_at\n updated_at\n status\n buyer {\n firstname\n lastname\n }\n comments {\n uid\n created_at\n author {\n firstname\n lastname\n }\n }\n template_id\n template_name\n items {\n product {\n uid\n sku\n name\n price_range {\n maximum_price {\n regular_price {\n value\n }\n }\n }\n }\n quantity\n }\n prices {\n subtotal_excluding_tax {\n value\n }\n subtotal_including_tax {\n value\n }\n subtotal_with_discount_excluding_tax {\n value\n }\n grand_total {\n value\n currency\n }\n }\n }\n";
|
|
18
18
|
//# sourceMappingURL=NegotiableQuoteFragment.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* Copyright 2025 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
+
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
+
* accompanying it.
|
|
8
|
+
*******************************************************************/
|
|
9
|
+
export declare const SEARCH_RESULT_PAGE_INFO_FRAGMENT = "\n fragment SearchResultPageInfoFragment on SearchResultPageInfo {\n current_page\n page_size\n total_pages\n }\n";
|
|
10
|
+
//# sourceMappingURL=SearchResultPageInfoFragment.d.ts.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export declare const
|
|
10
|
-
//# sourceMappingURL=
|
|
9
|
+
export declare const SORT_FIELDS_FRAGMENT = "\n fragment SortFieldsFragment on SortFields {\n default\n options {\n label\n value\n }\n }\n";
|
|
10
|
+
//# sourceMappingURL=SortFieldsFragment.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Lang } from '@dropins/tools/types/elsie/src/i18n';
|
|
|
3
3
|
|
|
4
4
|
type ConfigProps = {
|
|
5
5
|
langDefinitions?: Lang;
|
|
6
|
-
quoteId?: string;
|
|
7
6
|
};
|
|
8
7
|
export declare const initialize: Initializer<ConfigProps>;
|
|
9
8
|
export declare const config: import('@dropins/tools/types/elsie/src/lib').Config<ConfigProps>;
|
package/{components/ActionsBar/index.d.ts → api/negotiableQuotes/graphql/NegotiableQuotesQuery.d.ts}
RENAMED
|
@@ -6,6 +6,5 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
9
|
+
export declare const NEGOTIABLE_QUOTES_QUERY: string;
|
|
10
|
+
//# sourceMappingURL=NegotiableQuotesQuery.d.ts.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './negotiableQuotes';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NegotiableQuotesListModel } from '../../data/models/negotiable-quote-model';
|
|
2
|
+
|
|
3
|
+
export declare enum FilterMatchTypeEnum {
|
|
4
|
+
FULL = "FULL",
|
|
5
|
+
PARTIAL = "PARTIAL"
|
|
6
|
+
}
|
|
7
|
+
export interface FilterEqualTypeInput {
|
|
8
|
+
eq?: string;
|
|
9
|
+
in?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface FilterMatchTypeInput {
|
|
12
|
+
match?: string;
|
|
13
|
+
match_type?: FilterMatchTypeEnum;
|
|
14
|
+
}
|
|
15
|
+
export interface NegotiableQuoteFilterInput {
|
|
16
|
+
ids?: FilterEqualTypeInput;
|
|
17
|
+
name?: FilterMatchTypeInput;
|
|
18
|
+
}
|
|
19
|
+
export declare enum SortEnum {
|
|
20
|
+
ASC = "ASC",
|
|
21
|
+
DESC = "DESC"
|
|
22
|
+
}
|
|
23
|
+
export declare enum NegotiableQuoteSortableField {
|
|
24
|
+
QUOTE_NAME = "QUOTE_NAME",
|
|
25
|
+
CREATED_AT = "CREATED_AT",
|
|
26
|
+
UPDATED_AT = "UPDATED_AT"
|
|
27
|
+
}
|
|
28
|
+
export interface NegotiableQuoteSortInput {
|
|
29
|
+
sort_direction: SortEnum;
|
|
30
|
+
sort_field: NegotiableQuoteSortableField;
|
|
31
|
+
}
|
|
32
|
+
export interface NegotiableQuotesParams {
|
|
33
|
+
filter?: NegotiableQuoteFilterInput;
|
|
34
|
+
pageSize?: number;
|
|
35
|
+
currentPage?: number;
|
|
36
|
+
sort?: NegotiableQuoteSortInput;
|
|
37
|
+
}
|
|
38
|
+
export declare const negotiableQuotes: (params?: NegotiableQuotesParams) => Promise<NegotiableQuotesListModel>;
|
|
39
|
+
//# sourceMappingURL=negotiableQuotes.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{s as o,D as r}from"./chunks/NegotiableQuoteFragment.js";import{FetchGraphQL as l}from"@dropins/tools/fetch-graphql.js";import{events as i}from"@dropins/tools/event-bus.js";import{r as x}from"./chunks/requestNegotiableQuote.js";import{F as G,N as y,S as b,n as v}from"./chunks/negotiableQuotes.js";import{Initializer as E}from"@dropins/tools/lib.js";const d=`
|
|
4
4
|
fragment CUSTOMER_FRAGMENT on Customer {
|
|
5
5
|
role {
|
|
6
6
|
permissions {
|
|
@@ -17,25 +17,13 @@ import{D as i,s as r,N as l,t as Q}from"./chunks/requestNegotiableQuote.js";impo
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
`,
|
|
20
|
+
`,h=`
|
|
21
21
|
query CUSTOMER_QUERY {
|
|
22
22
|
customer {
|
|
23
23
|
...CUSTOMER_FRAGMENT
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
${
|
|
28
|
-
`,
|
|
29
|
-
query QUOTE_DATA_QUERY(
|
|
30
|
-
$quoteId: ID!
|
|
31
|
-
) {
|
|
32
|
-
negotiableQuote(
|
|
33
|
-
uid: $quoteId
|
|
34
|
-
) {
|
|
35
|
-
...NegotiableQuoteFragment
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
${l}
|
|
40
|
-
`,A=async t=>{var e;if(!r.authenticated)return Promise.reject(new Error("Unauthorized"));if(!r.permissions.editQuote)return Promise.reject(new Error("Unauthorized"));try{const o=await m(O,{variables:{quoteId:t}}),n=Q((e=o==null?void 0:o.data)==null?void 0:e.negotiableQuote);if(!n)throw new Error("Failed to transform quote data");return s.emit("quote-management/quote-data",{quote:n,permissions:r.permissions}),n}catch(o){return Promise.reject(o)}},u=new h({init:async t=>{const e={};u.config.setConfig({...e,...t})},listeners:()=>[s.on("authenticated",async t=>{r.authenticated=!!t,t?C().then(e=>{r.permissions={requestQuote:e.permissions.canRequestQuote,editQuote:e.permissions.canEditQuote,deleteQuote:e.permissions.canDeleteQuote,checkoutQuote:e.permissions.canCheckoutQuote},s.emit("quote-management/permissions",r.permissions)}).catch(e=>{console.error(e),r.permissions=i,s.emit("quote-management/permissions",i)}):(r.permissions=i,s.emit("quote-management/permissions",i))},{eager:!0}),s.on("quote-management/permissions",async t=>{const e=u.config.getConfig().quoteId;e&&t.editQuote&&A(e).then(o=>{s.emit("quote-management/quote-data/initialized",{quote:o,permissions:t},{})}).catch(o=>{console.error(o)})},{eager:!0})]}),M=u.config,{setEndpoint:P,setFetchGraphQlHeader:D,removeFetchGraphQlHeader:F,setFetchGraphQlHeaders:G,fetchGraphQl:m,getConfig:y}=new E().getMethods();export{M as config,m as fetchGraphQl,y as getConfig,C as getCustomerData,A as getQuoteData,u as initialize,F as removeFetchGraphQlHeader,z as requestNegotiableQuote,P as setEndpoint,D as setFetchGraphQlHeader,G as setFetchGraphQlHeaders};
|
|
27
|
+
${d}
|
|
28
|
+
`,p="All/Quotes/View/Request, Edit, Delete",Q="All/Quotes/View/Request, Edit, Delete",f="All/Quotes/View/Request, Edit, Delete",R=t=>{const e=[],s=(u,m=[])=>{for(const n of u){const a=[...m,n.text];n.children&&n.children.length>0?s(n.children,a):e.push(a.join("/"))}};return s(t),e};function g(t){const{role:{permissions:e}}=t,s=R(e);return{permissions:{canRequestQuote:s.includes(p),canEditQuote:s.includes(Q),canDeleteQuote:s.includes(f)}}}const S=async()=>{var t;if(!o.authenticated)return Promise.reject(new Error("Unauthorized"));try{const e=await T(h);if(!((t=e==null?void 0:e.data)!=null&&t.customer))throw new Error("No customer data received");return g(e.data.customer)}catch(e){return Promise.reject(e)}},c=new E({init:async t=>{const e={};c.config.setConfig({...e,...t})},listeners:()=>[i.on("authenticated",async t=>{o.authenticated=!!t,t?S().then(e=>{o.permissions={requestQuote:e.permissions.canRequestQuote,editQuote:e.permissions.canEditQuote,deleteQuote:e.permissions.canDeleteQuote},i.emit("quote-management/permissions",o.permissions)}).catch(e=>{console.error(e),o.permissions=r,i.emit("quote-management/permissions",r)}):(o.permissions=r,i.emit("quote-management/permissions",r))},{eager:!0})]}),U=c.config,{setEndpoint:O,setFetchGraphQlHeader:q,removeFetchGraphQlHeader:F,setFetchGraphQlHeaders:A,fetchGraphQl:T,getConfig:I}=new l().getMethods();export{G as FilterMatchTypeEnum,y as NegotiableQuoteSortableField,b as SortEnum,U as config,T as fetchGraphQl,I as getConfig,S as getCustomerData,c as initialize,v as negotiableQuotes,F as removeFetchGraphQlHeader,x as requestNegotiableQuote,O as setEndpoint,q as setFetchGraphQlHeader,A as setFetchGraphQlHeaders};
|
|
41
29
|
//# sourceMappingURL=api.js.map
|
package/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/CustomerFragment.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/graphql/CustomerQuery.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-customer.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/graphql/QuoteDataQuery.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/getQuoteData.ts","/@dropins/storefront-quote-management/src/api/initialize/initialize.ts","/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.ts"],"sourcesContent":["export const CUSTOMER_FRAGMENT = /* GraphQL */ `\n fragment CUSTOMER_FRAGMENT on Customer {\n role {\n permissions {\n text\n children {\n text\n children {\n text\n children {\n text\n }\n }\n }\n }\n }\n }\n`","import { CUSTOMER_FRAGMENT } from '@/quote-management/api/graphql/CustomerFragment';\n\nexport const CUSTOMER_QUERY = `\n query CUSTOMER_QUERY {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { DEFAULT_PERMISSIONS } from \"@/quote-management/lib/state\";\nimport { CustomerModel } from \"../models\";\n\ntype PermissionsSchema = {\n text: string;\n children: PermissionsSchema[];\n}\n\nconst CAN_REQUEST_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_EDIT_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_DELETE_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_CHECKOUT_QUOTE_PERMISSION = 'All/Quotes/View/Checkout with quote';\n\n/**\n * Flatten the permissions into a list of strings\n * @param permissions - The permissions to flatten\n * @returns A list of strings representing the flattened permissions\n */\nexport const flattenPermissions = (permissions: PermissionsSchema[]): string[] => {\n const result: string[] = [];\n \n // Recursively traverse the permissions and build the path\n const traverse = (nodes: PermissionsSchema[], path: string[] = []) => {\n for (const node of nodes) {\n const currentPath = [...path, node.text];\n \n if (node.children && node.children.length > 0) {\n traverse(node.children, currentPath);\n } else {\n result.push(currentPath.join('/'));\n }\n }\n };\n \n traverse(permissions);\n return result;\n}\n\nexport function transformCustomer(customerData: any): CustomerModel {\n const { role } = customerData;\n\n if (!role) {\n return {\n permissions: {\n canRequestQuote: DEFAULT_PERMISSIONS.requestQuote,\n canEditQuote: DEFAULT_PERMISSIONS.editQuote,\n canDeleteQuote: DEFAULT_PERMISSIONS.deleteQuote,\n },\n };\n }\n\n const { permissions } = role;\n\n const flattenedPermissions = flattenPermissions(permissions);\n return {\n permissions: {\n canRequestQuote: flattenedPermissions.includes(CAN_REQUEST_QUOTE_PERMISSION),\n canEditQuote: flattenedPermissions.includes(CAN_EDIT_QUOTE_PERMISSION),\n canDeleteQuote: flattenedPermissions.includes(CAN_DELETE_QUOTE_PERMISSION),\n canCheckoutQuote: flattenedPermissions.includes(CAN_CHECKOUT_QUOTE_PERMISSION),\n }\n }\n}","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { CUSTOMER_QUERY } from './graphql/CustomerQuery';\nimport { transformCustomer } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport const getCustomerData = async () => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(CUSTOMER_QUERY);\n \n if (!results?.data?.customer) {\n throw new Error('No customer data received');\n }\n \n return transformCustomer(results.data.customer);\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const QUOTE_DATA_QUERY = `\n query QUOTE_DATA_QUERY(\n $quoteId: ID!\n ) {\n negotiableQuote(\n uid: $quoteId\n ) {\n ...NegotiableQuoteFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { QUOTE_DATA_QUERY } from './graphql/QuoteDataQuery';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteData = async (quoteId: string) => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n if (!state.permissions.editQuote) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_DATA_QUERY, {\n variables: {\n quoteId\n }\n });\n\n const transformedQuote = transformQuote(results?.data?.negotiableQuote);\n\n if (!transformedQuote) {\n throw new Error('Failed to transform quote data');\n }\n\n events.emit('quote-management/quote-data', {\n quote: transformedQuote,\n permissions: state.permissions,\n });\n \n return transformedQuote;\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state, DEFAULT_PERMISSIONS } from '@/quote-management/lib/state';\nimport { getCustomerData } from '@/quote-management/api/getCustomerData';\nimport { getQuoteData } from '@/quote-management/api/getQuoteData';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n quoteId?: string;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {};\n\n initialize.config.setConfig({ ...defaultConfig, ...config });\n },\n\n listeners: () => [\n events.on('authenticated', async (authenticated) => {\n state.authenticated = !!authenticated;\n\n if (authenticated) {\n getCustomerData().then((customerData) => {\n state.permissions = {\n requestQuote: customerData.permissions.canRequestQuote,\n editQuote: customerData.permissions.canEditQuote,\n deleteQuote: customerData.permissions.canDeleteQuote,\n checkoutQuote: customerData.permissions.canCheckoutQuote,\n };\n events.emit('quote-management/permissions', state.permissions);\n })\n .catch((error) => {\n console.error(error);\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n });\n } else {\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n }\n }, {\n eager: true,\n }),\n events.on('quote-management/permissions', async (permissions) => {\n const quoteId = initialize.config.getConfig().quoteId;\n if (!quoteId) {\n return;\n }\n\n if (permissions.editQuote) {\n getQuoteData(quoteId).then((quoteData) => {\n events.emit('quote-management/quote-data/initialized', {\n quote: quoteData,\n permissions,\n }, {});\n }).catch((error) => {\n console.error(error);\n });\n }\n }, {\n eager: true,\n }),\n ],\n});\n\nexport const config = initialize.config;\n","import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n"],"names":["CUSTOMER_FRAGMENT","CUSTOMER_QUERY","CAN_REQUEST_QUOTE_PERMISSION","CAN_EDIT_QUOTE_PERMISSION","CAN_DELETE_QUOTE_PERMISSION","CAN_CHECKOUT_QUOTE_PERMISSION","flattenPermissions","permissions","result","traverse","nodes","path","node","currentPath","transformCustomer","customerData","role","DEFAULT_PERMISSIONS","flattenedPermissions","getCustomerData","state","results","fetchGraphQl","_a","error","QUOTE_DATA_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","getQuoteData","quoteId","transformedQuote","transformQuote","events","initialize","Initializer","config","defaultConfig","authenticated","quoteData","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getConfig","FetchGraphQL"],"mappings":"2SAA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CgB,EAAO,KAAK,+BAAgCX,EAAM,WAAW,CAC/D,CAAC,EACE,MAAOI,GAAU,CAChB,QAAQ,MAAMA,CAAK,EACnBJ,EAAM,YAAcH,EACpBc,EAAO,KAAK,+BAAgCd,CAAmB,CACjE,CAAC,GAEHG,EAAM,YAAcH,EACpBc,EAAO,KAAK,+BAAgCd,CAAmB,EAEnE,EAAG,CACD,MAAO,EAAA,CACR,EACDc,EAAO,GAAG,+BAAgC,MAAOxB,GAAgB,CAC/D,MAAMqB,EAAUI,EAAW,OAAO,UAAA,EAAY,QACzCJ,GAIDrB,EAAY,WACdoB,EAAaC,CAAO,EAAE,KAAMS,GAAc,CACxCN,EAAO,KAAK,0CAA2C,CACrD,MAAOM,EACP,YAAA9B,CAAA,EACC,EAAE,CACP,CAAC,EAAE,MAAOiB,GAAU,CAClB,QAAQ,MAAMA,CAAK,CACrB,CAAC,CAEL,EAAG,CACD,MAAO,EAAA,CACR,CAAA,CAEL,CAAC,EAEYU,EAASF,EAAW,OCjEpB,CACX,YAAAM,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAnB,EACA,UAAAoB,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA"}
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/CustomerFragment.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/graphql/CustomerQuery.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-customer.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-quote-management/src/api/initialize/initialize.ts","/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.ts"],"sourcesContent":["export const CUSTOMER_FRAGMENT = /* GraphQL */ `\n fragment CUSTOMER_FRAGMENT on Customer {\n role {\n permissions {\n text\n children {\n text\n children {\n text\n children {\n text\n }\n }\n }\n }\n }\n }\n`","import { CUSTOMER_FRAGMENT } from '@/quote-management/api/graphql/CustomerFragment';\n\nexport const CUSTOMER_QUERY = `\n query CUSTOMER_QUERY {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { CustomerModel } from \"../models\";\n\ntype PermissionsSchema = {\n text: string;\n children: PermissionsSchema[];\n}\n\nconst CAN_REQUEST_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_EDIT_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_DELETE_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\n\n/**\n * Flatten the permissions into a list of strings\n * @param permissions - The permissions to flatten\n * @returns A list of strings representing the flattened permissions\n */\nexport const flattenPermissions = (permissions: PermissionsSchema[]): string[] => {\n const result: string[] = [];\n \n // Recursively traverse the permissions and build the path\n const traverse = (nodes: PermissionsSchema[], path: string[] = []) => {\n for (const node of nodes) {\n const currentPath = [...path, node.text];\n \n if (node.children && node.children.length > 0) {\n traverse(node.children, currentPath);\n } else {\n result.push(currentPath.join('/'));\n }\n }\n };\n \n traverse(permissions);\n return result;\n}\n\nexport function transformCustomer(customerData: any): CustomerModel {\n const { role: { permissions } } = customerData;\n const flattenedPermissions = flattenPermissions(permissions);\n return {\n permissions: {\n canRequestQuote: flattenedPermissions.includes(CAN_REQUEST_QUOTE_PERMISSION),\n canEditQuote: flattenedPermissions.includes(CAN_EDIT_QUOTE_PERMISSION),\n canDeleteQuote: flattenedPermissions.includes(CAN_DELETE_QUOTE_PERMISSION),\n }\n }\n}","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { CUSTOMER_QUERY } from './graphql/CustomerQuery';\nimport { transformCustomer } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport const getCustomerData = async () => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(CUSTOMER_QUERY);\n \n if (!results?.data?.customer) {\n throw new Error('No customer data received');\n }\n \n return transformCustomer(results.data.customer);\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state, DEFAULT_PERMISSIONS } from '@/quote-management/lib/state';\nimport { getCustomerData } from '@/quote-management/api/getCustomerData';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {};\n\n initialize.config.setConfig({ ...defaultConfig, ...config });\n },\n\n listeners: () => [\n events.on('authenticated', async (authenticated) => {\n state.authenticated = !!authenticated;\n\n if (authenticated) {\n getCustomerData().then((customerData) => {\n state.permissions = {\n requestQuote: customerData.permissions.canRequestQuote,\n editQuote: customerData.permissions.canEditQuote,\n deleteQuote: customerData.permissions.canDeleteQuote,\n };\n events.emit('quote-management/permissions', state.permissions);\n })\n .catch((error) => {\n console.error(error);\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n });\n } else {\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n }\n }, {\n eager: true,\n }),\n ],\n});\n\nexport const config = initialize.config;\n","import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n"],"names":["CUSTOMER_FRAGMENT","CUSTOMER_QUERY","CAN_REQUEST_QUOTE_PERMISSION","CAN_EDIT_QUOTE_PERMISSION","CAN_DELETE_QUOTE_PERMISSION","flattenPermissions","permissions","result","traverse","nodes","path","node","currentPath","transformCustomer","customerData","flattenedPermissions","getCustomerData","state","results","fetchGraphQl","_a","error","initialize","Initializer","config","defaultConfig","events","authenticated","DEFAULT_PERMISSIONS","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getConfig","FetchGraphQL"],"mappings":"oWAAO,MAAMA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECElCC,EAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOxBD,CAAiB;AAAA,ECOjBE,EAA+B,wCAC/BC,EAA4B,wCAC5BC,EAA8B,wCAOvBC,EAAsBC,GAA+C,CAC9E,MAAMC,EAAmB,CAAA,EAGnBC,EAAW,CAACC,EAA4BC,EAAiB,CAAA,IAAO,CAClE,UAAWC,KAAQF,EAAO,CACtB,MAAMG,EAAc,CAAC,GAAGF,EAAMC,EAAK,IAAI,EAEnCA,EAAK,UAAYA,EAAK,SAAS,OAAS,EACxCH,EAASG,EAAK,SAAUC,CAAW,EAEnCL,EAAO,KAAKK,EAAY,KAAK,GAAG,CAAC,CAEzC,CACJ,EAEA,OAAAJ,EAASF,CAAW,EACbC,CACX,EAEO,SAASM,EAAkBC,EAAkC,CAChE,KAAM,CAAE,KAAM,CAAE,YAAAR,CAAA,GAAkBQ,EAC5BC,EAAuBV,EAAmBC,CAAW,EAC3D,MAAO,CACH,YAAa,CACT,gBAAiBS,EAAqB,SAASb,CAA4B,EAC3E,aAAca,EAAqB,SAASZ,CAAyB,EACrE,eAAgBY,EAAqB,SAASX,CAA2B,CAAA,CAC7E,CAER,CCzCO,MAAMY,EAAkB,SAAY,OACvC,GAAI,CA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uote:!1,deleteQuote:!1},o={authenticated:!1,permissions:l},p=new Proxy(o,{get:(t,a)=>t[a],set:(t,a,n)=>(t[a]=n,!0)});function i(t){var a,n;return{uid:t.uid,name:t.name,createdAt:t.created_at,updatedAt:t.updated_at,status:t.status,buyer:{firstname:t.buyer.firstname,lastname:t.buyer.lastname},comments:(a=t.comments)==null?void 0:a.map(e=>({uid:e.uid,createdAt:e.created_at,author:{firstname:e.author.firstname,lastname:e.author.lastname}})),items:(n=t.items)==null?void 0:n.map(e=>({product:{uid:e.product.uid,sku:e.product.sku,name:e.product.name,templateId:e.product.template_id,templateName:e.product.template_name,priceRange:{maximumPrice:{regularPrice:{value:e.product.price_range.maximum_price.regular_price.value}}}},quantity:e.quantity,prices:{subtotalExcludingTax:{value:t.prices.subtotal_excluding_tax.value},subtotalIncludingTax:{value:t.prices.subtotal_including_tax.value},subtotalWithDiscountExcludingTax:{value:t.prices.subtotal_with_discount_excluding_tax.value},grandTotal:{value:t.prices.grand_total.value,currency:t.prices.grand_total.currency}}}))}}function g(t){if(!t||!t.data||!t.data.requestNegotiableQuote)return null;const a=t.data.requestNegotiableQuote.quote;return i(a)}function m(t){var e;if(!t)return null;const a={items:((e=t.items)==null?void 0:e.filter(r=>r==null?void 0:r.uid).map(i))||[],pageInfo:{currentPage:t.page_info.current_page,pageSize:t.page_info.page_size,totalPages:t.page_info.total_pages},totalCount:t.total_count,sortFields:t.sort_fields?{default:t.sort_fields.default,options:t.sort_fields.options}:void 0},n=c(a);return{...a,paginationInfo:n||void 0}}function c(t){if(!(t!=null&&t.pageInfo)||!t.totalCount)return null;const{currentPage:a,pageSize:n,totalPages:e}=t.pageInfo,{totalCount:r}=t,s=r>0?(a-1)*n+1:0,u=Math.min(a*n,r);return{currentPage:a,totalCount:r,pageSize:n,startItem:s,endItem:u,totalPages:e,pageSizeOptions:[20,30,50,100,200]}}const _=()=>[20,30,50,100,200],f=`
|
|
4
|
+
fragment NegotiableQuoteFragment on NegotiableQuote {
|
|
5
|
+
uid
|
|
6
|
+
name
|
|
7
|
+
created_at
|
|
8
|
+
updated_at
|
|
9
|
+
status
|
|
10
|
+
buyer {
|
|
11
|
+
firstname
|
|
12
|
+
lastname
|
|
13
|
+
}
|
|
14
|
+
comments {
|
|
15
|
+
uid
|
|
16
|
+
created_at
|
|
17
|
+
author {
|
|
18
|
+
firstname
|
|
19
|
+
lastname
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
template_id
|
|
23
|
+
template_name
|
|
24
|
+
items {
|
|
25
|
+
product {
|
|
26
|
+
uid
|
|
27
|
+
sku
|
|
28
|
+
name
|
|
29
|
+
price_range {
|
|
30
|
+
maximum_price {
|
|
31
|
+
regular_price {
|
|
32
|
+
value
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
quantity
|
|
38
|
+
}
|
|
39
|
+
prices {
|
|
40
|
+
subtotal_excluding_tax {
|
|
41
|
+
value
|
|
42
|
+
}
|
|
43
|
+
subtotal_including_tax {
|
|
44
|
+
value
|
|
45
|
+
}
|
|
46
|
+
subtotal_with_discount_excluding_tax {
|
|
47
|
+
value
|
|
48
|
+
}
|
|
49
|
+
grand_total {
|
|
50
|
+
value
|
|
51
|
+
currency
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;export{l as D,f as N,m as a,_ as g,p as s,g as t};
|
|
56
|
+
//# sourceMappingURL=NegotiableQuoteFragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NegotiableQuoteFragment.js","sources":["/@dropins/storefront-quote-management/src/lib/state.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote.ts","/@dropins/storefront-quote-management/src/api/graphql/NegotiableQuoteFragment.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { State } from '../types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n}\n\n// Proxy state to make it reactive\nexport const state = new Proxy(_state, {\n get: (target, key) => {\n return target[key as keyof State];\n },\n set: (target, key, value) => {\n target[key as keyof State] = value;\n return true;\n }\n})","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 NegotiableQuoteModel,\n NegotiableQuotesListModel,\n PaginationInfo,\n} from '@/quote-management/data/models/negotiable-quote-model';\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n status: quote.status,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n comments: quote.comments?.map((comment: any) => ({\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n })),\n items: quote.items?.map((item: any) => ({\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n templateId: item.product.template_id,\n templateName: item.product.template_name,\n priceRange: {\n maximumPrice: {\n regularPrice: {\n value: item.product.price_range.maximum_price.regular_price.value,\n },\n },\n },\n },\n quantity: item.quantity,\n prices: {\n subtotalExcludingTax: {\n value: quote.prices.subtotal_excluding_tax.value,\n },\n subtotalIncludingTax: {\n value: quote.prices.subtotal_including_tax.value,\n },\n subtotalWithDiscountExcludingTax: {\n value: quote.prices.subtotal_with_discount_excluding_tax.value,\n },\n grandTotal: {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n },\n })),\n };\n}\n\nexport function transformQuote(quoteData: any): NegotiableQuoteModel | null {\n if (!quoteData || !quoteData.data || !quoteData.data.requestNegotiableQuote) {\n return null;\n }\n\n const quote = quoteData.data.requestNegotiableQuote.quote;\n return transformSingleQuote(quote);\n}\n\nexport function transformNegotiableQuotesList(\n quotesData: any\n): NegotiableQuotesListModel | null {\n if (!quotesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n quotesData.items\n ?.filter((quote: any) => quote?.uid)\n .map(transformSingleQuote) || [],\n pageInfo: {\n currentPage: quotesData.page_info.current_page,\n pageSize: quotesData.page_info.page_size,\n totalPages: quotesData.page_info.total_pages,\n },\n totalCount: quotesData.total_count,\n sortFields: quotesData.sort_fields\n ? {\n default: quotesData.sort_fields.default,\n options: quotesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n\nexport function transformPaginationInfo(\n quotesData: NegotiableQuotesListModel | null\n): PaginationInfo | null {\n if (!quotesData?.pageInfo || !quotesData.totalCount) {\n return null;\n }\n\n const { currentPage, pageSize, totalPages } = quotesData.pageInfo;\n const { totalCount } = quotesData;\n\n const startItem = totalCount > 0 ? (currentPage - 1) * pageSize + 1 : 0;\n const endItem = Math.min(currentPage * pageSize, totalCount);\n\n const pageSizeOptions = [20, 30, 50, 100, 200]; // Default page size options\n\n return {\n currentPage,\n totalCount,\n pageSize,\n startItem,\n endItem,\n totalPages,\n pageSizeOptions,\n };\n}\n\n// TODO: Check if admin has this configuration\nexport const getDefaultPageSizeOptions = () => [20, 30, 50, 100, 200];\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 NEGOTIABLE_QUOTE_FRAGMENT = /* GraphQL */ `\n fragment NegotiableQuoteFragment on NegotiableQuote {\n uid\n name\n created_at\n updated_at\n status\n buyer {\n firstname\n lastname\n }\n comments {\n uid\n created_at\n author {\n firstname\n lastname\n }\n }\n template_id\n template_name\n items {\n product {\n uid\n sku\n name\n price_range {\n maximum_price {\n regular_price {\n value\n }\n }\n }\n }\n quantity\n }\n prices {\n subtotal_excluding_tax {\n value\n }\n subtotal_including_tax {\n value\n }\n subtotal_with_discount_excluding_tax {\n value\n }\n grand_total {\n value\n currency\n }\n }\n }\n`;\n"],"names":["DEFAULT_PERMISSIONS","_state","state","target","key","value","transformSingleQuote","quote","_a","_b","comment","item","transformQuote","quoteData","transformNegotiableQuotesList","quotesData","transformedModel","paginationInfo","transformPaginationInfo","currentPage","pageSize","totalPages","totalCount","startItem","endItem","getDefaultPageSizeOptions","NEGOTIABLE_QUOTE_FRAGMENT"],"mappings":"AAWO,MAAMA,EAAsB,CAC/B,aAAc,GACd,UAAW,GACX,YAAa,EACjB,EAEMC,EAAgB,CAClB,cAAe,GACf,YAAaD,CACjB,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACnC,IAAK,CAACE,EAAQC,IACHD,EAAOC,CAAkB,EAEpC,IAAK,CAACD,EAAQC,EAAKC,KACfF,EAAOC,CAAkB,EAAIC,EACtB,GAEf,CAAC,ECRD,SAASC,EAAqBC,EAAkC,CDZzD,IAAAC,EAAAC,ECaL,MAAO,CACL,IAAKF,EAAM,IACX,KAAMA,EAAM,KACZ,UAAWA,EAAM,WACjB,UAAWA,EAAM,WACjB,OAAQA,EAAM,OACd,MA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-graphql.js";import{N as s,s as i,a as g}from"./NegotiableQuoteFragment.js";const u=`
|
|
4
|
+
fragment SearchResultPageInfoFragment on SearchResultPageInfo {
|
|
5
|
+
current_page
|
|
6
|
+
page_size
|
|
7
|
+
total_pages
|
|
8
|
+
}
|
|
9
|
+
`,l=`
|
|
10
|
+
fragment SortFieldsFragment on SortFields {
|
|
11
|
+
default
|
|
12
|
+
options {
|
|
13
|
+
label
|
|
14
|
+
value
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`,E=`
|
|
18
|
+
query negotiableQuotes(
|
|
19
|
+
$filter: NegotiableQuoteFilterInput
|
|
20
|
+
$pageSize: Int
|
|
21
|
+
$currentPage: Int
|
|
22
|
+
$sort: NegotiableQuoteSortInput
|
|
23
|
+
) {
|
|
24
|
+
negotiableQuotes(
|
|
25
|
+
filter: $filter
|
|
26
|
+
pageSize: $pageSize
|
|
27
|
+
currentPage: $currentPage
|
|
28
|
+
sort: $sort
|
|
29
|
+
) {
|
|
30
|
+
items {
|
|
31
|
+
...NegotiableQuoteFragment
|
|
32
|
+
}
|
|
33
|
+
page_info {
|
|
34
|
+
...SearchResultPageInfoFragment
|
|
35
|
+
}
|
|
36
|
+
sort_fields {
|
|
37
|
+
...SortFieldsFragment
|
|
38
|
+
}
|
|
39
|
+
total_count
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
${s}
|
|
44
|
+
${u}
|
|
45
|
+
${l}
|
|
46
|
+
`;var c=(e=>(e.FULL="FULL",e.PARTIAL="PARTIAL",e))(c||{}),A=(e=>(e.ASC="ASC",e.DESC="DESC",e))(A||{}),f=(e=>(e.QUOTE_NAME="QUOTE_NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(f||{});const S=async(e={})=>{var r;if(!i.authenticated)return Promise.reject(new Error("Unauthorized"));const o={filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null};try{const t=await n(E,{variables:o});if(!((r=t==null?void 0:t.data)!=null&&r.negotiableQuotes))throw new Error("No quotes data received");const a=g(t.data.negotiableQuotes);if(!a)throw new Error("Failed to transform quotes data");return a}catch(t){return Promise.reject(t)}};export{c as F,f as N,A as S,S as n};
|
|
47
|
+
//# sourceMappingURL=negotiableQuotes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiableQuotes.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/SearchResultPageInfoFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SortFieldsFragment.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/graphql/NegotiableQuotesQuery.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/negotiableQuotes.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const SEARCH_RESULT_PAGE_INFO_FRAGMENT = /* GraphQL */ `\n fragment SearchResultPageInfoFragment on SearchResultPageInfo {\n current_page\n page_size\n total_pages\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const SORT_FIELDS_FRAGMENT = /* GraphQL */ `\n fragment SortFieldsFragment on SortFields {\n default\n options {\n label\n value\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\nimport { SEARCH_RESULT_PAGE_INFO_FRAGMENT } from '@/quote-management/api/graphql/SearchResultPageInfoFragment';\nimport { SORT_FIELDS_FRAGMENT } from '@/quote-management/api/graphql/SortFieldsFragment';\n\nexport const NEGOTIABLE_QUOTES_QUERY = /* GraphQL */ `\n query negotiableQuotes(\n $filter: NegotiableQuoteFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteSortInput\n ) {\n negotiableQuotes(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n ...NegotiableQuoteFragment\n }\n page_info {\n ...SearchResultPageInfoFragment\n }\n sort_fields {\n ...SortFieldsFragment\n }\n total_count\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n ${SEARCH_RESULT_PAGE_INFO_FRAGMENT}\n ${SORT_FIELDS_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@adobe-commerce/fetch-graphql';\nimport { NEGOTIABLE_QUOTES_QUERY } from './graphql/NegotiableQuotesQuery';\nimport { transformNegotiableQuotesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuotesListModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\nexport enum FilterMatchTypeEnum {\n FULL = 'FULL',\n PARTIAL = 'PARTIAL',\n}\n\nexport interface FilterEqualTypeInput {\n eq?: string;\n in?: string[];\n}\n\nexport interface FilterMatchTypeInput {\n match?: string;\n match_type?: FilterMatchTypeEnum;\n}\n\nexport interface NegotiableQuoteFilterInput {\n ids?: FilterEqualTypeInput;\n name?: FilterMatchTypeInput;\n}\n\nexport enum SortEnum {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport enum NegotiableQuoteSortableField {\n QUOTE_NAME = 'QUOTE_NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport interface NegotiableQuoteSortInput {\n sort_direction: SortEnum;\n sort_field: NegotiableQuoteSortableField;\n}\n\nexport interface NegotiableQuotesParams {\n filter?: NegotiableQuoteFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: NegotiableQuoteSortInput;\n}\n\nexport const negotiableQuotes = async (\n params: NegotiableQuotesParams = {}\n): Promise<NegotiableQuotesListModel> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const variables = {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n };\n\n try {\n const results: any = await fetchGraphQl(NEGOTIABLE_QUOTES_QUERY, {\n variables,\n });\n\n if (!results?.data?.negotiableQuotes) {\n throw new Error('No quotes data received');\n }\n\n const transformedData = transformNegotiableQuotesList(\n results.data.negotiableQuotes\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quotes data');\n }\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["SEARCH_RESULT_PAGE_INFO_FRAGMENT","SORT_FIELDS_FRAGMENT","NEGOTIABLE_QUOTES_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","FilterMatchTypeEnum","SortEnum","NegotiableQuoteSortableField","negotiableQuotes","params","state","variables","results","fetchGraphQl","_a","transformedData","transformNegotiableQuotesList","error"],"mappings":"8HASO,MAAMA,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECAjDC,EAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECIrCC,EAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA0BjDC,CAAyB;AAAA,IACzBH,CAAgC;AAAA,IAChCC,CAAoB;AAAA,EC1BjB,IAAKG,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UAFAA,IAAAA,GAAA,CAAA,CAAA,EAoBAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAkBL,MAAMC,EAAmB,MAC9BC,EAAiC,KACM,OACvC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,MAAMC,EAAY,CAChB,OAAQF,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,EAGvB,GAAI,CACF,MAAMG,EAAe,MAAMC,EAAaV,EAAyB,CAC/D,UAAAQ,CAAA,CACD,EAED,GAAI,GAACG,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,kBAClB,MAAM,IAAI,MAAM,yBAAyB,EAG3C,MAAMC,EAAkBC,EACtBJ,EAAQ,KAAK,gBAAA,EAGf,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
@@ -1,114 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{fetchGraphQl as
|
|
4
|
-
fragment NegotiableQuoteFragment on NegotiableQuote {
|
|
5
|
-
uid
|
|
6
|
-
name
|
|
7
|
-
created_at
|
|
8
|
-
status
|
|
9
|
-
buyer {
|
|
10
|
-
firstname
|
|
11
|
-
lastname
|
|
12
|
-
}
|
|
13
|
-
comments {
|
|
14
|
-
uid
|
|
15
|
-
created_at
|
|
16
|
-
author {
|
|
17
|
-
firstname
|
|
18
|
-
lastname
|
|
19
|
-
}
|
|
20
|
-
text
|
|
21
|
-
}
|
|
22
|
-
items {
|
|
23
|
-
product {
|
|
24
|
-
name
|
|
25
|
-
sku
|
|
26
|
-
uid
|
|
27
|
-
stock_status
|
|
28
|
-
quantity
|
|
29
|
-
price_range {
|
|
30
|
-
maximum_price {
|
|
31
|
-
regular_price {
|
|
32
|
-
value
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
prices {
|
|
38
|
-
price {
|
|
39
|
-
currency
|
|
40
|
-
value
|
|
41
|
-
}
|
|
42
|
-
original_item_price {
|
|
43
|
-
currency
|
|
44
|
-
value
|
|
45
|
-
}
|
|
46
|
-
original_row_total {
|
|
47
|
-
currency
|
|
48
|
-
value
|
|
49
|
-
}
|
|
50
|
-
row_total {
|
|
51
|
-
currency
|
|
52
|
-
value
|
|
53
|
-
}
|
|
54
|
-
catalog_discount {
|
|
55
|
-
amount_off
|
|
56
|
-
percent_off
|
|
57
|
-
}
|
|
58
|
-
discounts {
|
|
59
|
-
label
|
|
60
|
-
value
|
|
61
|
-
amount {
|
|
62
|
-
currency
|
|
63
|
-
value
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
quantity
|
|
68
|
-
}
|
|
69
|
-
history {
|
|
70
|
-
uid
|
|
71
|
-
created_at
|
|
72
|
-
author {
|
|
73
|
-
firstname
|
|
74
|
-
lastname
|
|
75
|
-
}
|
|
76
|
-
change_type
|
|
77
|
-
changes {
|
|
78
|
-
comment_added {
|
|
79
|
-
comment
|
|
80
|
-
}
|
|
81
|
-
statuses {
|
|
82
|
-
changes {
|
|
83
|
-
new_status
|
|
84
|
-
old_status
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
expiration {
|
|
88
|
-
new_expiration
|
|
89
|
-
old_expiration
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
prices {
|
|
94
|
-
subtotal_excluding_tax {
|
|
95
|
-
currency
|
|
96
|
-
value
|
|
97
|
-
}
|
|
98
|
-
applied_taxes {
|
|
99
|
-
amount {
|
|
100
|
-
currency
|
|
101
|
-
value
|
|
102
|
-
}
|
|
103
|
-
label
|
|
104
|
-
}
|
|
105
|
-
grand_total {
|
|
106
|
-
currency
|
|
107
|
-
value
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`,v=`
|
|
3
|
+
import{fetchGraphQl as E}from"@dropins/tools/fetch-graphql.js";import{events as c}from"@dropins/tools/event-bus.js";import{N as q,t as f}from"./NegotiableQuoteFragment.js";const N=`
|
|
112
4
|
mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(
|
|
113
5
|
$cartId: ID!
|
|
114
6
|
$quoteName: String!
|
|
@@ -128,6 +20,6 @@ import{fetchGraphQl as _}from"@dropins/tools/fetch-graphql.js";import{events as
|
|
|
128
20
|
}
|
|
129
21
|
}
|
|
130
22
|
}
|
|
131
|
-
${
|
|
132
|
-
`,
|
|
23
|
+
${q}
|
|
24
|
+
`,I=async m=>{const{cartId:e,quoteName:t,comment:r,isDraft:a}=m;if(!e)throw new Error("Cart ID is required");if(!t)throw new Error("Quote name is required");if(!r)throw new Error("Comment is required");return E(N,{variables:{cartId:e,quoteName:t,comment:{comment:r},isDraft:a}}).then(n=>{const{errors:i}=n;if(i){const s=i.map(u=>u.message).join("; ");throw new Error(`Failed to request negotiable quote: ${s}`)}const o=f(n);if(!o)throw new Error("Failed to transform quote data: Invalid response structure");return c.emit("quote-management/negotiable-quote-requested",{quote:o,input:{cartId:e,quoteName:t,comment:r,isDraft:a}}),o})};export{I as r};
|
|
133
25
|
//# sourceMappingURL=requestNegotiableQuote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestNegotiableQuote.js","sources":["/@dropins/storefront-quote-management/src/lib/state.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote.ts","/@dropins/storefront-quote-management/src/api/graphql/NegotiableQuoteFragment.ts","/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/graphql/RequestNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/requestNegotiableQuote.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { State } from '../types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n}\n\n// Proxy state to make it reactive\nexport const state = new Proxy(_state, {\n get: (target, key) => {\n return target[key as keyof State];\n },\n set: (target, key, value) => {\n target[key as keyof State] = value;\n return true;\n }\n})","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\nexport function transformQuote(quoteData: any): NegotiableQuoteModel | null {\n if (!quoteData) return null;\n\n return {\n uid: quoteData.uid,\n name: quoteData.name,\n createdAt: quoteData.created_at,\n status: quoteData.status,\n buyer: quoteData.buyer,\n comments: quoteData.comments.map((comment: any) => ({\n uid: comment.uid,\n createdAt: comment.created_at,\n author: comment.author,\n })),\n items: quoteData.items.map((item: any) => ({\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\n catalogDiscount: {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts: item.prices?.discounts?.map((discount: any) => ({\n label: discount.label,\n value: discount.value,\n amount: { value: discount.amount.value, currency: discount.amount.currency },\n })) ?? [],\n stockStatus: item.product.stock_status,\n quantity: item.quantity,\n prices: {\n originalItemPrice: {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n },\n rowTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n },\n })),\n prices: {\n grandTotal: {\n value: quoteData.prices.grand_total.value,\n currency: quoteData.prices.grand_total.currency,\n },\n subtotalExcludingTax: {\n value: quoteData.prices.subtotal_excluding_tax.value,\n currency: quoteData.prices.subtotal_excluding_tax.currency,\n },\n appliedTaxes: quoteData.prices.applied_taxes.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n },\n canCheckout: ['UPDATED', 'DECLINED'].includes(quoteData.status) && state.permissions.checkoutQuote,\n canSendForReview: ['SUBMITTED', 'DRAFT', 'UPDATED', 'DECLINED','EXPIRED'].includes(quoteData.status) && state.permissions.editQuote,\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 NEGOTIABLE_QUOTE_FRAGMENT = /* GraphQL */ `\n fragment NegotiableQuoteFragment on NegotiableQuote {\n uid\n\t\tname\n\t\tcreated_at\n status\n\t\tbuyer {\n\t\t\tfirstname\n\t\t\tlastname\n\t\t}\n\t\tcomments {\n uid\n created_at\n author {\n firstname\n lastname\n }\n text\n }\n\t\titems {\n product {\n name\n sku\n uid\n\t\t\t\tstock_status\n\t\t\t\tquantity\n price_range {\n maximum_price {\n regular_price {\n value\n }\n }\n }\n }\n\t\t\tprices {\n\t\t\t\tprice {\n\t\t\t\t\tcurrency\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t\toriginal_item_price {\n\t\t\t\t\tcurrency\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t\toriginal_row_total {\n\t\t\t\t\tcurrency\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t\trow_total {\n\t\t\t\t\tcurrency\n\t\t\t\t\tvalue\n\t\t\t\t}\n catalog_discount {\n\t\t\t\t\tamount_off\n\t\t\t\t\tpercent_off\n\t\t\t\t}\n\t\t\t\tdiscounts {\n\t\t\t\t\tlabel\n\t\t\t\t\tvalue\n\t\t\t\t\tamount {\n\t\t\t\t\t\tcurrency\n\t\t\t\t\t\tvalue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n quantity\n }\n history {\n uid\n created_at\n author {\n firstname\n lastname\n }\n change_type\n changes {\n comment_added {\n comment\n }\n statuses {\n changes {\n new_status\n old_status\n }\n }\n expiration {\n new_expiration\n old_expiration\n }\n }\n\t }\n prices {\n subtotal_excluding_tax {\n\t\t\t\tcurrency\n\t\t\t\tvalue\n\t\t\t}\n\t\t\tapplied_taxes {\n\t\t\t\tamount {\n\t\t\t\t\tcurrency\n\t\t\t\t\tvalue\n\t\t\t\t}\n\t\t\t\tlabel\n\t\t\t}\n\t\t\tgrand_total {\n\t\t\t\tcurrency\n\t\t\t\tvalue\n\t\t\t}\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const REQUEST_NEGOTIABLE_QUOTE_MUTATION = `\n mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(\n $cartId: ID!\n $quoteName: String!\n $comment: NegotiableQuoteCommentInput!\n $isDraft: Boolean\n ) {\n requestNegotiableQuote(\n input: {\n cart_id: $cartId\n quote_name: $quoteName\n comment: $comment\n is_draft: $isDraft\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@adobe-commerce/fetch-graphql';\nimport { events } from '@adobe-commerce/event-bus';\nimport { REQUEST_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RequestNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RequestNegotiableQuoteInput {\n cartId: string;\n quoteName: string;\n comment: string;\n isDraft?: boolean;\n}\n\nexport const requestNegotiableQuote = async (\n input: RequestNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { cartId, quoteName, comment, isDraft } = input;\n\n if (!cartId) {\n throw new Error('Cart ID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n if (!comment) {\n throw new Error('Comment is required');\n }\n\n return fetchGraphQl(REQUEST_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n cartId,\n quoteName,\n comment: {\n comment\n },\n isDraft,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to request negotiable quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(response.data?.requestNegotiableQuote?.quote);\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/negotiable-quote-requested', {\n quote: quoteData,\n input: { cartId, quoteName, comment, isDraft },\n });\n\n return quoteData;\n });\n};\n"],"names":["DEFAULT_PERMISSIONS","_state","state","target","key","value","transformQuote","quoteData","comment","item","_b","_a","discount","tax","NEGOTIABLE_QUOTE_FRAGMENT","REQUEST_NEGOTIABLE_QUOTE_MUTATION","requestNegotiableQuote","input","cartId","quoteName","isDraft","fetchGraphQl","response","errors","errorMessages","error","events"],"mappings":"oHAWO,MAAMA,EAAsB,CAC/B,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,EACnB,EAEMC,EAAgB,CAClB,cAAe,GACf,YAAaD,CACjB,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACnC,IAAK,CAACE,EAAQC,IACHD,EAAOC,CAAkB,EAEpC,IAAK,CAACD,EAAQC,EAAKC,KACfF,EAAOC,CAAkB,EAAIC,EACtB,GAEf,CAAC,ECbM,SAASC,EAAeC,EAA6C,CAC1E,OAAKA,EAEE,CACL,IAAKA,EAAU,IACf,KAAMA,EAAU,KAChB,UAAWA,EAAU,WACrB,OAAQA,EAAU,OAClB,MAAOA,EAAU,MACjB,SAAUA,EAAU,SAAS,IAAKC,IAAkB,CAClD,IAAKA,EAAQ,IACb,UAAWA,EAAQ,WACnB,OAAQA,EAAQ,MAAA,EAChB,EACF,MAAOD,EAAU,MAAM,IAAKE,GAAA,SAAe,OACzC,QAAS,CACP,IAAKA,EAAK,QAAQ,IAClB,IAAKA,EAAK,QAAQ,IAClB,KAAMA,EAAK,QAAQ,IAAA,EAErB,gBAAiB,CACf,UAAWA,EAAK,OAAO,iBAAiB,WACxC,WAAYA,EAAK,OAAO,iBAAiB,WAAA,EAE3C,YAAWC,GAAAC,EAAAF,EAAK,SAAL,YAAAE,EAA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I,MACR,4DAAA,EAKJ,OAAAmB,EAAO,KAAK,8CAA+C,CACzD,MAAOnB,EACP,MAAO,CAAE,OAAAW,EAAQ,UAAAC,EAAW,QAAAX,EAAS,QAAAY,CAAA,CAAQ,CAC9C,EAEMb,CACT,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"requestNegotiableQuote.js","sources":["/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/graphql/RequestNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/requestNegotiableQuote.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const REQUEST_NEGOTIABLE_QUOTE_MUTATION = `\n mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(\n $cartId: ID!\n $quoteName: String!\n $comment: NegotiableQuoteCommentInput!\n $isDraft: Boolean\n ) {\n requestNegotiableQuote(\n input: {\n cart_id: $cartId\n quote_name: $quoteName\n comment: $comment\n is_draft: $isDraft\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@adobe-commerce/fetch-graphql';\nimport { events } from '@adobe-commerce/event-bus';\nimport { REQUEST_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RequestNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RequestNegotiableQuoteInput {\n cartId: string;\n quoteName: string;\n comment: string;\n isDraft?: boolean;\n}\n\nexport const requestNegotiableQuote = async (\n input: RequestNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { cartId, quoteName, comment, isDraft } = input;\n\n if (!cartId) {\n throw new Error('Cart ID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n if (!comment) {\n throw new Error('Comment is required');\n }\n\n return fetchGraphQl(REQUEST_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n cartId,\n quoteName,\n comment: {\n comment\n },\n isDraft,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to request negotiable quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(response);\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/negotiable-quote-requested', {\n quote: quoteData,\n input: { cartId, quoteName, comment, isDraft },\n });\n\n return quoteData;\n });\n};\n"],"names":["REQUEST_NEGOTIABLE_QUOTE_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","requestNegotiableQuote","input","cartId","quoteName","comment","isDraft","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","events"],"mappings":"4KAmBO,MAAMA,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoB7CC,CAAyB;AAAA,ECjBhBC,EAAyB,MACpCC,GACyC,CACzC,KAAM,CAAE,OAAAC,EAAQ,UAAAC,EAAW,QAAAC,EAAS,QAAAC,GAAYJ,EAEhD,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,qBAAqB,EAGvC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,wBAAwB,EAG1C,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,qBAAqB,EAGvC,OAAOE,EAAaR,EAAmC,CACrD,UAAW,CACT,OAAAI,EACA,UAAAC,EACA,QAAS,CACP,QAAAC,CAAA,EAEF,QAAAC,CAAA,CACF,CACD,EAAE,KAAME,GAAa,CACpB,KAAM,CAAE,OAAAC,GAAWD,EAEnB,GAAIC,EAAQ,CAEV,MAAMC,EAAgBD,EAAO,IAAKE,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MAAM,uCAAuCD,CAAa,EAAE,CACxE,CAGA,MAAME,EAAYC,EAAeL,CAAQ,EAEzC,GAAI,CAACI,EACH,MAAM,IAAI,MACR,4DAAA,EAKJ,OAAAE,EAAO,KAAK,8CAA+C,CACzD,MAAOF,EACP,MAAO,CAAE,OAAAT,EAAQ,UAAAC,EAAW,QAAAC,EAAS,QAAAC,CAAA,CAAQ,CAC9C,EAEMM,CACT,CAAC,CACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FunctionComponent, VNode } from 'preact';
|
|
2
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
+
|
|
4
|
+
export interface QuotesListTableProps extends Omit<HTMLAttributes<HTMLDivElement>, 'loading' | 'children'> {
|
|
5
|
+
rowData: QuoteRowData[];
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
emptyStateMessage?: VNode;
|
|
9
|
+
showItemRange?: boolean;
|
|
10
|
+
itemRangeMessage?: VNode;
|
|
11
|
+
showPageSizePicker?: boolean;
|
|
12
|
+
pageSizePickerMessage?: VNode;
|
|
13
|
+
showPagination?: boolean;
|
|
14
|
+
paginationMessage?: VNode;
|
|
15
|
+
}
|
|
16
|
+
export type QuoteRowData = {
|
|
17
|
+
id: string;
|
|
18
|
+
quoteName: VNode;
|
|
19
|
+
created: VNode;
|
|
20
|
+
createdBy: VNode;
|
|
21
|
+
status: VNode;
|
|
22
|
+
lastUpdated: VNode;
|
|
23
|
+
quoteTemplate: VNode;
|
|
24
|
+
quoteTotal: VNode;
|
|
25
|
+
actions: VNode;
|
|
26
|
+
[key: string]: VNode | string | number | undefined;
|
|
27
|
+
};
|
|
28
|
+
export declare const QuotesListTable: FunctionComponent<QuotesListTableProps>;
|
|
29
|
+
//# sourceMappingURL=QuotesListTable.d.ts.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export * from './
|
|
10
|
-
export {
|
|
9
|
+
export * from './QuotesListTable';
|
|
10
|
+
export { QuotesListTable as default } from './QuotesListTable';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/components/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export * from './RequestNegotiableQuoteForm';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './TabbedContent';
|
|
4
|
-
export * from './ActionsBar';
|
|
5
|
-
export * from './ProductListTable';
|
|
6
|
-
export * from './QuotePricesSummary';
|
|
7
|
-
export * from './ItemsQuoted';
|
|
2
|
+
export * from './QuotesListTable';
|
|
8
3
|
//# sourceMappingURL=index.d.ts.map
|