@dropins/storefront-quote-management 0.0.1-alpha20 → 0.0.1-alpha22

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.
Files changed (67) hide show
  1. package/api/getStoreConfig/getStoreConfig.d.ts +4 -0
  2. package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +10 -0
  3. package/api/getStoreConfig/index.d.ts +10 -0
  4. package/api/index.d.ts +1 -0
  5. package/api.js +33 -19
  6. package/api.js.map +1 -1
  7. package/chunks/ChevronDown.js +4 -0
  8. package/chunks/ChevronDown.js.map +1 -0
  9. package/chunks/NegotiableQuoteFragment.js +129 -0
  10. package/chunks/NegotiableQuoteFragment.js.map +1 -1
  11. package/chunks/QuoteHistoryLog.js +1 -1
  12. package/chunks/QuoteHistoryLog.js.map +1 -1
  13. package/chunks/dateUtils.js +4 -0
  14. package/chunks/dateUtils.js.map +1 -0
  15. package/chunks/getQuoteTemplates.js +1 -1
  16. package/chunks/getQuoteTemplates.js.map +1 -1
  17. package/chunks/negotiableQuotes.js +1 -1
  18. package/chunks/negotiableQuotes.js.map +1 -1
  19. package/chunks/renameNegotiableQuote.js +1 -1
  20. package/chunks/renameNegotiableQuote.js.map +1 -1
  21. package/chunks/state.js +1 -1
  22. package/chunks/state.js.map +1 -1
  23. package/chunks/transform-quote.js +4 -0
  24. package/chunks/transform-quote.js.map +1 -0
  25. package/chunks/updateQuantities.js +1 -1
  26. package/chunks/updateQuantities.js.map +1 -1
  27. package/chunks/uploadFile.js +1 -1
  28. package/chunks/uploadFile.js.map +1 -1
  29. package/components/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +0 -1
  30. package/containers/ItemsQuoted.js +1 -1
  31. package/containers/ManageNegotiableQuote.js +1 -1
  32. package/containers/ManageNegotiableQuote.js.map +1 -1
  33. package/containers/OrderSummary.js +1 -1
  34. package/containers/OrderSummary.js.map +1 -1
  35. package/containers/QuoteHistoryLog.js +1 -1
  36. package/containers/QuoteSummaryList/QuoteSummaryList.d.ts +51 -0
  37. package/containers/QuoteSummaryList/index.d.ts +11 -0
  38. package/containers/QuoteSummaryList.d.ts +3 -0
  39. package/containers/QuoteSummaryList.js +4 -0
  40. package/containers/QuoteSummaryList.js.map +1 -0
  41. package/containers/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +0 -4
  42. package/containers/QuoteTemplatesListTable.js +1 -1
  43. package/containers/QuoteTemplatesListTable.js.map +1 -1
  44. package/containers/QuotesListTable.js +1 -1
  45. package/containers/QuotesListTable.js.map +1 -1
  46. package/containers/RequestNegotiableQuoteForm.js +1 -1
  47. package/containers/RequestNegotiableQuoteForm.js.map +1 -1
  48. package/containers/index.d.ts +1 -0
  49. package/data/models/__fixtures__/negotiableQuoteModel.d.ts +1 -0
  50. package/data/models/__fixtures__/storeConfigModel.d.ts +5 -0
  51. package/data/models/negotiable-quote-model.d.ts +33 -5
  52. package/data/models/store-config-model.d.ts +5 -2
  53. package/data/transforms/__fixtures__/negotiableQuoteData.d.ts +216 -0
  54. package/data/transforms/__fixtures__/storeConfigData.d.ts +31 -0
  55. package/data/transforms/index.d.ts +1 -0
  56. package/data/transforms/transform-store-config.d.ts +4 -0
  57. package/hooks/useQuoteSummaryData.d.ts +10 -0
  58. package/i18n/en_US.json.d.ts +13 -2
  59. package/lib/configurationTransformers.d.ts +27 -0
  60. package/lib/itemFormatters.d.ts +47 -0
  61. package/lib/priceCalculators.d.ts +41 -0
  62. package/package.json +1 -1
  63. package/render.js +1 -1
  64. package/render.js.map +1 -1
  65. package/utils/dateUtils.d.ts +6 -0
  66. package/chunks/fetch-graphql.js +0 -4
  67. package/chunks/fetch-graphql.js.map +0 -1
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as n,jsx as l}from"@dropins/tools/preact-jsx-runtime.js";import{useState as $,useEffect as D}from"@dropins/tools/preact-compat.js";import{events as U}from"@dropins/tools/event-bus.js";import{getGlobalLocale as Q,classes as q}from"@dropins/tools/lib.js";/* empty css */import{useText as P}from"@dropins/tools/i18n.js";function f(s,p){return p.format(new Date(s))}function I(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(s){return console.warn("Failed to detect user timezone, falling back to UTC:",s),"UTC"}}const k=({className:s,children:p,quoteData:o,...v})=>{const c=Q()||"en-US",t=P({quoteCreated:"historyLog.changeTypes.created",quoteUpdated:"historyLog.changeTypes.updated",statusChanged:"historyLog.changeTypes.statusChanged",commentAdded:"historyLog.changeTypes.commentAdded",expirationChanged:"historyLog.changeTypes.expirationChanged",buyerNoteAdded:"historyLog.noteTypes.buyerNoteAdded",sellerNoteAdded:"historyLog.noteTypes.sellerNoteAdded",buyerLabel:"historyLog.authorLabels.buyer",sellerLabel:"historyLog.authorLabels.seller",commentDetail:"historyLog.changeDetails.comment",statusChangedFromTo:"historyLog.changeDetails.statusChangedFromTo",statusSetTo:"historyLog.changeDetails.statusSetTo",expirationChangedFromTo:"historyLog.changeDetails.expirationChangedFromTo",expirationSetTo:"historyLog.changeDetails.expirationSetTo",totalChangedFromTo:"historyLog.changeDetails.totalChangedFromTo",customChange:"historyLog.changeDetails.customChange",productsRemovedFromCatalog:"historyLog.changeDetails.productsRemovedFromCatalog",productsRemovedFromQuote:"historyLog.changeDetails.productsRemovedFromQuote",noDetailsAvailable:"historyLog.changeDetails.noDetailsAvailable",emptyState:"historyLog.emptyState",never:"dateUtils.never"}),h=new Intl.DateTimeFormat(c,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:I()}),x=e=>{switch(e){case"CREATED":return t.quoteCreated;case"UPDATED":return t.quoteUpdated;case"STATUS_CHANGED":return t.statusChanged;case"COMMENT_ADDED":return t.commentAdded;case"EXPIRATION_CHANGED":return t.expirationChanged;default:return e.replace(/_/g," ").toLowerCase().replace(/\b\w/g,r=>r.toUpperCase())}},S=e=>{var a,u,T,y,m,C,L,N,F,_,b,w;const r=[];if((a=e==null?void 0:e.commentAdded)!=null&&a.comment&&r.push(t.commentDetail.replace("{comment}",e.commentAdded.comment)),(u=e==null?void 0:e.statuses)!=null&&u.changes&&e.statuses.changes.forEach(i=>{i.oldStatus&&i.newStatus?r.push(t.statusChangedFromTo.replace("{oldStatus}",i.oldStatus).replace("{newStatus}",i.newStatus)):i.newStatus&&r.push(t.statusSetTo.replace("{newStatus}",i.newStatus))}),(T=e==null?void 0:e.expiration)!=null&&T.newExpiration&&((y=e==null?void 0:e.expiration)!=null&&y.oldExpiration)){const i=f(e.expiration.newExpiration,h),d=f(e.expiration.oldExpiration,h);r.push(t.expirationChangedFromTo.replace("{oldExpiration}",d).replace("{newExpiration}",i))}else if((m=e==null?void 0:e.expiration)!=null&&m.newExpiration){const i=f(e.expiration.newExpiration,h);r.push(t.expirationSetTo.replace("{newExpiration}",i))}if((C=e==null?void 0:e.total)!=null&&C.newPrice&&((L=e==null?void 0:e.total)!=null&&L.oldPrice)){const i=`${e.total.newPrice.currency} ${e.total.newPrice.value}`,d=`${e.total.oldPrice.currency} ${e.total.oldPrice.value}`;r.push(t.totalChangedFromTo.replace("{oldTotal}",d).replace("{newTotal}",i))}if((N=e==null?void 0:e.customChanges)!=null&&N.title&&((F=e==null?void 0:e.customChanges)!=null&&F.old_value)&&((_=e==null?void 0:e.customChanges)!=null&&_.new_value)&&r.push(t.customChange.replace("{title}",e.customChanges.title).replace("{oldValue}",e.customChanges.old_value).replace("{newValue}",e.customChanges.new_value)),(b=e==null?void 0:e.productsRemoved)!=null&&b.productsRemovedFromCatalog&&e.productsRemoved.productsRemovedFromCatalog.length>0&&r.push(t.productsRemovedFromCatalog.replace("{products}",e.productsRemoved.productsRemovedFromCatalog.join(", "))),(w=e==null?void 0:e.productsRemoved)!=null&&w.productsRemovedFromQuote&&e.productsRemoved.productsRemovedFromQuote.length>0){const i=e.productsRemoved.productsRemovedFromQuote.map(d=>d.name||d.sku||d.uid).join(", ");r.push(t.productsRemovedFromQuote.replace("{products}",i))}return r.length>0?r:[t.noDetailsAvailable]},E=(()=>{const e=[],r=(a,u,T,y)=>{a&&Array.isArray(a)&&a.forEach(m=>{m&&m.note&&m.note.trim()&&e.push({...m,type:u,productName:y.product.name,productSku:y.product.sku,authorName:T})})};return o!=null&&o.items&&o.items.forEach(a=>{r(a.noteFromBuyer,"buyer",`${o.buyer.firstname} ${o.buyer.lastname} ${t.buyerLabel}`,a),r(a.noteFromSeller,"seller",`${o.salesRepName} ${t.sellerLabel}`,a)}),e})(),A=((o==null?void 0:o.history)||[]).map(e=>({...e,entryType:"history"})),R=E.map(e=>({...e,entryType:"note"})),g=[...A,...R];return n("div",{...v,className:q(["quote-management-quote-history-log",s]),children:[g.length>0?l("div",{className:"quote-management-quote-history-log__entries",children:g.map((e,r)=>n("div",{className:"quote-management-quote-history-log__entry",children:[n("div",{className:"quote-management-quote-history-log__entry-header",children:[n("div",{className:"quote-management-quote-history-log__entry-meta",children:[l("span",{className:"quote-management-quote-history-log__entry-date",children:h.format(new Date(e.createdAt))}),l("span",{className:"quote-management-quote-history-log__entry-author",children:e.entryType==="history"?`by ${e.author.firstname} ${e.author.lastname} ${e.author.firstname===(o==null?void 0:o.buyer.firstname)&&e.author.lastname===(o==null?void 0:o.buyer.lastname)?t.buyerLabel:t.sellerLabel}`:`by ${e.authorName}`})]}),l("div",{className:"quote-management-quote-history-log__entry-type",children:e.entryType==="history"?x(e.changeType):e.type==="buyer"?t.buyerNoteAdded:t.sellerNoteAdded})]}),l("div",{className:"quote-management-quote-history-log__entry-changes",children:e.entryType==="history"?S(e.changes).map((a,u)=>l("div",{className:"quote-management-quote-history-log__entry-change",children:a},u)):n("div",{className:"quote-management-quote-history-log__entry-change",children:[n("div",{children:[e.productName,"(",e.productSku,")"]}),n("div",{children:['"',e.note,'"']})]})})]},e.entryType==="history"?e.uid:`${e.noteUid}-${r}`))}):l("div",{className:"quote-management-quote-history-log__empty",children:t.emptyState}),p]})},Z=({quoteData:s,...p})=>{const[o,v]=$(s);return D(()=>{const c=U.on("quote-management/quote-data",t=>{v(t.quote)},{eager:!0});return()=>c==null?void 0:c.off()},[]),o?l("div",{...p,children:l(k,{quoteData:o})}):null};export{Z as Q};
3
+ import{jsxs as d,jsx as l}from"@dropins/tools/preact-jsx-runtime.js";import{useState as $,useEffect as Q}from"@dropins/tools/preact-compat.js";import{events as q}from"@dropins/tools/event-bus.js";import{getGlobalLocale as D,classes as U}from"@dropins/tools/lib.js";import{g as P,a as g}from"./dateUtils.js";/* empty css */import{useText as I}from"@dropins/tools/i18n.js";const j=({className:h,children:v,quoteData:o,...T})=>{const u=D()||"en-US",t=I({quoteCreated:"historyLog.changeTypes.created",quoteUpdated:"historyLog.changeTypes.updated",statusChanged:"historyLog.changeTypes.statusChanged",commentAdded:"historyLog.changeTypes.commentAdded",expirationChanged:"historyLog.changeTypes.expirationChanged",buyerNoteAdded:"historyLog.noteTypes.buyerNoteAdded",sellerNoteAdded:"historyLog.noteTypes.sellerNoteAdded",buyerLabel:"historyLog.authorLabels.buyer",sellerLabel:"historyLog.authorLabels.seller",commentDetail:"historyLog.changeDetails.comment",statusChangedFromTo:"historyLog.changeDetails.statusChangedFromTo",statusSetTo:"historyLog.changeDetails.statusSetTo",expirationChangedFromTo:"historyLog.changeDetails.expirationChangedFromTo",expirationSetTo:"historyLog.changeDetails.expirationSetTo",totalChangedFromTo:"historyLog.changeDetails.totalChangedFromTo",customChange:"historyLog.changeDetails.customChange",productsRemovedFromCatalog:"historyLog.changeDetails.productsRemovedFromCatalog",productsRemovedFromQuote:"historyLog.changeDetails.productsRemovedFromQuote",noDetailsAvailable:"historyLog.changeDetails.noDetailsAvailable",emptyState:"historyLog.emptyState",never:"dateUtils.never"}),c=new Intl.DateTimeFormat(u,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:P()}),w=e=>{switch(e){case"CREATED":return t.quoteCreated;case"UPDATED":return t.quoteUpdated;case"STATUS_CHANGED":return t.statusChanged;case"COMMENT_ADDED":return t.commentAdded;case"EXPIRATION_CHANGED":return t.expirationChanged;default:return e.replace(/_/g," ").toLowerCase().replace(/\b\w/g,r=>r.toUpperCase())}},S=e=>{var a,n,y,p,s,C,L,N,_,x,b,F;const r=[];if((a=e==null?void 0:e.commentAdded)!=null&&a.comment&&r.push(t.commentDetail.replace("{comment}",e.commentAdded.comment)),(n=e==null?void 0:e.statuses)!=null&&n.changes&&e.statuses.changes.forEach(i=>{i.oldStatus&&i.newStatus?r.push(t.statusChangedFromTo.replace("{oldStatus}",i.oldStatus).replace("{newStatus}",i.newStatus)):i.newStatus&&r.push(t.statusSetTo.replace("{newStatus}",i.newStatus))}),(y=e==null?void 0:e.expiration)!=null&&y.newExpiration&&((p=e==null?void 0:e.expiration)!=null&&p.oldExpiration)){const i=g(e.expiration.newExpiration,c),m=g(e.expiration.oldExpiration,c);r.push(t.expirationChangedFromTo.replace("{oldExpiration}",m).replace("{newExpiration}",i))}else if((s=e==null?void 0:e.expiration)!=null&&s.newExpiration){const i=g(e.expiration.newExpiration,c);r.push(t.expirationSetTo.replace("{newExpiration}",i))}if((C=e==null?void 0:e.total)!=null&&C.newPrice&&((L=e==null?void 0:e.total)!=null&&L.oldPrice)){const i=`${e.total.newPrice.currency} ${e.total.newPrice.value}`,m=`${e.total.oldPrice.currency} ${e.total.oldPrice.value}`;r.push(t.totalChangedFromTo.replace("{oldTotal}",m).replace("{newTotal}",i))}if((N=e==null?void 0:e.customChanges)!=null&&N.title&&((_=e==null?void 0:e.customChanges)!=null&&_.old_value)&&((x=e==null?void 0:e.customChanges)!=null&&x.new_value)&&r.push(t.customChange.replace("{title}",e.customChanges.title).replace("{oldValue}",e.customChanges.old_value).replace("{newValue}",e.customChanges.new_value)),(b=e==null?void 0:e.productsRemoved)!=null&&b.productsRemovedFromCatalog&&e.productsRemoved.productsRemovedFromCatalog.length>0&&r.push(t.productsRemovedFromCatalog.replace("{products}",e.productsRemoved.productsRemovedFromCatalog.join(", "))),(F=e==null?void 0:e.productsRemoved)!=null&&F.productsRemovedFromQuote&&e.productsRemoved.productsRemovedFromQuote.length>0){const i=e.productsRemoved.productsRemovedFromQuote.map(m=>m.name||m.sku||m.uid).join(", ");r.push(t.productsRemovedFromQuote.replace("{products}",i))}return r.length>0?r:[t.noDetailsAvailable]},E=(()=>{const e=[],r=(a,n,y,p)=>{a&&Array.isArray(a)&&a.forEach(s=>{s&&s.note&&s.note.trim()&&e.push({...s,type:n,productName:p.product.name,productSku:p.product.sku,authorName:y})})};return o!=null&&o.items&&o.items.forEach(a=>{r(a.noteFromBuyer,"buyer",`${o.buyer.firstname} ${o.buyer.lastname} ${t.buyerLabel}`,a),r(a.noteFromSeller,"seller",`${o.salesRepName} ${t.sellerLabel}`,a)}),e})(),A=((o==null?void 0:o.history)||[]).map(e=>({...e,entryType:"history"})),R=E.map(e=>({...e,entryType:"note"})),f=[...A,...R];return d("div",{...T,className:U(["quote-management-quote-history-log",h]),children:[f.length>0?l("div",{className:"quote-management-quote-history-log__entries",children:f.map((e,r)=>d("div",{className:"quote-management-quote-history-log__entry",children:[d("div",{className:"quote-management-quote-history-log__entry-header",children:[d("div",{className:"quote-management-quote-history-log__entry-meta",children:[l("span",{className:"quote-management-quote-history-log__entry-date",children:c.format(new Date(e.createdAt))}),l("span",{className:"quote-management-quote-history-log__entry-author",children:e.entryType==="history"?`by ${e.author.firstname} ${e.author.lastname} ${e.author.firstname===(o==null?void 0:o.buyer.firstname)&&e.author.lastname===(o==null?void 0:o.buyer.lastname)?t.buyerLabel:t.sellerLabel}`:`by ${e.authorName}`})]}),l("div",{className:"quote-management-quote-history-log__entry-type",children:e.entryType==="history"?w(e.changeType):e.type==="buyer"?t.buyerNoteAdded:t.sellerNoteAdded})]}),l("div",{className:"quote-management-quote-history-log__entry-changes",children:e.entryType==="history"?S(e.changes).map((a,n)=>l("div",{className:"quote-management-quote-history-log__entry-change",children:a},n)):d("div",{className:"quote-management-quote-history-log__entry-change",children:[d("div",{children:[e.productName,"(",e.productSku,")"]}),d("div",{children:['"',e.note,'"']})]})})]},e.entryType==="history"?e.uid:`${e.noteUid}-${r}`))}):l("div",{className:"quote-management-quote-history-log__empty",children:t.emptyState}),v]})},X=({quoteData:h,...v})=>{const[o,T]=$(h);return Q(()=>{const u=q.on("quote-management/quote-data",t=>{T(t.quote)},{eager:!0});return()=>u==null?void 0:u.off()},[]),o?l("div",{...v,children:l(j,{quoteData:o})}):null};export{X as Q};
4
4
  //# sourceMappingURL=QuoteHistoryLog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuoteHistoryLog.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.ts","/@dropins/storefront-quote-management/src/components/QuoteHistoryLog/QuoteHistoryLog.tsx","/@dropins/storefront-quote-management/src/containers/QuoteHistoryLog/QuoteHistoryLog.tsx"],"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\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 */\n\nexport function formatExpirationDate(date: string, dateFormatter: Intl.DateTimeFormat): string {\n return dateFormatter.format(new Date(date));\n}\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 * 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 { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, getGlobalLocale } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport {\n formatExpirationDate,\n getUserTimezone,\n} from '@/quote-management/utils/dateUtils';\nimport '@/quote-management/components/QuoteHistoryLog/QuoteHistoryLog.css';\n\nexport interface QuoteHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n quoteData?: NegotiableQuoteModel;\n}\n\nexport const QuoteHistoryLog: FunctionComponent<QuoteHistoryLogProps> = ({\n className,\n children,\n quoteData,\n ...props\n}) => {\n // Fallback to en-US if no locale is set\n const calculatedLocale = getGlobalLocale() || 'en-US';\n\n const dictionary = useText({\n quoteCreated: 'historyLog.changeTypes.created',\n quoteUpdated: 'historyLog.changeTypes.updated',\n statusChanged: 'historyLog.changeTypes.statusChanged',\n commentAdded: 'historyLog.changeTypes.commentAdded',\n expirationChanged: 'historyLog.changeTypes.expirationChanged',\n buyerNoteAdded: 'historyLog.noteTypes.buyerNoteAdded',\n sellerNoteAdded: 'historyLog.noteTypes.sellerNoteAdded',\n buyerLabel: 'historyLog.authorLabels.buyer',\n sellerLabel: 'historyLog.authorLabels.seller',\n commentDetail: 'historyLog.changeDetails.comment',\n statusChangedFromTo: 'historyLog.changeDetails.statusChangedFromTo',\n statusSetTo: 'historyLog.changeDetails.statusSetTo',\n expirationChangedFromTo: 'historyLog.changeDetails.expirationChangedFromTo',\n expirationSetTo: 'historyLog.changeDetails.expirationSetTo',\n totalChangedFromTo: 'historyLog.changeDetails.totalChangedFromTo',\n customChange: 'historyLog.changeDetails.customChange',\n productsRemovedFromCatalog: 'historyLog.changeDetails.productsRemovedFromCatalog',\n productsRemovedFromQuote: 'historyLog.changeDetails.productsRemovedFromQuote',\n noDetailsAvailable: 'historyLog.changeDetails.noDetailsAvailable',\n emptyState: 'historyLog.emptyState',\n never: 'dateUtils.never',\n });\n\n const dateFormatter = new Intl.DateTimeFormat(calculatedLocale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n timeZone: getUserTimezone(),\n });\n\n const formatChangeType = (changeType: string) => {\n switch (changeType) {\n case 'CREATED':\n return dictionary.quoteCreated;\n case 'UPDATED':\n return dictionary.quoteUpdated;\n case 'STATUS_CHANGED':\n return dictionary.statusChanged;\n case 'COMMENT_ADDED':\n return dictionary.commentAdded;\n case 'EXPIRATION_CHANGED':\n return dictionary.expirationChanged;\n default:\n return changeType\n .replace(/_/g, ' ')\n .toLowerCase()\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n };\n\n // Handle status or expiration changes\n const formatChanges = (changes: any) => {\n const changeDetails = [];\n\n if (changes?.commentAdded?.comment) {\n changeDetails.push(\n dictionary.commentDetail.replace(\n '{comment}',\n changes.commentAdded.comment\n )\n );\n }\n\n if (changes?.statuses?.changes) {\n changes.statuses.changes.forEach((statusChange: any) => {\n if (statusChange.oldStatus && statusChange.newStatus) {\n changeDetails.push(\n dictionary.statusChangedFromTo\n .replace('{oldStatus}', statusChange.oldStatus)\n .replace('{newStatus}', statusChange.newStatus)\n );\n } else if (statusChange.newStatus) {\n changeDetails.push(\n dictionary.statusSetTo.replace(\n '{newStatus}',\n statusChange.newStatus\n )\n );\n }\n });\n }\n\n if (\n changes?.expiration?.newExpiration &&\n changes?.expiration?.oldExpiration\n ) {\n const newDateFormatted = formatExpirationDate(\n changes.expiration.newExpiration,\n dateFormatter\n );\n const oldDateFormatted = formatExpirationDate(\n changes.expiration.oldExpiration,\n dateFormatter\n );\n changeDetails.push(\n dictionary.expirationChangedFromTo\n .replace('{oldExpiration}', oldDateFormatted)\n .replace('{newExpiration}', newDateFormatted)\n );\n } else if (changes?.expiration?.newExpiration) {\n const newDateFormatted = formatExpirationDate(\n changes.expiration.newExpiration,\n dateFormatter\n );\n changeDetails.push(\n dictionary.expirationSetTo.replace('{newExpiration}', newDateFormatted)\n );\n }\n\n if (changes?.total?.newPrice && changes?.total?.oldPrice) {\n const newTotal = `${changes.total.newPrice.currency} ${changes.total.newPrice.value}`;\n const oldTotal = `${changes.total.oldPrice.currency} ${changes.total.oldPrice.value}`;\n changeDetails.push(\n dictionary.totalChangedFromTo\n .replace('{oldTotal}', oldTotal)\n .replace('{newTotal}', newTotal)\n );\n }\n\n if (changes?.customChanges?.title && changes?.customChanges?.old_value && changes?.customChanges?.new_value) {\n changeDetails.push(\n dictionary.customChange\n .replace('{title}', changes.customChanges.title)\n .replace('{oldValue}', changes.customChanges.old_value)\n .replace('{newValue}', changes.customChanges.new_value)\n );\n }\n\n if (changes?.productsRemoved?.productsRemovedFromCatalog && changes.productsRemoved.productsRemovedFromCatalog.length > 0) {\n changeDetails.push(\n dictionary.productsRemovedFromCatalog.replace(\n '{products}',\n changes.productsRemoved.productsRemovedFromCatalog.join(', ')\n )\n );\n }\n\n if (changes?.productsRemoved?.productsRemovedFromQuote && changes.productsRemoved.productsRemovedFromQuote.length > 0) {\n const productNames = changes.productsRemoved.productsRemovedFromQuote.map((product: any) => \n product.name || product.sku || product.uid\n ).join(', ');\n changeDetails.push(\n dictionary.productsRemovedFromQuote.replace('{products}', productNames)\n );\n }\n\n return changeDetails.length > 0\n ? changeDetails\n : [dictionary.noDetailsAvailable];\n };\n\n // Get item notes outside of history entries\n const getItemNotes = () => {\n const notes: Array<{\n createdAt: string;\n creatorId: string;\n creatorType: string;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n type: 'buyer' | 'seller';\n productName: string;\n productSku: string;\n authorName: string;\n }> = [];\n\n const processNotes = (\n noteArray: any | undefined,\n type: 'buyer' | 'seller',\n authorName: string,\n item: any\n ) => {\n if (noteArray && Array.isArray(noteArray)) {\n noteArray.forEach((note) => {\n if (note && note.note && note.note.trim()) {\n notes.push({\n ...note,\n type,\n productName: item.product.name,\n productSku: item.product.sku,\n authorName,\n });\n }\n });\n }\n };\n\n if (quoteData?.items) {\n quoteData.items.forEach((item) => {\n processNotes(\n item.noteFromBuyer,\n 'buyer',\n `${quoteData.buyer.firstname} ${quoteData.buyer.lastname} ${dictionary.buyerLabel}`,\n item\n );\n\n processNotes(\n item.noteFromSeller,\n 'seller',\n `${quoteData.salesRepName} ${dictionary.sellerLabel}`,\n item\n );\n });\n }\n\n return notes;\n };\n\n const itemNotes = getItemNotes();\n\n // Get history entries\n const historyEntries = (quoteData?.history || []).map((entry) => ({\n ...entry,\n entryType: 'history' as const,\n }));\n const noteEntries = itemNotes.map((note) => ({\n ...note,\n entryType: 'note' as const,\n }));\n\n // Combine history and item notes without sorting\n const allEntries = [...historyEntries, ...noteEntries];\n\n return (\n <div\n {...props}\n className={classes(['quote-management-quote-history-log', className])}\n >\n {allEntries.length > 0 ? (\n <div className=\"quote-management-quote-history-log__entries\">\n {allEntries.map((entry, index) => (\n <div\n key={\n entry.entryType === 'history'\n ? entry.uid\n : `${entry.noteUid}-${index}`\n }\n className=\"quote-management-quote-history-log__entry\"\n >\n <div className=\"quote-management-quote-history-log__entry-header\">\n <div className=\"quote-management-quote-history-log__entry-meta\">\n <span className=\"quote-management-quote-history-log__entry-date\">\n {dateFormatter.format(new Date(entry.createdAt))}\n </span>\n <span className=\"quote-management-quote-history-log__entry-author\">\n {entry.entryType === 'history'\n ? `by ${entry.author.firstname} ${\n entry.author.lastname\n } ${\n entry.author.firstname ===\n quoteData?.buyer.firstname &&\n entry.author.lastname === quoteData?.buyer.lastname\n ? dictionary.buyerLabel\n : dictionary.sellerLabel\n }`\n : `by ${entry.authorName}`}\n </span>\n </div>\n <div className=\"quote-management-quote-history-log__entry-type\">\n {entry.entryType === 'history'\n ? formatChangeType(entry.changeType)\n : entry.type === 'buyer'\n ? dictionary.buyerNoteAdded\n : dictionary.sellerNoteAdded}\n </div>\n </div>\n <div className=\"quote-management-quote-history-log__entry-changes\">\n {entry.entryType === 'history' ? (\n formatChanges(entry.changes).map((change, changeIndex) => (\n <div\n key={changeIndex}\n className=\"quote-management-quote-history-log__entry-change\"\n >\n {change}\n </div>\n ))\n ) : (\n <div className=\"quote-management-quote-history-log__entry-change\">\n <div>\n {entry.productName}({entry.productSku})\n </div>\n <div>\"{entry.note}\"</div>\n </div>\n )}\n </div>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"quote-management-quote-history-log__empty\">\n {dictionary.emptyState}\n </div>\n )}\n {children}\n </div>\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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { events } from '@adobe-commerce/event-bus';\nimport { QuoteHistoryLog as QuoteHistoryLogComponent } from '@/quote-management/components/QuoteHistoryLog';\n\nexport interface QuoteHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n quoteData?: NegotiableQuoteModel;\n}\n \nexport const QuoteHistoryLog: Container<QuoteHistoryLogProps> = ({ quoteData: initialData, ...props }) => {\n\n const [quoteData, setQuoteData] = useState<NegotiableQuoteModel | undefined>(\n initialData\n );\n\n useEffect(() => {\n const quoteDataEvent = events.on(\n 'quote-management/quote-data',\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n },\n {\n eager: true,\n }\n );\n return () => quoteDataEvent?.off();\n }, []);\n\n if (!quoteData) {\n return null;\n }\n\n return (\n <div {...props}>\n <QuoteHistoryLogComponent quoteData={quoteData} />\n </div>\n );\n};\n"],"names":["formatExpirationDate","date","dateFormatter","getUserTimezone","error","QuoteHistoryLog","className","children","quoteData","props","calculatedLocale","getGlobalLocale","dictionary","useText","formatChangeType","changeType","l","formatChanges","changes","changeDetails","_a","_b","statusChange","_c","_d","newDateFormatted","oldDateFormatted","_e","_f","_g","newTotal","oldTotal","_h","_i","_j","_k","_l","productNames","product","itemNotes","notes","processNotes","noteArray","type","authorName","item","note","historyEntries","entry","noteEntries","allEntries","jsxs","classes","jsx","index","change","changeIndex","initialData","setQuoteData","useState","useEffect","quoteDataEvent","events","data","QuoteHistoryLogComponent"],"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og/QuoteHistoryLog.tsx","/@dropins/storefront-quote-management/src/containers/QuoteHistoryLog/QuoteHistoryLog.tsx"],"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 { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, getGlobalLocale } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport {\n formatExpirationDate,\n getUserTimezone,\n} from '@/quote-management/utils/dateUtils';\nimport '@/quote-management/components/QuoteHistoryLog/QuoteHistoryLog.css';\n\nexport interface QuoteHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n quoteData?: NegotiableQuoteModel;\n}\n\nexport const QuoteHistoryLog: FunctionComponent<QuoteHistoryLogProps> = ({\n className,\n children,\n quoteData,\n ...props\n}) => {\n // Fallback to en-US if no locale is set\n const calculatedLocale = getGlobalLocale() || 'en-US';\n\n const dictionary = useText({\n quoteCreated: 'historyLog.changeTypes.created',\n quoteUpdated: 'historyLog.changeTypes.updated',\n statusChanged: 'historyLog.changeTypes.statusChanged',\n commentAdded: 'historyLog.changeTypes.commentAdded',\n expirationChanged: 'historyLog.changeTypes.expirationChanged',\n buyerNoteAdded: 'historyLog.noteTypes.buyerNoteAdded',\n sellerNoteAdded: 'historyLog.noteTypes.sellerNoteAdded',\n buyerLabel: 'historyLog.authorLabels.buyer',\n sellerLabel: 'historyLog.authorLabels.seller',\n commentDetail: 'historyLog.changeDetails.comment',\n statusChangedFromTo: 'historyLog.changeDetails.statusChangedFromTo',\n statusSetTo: 'historyLog.changeDetails.statusSetTo',\n expirationChangedFromTo: 'historyLog.changeDetails.expirationChangedFromTo',\n expirationSetTo: 'historyLog.changeDetails.expirationSetTo',\n totalChangedFromTo: 'historyLog.changeDetails.totalChangedFromTo',\n customChange: 'historyLog.changeDetails.customChange',\n productsRemovedFromCatalog: 'historyLog.changeDetails.productsRemovedFromCatalog',\n productsRemovedFromQuote: 'historyLog.changeDetails.productsRemovedFromQuote',\n noDetailsAvailable: 'historyLog.changeDetails.noDetailsAvailable',\n emptyState: 'historyLog.emptyState',\n never: 'dateUtils.never',\n });\n\n const dateFormatter = new Intl.DateTimeFormat(calculatedLocale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n timeZone: getUserTimezone(),\n });\n\n const formatChangeType = (changeType: string) => {\n switch (changeType) {\n case 'CREATED':\n return dictionary.quoteCreated;\n case 'UPDATED':\n return dictionary.quoteUpdated;\n case 'STATUS_CHANGED':\n return dictionary.statusChanged;\n case 'COMMENT_ADDED':\n return dictionary.commentAdded;\n case 'EXPIRATION_CHANGED':\n return dictionary.expirationChanged;\n default:\n return changeType\n .replace(/_/g, ' ')\n .toLowerCase()\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n };\n\n // Handle status or expiration changes\n const formatChanges = (changes: any) => {\n const changeDetails = [];\n\n if (changes?.commentAdded?.comment) {\n changeDetails.push(\n dictionary.commentDetail.replace(\n '{comment}',\n changes.commentAdded.comment\n )\n );\n }\n\n if (changes?.statuses?.changes) {\n changes.statuses.changes.forEach((statusChange: any) => {\n if (statusChange.oldStatus && statusChange.newStatus) {\n changeDetails.push(\n dictionary.statusChangedFromTo\n .replace('{oldStatus}', statusChange.oldStatus)\n .replace('{newStatus}', statusChange.newStatus)\n );\n } else if (statusChange.newStatus) {\n changeDetails.push(\n dictionary.statusSetTo.replace(\n '{newStatus}',\n statusChange.newStatus\n )\n );\n }\n });\n }\n\n if (\n changes?.expiration?.newExpiration &&\n changes?.expiration?.oldExpiration\n ) {\n const newDateFormatted = formatExpirationDate(\n changes.expiration.newExpiration,\n dateFormatter\n );\n const oldDateFormatted = formatExpirationDate(\n changes.expiration.oldExpiration,\n dateFormatter\n );\n changeDetails.push(\n dictionary.expirationChangedFromTo\n .replace('{oldExpiration}', oldDateFormatted)\n .replace('{newExpiration}', newDateFormatted)\n );\n } else if (changes?.expiration?.newExpiration) {\n const newDateFormatted = formatExpirationDate(\n changes.expiration.newExpiration,\n dateFormatter\n );\n changeDetails.push(\n dictionary.expirationSetTo.replace('{newExpiration}', newDateFormatted)\n );\n }\n\n if (changes?.total?.newPrice && changes?.total?.oldPrice) {\n const newTotal = `${changes.total.newPrice.currency} ${changes.total.newPrice.value}`;\n const oldTotal = `${changes.total.oldPrice.currency} ${changes.total.oldPrice.value}`;\n changeDetails.push(\n dictionary.totalChangedFromTo\n .replace('{oldTotal}', oldTotal)\n .replace('{newTotal}', newTotal)\n );\n }\n\n if (changes?.customChanges?.title && changes?.customChanges?.old_value && changes?.customChanges?.new_value) {\n changeDetails.push(\n dictionary.customChange\n .replace('{title}', changes.customChanges.title)\n .replace('{oldValue}', changes.customChanges.old_value)\n .replace('{newValue}', changes.customChanges.new_value)\n );\n }\n\n if (changes?.productsRemoved?.productsRemovedFromCatalog && changes.productsRemoved.productsRemovedFromCatalog.length > 0) {\n changeDetails.push(\n dictionary.productsRemovedFromCatalog.replace(\n '{products}',\n changes.productsRemoved.productsRemovedFromCatalog.join(', ')\n )\n );\n }\n\n if (changes?.productsRemoved?.productsRemovedFromQuote && changes.productsRemoved.productsRemovedFromQuote.length > 0) {\n const productNames = changes.productsRemoved.productsRemovedFromQuote.map((product: any) => \n product.name || product.sku || product.uid\n ).join(', ');\n changeDetails.push(\n dictionary.productsRemovedFromQuote.replace('{products}', productNames)\n );\n }\n\n return changeDetails.length > 0\n ? changeDetails\n : [dictionary.noDetailsAvailable];\n };\n\n // Get item notes outside of history entries\n const getItemNotes = () => {\n const notes: Array<{\n createdAt: string;\n creatorId: string;\n creatorType: string;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n type: 'buyer' | 'seller';\n productName: string;\n productSku: string;\n authorName: string;\n }> = [];\n\n const processNotes = (\n noteArray: any | undefined,\n type: 'buyer' | 'seller',\n authorName: string,\n item: any\n ) => {\n if (noteArray && Array.isArray(noteArray)) {\n noteArray.forEach((note) => {\n if (note && note.note && note.note.trim()) {\n notes.push({\n ...note,\n type,\n productName: item.product.name,\n productSku: item.product.sku,\n authorName,\n });\n }\n });\n }\n };\n\n if (quoteData?.items) {\n quoteData.items.forEach((item) => {\n processNotes(\n item.noteFromBuyer,\n 'buyer',\n `${quoteData.buyer.firstname} ${quoteData.buyer.lastname} ${dictionary.buyerLabel}`,\n item\n );\n\n processNotes(\n item.noteFromSeller,\n 'seller',\n `${quoteData.salesRepName} ${dictionary.sellerLabel}`,\n item\n );\n });\n }\n\n return notes;\n };\n\n const itemNotes = getItemNotes();\n\n // Get history entries\n const historyEntries = (quoteData?.history || []).map((entry) => ({\n ...entry,\n entryType: 'history' as const,\n }));\n const noteEntries = itemNotes.map((note) => ({\n ...note,\n entryType: 'note' as const,\n }));\n\n // Combine history and item notes without sorting\n const allEntries = [...historyEntries, ...noteEntries];\n\n return (\n <div\n {...props}\n className={classes(['quote-management-quote-history-log', className])}\n >\n {allEntries.length > 0 ? (\n <div className=\"quote-management-quote-history-log__entries\">\n {allEntries.map((entry, index) => (\n <div\n key={\n entry.entryType === 'history'\n ? entry.uid\n : `${entry.noteUid}-${index}`\n }\n className=\"quote-management-quote-history-log__entry\"\n >\n <div className=\"quote-management-quote-history-log__entry-header\">\n <div className=\"quote-management-quote-history-log__entry-meta\">\n <span className=\"quote-management-quote-history-log__entry-date\">\n {dateFormatter.format(new Date(entry.createdAt))}\n </span>\n <span className=\"quote-management-quote-history-log__entry-author\">\n {entry.entryType === 'history'\n ? `by ${entry.author.firstname} ${\n entry.author.lastname\n } ${\n entry.author.firstname ===\n quoteData?.buyer.firstname &&\n entry.author.lastname === quoteData?.buyer.lastname\n ? dictionary.buyerLabel\n : dictionary.sellerLabel\n }`\n : `by ${entry.authorName}`}\n </span>\n </div>\n <div className=\"quote-management-quote-history-log__entry-type\">\n {entry.entryType === 'history'\n ? formatChangeType(entry.changeType)\n : entry.type === 'buyer'\n ? dictionary.buyerNoteAdded\n : dictionary.sellerNoteAdded}\n </div>\n </div>\n <div className=\"quote-management-quote-history-log__entry-changes\">\n {entry.entryType === 'history' ? (\n formatChanges(entry.changes).map((change, changeIndex) => (\n <div\n key={changeIndex}\n className=\"quote-management-quote-history-log__entry-change\"\n >\n {change}\n </div>\n ))\n ) : (\n <div className=\"quote-management-quote-history-log__entry-change\">\n <div>\n {entry.productName}({entry.productSku})\n </div>\n <div>\"{entry.note}\"</div>\n </div>\n )}\n </div>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"quote-management-quote-history-log__empty\">\n {dictionary.emptyState}\n </div>\n )}\n {children}\n </div>\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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { events } from '@adobe-commerce/event-bus';\nimport { QuoteHistoryLog as QuoteHistoryLogComponent } from '@/quote-management/components/QuoteHistoryLog';\n\nexport interface QuoteHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n quoteData?: NegotiableQuoteModel;\n}\n \nexport const QuoteHistoryLog: Container<QuoteHistoryLogProps> = ({ quoteData: initialData, ...props }) => {\n\n const [quoteData, setQuoteData] = useState<NegotiableQuoteModel | undefined>(\n initialData\n );\n\n useEffect(() => {\n const quoteDataEvent = events.on(\n 'quote-management/quote-data',\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n },\n {\n eager: true,\n }\n );\n return () => quoteDataEvent?.off();\n }, []);\n\n if (!quoteData) {\n return null;\n }\n\n return (\n <div {...props}>\n <QuoteHistoryLogComponent quoteData={quoteData} />\n </div>\n );\n};\n"],"names":["QuoteHistoryLog","className","children","quoteData","props","calculatedLocale","getGlobalLocale","dictionary","useText","dateFormatter","getUserTimezone","formatChangeType","changeType","l","formatChanges","changes","changeDetails","_a","_b","statusChange","_c","_d","newDateFormatted","formatExpirationDate","oldDateFormatted","_e","_f","_g","newTotal","oldTotal","_h","_i","_j","_k","_l","productNames","product","itemNotes","notes","processNotes","noteArray","type","authorName","item","note","historyEntries","entry","noteEntries","allEntries","jsxs","classes","jsx","index","change","changeIndex","initialData","setQuoteData","useState","useEffect","quoteDataEvent","events","data","QuoteHistoryLogComponent"],"mappings":"kYAwBO,MAAMA,EAA2D,CAAC,CACvE,UAAAC,EACA,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAAM,CAEJ,MAAMC,EAAmBC,KAAqB,QAExCC,EAAaC,EAAQ,CACzB,aAAc,iCACd,aAAc,iCACd,cAAe,uCACf,aAAc,sCACd,kBAAmB,2CACnB,eAAgB,sCAChB,gBAAiB,uCACjB,WAAY,gCACZ,YAAa,iCACb,cAAe,mCACf,oBAAqB,+CACrB,YAAa,uCACb,wBAAyB,mDACzB,gBAAiB,2CACjB,mBAAoB,8CACpB,aAAc,wCACd,2BAA4B,sDAC5B,yBAA0B,oDAC1B,mBAAoB,8CACpB,WAAY,wBACZ,MAAO,iBAAA,CACR,EAEKC,EAAgB,IAAI,KAAK,eAAeJ,EAAkB,CAC9D,KAAM,UACN,MAAO,OACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,SAAUK,EAAA,CAAgB,CAC3B,EAEKC,EAAoBC,GAAuB,CAC/C,OAAQA,EAAA,CACN,IAAK,UACH,OAAOL,EAAW,aACpB,IAAK,UACH,OAAOA,EAAW,aACpB,IAAK,iBACH,OAAOA,EAAW,cACpB,IAAK,gBACH,OAAOA,EAAW,aACpB,IAAK,qBACH,OAAOA,EAAW,kBACpB,QACE,OAAOK,EACJ,QAAQ,KAAM,GAAG,E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,MAAA,CAAK,GAAGC,EACP,SAAA+C,EAACW,EAAA,CAAyB,UAAA3D,EAAsB,EAClD,EANO,IAQX"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ function a(t,e){return e.format(new Date(t))}function n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return console.warn("Failed to detect user timezone, falling back to UTC:",t),"UTC"}}function r(t){const e=new Date(t);return isNaN(e.getTime())?"–":e.toLocaleDateString()}export{a,r as f,n as g};
