@dropins/storefront-quote-management 0.0.1-alpha24 → 0.0.1-alpha25

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ItemsQuotedTemplate.js","sources":["/@dropins/storefront-quote-management/src/containers/ItemsQuotedTemplate/ItemsQuotedTemplate.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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Price } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { QuotePricesSummary, ProductListTable, ItemsQuoted as ItemsQuotedComponent } from '@/quote-management/components';\n\nexport interface ItemsQuotedTemplateProps extends HTMLAttributes<HTMLDivElement> {\n templateData?: NegotiableQuoteTemplateModel;\n slots?: {\n ProductListTable?: SlotProps<{\n items: NegotiableQuoteTemplateModel['items'];\n canEdit: boolean;\n }>;\n QuotePricesSummary?: SlotProps<{\n items: NegotiableQuoteTemplateModel['items'];\n prices: NegotiableQuoteTemplateModel['prices'];\n }>;\n }\n}\n\nexport const ItemsQuotedTemplate: Container<ItemsQuotedTemplateProps> = ({\n templateData: initialData,\n slots,\n ...props\n}) => {\n const [templateData, setTemplateData] = useState<NegotiableQuoteTemplateModel | undefined>(initialData);\n\n const dictionary = useText({\n subtotal: 'NegotiableQuoteTemplate.Manage.quotePricesSummary.subtotal.excludingTax',\n grandTotal: 'NegotiableQuoteTemplate.Manage.quotePricesSummary.grandTotal.includingTax',\n appliedTaxes: 'NegotiableQuoteTemplate.Manage.quotePricesSummary.appliedTaxes',\n });\n\n useEffect(() => {\n const templateDataEvent = events.on('quote-management/quote-template-data', (payload) => {\n setTemplateData(payload.quoteTemplate);\n }, { eager: true });\n\n return () => templateDataEvent?.off();\n }, []);\n\n if (!templateData) {\n return <ItemsQuotedComponent loading={true} />;\n }\n\n const quotePricesSummaryEntries = [];\n\n templateData.prices.subtotalExcludingTax && quotePricesSummaryEntries.push({\n label: dictionary.subtotal,\n id: 'subtotal',\n value: <Price amount={templateData.prices.subtotalExcludingTax.value} currency={templateData.prices.subtotalExcludingTax.currency} weight='normal' />,\n })\n\n templateData.prices.grandTotal && quotePricesSummaryEntries.push({\n label: dictionary.grandTotal,\n id: 'total',\n value: <Price amount={templateData.prices.grandTotal.value} currency={templateData.prices.grandTotal.currency} />,\n strong: true,\n })\n\n return (\n <ItemsQuotedComponent data-testid=\"items-quoted-template-container\" {...props} loading={false}\n table={\n <Slot name=\"ProductListTable\" slot={slots?.ProductListTable}\n context={{\n items: templateData.items,\n canEdit: false,\n }}>\n\n <ProductListTable items={templateData.items} canEdit={false} />\n </Slot>\n }\n pricesSummary={<Slot name=\"QuotePricesSummary\" slot={slots?.QuotePricesSummary} context={{\n items: templateData.items,\n prices: templateData.prices,\n }}>\n <QuotePricesSummary entries={quotePricesSummaryEntries} />\n </Slot>\n }\n />\n );\n};\n"],"names":["ItemsQuotedTemplate","initialData","slots","props","templateData","setTemplateData","useState","dictionary","useText","useEffect","templateDataEvent","events","payload","jsx","ItemsQuotedComponent","quotePricesSummaryEntries","Price","Slot","ProductListTable","QuotePricesSummary"],"mappings":"whBA+BO,MAAMA,EAA2D,CAAC,CACvE,aAAcC,EACd,MAAAC,EACA,GAAGC,CACL,IAAM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAmDL,CAAW,EAEhGM,EAAaC,EAAQ,CACzB,SAAU,0EACV,WAAY,4EACZ,aAAc,gEAAA,CACf,EAUD,GARAC,EAAU,IAAM,CACd,MAAMC,EAAoBC,EAAO,GAAG,uCAAyCC,GAAY,CACvFP,EAAgBO,EAAQ,aAAa,CACvC,EAAG,CAAE,MAAO,GAAM,EAElB,MAAO,IAAMF,GAAA,YAAAA,EAAmB,KAClC,EAAG,CAAA,CAAE,EAED,CAACN,EACH,OAAOS,EAACC,EAAA,CAAqB,QAAS,EAAA,CAAM,EAG9C,MAAMC,EAA4B,CAAA,EAElC,OAAAX,EAAa,OAAO,sBAAwBW,EAA0B,KAAK,CACzE,MAAOR,EAAW,SAClB,GAAI,WACJ,MAAOM,EAACG,EAAA,CAAM,OAAQZ,EAAa,OAAO,qBAAqB,MAAO,SAAUA,EAAa,OAAO,qBAAqB,SAAU,OAAO,QAAA,CAAS,CAAA,CACpJ,EAEDA,EAAa,OAAO,YAAcW,EAA0B,KAAK,CAC/D,MAAOR,EAAW,WAClB,GAAI,QACJ,MAAOM,EAACG,EAAA,CAAM,OAAQZ,EAAa,OAAO,WAAW,MAAO,SAAUA,EAAa,OAAO,WAAW,QAAA,CAAU,EAC/G,OAAQ,EAAA,CACT,EAGCS,EAACC,EAAA,CAAqB,cAAY,kCAAmC,GAAGX,EAAO,QAAS,GACtF,MACEU,EAACI,EAAA,CAAK,KAAK,mBAAmB,KAAMf,GAAA,YAAAA,EAAO,iBACzC,QAAS,CACP,MAAOE,EAAa,MACpB,QAAS,EAAA,EAGX,WAACc,EAAA,CAAiB,MAAOd,EAAa,MAAO,QAAS,EAAA,CAAO,CAAA,CAAA,EAGjE,gBAAgBa,EAAA,CAAK,KAAK,qBAAqB,KAAMf,GAAA,YAAAA,EAAO,mBAAoB,QAAS,CACvF,MAAOE,EAAa,MACpB,OAAQA,EAAa,MAAA,EAErB,SAAAS,EAACM,EAAA,CAAmB,QAASJ,EAA2B,CAAA,CAC1D,CAAA,CAAA,CAIN"}
1
+ {"version":3,"file":"ItemsQuotedTemplate.js","sources":["/@dropins/storefront-quote-management/src/containers/ItemsQuotedTemplate/ItemsQuotedTemplate.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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Price } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { QuotePricesSummary, ProductListTable, ItemsQuoted as ItemsQuotedComponent } from '@/quote-management/components';\n\nexport interface ItemsQuotedTemplateProps extends HTMLAttributes<HTMLDivElement> {\n templateData?: NegotiableQuoteTemplateModel;\n slots?: {\n ProductListTable?: SlotProps<{\n items: NegotiableQuoteTemplateModel['items'];\n canEdit: boolean;\n }>;\n QuotePricesSummary?: SlotProps<{\n items: NegotiableQuoteTemplateModel['items'];\n prices: NegotiableQuoteTemplateModel['prices'];\n }>;\n }\n}\n\nexport const ItemsQuotedTemplate: Container<ItemsQuotedTemplateProps> = ({\n templateData: initialData,\n slots,\n ...props\n}) => {\n const [templateData, setTemplateData] = useState<NegotiableQuoteTemplateModel | undefined>(initialData);\n\n const dictionary = useText({\n subtotal: 'NegotiableQuoteTemplate.Manage.quotePricesSummary.subtotal.excludingTax',\n grandTotal: 'NegotiableQuoteTemplate.Manage.quotePricesSummary.grandTotal.includingTax',\n appliedTaxes: 'NegotiableQuoteTemplate.Manage.quotePricesSummary.appliedTaxes',\n });\n\n useEffect(() => {\n const templateDataEvent = events.on('quote-management/quote-template-data', (payload) => {\n setTemplateData(payload.quoteTemplate);\n }, { eager: true });\n\n return () => templateDataEvent?.off();\n }, []);\n\n if (!templateData) {\n return <ItemsQuotedComponent loading={true} />;\n }\n\n const quotePricesSummaryEntries = [];\n\n templateData.prices.subtotalExcludingTax && quotePricesSummaryEntries.push({\n label: dictionary.subtotal,\n id: 'subtotal',\n value: <Price amount={templateData.prices.subtotalExcludingTax.value} currency={templateData.prices.subtotalExcludingTax.currency} weight='normal' />,\n });\n\n templateData.prices.grandTotal && quotePricesSummaryEntries.push({\n label: dictionary.grandTotal,\n id: 'total',\n value: <Price amount={templateData.prices.grandTotal.value} currency={templateData.prices.grandTotal.currency} />,\n strong: true,\n })\n\n return (\n <ItemsQuotedComponent data-testid=\"items-quoted-template-container\" {...props} loading={false}\n table={\n <Slot name=\"ProductListTable\" slot={slots?.ProductListTable}\n context={{\n items: templateData.items,\n canEdit: false,\n }}>\n\n <ProductListTable items={templateData.items} canEdit={false} />\n </Slot>\n }\n pricesSummary={<Slot name=\"QuotePricesSummary\" slot={slots?.QuotePricesSummary} context={{\n items: templateData.items,\n prices: templateData.prices,\n }}>\n <QuotePricesSummary entries={quotePricesSummaryEntries} />\n </Slot>\n }\n />\n );\n};\n"],"names":["ItemsQuotedTemplate","initialData","slots","props","templateData","setTemplateData","useState","dictionary","useText","useEffect","templateDataEvent","events","payload","jsx","ItemsQuotedComponent","quotePricesSummaryEntries","Price","Slot","ProductListTable","QuotePricesSummary"],"mappings":"whBA+BO,MAAMA,EAA2D,CAAC,CACvE,aAAcC,EACd,MAAAC,EACA,GAAGC,CACL,IAAM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAmDL,CAAW,EAEhGM,EAAaC,EAAQ,CACzB,SAAU,0EACV,WAAY,4EACZ,aAAc,gEAAA,CACf,EAUD,GARAC,EAAU,IAAM,CACd,MAAMC,EAAoBC,EAAO,GAAG,uCAAyCC,GAAY,CACvFP,EAAgBO,EAAQ,aAAa,CACvC,EAAG,CAAE,MAAO,GAAM,EAElB,MAAO,IAAMF,GAAA,YAAAA,EAAmB,KAClC,EAAG,CAAA,CAAE,EAED,CAACN,EACH,OAAOS,EAACC,EAAA,CAAqB,QAAS,EAAA,CAAM,EAG9C,MAAMC,EAA4B,CAAA,EAElC,OAAAX,EAAa,OAAO,sBAAwBW,EAA0B,KAAK,CACzE,MAAOR,EAAW,SAClB,GAAI,WACJ,MAAOM,EAACG,EAAA,CAAM,OAAQZ,EAAa,OAAO,qBAAqB,MAAO,SAAUA,EAAa,OAAO,qBAAqB,SAAU,OAAO,QAAA,CAAS,CAAA,CACpJ,EAEDA,EAAa,OAAO,YAAcW,EAA0B,KAAK,CAC/D,MAAOR,EAAW,WAClB,GAAI,QACJ,MAAOM,EAACG,EAAA,CAAM,OAAQZ,EAAa,OAAO,WAAW,MAAO,SAAUA,EAAa,OAAO,WAAW,QAAA,CAAU,EAC/G,OAAQ,EAAA,CACT,EAGCS,EAACC,EAAA,CAAqB,cAAY,kCAAmC,GAAGX,EAAO,QAAS,GACtF,MACEU,EAACI,EAAA,CAAK,KAAK,mBAAmB,KAAMf,GAAA,YAAAA,EAAO,iBACzC,QAAS,CACP,MAAOE,EAAa,MACpB,QAAS,EAAA,EAGX,WAACc,EAAA,CAAiB,MAAOd,EAAa,MAAO,QAAS,EAAA,CAAO,CAAA,CAAA,EAGjE,gBAAgBa,EAAA,CAAK,KAAK,qBAAqB,KAAMf,GAAA,YAAAA,EAAO,mBAAoB,QAAS,CACvF,MAAOE,EAAa,MACpB,OAAQA,EAAa,MAAA,EAErB,SAAAS,EAACM,EAAA,CAAmB,QAASJ,EAA2B,CAAA,CAC1D,CAAA,CAAA,CAIN"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as o,jsxs as d}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useEffect as f}from"@dropins/tools/preact-compat.js";import{getGlobalLocale as h}from"@dropins/tools/lib.js";import{Q as p}from"./QuoteCommentsList.js";import{events as g}from"@dropins/tools/event-bus.js";const j=({quoteData:a,...n})=>{var r;const[e,s]=l(a);if(f(()=>{const t=g.on("quote-management/quote-data",c=>{s(c.quote)},{eager:!0});return()=>t==null?void 0:t.off()},[]),!e)return null;const m=h()||"en-US",i=new Intl.DateTimeFormat(m,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),u=(r=e==null?void 0:e.comments)==null?void 0:r.map(t=>({uid:t.uid,createdAt:o("span",{children:i.format(new Date(t.createdAt))}),author:d("span",{children:[t.author.firstname," ",t.author.lastname]}),text:o("p",{children:t.text})}));return o(p,{"data-testid":"quote-comments-list-container",...n,comments:u||[]})};export{j as Q};
3
+ import{jsx as o,jsxs as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as f,useEffect as d}from"@dropins/tools/preact-compat.js";import{Q as c}from"./QuoteCommentsList.js";import{events as p}from"@dropins/tools/event-bus.js";import{f as l}from"./dateUtils.js";const C=({quoteData:s,...a})=>{var r;const[e,n]=f(s);if(d(()=>{const t=p.on("quote-management/quote-data",u=>{n(u.quote)},{eager:!0});return()=>t==null?void 0:t.off()},[]),!e)return null;const m=(r=e==null?void 0:e.comments)==null?void 0:r.map(t=>({uid:t.uid,createdAt:o("span",{children:l(t.createdAt,"long")}),author:i("span",{children:[t.author.firstname," ",t.author.lastname]}),text:o("p",{children:t.text})}));return o(c,{"data-testid":"quote-comments-list-container",...a,comments:m||[]})};export{C as Q};
4
4
  //# sourceMappingURL=QuoteCommentsList3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuoteCommentsList3.js","sources":["/@dropins/storefront-quote-management/src/containers/QuoteCommentsList/QuoteCommentsList.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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, getGlobalLocale } from '@adobe-commerce/elsie/lib';\nimport { QuoteCommentsList as QuoteCommentsListComponent } from '@/quote-management/components/QuoteCommentsList';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface QuoteCommentsListProps\n extends HTMLAttributes<HTMLUListElement> {\n quoteData?: NegotiableQuoteModel;\n}\n\nexport const QuoteCommentsList: Container<QuoteCommentsListProps> = ({\n quoteData: initialData,\n ...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 // Format comments data\n const calculatedLocale = getGlobalLocale() || 'en-US';\n const dateFormatter = new Intl.DateTimeFormat(calculatedLocale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n });\n\n const formattedComments = quoteData?.comments?.map((comment) => ({\n uid: comment.uid,\n createdAt: <span>{dateFormatter.format(new Date(comment.createdAt))}</span>,\n author: (\n <span>\n {comment.author.firstname} {comment.author.lastname}\n </span>\n ),\n text: <p>{comment.text}</p>,\n }));\n\n return (\n <QuoteCommentsListComponent\n data-testid=\"quote-comments-list-container\"\n {...props}\n comments={formattedComments || []}\n />\n );\n};\n"],"names":["QuoteCommentsList","initialData","props","quoteData","setQuoteData","useState","useEffect","quoteDataEvent","events","data","calculatedLocale","getGlobalLocale","dateFormatter","formattedComments","_a","comment","jsx","QuoteCommentsListComponent"],"mappings":"uSAoBO,MAAMA,EAAuD,CAAC,CACnE,UAAWC,EACX,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAChCJ,CAAA,EAgBF,GAbAK,EAAU,IAAM,CACd,MAAMC,EAAiBC,EAAO,GAC5B,8BACCC,GAA0C,CACzCL,EAAaK,EAAK,KAAK,CACzB,EACA,CACE,MAAO,EAAA,CACT,EAEF,MAAO,IAAMF,GAAA,YAAAA,EAAgB,KAC/B,EAAG,CAAA,CAAE,EAED,CAACJ,EACH,OAAO,KAIT,MAAMO,EAAmBC,KAAqB,QACxCC,EAAgB,IAAI,KAAK,eAAeF,EAAkB,CAC9D,KAAM,UACN,MAAO,QACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OAAQ,EAAA,CACT,EAEKG,GAAoBC,EAAAX,GAAA,YAAAA,EAAW,WAAX,YAAAW,EAAqB,IAAKC,IAAa,CAC/D,IAAKA,EAAQ,IACb,UAAWC,EAAC,OAAA,CAAM,SAAAJ,EAAc,OAAO,IAAI,KAAKG,EAAQ,SAAS,CAAC,CAAA,CAAE,EACpE,SACG,OAAA,CACE,SAAA,CAAAA,EAAQ,OAAO,UAAU,IAAEA,EAAQ,OAAO,QAAA,EAC7C,EAEF,KAAMC,EAAC,IAAA,CAAG,SAAAD,EAAQ,IAAA,CAAK,CAAA,IAGzB,OACEC,EAACC,EAAA,CACC,cAAY,gCACX,GAAGf,EACJ,SAAUW,GAAqB,CAAA,CAAC,CAAA,CAGtC"}
