@dropins/storefront-quote-management 0.0.1-alpha28 → 0.0.1-alpha29
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/duplicateNegotiableQuote/duplicateNegotiableQuote.d.ts +8 -0
- package/api/duplicateNegotiableQuote/graphql/duplicateNegotiableQuoteMutation.d.ts +10 -0
- package/api/duplicateNegotiableQuote/index.d.ts +10 -0
- package/api/index.d.ts +2 -0
- package/api/setLineItemNote/graphql/SetLineItemNoteMutation.d.ts +10 -0
- package/api/setLineItemNote/index.d.ts +10 -0
- package/api/setLineItemNote/setLineItemNote.d.ts +10 -0
- package/api.js +17 -41
- package/api.js.map +1 -1
- package/chunks/ConfirmationModal.js +4 -0
- package/chunks/ConfirmationModal.js.map +1 -0
- package/chunks/ItemsQuoted.js +1 -1
- package/chunks/ItemsQuoted.js.map +1 -1
- package/chunks/ItemsQuotedTemplate.js +1 -1
- package/chunks/ItemsQuotedTemplate.js.map +1 -1
- package/chunks/OrderSummaryLine.js +1 -1
- package/chunks/OrderSummaryLine.js.map +1 -1
- package/chunks/QuotePricesSummary.js +1 -1
- package/chunks/QuotePricesSummary.js.map +1 -1
- package/chunks/TabbedContent.js +1 -1
- package/chunks/TabbedContent.js.map +1 -1
- package/chunks/dateUtils.js +1 -1
- package/chunks/dateUtils.js.map +1 -1
- package/chunks/duplicateNegotiableQuote.js +121 -0
- package/chunks/duplicateNegotiableQuote.js.map +1 -0
- package/chunks/generateQuoteFromTemplate.js +12 -0
- package/chunks/generateQuoteFromTemplate.js.map +1 -0
- package/chunks/openQuoteTemplate.js +31 -0
- package/chunks/openQuoteTemplate.js.map +1 -0
- package/chunks/setLineItemNote.js +47 -0
- package/chunks/setLineItemNote.js.map +1 -0
- package/chunks/state.js +1 -1
- package/chunks/state.js.map +1 -1
- package/chunks/transform-quote-template.js +1 -1
- package/chunks/transform-quote-template.js.map +1 -1
- package/chunks/transform-quote.js +1 -1
- package/chunks/transform-quote.js.map +1 -1
- package/components/LineItemNoteModal/LineItemNoteModal.d.ts +16 -0
- package/components/LineItemNoteModal/index.d.ts +11 -0
- package/components/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +0 -2
- package/components/ProductListTable/ProductListTable.d.ts +8 -0
- package/components/index.d.ts +1 -0
- package/containers/ItemsQuoted/ItemsQuoted.d.ts +1 -1
- package/containers/ItemsQuoted.js +1 -1
- package/containers/ItemsQuotedTemplate.js +1 -1
- package/containers/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +4 -0
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +4 -0
- package/containers/ManageNegotiableQuoteTemplate.js +1 -1
- package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
- package/containers/OrderSummary.js +1 -1
- package/containers/OrderSummary.js.map +1 -1
- package/containers/OrderSummaryLine.js +1 -1
- package/containers/QuoteSummaryList.js +1 -1
- package/containers/QuoteSummaryList.js.map +1 -1
- package/containers/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +2 -0
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuoteTemplatesListTable.js.map +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/QuotesListTable.js.map +1 -1
- package/data/models/negotiable-quote-template-model.d.ts +16 -7
- package/i18n/en_US.json.d.ts +57 -1
- package/package.json +1 -1
- package/render.js +3 -3
- package/render.js.map +1 -1
- package/types/state.types.d.ts +1 -0
- package/chunks/removeNegotiableQuoteItems.js +0 -38
- package/chunks/removeNegotiableQuoteItems.js.map +0 -1
- package/chunks/renameNegotiableQuote.js +0 -112
- package/chunks/renameNegotiableQuote.js.map +0 -1
- package/chunks/sendQuoteTemplateForReview.js +0 -15
- package/chunks/sendQuoteTemplateForReview.js.map +0 -1
package/chunks/dateUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{getGlobalLocale as
|
|
3
|
+
import{getGlobalLocale as n}from"@dropins/tools/lib.js";function a(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return console.warn("Failed to detect user timezone, falling back to UTC:",e),"UTC"}}function o(e){const t=new Date(e);return!isNaN(t.getTime())}function c(e,t="short"){if(!o(e))return"–";const r=n()||"en-US";return t==="short"?new Date(e).toLocaleDateString(r,{year:"numeric",month:"numeric",day:"numeric"}):new Date(e).toLocaleDateString(r,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0})}export{c as f,a as g};
|
|
4
4
|
//# sourceMappingURL=dateUtils.js.map
|
package/chunks/dateUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.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 { getGlobalLocale } from \"@adobe-commerce/elsie/lib\";\n\n/**\n * Gets the user's timezone with fallback to UTC if detection fails\n * @returns The user's timezone string (e.g., 'America/New_York') or 'UTC' as fallback\n */\nexport function getUserTimezone(): string {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch (error) {\n console.warn('Failed to detect user timezone, falling back to UTC:', error);\n return 'UTC';\n }\n}\n\n/**\n * Checks if a date string is a valid date\n * @param dateString - The date string to check\n * @returns True if the date string is a valid date, false otherwise\n */\nexport function isValidDate(dateString: string): boolean {\n const date = new Date(dateString);\n return !isNaN(date.getTime());\n}\n\n/**\n * Formats a date string to locale date string, returning \"–\" for invalid dates\n * @param dateString - The date string to format\n * @returns Formatted date string or \"–\" for invalid dates\n */\nexport function formattedDate(dateString: string, type: 'short' | 'long' = 'short'): string {\n if (!isValidDate(dateString)) {\n return '–';\n }\n\n const locale = getGlobalLocale() || 'en-US';\n\n if (type === 'short') {\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n });\n }\n\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n });\n}\n"],"names":["isValidDate","dateString","date","formattedDate","type","locale","getGlobalLocale"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dateUtils.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.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 { getGlobalLocale } from \"@adobe-commerce/elsie/lib\";\n\n/**\n * Gets the user's timezone with fallback to UTC if detection fails\n * @returns The user's timezone string (e.g., 'America/New_York') or 'UTC' as fallback\n */\nexport function getUserTimezone(): string {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch (error) {\n console.warn('Failed to detect user timezone, falling back to UTC:', error);\n return 'UTC';\n }\n}\n\n/**\n * Checks if a date string is a valid date\n * @param dateString - The date string to check\n * @returns True if the date string is a valid date, false otherwise\n */\nexport function isValidDate(dateString: string): boolean {\n const date = new Date(dateString);\n return !isNaN(date.getTime());\n}\n\n/**\n * Formats a date string to locale date string, returning \"–\" for invalid dates\n * @param dateString - The date string to format\n * @returns Formatted date string or \"–\" for invalid dates\n */\nexport function formattedDate(dateString: string, type: 'short' | 'long' = 'short'): string {\n if (!isValidDate(dateString)) {\n return '–';\n }\n\n const locale = getGlobalLocale() || 'en-US';\n\n if (type === 'short') {\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n });\n }\n\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n });\n}\n"],"names":["getUserTimezone","error","isValidDate","dateString","date","formattedDate","type","locale","getGlobalLocale"],"mappings":"wDAeO,SAASA,GAA0B,CACxC,GAAI,CACF,OAAO,KAAK,iBAAiB,gBAAA,EAAkB,QACjD,OAASC,EAAO,CACd,eAAQ,KAAK,uDAAwDA,CAAK,EACnE,KACT,CACF,CAOO,SAASC,EAAYC,EAA6B,CACvD,MAAMC,EAAO,IAAI,KAAKD,CAAU,EAChC,MAAO,CAAC,MAAMC,EAAK,SAAS,CAC9B,CAOO,SAASC,EAAcF,EAAoBG,EAAyB,QAAiB,CAC1F,GAAI,CAACJ,EAAYC,CAAU,EACzB,MAAO,IAGT,MAAMI,EAASC,KAAqB,QAEpC,OAAIF,IAAS,QACJ,IAAI,KAAKH,CAAU,EAAE,mBAAmBI,EAAQ,CACrD,KAAM,UACN,MAAO,UACP,IAAK,SAAA,CACN,EAGI,IAAI,KAAKJ,CAAU,EAAE,mBAAmBI,EAAQ,CACrD,KAAM,UACN,MAAO,OACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OAAQ,EAAA,CACT,CACH"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as p}from"@dropins/tools/event-bus.js";import{f as E,a as q}from"./transform-quote.js";import{N as g}from"./NegotiableQuoteFragment.js";import{s as _}from"./state.js";import{a as Q}from"./transform-quote-template.js";import{N as U}from"./NegotiableQuoteTemplateFragment.js";const N=`
|
|
4
|
+
query QUOTE_DATA_QUERY(
|
|
5
|
+
$quoteId: ID!
|
|
6
|
+
) {
|
|
7
|
+
negotiableQuote(
|
|
8
|
+
uid: $quoteId
|
|
9
|
+
) {
|
|
10
|
+
...NegotiableQuoteFragment
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
${g}
|
|
15
|
+
`,S=async u=>{var r;if(!_.authenticated)return Promise.reject(new Error("Unauthorized"));if(!_.permissions.editQuote)return Promise.reject(new Error("Unauthorized"));try{const o=await E(N,{variables:{quoteId:u}}),t=q((r=o==null?void 0:o.data)==null?void 0:r.negotiableQuote);if(!t)throw new Error("Failed to transform quote data");return p.emit("quote-management/quote-data",{quote:t,permissions:_.permissions}),t}catch(o){return Promise.reject(o)}},T=`
|
|
16
|
+
mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {
|
|
17
|
+
deleteNegotiableQuotes(
|
|
18
|
+
input: {
|
|
19
|
+
quote_uids: $quoteUids
|
|
20
|
+
}
|
|
21
|
+
) {
|
|
22
|
+
result_status
|
|
23
|
+
operation_results {
|
|
24
|
+
__typename
|
|
25
|
+
... on NegotiableQuoteUidOperationSuccess {
|
|
26
|
+
quote_uid
|
|
27
|
+
}
|
|
28
|
+
... on DeleteNegotiableQuoteOperationFailure {
|
|
29
|
+
quote_uid
|
|
30
|
+
errors {
|
|
31
|
+
__typename
|
|
32
|
+
... on ErrorInterface {
|
|
33
|
+
message
|
|
34
|
+
}
|
|
35
|
+
... on NoSuchEntityUidError {
|
|
36
|
+
uid
|
|
37
|
+
message
|
|
38
|
+
}
|
|
39
|
+
... on NegotiableQuoteInvalidStateError {
|
|
40
|
+
message
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`,M=async u=>{var o;if(!_.authenticated)return Promise.reject(new Error("Unauthorized"));const r=Array.isArray(u)?u:[u];try{const t=await E(T,{variables:{quoteUids:r}}),{errors:c}=t||{};if(c&&c.length){const a=c.map(e=>e==null?void 0:e.message).filter(Boolean).join("; ");throw new Error(a||"Failed to delete negotiable quotes")}const i=(o=t==null?void 0:t.data)==null?void 0:o.deleteNegotiableQuotes;if(!i)throw new Error("No delete result returned");const n={resultStatus:i.result_status,operationResults:(i.operation_results||[]).map(a=>(a==null?void 0:a.__typename)==="NegotiableQuoteUidOperationSuccess"?{__typename:"NegotiableQuoteUidOperationSuccess",quoteUid:a==null?void 0:a.quote_uid}:{__typename:"DeleteNegotiableQuoteOperationFailure",quoteUid:a==null?void 0:a.quote_uid,errors:((a==null?void 0:a.errors)||[]).map(d=>({__typename:d==null?void 0:d.__typename,message:d==null?void 0:d.message,uid:d==null?void 0:d.uid}))})},s=n.operationResults.filter(a=>a.__typename==="NegotiableQuoteUidOperationSuccess").map(a=>a.quoteUid);return s.length>0&&p.emit("quote-management/negotiable-quote-deleted",{deletedQuoteUids:s,resultStatus:n.resultStatus}),n}catch(t){return p.emit("quote-management/negotiable-quote-delete-error",{error:t instanceof Error?t:new Error(String(t)),attemptedQuoteUids:r}),Promise.reject(t)}},f=`
|
|
48
|
+
mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(
|
|
49
|
+
$quoteUid: ID!
|
|
50
|
+
$comment: NegotiableQuoteCommentInput
|
|
51
|
+
) {
|
|
52
|
+
sendNegotiableQuoteForReview(
|
|
53
|
+
input: {
|
|
54
|
+
quote_uid: $quoteUid
|
|
55
|
+
comment: $comment
|
|
56
|
+
}
|
|
57
|
+
) {
|
|
58
|
+
quote {
|
|
59
|
+
...NegotiableQuoteFragment
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
${g}
|
|
64
|
+
`,R=async u=>{const{quoteUid:r,comment:o}=u;if(!r)throw new Error("Quote UID is required");return E(f,{variables:{quoteUid:r,comment:o?{comment:o}:null}}).then(c=>{var s,a;const{errors:i}=c;if(i){const e=i.map(m=>m.message).join("; ");throw new Error(`Failed to send quote for review: ${e}`)}const n=q((a=(s=c.data)==null?void 0:s.sendNegotiableQuoteForReview)==null?void 0:a.quote);if(!n)throw new Error("Failed to transform quote data: Invalid response structure");return p.emit("quote-management/quote-sent-for-review",{quote:n,input:{quoteUid:r,comment:o}}),n})},w=`
|
|
65
|
+
mutation CLOSE_NEGOTIABLE_QUOTE_MUTATION(
|
|
66
|
+
$quoteUids: [ID!]!
|
|
67
|
+
) {
|
|
68
|
+
closeNegotiableQuotes(input: { quote_uids: $quoteUids }) {
|
|
69
|
+
result_status
|
|
70
|
+
operation_results {
|
|
71
|
+
... on NegotiableQuoteUidOperationSuccess {
|
|
72
|
+
__typename
|
|
73
|
+
quote_uid
|
|
74
|
+
}
|
|
75
|
+
... on CloseNegotiableQuoteOperationFailure {
|
|
76
|
+
__typename
|
|
77
|
+
quote_uid
|
|
78
|
+
errors {
|
|
79
|
+
__typename
|
|
80
|
+
... on ErrorInterface {
|
|
81
|
+
message
|
|
82
|
+
}
|
|
83
|
+
... on NoSuchEntityUidError {
|
|
84
|
+
uid
|
|
85
|
+
}
|
|
86
|
+
... on NegotiableQuoteInvalidStateError {
|
|
87
|
+
message
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`,v=async u=>{var o;if(!_.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUids:r}=u;if(!r||r.length===0)throw new Error("Quote UIDs are required");try{const t=await E(w,{variables:{quoteUids:r}}),{errors:c}=t||{};if(c&&c.length){const e=c.map(m=>m==null?void 0:m.message).filter(Boolean).join("; ");throw new Error(e||"Failed to close negotiable quotes")}const i=(o=t==null?void 0:t.data)==null?void 0:o.closeNegotiableQuotes;if(!i)throw new Error("No close result returned");const n={resultStatus:i.result_status,operationResults:(i.operation_results||[]).map(e=>(e==null?void 0:e.__typename)==="NegotiableQuoteUidOperationSuccess"?{__typename:"NegotiableQuoteUidOperationSuccess",quoteUid:e==null?void 0:e.quote_uid}:{__typename:"CloseNegotiableQuoteOperationFailure",quoteUid:e==null?void 0:e.quote_uid,errors:((e==null?void 0:e.errors)||[]).map(l=>({__typename:l==null?void 0:l.__typename,message:l==null?void 0:l.message,uid:l==null?void 0:l.uid}))})},s=n.operationResults.filter(e=>e.__typename==="CloseNegotiableQuoteOperationFailure").map(e=>e);if(s.length>0){const e=s.map(m=>m.errors&&m.errors.length>0?m.errors.map(d=>d.message||`Failed to close quote ${m.quoteUid}`).join(", "):`Failed to close quote ${m.quoteUid}`).join("; ");throw new Error(e)}const a=n.operationResults.filter(e=>e.__typename==="NegotiableQuoteUidOperationSuccess").map(e=>e.quoteUid);return a.length>0&&p.emit("quote-management/negotiable-quote-closed",{closedQuoteUids:a,resultStatus:n.resultStatus}),n}catch(t){return p.emit("quote-management/negotiable-quote-close-error",{error:t instanceof Error?t:new Error(String(t)),attemptedQuoteUids:r}),Promise.reject(t)}},b=`
|
|
95
|
+
mutation CREATE_QUOTE_TEMPLATE_MUTATION($cartId: ID!) {
|
|
96
|
+
requestNegotiableQuoteTemplateFromQuote(input: { cart_id: $cartId }) {
|
|
97
|
+
...NegotiableQuoteTemplateFragment
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
${U}
|
|
102
|
+
`,L=async u=>{var r;if(!_.authenticated)throw new Error("Unauthorized");if(!u)throw new Error("Cart ID is required");try{const o=await E(b,{variables:{cartId:u}});if(!((r=o==null?void 0:o.data)!=null&&r.requestNegotiableQuoteTemplateFromQuote))throw new Error("Failed to create quote template");const t=Q(o.data.requestNegotiableQuoteTemplateFromQuote);if(!t)throw new Error("Failed to transform quote template data");return p.emit("quote-management/quote-template-data",{quoteTemplate:t,permissions:_.permissions}),t}catch(o){return Promise.reject(o)}},I=`
|
|
103
|
+
mutation renameNegotiableQuote($input: RenameNegotiableQuoteInput!) {
|
|
104
|
+
renameNegotiableQuote(input: $input) {
|
|
105
|
+
quote {
|
|
106
|
+
...NegotiableQuoteFragment
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
${g}
|
|
111
|
+
`,j=async u=>{const{quoteUid:r,quoteName:o,quoteComment:t}=u;if(!r)throw new Error("Quote UID is required");if(!o)throw new Error("Quote name is required");return E(I,{variables:{input:{quote_uid:r,quote_name:o,quote_comment:t||""}}}).then(i=>{var a,e;const{errors:n}=i;if(n){const m=n.map(d=>d.message).join("; ");throw new Error(`Failed to rename quote: ${m}`)}const s=q((e=(a=i.data)==null?void 0:a.renameNegotiableQuote)==null?void 0:e.quote);if(!s)throw new Error("Failed to transform quote data: Invalid response structure");return p.emit("quote-management/quote-renamed",{quote:s,input:{quoteUid:r,quoteName:o,quoteComment:t}}),s})},h=`
|
|
112
|
+
mutation DUPLICATE_NEGOTIABLE_QUOTE_MUTATION($quoteUid: ID!, $duplicatedQuoteUid: ID!) {
|
|
113
|
+
duplicateNegotiableQuote(input: { quote_uid: $quoteUid, duplicated_quote_uid: $duplicatedQuoteUid }) {
|
|
114
|
+
quote {
|
|
115
|
+
...NegotiableQuoteFragment
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
${g}
|
|
120
|
+
`,P=async u=>{if(!_.authenticated)throw new Error("Unauthorized");const{quoteUid:r,duplicatedQuoteUid:o}=u;if(!r||!r.trim())throw new Error("Quote UID is required");if(!o||!o.trim())throw new Error("Duplicated Quote UID is required");return E(h,{variables:{quoteUid:r,duplicatedQuoteUid:o}}).then(t=>{var n,s;const{errors:c}=t;if(c){const a=c.map(e=>e.message).join("; ");throw new Error(`Failed to duplicate quote: ${a}`)}const i=q((s=(n=t.data)==null?void 0:n.duplicateNegotiableQuote)==null?void 0:s.quote);if(!i)throw new Error("Failed to transform quote data: Invalid response structure");return p.emit("quote-management/quote-duplicated",{quote:i,input:{quoteUid:r,duplicatedQuoteUid:o}}),i})};export{L as a,P as b,v as c,M as d,S as g,j as r,R as s};
|
|
121
|
+
//# sourceMappingURL=duplicateNegotiableQuote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicateNegotiableQuote.js","sources":["/@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/deleteQuote/graphql/DeleteQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/deleteQuote/deleteQuote.ts","/@dropins/storefront-quote-management/src/api/sendForReview/graphql/SendNegotiableQuoteForReviewMutation.ts","/@dropins/storefront-quote-management/src/api/sendForReview/sendForReview.ts","/@dropins/storefront-quote-management/src/api/closeNegotiableQuote/graphql/CloseNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/closeNegotiableQuote/closeNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/createQuoteTemplate/graphql/createQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/createQuoteTemplate/createQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/graphql/RenameNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/renameNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/duplicateNegotiableQuote/graphql/duplicateNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/duplicateNegotiableQuote/duplicateNegotiableQuote.ts"],"sourcesContent":["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","/********************************************************************\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 DELETE_QUOTE_MUTATION = `\n mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {\n deleteNegotiableQuotes(\n input: {\n quote_uids: $quoteUids\n }\n ) {\n result_status\n operation_results {\n __typename\n ... on NegotiableQuoteUidOperationSuccess {\n quote_uid\n }\n ... on DeleteNegotiableQuoteOperationFailure {\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n message\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\n }\n }\n }\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 { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { DELETE_QUOTE_MUTATION } from '@/quote-management/api/deleteQuote/graphql/DeleteQuoteMutation';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface DeleteQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface DeleteQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface DeleteQuoteFailureResult {\n __typename: 'DeleteNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: DeleteQuoteFailureError[];\n}\n\nexport interface DeleteQuoteOutput {\n resultStatus: string;\n operationResults: Array<DeleteQuoteSuccessResult | DeleteQuoteFailureResult>;\n}\n\nexport const deleteQuote = async ( quoteUids: string[] | string ): Promise<DeleteQuoteOutput> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const quoteUidsArray = Array.isArray(quoteUids) ? quoteUids : [quoteUids];\n\n try {\n const response: any = await fetchGraphQl(DELETE_QUOTE_MUTATION, {\n variables: {\n quoteUids: quoteUidsArray,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors.map((e: any) => e?.message).filter(Boolean).join('; ');\n throw new Error(errorMessages || 'Failed to delete negotiable quotes');\n }\n\n const raw = response?.data?.deleteNegotiableQuotes;\n if (!raw) {\n throw new Error('No delete result returned');\n }\n\n const transformed: DeleteQuoteOutput = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: DeleteQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: DeleteQuoteFailureResult = {\n __typename: 'DeleteNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Emit event with successfully deleted quote UIDs\n const deletedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as DeleteQuoteSuccessResult).quoteUid);\n\n if (deletedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-deleted', {\n deletedQuoteUids: deletedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-delete-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUidsArray,\n });\n return Promise.reject(error);\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';\n\nexport const SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION = `\n mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(\n $quoteUid: ID!\n $comment: NegotiableQuoteCommentInput\n ) {\n sendNegotiableQuoteForReview(\n input: {\n quote_uid: $quoteUid\n comment: $comment\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 '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION } from './graphql/SendNegotiableQuoteForReviewMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface SendForReviewInput {\n quoteUid: string;\n comment?: string;\n}\n\nexport const sendForReview = async (\n input: SendForReviewInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, comment } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Build the comment object only if a comment is provided\n const commentInput = comment ? { comment } : null;\n\n return fetchGraphQl(SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION, {\n variables: {\n quoteUid,\n comment: commentInput,\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 send quote for review: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.sendNegotiableQuoteForReview?.quote\n );\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/quote-sent-for-review', {\n quote: quoteData,\n input: { quoteUid, comment },\n });\n\n return quoteData;\n });\n};\n\n","export const CLOSE_NEGOTIABLE_QUOTE_MUTATION = `\n mutation CLOSE_NEGOTIABLE_QUOTE_MUTATION(\n $quoteUids: [ID!]!\n ) {\n closeNegotiableQuotes(input: { quote_uids: $quoteUids }) {\n result_status\n operation_results {\n ... on NegotiableQuoteUidOperationSuccess {\n __typename\n quote_uid\n }\n ... on CloseNegotiableQuoteOperationFailure {\n __typename\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\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 { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CLOSE_NEGOTIABLE_QUOTE_MUTATION } from './graphql/CloseNegotiableQuoteMutation';\n\nexport interface CloseNegotiableQuoteInput {\n quoteUids: string[];\n}\n\nexport interface CloseNegotiableQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface CloseNegotiableQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface CloseNegotiableQuoteFailureResult {\n __typename: 'CloseNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: CloseNegotiableQuoteFailureError[];\n}\n\nexport interface CloseNegotiableQuoteResult {\n resultStatus: string;\n operationResults: Array<CloseNegotiableQuoteSuccessResult | CloseNegotiableQuoteFailureResult>;\n}\n\nexport const closeNegotiableQuote = async (input: CloseNegotiableQuoteInput): Promise<CloseNegotiableQuoteResult> => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUids } = input;\n\n if (!quoteUids || quoteUids.length === 0) {\n throw new Error('Quote UIDs are required');\n }\n\n try {\n const response: any = await fetchGraphQl(CLOSE_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n quoteUids,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors\n .map((e: any) => e?.message)\n .filter(Boolean)\n .join('; ');\n throw new Error(errorMessages || 'Failed to close negotiable quotes');\n }\n\n const raw = response?.data?.closeNegotiableQuotes;\n if (!raw) {\n throw new Error('No close result returned');\n }\n\n const transformed: CloseNegotiableQuoteResult = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: CloseNegotiableQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: CloseNegotiableQuoteFailureResult = {\n __typename: 'CloseNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Check for operation failures\n const failures = transformed.operationResults\n .filter(\n (res) => res.__typename === 'CloseNegotiableQuoteOperationFailure'\n )\n .map((res) => res as CloseNegotiableQuoteFailureResult);\n\n if (failures.length > 0) {\n // Create error message from failures\n const failureMessages = failures\n .map((failure) => {\n if (failure.errors && failure.errors.length > 0) {\n return failure.errors\n .map(\n (err) =>\n err.message || `Failed to close quote ${failure.quoteUid}`\n )\n .join(', ');\n }\n return `Failed to close quote ${failure.quoteUid}`;\n })\n .join('; ');\n\n throw new Error(failureMessages);\n }\n\n // Emit success event with closed quote UIDs\n const closedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as CloseNegotiableQuoteSuccessResult).quoteUid);\n\n if (closedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-closed', {\n closedQuoteUids: closedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-close-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUids,\n });\n return Promise.reject(error);\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_TEMPLATE_FRAGMENT } from \"../../graphql/NegotiableQuoteTemplateFragment\";\n\nexport const CREATE_QUOTE_TEMPLATE_MUTATION = /* GraphQL */ `\n mutation CREATE_QUOTE_TEMPLATE_MUTATION($cartId: ID!) {\n requestNegotiableQuoteTemplateFromQuote(input: { cart_id: $cartId }) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_TEMPLATE_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 { events } from '@adobe-commerce/event-bus';\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { CREATE_QUOTE_TEMPLATE_MUTATION } from './graphql/createQuoteTemplate';\nimport { state } from '@/quote-management/lib/state';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\n\nexport const createQuoteTemplate = async (\n quoteId: string\n): Promise<NegotiableQuoteTemplateModel | null> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n if (!quoteId) {\n throw new Error('Cart ID is required');\n }\n\n try {\n const results: any = await fetchGraphQl(CREATE_QUOTE_TEMPLATE_MUTATION, {\n variables: {\n cartId: quoteId,\n },\n });\n\n if (!results?.data?.requestNegotiableQuoteTemplateFromQuote) {\n throw new Error('Failed to create quote template');\n }\n\n const transformedQuoteTemplate = transformQuoteTemplate(\n results.data.requestNegotiableQuoteTemplateFromQuote\n );\n\n if (!transformedQuoteTemplate) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedQuoteTemplate,\n permissions: state.permissions,\n });\n\n return transformedQuoteTemplate;\n } catch (error) {\n return Promise.reject(error);\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';\n\nexport const RENAME_NEGOTIABLE_QUOTE_MUTATION = `\n mutation renameNegotiableQuote($input: RenameNegotiableQuoteInput!) {\n renameNegotiableQuote(input: $input) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { events } from '@adobe-commerce/event-bus';\nimport { RENAME_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RenameNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RenameNegotiableQuoteInput {\n quoteUid: string;\n quoteName: string;\n quoteComment?: string;\n}\n\nexport const renameNegotiableQuote = async (\n input: RenameNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, quoteName, quoteComment } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n // Backend requires quote_comment to be present (even if empty string)\n const mutationInput = {\n quote_uid: quoteUid,\n quote_name: quoteName,\n quote_comment: quoteComment || '', // Always include, use empty string if not provided\n };\n\n return fetchGraphQl(RENAME_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n input: mutationInput,\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 rename quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.renameNegotiableQuote?.quote\n );\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/quote-renamed', {\n quote: quoteData,\n input: { quoteUid, quoteName, quoteComment },\n });\n\n return quoteData;\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';\n\nexport const DUPLICATE_NEGOTIABLE_QUOTE_MUTATION = `\n mutation DUPLICATE_NEGOTIABLE_QUOTE_MUTATION($quoteUid: ID!, $duplicatedQuoteUid: ID!) {\n duplicateNegotiableQuote(input: { quote_uid: $quoteUid, duplicated_quote_uid: $duplicatedQuoteUid }) {\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 '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { DUPLICATE_NEGOTIABLE_QUOTE_MUTATION } from './graphql/duplicateNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport interface DuplicateQuoteInput {\n quoteUid: string;\n duplicatedQuoteUid: string;\n}\n\nexport const duplicateQuote = async (\n input: DuplicateQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n const { quoteUid, duplicatedQuoteUid } = input;\n\n if (!quoteUid || !quoteUid.trim()) {\n throw new Error('Quote UID is required');\n }\n\n if (!duplicatedQuoteUid || !duplicatedQuoteUid.trim()) {\n throw new Error('Duplicated Quote UID is required');\n }\n\n return fetchGraphQl(DUPLICATE_NEGOTIABLE_QUOTE_MUTATION, {\n variables: { quoteUid, duplicatedQuoteUid },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to duplicate quote: ${errorMessages}`);\n }\n\n const quoteData = transformQuote(\n response.data?.duplicateNegotiableQuote?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n events.emit('quote-management/quote-duplicated', {\n quote: quoteData,\n input: { quoteUid, duplicatedQuoteUid },\n });\n\n return quoteData;\n });\n};\n"],"names":["QUOTE_DATA_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","getQuoteData","quoteId","state","results","fetchGraphQl","transformedQuote","transformQuote","_a","events","error","DELETE_QUOTE_MUTATION","deleteQuote","quoteUids","quoteUidsArray","response","errors","errorMessages","raw","transformed","result","err","deletedUids","res","SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION","sendForReview","input","quoteUid","comment","quoteData","_b","CLOSE_NEGOTIABLE_QUOTE_MUTATION","closeNegotiableQuote","e","failures","failureMessages","failure","closedUids","CREATE_QUOTE_TEMPLATE_MUTATION","NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT","createQuoteTemplate","transformedQuoteTemplate","transformQuoteTemplate","RENAME_NEGOTIABLE_QUOTE_MUTATION","renameNegotiableQuote","quoteName","quoteComment","DUPLICATE_NEGOTIABLE_QUOTE_MUTATION","duplicateQuote","duplicatedQuoteUid"],"mappings":"gSAEO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAW1BC,CAAyB;AAAA,ECElBC,EAAe,MAAOC,GAAoB,OACnD,GAAI,CAACC,EAAM,cACP,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGnD,GAAI,CAACA,EAAM,YAAY,UACnB,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGnD,GAAI,CACA,MAAMC,EAAe,MAAMC,EAAaN,EAAkB,CACtD,UAAW,CACP,QAAAG,CAAA,CACJ,CACH,EAEKI,EAAmBC,GAAeC,EAAAJ,GAAA,YAAAA,EAAS,OAAT,YAAAI,EAAe,eAAe,EAEtE,GAAI,CAACF,EACD,MAAM,IAAI,MAAM,gCAAgC,EAGpD,OAAAG,EAAO,KAAK,8BAA+B,CACvC,MAAOH,EACP,YAAaH,EAAM,WAAA,CACtB,EAEMG,CACX,OAASI,EAAO,CACZ,O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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ/C/C,CAAyB;AAAA,ECEhBgD,EAAiB,MAC5BtB,GACyC,CAEzC,GAAI,CAACvB,EAAM,cACT,MAAM,IAAI,MAAM,cAAc,EAGhC,KAAM,CAAE,SAAAwB,EAAU,mBAAAsB,CAAA,EAAuBvB,EAEzC,GAAI,CAACC,GAAY,CAACA,EAAS,OACzB,MAAM,IAAI,MAAM,uBAAuB,EAGzC,GAAI,CAACsB,GAAsB,CAACA,EAAmB,OAC7C,MAAM,IAAI,MAAM,kCAAkC,EAGpD,OAAO5C,EAAa0C,EAAqC,CACvD,UAAW,CAAE,SAAApB,EAAU,mBAAAsB,CAAA,CAAmB,CAC3C,EAAE,KAAMlC,GAAa,SACpB,KAAM,CAAE,OAAAC,GAAWD,EAEnB,GAAIC,EAAQ,CACV,MAAMC,EAAgBD,EAAO,IAAKN,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MAAM,8BAA8BO,CAAa,EAAE,CAC/D,CAEA,MAAMY,EAAYtB,GAChBuB,GAAAtB,EAAAO,EAAS,OAAT,YAAAP,EAAe,2BAAf,YAAAsB,EAAyC,KAAA,EAG3C,GAAI,CAACD,EACH,MAAM,IAAI,MACR,4DAAA,EAIJ,OAAApB,EAAO,KAAK,oCAAqC,CAC/C,MAAOoB,EACP,MAAO,CAAE,SAAAF,EAAU,mBAAAsB,CAAA,CAAmB,CACvC,EAEMpB,CACT,CAAC,CACH"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as i}from"@dropins/tools/event-bus.js";import{s as n}from"./state.js";import{f as m}from"./transform-quote.js";const u=`
|
|
4
|
+
mutation GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION(
|
|
5
|
+
$input: GenerateNegotiableQuoteFromTemplateInput!
|
|
6
|
+
) {
|
|
7
|
+
generateNegotiableQuoteFromTemplate(input: $input) {
|
|
8
|
+
negotiable_quote_uid
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`,l=async t=>{var o,r;if(!t.templateId)throw new Error("Template ID is required");if(!n.authenticated)throw new Error("Unauthorized");try{const e=await m(u,{variables:{input:{template_id:t.templateId}}});if(!((r=(o=e==null?void 0:e.data)==null?void 0:o.generateNegotiableQuoteFromTemplate)!=null&&r.negotiable_quote_uid))throw new Error("No quote UID received");const a=e.data.generateNegotiableQuoteFromTemplate.negotiable_quote_uid;return i.emit("quote-management/quote-template-generated",{quoteId:a}),{quoteId:a}}catch(e){return Promise.reject(e)}};export{l as g};
|
|
12
|
+
//# sourceMappingURL=generateQuoteFromTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateQuoteFromTemplate.js","sources":["/@dropins/storefront-quote-management/src/api/generateQuoteFromTemplate/graphql/generateNegotiableQuoteFromTemplate.ts","/@dropins/storefront-quote-management/src/api/generateQuoteFromTemplate/generateQuoteFromTemplate.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 GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION = /* GraphQL */ `\n mutation GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION(\n $input: GenerateNegotiableQuoteFromTemplateInput!\n ) {\n generateNegotiableQuoteFromTemplate(input: $input) {\n negotiable_quote_uid\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 { fetchGraphQl } from '@/quote-management/api';\nimport { GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION } from './graphql/generateNegotiableQuoteFromTemplate';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface GenerateQuoteFromTemplateParams {\n templateId: string;\n}\n\nexport const generateQuoteFromTemplate = async (\n params: GenerateQuoteFromTemplateParams\n) => {\n if (!params.templateId) {\n throw new Error('Template ID is required');\n }\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(\n GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION,\n {\n variables: {\n input: {\n template_id: params.templateId,\n },\n },\n }\n );\n\n if (\n !results?.data?.generateNegotiableQuoteFromTemplate?.negotiable_quote_uid\n ) {\n throw new Error('No quote UID received');\n }\n\n const quoteId =\n results.data.generateNegotiableQuoteFromTemplate.negotiable_quote_uid;\n\n events.emit('quote-management/quote-template-generated', {\n quoteId,\n });\n\n return { quoteId };\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION","generateQuoteFromTemplate","params","state","results","fetchGraphQl","_b","_a","quoteId","events","error"],"mappings":"6HASO,MAAMA,EAAiE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECSjEC,EAA4B,MACvCC,GACG,SACH,GAAI,CAACA,EAAO,WACV,MAAM,IAAI,MAAM,yBAAyB,EAG3C,GAAI,CAACC,EAAM,cACT,MAAM,IAAI,MAAM,cAAc,EAGhC,GAAI,CACF,MAAMC,EAAe,MAAMC,EACzBL,EACA,CACE,UAAW,CACT,MAAO,CACL,YAAaE,EAAO,UAAA,CACtB,CACF,CACF,EAGF,GACE,GAACI,GAAAC,EAAAH,GAAA,YAAAA,EAAS,OAAT,YAAAG,EAAe,sCAAf,MAAAD,EAAoD,sBAErD,MAAM,IAAI,MAAM,uBAAuB,EAGzC,MAAME,EACJJ,EAAQ,KAAK,oCAAoC,qBAEnD,OAAAK,EAAO,KAAK,4CAA6C,CACvD,QAAAD,CAAA,CACD,EAEM,CAAE,QAAAA,CAAA,CACX,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as m}from"@dropins/tools/event-bus.js";import{a as i}from"./transform-quote-template.js";import{s as r}from"./state.js";import{N as n}from"./NegotiableQuoteTemplateFragment.js";import{f as p}from"./transform-quote.js";const l=`
|
|
4
|
+
mutation SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION(
|
|
5
|
+
$templateId: ID!
|
|
6
|
+
$comment: String
|
|
7
|
+
$name: String
|
|
8
|
+
) {
|
|
9
|
+
submitNegotiableQuoteTemplateForReview(input: { template_id: $templateId, name: $name, comment: $comment }) {
|
|
10
|
+
...NegotiableQuoteTemplateFragment
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
${n}
|
|
14
|
+
`,I=async a=>{var o;if(!a.templateId)throw new Error("Template ID is required");if(!r.authenticated)throw new Error("Unauthorized");try{const e=await p(l,{variables:{templateId:a.templateId,name:a.name,comment:a.comment}});if(!((o=e==null?void 0:e.data)!=null&&o.submitNegotiableQuoteTemplateForReview))throw new Error("No quote template data received");const t=i(e.data.submitNegotiableQuoteTemplateForReview);if(!t)throw new Error("Failed to transform quote template data");return m.emit("quote-management/quote-template-data",{quoteTemplate:t,permissions:r.permissions}),t}catch(e){return Promise.reject(e)}},T=`
|
|
15
|
+
mutation ACCEPT_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {
|
|
16
|
+
acceptNegotiableQuoteTemplate(input: { template_id: $templateId }) {
|
|
17
|
+
...NegotiableQuoteTemplateFragment
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
${n}
|
|
22
|
+
`,N=async a=>{var o;if(!a.templateId)throw new Error("Template ID is required");if(!r.authenticated)throw new Error("Unauthorized");try{const e=await p(T,{variables:{templateId:a.templateId}});if(!((o=e==null?void 0:e.data)!=null&&o.acceptNegotiableQuoteTemplate))throw new Error("No quote template data received");const t=i(e.data.acceptNegotiableQuoteTemplate);if(!t)throw new Error("Failed to transform quote template data");return m.emit("quote-management/quote-template-data",{quoteTemplate:t,permissions:r.permissions}),t}catch(e){return Promise.reject(e)}},s=`
|
|
23
|
+
mutation OPEN_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {
|
|
24
|
+
openNegotiableQuoteTemplate(input: { template_id: $templateId }) {
|
|
25
|
+
...NegotiableQuoteTemplateFragment
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
${n}
|
|
30
|
+
`,_=async a=>{var o;if(!a.templateId)throw new Error("Template ID is required");if(!r.authenticated)throw new Error("Unauthorized");try{const e=await p(s,{variables:{templateId:a.templateId}});if(!((o=e==null?void 0:e.data)!=null&&o.openNegotiableQuoteTemplate))throw new Error("No quote template data received");const t=i(e.data.openNegotiableQuoteTemplate);if(!t)throw new Error("Failed to transform quote template data");return m.emit("quote-management/quote-template-data",{quoteTemplate:t,permissions:r.permissions}),t}catch(e){return Promise.reject(e)}};export{N as a,_ as o,I as s};
|
|
31
|
+
//# sourceMappingURL=openQuoteTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openQuoteTemplate.js","sources":["/@dropins/storefront-quote-management/src/api/sendQuoteTemplateForReview/graphql/sendQuoteTemplateForReview.ts","/@dropins/storefront-quote-management/src/api/sendQuoteTemplateForReview/sendQuoteTemplateForReview.ts","/@dropins/storefront-quote-management/src/api/acceptQuoteTemplate/graphql/acceptQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/acceptQuoteTemplate/acceptQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/openQuoteTemplate/graphql/openQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/openQuoteTemplate/openQuoteTemplate.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 { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION = /* GraphQL */ `\n mutation SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION(\n $templateId: ID!\n $comment: String\n $name: String\n ) {\n submitNegotiableQuoteTemplateForReview(input: { template_id: $templateId, name: $name, comment: $comment }) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n ${NEGOTIABLE_QUOTE_TEMPLATE_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 '@/quote-management/api';\nimport { SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION } from './graphql/sendQuoteTemplateForReview';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface SendQuoteTemplateForReviewParams {\n templateId: string;\n name?: string;\n comment?: string;\n}\n\nexport const sendQuoteTemplateForReview = async (\n params: SendQuoteTemplateForReviewParams\n) => {\n if (!params.templateId) {\n throw new Error('Template ID is required');\n }\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(\n SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION,\n {\n variables: {\n templateId: params.templateId,\n name: params.name,\n comment: params.comment,\n },\n }\n );\n\n if (!results?.data?.submitNegotiableQuoteTemplateForReview) {\n throw new Error('No quote template data received');\n }\n\n const transformedData = transformQuoteTemplate(\n results.data.submitNegotiableQuoteTemplateForReview\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\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_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const ACCEPT_QUOTE_TEMPLATE_MUTATION = /* GraphQL */ `\n mutation ACCEPT_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {\n acceptNegotiableQuoteTemplate(input: { template_id: $templateId }) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n \n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\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 { ACCEPT_QUOTE_TEMPLATE_MUTATION } from './graphql/acceptQuoteTemplate';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface AcceptQuoteTemplateParams {\n templateId: string;\n}\n\nexport const acceptQuoteTemplate = async (\n params: AcceptQuoteTemplateParams\n) => {\n if (!params.templateId) {\n throw new Error('Template ID is required');\n }\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(ACCEPT_QUOTE_TEMPLATE_MUTATION, {\n variables: { templateId: params.templateId },\n });\n\n if (!results?.data?.acceptNegotiableQuoteTemplate) {\n throw new Error('No quote template data received');\n }\n\n const transformedData = transformQuoteTemplate(\n results.data.acceptNegotiableQuoteTemplate\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\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_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const OPEN_QUOTE_TEMPLATE_MUTATION = /* GraphQL */ `\n mutation OPEN_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {\n openNegotiableQuoteTemplate(input: { template_id: $templateId }) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_TEMPLATE_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 '@/quote-management/api';\nimport { OPEN_QUOTE_TEMPLATE_MUTATION } from './graphql/openQuoteTemplate';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface OpenQuoteTemplateParams {\n templateId: string;\n}\n\nexport const openQuoteTemplate = async (params: OpenQuoteTemplateParams) => {\n if (!params.templateId) {\n throw new Error('Template ID is required');\n }\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(OPEN_QUOTE_TEMPLATE_MUTATION, {\n variables: { templateId: params.templateId },\n });\n\n if (!results?.data?.openNegotiableQuoteTemplate) {\n throw new Error('No quote template data received');\n }\n\n const transformedData = transformQuoteTemplate(\n results.data.openNegotiableQuoteTemplate\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION","NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT","sendQuoteTemplateForReview","params","state","results","fetchGraphQl","_a","transformedData","transformQuoteTemplate","events","error","ACCEPT_QUOTE_TEMPLATE_MUTATION","acceptQuoteTemplate","OPEN_QUOTE_TEMPLATE_MUTATION","openQuoteTemplate"],"mappings":"wOAWO,MAAMA,EAAwD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUjEC,CAAkC;AAAA,ECAzBC,EAA6B,MACxCC,GACG,OACH,GAAI,CAACA,EAAO,WACV,MAAM,IAAI,MAAM,yBAAyB,EAG3C,GAAI,CAACC,EAAM,cACT,MAAM,IAAI,MAAM,cAAc,EAGhC,GAAI,CACF,MAAMC,EAAe,MAAMC,EACzBN,EACA,CACE,UAAW,CACT,WAAYG,EAAO,WACnB,KAAMA,EAAO,KACb,QAASA,EAAO,OAAA,CAClB,CACF,EAGF,GAAI,GAACI,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,wCAClB,MAAM,IAAI,MAAM,iCAAiC,EAGnD,MAAMC,EAAkBC,EACtBJ,EAAQ,KAAK,sCAAA,EAGf,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,yCAAyC,EAG3D,OAAAE,EAAO,KAAK,uCAAwC,CAClD,cAAeF,EACf,YAAaJ,EAAM,WAAA,CACpB,EAEMI,CACT,OAASG,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF,ECtDaC,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,I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ACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as d}from"@dropins/tools/event-bus.js";import{f as E,a as U}from"./transform-quote.js";import{s as I}from"./state.js";import{N as w}from"./NegotiableQuoteFragment.js";const f=`
|
|
4
|
+
mutation UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION(
|
|
5
|
+
$quoteUid: ID!
|
|
6
|
+
$items: [NegotiableQuoteItemQuantityInput!]!
|
|
7
|
+
) {
|
|
8
|
+
updateNegotiableQuoteQuantities(
|
|
9
|
+
input: {
|
|
10
|
+
quote_uid: $quoteUid
|
|
11
|
+
items: $items
|
|
12
|
+
}
|
|
13
|
+
) {
|
|
14
|
+
quote {
|
|
15
|
+
...NegotiableQuoteFragment
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
${w}
|
|
20
|
+
`,Q=async s=>{if(!I.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUid:o,items:e}=s;if(!o)throw new Error("Quote UID is required");if(!e||!Array.isArray(e)||e.length===0)throw new Error("Items array is required and must not be empty");for(const t of e){if(!t.quoteItemUid)throw new Error("Each item must have a quoteItemUid");if(typeof t.quantity!="number"||t.quantity<=0)throw new Error(`Invalid quantity for item ${t.quoteItemUid}: quantity must be a positive number`);if(!Number.isInteger(t.quantity))throw new Error(`Invalid quantity for item ${t.quoteItemUid}: quantity must be an integer`)}const a=e.map(t=>({quote_item_uid:t.quoteItemUid,quantity:t.quantity}));return E(f,{variables:{quoteUid:o,items:a}}).then(t=>{var u,i;const{errors:n}=t;if(n){const m=n.map(q=>q.message).join("; ");throw new Error(`Failed to update quote quantities: ${m}`)}const r=U((i=(u=t.data)==null?void 0:u.updateNegotiableQuoteQuantities)==null?void 0:i.quote);if(!r)throw new Error("Failed to transform quote data: Invalid response structure");return d.emit("quote-management/quantities-updated",{quote:r,input:{quoteUid:o,items:e}}),r})},_=`
|
|
21
|
+
mutation REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION(
|
|
22
|
+
$quoteUid: ID!
|
|
23
|
+
$quoteItemUids: [ID!]!
|
|
24
|
+
) {
|
|
25
|
+
removeNegotiableQuoteItems(
|
|
26
|
+
input: {
|
|
27
|
+
quote_uid: $quoteUid
|
|
28
|
+
quote_item_uids: $quoteItemUids
|
|
29
|
+
}
|
|
30
|
+
) {
|
|
31
|
+
quote {
|
|
32
|
+
...NegotiableQuoteFragment
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
${w}
|
|
37
|
+
`,y=async s=>{var u;if(!I.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUid:o,quoteItemUids:e}=s;if(!o)throw new Error("Quote UID is required");if(!Array.isArray(e)||e.length===0)throw new Error("At least one quote item UID is required");const a=await E(_,{variables:{quoteUid:o,quoteItemUids:e}}),{errors:t,data:n}=a;if(t!=null&&t.length){const i=t.map(m=>m.message).join("; ");throw new Error(`Failed to remove negotiable quote items: ${i}`)}const r=U((u=n==null?void 0:n.removeNegotiableQuoteItems)==null?void 0:u.quote);if(!r)throw new Error("Failed to transform quote data: Invalid response structure");return d.emit("quote-management/quote-items-removed",{quote:r,removedItemUids:e,input:s}),r},N=`
|
|
38
|
+
mutation SET_LINE_ITEM_NOTE_MUTATION($input: LineItemNoteInput!) {
|
|
39
|
+
setLineItemNote(input: $input) {
|
|
40
|
+
quote {
|
|
41
|
+
...NegotiableQuoteFragment
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
${w}
|
|
46
|
+
`,A=async s=>{if(!I.authenticated)throw new Error("Unauthorized");const{quoteUid:o,itemUid:e,note:a,quantity:t}=s;if(!o)throw new Error("Quote UID is required");if(!e)throw new Error("Item UID is required");if(!a)throw new Error("Note is required");const n={quote_uid:o,quote_item_uid:e,note:a.trim()};return E(N,{variables:{input:n}}).then(r=>{var m,q;const{errors:u}=r;if(u){const T=u.map(c=>c.message).join("; ");throw new Error(`Failed to set line item note: ${T}`)}const i=U((q=(m=r.data)==null?void 0:m.setLineItemNote)==null?void 0:q.quote);if(!i)throw new Error("Failed to transform quote data: Invalid response structure");return d.emit("quote-management/line-item-note-set",{quote:i,input:{quoteUid:o,itemUid:e,note:a,quantity:t}}),d.emit("quote-management/quote-data",{quote:i,permissions:I.permissions}),i})};export{y as r,A as s,Q as u};
|
|
47
|
+
//# sourceMappingURL=setLineItemNote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setLineItemNote.js","sources":["/@dropins/storefront-quote-management/src/api/updateQuantities/graphql/UpdateNegotiableQuoteQuantitiesMutation.ts","/@dropins/storefront-quote-management/src/api/updateQuantities/updateQuantities.ts","/@dropins/storefront-quote-management/src/api/removeNegotiableQuoteItems/graphql/RemoveNegotiableQuoteItemsMutation.ts","/@dropins/storefront-quote-management/src/api/removeNegotiableQuoteItems/removeNegotiableQuoteItems.ts","/@dropins/storefront-quote-management/src/api/setLineItemNote/graphql/SetLineItemNoteMutation.ts","/@dropins/storefront-quote-management/src/api/setLineItemNote/setLineItemNote.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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION = `\n mutation UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION(\n $quoteUid: ID!\n $items: [NegotiableQuoteItemQuantityInput!]!\n ) {\n updateNegotiableQuoteQuantities(\n input: {\n quote_uid: $quoteUid\n items: $items\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 '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/quote-management/lib/state';\nimport { UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION } from './graphql/UpdateNegotiableQuoteQuantitiesMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface QuantityItem {\n /** The unique ID of the quote item */\n quoteItemUid: string;\n /** The new quantity for the item (must be greater than 0) */\n quantity: number;\n}\n\nexport interface UpdateQuantitiesInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** Array of items with their new quantities */\n items: QuantityItem[];\n}\n\n/**\n * Updates the quantities of items in a negotiable quote.\n *\n * @param input - The input parameters for updating quantities\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.items - Array of items with their new quantities\n * @returns Promise that resolves to the updated quote model\n * @throws Error if validation fails or GraphQL operation fails\n *\n * @example\n * ```ts\n * const quote = await updateQuantities({\n * quoteUid: 'quote-123',\n * items: [\n * { quoteItemUid: 'item-1', quantity: 5 },\n * { quoteItemUid: 'item-2', quantity: 3 }\n * ]\n * });\n * ```\n */\nexport const updateQuantities = async (\n input: UpdateQuantitiesInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUid, items } = input;\n\n // Validate quoteUid\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate items array\n if (!items || !Array.isArray(items) || items.length === 0) {\n throw new Error('Items array is required and must not be empty');\n }\n\n // Validate each item\n for (const item of items) {\n if (!item.quoteItemUid) {\n throw new Error('Each item must have a quoteItemUid');\n }\n if (typeof item.quantity !== 'number' || item.quantity <= 0) {\n throw new Error(\n `Invalid quantity for item ${item.quoteItemUid}: quantity must be a positive number`\n );\n }\n // Ensure quantity is an integer\n if (!Number.isInteger(item.quantity)) {\n throw new Error(\n `Invalid quantity for item ${item.quoteItemUid}: quantity must be an integer`\n );\n }\n }\n\n // Transform items to snake_case for GraphQL\n const transformedItems = items.map((item) => ({\n quote_item_uid: item.quoteItemUid,\n quantity: item.quantity,\n }));\n\n return fetchGraphQl(UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION, {\n variables: {\n quoteUid,\n items: transformedItems,\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 update quote quantities: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.updateNegotiableQuoteQuantities?.quote\n );\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/quantities-updated', {\n quote: quoteData,\n input: { quoteUid, items },\n });\n\n return quoteData;\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';\n\nexport const REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION = `\n mutation REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION(\n $quoteUid: ID!\n $quoteItemUids: [ID!]!\n ) {\n removeNegotiableQuoteItems(\n input: {\n quote_uid: $quoteUid\n quote_item_uids: $quoteItemUids\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 '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/quote-management/lib/state';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION } from './graphql/RemoveNegotiableQuoteItemsMutation';\n\nexport interface RemoveNegotiableQuoteItemsInput {\n quoteUid: string;\n quoteItemUids: string[];\n}\n\nexport const removeNegotiableQuoteItems = async (\n input: RemoveNegotiableQuoteItemsInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUid, quoteItemUids } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!Array.isArray(quoteItemUids) || quoteItemUids.length === 0) {\n throw new Error('At least one quote item UID is required');\n }\n\n const response = await fetchGraphQl(REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION, {\n variables: {\n quoteUid,\n quoteItemUids,\n },\n });\n\n const { errors, data } = response;\n\n if (errors?.length) {\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(\n `Failed to remove negotiable quote items: ${errorMessages}`\n );\n }\n\n const quote = transformQuote(data?.removeNegotiableQuoteItems?.quote);\n\n if (!quote) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n events.emit('quote-management/quote-items-removed', {\n quote,\n removedItemUids: quoteItemUids,\n input,\n });\n\n return quote;\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';\n\nexport const SET_LINE_ITEM_NOTE_MUTATION = /* GraphQL */ `\n mutation SET_LINE_ITEM_NOTE_MUTATION($input: LineItemNoteInput!) {\n setLineItemNote(input: $input) {\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 '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SET_LINE_ITEM_NOTE_MUTATION } from './graphql/SetLineItemNoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport interface SetLineItemNoteInput {\n quoteUid: string;\n itemUid: string;\n note: string;\n quantity?: number;\n}\n\nexport const setLineItemNote = async (\n input: SetLineItemNoteInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n const { quoteUid, itemUid, note, quantity } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!itemUid) {\n throw new Error('Item UID is required');\n }\n\n if (!note) {\n throw new Error('Note is required');\n }\n\n // Build the mutation input\n const mutationInput: any = {\n quote_uid: quoteUid,\n quote_item_uid: itemUid,\n note: note.trim(),\n };\n\n return fetchGraphQl(SET_LINE_ITEM_NOTE_MUTATION, {\n variables: {\n input: mutationInput,\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 set line item note: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(response.data?.setLineItemNote?.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/line-item-note-set', {\n quote: quoteData,\n input: { quoteUid, itemUid, note, quantity },\n });\n\n // Also emit the general quote-data event to update all listeners\n events.emit('quote-management/quote-data', {\n quote: quoteData,\n permissions: state.permissions,\n });\n\n return quoteData;\n });\n};\n"],"names":["UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","updateQuantities","input","state","quoteUid","items","item","transformedItems","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","_b","_a","events","REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION","removeNegotiableQuoteItems","quoteItemUids","data","quote","SET_LINE_ITEM_NOTE_MUTATION","setLineItemNote","itemUid","note","quantity","mutationInput"],"mappings":"qLAWO,MAAMA,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBvDC,CAAyB;AAAA,ECuBhBC,EAAmB,MAC9BC,GACyC,CACzC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,KAAM,CAAE,SAAAC,EAAU,MAAAC,CAAA,EAAUH,EAG5B,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,uBAAuB,EAIzC,GAAI,CAACC,GAAS,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,SAAW,EACtD,MAAM,IAAI,MAAM,+CAA+C,EAIjE,UAAWC,KAAQD,EAAO,CACxB,GAAI,CAACC,EAAK,aACR,MAAM,IAAI,MAAM,oCAAoC,EAEtD,GAAI,OAAOA,EAAK,UAAa,UAAYA,EAAK,UAAY,EACxD,MAAM,IAAI,MACR,6BAA6BA,EAAK,YAAY,sCAAA,EAIlD,GAAI,CAAC,OAAO,UAAUA,EAAK,QAAQ,EACjC,MAAM,IAAI,MACR,6BAA6BA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BAAf,YAAAD,EAAgC,KAAK,EAEtE,GAAI,CAACF,EACH,MAAM,IAAI,MACR,4DAAA,EAKJ,OAAAI,EAAO,KAAK,sCAAuC,CACjD,MAAOJ,EACP,MAAO,CAAE,SAAAT,EAAU,QAAAqB,EAAS,KAAAC,EAAM,SAAAC,CAAA,CAAS,CAC5C,EAGDV,EAAO,KAAK,8BAA+B,CACzC,MAAOJ,EACP,YAAaV,EAAM,WAAA,CACpB,EAEMU,CACT,CAAC,CACH"}
|
package/chunks/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
var a=(e=>(e[e.TAX_EXCLUDED=1]="TAX_EXCLUDED",e[e.TAX_INCLUDED=2]="TAX_INCLUDED",e[e.TAX_INCLUDED_AND_EXCLUDED=3]="TAX_INCLUDED_AND_EXCLUDED",e))(a||{});const D={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1},r={quoteSummaryDisplayTotal:1,quoteSummaryMaxItems:10,quoteDisplaySettings:{zeroTax:!1,subtotal:a.TAX_INCLUDED,price:a.TAX_INCLUDED,shipping:a.TAX_INCLUDED,fullSummary:!1,grandTotal:!0},useConfigurableParentThumbnail:!0},l={authenticated:!1,permissions:D,config:r,initialized:!1,quoteDataLoaded:!1},u=new Proxy(l,{get:(e,t)=>e[t],set:(e,t,s)=>(e[t]=s,!0)});export{D,a as Q,r as a,u as s};
|
|
3
|
+
var a=(e=>(e[e.TAX_EXCLUDED=1]="TAX_EXCLUDED",e[e.TAX_INCLUDED=2]="TAX_INCLUDED",e[e.TAX_INCLUDED_AND_EXCLUDED=3]="TAX_INCLUDED_AND_EXCLUDED",e))(a||{});const D={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1},r={quoteSummaryDisplayTotal:1,quoteSummaryMaxItems:10,quoteDisplaySettings:{zeroTax:!1,subtotal:a.TAX_INCLUDED,price:a.TAX_INCLUDED,shipping:a.TAX_INCLUDED,fullSummary:!1,grandTotal:!0},useConfigurableParentThumbnail:!0},l={authenticated:!1,permissions:D,config:r,initialized:!1,quoteDataLoaded:!1,quoteDataInitialized:!1},u=new Proxy(l,{get:(e,t)=>e[t],set:(e,t,s)=>(e[t]=s,!0)});export{D,a as Q,r as a,u as s};
|
|
4
4
|
//# sourceMappingURL=state.js.map
|
package/chunks/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sources":["/@dropins/storefront-quote-management/src/data/models/store-config-model.ts","/@dropins/storefront-quote-management/src/lib/state.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 enum QuoteDisplayAmount {\n TAX_EXCLUDED = 1,\n TAX_INCLUDED = 2,\n TAX_INCLUDED_AND_EXCLUDED = 3,\n}\n\nexport interface StoreConfigModel {\n quoteSummaryDisplayTotal: number;\n quoteSummaryMaxItems: number;\n quoteDisplaySettings: {\n zeroTax: boolean;\n subtotal: QuoteDisplayAmount;\n price: QuoteDisplayAmount;\n shipping: QuoteDisplayAmount;\n fullSummary: boolean;\n grandTotal: boolean;\n };\n useConfigurableParentThumbnail: boolean;\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 {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { State } from '@/quote-management/types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n viewQuoteTemplates: false,\n manageQuoteTemplates: false,\n generateQuoteFromTemplate: false,\n};\n\nexport const DEFAULT_CONFIG: StoreConfigModel = {\n quoteSummaryDisplayTotal: 1,\n quoteSummaryMaxItems: 10,\n quoteDisplaySettings: {\n zeroTax: false,\n subtotal: QuoteDisplayAmount.TAX_INCLUDED,\n price: QuoteDisplayAmount.TAX_INCLUDED,\n shipping: QuoteDisplayAmount.TAX_INCLUDED,\n fullSummary: false,\n grandTotal: true,\n },\n useConfigurableParentThumbnail: true,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n config: DEFAULT_CONFIG,\n initialized: false,\n quoteDataLoaded: false,\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"],"names":["QuoteDisplayAmount","DEFAULT_PERMISSIONS","DEFAULT_CONFIG","_state","state","target","key","value"],"mappings":"AASO,IAAKA,GAAAA,IACVA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,0BAA4B,CAAA,EAA5B,4BAHUA,IAAAA,GAAA,CAAA,CAAA,ECML,MAAMC,EAAsB,CACjC,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAC7B,EAEaC,EAAmC,CAC9C,yBAA0B,EAC1B,qBAAsB,GACtB,qBAAsB,CACpB,QAAS,GACT,SAAUF,EAAmB,aAC7B,MAAOA,EAAmB,aAC1B,SAAUA,EAAmB,aAC7B,YAAa,GACb,WAAY,EAAA,EAEd,+BAAgC,EAClC,EAEMG,EAAgB,CACpB,cAAe,GACf,YAAaF,EACb,OAAQC,EACR,YAAa,GACb,gBAAiB,
|
|
1
|
+
{"version":3,"file":"state.js","sources":["/@dropins/storefront-quote-management/src/data/models/store-config-model.ts","/@dropins/storefront-quote-management/src/lib/state.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 enum QuoteDisplayAmount {\n TAX_EXCLUDED = 1,\n TAX_INCLUDED = 2,\n TAX_INCLUDED_AND_EXCLUDED = 3,\n}\n\nexport interface StoreConfigModel {\n quoteSummaryDisplayTotal: number;\n quoteSummaryMaxItems: number;\n quoteDisplaySettings: {\n zeroTax: boolean;\n subtotal: QuoteDisplayAmount;\n price: QuoteDisplayAmount;\n shipping: QuoteDisplayAmount;\n fullSummary: boolean;\n grandTotal: boolean;\n };\n useConfigurableParentThumbnail: boolean;\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 {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { State } from '@/quote-management/types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n viewQuoteTemplates: false,\n manageQuoteTemplates: false,\n generateQuoteFromTemplate: false,\n};\n\nexport const DEFAULT_CONFIG: StoreConfigModel = {\n quoteSummaryDisplayTotal: 1,\n quoteSummaryMaxItems: 10,\n quoteDisplaySettings: {\n zeroTax: false,\n subtotal: QuoteDisplayAmount.TAX_INCLUDED,\n price: QuoteDisplayAmount.TAX_INCLUDED,\n shipping: QuoteDisplayAmount.TAX_INCLUDED,\n fullSummary: false,\n grandTotal: true,\n },\n useConfigurableParentThumbnail: true,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n config: DEFAULT_CONFIG,\n initialized: false,\n quoteDataLoaded: false,\n quoteDataInitialized: false,\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"],"names":["QuoteDisplayAmount","DEFAULT_PERMISSIONS","DEFAULT_CONFIG","_state","state","target","key","value"],"mappings":"AASO,IAAKA,GAAAA,IACVA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,0BAA4B,CAAA,EAA5B,4BAHUA,IAAAA,GAAA,CAAA,CAAA,ECML,MAAMC,EAAsB,CACjC,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAC7B,EAEaC,EAAmC,CAC9C,yBAA0B,EAC1B,qBAAsB,GACtB,qBAAsB,CACpB,QAAS,GACT,SAAUF,EAAmB,aAC7B,MAAOA,EAAmB,aAC1B,SAAUA,EAAmB,aAC7B,YAAa,GACb,WAAY,EAAA,EAEd,+BAAgC,EAClC,EAEMG,EAAgB,CACpB,cAAe,GACf,YAAaF,EACb,OAAQC,EACR,YAAa,GACb,gBAAiB,GACjB,qBAAsB,EACxB,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAK,CAACE,EAAQC,IACLD,EAAOC,CAAkB,EAElC,IAAK,CAACD,EAAQC,EAAKC,KACjBF,EAAOC,CAAkB,EAAIC,EACtB,GAEX,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{t as y}from"./transform-quote.js";function
|
|
3
|
+
import{t as y}from"./transform-quote.js";var i=(r=>(r.ACTIVE="Active",r.IN_REVIEW="In Review",r.INACTIVE="Inactive",r.SUBMITTED="Submitted",r.PENDING="Pending",r.CLOSED="Closed",r.OPEN="Open",r.UPDATED="Updated",r.EDITED="Edited",r.NEW="New",r.DRAFT="Draft",r.DECLINED="Declined",r.CANCELED="Canceled",r.EXPIRED="Expired",r))(i||{});function I(r){var o,_,s,e,l;return r?{id:r.template_id,uid:r.uid,name:r.name,createdAt:r.created_at,updatedAt:r.updated_at,expirationDate:r.expiration_date,status:r.status,salesRepName:r.sales_rep_name,buyer:{firstname:r.buyer.firstname,lastname:r.buyer.lastname},comments:(o=r.comments)==null?void 0:o.map(n=>{var a;return{uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},text:n.text,attachments:(a=n.attachments)==null?void 0:a.map(d=>({name:d.name,url:d.url}))}}),prices:r.prices&&{subtotalExcludingTax:r.prices.subtotal_excluding_tax&&{value:r.prices.subtotal_excluding_tax.value,currency:r.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:r.prices.subtotal_including_tax&&{value:r.prices.subtotal_including_tax.value,currency:r.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:r.prices.subtotal_with_discount_excluding_tax&&{value:r.prices.subtotal_with_discount_excluding_tax.value,currency:r.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(_=r.prices.applied_taxes)==null?void 0:_.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})),grandTotal:r.prices.grand_total&&{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency}},history:(s=r.history)==null?void 0:s.map(n=>({uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},changeType:n.change_type,changes:n.changes})),items:((e=r.items)==null?void 0:e.map(n=>{var a,d,t,g,p,E;return{uid:n.uid,product:{uid:n.product.uid,sku:n.product.sku,name:n.product.name},quantity:n.quantity,prices:{originalItemPrice:{value:n.prices.original_item_price.value,currency:n.prices.original_item_price.currency},rowTotal:{value:n.prices.row_total.value,currency:n.prices.row_total.currency}},catalogDiscount:n.prices.catalog_discount&&{amountOff:n.prices.catalog_discount.amount_off,percentOff:n.prices.catalog_discount.percent_off},discounts:(d=(a=n.prices)==null?void 0:a.discounts)==null?void 0:d.map(c=>({label:c.label,value:c.value,amount:{value:c.amount.value,currency:c.amount.currency}})),noteFromBuyer:(t=n.note_from_buyer)==null?void 0:t.map(c=>({createdAt:c.created_at,creatorId:c.creator_id,creatorType:c.creator_type,negotiableQuoteItemUid:c.negotiable_quote_template_item_uid,note:c.note,noteUid:c.note_uid})),noteFromSeller:(g=n.note_from_seller)==null?void 0:g.map(c=>({createdAt:c.created_at,creatorId:c.creator_id,creatorType:c.creator_type,negotiableQuoteItemUid:c.negotiable_quote_template_item_uid,note:c.note,noteUid:c.note_uid})),configurableOptions:(p=n.configurable_options)==null?void 0:p.map(c=>({optionLabel:c.option_label,valueLabel:c.value_label})),bundleOptions:(E=n.bundle_options)==null?void 0:E.map(c=>({label:c.label,values:c.values.map(u=>({label:u.label,quantity:u.quantity,originalPrice:{value:u.original_price.value,currency:u.original_price.currency},price:{value:u.priceV2.value,currency:u.priceV2.currency}}))}))}}))||[],shippingAddresses:(l=r.shipping_addresses)==null?void 0:l.map(n=>({uid:n.uid,firstname:n.firstname,lastname:n.lastname,company:n.company,street:n.street,city:n.city,postcode:n.postcode,country:{code:n.country.code,label:n.country.label},telephone:n.telephone,region:n.region?{code:n.region.code,label:n.region.label,regionId:n.region.region_id}:void 0})),canAccept:[i.SUBMITTED,i.PENDING,i.EDITED,i.OPEN].includes(r.status),canDelete:[i.DECLINED,i.CANCELED,i.EXPIRED].includes(r.status),canReopen:[i.DECLINED,i.CANCELED,i.EXPIRED].includes(r.status),canCancel:[i.ACTIVE,i.SUBMITTED,i.PENDING,i.EDITED,i.OPEN,i.UPDATED].includes(r.status),canSendForReview:[i.DRAFT,i.NEW].includes(r.status),canGenerateQuoteFromTemplate:[i.ACTIVE].includes(r.status)}:null}function v(r){var s;if(!r)return null;const o={items:((s=r.items)==null?void 0:s.map(e=>({id:e.template_id,uid:"TBD",name:e.name,createdAt:"0000-00-00 00:00:00",updatedAt:"0000-00-00 00:00:00",status:e.status,state:e.state,prices:{grandTotal:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:e.min_negotiated_grand_total,currency:"USD"}},lastSharedAt:e.last_shared_at,lastOrderedAt:"0000-00-00 00:00:00",expirationDate:"0000-00-00 00:00:00",ordersPlaced:e.orders_placed,canGenerateQuoteFromTemplate:[i.ACTIVE].includes(e.status)})))||[],pageInfo:{currentPage:r.page_info.current_page,pageSize:r.page_info.page_size,totalPages:r.page_info.total_pages},totalCount:r.total_count,sortFields:r.sort_fields?{default:r.sort_fields.default,options:r.sort_fields.options}:void 0},_=y(o);return{...o,paginationInfo:_||void 0}}export{i as N,I as a,v as t};
|
|
4
4
|
//# sourceMappingURL=transform-quote-template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-quote-template.js","sources":["/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.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 {\n NegotiableQuoteTemplateModel,\n NegotiableQuoteTemplatesListModel,\n} from '../models/negotiable-quote-template-model';\nimport { transformPaginationInfo } from './transform-quote';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\n id: templateData.template_id,\n uid: templateData.uid,\n name: templateData.name,\n createdAt: templateData.created_at,\n updatedAt: templateData.updated_at,\n expirationDate: templateData.expiration_date,\n status: templateData.status,\n salesRepName: templateData.sales_rep_name,\n buyer: {\n firstname: templateData.buyer.firstname,\n lastname: templateData.buyer.lastname,\n },\n comments: templateData.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 text: comment.text,\n attachments: comment.attachments?.map((a: any) => ({\n name: a.name,\n url: a.url,\n })),\n })),\n prices: templateData.prices && {\n subtotalExcludingTax: templateData.prices.subtotal_excluding_tax && {\n value: templateData.prices.subtotal_excluding_tax.value,\n currency: templateData.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: templateData.prices.subtotal_including_tax && {\n value: templateData.prices.subtotal_including_tax.value,\n currency: templateData.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: templateData.prices\n .subtotal_with_discount_excluding_tax && {\n value: templateData.prices.subtotal_with_discount_excluding_tax.value,\n currency:\n templateData.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: templateData.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: templateData.prices.grand_total && {\n value: templateData.prices.grand_total.value,\n currency: templateData.prices.grand_total.currency,\n },\n },\n history: templateData.history?.map((h: any) => ({\n uid: h.uid,\n createdAt: h.created_at,\n author: {\n firstname: h.author.firstname,\n lastname: h.author.lastname,\n },\n changeType: h.change_type,\n changes: h.changes,\n })),\n items: templateData.items?.map((item: any) => ({\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\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 catalogDiscount: item.prices.catalog_discount && {\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: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })),\n noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_template_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_template_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n })) || [],\n shippingAddresses: templateData.shipping_addresses?.map((address: any) => ({\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n region: address.region ? {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n } : undefined,\n })),\n // Calculate permissions based on status\n canAccept: ['Submitted', 'Pending', 'Edited', 'Open'].includes(templateData.status),\n canDelete: ['Declined', 'Canceled', 'Expired'].includes(templateData.status),\n canReopen: ['Declined', 'Canceled', 'Expired'].includes(templateData.status),\n canCancel: ['Active', 'Submitted', 'Pending', 'Edited', 'Open', 'Updated'].includes(templateData.status),\n canSendForReview: ['Draft', 'New'].includes(templateData.status),\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n const transformedModel = {\n items: templatesData.items?.map((template: any) => ({\n id: template.template_id,\n uid: 'TBD',\n name: template.name,\n createdAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n updatedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n status: template.status,\n state: template.state,\n prices: {\n grandTotal: {\n value: 0, // TODO: missing from GraphQL API\n currency: 'USD', // TODO: missing from GraphQL API\n },\n minNegotiatedGrandTotal: {\n value: template.min_negotiated_grand_total,\n currency: 'USD', // TODO: use the same from grand total when available\n },\n },\n lastSharedAt: template.last_shared_at,\n lastOrderedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n expirationDate: '0000-00-00 00:00:00', // TODO: broken in GraphQL API\n ordersPlaced: template.orders_placed,\n })) || [],\n pageInfo: {\n currentPage: templatesData.page_info.current_page,\n pageSize: templatesData.page_info.page_size,\n totalPages: templatesData.page_info.total_pages,\n },\n totalCount: templatesData.total_count,\n sortFields: templatesData.sort_fields ? {\n default: templatesData.sort_fields.default,\n options: templatesData.sort_fields.options,\n } : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}"],"names":["transformQuoteTemplate","templateData","_a","comment","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","transformQuoteTemplatesList","templatesData","transformedModel","template","paginationInfo","transformPaginationInfo"],"mappings":"yCAeO,SAASA,EACZC,EACmC,eACnC,OAAKA,EAIE,CACH,GAAIA,EAAa,YACjB,IAAKA,EAAa,IAClB,KAAMA,EAAa,KACnB,UAAWA,EAAa,WACxB,UAAWA,EAAa,WACxB,eAAgBA,EAAa,gBAC7B,OAAQA,EAAa,OACrB,aAAcA,EAAa,eAC3B,MAAO,CACH,UAAWA,EAAa,MAAM,UAC9B,SAAUA,EAAa,MAAM,QAAA,EAEjC,UAAUC,EAAAD,EAAa,WAAb,YAAAC,EAAuB,IAAKC,GAAA,OAAkB,OACpD,IAAKA,EAAQ,IACb,UAAWA,EAAQ,WACnB,OAAQ,CACJ,UAAWA,EAAQ,OAAO,UAC1B,SAAUA,EAAQ,OAAO,QAAA,EAE7B,KAAMA,EAAQ,KACd,aAAaD,EAAAC,EAAQ,cAAR,YAAAD,EAAqB,IAAK,IAAY,CAC/C,KAAM,EAAE,KACR,IAAK,EAAE,GAAA,GACT,IAEN,OAAQ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Ac,YAAc,CACpC,QAASA,EAAc,YAAY,QACnC,QAASA,EAAc,YAAY,OAAA,EACnC,MAAA,EAIFG,EAAiBC,EAAwBH,CAAgB,EAE/D,MAAO,CACH,GAAGA,EACH,eAAgBE,GAAkB,MAAA,CAE1C"}
|
|
1
|
+
{"version":3,"file":"transform-quote-template.js","sources":["/@dropins/storefront-quote-management/src/data/models/negotiable-quote-template-model.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.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 {\n Currency,\n ItemNote,\n PaginationInfo,\n ShippingAddress,\n ConfigurableOption,\n BundleOption,\n} from './negotiable-quote-model';\n\nexport interface NegotiableQuoteTemplateModel {\n id: string;\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n expirationDate?: string;\n status: NegotiableQuoteTemplateStatus;\n salesRepName: string;\n buyer: {\n firstname: string;\n lastname: string;\n };\n comments?: QuoteTemplateComment[];\n history?: QuoteTemplateHistoryEntry[];\n prices: {\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n grandTotal?: Currency;\n appliedTaxes?: {\n amount: Currency;\n label: string;\n }[];\n };\n items: QuoteTemplateCartItem[];\n shippingAddresses?: ShippingAddress[];\n referenceDocuments?: {\n uid: string;\n name: string;\n url: string;\n }[];\n // Template-specific fields\n quantityThresholds?: {\n min?: number;\n max?: number;\n };\n canAccept: boolean;\n canDelete: boolean;\n canReopen: boolean;\n canCancel: boolean;\n canSendForReview: boolean;\n canGenerateQuoteFromTemplate: boolean;\n}\n\nexport enum NegotiableQuoteTemplateStatus {\n ACTIVE = 'Active',\n IN_REVIEW = 'In Review',\n INACTIVE = 'Inactive',\n SUBMITTED = 'Submitted',\n PENDING = 'Pending',\n CLOSED = 'Closed',\n OPEN = 'Open',\n UPDATED = 'Updated',\n EDITED = 'Edited',\n NEW = 'New',\n DRAFT = 'Draft',\n DECLINED = 'Declined',\n CANCELED = 'Canceled',\n EXPIRED = 'Expired',\n}\n\nexport interface QuoteTemplateCartItem {\n uid?: string;\n product: {\n uid: string;\n sku: string;\n name: string;\n };\n quantity: number;\n prices: {\n originalItemPrice: Currency;\n rowTotal: Currency;\n };\n catalogDiscount?: {\n amountOff: number;\n percentOff: number;\n };\n discounts?: {\n label: string;\n value: string;\n amount: Currency;\n }[];\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n configurableOptions?: ConfigurableOption[];\n bundleOptions?: BundleOption[];\n}\n\nexport interface QuoteTemplateComment {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n}\n\nexport interface QuoteTemplateHistoryEntry {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: string;\n changes: any; // Similar structure to NegotiableQuoteHistoryEntry\n}\n\n// List model for getQuoteTemplates\nexport interface NegotiableQuoteTemplatesListModel {\n items: NegotiableQuoteTemplateListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteTemplateListEntry {\n id: string;\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteTemplateStatus;\n state: 'active' | 'inactive' | 'in_review';\n lastSharedAt: string;\n lastOrderedAt: string;\n expirationDate: string;\n ordersPlaced: number;\n prices: {\n grandTotal: Currency;\n minNegotiatedGrandTotal: Currency;\n };\n canGenerateQuoteFromTemplate?: boolean;\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 {\n NegotiableQuoteTemplateModel,\n NegotiableQuoteTemplatesListModel,\n NegotiableQuoteTemplateStatus,\n} from '../models/negotiable-quote-template-model';\nimport { transformPaginationInfo } from './transform-quote';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\n id: templateData.template_id,\n uid: templateData.uid,\n name: templateData.name,\n createdAt: templateData.created_at,\n updatedAt: templateData.updated_at,\n expirationDate: templateData.expiration_date,\n status: templateData.status,\n salesRepName: templateData.sales_rep_name,\n buyer: {\n firstname: templateData.buyer.firstname,\n lastname: templateData.buyer.lastname,\n },\n comments: templateData.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 text: comment.text,\n attachments: comment.attachments?.map((a: any) => ({\n name: a.name,\n url: a.url,\n })),\n })),\n prices: templateData.prices && {\n subtotalExcludingTax: templateData.prices.subtotal_excluding_tax && {\n value: templateData.prices.subtotal_excluding_tax.value,\n currency: templateData.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: templateData.prices.subtotal_including_tax && {\n value: templateData.prices.subtotal_including_tax.value,\n currency: templateData.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: templateData.prices\n .subtotal_with_discount_excluding_tax && {\n value: templateData.prices.subtotal_with_discount_excluding_tax.value,\n currency:\n templateData.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: templateData.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: templateData.prices.grand_total && {\n value: templateData.prices.grand_total.value,\n currency: templateData.prices.grand_total.currency,\n },\n },\n history: templateData.history?.map((h: any) => ({\n uid: h.uid,\n createdAt: h.created_at,\n author: {\n firstname: h.author.firstname,\n lastname: h.author.lastname,\n },\n changeType: h.change_type,\n changes: h.changes,\n })),\n items: templateData.items?.map((item: any) => ({\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\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 catalogDiscount: item.prices.catalog_discount && {\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: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })),\n noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_template_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_template_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n })) || [],\n shippingAddresses: templateData.shipping_addresses?.map((address: any) => ({\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n region: address.region ? {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n } : undefined,\n })),\n // Calculate permissions based on status\n canAccept: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.PENDING,\n NegotiableQuoteTemplateStatus.EDITED,\n NegotiableQuoteTemplateStatus.OPEN,\n ].includes(templateData.status),\n canDelete: [\n NegotiableQuoteTemplateStatus.DECLINED,\n NegotiableQuoteTemplateStatus.CANCELED,\n NegotiableQuoteTemplateStatus.EXPIRED,\n ].includes(templateData.status),\n canReopen: [\n NegotiableQuoteTemplateStatus.DECLINED,\n NegotiableQuoteTemplateStatus.CANCELED,\n NegotiableQuoteTemplateStatus.EXPIRED,\n ].includes(templateData.status),\n canCancel: [\n NegotiableQuoteTemplateStatus.ACTIVE,\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.PENDING,\n NegotiableQuoteTemplateStatus.EDITED,\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.UPDATED,\n ].includes(templateData.status),\n canSendForReview: [\n NegotiableQuoteTemplateStatus.DRAFT,\n NegotiableQuoteTemplateStatus.NEW,\n ].includes(templateData.status),\n canGenerateQuoteFromTemplate: [\n NegotiableQuoteTemplateStatus.ACTIVE,\n ].includes(templateData.status),\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n const transformedModel = {\n items: templatesData.items?.map((template: any) => ({\n id: template.template_id,\n uid: 'TBD',\n name: template.name,\n createdAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n updatedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n status: template.status,\n state: template.state,\n prices: {\n grandTotal: {\n value: 0, // TODO: missing from GraphQL API\n currency: 'USD', // TODO: missing from GraphQL API\n },\n minNegotiatedGrandTotal: {\n value: template.min_negotiated_grand_total,\n currency: 'USD', // TODO: use the same from grand total when available\n },\n },\n lastSharedAt: template.last_shared_at,\n lastOrderedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n expirationDate: '0000-00-00 00:00:00', // TODO: broken in GraphQL API\n ordersPlaced: template.orders_placed,\n canGenerateQuoteFromTemplate: [NegotiableQuoteTemplateStatus.ACTIVE].includes(template.status),\n })) || [],\n pageInfo: {\n currentPage: templatesData.page_info.current_page,\n pageSize: templatesData.page_info.page_size,\n totalPages: templatesData.page_info.total_pages,\n },\n totalCount: templatesData.total_count,\n sortFields: templatesData.sort_fields ? {\n default: templatesData.sort_fields.default,\n options: templatesData.sort_fields.options,\n } : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}"],"names":["NegotiableQuoteTemplateStatus","transformQuoteTemplate","templateData","_a","comment","a","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","transformQuoteTemplatesList","templatesData","transformedModel","template","paginationInfo","transformPaginationInfo"],"mappings":"yCA+DO,IAAKA,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,IAAM,MACNA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UAdAA,IAAAA,GAAA,CAAA,CAAA,EC/CL,SAASC,EACZC,EACmC,eACnC,OAAKA,EAIE,CACH,GAAIA,EAAa,YACjB,IAAKA,EAAa,IAClB,KAAMA,EAAa,KACnB,UAAWA,EAAa,WACxB,UAAWA,EAAa,WACxB,eAAgBA,EAAa,gBAC7B,OAAQA,EAAa,OACrB,aAAcA,EAAa,eAC3B,MAAO,CACH,UAAWA,EAAa,MAAM,UAC9B,SAAUA,EAAa,MAAM,QAAA,EAEjC,UAAUC,EAAAD,EAA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