4
+ //# sourceMappingURL=dateUtils.js.map
@@ -0,0 +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\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 */\n\nexport function formatExpirationDate(date: string, dateFormatter: Intl.DateTimeFormat): string {\n return dateFormatter.format(new Date(date));\n}\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 * 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): string {\n const date = new Date(dateString);\n return isNaN(date.getTime()) ? '–' : date.toLocaleDateString();\n}\n"],"names":["formatExpirationDate","date","dateFormatter","getUserTimezone","error","formattedDate","dateString"],"mappings":"AAcO,SAASA,EAAqBC,EAAcC,EAA4C,CAC7F,OAAOA,EAAc,OAAO,IAAI,KAAKD,CAAI,CAAC,CAC5C,CAEO,SAASE,GAA0B,CACxC,GAAI,CACF,OAAO,KAAK,iBAAiB,gBAAA,EAAkB,QACjD,OAASC,EAAO,CACd,eAAQ,KAAK,uDAAwDA,CAAK,EACnE,KACT,CACF,CAOO,SAASC,EAAcC,EAA4B,CACxD,MAAML,EAAO,IAAI,KAAKK,CAAU,EAChC,OAAO,MAAML,EAAK,QAAA,CAAS,EAAI,IAAMA,EAAK,mBAAA,CAC5C"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{s as f}from"./state.js";import{events as y}from"@dropins/tools/event-bus.js";import{f as b}from"./fetch-graphql.js";function C(e){var a,n,o,s,l;return e?{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:e.status,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},comments:(a=e.comments)==null?void 0:a.map(r=>{var u;return{uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text,attachments:(u=r.attachments)==null?void 0:u.map(c=>({name:c.name,url:c.url}))}}),prices:e.prices&&{subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(n=e.prices.applied_taxes)==null?void 0:n.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}},history:(o=e.history)==null?void 0:o.map(r=>({uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},changeType:r.change_type,changes:r.changes})),items:((s=e.items)==null?void 0:s.map(r=>{var u,c,_,d,g,p;return{uid:r.uid,product:{uid:r.product.uid,sku:r.product.sku,name:r.product.name},quantity:r.quantity,prices:{originalItemPrice:{value:r.prices.original_item_price.value,currency:r.prices.original_item_price.currency},rowTotal:{value:r.prices.row_total.value,currency:r.prices.row_total.currency}},catalogDiscount:r.prices.catalog_discount&&{amountOff:r.prices.catalog_discount.amount_off,percentOff:r.prices.catalog_discount.percent_off},discounts:(c=(u=r.prices)==null?void 0:u.discounts)==null?void 0:c.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})),noteFromBuyer:(_=r.note_from_buyer)==null?void 0:_.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_template_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(d=r.note_from_seller)==null?void 0:d.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_template_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(g=r.configurable_options)==null?void 0:g.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(p=r.bundle_options)==null?void 0:p.map(t=>({label:t.label,values:t.values.map(i=>({label:i.label,quantity:i.quantity,originalPrice:{value:i.original_price.value,currency:i.original_price.currency},price:{value:i.priceV2.value,currency:i.priceV2.currency}}))}))}}))||[],shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(r=>({uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone,region:r.region?{code:r.region.code,label:r.region.label,regionId:r.region.region_id}:void 0})),canAccept:["SUBMITTED","PENDING","IN_REVIEW"].includes(e.status),canDelete:["CLOSED","INACTIVE"].includes(e.status),canReopen:e.status==="CLOSED",canCancel:["ACTIVE","IN_REVIEW","SUBMITTED"].includes(e.status),canGenerateQuote:e.status==="ACTIVE"}:null}function E(e){var a;return e?{items:((a=e.items)==null?void 0:a.map(n=>({id:n.template_id,uid:"TBD",name:n.name,createdAt:"0000-00-00 00:00:00",updatedAt:"0000-00-00 00:00:00",status:n.status,state:n.state,prices:{grandTotal:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:n.min_negotiated_grand_total,currency:"USD"}},lastSharedAt:n.last_shared_at,lastOrderedAt:"0000-00-00 00:00:00",expirationDate:"0000-00-00 00:00:00",ordersPlaced:n.orders_placed})))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0}:null}const T=`
3
+ import{s as f}from"./state.js";import{events as y}from"@dropins/tools/event-bus.js";import{f as b}from"./transform-quote.js";function C(e){var a,n,o,s,l;return e?{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:e.status,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},comments:(a=e.comments)==null?void 0:a.map(r=>{var u;return{uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text,attachments:(u=r.attachments)==null?void 0:u.map(c=>({name:c.name,url:c.url}))}}),prices:e.prices&&{subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(n=e.prices.applied_taxes)==null?void 0:n.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}},history:(o=e.history)==null?void 0:o.map(r=>({uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},changeType:r.change_type,changes:r.changes})),items:((s=e.items)==null?void 0:s.map(r=>{var u,c,_,d,g,p;return{uid:r.uid,product:{uid:r.product.uid,sku:r.product.sku,name:r.product.name},quantity:r.quantity,prices:{originalItemPrice:{value:r.prices.original_item_price.value,currency:r.prices.original_item_price.currency},rowTotal:{value:r.prices.row_total.value,currency:r.prices.row_total.currency}},catalogDiscount:r.prices.catalog_discount&&{amountOff:r.prices.catalog_discount.amount_off,percentOff:r.prices.catalog_discount.percent_off},discounts:(c=(u=r.prices)==null?void 0:u.discounts)==null?void 0:c.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})),noteFromBuyer:(_=r.note_from_buyer)==null?void 0:_.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_template_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(d=r.note_from_seller)==null?void 0:d.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_template_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(g=r.configurable_options)==null?void 0:g.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(p=r.bundle_options)==null?void 0:p.map(t=>({label:t.label,values:t.values.map(i=>({label:i.label,quantity:i.quantity,originalPrice:{value:i.original_price.value,currency:i.original_price.currency},price:{value:i.priceV2.value,currency:i.priceV2.currency}}))}))}}))||[],shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(r=>({uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone,region:r.region?{code:r.region.code,label:r.region.label,regionId:r.region.region_id}:void 0})),canAccept:["SUBMITTED","PENDING","IN_REVIEW"].includes(e.status),canDelete:["CLOSED","INACTIVE"].includes(e.status),canReopen:e.status==="CLOSED",canCancel:["ACTIVE","IN_REVIEW","SUBMITTED"].includes(e.status),canGenerateQuote:e.status==="ACTIVE"}:null}function E(e){var a;return e?{items:((a=e.items)==null?void 0:a.map(n=>({id:n.template_id,uid:"TBD",name:n.name,createdAt:"0000-00-00 00:00:00",updatedAt:"0000-00-00 00:00:00",status:n.status,state:n.state,prices:{grandTotal:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:n.min_negotiated_grand_total,currency:"USD"}},lastSharedAt:n.last_shared_at,lastOrderedAt:"0000-00-00 00:00:00",expirationDate:"0000-00-00 00:00:00",ordersPlaced:n.orders_placed})))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0}:null}const T=`
4
4
  query QUOTE_TEMPLATES_QUERY(
5
5
  $filter: NegotiableQuoteTemplateFilterInput
6
6
  $pageSize: Int
@@ -1 +1 @@
1
- {"version":3,"file":"getQuoteTemplates.js","sources":["/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/graphql/getQuoteTemplates.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/getQuoteTemplates.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';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\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', 'IN_REVIEW'].includes(templateData.status),\n canDelete: ['CLOSED', 'INACTIVE'].includes(templateData.status),\n canReopen: templateData.status === 'CLOSED',\n canCancel: ['ACTIVE', 'IN_REVIEW', 'SUBMITTED'].includes(templateData.status),\n canGenerateQuote: templateData.status === 'ACTIVE',\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n return {\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 * 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 QUOTE_TEMPLATES_QUERY = /* GraphQL */ `\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n # uid\n template_id\n name\n # created_at\n # updated_at\n # last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n # expiration_date\n orders_placed\n # grand_total {\n # currency\n # value\n # }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\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 { QUOTE_TEMPLATES_QUERY } from './graphql/getQuoteTemplates';\nimport { transformQuoteTemplatesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplatesListModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QuoteTemplateFilterStatus {\n ACTIVE = 'ACTIVE',\n IN_REVIEW = 'IN_REVIEW',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface QuoteTemplateFilterInput {\n status?: QuoteTemplateFilterStatus[];\n name?: {\n match?: string;\n };\n}\n\nexport enum QuoteTemplateSortField {\n NAME = 'NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface QuoteTemplateSortInput {\n sortField: QuoteTemplateSortField;\n sortDirection: SortDirection;\n}\n\nexport interface GetQuoteTemplatesParams {\n filter?: QuoteTemplateFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: QuoteTemplateSortInput;\n}\n\nexport const getQuoteTemplates = async (\n params: GetQuoteTemplatesParams = {}\n): Promise<NegotiableQuoteTemplatesListModel> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_TEMPLATES_QUERY, {\n variables: {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n },\n });\n\n if (!results?.data?.negotiableQuoteTemplates) {\n throw new Error('No quote templates data received');\n }\n\n const transformedData = transformQuoteTemplatesList(results.data.negotiableQuoteTemplates);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote templates data');\n }\n\n events.emit('quote-management/quote-templates-data', {\n quoteTemplates: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};"],"names":["transformQuoteTemplate","templateData","_a","comment","a","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","transformQuoteTemplatesList","templatesData","template","QUOTE_TEMPLATES_QUERY","QuoteTemplateFilterStatus","QuoteTemplateSortField","SortDirection","getQuoteTemplates","params","state","results","fetchGraphQl","transformedData","events","error"],"mappings":"2HAcO,SAASA,EACZC,EACmC,eACnC,OAAKA,EAIE,CACH,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,IAAKE,IAAY,CAC/C,KAAMA,EAAE,KACR,IAAKA,EAAE,GAAA,GACT,IAEN,OAAQH,EAAa,QAAU,CAC3B,qBAAsBA,EAAa,OAAO,wBAA0B,CAChE,MAAOA,EAAa,OAAO,uBAAuB,MAClD,SAAUA,EAAa,OAAO,uBAAuB,QAAA,EAEzD,qBAAsBA,EAAa,OAAO,wBAA0B,CAChE,MAAOA,EAAa,OAAO,uBAAuB,MAClD,SAAUA,EAAa,OAAO,uBAAuB,QAAA,EAEzD,iCAAkCA,EAAa,OAC1C,sCAAwC,CAC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KC,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EAaAC,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAMAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAiBL,MAAMC,EAAoB,MAC/BC,EAAkC,KACa,OAC/C,GAAI,CAACC,EAAM,cACT,MAAM,IAAI,MAAM,cAAc,EAGhC,GAAI,CACF,MAAMC,EAAe,MAAMC,EAAaR,EAAuB,CAC7D,UAAW,CACT,OAAQK,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,CACvB,CACD,EAED,GAAI,GAACxB,EAAA0B,GAAA,YAAAA,EAAS,OAAT,MAAA1B,EAAe,0BAClB,MAAM,IAAI,MAAM,kCAAkC,EAGpD,MAAM4B,EAAkBZ,EAA4BU,EAAQ,KAAK,wBAAwB,EAEzF,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0CAA0C,EAG5D,OAAAC,EAAO,KAAK,wCAAyC,CACnD,eAAgBD,EAChB,YAAaH,EAAM,WAAA,CACpB,EAEMG,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
1
+ {"version":3,"file":"getQuoteTemplates.js","sources":["/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/graphql/getQuoteTemplates.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/getQuoteTemplates.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';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\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', 'IN_REVIEW'].includes(templateData.status),\n canDelete: ['CLOSED', 'INACTIVE'].includes(templateData.status),\n canReopen: templateData.status === 'CLOSED',\n canCancel: ['ACTIVE', 'IN_REVIEW', 'SUBMITTED'].includes(templateData.status),\n canGenerateQuote: templateData.status === 'ACTIVE',\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n return {\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 * 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 QUOTE_TEMPLATES_QUERY = /* GraphQL */ `\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n # uid\n template_id\n name\n # created_at\n # updated_at\n # last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n # expiration_date\n orders_placed\n # grand_total {\n # currency\n # value\n # }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\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 { QUOTE_TEMPLATES_QUERY } from './graphql/getQuoteTemplates';\nimport { transformQuoteTemplatesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplatesListModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QuoteTemplateFilterStatus {\n ACTIVE = 'ACTIVE',\n IN_REVIEW = 'IN_REVIEW',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface QuoteTemplateFilterInput {\n status?: QuoteTemplateFilterStatus[];\n name?: {\n match?: string;\n };\n}\n\nexport enum QuoteTemplateSortField {\n NAME = 'NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface QuoteTemplateSortInput {\n sortField: QuoteTemplateSortField;\n sortDirection: SortDirection;\n}\n\nexport interface GetQuoteTemplatesParams {\n filter?: QuoteTemplateFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: QuoteTemplateSortInput;\n}\n\nexport const getQuoteTemplates = async (\n params: GetQuoteTemplatesParams = {}\n): Promise<NegotiableQuoteTemplatesListModel> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_TEMPLATES_QUERY, {\n variables: {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n },\n });\n\n if (!results?.data?.negotiableQuoteTemplates) {\n throw new Error('No quote templates data received');\n }\n\n const transformedData = transformQuoteTemplatesList(results.data.negotiableQuoteTemplates);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote templates data');\n }\n\n events.emit('quote-management/quote-templates-data', {\n quoteTemplates: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};"],"names":["transformQuoteTemplate","templateData","_a","comment","a","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","transformQuoteTemplatesList","templatesData","template","QUOTE_TEMPLATES_QUERY","QuoteTemplateFilterStatus","QuoteTemplateSortField","SortDirection","getQuoteTemplates","params","state","results","fetchGraphQl","transformedData","events","error"],"mappings":"6HAcO,SAASA,EACZC,EACmC,eACnC,OAAKA,EAIE,CACH,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,IAAKE,IAAY,CAC/C,KAAMA,EAAE,KACR,IAAKA,EAAE,GAAA,GACT,IAEN,OAAQH,EAAa,QAAU,CAC3B,qBAAsBA,EAAa,OAAO,wBAA0B,CAChE,MAAOA,EAAa,OAAO,uBAA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/tools/event-bus.js";const u=`
3
+ import{f as n,a as s}from"./transform-quote.js";import{s as i}from"./state.js";import"@dropins/tools/event-bus.js";const u=`
4
4
  fragment NegotiableQuoteListFragment on NegotiableQuote {
5
5
  uid
6
6
  name
@@ -1 +1 @@
1
- {"version":3,"file":"negotiableQuotes.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/NegotiableQuoteListFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SearchResultPageInfoFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SortFieldsFragment.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/graphql/NegotiableQuotesQuery.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/negotiableQuotes.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const NEGOTIABLE_QUOTE_LIST_FRAGMENT = /* GraphQL */ `\n fragment NegotiableQuoteListFragment on NegotiableQuote {\n uid\n name\n created_at\n updated_at\n status\n buyer {\n firstname\n lastname\n }\n template_name\n prices {\n grand_total {\n value\n currency\n }\n }\n history {\n change_type\n changes {\n statuses {\n changes {\n new_status\n old_status\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\nexport const SEARCH_RESULT_PAGE_INFO_FRAGMENT = /* GraphQL */ `\n fragment SearchResultPageInfoFragment on SearchResultPageInfo {\n current_page\n page_size\n total_pages\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const SORT_FIELDS_FRAGMENT = /* GraphQL */ `\n fragment SortFieldsFragment on SortFields {\n default\n options {\n label\n value\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_LIST_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteListFragment';\nimport { SEARCH_RESULT_PAGE_INFO_FRAGMENT } from '@/quote-management/api/graphql/SearchResultPageInfoFragment';\nimport { SORT_FIELDS_FRAGMENT } from '@/quote-management/api/graphql/SortFieldsFragment';\n\nexport const NEGOTIABLE_QUOTES_QUERY = /* GraphQL */ `\n query negotiableQuotes(\n $filter: NegotiableQuoteFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteSortInput\n ) {\n negotiableQuotes(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n ...NegotiableQuoteListFragment\n }\n page_info {\n ...SearchResultPageInfoFragment\n }\n sort_fields {\n ...SortFieldsFragment\n }\n total_count\n }\n }\n\n ${NEGOTIABLE_QUOTE_LIST_FRAGMENT}\n ${SEARCH_RESULT_PAGE_INFO_FRAGMENT}\n ${SORT_FIELDS_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { NEGOTIABLE_QUOTES_QUERY } from './graphql/NegotiableQuotesQuery';\nimport { transformNegotiableQuotesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuotesListModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\nexport enum FilterMatchTypeEnum {\n FULL = 'FULL',\n PARTIAL = 'PARTIAL',\n}\n\nexport interface FilterEqualTypeInput {\n eq?: string;\n in?: string[];\n}\n\nexport interface FilterMatchTypeInput {\n match?: string;\n match_type?: FilterMatchTypeEnum;\n}\n\nexport interface NegotiableQuoteFilterInput {\n ids?: FilterEqualTypeInput;\n name?: FilterMatchTypeInput;\n}\n\nexport enum SortEnum {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport enum NegotiableQuoteSortableField {\n QUOTE_NAME = 'QUOTE_NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport interface NegotiableQuoteSortInput {\n sort_direction: SortEnum;\n sort_field: NegotiableQuoteSortableField;\n}\n\nexport interface NegotiableQuotesParams {\n filter?: NegotiableQuoteFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: NegotiableQuoteSortInput;\n}\n\nexport const negotiableQuotes = async (\n params: NegotiableQuotesParams = {}\n): Promise<NegotiableQuotesListModel> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const variables = {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n };\n\n try {\n const results: any = await fetchGraphQl(NEGOTIABLE_QUOTES_QUERY, {\n variables,\n });\n\n if (!results?.data?.negotiableQuotes) {\n throw new Error('No quotes data received');\n }\n\n const transformedData = transformNegotiableQuotesList(\n results.data.negotiableQuotes\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quotes data');\n }\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["NEGOTIABLE_QUOTE_LIST_FRAGMENT","SEARCH_RESULT_PAGE_INFO_FRAGMENT","SORT_FIELDS_FRAGMENT","NEGOTIABLE_QUOTES_QUERY","FilterMatchTypeEnum","SortEnum","NegotiableQuoteSortableField","negotiableQuotes","params","state","variables","results","fetchGraphQl","_a","transformedData","transformNegotiableQuotesList","error"],"mappings":"iHASO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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BAAA,EAGf,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
1
+ {"version":3,"file":"negotiableQuotes.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/NegotiableQuoteListFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SearchResultPageInfoFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SortFieldsFragment.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/graphql/NegotiableQuotesQuery.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/negotiableQuotes.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const NEGOTIABLE_QUOTE_LIST_FRAGMENT = /* GraphQL */ `\n fragment NegotiableQuoteListFragment on NegotiableQuote {\n uid\n name\n created_at\n updated_at\n status\n buyer {\n firstname\n lastname\n }\n template_name\n prices {\n grand_total {\n value\n currency\n }\n }\n history {\n change_type\n changes {\n statuses {\n changes {\n new_status\n old_status\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\nexport const SEARCH_RESULT_PAGE_INFO_FRAGMENT = /* GraphQL */ `\n fragment SearchResultPageInfoFragment on SearchResultPageInfo {\n current_page\n page_size\n total_pages\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const SORT_FIELDS_FRAGMENT = /* GraphQL */ `\n fragment SortFieldsFragment on SortFields {\n default\n options {\n label\n value\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_LIST_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteListFragment';\nimport { SEARCH_RESULT_PAGE_INFO_FRAGMENT } from '@/quote-management/api/graphql/SearchResultPageInfoFragment';\nimport { SORT_FIELDS_FRAGMENT } from '@/quote-management/api/graphql/SortFieldsFragment';\n\nexport const NEGOTIABLE_QUOTES_QUERY = /* GraphQL */ `\n query negotiableQuotes(\n $filter: NegotiableQuoteFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteSortInput\n ) {\n negotiableQuotes(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n ...NegotiableQuoteListFragment\n }\n page_info {\n ...SearchResultPageInfoFragment\n }\n sort_fields {\n ...SortFieldsFragment\n }\n total_count\n }\n }\n\n ${NEGOTIABLE_QUOTE_LIST_FRAGMENT}\n ${SEARCH_RESULT_PAGE_INFO_FRAGMENT}\n ${SORT_FIELDS_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { NEGOTIABLE_QUOTES_QUERY } from './graphql/NegotiableQuotesQuery';\nimport { transformNegotiableQuotesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuotesListModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\nexport enum FilterMatchTypeEnum {\n FULL = 'FULL',\n PARTIAL = 'PARTIAL',\n}\n\nexport interface FilterEqualTypeInput {\n eq?: string;\n in?: string[];\n}\n\nexport interface FilterMatchTypeInput {\n match?: string;\n match_type?: FilterMatchTypeEnum;\n}\n\nexport interface NegotiableQuoteFilterInput {\n ids?: FilterEqualTypeInput;\n name?: FilterMatchTypeInput;\n}\n\nexport enum SortEnum {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport enum NegotiableQuoteSortableField {\n QUOTE_NAME = 'QUOTE_NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport interface NegotiableQuoteSortInput {\n sort_direction: SortEnum;\n sort_field: NegotiableQuoteSortableField;\n}\n\nexport interface NegotiableQuotesParams {\n filter?: NegotiableQuoteFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: NegotiableQuoteSortInput;\n}\n\nexport const negotiableQuotes = async (\n params: NegotiableQuotesParams = {}\n): Promise<NegotiableQuotesListModel> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const variables = {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n };\n\n try {\n const results: any = await fetchGraphQl(NEGOTIABLE_QUOTES_QUERY, {\n variables,\n });\n\n if (!results?.data?.negotiableQuotes) {\n throw new Error('No quotes data received');\n }\n\n const transformedData = transformNegotiableQuotesList(\n results.data.negotiableQuotes\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quotes data');\n }\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["NEGOTIABLE_QUOTE_LIST_FRAGMENT","SEARCH_RESULT_PAGE_INFO_FRAGMENT","SORT_FIELDS_FRAGMENT","NEGOTIABLE_QUOTES_QUERY","FilterMatchTypeEnum","SortEnum","NegotiableQuoteSortableField","negotiableQuotes","params","state","variables","results","fetchGraphQl","_a","transformedData","transformNegotiableQuotesList","error"],"mappings":"mHASO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{f as g,t as q}from"./fetch-graphql.js";import{s as p}from"./state.js";import{events as _}from"@dropins/tools/event-bus.js";import{N as E}from"./NegotiableQuoteFragment.js";const Q=`
3
+ import{f as g,t as q}from"./transform-quote.js";import{s as p}from"./state.js";import{events as _}from"@dropins/tools/event-bus.js";import{N as E}from"./NegotiableQuoteFragment.js";const Q=`
4
4
  query QUOTE_DATA_QUERY(
5
5
  $quoteId: ID!
6
6
  ) {
@@ -1 +1 @@
1
- {"version":3,"file":"renameNegotiableQuote.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/renameNegotiableQuote/graphql/RenameNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/renameNegotiableQuote.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_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"],"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","RENAME_NEGOTIABLE_QUOTE_MUTATION","renameNegotiableQuote","quoteName","quoteComment"],"mappings":"mLAEO,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,OAAO,QAAQ,OAAOA,CAAK,CAC/B,CACJ,ECrCaC,EAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC2BxBC,EAAc,M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tB,GAChBuB,GAAAtB,EAAAO,EAAS,OAAT,YAAAP,EAAe,wBAAf,YAAAsB,EAAsC,KAAA,EAGxC,GAAI,CAACD,EACH,MAAM,IAAI,MACR,4DAAA,EAKJ,OAAApB,EAAO,KAAK,iCAAkC,CAC5C,MAAOoB,EACP,MAAO,CAAE,SAAAF,EAAU,UAAAa,EAAW,aAAAC,CAAA,CAAa,CAC5C,EAEMZ,CACT,CAAC,CACH"}
1
+ {"version":3,"file":"renameNegotiableQuote.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/renameNegotiableQuote/graphql/RenameNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/renameNegotiableQuote.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_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"],"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","RENAME_NEGOTIABLE_QUOTE_MUTATION","renameNegotiableQuote","quoteName","quoteComment"],"mappings":"qLAEO,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,OAAO,QAAQ,OAAOA,CAAK,CAC/B,CACJ,ECrCaC,EAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC2BxBC,EAAc,MAAQC,GAA8D,OAC/F,GAAI,CAACV,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,MAAMW,EAAiB,MAAM,QAAQD,CAAS,EAAIA,EAAY,CAACA,CAAS,EAExE,GAAI,CACF,MAAME,EAA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,EACP,MAAO,CAAE,SAAAF,EAAU,UAAAa,EAAW,aAAAC,CAAA,CAAa,CAC5C,EAEMZ,CACT,CAAC,CACH"}
package/chunks/state.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- var t=(e=>(e[e.TAX_INCLUDED=1]="TAX_INCLUDED",e[e.TAX_EXCLUDED=2]="TAX_EXCLUDED",e[e.TAX_INCLUDED_AND_EXCLUDED=3]="TAX_INCLUDED_AND_EXCLUDED",e))(t||{});const E={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1},r={quoteDisplaySettings:{zeroTax:!1,subtotal:t.TAX_INCLUDED,price:t.TAX_INCLUDED,shipping:t.TAX_INCLUDED,fullSummary:!1,grandTotal:!0}},a={authenticated:!1,permissions:E,config:r},_=new Proxy(a,{get:(e,D)=>e[D],set:(e,D,s)=>(e[D]=s,!0)});export{E as D,t as Q,_ as s};
3
+ var t=(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))(t||{});const D={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1},r={quoteSummaryDisplayTotal:1,quoteSummaryMaxItems:10,quoteDisplaySettings:{zeroTax:!1,subtotal:t.TAX_INCLUDED,price:t.TAX_INCLUDED,shipping:t.TAX_INCLUDED,fullSummary:!1,grandTotal:!0},useConfigurableParentThumbnail:!0},E={authenticated:!1,permissions:D,config:r},_=new Proxy(E,{get:(e,a)=>e[a],set:(e,a,s)=>(e[a]=s,!0)});export{D,t as Q,r as a,_ as s};
4
4
  //# sourceMappingURL=state.js.map