1
+ {"version":3,"file":"QuoteCommentsList3.js","sources":["/@dropins/storefront-quote-management/src/containers/QuoteCommentsList/QuoteCommentsList.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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { QuoteCommentsList as QuoteCommentsListComponent } from '@/quote-management/components/QuoteCommentsList';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { events } from '@adobe-commerce/event-bus';\nimport { formattedDate } from '@/quote-management/utils/dateUtils';\n\nexport interface QuoteCommentsListProps\n extends HTMLAttributes<HTMLUListElement> {\n quoteData?: NegotiableQuoteModel;\n}\n\nexport const QuoteCommentsList: Container<QuoteCommentsListProps> = ({\n quoteData: initialData,\n ...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 // Format comments data\n const formattedComments = quoteData?.comments?.map((comment) => ({\n uid: comment.uid,\n createdAt: <span>{formattedDate(comment.createdAt, 'long')}</span>,\n author: (\n <span>\n {comment.author.firstname} {comment.author.lastname}\n </span>\n ),\n text: <p>{comment.text}</p>,\n }));\n\n return (\n <QuoteCommentsListComponent\n data-testid=\"quote-comments-list-container\"\n {...props}\n comments={formattedComments || []}\n />\n );\n};\n"],"names":["QuoteCommentsList","initialData","props","quoteData","setQuoteData","useState","useEffect","quoteDataEvent","events","data","formattedComments","_a","comment","jsx","QuoteCommentsListComponent"],"mappings":"kRAqBO,MAAMA,EAAuD,CAAC,CACnE,UAAWC,EACX,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAChCJ,CAAA,EAgBF,GAbAK,EAAU,IAAM,CACd,MAAMC,EAAiBC,EAAO,GAC5B,8BACCC,GAA0C,CACzCL,EAAaK,EAAK,KAAK,CACzB,EACA,CACE,MAAO,EAAA,CACT,EAEF,MAAO,IAAMF,GAAA,YAAAA,EAAgB,KAC/B,EAAG,CAAA,CAAE,EAED,CAACJ,EACH,OAAO,KAIT,MAAMO,GAAoBC,EAAAR,GAAA,YAAAA,EAAW,WAAX,YAAAQ,EAAqB,IAAKC,IAAa,CAC/D,IAAKA,EAAQ,IACb,UAAWC,EAAC,OAAA,CAAM,WAAcD,EAAQ,UAAW,MAAM,EAAE,EAC3D,SACG,OAAA,CACE,SAAA,CAAAA,EAAQ,OAAO,UAAU,IAAEA,EAAQ,OAAO,QAAA,EAC7C,EAEF,KAAMC,EAAC,IAAA,CAAG,SAAAD,EAAQ,IAAA,CAAK,CAAA,IAGzB,OACEC,EAACC,EAAA,CACC,cAAY,gCACX,GAAGZ,EACJ,SAAUQ,GAAqB,CAAA,CAAC,CAAA,CAGtC"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as d,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{getGlobalLocale as U,classes as P}from"@dropins/tools/lib.js";import{g as Q,f as y}from"./dateUtils.js";/* empty css */import{useText as I}from"@dropins/tools/i18n.js";const V=({className:_,children:x,history:q,items:h,buyer:n,salesRepName:F,...w})=>{const E=U()||"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"}),p=new Intl.DateTimeFormat(E,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:Q()}),S=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,o=>o.toUpperCase())}},A=e=>{var a,m,c,u,i,v,C,g,L,f,D,N;const o=[];if((a=e==null?void 0:e.commentAdded)!=null&&a.comment&&o.push(t.commentDetail.replace("{comment}",e.commentAdded.comment)),(m=e==null?void 0:e.statuses)!=null&&m.changes&&e.statuses.changes.forEach(r=>{r.oldStatus&&r.newStatus?o.push(t.statusChangedFromTo.replace("{oldStatus}",r.oldStatus).replace("{newStatus}",r.newStatus)):r.newStatus&&o.push(t.statusSetTo.replace("{newStatus}",r.newStatus))}),(c=e==null?void 0:e.expiration)!=null&&c.newExpiration&&((u=e==null?void 0:e.expiration)!=null&&u.oldExpiration)){const r=y(e.expiration.newExpiration,p),l=y(e.expiration.oldExpiration,p);o.push(t.expirationChangedFromTo.replace("{oldExpiration}",l).replace("{newExpiration}",r))}else if((i=e==null?void 0:e.expiration)!=null&&i.newExpiration){const r=y(e.expiration.newExpiration,p);o.push(t.expirationSetTo.replace("{newExpiration}",r))}if((v=e==null?void 0:e.total)!=null&&v.newPrice&&((C=e==null?void 0:e.total)!=null&&C.oldPrice)){const r=`${e.total.newPrice.currency} ${e.total.newPrice.value}`,l=`${e.total.oldPrice.currency} ${e.total.oldPrice.value}`;o.push(t.totalChangedFromTo.replace("{oldTotal}",l).replace("{newTotal}",r))}if((g=e==null?void 0:e.customChanges)!=null&&g.title&&((L=e==null?void 0:e.customChanges)!=null&&L.old_value)&&((f=e==null?void 0:e.customChanges)!=null&&f.new_value)&&o.push(t.customChange.replace("{title}",e.customChanges.title).replace("{oldValue}",e.customChanges.old_value).replace("{newValue}",e.customChanges.new_value)),(D=e==null?void 0:e.productsRemoved)!=null&&D.productsRemovedFromCatalog&&e.productsRemoved.productsRemovedFromCatalog.length>0&&o.push(t.productsRemovedFromCatalog.replace("{products}",e.productsRemoved.productsRemovedFromCatalog.join(", "))),(N=e==null?void 0:e.productsRemoved)!=null&&N.productsRemovedFromQuote&&e.productsRemoved.productsRemovedFromQuote.length>0){const r=e.productsRemoved.productsRemovedFromQuote.map(l=>l.name||l.sku||l.uid).join(", ");o.push(t.productsRemovedFromQuote.replace("{products}",r))}return o.length>0?o:[t.noDetailsAvailable]},b=(()=>{const e=[],o=(a,m,c,u)=>{a&&Array.isArray(a)&&a.forEach(i=>{i&&i.note&&i.note.trim()&&e.push({...i,type:m,productName:u.product.name,productSku:u.product.sku,authorName:c})})};return h&&h.forEach(a=>{o(a.noteFromBuyer,"buyer",`${n.firstname} ${n.lastname} ${t.buyerLabel}`,a),o(a.noteFromSeller,"seller",`${F} ${t.sellerLabel}`,a)}),e})(),R=(q||[]).map(e=>({...e,entryType:"history"})),$=b.map(e=>({...e,entryType:"note"})),T=[...R,...$];return d("div",{...w,className:P(["quote-management-quote-history-log",_]),children:[T.length>0?s("div",{className:"quote-management-quote-history-log__entries",children:T.map((e,o)=>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:[s("span",{className:"quote-management-quote-history-log__entry-date",children:p.format(new Date(e.createdAt))}),s("span",{className:"quote-management-quote-history-log__entry-author",children:e.entryType==="history"?`by ${e.author.firstname} ${e.author.lastname} ${e.author.firstname===n.firstname&&e.author.lastname===n.lastname?t.buyerLabel:t.sellerLabel}`:`by ${e.authorName}`})]}),s("div",{className:"quote-management-quote-history-log__entry-type",children:e.entryType==="history"?S(e.changeType):e.type==="buyer"?t.buyerNoteAdded:t.sellerNoteAdded})]}),s("div",{className:"quote-management-quote-history-log__entry-changes",children:e.entryType==="history"?A(e.changes).map((a,m)=>s("div",{className:"quote-management-quote-history-log__entry-change",children:a},m)):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}-${o}`))}):s("div",{className:"quote-management-quote-history-log__empty",children:t.emptyState}),x]})};export{V as Q};
3
+ import{jsxs as d,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as R}from"@dropins/tools/lib.js";import{f as c}from"./dateUtils.js";/* empty css */import{useText as $}from"@dropins/tools/i18n.js";const H=({className:g,children:q,history:x,items:y,buyer:n,salesRepName:D,...F})=>{const t=$({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"}),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,o=>o.toUpperCase())}},E=e=>{var a,m,p,u,i,v,T,C,L,N,_,f;const o=[];if((a=e==null?void 0:e.commentAdded)!=null&&a.comment&&o.push(t.commentDetail.replace("{comment}",e.commentAdded.comment)),(m=e==null?void 0:e.statuses)!=null&&m.changes&&e.statuses.changes.forEach(r=>{r.oldStatus&&r.newStatus?o.push(t.statusChangedFromTo.replace("{oldStatus}",r.oldStatus).replace("{newStatus}",r.newStatus)):r.newStatus&&o.push(t.statusSetTo.replace("{newStatus}",r.newStatus))}),(p=e==null?void 0:e.expiration)!=null&&p.newExpiration&&((u=e==null?void 0:e.expiration)!=null&&u.oldExpiration)){const r=c(e.expiration.newExpiration),l=c(e.expiration.oldExpiration);o.push(t.expirationChangedFromTo.replace("{oldExpiration}",l).replace("{newExpiration}",r))}else if((i=e==null?void 0:e.expiration)!=null&&i.newExpiration){const r=c(e.expiration.newExpiration);o.push(t.expirationSetTo.replace("{newExpiration}",r))}if((v=e==null?void 0:e.total)!=null&&v.newPrice&&((T=e==null?void 0:e.total)!=null&&T.oldPrice)){const r=`${e.total.newPrice.currency} ${e.total.newPrice.value}`,l=`${e.total.oldPrice.currency} ${e.total.oldPrice.value}`;o.push(t.totalChangedFromTo.replace("{oldTotal}",l).replace("{newTotal}",r))}if((C=e==null?void 0:e.customChanges)!=null&&C.title&&((L=e==null?void 0:e.customChanges)!=null&&L.old_value)&&((N=e==null?void 0:e.customChanges)!=null&&N.new_value)&&o.push(t.customChange.replace("{title}",e.customChanges.title).replace("{oldValue}",e.customChanges.old_value).replace("{newValue}",e.customChanges.new_value)),(_=e==null?void 0:e.productsRemoved)!=null&&_.productsRemovedFromCatalog&&e.productsRemoved.productsRemovedFromCatalog.length>0&&o.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 r=e.productsRemoved.productsRemovedFromQuote.map(l=>l.name||l.sku||l.uid).join(", ");o.push(t.productsRemovedFromQuote.replace("{products}",r))}return o.length>0?o:[t.noDetailsAvailable]},S=(()=>{const e=[],o=(a,m,p,u)=>{a&&Array.isArray(a)&&a.forEach(i=>{i&&i.note&&i.note.trim()&&e.push({...i,type:m,productName:u.product.name,productSku:u.product.sku,authorName:p})})};return y&&y.forEach(a=>{o(a.noteFromBuyer,"buyer",`${n.firstname} ${n.lastname} ${t.buyerLabel}`,a),o(a.noteFromSeller,"seller",`${D} ${t.sellerLabel}`,a)}),e})(),A=(x||[]).map(e=>({...e,entryType:"history"})),b=S.map(e=>({...e,entryType:"note"})),h=[...A,...b];return d("div",{...F,className:R(["quote-management-quote-history-log",g]),children:[h.length>0?s("div",{className:"quote-management-quote-history-log__entries",children:h.map((e,o)=>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:[s("span",{className:"quote-management-quote-history-log__entry-date",children:c(e.createdAt,"long")}),s("span",{className:"quote-management-quote-history-log__entry-author",children:e.entryType==="history"?`by ${e.author.firstname} ${e.author.lastname} ${e.author.firstname===n.firstname&&e.author.lastname===n.lastname?t.buyerLabel:t.sellerLabel}`:`by ${e.authorName}`})]}),s("div",{className:"quote-management-quote-history-log__entry-type",children:e.entryType==="history"?w(e.changeType):e.type==="buyer"?t.buyerNoteAdded:t.sellerNoteAdded})]}),s("div",{className:"quote-management-quote-history-log__entry-changes",children:e.entryType==="history"?E(e.changes).map((a,m)=>s("div",{className:"quote-management-quote-history-log__entry-change",children:a},m)):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}-${o}`))}):s("div",{className:"quote-management-quote-history-log__empty",children:t.emptyState}),q]})};export{H as Q};
4
4
  //# sourceMappingURL=QuoteHistoryLog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuoteHistoryLog.js","sources":["/@dropins/storefront-quote-management/src/components/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 {\n formatExpirationDate,\n getUserTimezone,\n} from '@/quote-management/utils/dateUtils';\nimport '@/quote-management/components/QuoteHistoryLog/QuoteHistoryLog.css';\n\nexport interface HistoryEntry {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: string;\n changes: {\n commentAdded?: { comment: string };\n statuses?: { changes: Array<{ oldStatus?: string; newStatus?: string }> };\n expiration?: { oldExpiration?: string; newExpiration?: string };\n total?: {\n oldPrice?: { value: number; currency: string };\n newPrice?: { value: number; currency: string };\n };\n customChanges?: { title: string; old_value: string; new_value: string };\n productsRemoved?: {\n productsRemovedFromCatalog?: string[];\n productsRemovedFromQuote?: Array<{ name?: string; sku?: string; uid: string }>;\n };\n };\n}\n\nexport interface ItemNote {\n createdAt: string;\n creatorId: number;\n creatorType: number;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n}\n\nexport interface QuoteItem {\n product: {\n name: string;\n sku: string;\n };\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n}\n\nexport interface QuoteHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n history?: HistoryEntry[];\n items?: QuoteItem[];\n buyer: {\n firstname: string;\n lastname: string;\n };\n salesRepName: string;\n}\n\nexport const QuoteHistoryLog: FunctionComponent<QuoteHistoryLogProps> = ({\n className,\n children,\n history,\n items,\n buyer,\n salesRepName,\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: number;\n creatorType: number;\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: ItemNote[] | undefined,\n type: 'buyer' | 'seller',\n authorName: string,\n item: QuoteItem\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 (items) {\n items.forEach((item) => {\n processNotes(\n item.noteFromBuyer,\n 'buyer',\n `${buyer.firstname} ${buyer.lastname} ${dictionary.buyerLabel}`,\n item\n );\n\n processNotes(\n item.noteFromSeller,\n 'seller',\n `${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 = (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} ${entry.author.lastname\n } ${entry.author.firstname === buyer.firstname &&\n entry.author.lastname === 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"],"names":["QuoteHistoryLog","className","children","history","items","buyer","salesRepName","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"],"mappings":"mQAuEO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UAAU,mDAET,SAAAE,CAAA,EAHIC,CAAA,CAKR,EAEDL,EAAC,MAAA,CAAI,UAAU,mDACb,SAAA,CAAAA,EAAC,MAAA,CACE,SAAA,CAAAH,EAAM,YAAY,IAAEA,EAAM,WAAW,GAAA,EACxC,IACC,MAAA,CAAI,SAAA,CAAA,IAAEA,EAAM,KAAK,GAAA,CAAA,CAAC,CAAA,CAAA,CACrB,CAAA,CAEJ,CAAA,CAAA,EAhDEA,EAAM,YAAc,UAChBA,EAAM,IACN,GAAGA,EAAM,OAAO,IAAIM,CAAK,EAAA,CAgDlC,EACH,EAEAD,EAAC,OAAI,UAAU,4CACZ,WAAW,WACd,EAEDpD,CAAA,CAAA,CAAA,CAGP"}
