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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/api/getStoreConfig/getStoreConfig.d.ts +4 -0
  2. package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +10 -0
  3. package/api/getStoreConfig/index.d.ts +10 -0
  4. package/api/index.d.ts +1 -0
  5. package/api.js +33 -19
  6. package/api.js.map +1 -1
  7. package/chunks/ChevronDown.js +4 -0
  8. package/chunks/ChevronDown.js.map +1 -0
  9. package/chunks/NegotiableQuoteFragment.js +129 -0
  10. package/chunks/NegotiableQuoteFragment.js.map +1 -1
  11. package/chunks/QuoteHistoryLog.js +1 -1
  12. package/chunks/QuoteHistoryLog.js.map +1 -1
  13. package/chunks/dateUtils.js +4 -0
  14. package/chunks/dateUtils.js.map +1 -0
  15. package/chunks/getQuoteTemplates.js +1 -1
  16. package/chunks/getQuoteTemplates.js.map +1 -1
  17. package/chunks/negotiableQuotes.js +1 -1
  18. package/chunks/negotiableQuotes.js.map +1 -1
  19. package/chunks/renameNegotiableQuote.js +1 -1
  20. package/chunks/renameNegotiableQuote.js.map +1 -1
  21. package/chunks/state.js +1 -1
  22. package/chunks/state.js.map +1 -1
  23. package/chunks/transform-quote.js +4 -0
  24. package/chunks/transform-quote.js.map +1 -0
  25. package/chunks/updateQuantities.js +1 -1
  26. package/chunks/updateQuantities.js.map +1 -1
  27. package/chunks/uploadFile.js +1 -1
  28. package/chunks/uploadFile.js.map +1 -1
  29. package/components/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +0 -1
  30. package/containers/ItemsQuoted.js +1 -1
  31. package/containers/ManageNegotiableQuote.js +1 -1
  32. package/containers/ManageNegotiableQuote.js.map +1 -1
  33. package/containers/OrderSummary.js +1 -1
  34. package/containers/OrderSummary.js.map +1 -1
  35. package/containers/QuoteHistoryLog.js +1 -1
  36. package/containers/QuoteSummaryList/QuoteSummaryList.d.ts +51 -0
  37. package/containers/QuoteSummaryList/index.d.ts +11 -0
  38. package/containers/QuoteSummaryList.d.ts +3 -0
  39. package/containers/QuoteSummaryList.js +4 -0
  40. package/containers/QuoteSummaryList.js.map +1 -0
  41. package/containers/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +0 -4
  42. package/containers/QuoteTemplatesListTable.js +1 -1
  43. package/containers/QuoteTemplatesListTable.js.map +1 -1
  44. package/containers/QuotesListTable.js +1 -1
  45. package/containers/QuotesListTable.js.map +1 -1
  46. package/containers/RequestNegotiableQuoteForm.js +1 -1
  47. package/containers/RequestNegotiableQuoteForm.js.map +1 -1
  48. package/containers/index.d.ts +1 -0
  49. package/data/models/__fixtures__/negotiableQuoteModel.d.ts +1 -0
  50. package/data/models/__fixtures__/storeConfigModel.d.ts +5 -0
  51. package/data/models/negotiable-quote-model.d.ts +33 -5
  52. package/data/models/store-config-model.d.ts +5 -2
  53. package/data/transforms/__fixtures__/negotiableQuoteData.d.ts +216 -0
  54. package/data/transforms/__fixtures__/storeConfigData.d.ts +31 -0
  55. package/data/transforms/index.d.ts +1 -0
  56. package/data/transforms/transform-store-config.d.ts +4 -0
  57. package/hooks/useQuoteSummaryData.d.ts +10 -0
  58. package/i18n/en_US.json.d.ts +13 -2
  59. package/lib/configurationTransformers.d.ts +27 -0
  60. package/lib/itemFormatters.d.ts +47 -0
  61. package/lib/priceCalculators.d.ts +41 -0
  62. package/package.json +1 -1
  63. package/render.js +1 -1
  64. package/render.js.map +1 -1
  65. package/utils/dateUtils.d.ts +6 -0
  66. package/chunks/fetch-graphql.js +0 -4
  67. package/chunks/fetch-graphql.js.map +0 -1
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as P,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import{useState as Q,useEffect as A}from"@dropins/tools/preact-compat.js";import{classes as H,Slot as o}from"@dropins/tools/lib.js";import{Table as J,IllustratedMessage as K,Picker as W,Pagination as X,Button as Y,Price as Z}from"@dropins/tools/components.js";import{events as U}from"@dropins/tools/event-bus.js";/* empty css *//* empty css */import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{useText as q}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{g as V}from"../chunks/fetch-graphql.js";import"../chunks/state.js";import{n as C}from"../chunks/negotiableQuotes.js";import"@dropins/tools/fetch-graphql.js";const ee=({rowData:S=[],loading:f=!1,className:N,emptyStateMessage:y,showItemRange:v=!0,itemRangeMessage:s,showPageSizePicker:p=!0,pageSizePickerMessage:i,showPagination:x=!0,paginationMessage:l,...g})=>{const m=q({quoteName:"QuoteManagement.QuotesListTable.quoteName",created:"QuoteManagement.QuotesListTable.created",createdBy:"QuoteManagement.QuotesListTable.createdBy",status:"QuoteManagement.QuotesListTable.status",lastUpdated:"QuoteManagement.QuotesListTable.lastUpdated",quoteTemplate:"QuoteManagement.QuotesListTable.quoteTemplate",quoteTotal:"QuoteManagement.QuotesListTable.quoteTotal",actions:"QuoteManagement.QuotesListTable.actions"}),h=[{key:"quoteName",label:m.quoteName},{key:"created",label:m.created},{key:"createdBy",label:m.createdBy},{key:"status",label:m.status},{key:"lastUpdated",label:m.lastUpdated},{key:"quoteTemplate",label:m.quoteTemplate},{key:"quoteTotal",label:m.quoteTotal},{key:"actions",label:m.actions}],z=!f&&S.length===0&&y,d=v&&s,b=p&&i,u=x&&l,T=d||b||u;return P("div",{...g,className:H(["quote-management-quotes-list-table",N]),children:[t(J,{columns:h,rowData:S,loading:f,mobileLayout:"none",className:"quote-management-quotes-list-table__table"}),z&&t("div",{className:"quotes-list-table__empty-state",children:y}),T&&P("div",{className:"quotes-list-table__footer",children:[t("div",{className:"quotes-list-table__item-range",children:d&&s}),t("div",{className:"quotes-list-table__pagination",children:u&&l}),t("div",{className:"quotes-list-table__page-size-picker",children:b&&i})]})]})},ye=({pageSize:S,showItemRange:f=!0,showPageSizePicker:N=!0,showPagination:y=!0,onViewQuote:v,onPageSizeChange:s,onPageChange:p,slots:i,...x})=>{const[l,g]=Q(null),[m,h]=Q(!0),z=V()[0],[d,b]=Q(S||z),[u,T]=Q(1);A(()=>{const c=async()=>{try{h(!0);const r=await C({pageSize:d,currentPage:u});g(r)}catch(r){console.error("Failed to fetch quotes:",r)}finally{h(!1)}},e=U.on("authenticated",r=>{r?c():(g(null),h(!1))},{eager:!0});return()=>{e==null||e.off()}},[d,u]),A(()=>{const c=async()=>{try{const r=await C({pageSize:d,currentPage:u});g(r)}catch(r){console.error("Failed to fetch quotes:",r)}},e=U.on("quote-management/quote-renamed",()=>{c()},{eager:!0});return()=>{e==null||e.off()}},[d,u]);const k=c=>{b(c),T(1),s==null||s(c)},_=c=>{T(c),p==null||p(c)},O=c=>{const e=c.target,r=e==null?void 0:e.value;r&&k(Number(r))},R=(c,e,r)=>c.filter(a=>a==null?void 0:a.uid).map(a=>{var w,I,B,M;const G=`${a.buyer.firstname} ${a.buyer.lastname}`;return{id:a.uid,quoteName:t(o,{name:"QuoteName",slot:e==null?void 0:e.QuoteName,context:{quote:a},children:t("span",{children:a.name})}),created:t(o,{name:"Created",slot:e==null?void 0:e.Created,context:{quote:a},children:t("span",{children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"N/A"})}),createdBy:t(o,{name:"CreatedBy",slot:e==null?void 0:e.CreatedBy,context:{quote:a},children:t("span",{children:G})}),status:t(o,{name:"Status",slot:e==null?void 0:e.Status,context:{quote:a},children:t("span",{children:a.status})}),lastUpdated:t(o,{name:"LastUpdated",slot:e==null?void 0:e.LastUpdated,context:{quote:a},children:t("span",{children:a.updatedAt?new Date(a.updatedAt).toLocaleDateString():"N/A"})}),quoteTemplate:t(o,{name:"QuoteTemplate",slot:e==null?void 0:e.QuoteTemplate,context:{quote:a},children:t("span",{children:a.templateName})}),quoteTotal:t(o,{name:"QuoteTotal",slot:e==null?void 0:e.QuoteTotal,context:{quote:a},children:t(Z,{amount:(I=(w=a.prices)==null?void 0:w.grandTotal)==null?void 0:I.value,currency:(M=(B=a.prices)==null?void 0:B.grandTotal)==null?void 0:M.currency})}),actions:t(o,{name:"Actions",slot:e==null?void 0:e.Actions,context:{quote:a,onViewQuote:r},children:t(Y,{variant:"tertiary",size:"medium",onClick:()=>r==null?void 0:r(a.uid,a.name,a.status),children:"View"})})}}),D=l!=null&&l.items?R(l.items,i,v):[],n=l==null?void 0:l.paginationInfo,L=!!n,E=t(o,{name:"EmptyQuotes",slot:i==null?void 0:i.EmptyQuotes,context:{quotesData:l},children:t(K,{heading:"No Quotes Found"})}),F=n?t(o,{name:"ItemRange",slot:i==null?void 0:i.ItemRange,context:n,children:P("span",{children:["Items ",n.startItem," to ",n.endItem," of"," ",n.totalCount," total"]})}):void 0,$=n&&n.pageSizeOptions?P(o,{name:"PageSizePicker",slot:i==null?void 0:i.PageSizePicker,context:{pageSize:n.pageSize,pageSizeOptions:n.pageSizeOptions,onPageSizeChange:k},children:[t("span",{children:"Show "}),t(W,{variant:"primary",size:"medium",value:String(n.pageSize),options:n.pageSizeOptions.map(c=>({value:String(c),text:String(c)})),handleSelect:O}),t("span",{children:" per page"})]}):void 0,j=n?t(o,{name:"Pagination",slot:i==null?void 0:i.Pagination,context:{currentPage:n.currentPage,totalPages:n.totalPages,onChange:_},children:t(X,{currentPage:n.currentPage,totalPages:n.totalPages,onChange:_})}):void 0;return t(ee,{rowData:D,loading:m,className:x.className,emptyStateMessage:E,showItemRange:f&&L,itemRangeMessage:F,showPageSizePicker:N&&L,pageSizePickerMessage:$,showPagination:y&&L,paginationMessage:j})};export{ye as QuotesListTable,ye as default};
3
+ import{jsxs as P,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import{useState as Q,useEffect as A}from"@dropins/tools/preact-compat.js";import{classes as H,Slot as o}from"@dropins/tools/lib.js";import{Table as J,IllustratedMessage as K,Picker as W,Pagination as X,Button as Y,Price as Z}from"@dropins/tools/components.js";import{events as U}from"@dropins/tools/event-bus.js";/* empty css *//* empty css */import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{useText as q}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{g as V}from"../chunks/transform-quote.js";import"../chunks/state.js";import{n as C}from"../chunks/negotiableQuotes.js";import"@dropins/tools/fetch-graphql.js";const ee=({rowData:S=[],loading:f=!1,className:N,emptyStateMessage:y,showItemRange:v=!0,itemRangeMessage:s,showPageSizePicker:p=!0,pageSizePickerMessage:i,showPagination:x=!0,paginationMessage:l,...g})=>{const m=q({quoteName:"QuoteManagement.QuotesListTable.quoteName",created:"QuoteManagement.QuotesListTable.created",createdBy:"QuoteManagement.QuotesListTable.createdBy",status:"QuoteManagement.QuotesListTable.status",lastUpdated:"QuoteManagement.QuotesListTable.lastUpdated",quoteTemplate:"QuoteManagement.QuotesListTable.quoteTemplate",quoteTotal:"QuoteManagement.QuotesListTable.quoteTotal",actions:"QuoteManagement.QuotesListTable.actions"}),h=[{key:"quoteName",label:m.quoteName},{key:"created",label:m.created},{key:"createdBy",label:m.createdBy},{key:"status",label:m.status},{key:"lastUpdated",label:m.lastUpdated},{key:"quoteTemplate",label:m.quoteTemplate},{key:"quoteTotal",label:m.quoteTotal},{key:"actions",label:m.actions}],z=!f&&S.length===0&&y,d=v&&s,b=p&&i,u=x&&l,T=d||b||u;return P("div",{...g,className:H(["quote-management-quotes-list-table",N]),children:[t(J,{columns:h,rowData:S,loading:f,mobileLayout:"none",className:"quote-management-quotes-list-table__table"}),z&&t("div",{className:"quotes-list-table__empty-state",children:y}),T&&P("div",{className:"quotes-list-table__footer",children:[t("div",{className:"quotes-list-table__item-range",children:d&&s}),t("div",{className:"quotes-list-table__pagination",children:u&&l}),t("div",{className:"quotes-list-table__page-size-picker",children:b&&i})]})]})},ye=({pageSize:S,showItemRange:f=!0,showPageSizePicker:N=!0,showPagination:y=!0,onViewQuote:v,onPageSizeChange:s,onPageChange:p,slots:i,...x})=>{const[l,g]=Q(null),[m,h]=Q(!0),z=V()[0],[d,b]=Q(S||z),[u,T]=Q(1);A(()=>{const c=async()=>{try{h(!0);const r=await C({pageSize:d,currentPage:u});g(r)}catch(r){console.error("Failed to fetch quotes:",r)}finally{h(!1)}},e=U.on("authenticated",r=>{r?c():(g(null),h(!1))},{eager:!0});return()=>{e==null||e.off()}},[d,u]),A(()=>{const c=async()=>{try{const r=await C({pageSize:d,currentPage:u});g(r)}catch(r){console.error("Failed to fetch quotes:",r)}},e=U.on("quote-management/quote-renamed",()=>{c()},{eager:!0});return()=>{e==null||e.off()}},[d,u]);const k=c=>{b(c),T(1),s==null||s(c)},_=c=>{T(c),p==null||p(c)},O=c=>{const e=c.target,r=e==null?void 0:e.value;r&&k(Number(r))},R=(c,e,r)=>c.filter(a=>a==null?void 0:a.uid).map(a=>{var w,I,B,M;const G=`${a.buyer.firstname} ${a.buyer.lastname}`;return{id:a.uid,quoteName:t(o,{name:"QuoteName",slot:e==null?void 0:e.QuoteName,context:{quote:a},children:t("span",{children:a.name})}),created:t(o,{name:"Created",slot:e==null?void 0:e.Created,context:{quote:a},children:t("span",{children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"N/A"})}),createdBy:t(o,{name:"CreatedBy",slot:e==null?void 0:e.CreatedBy,context:{quote:a},children:t("span",{children:G})}),status:t(o,{name:"Status",slot:e==null?void 0:e.Status,context:{quote:a},children:t("span",{children:a.status})}),lastUpdated:t(o,{name:"LastUpdated",slot:e==null?void 0:e.LastUpdated,context:{quote:a},children:t("span",{children:a.updatedAt?new Date(a.updatedAt).toLocaleDateString():"N/A"})}),quoteTemplate:t(o,{name:"QuoteTemplate",slot:e==null?void 0:e.QuoteTemplate,context:{quote:a},children:t("span",{children:a.templateName})}),quoteTotal:t(o,{name:"QuoteTotal",slot:e==null?void 0:e.QuoteTotal,context:{quote:a},children:t(Z,{amount:(I=(w=a.prices)==null?void 0:w.grandTotal)==null?void 0:I.value,currency:(M=(B=a.prices)==null?void 0:B.grandTotal)==null?void 0:M.currency})}),actions:t(o,{name:"Actions",slot:e==null?void 0:e.Actions,context:{quote:a,onViewQuote:r},children:t(Y,{variant:"tertiary",size:"medium",onClick:()=>r==null?void 0:r(a.uid,a.name,a.status),children:"View"})})}}),D=l!=null&&l.items?R(l.items,i,v):[],n=l==null?void 0:l.paginationInfo,L=!!n,E=t(o,{name:"EmptyQuotes",slot:i==null?void 0:i.EmptyQuotes,context:{quotesData:l},children:t(K,{heading:"No Quotes Found"})}),F=n?t(o,{name:"ItemRange",slot:i==null?void 0:i.ItemRange,context:n,children:P("span",{children:["Items ",n.startItem," to ",n.endItem," of"," ",n.totalCount," total"]})}):void 0,$=n&&n.pageSizeOptions?P(o,{name:"PageSizePicker",slot:i==null?void 0:i.PageSizePicker,context:{pageSize:n.pageSize,pageSizeOptions:n.pageSizeOptions,onPageSizeChange:k},children:[t("span",{children:"Show "}),t(W,{variant:"primary",size:"medium",value:String(n.pageSize),options:n.pageSizeOptions.map(c=>({value:String(c),text:String(c)})),handleSelect:O}),t("span",{children:" per page"})]}):void 0,j=n?t(o,{name:"Pagination",slot:i==null?void 0:i.Pagination,context:{currentPage:n.currentPage,totalPages:n.totalPages,onChange:_},children:t(X,{currentPage:n.currentPage,totalPages:n.totalPages,onChange:_})}):void 0;return t(ee,{rowData:D,loading:m,className:x.className,emptyStateMessage:E,showItemRange:f&&L,itemRangeMessage:F,showPageSizePicker:N&&L,pageSizePickerMessage:$,showPagination:y&&L,paginationMessage:j})};export{ye as QuotesListTable,ye as default};
4
4
  //# sourceMappingURL=QuotesListTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuotesListTable.js","sources":["/@dropins/storefront-quote-management/src/components/QuotesListTable/QuotesListTable.tsx","/@dropins/storefront-quote-management/src/containers/QuotesListTable/QuotesListTable.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, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Table } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport '@/quote-management/components/QuotesListTable/QuotesListTable.css';\n\ntype Column = {\n key: string;\n label: string;\n};\n\nexport interface QuotesListTableProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'loading' | 'children'> {\n rowData: QuoteRowData[];\n loading?: boolean;\n className?: string;\n emptyStateMessage?: VNode;\n showItemRange?: boolean;\n itemRangeMessage?: VNode;\n showPageSizePicker?: boolean;\n pageSizePickerMessage?: VNode;\n showPagination?: boolean;\n paginationMessage?: VNode;\n}\n\nexport type QuoteRowData = {\n id: string;\n quoteName: VNode;\n created: VNode;\n createdBy: VNode;\n status: VNode;\n lastUpdated: VNode;\n quoteTemplate: VNode;\n quoteTotal: VNode;\n actions: VNode;\n [key: string]: VNode | string | number | undefined;\n};\n\nexport const QuotesListTable: FunctionComponent<QuotesListTableProps> = ({\n rowData = [],\n loading = false,\n className,\n emptyStateMessage,\n showItemRange = true,\n itemRangeMessage,\n showPageSizePicker = true,\n pageSizePickerMessage,\n showPagination = true,\n paginationMessage,\n ...props\n}) => {\n const dictionary = useText({\n quoteName: 'QuoteManagement.QuotesListTable.quoteName',\n created: 'QuoteManagement.QuotesListTable.created',\n createdBy: 'QuoteManagement.QuotesListTable.createdBy',\n status: 'QuoteManagement.QuotesListTable.status',\n lastUpdated: 'QuoteManagement.QuotesListTable.lastUpdated',\n quoteTemplate: 'QuoteManagement.QuotesListTable.quoteTemplate',\n quoteTotal: 'QuoteManagement.QuotesListTable.quoteTotal',\n actions: 'QuoteManagement.QuotesListTable.actions',\n });\n\n const columns: Column[] = [\n { key: 'quoteName', label: dictionary.quoteName },\n { key: 'created', label: dictionary.created },\n { key: 'createdBy', label: dictionary.createdBy },\n { key: 'status', label: dictionary.status },\n { key: 'lastUpdated', label: dictionary.lastUpdated },\n { key: 'quoteTemplate', label: dictionary.quoteTemplate },\n { key: 'quoteTotal', label: dictionary.quoteTotal },\n { key: 'actions', label: dictionary.actions },\n ];\n\n // Check if we should show empty state\n const shouldShowEmptyState =\n !loading && rowData.length === 0 && emptyStateMessage;\n\n // Show item range if requested and message is provided\n const shouldShowItemRange = showItemRange && itemRangeMessage;\n\n // Show page size picker if requested and message is provided\n const shouldShowPageSizePicker = showPageSizePicker && pageSizePickerMessage;\n\n // Show pagination if requested and message is provided\n const shouldShowPagination = showPagination && paginationMessage;\n\n // Show footer if any pagination element should be shown\n const shouldShowFooter =\n shouldShowItemRange || shouldShowPageSizePicker || shouldShowPagination;\n\n return (\n <div\n {...props}\n className={classes(['quote-management-quotes-list-table', className])}\n >\n <Table\n columns={columns}\n rowData={rowData}\n loading={loading}\n mobileLayout=\"none\"\n className=\"quote-management-quotes-list-table__table\"\n />\n {shouldShowEmptyState && (\n <div className=\"quotes-list-table__empty-state\">\n {emptyStateMessage}\n </div>\n )}\n {shouldShowFooter && (\n <div className=\"quotes-list-table__footer\">\n <div className=\"quotes-list-table__item-range\">\n {shouldShowItemRange && itemRangeMessage}\n </div>\n <div className=\"quotes-list-table__pagination\">\n {shouldShowPagination && paginationMessage}\n </div>\n <div className=\"quotes-list-table__page-size-picker\">\n {shouldShowPageSizePicker && pageSizePickerMessage}\n </div>\n </div>\n )}\n </div>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport {\n Price,\n Button,\n IllustratedMessage,\n Picker,\n Pagination,\n type PickerOption,\n} from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport {\n QuotesListTable as QuotesListTableComponent,\n QuoteRowData,\n} from '@/quote-management/components';\nimport { negotiableQuotes } from '@/quote-management/api';\nimport { getDefaultPageSizeOptions } from '@/quote-management/data/transforms';\nimport {\n NegotiableQuotesListModel,\n NegotiableQuoteListEntry,\n} from '@/quote-management/data/models';\n\nexport interface QuotesListTableProps extends HTMLAttributes<HTMLDivElement> {\n pageSize?: number;\n showItemRange?: boolean;\n showPageSizePicker?: boolean;\n showPagination?: boolean;\n onViewQuote?: (quoteId: string, quoteName: string, status: string) => void;\n onPageSizeChange?: (pageSize: number) => void;\n onPageChange?: (page: number) => void;\n slots?: {\n /** Slot for customizing the quote name cell content */\n QuoteName?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the created date cell content */\n Created?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the created by cell content */\n CreatedBy?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the status cell content */\n Status?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the last updated cell content */\n LastUpdated?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the quote template cell content */\n QuoteTemplate?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the quote total cell content */\n QuoteTotal?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the actions cell content */\n Actions?: SlotProps<{\n quote: NegotiableQuoteListEntry;\n onViewQuote?: (id: string, name: string, status: string) => void;\n }>;\n /** Slot for customizing the empty quotes message */\n EmptyQuotes?: SlotProps;\n /** Slot for customizing the item range display */\n ItemRange?: SlotProps<{\n startItem: number;\n endItem: number;\n totalCount: number;\n currentPage: number;\n pageSize: number;\n }>;\n /** Slot for customizing the page size picker */\n PageSizePicker?: SlotProps<{\n pageSize: number;\n pageSizeOptions: number[];\n onPageSizeChange?: (pageSize: number) => void;\n }>;\n /** Slot for customizing the pagination */\n Pagination?: SlotProps<{\n currentPage: number;\n totalPages: number;\n onChange?: (page: number) => void;\n }>;\n };\n}\n\nexport const QuotesListTable: Container<QuotesListTableProps> = ({\n pageSize,\n showItemRange = true,\n showPageSizePicker = true,\n showPagination = true,\n onViewQuote,\n onPageSizeChange,\n onPageChange,\n slots,\n ...props\n}) => {\n const [quotesData, setQuotesData] =\n useState<NegotiableQuotesListModel | null>(null);\n const [loading, setLoading] = useState(true);\n\n // Default to first page size option if no pageSize prop provided\n const defaultPageSize = getDefaultPageSizeOptions()[0];\n const [currentPageSize, setCurrentPageSize] = useState(\n pageSize || defaultPageSize\n );\n const [currentPage, setCurrentPage] = useState(1);\n\n // Fetch quotes data when authenticated\n useEffect(() => {\n const fetchQuotes = async () => {\n try {\n setLoading(true);\n const data = await negotiableQuotes({\n pageSize: currentPageSize,\n currentPage,\n });\n setQuotesData(data);\n } catch (error) {\n console.error('Failed to fetch quotes:', error);\n } finally {\n setLoading(false);\n }\n };\n\n // Listen for authentication events\n const unsubscribe = events.on(\n 'authenticated',\n (isAuthenticated) => {\n if (isAuthenticated) {\n fetchQuotes();\n } else {\n setQuotesData(null);\n setLoading(false);\n }\n },\n { eager: true }\n ); // eager: true means it fires immediately with current state\n\n return () => {\n unsubscribe?.off();\n };\n }, [currentPageSize, currentPage]);\n\n // Listen for quote renamed event to refresh the list\n useEffect(() => {\n const fetchQuotes = async () => {\n try {\n const data = await negotiableQuotes({\n pageSize: currentPageSize,\n currentPage,\n });\n setQuotesData(data);\n } catch (error) {\n console.error('Failed to fetch quotes:', error);\n }\n };\n\n const unsubscribe = events.on(\n 'quote-management/quote-renamed',\n () => {\n // Refetch quotes list to show the updated name\n fetchQuotes();\n },\n { eager: true }\n );\n\n return () => {\n unsubscribe?.off();\n };\n }, [currentPageSize, currentPage]);\n\n // Handle page size change\n const handlePageSizeChange = (newPageSize: number) => {\n setCurrentPageSize(newPageSize);\n setCurrentPage(1); // Reset to page 1 when page size changes\n onPageSizeChange?.(newPageSize); // Also call parent callback\n };\n\n // Handle page change\n const handlePageChange = (newPage: number) => {\n setCurrentPage(newPage);\n onPageChange?.(newPage); // Also call parent callback\n };\n\n // Handle page size picker selection\n const handlePageSizeSelect = (event: Event) => {\n const target = event.target as HTMLSelectElement;\n const value = target?.value;\n if (value) {\n handlePageSizeChange(Number(value));\n }\n };\n\n // Prepare transformed quote data for table component\n const prepareRowData = (\n quotes: NegotiableQuoteListEntry[],\n slots?: QuotesListTableProps['slots'],\n onViewQuote?: (quoteId: string, quoteName: string, status: string) => void\n ): QuoteRowData[] => {\n return quotes\n .filter((quote) => quote?.uid) // Filter out null quotes\n .map((quote) => {\n const createdByName = `${quote.buyer.firstname} ${quote.buyer.lastname}`;\n\n return {\n id: quote.uid,\n quoteName: (\n <Slot name=\"QuoteName\" slot={slots?.QuoteName} context={{ quote }}>\n <span>{quote.name}</span>\n </Slot>\n ),\n created: (\n <Slot name=\"Created\" slot={slots?.Created} context={{ quote }}>\n <span>\n {quote.createdAt\n ? new Date(quote.createdAt).toLocaleDateString()\n : 'N/A'}\n </span>\n </Slot>\n ),\n createdBy: (\n <Slot name=\"CreatedBy\" slot={slots?.CreatedBy} context={{ quote }}>\n <span>{createdByName}</span>\n </Slot>\n ),\n status: (\n <Slot name=\"Status\" slot={slots?.Status} context={{ quote }}>\n <span>{quote.status}</span>\n </Slot>\n ),\n lastUpdated: (\n <Slot\n name=\"LastUpdated\"\n slot={slots?.LastUpdated}\n context={{ quote }}\n >\n <span>\n {quote.updatedAt\n ? new Date(quote.updatedAt).toLocaleDateString()\n : 'N/A'}\n </span>\n </Slot>\n ),\n quoteTemplate: (\n <Slot\n name=\"QuoteTemplate\"\n slot={slots?.QuoteTemplate}\n context={{ quote }}\n >\n <span>{quote.templateName}</span>\n </Slot>\n ),\n quoteTotal: (\n <Slot\n name=\"QuoteTotal\"\n slot={slots?.QuoteTotal}\n context={{ quote }}\n >\n <Price\n amount={quote.prices?.grandTotal?.value}\n currency={quote.prices?.grandTotal?.currency}\n />\n </Slot>\n ),\n actions: (\n <Slot\n name=\"Actions\"\n slot={slots?.Actions}\n context={{ quote, onViewQuote }}\n >\n <Button\n variant=\"tertiary\"\n size=\"medium\"\n onClick={() =>\n onViewQuote?.(quote.uid, quote.name, quote.status)\n }\n >\n View\n </Button>\n </Slot>\n ),\n };\n });\n };\n\n // Prepare data for rendering\n const rowData = quotesData?.items\n ? prepareRowData(quotesData.items, slots, onViewQuote)\n : [];\n\n const paginationInfo = quotesData?.paginationInfo;\n const shouldShowPagination = !!paginationInfo;\n\n // Empty state message\n const emptyStateMessage = (\n <Slot name=\"EmptyQuotes\" slot={slots?.EmptyQuotes} context={{ quotesData }}>\n <IllustratedMessage heading=\"No Quotes Found\" />\n </Slot>\n );\n\n // Item range message\n const itemRangeMessage = paginationInfo ? (\n <Slot name=\"ItemRange\" slot={slots?.ItemRange} context={paginationInfo}>\n <span>\n Items {paginationInfo.startItem} to {paginationInfo.endItem} of{' '}\n {paginationInfo.totalCount} total\n </span>\n </Slot>\n ) : undefined;\n\n // Prepare page size picker message for component\n const pageSizePickerMessage =\n paginationInfo && paginationInfo.pageSizeOptions ? (\n <Slot\n name=\"PageSizePicker\"\n slot={slots?.PageSizePicker}\n context={{\n pageSize: paginationInfo.pageSize,\n pageSizeOptions: paginationInfo.pageSizeOptions,\n onPageSizeChange: handlePageSizeChange,\n }}\n >\n <span>Show </span>\n <Picker\n variant=\"primary\"\n size=\"medium\"\n value={String(paginationInfo.pageSize)}\n options={paginationInfo.pageSizeOptions.map(\n (size): PickerOption => ({\n value: String(size),\n text: String(size),\n })\n )}\n handleSelect={handlePageSizeSelect}\n />\n <span> per page</span>\n </Slot>\n ) : undefined;\n\n // Prepare pagination message for component\n const paginationMessage = paginationInfo ? (\n <Slot\n name=\"Pagination\"\n slot={slots?.Pagination}\n context={{\n currentPage: paginationInfo.currentPage,\n totalPages: paginationInfo.totalPages,\n onChange: handlePageChange,\n }}\n >\n <Pagination\n currentPage={paginationInfo.currentPage}\n totalPages={paginationInfo.totalPages}\n onChange={handlePageChange}\n />\n </Slot>\n ) : undefined;\n\n return (\n <QuotesListTableComponent\n rowData={rowData}\n loading={loading}\n className={props.className as string}\n emptyStateMessage={emptyStateMessage}\n showItemRange={showItemRange && shouldShowPagination}\n itemRangeMessage={itemRangeMessage}\n showPageSizePicker={showPageSizePicker && shouldShowPagination}\n pageSizePickerMessage={pageSizePickerMessage}\n showPagination={showPagination && shouldShowPagination}\n paginationMessage={paginationMessage}\n />\n );\n};\n"],"names":["QuotesListTable","rowData","loading","className","emptyStateMessage","showItemRange","itemRangeMessage","showPageSizePicker","pageSizePickerMessage","showPagination","paginationMessage","props","dictionary","useText","columns","shouldShowEmptyState","shouldShowItemRange","shouldShowPageSizePicker","shouldShowPagination","shouldShowFooter","jsxs","classes","jsx","Table","pageSize","onViewQuote","onPageSizeChange","onPageChange","slots","quotesData","setQuotesData","useState","setLoading","defaultPageSize","getDefaultPageSizeOptions","currentPageSize","setCurrentPageSize","currentPage","setCurrentPage","useEffect","fetchQuotes","data","negotiableQuotes","error","unsubscribe","events","isAuthenticated","handlePageSizeChange","newPageSize","handlePageChange","newPage","handlePageSizeSelect","event","target","value","prepareRowData","quotes","quote","createdByName","Slot","Price","_b","_a","_d","_c","Button","paginationInfo","IllustratedMessage","Picker","size","Pagination","QuotesListTableComponent"],"mappings":"s2BAgDO,MAAMA,GAA2D,CAAC,CACvE,QAAAC,EAAU,CAAA,EACV,QAAAC,EAAU,GACV,UAAAC,EACA,kBAAAC,EACA,cAAAC,EAAgB,GAChB,iBAAAC,EACA,mBAAAC,EAAqB,GACrB,sBAAAC,EACA,eAAAC,EAAiB,GACjB,kBAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAAaC,EAAQ,CACzB,UAAW,4CACX,QAAS,0CACT,UAAW,4CACX,OAAQ,yCACR,YAAa,8CACb,cAAe,gDACf,WAAY,6CACZ,QAAS,yCAAA,CACV,EAEKC,EAAoB,CACxB,CAAE,IAAK,YAAa,MAAOF,EAAW,SAAA,EACtC,CAAE,IAAK,UAAW,MAAOA,EAAW,OAAA,E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A,EAAe,WAAW,QAAA,CAAA,CAC7B,EACF,EACE,OAGE1D,EACJ0D,GAAkBA,EAAe,gBAC/B9C,EAACuC,EAAA,CACC,KAAK,iBACL,KAAM/B,GAAA,YAAAA,EAAO,eACb,QAAS,CACP,SAAUsC,EAAe,SACzB,gBAAiBA,EAAe,gBAChC,iBAAkBnB,CAAA,EAGpB,SAAA,CAAAzB,EAAC,QAAK,SAAA,OAAA,CAAK,EACXA,EAAC8C,EAAA,CACC,QAAQ,UACR,KAAK,SACL,MAAO,OAAOF,EAAe,QAAQ,EACrC,QAASA,EAAe,gBAAgB,IACrCG,IAAwB,CACvB,MAAO,OAAOA,CAAI,EAClB,KAAM,OAAOA,CAAI,CAAA,EACnB,EAEF,aAAclB,CAAA,CAAA,EAEhB7B,EAAC,QAAK,SAAA,WAAA,CAAS,CAAA,CAAA,CAAA,EAEf,OAGAZ,EAAoBwD,EACxB5C,EAACqC,EAAA,CACC,KAAK,aACL,KAAM/B,GAAA,YAAAA,EAAO,WACb,QAAS,CACP,YAAasC,EAAe,YAC5B,WAAYA,EAAe,WAC3B,SAAUjB,CAAA,EAGZ,SAAA3B,EAACgD,EAAA,CACC,YAAaJ,EAAe,YAC5B,WAAYA,EAAe,WAC3B,SAAUjB,CAAA,CAAA,CACZ,CAAA,EAEA,OAEJ,OACE3B,EAACiD,GAAA,CACC,QAAAtE,EACA,QAAAC,EACA,UAAWS,EAAM,UACjB,kBAAAP,EACA,cAAeC,GAAiBa,EAChC,iBAAAZ,EACA,mBAAoBC,GAAsBW,EAC1C,sBAAAV,EACA,eAAgBC,GAAkBS,EAClC,kBAAAR,CAAA,CAAA,CAGN"}
1
+ {"version":3,"file":"QuotesListTable.js","sources":["/@dropins/storefront-quote-management/src/components/QuotesListTable/QuotesListTable.tsx","/@dropins/storefront-quote-management/src/containers/QuotesListTable/QuotesListTable.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, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Table } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport '@/quote-management/components/QuotesListTable/QuotesListTable.css';\n\ntype Column = {\n key: string;\n label: string;\n};\n\nexport interface QuotesListTableProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'loading' | 'children'> {\n rowData: QuoteRowData[];\n loading?: boolean;\n className?: string;\n emptyStateMessage?: VNode;\n showItemRange?: boolean;\n itemRangeMessage?: VNode;\n showPageSizePicker?: boolean;\n pageSizePickerMessage?: VNode;\n showPagination?: boolean;\n paginationMessage?: VNode;\n}\n\nexport type QuoteRowData = {\n id: string;\n quoteName: VNode;\n created: VNode;\n createdBy: VNode;\n status: VNode;\n lastUpdated: VNode;\n quoteTemplate: VNode;\n quoteTotal: VNode;\n actions: VNode;\n [key: string]: VNode | string | number | undefined;\n};\n\nexport const QuotesListTable: FunctionComponent<QuotesListTableProps> = ({\n rowData = [],\n loading = false,\n className,\n emptyStateMessage,\n showItemRange = true,\n itemRangeMessage,\n showPageSizePicker = true,\n pageSizePickerMessage,\n showPagination = true,\n paginationMessage,\n ...props\n}) => {\n const dictionary = useText({\n quoteName: 'QuoteManagement.QuotesListTable.quoteName',\n created: 'QuoteManagement.QuotesListTable.created',\n createdBy: 'QuoteManagement.QuotesListTable.createdBy',\n status: 'QuoteManagement.QuotesListTable.status',\n lastUpdated: 'QuoteManagement.QuotesListTable.lastUpdated',\n quoteTemplate: 'QuoteManagement.QuotesListTable.quoteTemplate',\n quoteTotal: 'QuoteManagement.QuotesListTable.quoteTotal',\n actions: 'QuoteManagement.QuotesListTable.actions',\n });\n\n const columns: Column[] = [\n { key: 'quoteName', label: dictionary.quoteName },\n { key: 'created', label: dictionary.created },\n { key: 'createdBy', label: dictionary.createdBy },\n { key: 'status', label: dictionary.status },\n { key: 'lastUpdated', label: dictionary.lastUpdated },\n { key: 'quoteTemplate', label: dictionary.quoteTemplate },\n { key: 'quoteTotal', label: dictionary.quoteTotal },\n { key: 'actions', label: dictionary.actions },\n ];\n\n // Check if we should show empty state\n const shouldShowEmptyState =\n !loading && rowData.length === 0 && emptyStateMessage;\n\n // Show item range if requested and message is provided\n const shouldShowItemRange = showItemRange && itemRangeMessage;\n\n // Show page size picker if requested and message is provided\n const shouldShowPageSizePicker = showPageSizePicker && pageSizePickerMessage;\n\n // Show pagination if requested and message is provided\n const shouldShowPagination = showPagination && paginationMessage;\n\n // Show footer if any pagination element should be shown\n const shouldShowFooter =\n shouldShowItemRange || shouldShowPageSizePicker || shouldShowPagination;\n\n return (\n <div\n {...props}\n className={classes(['quote-management-quotes-list-table', className])}\n >\n <Table\n columns={columns}\n rowData={rowData}\n loading={loading}\n mobileLayout=\"none\"\n className=\"quote-management-quotes-list-table__table\"\n />\n {shouldShowEmptyState && (\n <div className=\"quotes-list-table__empty-state\">\n {emptyStateMessage}\n </div>\n )}\n {shouldShowFooter && (\n <div className=\"quotes-list-table__footer\">\n <div className=\"quotes-list-table__item-range\">\n {shouldShowItemRange && itemRangeMessage}\n </div>\n <div className=\"quotes-list-table__pagination\">\n {shouldShowPagination && paginationMessage}\n </div>\n <div className=\"quotes-list-table__page-size-picker\">\n {shouldShowPageSizePicker && pageSizePickerMessage}\n </div>\n </div>\n )}\n </div>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport {\n Price,\n Button,\n IllustratedMessage,\n Picker,\n Pagination,\n type PickerOption,\n} from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport {\n QuotesListTable as QuotesListTableComponent,\n QuoteRowData,\n} from '@/quote-management/components';\nimport { negotiableQuotes } from '@/quote-management/api';\nimport { getDefaultPageSizeOptions } from '@/quote-management/data/transforms';\nimport {\n NegotiableQuotesListModel,\n NegotiableQuoteListEntry,\n} from '@/quote-management/data/models';\n\nexport interface QuotesListTableProps extends HTMLAttributes<HTMLDivElement> {\n pageSize?: number;\n showItemRange?: boolean;\n showPageSizePicker?: boolean;\n showPagination?: boolean;\n onViewQuote?: (quoteId: string, quoteName: string, status: string) => void;\n onPageSizeChange?: (pageSize: number) => void;\n onPageChange?: (page: number) => void;\n slots?: {\n /** Slot for customizing the quote name cell content */\n QuoteName?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the created date cell content */\n Created?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the created by cell content */\n CreatedBy?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the status cell content */\n Status?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the last updated cell content */\n LastUpdated?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the quote template cell content */\n QuoteTemplate?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the quote total cell content */\n QuoteTotal?: SlotProps<{ quote: NegotiableQuoteListEntry }>;\n /** Slot for customizing the actions cell content */\n Actions?: SlotProps<{\n quote: NegotiableQuoteListEntry;\n onViewQuote?: (id: string, name: string, status: string) => void;\n }>;\n /** Slot for customizing the empty quotes message */\n EmptyQuotes?: SlotProps;\n /** Slot for customizing the item range display */\n ItemRange?: SlotProps<{\n startItem: number;\n endItem: number;\n totalCount: number;\n currentPage: number;\n pageSize: number;\n }>;\n /** Slot for customizing the page size picker */\n PageSizePicker?: SlotProps<{\n pageSize: number;\n pageSizeOptions: number[];\n onPageSizeChange?: (pageSize: number) => void;\n }>;\n /** Slot for customizing the pagination */\n Pagination?: SlotProps<{\n currentPage: number;\n totalPages: number;\n onChange?: (page: number) => void;\n }>;\n };\n}\n\nexport const QuotesListTable: Container<QuotesListTableProps> = ({\n pageSize,\n showItemRange = true,\n showPageSizePicker = true,\n showPagination = true,\n onViewQuote,\n onPageSizeChange,\n onPageChange,\n slots,\n ...props\n}) => {\n const [quotesData, setQuotesData] =\n useState<NegotiableQuotesListModel | null>(null);\n const [loading, setLoading] = useState(true);\n\n // Default to first page size option if no pageSize prop provided\n const defaultPageSize = getDefaultPageSizeOptions()[0];\n const [currentPageSize, setCurrentPageSize] = useState(\n pageSize || defaultPageSize\n );\n const [currentPage, setCurrentPage] = useState(1);\n\n // Fetch quotes data when authenticated\n useEffect(() => {\n const fetchQuotes = async () => {\n try {\n setLoading(true);\n const data = await negotiableQuotes({\n pageSize: currentPageSize,\n currentPage,\n });\n setQuotesData(data);\n } catch (error) {\n console.error('Failed to fetch quotes:', error);\n } finally {\n setLoading(false);\n }\n };\n\n // Listen for authentication events\n const unsubscribe = events.on(\n 'authenticated',\n (isAuthenticated) => {\n if (isAuthenticated) {\n fetchQuotes();\n } else {\n setQuotesData(null);\n setLoading(false);\n }\n },\n { eager: true }\n ); // eager: true means it fires immediately with current state\n\n return () => {\n unsubscribe?.off();\n };\n }, [currentPageSize, currentPage]);\n\n // Listen for quote renamed event to refresh the list\n useEffect(() => {\n const fetchQuotes = async () => {\n try {\n const data = await negotiableQuotes({\n pageSize: currentPageSize,\n currentPage,\n });\n setQuotesData(data);\n } catch (error) {\n console.error('Failed to fetch quotes:', error);\n }\n };\n\n const unsubscribe = events.on(\n 'quote-management/quote-renamed',\n () => {\n // Refetch quotes list to show the updated name\n fetchQuotes();\n },\n { eager: true }\n );\n\n return () => {\n unsubscribe?.off();\n };\n }, [currentPageSize, currentPage]);\n\n // Handle page size change\n const handlePageSizeChange = (newPageSize: number) => {\n setCurrentPageSize(newPageSize);\n setCurrentPage(1); // Reset to page 1 when page size changes\n onPageSizeChange?.(newPageSize); // Also call parent callback\n };\n\n // Handle page change\n const handlePageChange = (newPage: number) => {\n setCurrentPage(newPage);\n onPageChange?.(newPage); // Also call parent callback\n };\n\n // Handle page size picker selection\n const handlePageSizeSelect = (event: Event) => {\n const target = event.target as HTMLSelectElement;\n const value = target?.value;\n if (value) {\n handlePageSizeChange(Number(value));\n }\n };\n\n // Prepare transformed quote data for table component\n const prepareRowData = (\n quotes: NegotiableQuoteListEntry[],\n slots?: QuotesListTableProps['slots'],\n onViewQuote?: (quoteId: string, quoteName: string, status: string) => void\n ): QuoteRowData[] => {\n return quotes\n .filter((quote) => quote?.uid) // Filter out null quotes\n .map((quote) => {\n const createdByName = `${quote.buyer.firstname} ${quote.buyer.lastname}`;\n\n return {\n id: quote.uid,\n quoteName: (\n <Slot name=\"QuoteName\" slot={slots?.QuoteName} context={{ quote }}>\n <span>{quote.name}</span>\n </Slot>\n ),\n created: (\n <Slot name=\"Created\" slot={slots?.Created} context={{ quote }}>\n <span>\n {quote.createdAt\n ? new Date(quote.createdAt).toLocaleDateString()\n : 'N/A'}\n </span>\n </Slot>\n ),\n createdBy: (\n <Slot name=\"CreatedBy\" slot={slots?.CreatedBy} context={{ quote }}>\n <span>{createdByName}</span>\n </Slot>\n ),\n status: (\n <Slot name=\"Status\" slot={slots?.Status} context={{ quote }}>\n <span>{quote.status}</span>\n </Slot>\n ),\n lastUpdated: (\n <Slot\n name=\"LastUpdated\"\n slot={slots?.LastUpdated}\n context={{ quote }}\n >\n <span>\n {quote.updatedAt\n ? new Date(quote.updatedAt).toLocaleDateString()\n : 'N/A'}\n </span>\n </Slot>\n ),\n quoteTemplate: (\n <Slot\n name=\"QuoteTemplate\"\n slot={slots?.QuoteTemplate}\n context={{ quote }}\n >\n <span>{quote.templateName}</span>\n </Slot>\n ),\n quoteTotal: (\n <Slot\n name=\"QuoteTotal\"\n slot={slots?.QuoteTotal}\n context={{ quote }}\n >\n <Price\n amount={quote.prices?.grandTotal?.value}\n currency={quote.prices?.grandTotal?.currency}\n />\n </Slot>\n ),\n actions: (\n <Slot\n name=\"Actions\"\n slot={slots?.Actions}\n context={{ quote, onViewQuote }}\n >\n <Button\n variant=\"tertiary\"\n size=\"medium\"\n onClick={() =>\n onViewQuote?.(quote.uid, quote.name, quote.status)\n }\n >\n View\n </Button>\n </Slot>\n ),\n };\n });\n };\n\n // Prepare data for rendering\n const rowData = quotesData?.items\n ? prepareRowData(quotesData.items, slots, onViewQuote)\n : [];\n\n const paginationInfo = quotesData?.paginationInfo;\n const shouldShowPagination = !!paginationInfo;\n\n // Empty state message\n const emptyStateMessage = (\n <Slot name=\"EmptyQuotes\" slot={slots?.EmptyQuotes} context={{ quotesData }}>\n <IllustratedMessage heading=\"No Quotes Found\" />\n </Slot>\n );\n\n // Item range message\n const itemRangeMessage = paginationInfo ? (\n <Slot name=\"ItemRange\" slot={slots?.ItemRange} context={paginationInfo}>\n <span>\n Items {paginationInfo.startItem} to {paginationInfo.endItem} of{' '}\n {paginationInfo.totalCount} total\n </span>\n </Slot>\n ) : undefined;\n\n // Prepare page size picker message for component\n const pageSizePickerMessage =\n paginationInfo && paginationInfo.pageSizeOptions ? (\n <Slot\n name=\"PageSizePicker\"\n slot={slots?.PageSizePicker}\n context={{\n pageSize: paginationInfo.pageSize,\n pageSizeOptions: paginationInfo.pageSizeOptions,\n onPageSizeChange: handlePageSizeChange,\n }}\n >\n <span>Show </span>\n <Picker\n variant=\"primary\"\n size=\"medium\"\n value={String(paginationInfo.pageSize)}\n options={paginationInfo.pageSizeOptions.map(\n (size): PickerOption => ({\n value: String(size),\n text: String(size),\n })\n )}\n handleSelect={handlePageSizeSelect}\n />\n <span> per page</span>\n </Slot>\n ) : undefined;\n\n // Prepare pagination message for component\n const paginationMessage = paginationInfo ? (\n <Slot\n name=\"Pagination\"\n slot={slots?.Pagination}\n context={{\n currentPage: paginationInfo.currentPage,\n totalPages: paginationInfo.totalPages,\n onChange: handlePageChange,\n }}\n >\n <Pagination\n currentPage={paginationInfo.currentPage}\n totalPages={paginationInfo.totalPages}\n onChange={handlePageChange}\n />\n </Slot>\n ) : undefined;\n\n return (\n <QuotesListTableComponent\n rowData={rowData}\n loading={loading}\n className={props.className as string}\n emptyStateMessage={emptyStateMessage}\n showItemRange={showItemRange && shouldShowPagination}\n itemRangeMessage={itemRangeMessage}\n showPageSizePicker={showPageSizePicker && shouldShowPagination}\n pageSizePickerMessage={pageSizePickerMessage}\n showPagination={showPagination && shouldShowPagination}\n paginationMessage={paginationMessage}\n />\n );\n};\n"],"names":["QuotesListTable","rowData","loading","className","emptyStateMessage","showItemRange","itemRangeMessage","showPageSizePicker","pageSizePickerMessage","showPagination","paginationMessage","props","dictionary","useText","columns","shouldShowEmptyState","shouldShowItemRange","shouldShowPageSizePicker","shouldShowPagination","shouldShowFooter","jsxs","classes","jsx","Table","pageSize","onViewQuote","onPageSizeChange","onPageChange","slots","quotesData","setQuotesData","useState","setLoading","defaultPageSize","getDefaultPageSizeOptions","currentPageSize","setCurrentPageSize","currentPage","setCurrentPage","useEffect","fetchQuotes","data","negotiableQuotes","error","unsubscribe","events","isAuthenticated","handlePageSizeChange","newPageSize","handlePageChange","newPage","handlePageSizeSelect","event","target","value","prepareRowData","quotes","quote","createdByName","Slot","Price","_b","_a","_d","_c","Button","paginationInfo","IllustratedMessage","Picker","size","Pagination","QuotesListTableComponent"],"mappings":"w2BAgDO,MAAMA,GAA2D,CAAC,CACvE,QAAAC,EAAU,CAAA,EACV,QAAAC,EAAU,GACV,UAAAC,EACA,kBAAAC,EACA,cAAAC,EAAgB,GAChB,iBAAAC,EACA,mBAAAC,EAAqB,GACrB,sBAAAC,EACA,eAAAC,EAAiB,GACjB,kBAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAAaC,EAAQ,CACzB,UAAW,4CACX,QAAS,0CACT,UAAW,4CACX,OAAQ,yCACR,YAAa,8CACb,cAAe,gDACf,WAAY,6CACZ,QAAS,yCAAA,CACV,EAEKC,EAAoB,CACxB,CAAE,IAAK,YA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AK,SAAA,CAAA,SACG8C,EAAe,UAAU,OAAKA,EAAe,QAAQ,MAAI,IAC/DA,EAAe,WAAW,QAAA,CAAA,CAC7B,EACF,EACE,OAGE1D,EACJ0D,GAAkBA,EAAe,gBAC/B9C,EAACuC,EAAA,CACC,KAAK,iBACL,KAAM/B,GAAA,YAAAA,EAAO,eACb,QAAS,CACP,SAAUsC,EAAe,SACzB,gBAAiBA,EAAe,gBAChC,iBAAkBnB,CAAA,EAGpB,SAAA,CAAAzB,EAAC,QAAK,SAAA,OAAA,CAAK,EACXA,EAAC8C,EAAA,CACC,QAAQ,UACR,KAAK,SACL,MAAO,OAAOF,EAAe,QAAQ,EACrC,QAASA,EAAe,gBAAgB,IACrCG,IAAwB,CACvB,MAAO,OAAOA,CAAI,EAClB,KAAM,OAAOA,CAAI,CAAA,EACnB,EAEF,aAAclB,CAAA,CAAA,EAEhB7B,EAAC,QAAK,SAAA,WAAA,CAAS,CAAA,CAAA,CAAA,EAEf,OAGAZ,EAAoBwD,EACxB5C,EAACqC,EAAA,CACC,KAAK,aACL,KAAM/B,GAAA,YAAAA,EAAO,WACb,QAAS,CACP,YAAasC,EAAe,YAC5B,WAAYA,EAAe,WAC3B,SAAUjB,CAAA,EAGZ,SAAA3B,EAACgD,EAAA,CACC,YAAaJ,EAAe,YAC5B,WAAYA,EAAe,WAC3B,SAAUjB,CAAA,CAAA,CACZ,CAAA,EAEA,OAEJ,OACE3B,EAACiD,GAAA,CACC,QAAAtE,EACA,QAAAC,EACA,UAAWS,EAAM,UACjB,kBAAAP,EACA,cAAeC,GAAiBa,EAChC,iBAAAZ,EACA,mBAAoBC,GAAsBW,EAC1C,sBAAAV,EACA,eAAgBC,GAAkBS,EAClC,kBAAAR,CAAA,CAAA,CAGN"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as z,jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import*as v from"@dropins/tools/preact-compat.js";import{useState as g,useEffect as y,useCallback as re}from"@dropins/tools/preact-compat.js";import{classes as c,VComponent as q,Slot as h,getFormErrors as I,getFormValues as oe}from"@dropins/tools/lib.js";import{TextArea as ne,Field as ie,Input as se,InputFile as ce,Button as M,InLineAlert as me}from"@dropins/tools/components.js";/* empty css */import{events as T}from"@dropins/tools/event-bus.js";import"../chunks/state.js";import{u as ue,r as B}from"../chunks/uploadFile.js";import{S as de,a as le}from"../chunks/WarningFilled.js";import{useText as fe}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";const ge=u=>v.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...u},v.createElement("g",{id:"Large"},v.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),v.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},v.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),v.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),qe=({className:u,title:e,banner:_,commentField:C,quoteNameField:N,attachFile:i,requestButton:d,saveButton:Q,onSubmit:R,...A})=>z("form",{...A,className:c(["request-negotiable-quote-form",u]),onSubmit:R,children:[_&&a(q,{node:_,className:c(["request-negotiable-quote-form__banner"])}),e&&a(q,{node:e,className:c(["request-negotiable-quote-form__title"])}),C&&a(q,{node:C,className:c(["request-negotiable-quote-form__comment-field"])}),N&&a(q,{node:N,className:c(["request-negotiable-quote-form__quote-name-field"])}),i&&a(q,{node:i,className:c(["request-negotiable-quote-form__attach-file-field"])}),z("div",{className:c(["request-negotiable-quote-form__actions"]),children:[d&&a(q,{node:d,className:c(["request-negotiable-quote-form__request-button"])}),Q&&a(q,{node:Q,className:c(["request-negotiable-quote-form__save-button"])})]})]}),Ae=({cartId:u,slots:e,onRequestNegotiableQuote:_,onSaveNegotiableQuote:C,onAttachFiles:N,onSubmitErrors:i,onError:d,className:Q})=>{const[R,A]=g(void 0),[S,V]=g(void 0),[K,O]=g([]),[b,p]=g(void 0),[m,l]=g({}),[E,W]=g(void 0),[n,f]=g(!1),o=fe({title:"NegotiableQuote.Request.title",comment:"NegotiableQuote.Request.comment",commentError:"NegotiableQuote.Request.commentError",quoteName:"NegotiableQuote.Request.quoteName",quoteNameError:"NegotiableQuote.Request.quoteNameError",attachmentsError:"NegotiableQuote.Request.attachmentsError",requestCta:"NegotiableQuote.Request.requestCta",saveDraftCta:"NegotiableQuote.Request.saveDraftCta",errorHeader:"NegotiableQuote.Request.error.header",unauthenticated:"NegotiableQuote.Request.error.unauthenticated",unauthorized:"NegotiableQuote.Request.error.unauthorized",missingCart:"NegotiableQuote.Request.error.missingCart",successHeader:"NegotiableQuote.Request.success.header",submitSuccess:"NegotiableQuote.Request.success.submitted",draftSuccess:"NegotiableQuote.Request.success.draftSaved"});y(()=>{const t=T.on("quote-management/permissions",r=>{p(void 0),r.requestQuote||(p(o.unauthorized),f(!0))},{eager:!0});return()=>t==null?void 0:t.off()},[o.unauthorized]),y(()=>{const t=T.on("authenticated",r=>{p(void 0),r||(p(o.unauthenticated),f(!0))},{eager:!0});return()=>t==null?void 0:t.off()},[o.unauthenticated]),y(()=>{u||(p(o.missingCart),f(!0))},[u,o.missingCart]),y(()=>{b&&(d==null||d({error:b,isFormDisabled:n,setIsFormDisabled:f}))},[b,d,n]);const L=re(async t=>{if(t!=null&&t.length){if(l(r=>({...r,attachments:""})),N){try{await N(t)}catch{l(r=>({...r,attachments:o.attachmentsError}))}return}try{const r=await Promise.all(t.map(ue));O(r.map(({key:s})=>({key:s})))}catch{l(r=>({...r,attachments:o.attachmentsError}))}}},[N,o]),$=()=>{let t,r;if(E?(r={name:"SuccessBanner",slot:e==null?void 0:e.SuccessBanner,context:{message:E},"data-testid":"form-success-banner"},t={type:"success",variant:"primary",icon:a(de,{}),heading:o.successHeader,description:E,className:"request-negotiable-quote-form__success-banner"}):b&&(r={name:"ErrorBanner",slot:e==null?void 0:e.ErrorBanner,context:{message:b},"data-testid":"form-error-banner"},t={type:"error",variant:"primary",icon:a(le,{}),heading:o.errorHeader,description:b,className:"request-negotiable-quote-form__error-banner"}),r&&t)return a(h,{...r,children:a(me,{...t})})},H=t=>{l({});const r=t.target.closest("form"),s=I(r);Object.keys(s).length>0&&(l(s),i==null||i(s))},G=t=>{var j;t.preventDefault(),f(!0);const r=t.target,F={...I(r),...m};if(Object.keys(F).length>0){i==null||i(F);return}const k=t.submitter,x=oe(r);A(x.comment),V(x.quoteName);const P=((j=k==null?void 0:k.dataset)==null?void 0:j.draft)==="true"||!1,te={cartId:u,quoteName:x.quoteName,comment:x.comment,attachments:K,isDraft:P};let D,w;P?(D=C??B,w=o.draftSuccess):(D=_??B,w=o.submitSuccess),D(te).then(()=>{W(w)}).catch(ae=>{p(ae.message)})},J=a(h,{name:"Title",slot:e==null?void 0:e.Title,context:{text:o.title},children:a("span",{"data-testid":"form-title",children:o.title})}),U=a(h,{name:"CommentField",slot:e==null?void 0:e.CommentField,context:{value:R,required:!0,errorMessage:m.comment,setFormErrors:l,isFormDisabled:n},children:a(ne,{name:"comment",value:R,label:o.comment,required:!0,autoComplete:"off","data-testid":"form-comment-field",errorMessage:m.comment,disabled:n})}),X=a(h,{name:"QuoteNameField",slot:e==null?void 0:e.QuoteNameField,context:{value:S,required:!0,errorMessage:m.quoteName,setFormErrors:l,isFormDisabled:n},children:a(ie,{error:m.quoteName,disabled:n,children:a(se,{value:S,name:"quoteName",floatingLabel:o.quoteName,required:!0,autoComplete:"off","data-testid":"form-quote-name-field"})})}),Y=a(h,{name:"AttachFileField",slot:e==null?void 0:e.AttachFileField,context:{onChange:L,formErrors:m,isFormDisabled:n},children:a(ce,{onChange:t=>{const r=t.target,s=r==null?void 0:r.files,F=s?Array.from(s):[];F.length>0&&L(F)},icon:a(ge,{}),disabled:n,"data-testid":"form-attach-file-field"})}),Z=a(h,{name:"RequestButton",slot:e==null?void 0:e.RequestButton,context:{requestNegotiableQuote:B,formErrors:m,isFormDisabled:n,setIsFormDisabled:f},children:a(M,{type:"submit","data-testid":"form-request-button",onClick:H,disabled:n,children:o.requestCta})}),ee=a(h,{name:"SaveDraftButton",slot:e==null?void 0:e.SaveDraftButton,context:{requestNegotiableQuote:B,formErrors:m,isFormDisabled:n,setIsFormDisabled:f},children:a(M,{type:"submit","data-draft":"true",variant:"secondary","data-testid":"form-save-draft-button",onClick:H,disabled:n,children:o.saveDraftCta})});return a(qe,{title:J,banner:$(),commentField:U,quoteNameField:X,attachFile:Y,requestButton:Z,saveButton:ee,onSubmit:G,className:Q,disabled:n,"data-testid":"form-container"})};export{Ae as RequestNegotiableQuoteForm,Ae as default};
3
+ import{jsxs as z,jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import*as v from"@dropins/tools/preact-compat.js";import{useState as g,useEffect as y,useCallback as re}from"@dropins/tools/preact-compat.js";import{classes as c,VComponent as q,Slot as h,getFormErrors as I,getFormValues as oe}from"@dropins/tools/lib.js";import{TextArea as ne,Field as ie,Input as se,InputFile as ce,Button as M,InLineAlert as me}from"@dropins/tools/components.js";/* empty css */import{events as T}from"@dropins/tools/event-bus.js";import"../chunks/state.js";import{u as ue,r as B}from"../chunks/uploadFile.js";import{S as de,a as le}from"../chunks/WarningFilled.js";import{useText as fe}from"@dropins/tools/i18n.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";const ge=u=>v.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...u},v.createElement("g",{id:"Large"},v.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),v.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},v.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),v.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),qe=({className:u,title:e,banner:_,commentField:C,quoteNameField:N,attachFile:i,requestButton:d,saveButton:Q,onSubmit:R,...A})=>z("form",{...A,className:c(["request-negotiable-quote-form",u]),onSubmit:R,children:[_&&a(q,{node:_,className:c(["request-negotiable-quote-form__banner"])}),e&&a(q,{node:e,className:c(["request-negotiable-quote-form__title"])}),C&&a(q,{node:C,className:c(["request-negotiable-quote-form__comment-field"])}),N&&a(q,{node:N,className:c(["request-negotiable-quote-form__quote-name-field"])}),i&&a(q,{node:i,className:c(["request-negotiable-quote-form__attach-file-field"])}),z("div",{className:c(["request-negotiable-quote-form__actions"]),children:[d&&a(q,{node:d,className:c(["request-negotiable-quote-form__request-button"])}),Q&&a(q,{node:Q,className:c(["request-negotiable-quote-form__save-button"])})]})]}),Ae=({cartId:u,slots:e,onRequestNegotiableQuote:_,onSaveNegotiableQuote:C,onAttachFiles:N,onSubmitErrors:i,onError:d,className:Q})=>{const[R,A]=g(void 0),[S,V]=g(void 0),[K,O]=g([]),[b,p]=g(void 0),[m,l]=g({}),[E,W]=g(void 0),[n,f]=g(!1),o=fe({title:"NegotiableQuote.Request.title",comment:"NegotiableQuote.Request.comment",commentError:"NegotiableQuote.Request.commentError",quoteName:"NegotiableQuote.Request.quoteName",quoteNameError:"NegotiableQuote.Request.quoteNameError",attachmentsError:"NegotiableQuote.Request.attachmentsError",requestCta:"NegotiableQuote.Request.requestCta",saveDraftCta:"NegotiableQuote.Request.saveDraftCta",errorHeader:"NegotiableQuote.Request.error.header",unauthenticated:"NegotiableQuote.Request.error.unauthenticated",unauthorized:"NegotiableQuote.Request.error.unauthorized",missingCart:"NegotiableQuote.Request.error.missingCart",successHeader:"NegotiableQuote.Request.success.header",submitSuccess:"NegotiableQuote.Request.success.submitted",draftSuccess:"NegotiableQuote.Request.success.draftSaved"});y(()=>{const t=T.on("quote-management/permissions",r=>{p(void 0),r.requestQuote||(p(o.unauthorized),f(!0))},{eager:!0});return()=>t==null?void 0:t.off()},[o.unauthorized]),y(()=>{const t=T.on("authenticated",r=>{p(void 0),r||(p(o.unauthenticated),f(!0))},{eager:!0});return()=>t==null?void 0:t.off()},[o.unauthenticated]),y(()=>{u||(p(o.missingCart),f(!0))},[u,o.missingCart]),y(()=>{b&&(d==null||d({error:b,isFormDisabled:n,setIsFormDisabled:f}))},[b,d,n]);const L=re(async t=>{if(t!=null&&t.length){if(l(r=>({...r,attachments:""})),N){try{await N(t)}catch{l(r=>({...r,attachments:o.attachmentsError}))}return}try{const r=await Promise.all(t.map(ue));O(r.map(({key:s})=>({key:s})))}catch{l(r=>({...r,attachments:o.attachmentsError}))}}},[N,o]),$=()=>{let t,r;if(E?(r={name:"SuccessBanner",slot:e==null?void 0:e.SuccessBanner,context:{message:E},"data-testid":"form-success-banner"},t={type:"success",variant:"primary",icon:a(de,{}),heading:o.successHeader,description:E,className:"request-negotiable-quote-form__success-banner"}):b&&(r={name:"ErrorBanner",slot:e==null?void 0:e.ErrorBanner,context:{message:b},"data-testid":"form-error-banner"},t={type:"error",variant:"primary",icon:a(le,{}),heading:o.errorHeader,description:b,className:"request-negotiable-quote-form__error-banner"}),r&&t)return a(h,{...r,children:a(me,{...t})})},H=t=>{l({});const r=t.target.closest("form"),s=I(r);Object.keys(s).length>0&&(l(s),i==null||i(s))},G=t=>{var j;t.preventDefault(),f(!0);const r=t.target,F={...I(r),...m};if(Object.keys(F).length>0){i==null||i(F);return}const k=t.submitter,x=oe(r);A(x.comment),V(x.quoteName);const P=((j=k==null?void 0:k.dataset)==null?void 0:j.draft)==="true"||!1,te={cartId:u,quoteName:x.quoteName,comment:x.comment,attachments:K,isDraft:P};let D,w;P?(D=C??B,w=o.draftSuccess):(D=_??B,w=o.submitSuccess),D(te).then(()=>{W(w)}).catch(ae=>{p(ae.message)})},J=a(h,{name:"Title",slot:e==null?void 0:e.Title,context:{text:o.title},children:a("span",{"data-testid":"form-title",children:o.title})}),U=a(h,{name:"CommentField",slot:e==null?void 0:e.CommentField,context:{value:R,required:!0,errorMessage:m.comment,setFormErrors:l,isFormDisabled:n},children:a(ne,{name:"comment",value:R,label:o.comment,required:!0,autoComplete:"off","data-testid":"form-comment-field",errorMessage:m.comment,disabled:n})}),X=a(h,{name:"QuoteNameField",slot:e==null?void 0:e.QuoteNameField,context:{value:S,required:!0,errorMessage:m.quoteName,setFormErrors:l,isFormDisabled:n},children:a(ie,{error:m.quoteName,disabled:n,children:a(se,{value:S,name:"quoteName",floatingLabel:o.quoteName,required:!0,autoComplete:"off","data-testid":"form-quote-name-field"})})}),Y=a(h,{name:"AttachFileField",slot:e==null?void 0:e.AttachFileField,context:{onChange:L,formErrors:m,isFormDisabled:n},children:a(ce,{onChange:t=>{const r=t.target,s=r==null?void 0:r.files,F=s?Array.from(s):[];F.length>0&&L(F)},icon:a(ge,{}),disabled:n,"data-testid":"form-attach-file-field"})}),Z=a(h,{name:"RequestButton",slot:e==null?void 0:e.RequestButton,context:{requestNegotiableQuote:B,formErrors:m,isFormDisabled:n,setIsFormDisabled:f},children:a(M,{type:"submit","data-testid":"form-request-button",onClick:H,disabled:n,children:o.requestCta})}),ee=a(h,{name:"SaveDraftButton",slot:e==null?void 0:e.SaveDraftButton,context:{requestNegotiableQuote:B,formErrors:m,isFormDisabled:n,setIsFormDisabled:f},children:a(M,{type:"submit","data-draft":"true",variant:"secondary","data-testid":"form-save-draft-button",onClick:H,disabled:n,children:o.saveDraftCta})});return a(qe,{title:J,banner:$(),commentField:U,quoteNameField:X,attachFile:Y,requestButton:Z,saveButton:ee,onSubmit:G,className:Q,disabled:n,"data-testid":"form-container"})};export{Ae as RequestNegotiableQuoteForm,Ae as default};
4
4
  //# sourceMappingURL=RequestNegotiableQuoteForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RequestNegotiableQuoteForm.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Add.svg","/@dropins/storefront-quote-management/src/components/RequestNegotiableQuoteForm/RequestNegotiableQuoteForm.tsx","/@dropins/storefront-quote-management/src/containers/RequestNegotiableQuoteForm/RequestNegotiableQuoteForm.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgAdd = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Add_Base\", \"data-name\": \"Icon \\\\u2013 Add \\\\u2013 Base\", xmlns: \"http://www.w3.org/2000/svg\", width: 24, height: 24, viewBox: \"0 0 24 24\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { id: \"Large\" }, /* @__PURE__ */ React.createElement(\"rect\", { id: \"Placement_area\", \"data-name\": \"Placement area\", width: 24, height: 24, fill: \"#fff\", opacity: 0 }), /* @__PURE__ */ React.createElement(\"g\", { id: \"Add_icon\", \"data-name\": \"Add icon\", transform: \"translate(9.734 9.737)\" }, /* @__PURE__ */ React.createElement(\"line\", { vectorEffect: \"non-scaling-stroke\", id: \"Line_579\", \"data-name\": \"Line 579\", y2: 12.7, transform: \"translate(2.216 -4.087)\", fill: \"none\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"line\", { vectorEffect: \"non-scaling-stroke\", id: \"Line_580\", \"data-name\": \"Line 580\", x2: 12.7, transform: \"translate(-4.079 2.263)\", fill: \"none\", stroke: \"currentColor\" }))));\nexport default SvgAdd;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/quote-management/components/RequestNegotiableQuoteForm/RequestNegotiableQuoteForm.css';\n\nexport interface RequestNegotiableQuoteFormProps extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n title: VNode;\n banner?: VNode;\n commentField?: VNode;\n quoteNameField?: VNode;\n attachFile?: VNode;\n requestButton?: VNode;\n saveButton?: VNode;\n onSubmit: (e: Event) => void;\n}\n\nexport const RequestNegotiableQuoteForm: FunctionComponent<RequestNegotiableQuoteFormProps> = ({\n className,\n title,\n banner,\n commentField,\n quoteNameField,\n attachFile,\n requestButton,\n saveButton,\n onSubmit,\n ...props\n}) => {\n return (\n <form {...props} className={classes(['request-negotiable-quote-form', className])} onSubmit={onSubmit}>\n {banner &&\n <VComponent\n node={banner}\n className={classes(['request-negotiable-quote-form__banner'])}\n />\n }\n {title &&\n <VComponent\n node={title}\n className={classes(['request-negotiable-quote-form__title'])}\n />\n }\n {commentField &&\n <VComponent\n node={commentField}\n className={classes(['request-negotiable-quote-form__comment-field'])}\n />\n }\n {quoteNameField &&\n <VComponent\n node={quoteNameField}\n className={classes(['request-negotiable-quote-form__quote-name-field'])}\n />\n }\n {attachFile &&\n <VComponent\n node={attachFile}\n className={classes(['request-negotiable-quote-form__attach-file-field'])}\n />\n }\n <div className={classes(['request-negotiable-quote-form__actions'])}>\n {requestButton &&\n <VComponent\n node={requestButton}\n className={classes(['request-negotiable-quote-form__request-button'])}\n />\n }\n {saveButton &&\n <VComponent\n node={saveButton}\n className={classes(['request-negotiable-quote-form__save-button'])}\n />\n }\n </div>\n </form>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { HTMLAttributes, useCallback, useEffect, useState } from 'preact/compat';\nimport { Container, getFormErrors, getFormValues, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { InLineAlert, Button, InputFile, TextArea, Input, Field, InLineAlertProps } from '@adobe-commerce/elsie/components';\nimport { WarningFilled, CheckWithCircle, Add } from '@adobe-commerce/elsie/icons';\nimport RequestNegotiableQuoteFormComponent from '@/quote-management/components/RequestNegotiableQuoteForm';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { requestNegotiableQuote, RequestNegotiableQuoteInput, uploadFile } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\n\nexport type RequestNegotiableQuoteHandlers = {\n onAttachFiles?: (files: File[]) => Promise<void>;\n onRequestNegotiableQuote?: typeof requestNegotiableQuote;\n onSaveNegotiableQuote?: typeof requestNegotiableQuote;\n onSubmitErrors?: (errors: Record<string, string>) => void;\n onError?: (props: {\n error: string,\n isFormDisabled: boolean,\n setIsFormDisabled: (isFormDisabled: boolean) => void,\n }) => void;\n};\n\nexport interface RequestNegotiableQuoteFormProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onError'>,\n RequestNegotiableQuoteHandlers {\n cartId: string;\n slots?: {\n ErrorBanner?: SlotProps<{\n message: string,\n }>;\n SuccessBanner?: SlotProps<{\n message: string,\n }>;\n Title?: SlotProps<{\n text: string,\n }>;\n CommentField?: SlotProps<{\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setFormErrors: (errors: Record<string, string>) => void;\n }>;\n QuoteNameField?: SlotProps<{\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setFormErrors: (errors: Record<string, string>) => void;\n }>;\n AttachFileField?: SlotProps<{\n onChange: (files: File[]) => void, formErrors: Record<string, string>,\n isFormDisabled: boolean\n }>;\n RequestButton?: SlotProps<{\n requestNegotiableQuote: typeof requestNegotiableQuote;\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setIsFormDisabled: (isFormDisabled: boolean) => void;\n }>;\n SaveDraftButton?: SlotProps<{\n requestNegotiableQuote: typeof requestNegotiableQuote;\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setIsFormDisabled: (isFormDisabled: boolean) => void;\n }>;\n };\n}\n\nexport const RequestNegotiableQuoteForm: Container<RequestNegotiableQuoteFormProps> = ({\n cartId,\n slots,\n onRequestNegotiableQuote,\n onSaveNegotiableQuote,\n onAttachFiles,\n onSubmitErrors,\n onError,\n className,\n}) => {\n const [comment, setComment] = useState<string | undefined>(undefined);\n const [quoteName, setQuoteName] = useState<string | undefined>(undefined);\n const [attachmentKeys, setAttachmentKeys] = useState<{ key: string }[]>([]);\n const [error, setError] = useState<string | undefined>(undefined);\n const [formErrors, setFormErrors] = useState<Record<string, string>>({});\n const [success, setSuccess] = useState<string | undefined>(undefined);\n const [isFormDisabled, setIsFormDisabled] = useState<boolean>(false);\n\n const dictionary = useText({\n title: 'NegotiableQuote.Request.title',\n comment: 'NegotiableQuote.Request.comment',\n commentError: 'NegotiableQuote.Request.commentError',\n quoteName: 'NegotiableQuote.Request.quoteName',\n quoteNameError: 'NegotiableQuote.Request.quoteNameError',\n attachmentsError: 'NegotiableQuote.Request.attachmentsError',\n requestCta: 'NegotiableQuote.Request.requestCta',\n saveDraftCta: 'NegotiableQuote.Request.saveDraftCta',\n errorHeader: 'NegotiableQuote.Request.error.header',\n unauthenticated: 'NegotiableQuote.Request.error.unauthenticated',\n unauthorized: 'NegotiableQuote.Request.error.unauthorized',\n missingCart: 'NegotiableQuote.Request.error.missingCart',\n successHeader: 'NegotiableQuote.Request.success.header',\n submitSuccess: 'NegotiableQuote.Request.success.submitted',\n draftSuccess: 'NegotiableQuote.Request.success.draftSaved',\n });\n\n useEffect(() => {\n const permissionsEvent = events.on(\n 'quote-management/permissions',\n (permissions: typeof state.permissions) => {\n setError(undefined);\n if (!permissions.requestQuote) {\n setError(dictionary.unauthorized);\n setIsFormDisabled(true);\n }\n },\n { eager: true }\n );\n return () => permissionsEvent?.off();\n }, [dictionary.unauthorized]);\n\n useEffect(() => {\n const authenticatedEvent = events.on(\n 'authenticated',\n (authenticated: boolean) => {\n setError(undefined);\n if (!authenticated) {\n setError(dictionary.unauthenticated);\n setIsFormDisabled(true);\n }\n },\n { eager: true }\n );\n return () => authenticatedEvent?.off();\n }, [dictionary.unauthenticated]);\n\n useEffect(() => {\n if (!cartId) {\n setError(dictionary.missingCart);\n setIsFormDisabled(true);\n }\n }, [cartId, dictionary.missingCart]);\n\n useEffect(() => {\n if (error) {\n onError?.({ error, isFormDisabled, setIsFormDisabled });\n }\n }, [error, onError, isFormDisabled]);\n\n const handleAttachFiles = useCallback(async (files: File[]) => {\n /* istanbul ignore next: defensive guard; */\n if (!files?.length) return;\n\n setFormErrors(prev => ({ ...prev, attachments: '' }));\n\n if (onAttachFiles) {\n try {\n await onAttachFiles(files);\n } catch {\n setFormErrors(prev => ({ ...prev, attachments: dictionary.attachmentsError }));\n }\n return;\n }\n\n try {\n const uploaded = await Promise.all(files.map(uploadFile));\n setAttachmentKeys(uploaded.map(({ key }) => ({ key })));\n } catch {\n setFormErrors(prev => ({ ...prev, attachments: dictionary.attachmentsError }));\n }\n }, [onAttachFiles, dictionary]);\n\n /*\n * This function is used to get the banner node.\n * It can be used to render a success or error banner depending on the success or error state.\n */\n const getBannerNode = () => {\n let inlineAlertProps: InLineAlertProps | undefined;\n let slotProps: any | undefined;\n\n if (success) {\n slotProps = {\n name: 'SuccessBanner',\n slot: slots?.SuccessBanner,\n context: {\n message: success,\n },\n 'data-testid': 'form-success-banner',\n };\n inlineAlertProps = {\n type: 'success',\n variant: 'primary',\n icon: <CheckWithCircle />,\n heading: dictionary.successHeader,\n description: success,\n className: 'request-negotiable-quote-form__success-banner',\n };\n }\n else if (error) {\n slotProps = {\n name: 'ErrorBanner',\n slot: slots?.ErrorBanner,\n context: {\n message: error,\n },\n 'data-testid': 'form-error-banner',\n };\n inlineAlertProps = {\n type: 'error',\n variant: 'primary',\n icon: <WarningFilled />,\n heading: dictionary.errorHeader,\n description: error,\n className: 'request-negotiable-quote-form__error-banner',\n };\n }\n\n if (slotProps && inlineAlertProps) {\n return <Slot {...slotProps}>\n <InLineAlert {...inlineAlertProps} />\n </Slot>;\n }\n\n return undefined;\n }\n\n /*\n * This function is used to validate the parent form of the button that was clicked.\n */\n const validateParentForm = (e: Event) => {\n setFormErrors({});\n const closestForm = (e.target as HTMLElement).closest('form') as HTMLFormElement;\n const formErrors = getFormErrors(closestForm);\n if (Object.keys(formErrors).length > 0) {\n setFormErrors(formErrors);\n onSubmitErrors?.(formErrors);\n }\n };\n\n const formSubmitHandler = (e: Event) => {\n e.preventDefault();\n setIsFormDisabled(true);\n\n const form = (e.target as HTMLFormElement);\n\n const currentFormErrors = getFormErrors(form);\n\n const mergedFormErrors = { ...currentFormErrors, ...formErrors };\n\n if (Object.keys(mergedFormErrors).length > 0) {\n onSubmitErrors?.(mergedFormErrors)\n return;\n }\n\n // Since we have multiple submit buttons, we need to determine which one was clicked.\n const buttonTarget = (e as SubmitEvent).submitter as HTMLButtonElement;\n\n const formValues = getFormValues(form);\n\n setComment(formValues.comment);\n setQuoteName(formValues.quoteName);\n\n const isDraft = buttonTarget?.dataset?.draft === 'true' || false;\n\n const contextData: RequestNegotiableQuoteInput = {\n cartId: cartId!,\n quoteName: formValues.quoteName,\n comment: formValues.comment,\n attachments: attachmentKeys,\n isDraft,\n }\n\n let submitHandler;\n let successMessage;\n\n if (isDraft) {\n submitHandler = onSaveNegotiableQuote ?? requestNegotiableQuote;\n successMessage = dictionary.draftSuccess;\n } else {\n submitHandler = onRequestNegotiableQuote ?? requestNegotiableQuote;\n successMessage = dictionary.submitSuccess;\n }\n\n submitHandler(contextData).then(() => {\n setSuccess(successMessage);\n })\n .catch(error => {\n setError(error.message);\n })\n };\n\n const titleNode = (\n <Slot name=\"Title\" slot={slots?.Title} context={{ text: dictionary.title }}>\n <span data-testid=\"form-title\">{dictionary.title}</span>\n </Slot>\n );\n\n const commentFieldNode = (\n <Slot\n name=\"CommentField\"\n slot={slots?.CommentField}\n context={{\n value: comment,\n required: true,\n errorMessage: formErrors.comment,\n setFormErrors,\n isFormDisabled\n } as any}\n >\n <TextArea\n name=\"comment\"\n value={comment}\n label={dictionary.comment}\n required\n autoComplete=\"off\"\n data-testid=\"form-comment-field\"\n errorMessage={formErrors.comment}\n disabled={isFormDisabled}\n />\n </Slot>\n );\n\n const quoteNameFieldNode = (\n <Slot\n name=\"QuoteNameField\"\n slot={slots?.QuoteNameField}\n context={{\n value: quoteName,\n required: true,\n errorMessage: formErrors.quoteName,\n setFormErrors,\n isFormDisabled\n } as any}\n >\n <Field\n error={formErrors.quoteName}\n disabled={isFormDisabled}\n >\n <Input\n value={quoteName}\n name=\"quoteName\"\n floatingLabel={dictionary.quoteName}\n required\n autoComplete=\"off\"\n data-testid=\"form-quote-name-field\"\n />\n </Field>\n </Slot>\n );\n\n const attachFileNode = (\n <Slot\n name=\"AttachFileField\"\n slot={slots?.AttachFileField}\n context={{ onChange: handleAttachFiles, formErrors, isFormDisabled }}\n >\n <InputFile\n onChange={(e: Event) => {\n const target = e.target as HTMLInputElement;\n const fileList = target?.files;\n const files = fileList ? Array.from(fileList) : [];\n\n if (files.length > 0) {\n void handleAttachFiles(files);\n }\n }}\n icon={<Add />}\n disabled={isFormDisabled}\n data-testid=\"form-attach-file-field\"\n />\n </Slot>\n );\n\n const requestButtonNode = (\n <Slot\n name=\"RequestButton\"\n slot={slots?.RequestButton}\n context={\n {\n requestNegotiableQuote,\n formErrors,\n isFormDisabled,\n setIsFormDisabled\n }\n }\n >\n <Button\n type=\"submit\"\n data-testid=\"form-request-button\"\n onClick={validateParentForm}\n disabled={isFormDisabled}\n >\n {dictionary.requestCta}\n </Button>\n </Slot>\n );\n\n const saveButtonNode = (\n <Slot\n name=\"SaveDraftButton\"\n slot={slots?.SaveDraftButton}\n context={\n {\n requestNegotiableQuote,\n formErrors,\n isFormDisabled,\n setIsFormDisabled\n }\n }\n >\n <Button\n type=\"submit\"\n data-draft=\"true\"\n variant=\"secondary\"\n data-testid=\"form-save-draft-button\"\n onClick={validateParentForm}\n disabled={isFormDisabled}\n >\n {dictionary.saveDraftCta}\n </Button>\n </Slot>\n );\n\n return (\n <RequestNegotiableQuoteFormComponent\n title={titleNode}\n banner={getBannerNode()}\n commentField={commentFieldNode}\n quoteNameField={quoteNameFieldNode}\n attachFile={attachFileNode}\n requestButton={requestButtonNode}\n saveButton={saveButtonNode}\n onSubmit={formSubmitHandler}\n className={className}\n disabled={isFormDisabled}\n data-testid=\"form-container\"\n />\n );\n};\n"],"names":["SvgAdd","props","React","RequestNegotiableQuoteForm","className","title","banner","commentField","quoteNameField","attachFile","requestButton","saveButton","onSubmit","jsxs","classes","jsx","VComponent","cartId","slots","onRequestNegotiableQuote","onSaveNegotiableQuote","onAttachFiles","onSubmitErrors","onError","comment","setComment","useState","quoteName","setQuoteName","attachmentKeys","setAttachmentKeys","error","setError","formErrors","setFormErrors","success","setSuccess","isFormDisabled","setIsFormDisabled","dictionary","useText","useEffect","permissionsEvent","events","permissions","authenticatedEvent","authenticated","handleAttachFiles","useCallback","files","prev","uploaded","uploadFile","key","getBannerNode","inlineAlertProps","slotProps","CheckWithCircle","WarningFilled","Slot","InLineAlert","validateParentForm","e","closestForm","getFormErrors","formSubmitHandler","form","mergedFormErrors","buttonTarget","formValues","getFormValues","isDraft","_a","contextData","submitHandler","successMessage","requestNegotiableQuote","titleNode","commentFieldNode","TextArea","quoteNameFieldNode","Field","Input","attachFileNode","InputFile","target","fileList","Add","requestButtonNode","Button","saveButtonNode","RequestNegotiableQuoteFormComponent"],"mappings":"y1BACA,MAAMA,GAAUC,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,gBAAiB,YAAa,gCAAiC,MAAO,6BAA8B,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,GAAGD,GAAyBC,EAAM,cAAc,IAAK,CAAE,GAAI,OAAO,EAAoBA,EAAM,cAAc,OAAQ,CAAE,GAAI,iBAAkB,YAAa,iBAAkB,MAAO,GAAI,OAAQ,GAAI,KAAM,OAAQ,QAAS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,KAAKA,CAAQ,EAAI,CAAA,EAE5CrC,EAAM,OAAS,GACZF,EAAkBE,CAAK,CAEhC,EACA,OAAOsC,GAAA,EAAI,EACX,SAAUlD,EACV,cAAY,wBAAA,CAAA,CACd,CAAA,EAIEmD,EACJzE,EAAC4C,EAAA,CACC,KAAK,gBACL,KAAMzC,GAAA,YAAAA,EAAO,cACb,QACE,CACE,uBAAA0D,EACA,WAAA3C,EACA,eAAAI,EACA,kBAAAC,CAAA,EAIJ,SAAAvB,EAAC0E,EAAA,CACC,KAAK,SACL,cAAY,sBACZ,QAAS5B,EACT,SAAUxB,EAET,SAAAE,EAAW,UAAA,CAAA,CACd,CAAA,EAIEmD,GACJ3E,EAAC4C,EAAA,CACC,KAAK,kBACL,KAAMzC,GAAA,YAAAA,EAAO,gBACb,QACE,CACE,uBAAA0D,EACA,WAAA3C,EACA,eAAAI,EACA,kBAAAC,CAAA,EAIJ,SAAAvB,EAAC0E,EAAA,CACC,KAAK,SACL,aAAW,OACX,QAAQ,YACR,cAAY,yBACZ,QAAS5B,EACT,SAAUxB,EAET,SAAAE,EAAW,YAAA,CAAA,CACd,CAAA,EAIJ,OACExB,EAAC4E,GAAA,CACC,MAAOd,EACP,OAAQvB,EAAA,EACR,aAAcwB,EACd,eAAgBE,EAChB,WAAYG,EACZ,cAAeK,EACf,WAAYE,GACZ,SAAUzB,EACV,UAAA7D,EACA,SAAUiC,EACV,cAAY,gBAAA,CAAA,CAGlB","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"RequestNegotiableQuoteForm.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Add.svg","/@dropins/storefront-quote-management/src/components/RequestNegotiableQuoteForm/RequestNegotiableQuoteForm.tsx","/@dropins/storefront-quote-management/src/containers/RequestNegotiableQuoteForm/RequestNegotiableQuoteForm.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgAdd = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Add_Base\", \"data-name\": \"Icon \\\\u2013 Add \\\\u2013 Base\", xmlns: \"http://www.w3.org/2000/svg\", width: 24, height: 24, viewBox: \"0 0 24 24\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { id: \"Large\" }, /* @__PURE__ */ React.createElement(\"rect\", { id: \"Placement_area\", \"data-name\": \"Placement area\", width: 24, height: 24, fill: \"#fff\", opacity: 0 }), /* @__PURE__ */ React.createElement(\"g\", { id: \"Add_icon\", \"data-name\": \"Add icon\", transform: \"translate(9.734 9.737)\" }, /* @__PURE__ */ React.createElement(\"line\", { vectorEffect: \"non-scaling-stroke\", id: \"Line_579\", \"data-name\": \"Line 579\", y2: 12.7, transform: \"translate(2.216 -4.087)\", fill: \"none\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"line\", { vectorEffect: \"non-scaling-stroke\", id: \"Line_580\", \"data-name\": \"Line 580\", x2: 12.7, transform: \"translate(-4.079 2.263)\", fill: \"none\", stroke: \"currentColor\" }))));\nexport default SvgAdd;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/quote-management/components/RequestNegotiableQuoteForm/RequestNegotiableQuoteForm.css';\n\nexport interface RequestNegotiableQuoteFormProps extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n title: VNode;\n banner?: VNode;\n commentField?: VNode;\n quoteNameField?: VNode;\n attachFile?: VNode;\n requestButton?: VNode;\n saveButton?: VNode;\n onSubmit: (e: Event) => void;\n}\n\nexport const RequestNegotiableQuoteForm: FunctionComponent<RequestNegotiableQuoteFormProps> = ({\n className,\n title,\n banner,\n commentField,\n quoteNameField,\n attachFile,\n requestButton,\n saveButton,\n onSubmit,\n ...props\n}) => {\n return (\n <form {...props} className={classes(['request-negotiable-quote-form', className])} onSubmit={onSubmit}>\n {banner &&\n <VComponent\n node={banner}\n className={classes(['request-negotiable-quote-form__banner'])}\n />\n }\n {title &&\n <VComponent\n node={title}\n className={classes(['request-negotiable-quote-form__title'])}\n />\n }\n {commentField &&\n <VComponent\n node={commentField}\n className={classes(['request-negotiable-quote-form__comment-field'])}\n />\n }\n {quoteNameField &&\n <VComponent\n node={quoteNameField}\n className={classes(['request-negotiable-quote-form__quote-name-field'])}\n />\n }\n {attachFile &&\n <VComponent\n node={attachFile}\n className={classes(['request-negotiable-quote-form__attach-file-field'])}\n />\n }\n <div className={classes(['request-negotiable-quote-form__actions'])}>\n {requestButton &&\n <VComponent\n node={requestButton}\n className={classes(['request-negotiable-quote-form__request-button'])}\n />\n }\n {saveButton &&\n <VComponent\n node={saveButton}\n className={classes(['request-negotiable-quote-form__save-button'])}\n />\n }\n </div>\n </form>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { HTMLAttributes, useCallback, useEffect, useState } from 'preact/compat';\nimport { Container, getFormErrors, getFormValues, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { InLineAlert, Button, InputFile, TextArea, Input, Field, InLineAlertProps } from '@adobe-commerce/elsie/components';\nimport { WarningFilled, CheckWithCircle, Add } from '@adobe-commerce/elsie/icons';\nimport RequestNegotiableQuoteFormComponent from '@/quote-management/components/RequestNegotiableQuoteForm';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { requestNegotiableQuote, RequestNegotiableQuoteInput, uploadFile } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\n\nexport type RequestNegotiableQuoteHandlers = {\n onAttachFiles?: (files: File[]) => Promise<void>;\n onRequestNegotiableQuote?: typeof requestNegotiableQuote;\n onSaveNegotiableQuote?: typeof requestNegotiableQuote;\n onSubmitErrors?: (errors: Record<string, string>) => void;\n onError?: (props: {\n error: string,\n isFormDisabled: boolean,\n setIsFormDisabled: (isFormDisabled: boolean) => void,\n }) => void;\n};\n\nexport interface RequestNegotiableQuoteFormProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onError'>,\n RequestNegotiableQuoteHandlers {\n cartId: string;\n slots?: {\n ErrorBanner?: SlotProps<{\n message: string,\n }>;\n SuccessBanner?: SlotProps<{\n message: string,\n }>;\n Title?: SlotProps<{\n text: string,\n }>;\n CommentField?: SlotProps<{\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setFormErrors: (errors: Record<string, string>) => void;\n }>;\n QuoteNameField?: SlotProps<{\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setFormErrors: (errors: Record<string, string>) => void;\n }>;\n AttachFileField?: SlotProps<{\n onChange: (files: File[]) => void, formErrors: Record<string, string>,\n isFormDisabled: boolean\n }>;\n RequestButton?: SlotProps<{\n requestNegotiableQuote: typeof requestNegotiableQuote;\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setIsFormDisabled: (isFormDisabled: boolean) => void;\n }>;\n SaveDraftButton?: SlotProps<{\n requestNegotiableQuote: typeof requestNegotiableQuote;\n formErrors: Record<string, string>;\n isFormDisabled: boolean;\n setIsFormDisabled: (isFormDisabled: boolean) => void;\n }>;\n };\n}\n\nexport const RequestNegotiableQuoteForm: Container<RequestNegotiableQuoteFormProps> = ({\n cartId,\n slots,\n onRequestNegotiableQuote,\n onSaveNegotiableQuote,\n onAttachFiles,\n onSubmitErrors,\n onError,\n className,\n}) => {\n const [comment, setComment] = useState<string | undefined>(undefined);\n const [quoteName, setQuoteName] = useState<string | undefined>(undefined);\n const [attachmentKeys, setAttachmentKeys] = useState<{ key: string }[]>([]);\n const [error, setError] = useState<string | undefined>(undefined);\n const [formErrors, setFormErrors] = useState<Record<string, string>>({});\n const [success, setSuccess] = useState<string | undefined>(undefined);\n const [isFormDisabled, setIsFormDisabled] = useState<boolean>(false);\n\n const dictionary = useText({\n title: 'NegotiableQuote.Request.title',\n comment: 'NegotiableQuote.Request.comment',\n commentError: 'NegotiableQuote.Request.commentError',\n quoteName: 'NegotiableQuote.Request.quoteName',\n quoteNameError: 'NegotiableQuote.Request.quoteNameError',\n attachmentsError: 'NegotiableQuote.Request.attachmentsError',\n requestCta: 'NegotiableQuote.Request.requestCta',\n saveDraftCta: 'NegotiableQuote.Request.saveDraftCta',\n errorHeader: 'NegotiableQuote.Request.error.header',\n unauthenticated: 'NegotiableQuote.Request.error.unauthenticated',\n unauthorized: 'NegotiableQuote.Request.error.unauthorized',\n missingCart: 'NegotiableQuote.Request.error.missingCart',\n successHeader: 'NegotiableQuote.Request.success.header',\n submitSuccess: 'NegotiableQuote.Request.success.submitted',\n draftSuccess: 'NegotiableQuote.Request.success.draftSaved',\n });\n\n useEffect(() => {\n const permissionsEvent = events.on(\n 'quote-management/permissions',\n (permissions: typeof state.permissions) => {\n setError(undefined);\n if (!permissions.requestQuote) {\n setError(dictionary.unauthorized);\n setIsFormDisabled(true);\n }\n },\n { eager: true }\n );\n return () => permissionsEvent?.off();\n }, [dictionary.unauthorized]);\n\n useEffect(() => {\n const authenticatedEvent = events.on(\n 'authenticated',\n (authenticated: boolean) => {\n setError(undefined);\n if (!authenticated) {\n setError(dictionary.unauthenticated);\n setIsFormDisabled(true);\n }\n },\n { eager: true }\n );\n return () => authenticatedEvent?.off();\n }, [dictionary.unauthenticated]);\n\n useEffect(() => {\n if (!cartId) {\n setError(dictionary.missingCart);\n setIsFormDisabled(true);\n }\n }, [cartId, dictionary.missingCart]);\n\n useEffect(() => {\n if (error) {\n onError?.({ error, isFormDisabled, setIsFormDisabled });\n }\n }, [error, onError, isFormDisabled]);\n\n const handleAttachFiles = useCallback(async (files: File[]) => {\n /* istanbul ignore next: defensive guard; */\n if (!files?.length) return;\n\n setFormErrors(prev => ({ ...prev, attachments: '' }));\n\n if (onAttachFiles) {\n try {\n await onAttachFiles(files);\n } catch {\n setFormErrors(prev => ({ ...prev, attachments: dictionary.attachmentsError }));\n }\n return;\n }\n\n try {\n const uploaded = await Promise.all(files.map(uploadFile));\n setAttachmentKeys(uploaded.map(({ key }) => ({ key })));\n } catch {\n setFormErrors(prev => ({ ...prev, attachments: dictionary.attachmentsError }));\n }\n }, [onAttachFiles, dictionary]);\n\n /*\n * This function is used to get the banner node.\n * It can be used to render a success or error banner depending on the success or error state.\n */\n const getBannerNode = () => {\n let inlineAlertProps: InLineAlertProps | undefined;\n let slotProps: any | undefined;\n\n if (success) {\n slotProps = {\n name: 'SuccessBanner',\n slot: slots?.SuccessBanner,\n context: {\n message: success,\n },\n 'data-testid': 'form-success-banner',\n };\n inlineAlertProps = {\n type: 'success',\n variant: 'primary',\n icon: <CheckWithCircle />,\n heading: dictionary.successHeader,\n description: success,\n className: 'request-negotiable-quote-form__success-banner',\n };\n }\n else if (error) {\n slotProps = {\n name: 'ErrorBanner',\n slot: slots?.ErrorBanner,\n context: {\n message: error,\n },\n 'data-testid': 'form-error-banner',\n };\n inlineAlertProps = {\n type: 'error',\n variant: 'primary',\n icon: <WarningFilled />,\n heading: dictionary.errorHeader,\n description: error,\n className: 'request-negotiable-quote-form__error-banner',\n };\n }\n\n if (slotProps && inlineAlertProps) {\n return <Slot {...slotProps}>\n <InLineAlert {...inlineAlertProps} />\n </Slot>;\n }\n\n return undefined;\n }\n\n /*\n * This function is used to validate the parent form of the button that was clicked.\n */\n const validateParentForm = (e: Event) => {\n setFormErrors({});\n const closestForm = (e.target as HTMLElement).closest('form') as HTMLFormElement;\n const formErrors = getFormErrors(closestForm);\n if (Object.keys(formErrors).length > 0) {\n setFormErrors(formErrors);\n onSubmitErrors?.(formErrors);\n }\n };\n\n const formSubmitHandler = (e: Event) => {\n e.preventDefault();\n setIsFormDisabled(true);\n\n const form = (e.target as HTMLFormElement);\n\n const currentFormErrors = getFormErrors(form);\n\n const mergedFormErrors = { ...currentFormErrors, ...formErrors };\n\n if (Object.keys(mergedFormErrors).length > 0) {\n onSubmitErrors?.(mergedFormErrors)\n return;\n }\n\n // Since we have multiple submit buttons, we need to determine which one was clicked.\n const buttonTarget = (e as SubmitEvent).submitter as HTMLButtonElement;\n\n const formValues = getFormValues(form);\n\n setComment(formValues.comment);\n setQuoteName(formValues.quoteName);\n\n const isDraft = buttonTarget?.dataset?.draft === 'true' || false;\n\n const contextData: RequestNegotiableQuoteInput = {\n cartId: cartId!,\n quoteName: formValues.quoteName,\n comment: formValues.comment,\n attachments: attachmentKeys,\n isDraft,\n }\n\n let submitHandler;\n let successMessage;\n\n if (isDraft) {\n submitHandler = onSaveNegotiableQuote ?? requestNegotiableQuote;\n successMessage = dictionary.draftSuccess;\n } else {\n submitHandler = onRequestNegotiableQuote ?? requestNegotiableQuote;\n successMessage = dictionary.submitSuccess;\n }\n\n submitHandler(contextData).then(() => {\n setSuccess(successMessage);\n })\n .catch(error => {\n setError(error.message);\n })\n };\n\n const titleNode = (\n <Slot name=\"Title\" slot={slots?.Title} context={{ text: dictionary.title }}>\n <span data-testid=\"form-title\">{dictionary.title}</span>\n </Slot>\n );\n\n const commentFieldNode = (\n <Slot\n name=\"CommentField\"\n slot={slots?.CommentField}\n context={{\n value: comment,\n required: true,\n errorMessage: formErrors.comment,\n setFormErrors,\n isFormDisabled\n } as any}\n >\n <TextArea\n name=\"comment\"\n value={comment}\n label={dictionary.comment}\n required\n autoComplete=\"off\"\n data-testid=\"form-comment-field\"\n errorMessage={formErrors.comment}\n disabled={isFormDisabled}\n />\n </Slot>\n );\n\n const quoteNameFieldNode = (\n <Slot\n name=\"QuoteNameField\"\n slot={slots?.QuoteNameField}\n context={{\n value: quoteName,\n required: true,\n errorMessage: formErrors.quoteName,\n setFormErrors,\n isFormDisabled\n } as any}\n >\n <Field\n error={formErrors.quoteName}\n disabled={isFormDisabled}\n >\n <Input\n value={quoteName}\n name=\"quoteName\"\n floatingLabel={dictionary.quoteName}\n required\n autoComplete=\"off\"\n data-testid=\"form-quote-name-field\"\n />\n </Field>\n </Slot>\n );\n\n const attachFileNode = (\n <Slot\n name=\"AttachFileField\"\n slot={slots?.AttachFileField}\n context={{ onChange: handleAttachFiles, formErrors, isFormDisabled }}\n >\n <InputFile\n onChange={(e: Event) => {\n const target = e.target as HTMLInputElement;\n const fileList = target?.files;\n const files = fileList ? Array.from(fileList) : [];\n\n if (files.length > 0) {\n void handleAttachFiles(files);\n }\n }}\n icon={<Add />}\n disabled={isFormDisabled}\n data-testid=\"form-attach-file-field\"\n />\n </Slot>\n );\n\n const requestButtonNode = (\n <Slot\n name=\"RequestButton\"\n slot={slots?.RequestButton}\n context={\n {\n requestNegotiableQuote,\n formErrors,\n isFormDisabled,\n setIsFormDisabled\n }\n }\n >\n <Button\n type=\"submit\"\n data-testid=\"form-request-button\"\n onClick={validateParentForm}\n disabled={isFormDisabled}\n >\n {dictionary.requestCta}\n </Button>\n </Slot>\n );\n\n const saveButtonNode = (\n <Slot\n name=\"SaveDraftButton\"\n slot={slots?.SaveDraftButton}\n context={\n {\n requestNegotiableQuote,\n formErrors,\n isFormDisabled,\n setIsFormDisabled\n }\n }\n >\n <Button\n type=\"submit\"\n data-draft=\"true\"\n variant=\"secondary\"\n data-testid=\"form-save-draft-button\"\n onClick={validateParentForm}\n disabled={isFormDisabled}\n >\n {dictionary.saveDraftCta}\n </Button>\n </Slot>\n );\n\n return (\n <RequestNegotiableQuoteFormComponent\n title={titleNode}\n banner={getBannerNode()}\n commentField={commentFieldNode}\n quoteNameField={quoteNameFieldNode}\n attachFile={attachFileNode}\n requestButton={requestButtonNode}\n saveButton={saveButtonNode}\n onSubmit={formSubmitHandler}\n className={className}\n disabled={isFormDisabled}\n data-testid=\"form-container\"\n />\n );\n};\n"],"names":["SvgAdd","props","React","RequestNegotiableQuoteForm","className","title","banner","commentField","quoteNameField","attachFile","requestButton","saveButton","onSubmit","jsxs","classes","jsx","VComponent","cartId","slots","onRequestNegotiableQuote","onSaveNegotiableQuote","onAttachFiles","onSubmitErrors","onError","comment","setComment","useState","quoteName","setQuoteName","attachmentKeys","setAttachmentKeys","error","setError","formErrors","setFormErrors","success","setSuccess","isFormDisabled","setIsFormDisabled","dictionary","useText","useEffect","permissionsEvent","events","permissions","authenticatedEvent","authenticated","handleAttachFiles","useCallback","files","prev","uploaded","uploadFile","key","getBannerNode","inlineAlertProps","slotProps","CheckWithCircle","WarningFilled","Slot","InLineAlert","validateParentForm","e","closestForm","getFormErrors","formSubmitHandler","form","mergedFormErrors","buttonTarget","formValues","getFormValues","isDraft","_a","contextData","submitHandler","successMessage","requestNegotiableQuote","titleNode","commentFieldNode","TextArea","quoteNameFieldNode","Field","Input","attachFileNode","InputFile","target","fileList","Add","requestButtonNode","Button","saveButtonNode","RequestNegotiableQuoteFormComponent"],"mappings":"21BACA,MAAMA,GAAUC,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,gBAAiB,YAAa,gCAAiC,MAAO,6BAA8B,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,GAAGD,GAAyBC,EAAM,cAAc,IAAK,CAAE,GAAI,OAAO,EAAoBA,EAAM,cAAc,OAAQ,CAAE,GAAI,iBAAkB,YAAa,iBAAkB,MAAO,GAAI,OAAQ,GAAI,KAAM,OAAQ,QAAS,CAAC,CAAE,EAAmBA,EAAM,cAAc,IAAK,CAAE,GAAI,WAAY,YAAa,WAAY,UAAW,wBAAwB,EAAoBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,GAAI,WAAY,YAAa,WAAY,GAAI,KAAM,UAAW,0BAA2B,KAAM,OAAQ,OAAQ,cAAc,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,GAAI,WAAY,YAAa,WAAY,GAAI,KAAM,UAAW,0BAA2B,KAAM,OAAQ,OAAQ,eAAgB,CAAC,CAAC,CAAC,ECwB/8BC,GAAiF,CAAC,CAC7F,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,aAAAC,EACA,eAAAC,EACA,WA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AK,kBACL,KAAMzC,GAAA,YAAAA,EAAO,gBACb,QACE,CACE,uBAAA0D,EACA,WAAA3C,EACA,eAAAI,EACA,kBAAAC,CAAA,EAIJ,SAAAvB,EAAC0E,EAAA,CACC,KAAK,SACL,aAAW,OACX,QAAQ,YACR,cAAY,yBACZ,QAAS5B,EACT,SAAUxB,EAET,SAAAE,EAAW,YAAA,CAAA,CACd,CAAA,EAIJ,OACExB,EAAC4E,GAAA,CACC,MAAOd,EACP,OAAQvB,EAAA,EACR,aAAcwB,EACd,eAAgBE,EAChB,WAAYG,EACZ,cAAeK,EACf,WAAYE,GACZ,SAAUzB,EACV,UAAA7D,EACA,SAAUiC,EACV,cAAY,gBAAA,CAAA,CAGlB","x_google_ignoreList":[0]}