@@ -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_INCLUDED = 1,\n TAX_EXCLUDED = 2,\n TAX_INCLUDED_AND_EXCLUDED = 3,\n}\n\nexport interface StoreConfigModel {\n quoteDisplaySettings: {\n zeroTax: boolean;\n subtotal: QuoteDisplayAmount;\n price: QuoteDisplayAmount;\n shipping: QuoteDisplayAmount;\n fullSummary: boolean;\n grandTotal: boolean;\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 {\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};\n\nexport const DEFAULT_CONFIG: StoreConfigModel = {\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};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n config: DEFAULT_CONFIG,\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,EACjB,EAEaC,EAAmC,CAC9C,qBAAsB,CACpB,QAAS,GACT,SAAUF,EAAmB,aAC7B,MAAOA,EAAmB,aAC1B,SAAUA,EAAmB,aAC7B,YAAa,GACb,WAAY,EAAA,CAEhB,EAEMG,EAAgB,CACpB,cAAe,GACf,YAAaF,EACb,OAAQC,CACV,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
+ {"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};\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};\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,EACjB,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,CACV,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAK,CAACE,EAAQC,IACLD,EAAOC,CAAkB,EAElC,IAAK,CAACD,EAAQC,EAAKC,KACjBF,EAAOC,CAAkB,EAAIC,EACtB,GAEX,CAAC"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{FetchGraphQL as D}from"@dropins/tools/fetch-graphql.js";import{s as g}from"./state.js";var x=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(x||{});const{setEndpoint:M,setFetchGraphQlHeader:z,removeFetchGraphQlHeader:B,setFetchGraphQlHeaders:G,fetchGraphQl:W,getConfig:H}=new D().getMethods(),b=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function P(e){if(!e.items)return 0;const r=g.config;return(r==null?void 0:r.quoteSummaryDisplayTotal)===0?e.items.length:(r==null?void 0:r.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function w(e){var n,c,i,l;const r=g.config;return{src:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(n=e.configured_variant)==null?void 0:n.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.label:((l=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:l.label)||e.product.thumbnail.label}}function C(e){var r;return((r=e.links)==null?void 0:r.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function T(e,r){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>r>=c.quantity)||null}function A(e){var s,o;const r=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(s=e.configured_variant)==null?void 0:s.price_tiers:e.product.price_tiers,i=n?(o=e.configured_variant)==null?void 0:o.price_range:e.product.price_range,l=T(c,r);return l?l.discount.amount_off>0:(i==null?void 0:i.maximum_price.discount.amount_off)>0}function O(e){var i,l,s,o,d,a,u,p;const r=e.quantity,n=T(e.product.price_tiers,r);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(o=(s=(l=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:l.maximum_price)==null?void 0:s.discount)==null?void 0:o.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(p=(u=(a=(d=e==null?void 0:e.product)==null?void 0:d.price_range)==null?void 0:a.maximum_price)==null?void 0:u.discount)==null?void 0:p.percent_off}if(c!==0)return Math.round(c)}function R(e){var r,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(r=e.configured_variant)==null?void 0:r.price_range)==null?void 0:n.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function N(e){var c,i,l,s,o,d;let r,n;if(r=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((s=(l=e==null?void 0:e.prices)==null?void 0:l.row_total)==null?void 0:s.value),n=(d=(o=e==null?void 0:e.prices)==null?void 0:o.row_total)==null?void 0:d.currency,r!==0)return{value:r,currency:n}}function S(e){var n,c,i,l,s,o,d;const r=I(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:r?x.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:P(e),comments:(n=e.comments)==null?void 0:n.map(a=>{const u={uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},text:a.text};return Array.isArray(a.attachments)&&a.attachments.length>0&&(u.attachments=a.attachments.map(p=>({name:p.name,url:p.url}))),u}),prices:e.prices&&{appliedDiscounts:(c=e.prices.discounts)==null?void 0:c.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label,coupon:a.coupon})),appliedTaxes:(i=e.prices.applied_taxes)==null?void 0:i.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label})),discount:e.prices.discounts&&e.prices.grand_total&&E(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...Q(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&E(e.prices.applied_taxes,e.prices.grand_total.currency)},history:(l=e.history)==null?void 0:l.map(a=>{var u,p,f,m,v,y,h;return{uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},changeType:a.change_type,changes:{commentAdded:((u=a.changes)==null?void 0:u.comment_added)&&{comment:a.changes.comment_added.comment},customChanges:((p=a.changes)==null?void 0:p.custom_changes)&&{new_value:a.changes.custom_changes.new_value,old_value:a.changes.custom_changes.old_value,title:a.changes.custom_changes.title},expiration:((f=a.changes)==null?void 0:f.expiration)&&{newExpiration:a.changes.expiration.new_expiration,oldExpiration:a.changes.expiration.old_expiration},productsRemoved:((m=a.changes)==null?void 0:m.products_removed)&&{productsRemovedFromCatalog:a.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:a.changes.products_removed.products_removed_from_quote||[]},statuses:((v=a.changes)==null?void 0:v.statuses)&&{changes:((y=a.changes.statuses.changes)==null?void 0:y.map(t=>({newStatus:t.new_status,oldStatus:t.old_status})))||[]},total:((h=a.changes)==null?void 0:h.total)&&a.changes.total.new_price&&a.changes.total.old_price&&{newPrice:{value:a.changes.total.new_price.value,currency:a.changes.total.new_price.currency},oldPrice:{value:a.changes.total.old_price.value,currency:a.changes.total.old_price.currency}}}}}),items:((s=e.items)==null?void 0:s.map(a=>{var u,p,f,m,v,y,h;return{itemType:a.__typename,uid:a.uid,product:{uid:a.product.uid,sku:a.product.sku,name:a.product.name,priceRange:{maximumPrice:{regularPrice:{value:a.product.price_range.maximum_price.regular_price.value,currency:a.product.price_range.maximum_price.regular_price.currency}}}},image:w(a),links:C(a),discounted:A(a),discountedTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},catalogDiscount:{amountOff:a.prices.catalog_discount.amount_off,percentOff:a.prices.catalog_discount.percent_off},discounts:((p=(u=a.prices)==null?void 0:u.discounts)==null?void 0:p.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:O(a),insufficientQuantity:(a.__typename==="ConfigurableCartItem"?a.configured_variant:a.product).stock_status==="IN_STOCK"&&!a.is_available,outOfStock:a.product.stock_status==="OUT_OF_STOCK",stockStatus:a.product.stock_status,quantity:a.quantity,prices:{regularPrice:R(a),priceIncludingTax:{value:a.prices.price_including_tax.value,currency:a.prices.price_including_tax.currency},originalItemPrice:{value:a.prices.original_item_price.value,currency:a.prices.original_item_price.currency},originalRowTotal:{value:a.prices.original_row_total.value,currency:a.prices.original_row_total.currency},rowTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},rowTotalIncludingTax:{value:a.prices.row_total_including_tax.value,currency:a.prices.row_total_including_tax.currency}},savingsAmount:N(a),noteFromBuyer:(f=a.note_from_buyer)==null?void 0:f.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(m=a.note_from_seller)==null?void 0:m.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(v=a.configurable_options)==null?void 0:v.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(y=a.bundle_options)==null?void 0:y.map(t=>({label:t.label,values:t.values.map(_=>({label:_.label,quantity:_.quantity,originalPrice:{value:_.original_price.value,currency:_.original_price.currency},price:{value:_.priceV2.value,currency:_.priceV2.currency}}))})),customizableOptions:(h=a.customizable_options)==null?void 0:h.map(t=>({type:t.type,label:t.label,values:t.values.map(_=>({label:_.label,value:_.value}))}))}}))||[],shippingAddresses:(o=e.shipping_addresses)==null?void 0:o.map(a=>{const u={uid:a.uid,firstname:a.firstname,lastname:a.lastname,company:a.company,street:a.street,city:a.city,postcode:a.postcode,country:{code:a.country.code,label:a.country.label},telephone:a.telephone};return a.region&&(u.region={code:a.region.code,label:a.region.label,regionId:a.region.region_id}),u}),canCheckout:["UPDATED","DECLINED","OPEN"].includes(e.status)&&g.permissions.checkoutQuote&&((d=e.shipping_addresses)==null?void 0:d.length)>0,canSendForReview:(r||b.includes(e.status))&&g.permissions.editQuote,canUpdateQuote:(r||b.includes(e.status))&&g.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&g.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1}}function V(e){return e?S(e):null}function I(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(r=>{var n,c;return r.change_type==="UPDATED"&&(((c=(n=r.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function U(e){const r=I(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:r?x.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function X(e){var c;if(!e)return null;const r={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(U))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},n=F(r);return{...r,paginationInfo:n||void 0}}function F(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:r,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,l=i>0?(r-1)*n+1:0,s=Math.min(r*n,i);return{currentPage:r,totalCount:i,pageSize:n,startItem:l,endItem:s,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const K=()=>[20,30,50,100,200];function E(e,r){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:r}):{value:0,currency:r}}function Q(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const n=e.shipping_addresses[0].selected_shipping_method;return n?{shippingIncludingTax:n.price_incl_tax&&{value:n.price_incl_tax.value,currency:n.price_incl_tax.currency},shippingExcludingTax:n.price_excl_tax&&{value:n.price_excl_tax.value,currency:n.price_excl_tax.currency}}:{}}export{X as a,z as b,G as c,H as d,W as f,K as g,B as r,M as s,V as t};
4
+ //# sourceMappingURL=transform-quote.js.map