1
+ {"version":3,"file":"QuoteHistoryLog.js","sources":["/@dropins/storefront-quote-management/src/components/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 } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { formattedDate } from '@/quote-management/utils/dateUtils';\nimport '@/quote-management/components/QuoteHistoryLog/QuoteHistoryLog.css';\n\nexport interface HistoryEntry {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: string;\n changes: {\n commentAdded?: { comment: string };\n statuses?: { changes: Array<{ oldStatus?: string; newStatus?: string }> };\n expiration?: { oldExpiration?: string; newExpiration?: string };\n total?: {\n oldPrice?: { value: number; currency: string };\n newPrice?: { value: number; currency: string };\n };\n customChanges?: { title: string; old_value: string; new_value: string };\n productsRemoved?: {\n productsRemovedFromCatalog?: string[];\n productsRemovedFromQuote?: Array<{ name?: string; sku?: string; uid: string }>;\n };\n };\n}\n\nexport interface ItemNote {\n createdAt: string;\n creatorId: number;\n creatorType: number;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n}\n\nexport interface QuoteItem {\n product: {\n name: string;\n sku: string;\n };\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n}\n\nexport interface QuoteHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n history?: HistoryEntry[];\n items?: QuoteItem[];\n buyer: {\n firstname: string;\n lastname: string;\n };\n salesRepName: string;\n}\n\nexport const QuoteHistoryLog: FunctionComponent<QuoteHistoryLogProps> = ({\n className,\n children,\n history,\n items,\n buyer,\n salesRepName,\n ...props\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\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 = formattedDate(changes.expiration.newExpiration);\n const oldDateFormatted = formattedDate(changes.expiration.oldExpiration);\n changeDetails.push(\n dictionary.expirationChangedFromTo\n .replace('{oldExpiration}', oldDateFormatted)\n .replace('{newExpiration}', newDateFormatted)\n );\n } else if (changes?.expiration?.newExpiration) {\n const newDateFormatted = formattedDate(changes.expiration.newExpiration);\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: number;\n creatorType: number;\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: ItemNote[] | undefined,\n type: 'buyer' | 'seller',\n authorName: string,\n item: QuoteItem\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 (items) {\n items.forEach((item) => {\n processNotes(\n item.noteFromBuyer,\n 'buyer',\n `${buyer.firstname} ${buyer.lastname} ${dictionary.buyerLabel}`,\n item\n );\n\n processNotes(\n item.noteFromSeller,\n 'seller',\n `${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 = (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 {formattedDate(entry.createdAt, 'long')}\n </span>\n <span className=\"quote-management-quote-history-log__entry-author\">\n {entry.entryType === 'history'\n ? `by ${entry.author.firstname} ${entry.author.lastname\n } ${entry.author.firstname === buyer.firstname &&\n entry.author.lastname === 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"],"names":["QuoteHistoryLog","className","children","history","items","buyer","salesRepName","props","dictionary","useText","formatChangeType","changeType","l","formatChanges","changes","changeDetails","_a","_b","statusChange","_c","_d","newDateFormatted","formattedDate","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"],"mappings":"uOAoEO,MAAMA,EAA2D,CAAC,CACvE,UAAAC,EACA,SAAAC,EACA,QAAAC,EACA,MAAAC,EACA,MAAAC,EACA,aAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,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,EAGKC,EAAoBC,GAAuB,CAC/C,OAAQA,EAAA,CACN,IAAK,UACH,OAAOH,EAAW,aACpB,IAAK,UACH,OAAOA,EAAW,aACpB,IAAK,iBACH,OAAOA,EAAW,cACpB,IAAK,gBACH,OAAOA,EAAW,aACpB,IAAK,qBACH,OAAOA,EAAW,kBACpB,QACE,OAAOG,EACJ,QAAQ,KAAM,GAAG,EACjB,YAAA,EACA,QAAQ,QAAUC,GAAMA,EAAE,aAAa,CAAA,CAEhD,EAGMC,EAAiBC,GAAiB,6BACtC,MAAMC,EAAgB,CAAA,EA8BtB,IA5BIC,EAAAF,GAAA,YAAAA,EAAS,eAAT,MAAAE,EAAuB,SACzBD,EAAc,KACZP,EAAW,cAAc,QACvB,YACAM,EAAQ,aAAa,OAAA,CACvB,GAIAG,EAAAH,GAAA,YAAAA,EAAS,WAAT,MAAAG,EAAmB,SAC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,UAAU,mDAET,SAAAE,CAAA,EAHIC,CAAA,CAKR,EAEDL,EAAC,MAAA,CAAI,UAAU,mDACb,SAAA,CAAAA,EAAC,MAAA,CACE,SAAA,CAAAH,EAAM,YAAY,IAAEA,EAAM,WAAW,GAAA,EACxC,IACC,MAAA,CAAI,SAAA,CAAA,IAAEA,EAAM,KAAK,GAAA,CAAA,CAAC,CAAA,CAAA,CACrB,CAAA,CAEJ,CAAA,CAAA,EAhDEA,EAAM,YAAc,UAChBA,EAAM,IACN,GAAGA,EAAM,OAAO,IAAIM,CAAK,EAAA,CAgDlC,EACH,EAEAD,EAAC,OAAI,UAAU,4CACZ,WAAW,WACd,EAEDhD,CAAA,CAAA,CAAA,CAGP"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as o,jsxs as d}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useEffect as p}from"@dropins/tools/preact-compat.js";import{getGlobalLocale as f}from"@dropins/tools/lib.js";import{Q as h}from"./QuoteCommentsList.js";import{events as g}from"@dropins/tools/event-bus.js";const C=({templateData:a,...n})=>{var r;const[e,m]=l(a);if(p(()=>{const t=g.on("quote-management/quote-template-data",c=>{m(c.quoteTemplate)},{eager:!0});return()=>t==null?void 0:t.off()},[]),!e)return null;const s=f()||"en-US",i=new Intl.DateTimeFormat(s,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),u=(r=e==null?void 0:e.comments)==null?void 0:r.map(t=>({uid:t.uid,createdAt:o("span",{children:i.format(new Date(t.createdAt))}),author:d("span",{children:[t.author.firstname," ",t.author.lastname]}),text:o("p",{children:t.text})}));return o(h,{"data-testid":"quote-template-comments-list-container",...n,comments:u||[]})};export{C as Q};
3
+ import{jsx as o,jsxs as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as f,useEffect as p}from"@dropins/tools/preact-compat.js";import{Q as d}from"./QuoteCommentsList.js";import{events as l}from"@dropins/tools/event-bus.js";import{f as c}from"./dateUtils.js";const C=({templateData:a,...s})=>{var r;const[e,m]=f(a);if(p(()=>{const t=l.on("quote-management/quote-template-data",u=>{m(u.quoteTemplate)},{eager:!0});return()=>t==null?void 0:t.off()},[]),!e)return null;const n=(r=e==null?void 0:e.comments)==null?void 0:r.map(t=>({uid:t.uid,createdAt:o("span",{children:c(t.createdAt,"long")}),author:i("span",{children:[t.author.firstname," ",t.author.lastname]}),text:o("p",{children:t.text})}));return o(d,{"data-testid":"quote-template-comments-list-container",...s,comments:n||[]})};export{C as Q};
4
4
  //# sourceMappingURL=QuoteTemplateCommentsList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuoteTemplateCommentsList.js","sources":["/@dropins/storefront-quote-management/src/containers/QuoteTemplateCommentsList/QuoteTemplateCommentsList.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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, getGlobalLocale } from '@adobe-commerce/elsie/lib';\nimport { QuoteCommentsList as QuoteCommentsListComponent } from '@/quote-management/components/QuoteCommentsList';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface QuoteTemplateCommentsListProps extends HTMLAttributes<HTMLUListElement> {\n templateData?: NegotiableQuoteTemplateModel;\n}\n\nexport const QuoteTemplateCommentsList: Container<QuoteTemplateCommentsListProps> = ({\n templateData: initialData,\n ...props\n}) => {\n const [templateData, setTemplateData] = useState<NegotiableQuoteTemplateModel | undefined>(initialData);\n\n useEffect(() => {\n const templateDataEvent = events.on('quote-management/quote-template-data', (data: { quoteTemplate: NegotiableQuoteTemplateModel }) => {\n setTemplateData(data.quoteTemplate);\n }, { eager: true });\n return () => templateDataEvent?.off();\n }, []);\n\n if (!templateData) {\n return null;\n }\n\n // Format comments data\n const calculatedLocale = getGlobalLocale() || 'en-US';\n const dateFormatter = new Intl.DateTimeFormat(calculatedLocale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n });\n\n const formattedComments = templateData?.comments?.map((comment) => ({\n uid: comment.uid,\n createdAt: <span>{dateFormatter.format(new Date(comment.createdAt))}</span>,\n author: (\n <span>\n {comment.author.firstname} {comment.author.lastname}\n </span>\n ),\n text: <p>{comment.text}</p>,\n }));\n\n return (\n <QuoteCommentsListComponent\n data-testid=\"quote-template-comments-list-container\"\n {...props}\n comments={formattedComments || []}\n />\n );\n};\n"],"names":["QuoteTemplateCommentsList","initialData","props","templateData","setTemplateData","useState","useEffect","templateDataEvent","events","data","calculatedLocale","getGlobalLocale","dateFormatter","formattedComments","_a","comment","jsx","QuoteCommentsListComponent"],"mappings":"uSAmBO,MAAMA,EAAuE,CAAC,CACnF,aAAcC,EACd,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAmDJ,CAAW,EAStG,GAPAK,EAAU,IAAM,CACd,MAAMC,EAAoBC,EAAO,GAAG,uCAAyCC,GAA0D,CACrIL,EAAgBK,EAAK,aAAa,CACpC,EAAG,CAAE,MAAO,GAAM,EAClB,MAAO,IAAMF,GAAA,YAAAA,EAAmB,KAClC,EAAG,CAAA,CAAE,EAED,CAACJ,EACH,OAAO,KAIT,MAAMO,EAAmBC,KAAqB,QACxCC,EAAgB,IAAI,KAAK,eAAeF,EAAkB,CAC9D,KAAM,UACN,MAAO,QACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OAAQ,EAAA,CACT,EAEKG,GAAoBC,EAAAX,GAAA,YAAAA,EAAc,WAAd,YAAAW,EAAwB,IAAKC,IAAa,CAClE,IAAKA,EAAQ,IACb,UAAWC,EAAC,OAAA,CAAM,SAAAJ,EAAc,OAAO,IAAI,KAAKG,EAAQ,SAAS,CAAC,CAAA,CAAE,EACpE,SACG,OAAA,CACE,SAAA,CAAAA,EAAQ,OAAO,UAAU,IAAEA,EAAQ,OAAO,QAAA,EAC7C,EAEF,KAAMC,EAAC,IAAA,CAAG,SAAAD,EAAQ,IAAA,CAAK,CAAA,IAGzB,OACEC,EAACC,EAAA,CACC,cAAY,yCACX,GAAGf,EACJ,SAAUW,GAAqB,CAAA,CAAC,CAAA,CAGtC"}