@@ -13,6 +13,7 @@ export * from './OrderSummary';
13
13
  export * from './OrderSummaryLine';
14
14
  export * from './QuoteCommentsList';
15
15
  export * from './QuoteHistoryLog';
16
+ export * from './QuoteSummaryList';
16
17
  export * from './QuotesListTable';
17
18
  export * from './ShippingAddressDisplay';
18
19
  export * from './QuoteTemplatesListTable';
@@ -3,5 +3,6 @@ import { NegotiableQuoteCartItem, NegotiableQuoteModel } from '../negotiable-quo
3
3
  export declare const baseCartItem: NegotiableQuoteCartItem;
4
4
  export declare const configurableCartItem: NegotiableQuoteCartItem;
5
5
  export declare const bundleCartItem: NegotiableQuoteCartItem;
6
+ export declare const downloadableCartItem: NegotiableQuoteCartItem;
6
7
  export declare const base: NegotiableQuoteModel;
7
8
  //# sourceMappingURL=negotiableQuoteModel.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { StoreConfigModel } from '../store-config-model';
2
+
3
+ export declare const mockStoreConfigModel: StoreConfigModel;
4
+ export declare const mockStoreConfigModelWithDefaultValues: StoreConfigModel;
5
+ //# sourceMappingURL=storeConfigModel.d.ts.map
@@ -42,6 +42,7 @@ export interface NegotiableQuoteModel {
42
42
  lastname: string;
43
43
  };