1
+ {"version":3,"file":"QuoteTemplateCommentsList.js","sources":["/@dropins/storefront-quote-management/src/containers/QuoteTemplateCommentsList/QuoteTemplateCommentsList.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 { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { QuoteCommentsList as QuoteCommentsListComponent } from '@/quote-management/components/QuoteCommentsList';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { events } from '@adobe-commerce/event-bus';\nimport { formattedDate } from '@/quote-management/utils/dateUtils';\n\nexport interface QuoteTemplateCommentsListProps extends HTMLAttributes<HTMLUListElement> {\n templateData?: NegotiableQuoteTemplateModel;\n}\n\nexport const QuoteTemplateCommentsList: Container<QuoteTemplateCommentsListProps> = ({\n templateData: initialData,\n ...props\n}) => {\n const [templateData, setTemplateData] = useState<NegotiableQuoteTemplateModel | undefined>(initialData);\n\n useEffect(() => {\n const templateDataEvent = events.on('quote-management/quote-template-data', (data: { quoteTemplate: NegotiableQuoteTemplateModel }) => {\n setTemplateData(data.quoteTemplate);\n }, { eager: true });\n return () => templateDataEvent?.off();\n }, []);\n\n if (!templateData) {\n return null;\n }\n\n // Format comments data\n const formattedComments = templateData?.comments?.map((comment) => ({\n uid: comment.uid,\n createdAt: <span>{formattedDate(comment.createdAt, 'long')}</span>,\n author: (\n <span>\n {comment.author.firstname} {comment.author.lastname}\n </span>\n ),\n text: <p>{comment.text}</p>,\n }));\n\n return (\n <QuoteCommentsListComponent\n data-testid=\"quote-template-comments-list-container\"\n {...props}\n comments={formattedComments || []}\n />\n );\n};\n"],"names":["QuoteTemplateCommentsList","initialData","props","templateData","setTemplateData","useState","useEffect","templateDataEvent","events","data","formattedComments","_a","comment","jsx","QuoteCommentsListComponent"],"mappings":"kRAoBO,MAAMA,EAAuE,CAAC,CACnF,aAAcC,EACd,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAmDJ,CAAW,EAStG,GAPAK,EAAU,IAAM,CACd,MAAMC,EAAoBC,EAAO,GAAG,uCAAyCC,GAA0D,CACrIL,EAAgBK,EAAK,aAAa,CACpC,EAAG,CAAE,MAAO,GAAM,EAClB,MAAO,IAAMF,GAAA,YAAAA,EAAmB,KAClC,EAAG,CAAA,CAAE,EAED,CAACJ,EACH,OAAO,KAIT,MAAMO,GAAoBC,EAAAR,GAAA,YAAAA,EAAc,WAAd,YAAAQ,EAAwB,IAAKC,IAAa,CAClE,IAAKA,EAAQ,IACb,UAAWC,EAAC,OAAA,CAAM,WAAcD,EAAQ,UAAW,MAAM,EAAE,EAC3D,SACG,OAAA,CACE,SAAA,CAAAA,EAAQ,OAAO,UAAU,IAAEA,EAAQ,OAAO,QAAA,EAC7C,EAEF,KAAMC,EAAC,IAAA,CAAG,SAAAD,EAAQ,IAAA,CAAK,CAAA,IAGzB,OACEC,EAACC,EAAA,CACC,cAAY,yCACX,GAAGZ,EACJ,SAAUQ,GAAqB,CAAA,CAAC,CAAA,CAGtC"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
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{r as a,a as f,n as g};
3
+ import{getGlobalLocale as r}from"@dropins/tools/lib.js";function o(e){const t=new Date(e);return!isNaN(t.getTime())}function a(e,t="short"){if(!o(e))return"–";const n=r()||"en-US";return t==="short"?new Date(e).toLocaleDateString(n,{year:"numeric",month:"numeric",day:"numeric"}):new Date(e).toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0})}export{a as f};
4
4
  //# sourceMappingURL=dateUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateUtils.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\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
+ {"version":3,"file":"dateUtils.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { getGlobalLocale } from \"@adobe-commerce/elsie/lib\";\n\n/**\n * Gets the user's timezone with fallback to UTC if detection fails\n * @returns The user's timezone string (e.g., 'America/New_York') or 'UTC' as fallback\n */\nexport function getUserTimezone(): string {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch (error) {\n console.warn('Failed to detect user timezone, falling back to UTC:', error);\n return 'UTC';\n }\n}\n\n/**\n * Checks if a date string is a valid date\n * @param dateString - The date string to check\n * @returns True if the date string is a valid date, false otherwise\n */\nexport function isValidDate(dateString: string): boolean {\n const date = new Date(dateString);\n return !isNaN(date.getTime());\n}\n\n/**\n * Formats a date string to locale date string, returning \"–\" for invalid dates\n * @param dateString - The date string to format\n * @returns Formatted date string or \"–\" for invalid dates\n */\nexport function formattedDate(dateString: string, type: 'short' | 'long' = 'short'): string {\n if (!isValidDate(dateString)) {\n return '–';\n }\n\n const locale = getGlobalLocale() || 'en-US';\n\n if (type === 'short') {\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n });\n }\n\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n });\n}\n"],"names":["isValidDate","dateString","date","formattedDate","type","locale","getGlobalLocale"],"mappings":"wDA6BO,SAASA,EAAYC,EAA6B,CACvD,MAAMC,EAAO,IAAI,KAAKD,CAAU,EAChC,MAAO,CAAC,MAAMC,EAAK,SAAS,CAC9B,CAOO,SAASC,EAAcF,EAAoBG,EAAyB,QAAiB,CAC1F,GAAI,CAACJ,EAAYC,CAAU,EACzB,MAAO,IAGT,MAAMI,EAASC,KAAqB,QAEpC,OAAIF,IAAS,QACJ,IAAI,KAAKH,CAAU,EAAE,mBAAmBI,EAAQ,CACrD,KAAM,UACN,MAAO,UACP,IAAK,SAAA,CACN,EAGI,IAAI,KAAKJ,CAAU,EAAE,mBAAmBI,EAAQ,CACrD,KAAM,UACN,MAAO,OACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OAAQ,EAAA,CACT,CACH"}
@@ -6,7 +6,7 @@ export interface ManageNegotiableQuoteProps extends Omit<HTMLAttributes<HTMLDivE
6
6
  quoteName: VNode;
7
7
  quoteStatus: VNode;
8
8
  banner?: VNode;
9
- details: VNode;
9
+ details?: VNode;
10
10
  actionBar?: VNode;
11
11
  quoteContent: VNode;
12
12
  shippingInformationTitle: VNode;
@@ -6,7 +6,7 @@ export interface ManageNegotiableQuoteTemplateProps extends Omit<HTMLAttributes<
6
6
  templateName: VNode;
7
7
  templateId: VNode;
8
8
  banner?: VNode;
9
- details: VNode;
9
+ details?: VNode;
10
10
  actionBar?: VNode;
11
11
  referenceDocuments?: VNode;