44
44
  templateName?: string;
45
+ totalQuantity: number;
45
46
  comments?: {
46
47
  uid: string;
47
48
  createdAt: string;
@@ -91,7 +92,16 @@ export interface BundleOption {
91
92
  price: Currency;
92
93
  }[];
93
94
  }
95
+ export interface CustomizableOption {
96
+ type: string;
97
+ label: string;
98
+ values: {
99
+ label: string;
100
+ value: string;
101
+ }[];
102
+ }
94
103
  export interface NegotiableQuoteCartItem {
104
+ itemType: string;
95
105
  uid: string;
96
106
  product: {
97
107
  uid: string;
@@ -101,12 +111,14 @@ export interface NegotiableQuoteCartItem {
101
111
  templateName?: string;
102
112
  priceRange: {
103
113
  maximumPrice: {
104
- regularPrice: {
105
- value: number;
106
- };
114
+ regularPrice: Currency;
107
115
  };
108
116
  };
109
117
  };
118
+ image: ItemImage;
119
+ links?: ItemLinks;
120
+ discounted: boolean;
121
+ discountedTotal: Currency;
110
122
  catalogDiscount: {
111
123
  amountOff: number;
112
124
  percentOff: number;
@@ -116,19 +128,34 @@ export interface NegotiableQuoteCartItem {
116
128
  value: string;
117
129
  amount: Currency;
118
130
  }[];
131
+ discountPercentage?: number;
132
+ insufficientQuantity?: boolean;
133
+ outOfStock?: boolean;
119
134
  stockStatus: string;
120
135
  quantity: number;
121
136
  prices: {
137
+ regularPrice: Currency;
138
+ priceIncludingTax: Currency;
122
139
  originalItemPrice: Currency;
140
+ originalRowTotal: Currency;
123
141
  rowTotal: Currency;
142
+ rowTotalIncludingTax: Currency;
124
143
  };
144
+ savingsAmount?: Currency;
125
145
  configurableOptions?: ConfigurableOption[];
126
- optionLabel: string;
127
- valueLabel: string;
128
146
  bundleOptions?: BundleOption[];
147
+ customizableOptions?: CustomizableOption[];
129
148
  noteFromBuyer?: ItemNote[];
130
149
  noteFromSeller?: ItemNote[];
131
150
  }
151
+ interface ItemImage {
152
+ src: string;
153
+ alt: string;
154
+ }
155
+ interface ItemLinks {
156
+ count: number;
157
+ result: string;
158
+ }
132
159
  export interface ItemNote {
133
160
  createdAt: string;
134
161
  creatorId: number;
@@ -254,4 +281,5 @@ export interface PaginationInfo {
254
281
  totalPages: number;
255
282
  pageSizeOptions?: number[];
256
283
  }
284
+ export {};
257
285
  //# sourceMappingURL=negotiable-quote-model.d.ts.map
@@ -7,11 +7,13 @@
7
7
  * accompanying it.
8
8
  *******************************************************************/
9
9
  export declare enum QuoteDisplayAmount {
10
- TAX_INCLUDED = 1,
11
- TAX_EXCLUDED = 2,
10
+ TAX_EXCLUDED = 1,
11
+ TAX_INCLUDED = 2,
12
12
  TAX_INCLUDED_AND_EXCLUDED = 3
13
13
  }
14
14
  export interface StoreConfigModel {
15
+ quoteSummaryDisplayTotal: number;
16
+ quoteSummaryMaxItems: number;
15
17
  quoteDisplaySettings: {
16
18
  zeroTax: boolean;
17
19
  subtotal: QuoteDisplayAmount;
@@ -20,5 +22,6 @@ export interface StoreConfigModel {
20
22
  fullSummary: boolean;
21
23
  grandTotal: boolean;
22
24
  };
25
+ useConfigurableParentThumbnail: boolean;
23
26
  }
24
27
  //# sourceMappingURL=store-config-model.d.ts.map