12
12
  referenceDocumentsTitle?: VNode;
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as t,jsxs as s,Fragment as Le}from"@dropins/tools/preact-jsx-runtime.js";import*as we from"@dropins/tools/preact-compat.js";import{useState as c,useRef as ie,useEffect as y,useCallback as d,useMemo as f,createPortal as j}from"@dropins/tools/preact-compat.js";import{classes as l,VComponent as N,Slot as g,getGlobalLocale as ra}from"@dropins/tools/lib.js";/* empty css */import{Picker as ia,Skeleton as ma,SkeletonRow as F,Modal as la,Input as ca,TextArea as xe,Button as $,InLineAlert as L}from"@dropins/tools/components.js";import{events as x}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{I as sa,C as me}from"../chunks/ItemsQuoted.js";/* empty css *//* empty css */import{T as da}from"../chunks/TabbedContent.js";/* empty css */import{useText as Re}from"@dropins/tools/i18n.js";import{S as ua}from"../chunks/ShippingAddressDisplay.js";import{Q as ga}from"../chunks/QuoteHistoryLog3.js";import{g as ba,r as fa,c as pa,s as Ma,d as ha}from"../chunks/renameNegotiableQuote.js";import"../chunks/state.js";import{Q as Na}from"../chunks/QuoteCommentsList3.js";import{a as G,S as le}from"../chunks/WarningFilled.js";import"../chunks/QuotePricesSummary.js";import"../chunks/removeNegotiableQuoteItems.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/QuoteHistoryLog.js";import"../chunks/dateUtils.js";import"../chunks/QuoteCommentsList.js";const qa=p=>we.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",...p},we.createElement("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})),va=({className:p,dropdownPlaceholder:a,dropdownOptions:m,dropdownValue:q,handleDropdownChange:Q,buttons:e,...u})=>{const v=m&&m.length>0,S=e&&e.length>0,_=(m==null?void 0:m.map(M=>({text:M.label,value:M.value})))||[];return _.unshift({text:a||"",value:""}),t("div",{className:"quote-management-actions-bar__container","data-testid":"actions-bar-container",children:s("div",{className:l(["quote-management-actions-bar",p]),"data-testid":"actions-bar",...u,children:[v&&t(ia,{name:"dropdown",id:"dropdown",handleSelect:Q,className:"quote-management-actions-bar__dropdown","data-testid":"dropdown",options:_,value:q||""},`actions-bar-picker-${q||"empty"}`),S&&t("div",{className:"quote-management-actions-bar__buttons","data-testid":"buttons-container",children:e==null?void 0:e.map((M,C)=>t(N,{node:M,className:l(["quote-management-actions-bar__button"])},C))})]})})},Qa=({className:p,loading:a,quoteName:m,quoteStatus:q,banner:Q,details:e,actionBar:u,quoteContent:v,shippingInformationTitle:S,shippingInformation:_,quoteCommentsTitle:M,quoteComments:C,footer:b,...I})=>a?t(Sa,{}):s("div",{...I,className:l(["quote-management-manage-negotiable-quote",p]),children:[s("div",{className:l(["quote-management-manage-negotiable-quote__header"]),children:[m&&t(N,{node:m,className:l(["quote-management-manage-negotiable-quote__quote-name"])}),q&&t(N,{node:q,className:l(["quote-management-manage-negotiable-quote__quote-status"])})]}),Q&&t(N,{node:Q,className:l(["quote-management-manage-negotiable-quote__banner"])}),e&&t(N,{node:e,className:l(["quote-management-manage-negotiable-quote__details"])}),u&&t(N,{node:u,className:l(["quote-management-manage-negotiable-quote__action-bar"])}),v&&t(N,{node:v,className:l(["quote-management-manage-negotiable-quote__quote-content"])}),s("div",{"data-testid":"quote-shipping-information-container",className:l(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[S&&t(N,{node:S,className:l(["quote-management-manage-negotiable-quote__shipping-information-title"])}),_&&t(N,{node:_,className:l(["quote-management-manage-negotiable-quote__shipping-information"])})]}),s("div",{"data-testid":"quote-comments-container",className:l(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[M&&t(N,{node:M,className:l(["quote-management-manage-negotiable-quote__quote-comments-title"])}),C&&t(N,{node:C,className:l(["quote-management-manage-negotiable-quote__quote-comments"])})]}),t(N,{node:b,className:l(["quote-management-manage-negotiable-quote__footer"])})]}),Sa=()=>s(ma,{"data-testid":"manage-negotiable-quote-skeleton",children:[t(F,{variant:"heading",fullWidth:!0,size:"large"}),t(F,{variant:"row",fullWidth:!1,size:"small"}),t(F,{variant:"row",fullWidth:!1,size:"small"}),t(F,{variant:"row",fullWidth:!0}),t(F,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),t(F,{variant:"row",fullWidth:!1,size:"small"})]}),_a=({className:p,open:a,quoteName:m,renameReason:q,quoteNameError:Q,errorBanner:e,successBanner:u,showCloseButton:v=!0,onQuoteNameChange:S,onRenameReasonChange:_,onSave:M,onClose:C})=>{const b=Re({title:"NegotiableQuote.Manage.rename.title",quoteNameLabel:"NegotiableQuote.Manage.rename.quoteNameLabel",reasonLabel:"NegotiableQuote.Manage.rename.reasonLabel",renameButton:"NegotiableQuote.Manage.rename.renameButton",cancelButton:"NegotiableQuote.Manage.rename.cancelButton"});return a?s(la,{open:a,size:"medium",title:t(Le,{children:b.title}),onClose:C,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:v,className:l(["quote-management-rename-quote-modal",p]),"data-testid":"rename-quote-modal",children:[e&&t("div",{className:l(["quote-management-rename-quote-modal__error-banner"]),"data-testid":"rename-quote-modal-error-banner",children:e}),u&&t("div",{className:l(["quote-management-rename-quote-modal__success-banner"]),"data-testid":"rename-quote-modal-success-banner",children:u}),s("div",{className:l(["quote-management-rename-quote-modal__content"]),children:[s("div",{children:[t(ca,{name:"quoteName",type:"text",value:m,onInput:I=>S(I.target.value),floatingLabel:b.quoteNameLabel,required:!0,error:!!Q}),Q&&t("span",{className:l(["quote-management-rename-quote-modal__error-text"]),children:Q})]}),t(xe,{name:"quoteComment",value:q,onInput:I=>_(I.target.value),label:b.reasonLabel,rows:3})]}),s("div",{className:l(["quote-management-rename-quote-modal__actions"]),children:[t($,{variant:"secondary",size:"medium",onClick:C,className:l(["quote-management-rename-quote-modal__cancel-button"]),children:b.cancelButton}),t($,{variant:"primary",size:"medium",onClick:M,className:l(["quote-management-rename-quote-modal__save-button"]),children:b.renameButton})]})]}):null},at=({onActionsDropdownChange:p,slots:a,onActionsButtonClick:m,onSendForReview:q,...Q})=>{const[e,u]=c(void 0),[v,S]=c(!0),[_,M]=c(!1),[C,b]=c(null),[I,U]=c(!1),[T,ce]=c(""),[H,X]=c(!1),[se,J]=c(!1),[de,K]=c(!1),[ue,R]=c(""),[ge,B]=c(""),[be,Y]=c(!1),[P,z]=c(""),[Z,W]=c(""),[A,k]=c(""),[Ee,E]=c(""),[ee,O]=c(""),[ae,fe]=c(new Set),pe=ie(ae),te=ie(null),[D,ne]=c(""),V=ie(D),[Me,he]=c(!1);y(()=>{pe.current=ae},[ae]),y(()=>{V.current=D},[D]);const o=Re({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired",errorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",closeSuccessMessage:"NegotiableQuote.Manage.confirmationModal.close.successDescription",closeModalTitle:"NegotiableQuote.Manage.actionButtons.close",closeModalMessage:"NegotiableQuote.Manage.confirmationModal.close.message",closeModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",closeModalConfirm:"NegotiableQuote.Manage.confirmationModal.close.confirm",closeModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.close.confirmLoading",closeModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.close.successHeading",renameErrorHeading:"NegotiableQuote.Manage.rename.errorHeading",renameQuoteNameRequired:"NegotiableQuote.Manage.rename.quoteNameRequired",renameErrorDefault:"NegotiableQuote.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuote.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuote.Manage.rename.successMessage",confirmationModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",confirmationModalDeleteTitle:"NegotiableQuote.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuote.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuote.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuote.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription"});y(()=>{const n=x.on("quote-management/quote-data",r=>{const{quote:i}=r;i&&(u(i),S(!1))},{eager:!0});return()=>n==null?void 0:n.off()},[]),y(()=>{const n=x.on("quote-management/shipping-address-set",r=>{const{quote:i}=r;i&&u(i)},{eager:!0});return()=>n==null?void 0:n.off()},[]),y(()=>{const n=x.on("quote-management/quote-sent-for-review",r=>{const{quote:i}=r;u(i),ce(""),X(!1)},{eager:!0});return()=>n==null?void 0:n.off()},[]),y(()=>{const n=x.on("quote-management/quote-items-removed",r=>{const{quote:i,removedItemUids:h}=r;i&&u(i),h&&fe(w=>{const Te=new Set(w);return h.forEach(oa=>Te.delete(oa)),Te})},{eager:!0});return()=>n==null?void 0:n.off()},[]);const Ne=d((n,r)=>{fe(i=>{const h=new Set(i);return r?h.add(n.uid):h.delete(n.uid),h})},[]),qe=d(n=>{const r=n.target.value,i=pe.current;if(r==="remove"){if(ne(r),V.current=r,i.size===0)he(!0);else if(e&&te.current){const h=e.items.filter(w=>i.has(w.uid));te.current(h)}}p==null||p(n)},[p,e]),ve=d(()=>{he(!1),ne(""),V.current=""},[]);y(()=>{const n=x.on("quote-management/negotiable-quote-closed",async r=>{K(!1),B(""),R(o.closeSuccessMessage),u(i=>{var h;return i!=null&&i.uid&&((h=r.closedQuoteUids)!=null&&h.includes(i.uid))&&ba(i.uid).then(w=>{u(w)}).catch(w=>{console.warn("Failed to refresh quote data after closure:",w)}),i}),setTimeout(()=>{J(!1),R("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.closeSuccessMessage]),y(()=>{const n=x.on("quote-management/negotiable-quote-close-error",r=>{console.log("Close error event received:",r),K(!1),R("");const i=r.error.message||o.errorFallback;B(i)},{eager:!0});return()=>n==null?void 0:n.off()},[o.errorFallback]),y(()=>{const n=x.on("quote-management/quote-renamed",r=>{const{quote:i}=r;u(i),k(""),E(""),O(o.renameSuccessMessage),setTimeout(()=>{Y(!1),z(""),W(""),O("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.renameSuccessMessage]);const Qe=d(()=>{z((e==null?void 0:e.name)||""),W(""),k(""),E(""),O(""),Y(!0)},[e]),De=d(()=>{Y(!1),z(""),W(""),k(""),E(""),O("")},[]),Fe=d(n=>{z(n),n.trim()&&E("")},[]),He=d(async()=>{if(!P.trim()){E(o.renameQuoteNameRequired);return}try{k(""),E(""),await fa({quoteUid:e.uid,quoteName:P,quoteComment:Z.trim()||void 0})}catch(n){k(n.message||o.renameErrorDefault)}},[e,P,Z,o.renameQuoteNameRequired,o.renameErrorDefault]),Be=f(()=>{const n=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return t(g,{name:"QuoteName",slot:a==null?void 0:a.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:s("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[t("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),t("button",{onClick:Qe,disabled:n,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:t(qa,{})})]})})},[a==null?void 0:a.QuoteName,e,Qe]),ke=f(()=>t(g,{name:"QuoteStatus",slot:a==null?void 0:a.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:t("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[a==null?void 0:a.QuoteStatus,e]),Se=d(n=>{switch(n){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),_e=Se&&t(L,{type:"warning",variant:"secondary",icon:t(G,{}),heading:o.bannerTitle,description:Se}),Ue=_e&&t(g,{name:"Banner","data-testid":"banner",slot:a==null?void 0:a.Banner,context:{quoteData:e},children:_e}),Pe=f(()=>{if(!e)return null;const n=ra()||"en-US",r=new Intl.DateTimeFormat(n,{year:"numeric",month:"long",day:"numeric"});let i;try{i=r.format(new Date(e.expirationDate))}catch{i=e.expirationDate}return s(g,{name:"Details",slot:a==null?void 0:a.Details,context:{quoteData:e},children:[s("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),s("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[r.format(new Date(e.createdAt))," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),s("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),s("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:i})]})]})},[a==null?void 0:a.Details,o,e]),Ce=f(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate"},{label:o.createCopy,value:"createCopy"}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose]),ze=f(()=>{const n=r=>{switch(r){case"close":J(!0),B(""),R(""),m==null||m(r);break;case"delete":M(!0),m==null||m(r);break;case"print":m==null||m(r);break;case"createTemplate":m==null||m(r);break;case"createCopy":m==null||m(r);break}};return t(g,{name:"ActionBar",slot:a==null?void 0:a.ActionBar,context:{quoteData:e,actionsBarDropdownValue:D},children:t(va,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:D,handleDropdownChange:qe,buttons:Ce.map(r=>t($,{variant:"tertiary",onClick:()=>n(r.value),"data-testid":`actions-bar-${r.value}-button`,"data-action":r.value,disabled:r.disabled,children:r.label},r.value))})})},[Ce,o,a==null?void 0:a.ActionBar,e,qe,m,D]),We=f(()=>t(g,{name:"QuoteContent",slot:a==null?void 0:a.QuoteContent,context:{quoteData:e},children:t(da,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",t(g,{name:"ItemsQuotedTab",slot:a==null?void 0:a.ItemsQuotedTab,context:{quoteData:e},children:t(sa,{quoteData:e,onItemCheckboxChange:Ne,onRemoveItemsRef:n=>{te.current=n},onRemoveModalStateChange:n=>{!n&&V.current==="remove"&&ne("")}})},"items-quoted")],["comments",t(g,{name:"CommentsTab",slot:a==null?void 0:a.CommentsTab,context:{quoteData:e},children:t(Na,{quoteData:e})},"comments")],["history-log",t(g,{name:"HistoryLogTab",slot:a==null?void 0:a.HistoryLogTab,context:{quoteData:e},children:t(ga,{quoteData:e})},"history-log")]])})}),[a==null?void 0:a.QuoteContent,a==null?void 0:a.HistoryLogTab,a==null?void 0:a.CommentsTab,a==null?void 0:a.ItemsQuotedTab,e,Ne]),Oe=f(()=>t(g,{name:"ShippingInformationTitle",slot:a==null?void 0:a.ShippingInformationTitle,context:{quoteData:e},children:t("h2",{children:o.shippingInformationTitle})}),[a==null?void 0:a.ShippingInformationTitle,e,o]),Ve=f(()=>t(g,{name:"ShippingInformation",slot:a==null?void 0:a.ShippingInformation,context:{quoteData:e,loading:v,setLoading:S},children:t(ua,{quoteData:e,loading:v,"data-testid":"manage-quote-shipping-address"})}),[a==null?void 0:a.ShippingInformation,e,v,S]),je=f(()=>t(g,{name:"QuoteCommentsTitle",slot:a==null?void 0:a.QuoteCommentsTitle,context:{quoteData:e},children:t("h2",{children:o.quoteCommentsTitle})}),[a==null?void 0:a.QuoteCommentsTitle,o,e]),Ge=f(()=>t(g,{name:"QuoteComments",slot:a==null?void 0:a.QuoteComments,context:{quoteData:e},children:t(xe,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:T,onInput:n=>{ce(n.target.value)},disabled:H})}),[a==null?void 0:a.QuoteComments,o,e,T,H]),$e=d(async()=>{if(e!=null&&e.uid){K(!0),B(""),R("");try{await pa({quoteUids:[e.uid]})}catch(n){console.error("Failed to close quote:",n)}}},[e]),Xe=d(()=>{J(!1),B(""),R("")},[]),ye=d(async()=>{if(q){q({quoteData:e,comment:T.trim()||void 0});return}X(!0);try{await Ma({quoteUid:e.uid,comment:T.trim()||void 0})}catch(n){console.error("Failed to send quote for review:",n),X(!1)}},[e,q,T]),Je=f(()=>t(g,{name:"Footer",slot:a==null?void 0:a.Footer,context:{quoteData:e,comment:T,isSubmitting:H},children:t($,{variant:"primary",onClick:ye,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||H||!e,children:o.sendForReview})}),[a==null?void 0:a.Footer,o,e,T,H,ye]),Ke=f(()=>A?t(L,{type:"error",variant:"primary",icon:t(G,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:A}):void 0,[A,o.renameErrorHeading]),Ye=f(()=>ee?t(L,{type:"success",variant:"primary",icon:t(le,{}),heading:o.renameSuccessHeading,description:ee}):void 0,[ee,o.renameSuccessHeading]),oe=d(n=>n.errors&&Array.isArray(n.errors)&&n.errors.length>0?n.errors[0].message||o.confirmationModalDeleteErrorFallback:(n==null?void 0:n.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),Ze=d(()=>{M(!1),b(null),U(!1)},[]),Ae=d(async()=>{if(e!=null&&e.uid){b(null),U(!1);try{const{operationResults:n}=await ha(e.uid),r=n.find(i=>i.__typename==="DeleteNegotiableQuoteOperationFailure");if(r){const i=oe(r);b(i);return}U(!0)}catch(n){const r=oe(n);b(r)}}},[e,oe]),ea=d(()=>{b(null)},[]),aa=d(()=>{U(!1)},[]),ta=C?t(L,{type:"error",variant:"primary",icon:t(G,{}),heading:o.confirmationModalDeleteErrorHeading,description:C,onDismiss:ea,"data-testid":"confirmation-modal-error-banner"}):null,Ie=(I?t(L,{type:"success",variant:"primary",icon:t(le,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:aa,"data-testid":"confirmation-modal-success-banner"}):null)||ta,na={...Q,loading:v,quoteName:Be,quoteStatus:ke,banner:Ue||void 0,details:Pe,actionBar:ze,quoteContent:We,shippingInformationTitle:Oe,shippingInformation:Ve,quoteCommentsTitle:je,quoteComments:Ge,footer:Je};let re=null;return ue?re=t(L,{type:"success",variant:"primary",icon:t(le,{}),heading:o.closeModalSuccessHeading,description:ue,"data-testid":"close-quote-success-banner"}):ge&&(re=t(L,{type:"error",variant:"primary",icon:t(G,{}),heading:o.confirmationModalDeleteErrorHeading,description:ge,"data-testid":"close-quote-error-banner"})),s(Le,{children:[t(Qa,{...na}),be&&j(t(_a,{open:be,quoteName:P,renameReason:Z,quoteNameError:Ee,errorBanner:Ke,successBanner:Ye,onQuoteNameChange:Fe,onRenameReasonChange:W,onSave:He,onClose:De}),document.body),_&&j(t(me,{open:_,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:Ze,onConfirm:Ae,showCloseButton:!Ie,confirmationBanner:Ie}),document.body),se&&j(t(me,{open:se,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:de?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:Xe,onConfirm:de?void 0:$e,showCloseButton:!0,confirmationBanner:re,"data-testid":"close-quote-confirmation-modal"}),document.body),Me&&j(t(me,{open:Me,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:ve,onClose:ve,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{at as ManageNegotiableQuote,at as default};
3
+ import{jsx as t,jsxs as s,Fragment as we}from"@dropins/tools/preact-jsx-runtime.js";import*as xe from"@dropins/tools/preact-compat.js";import{useState as c,useRef as ie,useEffect as y,useCallback as d,useMemo as f,createPortal as j}from"@dropins/tools/preact-compat.js";import{classes as l,VComponent as h,Slot as g}from"@dropins/tools/lib.js";import{f as Le}from"../chunks/dateUtils.js";/* empty css */import{Picker as ia,Skeleton as ma,SkeletonRow as H,Modal as la,Input as ca,TextArea as Re,Button as G,InLineAlert as L}from"@dropins/tools/components.js";import{events as w}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{I as sa,C as me}from"../chunks/ItemsQuoted.js";/* empty css *//* empty css */import{T as da}from"../chunks/TabbedContent.js";/* empty css */import{useText as Ee}from"@dropins/tools/i18n.js";import{S as ua}from"../chunks/ShippingAddressDisplay.js";import{Q as ga}from"../chunks/QuoteHistoryLog3.js";import{g as ba,r as fa,c as pa,s as Ma,d as ha}from"../chunks/renameNegotiableQuote.js";import"../chunks/state.js";import{Q as Na}from"../chunks/QuoteCommentsList3.js";import{a as $,S as le}from"../chunks/WarningFilled.js";import"../chunks/QuotePricesSummary.js";import"../chunks/removeNegotiableQuoteItems.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/QuoteHistoryLog.js";import"../chunks/QuoteCommentsList.js";const qa=p=>xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",...p},xe.createElement("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})),va=({className:p,dropdownPlaceholder:a,dropdownOptions:m,dropdownValue:N,handleDropdownChange:Q,buttons:e,...u})=>{const q=m&&m.length>0,S=e&&e.length>0,_=(m==null?void 0:m.map(M=>({text:M.label,value:M.value})))||[];return _.unshift({text:a||"",value:""}),t("div",{className:"quote-management-actions-bar__container","data-testid":"actions-bar-container",children:s("div",{className:l(["quote-management-actions-bar",p]),"data-testid":"actions-bar",...u,children:[q&&t(ia,{name:"dropdown",id:"dropdown",handleSelect:Q,className:"quote-management-actions-bar__dropdown","data-testid":"dropdown",options:_,value:N||""},`actions-bar-picker-${N||"empty"}`),S&&t("div",{className:"quote-management-actions-bar__buttons","data-testid":"buttons-container",children:e==null?void 0:e.map((M,C)=>t(h,{node:M,className:l(["quote-management-actions-bar__button"])},C))})]})})},Qa=({className:p,loading:a,quoteName:m,quoteStatus:N,banner:Q,details:e,actionBar:u,quoteContent:q,shippingInformationTitle:S,shippingInformation:_,quoteCommentsTitle:M,quoteComments:C,footer:b,...I})=>a?t(Sa,{}):s("div",{...I,className:l(["quote-management-manage-negotiable-quote",p]),children:[s("div",{className:l(["quote-management-manage-negotiable-quote__header"]),children:[m&&t(h,{node:m,className:l(["quote-management-manage-negotiable-quote__quote-name"])}),N&&t(h,{node:N,className:l(["quote-management-manage-negotiable-quote__quote-status"])})]}),Q&&t(h,{node:Q,className:l(["quote-management-manage-negotiable-quote__banner"])}),e&&t(h,{node:e,className:l(["quote-management-manage-negotiable-quote__details"])}),u&&t(h,{node:u,className:l(["quote-management-manage-negotiable-quote__action-bar"])}),q&&t(h,{node:q,className:l(["quote-management-manage-negotiable-quote__quote-content"])}),s("div",{"data-testid":"quote-shipping-information-container",className:l(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[S&&t(h,{node:S,className:l(["quote-management-manage-negotiable-quote__shipping-information-title"])}),_&&t(h,{node:_,className:l(["quote-management-manage-negotiable-quote__shipping-information"])})]}),s("div",{"data-testid":"quote-comments-container",className:l(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[M&&t(h,{node:M,className:l(["quote-management-manage-negotiable-quote__quote-comments-title"])}),C&&t(h,{node:C,className:l(["quote-management-manage-negotiable-quote__quote-comments"])})]}),t(h,{node:b,className:l(["quote-management-manage-negotiable-quote__footer"])})]}),Sa=()=>s(ma,{"data-testid":"manage-negotiable-quote-skeleton",children:[t(H,{variant:"heading",fullWidth:!0,size:"large"}),t(H,{variant:"row",fullWidth:!1,size:"small"}),t(H,{variant:"row",fullWidth:!1,size:"small"}),t(H,{variant:"row",fullWidth:!0}),t(H,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),t(H,{variant:"row",fullWidth:!1,size:"small"})]}),_a=({className:p,open:a,quoteName:m,renameReason:N,quoteNameError:Q,errorBanner:e,successBanner:u,showCloseButton:q=!0,onQuoteNameChange:S,onRenameReasonChange:_,onSave:M,onClose:C})=>{const b=Ee({title:"NegotiableQuote.Manage.rename.title",quoteNameLabel:"NegotiableQuote.Manage.rename.quoteNameLabel",reasonLabel:"NegotiableQuote.Manage.rename.reasonLabel",renameButton:"NegotiableQuote.Manage.rename.renameButton",cancelButton:"NegotiableQuote.Manage.rename.cancelButton"});return a?s(la,{open:a,size:"medium",title:t(we,{children:b.title}),onClose:C,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:q,className:l(["quote-management-rename-quote-modal",p]),"data-testid":"rename-quote-modal",children:[e&&t("div",{className:l(["quote-management-rename-quote-modal__error-banner"]),"data-testid":"rename-quote-modal-error-banner",children:e}),u&&t("div",{className:l(["quote-management-rename-quote-modal__success-banner"]),"data-testid":"rename-quote-modal-success-banner",children:u}),s("div",{className:l(["quote-management-rename-quote-modal__content"]),children:[s("div",{children:[t(ca,{name:"quoteName",type:"text",value:m,onInput:I=>S(I.target.value),floatingLabel:b.quoteNameLabel,required:!0,error:!!Q}),Q&&t("span",{className:l(["quote-management-rename-quote-modal__error-text"]),children:Q})]}),t(Re,{name:"quoteComment",value:N,onInput:I=>_(I.target.value),label:b.reasonLabel,rows:3})]}),s("div",{className:l(["quote-management-rename-quote-modal__actions"]),children:[t(G,{variant:"secondary",size:"medium",onClick:C,className:l(["quote-management-rename-quote-modal__cancel-button"]),children:b.cancelButton}),t(G,{variant:"primary",size:"medium",onClick:M,className:l(["quote-management-rename-quote-modal__save-button"]),children:b.renameButton})]})]}):null},at=({onActionsDropdownChange:p,slots:a,onActionsButtonClick:m,onSendForReview:N,...Q})=>{const[e,u]=c(void 0),[q,S]=c(!0),[_,M]=c(!1),[C,b]=c(null),[I,P]=c(!1),[T,ce]=c(""),[F,X]=c(!1),[se,J]=c(!1),[de,K]=c(!1),[ue,R]=c(""),[ge,B]=c(""),[be,Y]=c(!1),[U,z]=c(""),[Z,W]=c(""),[A,k]=c(""),[De,E]=c(""),[ee,O]=c(""),[ae,fe]=c(new Set),pe=ie(ae),te=ie(null),[D,ne]=c(""),V=ie(D),[Me,he]=c(!1);y(()=>{pe.current=ae},[ae]),y(()=>{V.current=D},[D]);const o=Ee({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired",errorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",closeSuccessMessage:"NegotiableQuote.Manage.confirmationModal.close.successDescription",closeModalTitle:"NegotiableQuote.Manage.actionButtons.close",closeModalMessage:"NegotiableQuote.Manage.confirmationModal.close.message",closeModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",closeModalConfirm:"NegotiableQuote.Manage.confirmationModal.close.confirm",closeModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.close.confirmLoading",closeModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.close.successHeading",renameErrorHeading:"NegotiableQuote.Manage.rename.errorHeading",renameQuoteNameRequired:"NegotiableQuote.Manage.rename.quoteNameRequired",renameErrorDefault:"NegotiableQuote.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuote.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuote.Manage.rename.successMessage",confirmationModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",confirmationModalDeleteTitle:"NegotiableQuote.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuote.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuote.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuote.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription"});y(()=>{const n=w.on("quote-management/quote-data",r=>{const{quote:i}=r;i&&(u(i),S(!1))},{eager:!0});return()=>n==null?void 0:n.off()},[]),y(()=>{const n=w.on("quote-management/shipping-address-set",r=>{const{quote:i}=r;i&&u(i)},{eager:!0});return()=>n==null?void 0:n.off()},[]),y(()=>{const n=w.on("quote-management/quote-sent-for-review",r=>{const{quote:i}=r;u(i),ce(""),X(!1)},{eager:!0});return()=>n==null?void 0:n.off()},[]),y(()=>{const n=w.on("quote-management/quote-items-removed",r=>{const{quote:i,removedItemUids:v}=r;i&&u(i),v&&fe(x=>{const Te=new Set(x);return v.forEach(ra=>Te.delete(ra)),Te})},{eager:!0});return()=>n==null?void 0:n.off()},[]);const Ne=d((n,r)=>{fe(i=>{const v=new Set(i);return r?v.add(n.uid):v.delete(n.uid),v})},[]),qe=d(n=>{const r=n.target.value,i=pe.current;if(r==="remove"){if(ne(r),V.current=r,i.size===0)he(!0);else if(e&&te.current){const v=e.items.filter(x=>i.has(x.uid));te.current(v)}}p==null||p(n)},[p,e]),ve=d(()=>{he(!1),ne(""),V.current=""},[]);y(()=>{const n=w.on("quote-management/negotiable-quote-closed",async r=>{K(!1),B(""),R(o.closeSuccessMessage),u(i=>{var v;return i!=null&&i.uid&&((v=r.closedQuoteUids)!=null&&v.includes(i.uid))&&ba(i.uid).then(x=>{u(x)}).catch(x=>{console.warn("Failed to refresh quote data after closure:",x)}),i}),setTimeout(()=>{J(!1),R("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.closeSuccessMessage]),y(()=>{const n=w.on("quote-management/negotiable-quote-close-error",r=>{console.log("Close error event received:",r),K(!1),R("");const i=r.error.message||o.errorFallback;B(i)},{eager:!0});return()=>n==null?void 0:n.off()},[o.errorFallback]),y(()=>{const n=w.on("quote-management/quote-renamed",r=>{const{quote:i}=r;u(i),k(""),E(""),O(o.renameSuccessMessage),setTimeout(()=>{Y(!1),z(""),W(""),O("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.renameSuccessMessage]);const Qe=d(()=>{z((e==null?void 0:e.name)||""),W(""),k(""),E(""),O(""),Y(!0)},[e]),He=d(()=>{Y(!1),z(""),W(""),k(""),E(""),O("")},[]),Fe=d(n=>{z(n),n.trim()&&E("")},[]),Be=d(async()=>{if(!U.trim()){E(o.renameQuoteNameRequired);return}try{k(""),E(""),await fa({quoteUid:e.uid,quoteName:U,quoteComment:Z.trim()||void 0})}catch(n){k(n.message||o.renameErrorDefault)}},[e,U,Z,o.renameQuoteNameRequired,o.renameErrorDefault]),ke=f(()=>{const n=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return t(g,{name:"QuoteName",slot:a==null?void 0:a.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:s("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[t("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),t("button",{onClick:Qe,disabled:n,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:t(qa,{})})]})})},[a==null?void 0:a.QuoteName,e,Qe]),Pe=f(()=>t(g,{name:"QuoteStatus",slot:a==null?void 0:a.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:t("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[a==null?void 0:a.QuoteStatus,e]),Se=d(n=>{switch(n){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),_e=Se&&t(L,{type:"warning",variant:"secondary",icon:t($,{}),heading:o.bannerTitle,description:Se}),Ue=_e&&t(g,{name:"Banner","data-testid":"banner",slot:a==null?void 0:a.Banner,context:{quoteData:e},children:_e}),ze=f(()=>{if(!e)return null;const n=e.expirationDate?Le(e.expirationDate,"short"):void 0;return s(g,{name:"Details",slot:a==null?void 0:a.Details,context:{quoteData:e},children:[s("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),s("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[Le(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),s("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),s("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:n})]})]})},[a==null?void 0:a.Details,o,e]),Ce=f(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate"},{label:o.createCopy,value:"createCopy"}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose]),We=f(()=>{const n=r=>{switch(r){case"close":J(!0),B(""),R(""),m==null||m(r);break;case"delete":M(!0),m==null||m(r);break;case"print":m==null||m(r);break;case"createTemplate":m==null||m(r);break;case"createCopy":m==null||m(r);break}};return t(g,{name:"ActionBar",slot:a==null?void 0:a.ActionBar,context:{quoteData:e,actionsBarDropdownValue:D},children:t(va,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:D,handleDropdownChange:qe,buttons:Ce.map(r=>t(G,{variant:"tertiary",onClick:()=>n(r.value),"data-testid":`actions-bar-${r.value}-button`,"data-action":r.value,disabled:r.disabled,children:r.label},r.value))})})},[Ce,o,a==null?void 0:a.ActionBar,e,qe,m,D]),Oe=f(()=>t(g,{name:"QuoteContent",slot:a==null?void 0:a.QuoteContent,context:{quoteData:e},children:t(da,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",t(g,{name:"ItemsQuotedTab",slot:a==null?void 0:a.ItemsQuotedTab,context:{quoteData:e},children:t(sa,{quoteData:e,onItemCheckboxChange:Ne,onRemoveItemsRef:n=>{te.current=n},onRemoveModalStateChange:n=>{!n&&V.current==="remove"&&ne("")}})},"items-quoted")],["comments",t(g,{name:"CommentsTab",slot:a==null?void 0:a.CommentsTab,context:{quoteData:e},children:t(Na,{quoteData:e})},"comments")],["history-log",t(g,{name:"HistoryLogTab",slot:a==null?void 0:a.HistoryLogTab,context:{quoteData:e},children:t(ga,{quoteData:e})},"history-log")]])})}),[a==null?void 0:a.QuoteContent,a==null?void 0:a.HistoryLogTab,a==null?void 0:a.CommentsTab,a==null?void 0:a.ItemsQuotedTab,e,Ne]),Ve=f(()=>t(g,{name:"ShippingInformationTitle",slot:a==null?void 0:a.ShippingInformationTitle,context:{quoteData:e},children:t("h2",{children:o.shippingInformationTitle})}),[a==null?void 0:a.ShippingInformationTitle,e,o]),je=f(()=>t(g,{name:"ShippingInformation",slot:a==null?void 0:a.ShippingInformation,context:{quoteData:e,loading:q,setLoading:S},children:t(ua,{quoteData:e,loading:q,"data-testid":"manage-quote-shipping-address"})}),[a==null?void 0:a.ShippingInformation,e,q,S]),$e=f(()=>t(g,{name:"QuoteCommentsTitle",slot:a==null?void 0:a.QuoteCommentsTitle,context:{quoteData:e},children:t("h2",{children:o.quoteCommentsTitle})}),[a==null?void 0:a.QuoteCommentsTitle,o,e]),Ge=f(()=>t(g,{name:"QuoteComments",slot:a==null?void 0:a.QuoteComments,context:{quoteData:e},children:t(Re,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:T,onInput:n=>{ce(n.target.value)},disabled:F})}),[a==null?void 0:a.QuoteComments,o,e,T,F]),Xe=d(async()=>{if(e!=null&&e.uid){K(!0),B(""),R("");try{await pa({quoteUids:[e.uid]})}catch(n){console.error("Failed to close quote:",n)}}},[e]),Je=d(()=>{J(!1),B(""),R("")},[]),ye=d(async()=>{if(N){N({quoteData:e,comment:T.trim()||void 0});return}X(!0);try{await Ma({quoteUid:e.uid,comment:T.trim()||void 0})}catch(n){console.error("Failed to send quote for review:",n),X(!1)}},[e,N,T]),Ke=f(()=>t(g,{name:"Footer",slot:a==null?void 0:a.Footer,context:{quoteData:e,comment:T,isSubmitting:F},children:t(G,{variant:"primary",onClick:ye,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||F||!e,children:o.sendForReview})}),[a==null?void 0:a.Footer,o,e,T,F,ye]),Ye=f(()=>A?t(L,{type:"error",variant:"primary",icon:t($,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:A}):void 0,[A,o.renameErrorHeading]),Ze=f(()=>ee?t(L,{type:"success",variant:"primary",icon:t(le,{}),heading:o.renameSuccessHeading,description:ee}):void 0,[ee,o.renameSuccessHeading]),oe=d(n=>n.errors&&Array.isArray(n.errors)&&n.errors.length>0?n.errors[0].message||o.confirmationModalDeleteErrorFallback:(n==null?void 0:n.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),Ae=d(()=>{M(!1),b(null),P(!1)},[]),ea=d(async()=>{if(e!=null&&e.uid){b(null),P(!1);try{const{operationResults:n}=await ha(e.uid),r=n.find(i=>i.__typename==="DeleteNegotiableQuoteOperationFailure");if(r){const i=oe(r);b(i);return}P(!0)}catch(n){const r=oe(n);b(r)}}},[e,oe]),aa=d(()=>{b(null)},[]),ta=d(()=>{P(!1)},[]),na=C?t(L,{type:"error",variant:"primary",icon:t($,{}),heading:o.confirmationModalDeleteErrorHeading,description:C,onDismiss:aa,"data-testid":"confirmation-modal-error-banner"}):null,Ie=(I?t(L,{type:"success",variant:"primary",icon:t(le,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:ta,"data-testid":"confirmation-modal-success-banner"}):null)||na,oa={...Q,loading:q,quoteName:ke,quoteStatus:Pe,banner:Ue||void 0,details:ze,actionBar:We,quoteContent:Oe,shippingInformationTitle:Ve,shippingInformation:je,quoteCommentsTitle:$e,quoteComments:Ge,footer:Ke};let re=null;return ue?re=t(L,{type:"success",variant:"primary",icon:t(le,{}),heading:o.closeModalSuccessHeading,description:ue,"data-testid":"close-quote-success-banner"}):ge&&(re=t(L,{type:"error",variant:"primary",icon:t($,{}),heading:o.confirmationModalDeleteErrorHeading,description:ge,"data-testid":"close-quote-error-banner"})),s(we,{children:[t(Qa,{...oa}),be&&j(t(_a,{open:be,quoteName:U,renameReason:Z,quoteNameError:De,errorBanner:Ye,successBanner:Ze,onQuoteNameChange:Fe,onRenameReasonChange:W,onSave:Be,onClose:He}),document.body),_&&j(t(me,{open:_,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:Ae,onConfirm:ea,showCloseButton:!Ie,confirmationBanner:Ie}),document.body),se&&j(t(me,{open:se,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:de?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:Je,onConfirm:de?void 0:Xe,showCloseButton:!0,confirmationBanner:re,"data-testid":"close-quote-confirmation-modal"}),document.body),Me&&j(t(me,{open:Me,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:ve,onClose:ve,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{at as ManageNegotiableQuote,at as default};
4
4
  //# sourceMappingURL=ManageNegotiableQuote.js.map