@dropins/storefront-quote-management 0.0.1-alpha30 → 0.0.1-alpha31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/duplicateNegotiableQuote/duplicateNegotiableQuote.d.ts +1 -0
- package/api/getQuoteTemplates/graphql/getQuoteTemplates.d.ts +1 -1
- package/api/graphql/NegotiableQuoteTemplateFragment.d.ts +1 -1
- package/api.js +1 -1
- package/chunks/AttachedFilesList.js +1 -1
- package/chunks/AttachedFilesList.js.map +1 -1
- package/chunks/CheckWithCircle.js +4 -0
- package/chunks/CheckWithCircle.js.map +1 -0
- package/chunks/ItemsQuoted.js +1 -1
- package/chunks/ItemsQuoted.js.map +1 -1
- package/chunks/ItemsQuotedTemplate.js +1 -1
- package/chunks/ItemsQuotedTemplate.js.map +1 -1
- package/chunks/LineItemNoteModal.js +1 -1
- package/chunks/LineItemNoteModal.js.map +1 -1
- package/chunks/NegotiableQuoteTemplateFragment.js +148 -6
- package/chunks/NegotiableQuoteTemplateFragment.js.map +1 -1
- package/chunks/ShippingAddressDisplay.js +1 -1
- package/chunks/ShippingAddressDisplay.js.map +1 -1
- package/chunks/WarningFilled.js +1 -1
- package/chunks/WarningFilled.js.map +1 -1
- package/chunks/addQuoteTemplateLineItemNote.js +1 -1
- package/chunks/addQuoteTemplateLineItemNote.js.map +1 -1
- package/chunks/duplicateNegotiableQuote.js +8 -8
- package/chunks/duplicateNegotiableQuote.js.map +1 -1
- package/chunks/getQuoteTemplates.js +13 -11
- package/chunks/getQuoteTemplates.js.map +1 -1
- package/chunks/negotiableQuotes.js +1 -1
- package/chunks/transform-quote-template.js +1 -1
- package/chunks/transform-quote-template.js.map +1 -1
- package/chunks/transform-quote.js +1 -1
- package/chunks/transform-quote.js.map +1 -1
- package/components/LineItemNoteModal/LineItemNoteModal.d.ts +2 -2
- package/components/ProductListTable/ProductListTable.d.ts +5 -49
- package/containers/ItemsQuoted/ItemsQuoted.d.ts +7 -7
- package/containers/ItemsQuoted.js +1 -1
- package/containers/ItemsQuotedTemplate/ItemsQuotedTemplate.d.ts +3 -3
- package/containers/ItemsQuotedTemplate.js +1 -1
- package/containers/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +3 -4
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/ManageNegotiableQuoteTemplate.js +2 -2
- package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
- package/containers/QuoteSummaryList/QuoteSummaryList.d.ts +1 -1
- package/containers/QuoteSummaryList.js +1 -1
- package/containers/QuoteSummaryList.js.map +1 -1
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuoteTemplatesListTable.js.map +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/QuotesListTable.js.map +1 -1
- package/containers/RequestNegotiableQuoteForm.js +1 -1
- package/containers/RequestNegotiableQuoteForm.js.map +1 -1
- package/containers/ShippingAddressDisplay.js +1 -1
- package/data/models/__fixtures__/negotiableQuoteModel.d.ts +5 -5
- package/data/models/negotiable-quote-model.d.ts +2 -2
- package/data/models/negotiable-quote-template-model.d.ts +3 -39
- package/data/transforms/__fixtures__/negotiableQuoteData.d.ts +5 -0
- package/data/transforms/__fixtures__/negotiableQuoteTemplateData.d.ts +561 -75
- package/data/transforms/transform-history.d.ts +15 -0
- package/data/transforms/transform-quote-items.d.ts +15 -0
- package/hooks/useItemsQuotedTemplate.d.ts +3 -4
- package/hooks/useRemoveTemplateItems.d.ts +3 -3
- package/hooks/useUpdateTemplateQuantities.d.ts +2 -2
- package/i18n/en_US.json.d.ts +24 -5
- package/lib/itemFormatters.d.ts +1 -1
- package/lib/priceCalculators.d.ts +1 -1
- package/package.json +1 -1
- package/render.js +2 -2
- package/render.js.map +1 -1
|
@@ -3,6 +3,7 @@ import { NegotiableQuoteModel } from '../../data/models/negotiable-quote-model';
|
|
|
3
3
|
export interface DuplicateQuoteInput {
|
|
4
4
|
quoteUid: string;
|
|
5
5
|
duplicatedQuoteUid: string;
|
|
6
|
+
hasOutOfStockItems?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare const duplicateQuote: (input: DuplicateQuoteInput) => Promise<NegotiableQuoteModel | null>;
|
|
8
9
|
//# sourceMappingURL=duplicateNegotiableQuote.d.ts.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export declare const QUOTE_TEMPLATES_QUERY = "\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n
|
|
9
|
+
export declare const QUOTE_TEMPLATES_QUERY = "\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n uid\n template_id\n name\n created_at\n updated_at\n last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n expiration_date\n orders_placed\n prices {\n grand_total {\n currency\n value\n }\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\n }\n }\n }\n }\n";
|
|
10
10
|
//# sourceMappingURL=getQuoteTemplates.d.ts.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export declare const NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT = "\n fragment NegotiableQuoteTemplateFragment on NegotiableQuoteTemplate {\n
|
|
9
|
+
export declare const NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT = "\n fragment NegotiableQuoteTemplateFragment on NegotiableQuoteTemplate {\n uid\n template_id\n name\n created_at\n updated_at\n status\n sales_rep_name\n expiration_date\n buyer {\n firstname\n lastname\n }\n comments {\n uid\n created_at\n author {\n firstname\n lastname\n }\n text\n attachments {\n name\n url\n }\n }\n items {\n __typename\n uid\n product {\n name\n sku\n uid\n stock_status\n quantity\n thumbnail {\n label\n url\n }\n price_range {\n minimum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n discount {\n percent_off\n amount_off\n }\n }\n maximum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n discount {\n percent_off\n amount_off\n }\n }\n }\n price_tiers {\n quantity\n final_price {\n value\n }\n discount {\n amount_off\n percent_off\n }\n }\n }\n prices {\n price {\n currency\n value\n }\n price_including_tax {\n value\n currency\n }\n original_item_price {\n currency\n value\n }\n original_row_total {\n currency\n value\n }\n row_total {\n currency\n value\n }\n row_total_including_tax {\n value\n currency\n }\n catalog_discount {\n amount_off\n percent_off\n }\n discounts {\n label\n value\n amount {\n currency\n value\n }\n }\n }\n quantity\n is_available\n note_from_buyer {\n created_at\n creator_id\n creator_type\n negotiable_quote_item_uid\n note\n note_uid\n __typename\n }\n note_from_seller {\n created_at\n creator_id\n creator_type\n negotiable_quote_item_uid\n note\n note_uid\n __typename\n }\n ... on SimpleCartItem {\n customizable_options {\n type\n label\n values {\n label\n value\n }\n }\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n value_label\n }\n configured_variant {\n uid\n sku\n stock_status\n thumbnail {\n label\n url\n }\n price_range {\n minimum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n discount {\n percent_off\n amount_off\n }\n }\n maximum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n discount {\n percent_off\n amount_off\n }\n }\n }\n price_tiers {\n quantity\n final_price {\n value\n }\n discount {\n amount_off\n percent_off\n }\n }\n }\n customizable_options {\n type\n label\n values {\n label\n value\n }\n }\n }\n ... on BundleCartItem {\n bundle_options {\n label\n values {\n label\n quantity\n original_price {\n currency\n value\n }\n priceV2 {\n currency\n value\n }\n }\n }\n }\n ... on DownloadableCartItem {\n links {\n sort_order\n title\n }\n customizable_options {\n type\n label\n values {\n label\n value\n }\n }\n }\n }\n history {\n uid\n created_at\n author {\n firstname\n lastname\n }\n change_type\n changes {\n comment_added {\n comment\n }\n custom_changes {\n new_value\n old_value\n title\n }\n statuses {\n changes {\n new_status\n old_status\n }\n }\n expiration {\n new_expiration\n old_expiration\n }\n total {\n new_price {\n currency\n value\n }\n old_price {\n currency\n value\n }\n }\n }\n }\n prices {\n subtotal_excluding_tax {\n currency\n value\n }\n subtotal_including_tax {\n currency\n value\n }\n subtotal_with_discount_excluding_tax {\n currency\n value\n }\n applied_taxes {\n amount {\n currency\n value\n }\n label\n }\n grand_total {\n currency\n value\n }\n }\n shipping_addresses {\n uid\n firstname\n lastname\n company\n street\n city\n region {\n code\n label\n region_id\n }\n postcode\n country {\n code\n label\n }\n telephone\n }\n reference_document_links {\n link_id\n document_name\n document_identifier\n reference_document_url\n }\n }\n";
|
|
10
10
|
//# sourceMappingURL=NegotiableQuoteTemplateFragment.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chunks/duplicateNegotiableQuote.js";import{c as V,a as W,d as Z,b as ee,r as te,s as se}from"./chunks/duplicateNegotiableQuote.js";import{F as re,N as ae,S as ie,n as ne}from"./chunks/negotiableQuotes.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as r,D as f,a as h,Q as n}from"./chunks/state.js";import{f as d,t as q}from"./chunks/transform-quote.js";import{
|
|
3
|
+
import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chunks/duplicateNegotiableQuote.js";import{c as V,a as W,d as Z,b as ee,r as te,s as se}from"./chunks/duplicateNegotiableQuote.js";import{F as re,N as ae,S as ie,n as ne}from"./chunks/negotiableQuotes.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as r,D as f,a as h,Q as n}from"./chunks/state.js";import{f as d,t as q}from"./chunks/transform-quote.js";import{i as ue,r as pe,s as me,e as le,h as ge}from"./chunks/transform-quote.js";import{N as D}from"./chunks/NegotiableQuoteFragment.js";import{u as _e}from"./chunks/uploadFile.js";import{a as T}from"./chunks/transform-quote-template.js";import{N as Q}from"./chunks/NegotiableQuoteTemplateFragment.js";import{Q as he,a as Te,S as Qe,g as Ee}from"./chunks/getQuoteTemplates.js";import{a as Ie,c as qe,d as De,o as Ne,s as ye}from"./chunks/openQuoteTemplate.js";import{a as Se,r as we,u as Fe}from"./chunks/addQuoteTemplateLineItemNote.js";import{g as ve}from"./chunks/generateQuoteFromTemplate.js";import{r as Me,s as Oe,u as xe}from"./chunks/setLineItemNote.js";import{Initializer as N}from"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";function y(e){if(!e||typeof e!="object")return{requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1};if(e.all===!0)return{requestQuote:!0,editQuote:!0,deleteQuote:!0,checkoutQuote:!0,viewQuoteTemplates:!0,manageQuoteTemplates:!0,generateQuoteFromTemplate:!0};const s=e["Magento_NegotiableQuote::all"]===!0,t=e["Magento_NegotiableQuoteTemplate::all"]===!0,o=s||e["Magento_NegotiableQuote::manage"]===!0;return{requestQuote:o,editQuote:o,deleteQuote:o,checkoutQuote:s||e["Magento_NegotiableQuote::checkout"]===!0,viewQuoteTemplates:t||e["Magento_NegotiableQuoteTemplate::view_template"]===!0,manageQuoteTemplates:t||e["Magento_NegotiableQuoteTemplate::manage"]===!0,generateQuoteFromTemplate:t||e["Magento_NegotiableQuoteTemplate::generate_quote"]===!0}}function p(e){if(r.quoteDataLoaded)return;const s=m.config.getConfig(),{quoteId:t,quoteTemplateId:o}=s;!e.editQuote||!t&&!o||(r.quoteDataLoaded=!0,t&&I(t).then(i=>{r.quoteDataInitialized||a.emit("quote-management/quote-data/initialized",{quote:i,permissions:e}),r.quoteDataInitialized=!0}).catch(i=>{r.quoteDataLoaded=!1,a.emit("quote-management/quote-data/error",{error:i})}),o&&L(o).catch(i=>{r.quoteDataLoaded=!1,a.emit("quote-management/quote-template-data/error",{error:i})}))}const m=new N({init:async e=>{const s={};m.config.setConfig({...s,...e}),await w().then(t=>{r.config=t}).catch(t=>{console.error("Failed to fetch store config: ",t),r.config=h}),r.initialized=!0,a.emit("quote-management/initialized",{})},listeners:()=>[a.on("authenticated",async e=>{r.authenticated=!!e,e||(r.permissions=f,r.quoteDataLoaded=!1,a.emit("quote-management/permissions",f))},{eager:!0}),a.on("auth/permissions",async e=>{const s=y(e);r.permissions=s,r.quoteDataLoaded=!1,a.emit("quote-management/permissions",r.permissions)},{eager:!0}),a.on("quote-management/permissions",async e=>{r.initialized&&p(e)},{eager:!0}),a.on("quote-management/initialized",async()=>{p(r.permissions)},{eager:!0}),a.on("checkout/updated",async e=>{r.initialized&&(e==null?void 0:e.type)==="quote"&&(r.quoteDataLoaded=!1,p(r.permissions))},{eager:!0})]}),B=m.config;function b(e){if(!e)return h;const s=t=>[n.TAX_EXCLUDED,n.TAX_INCLUDED,n.TAX_INCLUDED_AND_EXCLUDED].includes(t)?t:n.TAX_EXCLUDED;return{quoteSummaryDisplayTotal:e.cart_summary_display_quantity,quoteSummaryMaxItems:e.max_items_in_order_summary,quoteDisplaySettings:{zeroTax:e.shopping_cart_display_zero_tax,subtotal:s(e.shopping_cart_display_subtotal),price:s(e.shopping_cart_display_price),shipping:s(e.shopping_cart_display_shipping),fullSummary:e.shopping_cart_display_full_summary,grandTotal:e.shopping_cart_display_grand_total},useConfigurableParentThumbnail:e.configurable_thumbnail_source==="parent"}}const S=`
|
|
4
4
|
query STORE_CONFIG_QUERY {
|
|
5
5
|
storeConfig {
|
|
6
6
|
cart_summary_display_quantity
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import*as
|
|
3
|
+
import*as i from"@dropins/tools/preact-compat.js";import{jsx as s,jsxs as o}from"@dropins/tools/preact-jsx-runtime.js";import{Button as u}from"@dropins/tools/components.js";import{S as h}from"./CheckWithCircle.js";import{S as g}from"./WarningFilled.js";import{useText as f}from"@dropins/tools/i18n.js";const M=t=>i.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",...t},i.createElement("g",{id:"Large"},i.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),i.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},i.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"}),i.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"})))),v=t=>i.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),_=t=>{if(t===0)return"0 Bytes";const a=1024,l=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(t)/Math.log(a)),e=Math.min(r,l.length-1),n=t/Math.pow(a,e);return`${Math.round(n*100)/100} ${l[e]}`},S=(t,a)=>!a||a.length===0?!0:a.includes(t),B=(t,a)=>a==null?!0:t<=a,b=({files:t,onRemove:a,disabled:l=!1})=>{const r=f({removeFile:"NegotiableQuote.Manage.removeFile",uploading:"NegotiableQuote.Manage.uploading",uploadSuccess:"NegotiableQuote.Manage.uploadSuccess",uploadError:"NegotiableQuote.Manage.uploadError"});return!t||t.length===0?null:s("div",{className:"attached-files-list","data-testid":"attached-files-list",children:t.map(e=>{const n=e.status==="uploading",c=e.status==="error",d=e.status==="success",m=!l&&!n;return o("div",{className:`attached-files-list__item attached-files-list__item--${e.status}`,"data-testid":`attached-file-${e.key}`,children:[o("div",{className:"attached-files-list__item-main",children:[o("div",{className:"attached-files-list__item-icon",children:[n&&s("div",{className:"attached-files-list__spinner","data-testid":"file-uploading-spinner","aria-label":r.uploading}),d&&s(h,{"data-testid":"file-success-icon","aria-label":r.uploadSuccess,className:"attached-files-list__success-icon"}),c&&s(g,{"data-testid":"file-error-icon","aria-label":r.uploadError,color:"var(--color-error)",className:"attached-files-list__error-icon"})]}),o("div",{className:"attached-files-list__item-info",children:[s("div",{className:"attached-files-list__item-name","data-testid":"file-name",children:e.name}),o("div",{className:"attached-files-list__item-size","data-testid":"file-size",children:[_(e.size),n&&` - ${r.uploading}`]})]}),s(u,{variant:"tertiary",onClick:()=>a(e.key),disabled:!m,type:"button","aria-label":`${r.removeFile}: ${e.name}`,"data-testid":`remove-file-${e.key}`,className:"attached-files-list__remove-button",children:s(v,{})})]}),c&&e.error&&s("div",{className:"attached-files-list__item-error","data-testid":"file-error-message",children:e.error})]},e.key)})})};export{b as A,M as S,S as a,_ as f,B as v};
|
|
4
4
|
//# sourceMappingURL=AttachedFilesList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachedFilesList.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Add.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Close.svg","/@dropins/storefront-quote-management/src/utils/fileUtils.ts","/@dropins/storefront-quote-management/src/components/AttachedFilesList/AttachedFilesList.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","import * as React from \"react\";\nconst SvgClose = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3599 5.64001L5.62988 18.37\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3599 18.37L5.62988 5.64001\", stroke: \"currentColor\" }));\nexport default SvgClose;\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\n/**\n * Formats a file size in bytes to a human-readable string\n * @param bytes - The file size in bytes\n * @returns A formatted string with the appropriate unit (Bytes, KB, MB, GB)\n * \n * @example\n * formatFileSize(0) // '0 Bytes'\n * formatFileSize(1024) // '1 KB'\n * formatFileSize(1536) // '1.5 KB'\n * formatFileSize(1048576) // '1 MB'\n * formatFileSize(5242880) // '5 MB'\n */\nexport const formatFileSize = (bytes: number): string => {\n if (bytes === 0) return '0 Bytes';\n \n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n \n // Ensure we don't go beyond our sizes array\n const sizeIndex = Math.min(i, sizes.length - 1);\n \n const size = bytes / Math.pow(k, sizeIndex);\n \n // Round to 2 decimal places\n const roundedSize = Math.round(size * 100) / 100;\n \n return `${roundedSize} ${sizes[sizeIndex]}`;\n};\n\n/**\n * Validates if a file type is accepted\n * @param fileType - The MIME type of the file\n * @param acceptedTypes - Array of accepted MIME types (e.g., ['image/png', 'application/pdf'])\n * @returns true if the file type is accepted, false otherwise\n * \n * @example\n * validateFileType('image/png', ['image/png', 'image/jpeg']) // true\n * validateFileType('application/pdf', ['image/png']) // false\n * validateFileType('image/png', []) // true (empty array means all types accepted)\n */\nexport const validateFileType = (\n fileType: string,\n acceptedTypes?: string[]\n): boolean => {\n if (!acceptedTypes || acceptedTypes.length === 0) {\n return true;\n }\n \n return acceptedTypes.includes(fileType);\n};\n\n/**\n * Validates if a file size is within the maximum limit\n * @param fileSize - The file size in bytes\n * @param maxSize - Maximum allowed file size in bytes\n * @returns true if the file size is within the limit, false otherwise\n * \n * @example\n * validateFileSize(1024, 2048) // true\n * validateFileSize(3072, 2048) // false\n * validateFileSize(1024, undefined) // true (no limit)\n */\nexport const validateFileSize = (\n fileSize: number,\n maxSize?: number\n): boolean => {\n if (maxSize === undefined || maxSize === null) {\n return true;\n }\n \n return fileSize <= maxSize;\n};\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { Close, CheckWithCircle, WarningFilled } from '@adobe-commerce/elsie/icons';\nimport { formatFileSize } from '@/quote-management/utils/fileUtils';\nimport './AttachedFilesList.css';\n\nexport interface AttachedFile {\n key: string;\n name: string;\n size: number;\n status: 'uploading' | 'success' | 'error';\n error?: string;\n}\n\nexport interface AttachedFilesListProps {\n files: AttachedFile[];\n onRemove: (key: string) => void;\n disabled?: boolean;\n}\n\nexport const AttachedFilesList: FunctionComponent<AttachedFilesListProps> = ({\n files,\n onRemove,\n disabled = false,\n}) => {\n const dictionary = useText({\n removeFile: 'NegotiableQuote.Manage.removeFile',\n uploading: 'NegotiableQuote.Manage.uploading',\n uploadSuccess: 'NegotiableQuote.Manage.uploadSuccess',\n uploadError: 'NegotiableQuote.Manage.uploadError',\n });\n\n if (!files || files.length === 0) {\n return null;\n }\n\n return (\n <div className=\"attached-files-list\" data-testid=\"attached-files-list\">\n {files.map((file) => {\n const isUploading = file.status === 'uploading';\n const isError = file.status === 'error';\n const isSuccess = file.status === 'success';\n const canRemove = !disabled && !isUploading;\n\n return (\n <div\n key={file.key}\n className={`attached-files-list__item attached-files-list__item--${file.status}`}\n data-testid={`attached-file-${file.key}`}\n >\n <div className=\"attached-files-list__item-main\">\n <div className=\"attached-files-list__item-icon\">\n {isUploading && (\n <div\n className=\"attached-files-list__spinner\"\n data-testid=\"file-uploading-spinner\"\n aria-label={dictionary.uploading}\n />\n )}\n {isSuccess && (\n <CheckWithCircle\n data-testid=\"file-success-icon\"\n aria-label={dictionary.uploadSuccess}\n className=\"attached-files-list__success-icon\"\n />\n )}\n {isError && (\n <WarningFilled\n data-testid=\"file-error-icon\"\n aria-label={dictionary.uploadError}\n color=\"var(--color-error)\"\n className=\"attached-files-list__error-icon\"\n />\n )}\n </div>\n\n <div className=\"attached-files-list__item-info\">\n <div className=\"attached-files-list__item-name\" data-testid=\"file-name\">\n {file.name}\n </div>\n <div className=\"attached-files-list__item-size\" data-testid=\"file-size\">\n {formatFileSize(file.size)}\n {isUploading && ` - ${dictionary.uploading}`}\n </div>\n </div>\n\n <Button\n variant=\"tertiary\"\n onClick={() => onRemove(file.key)}\n disabled={!canRemove}\n type=\"button\"\n aria-label={`${dictionary.removeFile}: ${file.name}`}\n data-testid={`remove-file-${file.key}`}\n className=\"attached-files-list__remove-button\"\n >\n <Close />\n </Button>\n </div>\n\n {isError && file.error && (\n <div\n className=\"attached-files-list__item-error\"\n data-testid=\"file-error-message\"\n >\n {file.error}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n};\n\n"],"names":["SvgAdd","props","React","SvgClose","formatFileSize","bytes","k","sizes","i","sizeIndex","size","validateFileType","fileType","acceptedTypes","validateFileSize","fileSize","maxSize","AttachedFilesList","files","onRemove","disabled","dictionary","useText","jsx","file","isUploading","isError","isSuccess","canRemove","jsxs","CheckWithCircle","WarningFilled","Button","Close"],"mappings":"4QACK,MAACA,EAAUC,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,gBAAiB,YAAa,gCAAiC,MAAO,6BAA8B,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,GAAGD,CAAK,EAAoBC,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,0BAA4CA,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,qBA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","x_google_ignoreList":[0,1]}
|
|
1
|
+
{"version":3,"file":"AttachedFilesList.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Add.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Close.svg","/@dropins/storefront-quote-management/src/utils/fileUtils.ts","/@dropins/storefront-quote-management/src/components/AttachedFilesList/AttachedFilesList.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","import * as React from \"react\";\nconst SvgClose = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3599 5.64001L5.62988 18.37\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3599 18.37L5.62988 5.64001\", stroke: \"currentColor\" }));\nexport default SvgClose;\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\n/**\n * Formats a file size in bytes to a human-readable string\n * @param bytes - The file size in bytes\n * @returns A formatted string with the appropriate unit (Bytes, KB, MB, GB)\n * \n * @example\n * formatFileSize(0) // '0 Bytes'\n * formatFileSize(1024) // '1 KB'\n * formatFileSize(1536) // '1.5 KB'\n * formatFileSize(1048576) // '1 MB'\n * formatFileSize(5242880) // '5 MB'\n */\nexport const formatFileSize = (bytes: number): string => {\n if (bytes === 0) return '0 Bytes';\n \n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n \n // Ensure we don't go beyond our sizes array\n const sizeIndex = Math.min(i, sizes.length - 1);\n \n const size = bytes / Math.pow(k, sizeIndex);\n \n // Round to 2 decimal places\n const roundedSize = Math.round(size * 100) / 100;\n \n return `${roundedSize} ${sizes[sizeIndex]}`;\n};\n\n/**\n * Validates if a file type is accepted\n * @param fileType - The MIME type of the file\n * @param acceptedTypes - Array of accepted MIME types (e.g., ['image/png', 'application/pdf'])\n * @returns true if the file type is accepted, false otherwise\n * \n * @example\n * validateFileType('image/png', ['image/png', 'image/jpeg']) // true\n * validateFileType('application/pdf', ['image/png']) // false\n * validateFileType('image/png', []) // true (empty array means all types accepted)\n */\nexport const validateFileType = (\n fileType: string,\n acceptedTypes?: string[]\n): boolean => {\n if (!acceptedTypes || acceptedTypes.length === 0) {\n return true;\n }\n \n return acceptedTypes.includes(fileType);\n};\n\n/**\n * Validates if a file size is within the maximum limit\n * @param fileSize - The file size in bytes\n * @param maxSize - Maximum allowed file size in bytes\n * @returns true if the file size is within the limit, false otherwise\n * \n * @example\n * validateFileSize(1024, 2048) // true\n * validateFileSize(3072, 2048) // false\n * validateFileSize(1024, undefined) // true (no limit)\n */\nexport const validateFileSize = (\n fileSize: number,\n maxSize?: number\n): boolean => {\n if (maxSize === undefined || maxSize === null) {\n return true;\n }\n \n return fileSize <= maxSize;\n};\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { Close, CheckWithCircle, WarningFilled } from '@adobe-commerce/elsie/icons';\nimport { formatFileSize } from '@/quote-management/utils/fileUtils';\nimport './AttachedFilesList.css';\n\nexport interface AttachedFile {\n key: string;\n name: string;\n size: number;\n status: 'uploading' | 'success' | 'error';\n error?: string;\n}\n\nexport interface AttachedFilesListProps {\n files: AttachedFile[];\n onRemove: (key: string) => void;\n disabled?: boolean;\n}\n\nexport const AttachedFilesList: FunctionComponent<AttachedFilesListProps> = ({\n files,\n onRemove,\n disabled = false,\n}) => {\n const dictionary = useText({\n removeFile: 'NegotiableQuote.Manage.removeFile',\n uploading: 'NegotiableQuote.Manage.uploading',\n uploadSuccess: 'NegotiableQuote.Manage.uploadSuccess',\n uploadError: 'NegotiableQuote.Manage.uploadError',\n });\n\n if (!files || files.length === 0) {\n return null;\n }\n\n return (\n <div className=\"attached-files-list\" data-testid=\"attached-files-list\">\n {files.map((file) => {\n const isUploading = file.status === 'uploading';\n const isError = file.status === 'error';\n const isSuccess = file.status === 'success';\n const canRemove = !disabled && !isUploading;\n\n return (\n <div\n key={file.key}\n className={`attached-files-list__item attached-files-list__item--${file.status}`}\n data-testid={`attached-file-${file.key}`}\n >\n <div className=\"attached-files-list__item-main\">\n <div className=\"attached-files-list__item-icon\">\n {isUploading && (\n <div\n className=\"attached-files-list__spinner\"\n data-testid=\"file-uploading-spinner\"\n aria-label={dictionary.uploading}\n />\n )}\n {isSuccess && (\n <CheckWithCircle\n data-testid=\"file-success-icon\"\n aria-label={dictionary.uploadSuccess}\n className=\"attached-files-list__success-icon\"\n />\n )}\n {isError && (\n <WarningFilled\n data-testid=\"file-error-icon\"\n aria-label={dictionary.uploadError}\n color=\"var(--color-error)\"\n className=\"attached-files-list__error-icon\"\n />\n )}\n </div>\n\n <div className=\"attached-files-list__item-info\">\n <div className=\"attached-files-list__item-name\" data-testid=\"file-name\">\n {file.name}\n </div>\n <div className=\"attached-files-list__item-size\" data-testid=\"file-size\">\n {formatFileSize(file.size)}\n {isUploading && ` - ${dictionary.uploading}`}\n </div>\n </div>\n\n <Button\n variant=\"tertiary\"\n onClick={() => onRemove(file.key)}\n disabled={!canRemove}\n type=\"button\"\n aria-label={`${dictionary.removeFile}: ${file.name}`}\n data-testid={`remove-file-${file.key}`}\n className=\"attached-files-list__remove-button\"\n >\n <Close />\n </Button>\n </div>\n\n {isError && file.error && (\n <div\n className=\"attached-files-list__item-error\"\n data-testid=\"file-error-message\"\n >\n {file.error}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n};\n\n"],"names":["SvgAdd","props","React","SvgClose","formatFileSize","bytes","k","sizes","i","sizeIndex","size","validateFileType","fileType","acceptedTypes","validateFileSize","fileSize","maxSize","AttachedFilesList","files","onRemove","disabled","dictionary","useText","jsx","file","isUploading","isError","isSuccess","canRemove","jsxs","CheckWithCircle","WarningFilled","Button","Close"],"mappings":"8SACK,MAACA,EAAUC,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,gBAAiB,YAAa,gCAAiC,MAAO,6BAA8B,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,GAAGD,CAAK,EAAoBC,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,GA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V,WAACS,EAAA,CAAA,CAAM,CAAA,CAAA,CACT,EACF,EAECP,GAAWF,EAAK,OACfD,EAAC,MAAA,CACC,UAAU,kCACV,cAAY,qBAEX,SAAAC,EAAK,KAAA,CAAA,CACR,CAAA,EA3DGA,EAAK,GAAA,CA+DhB,CAAC,CAAA,CACH,CAEJ","x_google_ignoreList":[0,1]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import*as e from"@dropins/tools/preact-compat.js";const r=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"}));export{r as S};
|
|
4
|
+
//# sourceMappingURL=CheckWithCircle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckWithCircle.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg"],"sourcesContent":["import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n"],"names":["SvgCheckWithCircle","props","React"],"mappings":"kDACK,MAACA,EAAsBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,0JAA2J,OAAQ,cAAc,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qCAAsC,OAAQ,eAAgB,CAAC","x_google_ignoreList":[0]}
|
package/chunks/ItemsQuoted.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as ye,Fragment as be}from"@dropins/tools/preact-jsx-runtime.js";import{useState as i,useEffect as T,useCallback as H}from"@dropins/tools/preact-compat.js";import{Slot as K}from"@dropins/tools/lib.js";import{events as P}from"@dropins/tools/event-bus.js";import{Price as V,InLineAlert as y}from"@dropins/tools/components.js";/* empty css */import{I as X,Q as Qe,P as ve,L as Ne}from"./LineItemNoteModal.js";import{C as Z}from"./ConfirmationModal.js";/* empty css *//* empty css */import"./state.js";import{u as R,s as Te,r as Ie}from"./setLineItemNote.js";import{S as ee
|
|
3
|
+
import{jsx as n,jsxs as ye,Fragment as be}from"@dropins/tools/preact-jsx-runtime.js";import{useState as i,useEffect as T,useCallback as H}from"@dropins/tools/preact-compat.js";import{Slot as K}from"@dropins/tools/lib.js";import{events as P}from"@dropins/tools/event-bus.js";import{Price as V,InLineAlert as y}from"@dropins/tools/components.js";/* empty css */import{I as X,Q as Qe,P as ve,L as Ne}from"./LineItemNoteModal.js";import{C as Z}from"./ConfirmationModal.js";/* empty css *//* empty css */import"./state.js";import{u as R,s as Te,r as Ie}from"./setLineItemNote.js";import{S as ee}from"./CheckWithCircle.js";import{S as D}from"./WarningFilled.js";import{useText as he}from"@dropins/tools/i18n.js";const qe=3e3,_e=({quoteData:te,onItemCheckboxChange:I,onItemDropdownChange:g,onRemoveItemsRef:b,onRemoveModalStateChange:m,slots:p,...ae})=>{const[s,h]=i(te),[F,q]=i({}),[u,j]=i(null),[se,Q]=i(!1),[oe,A]=i(!1),[k,B]=i(""),[v,l]=i({type:null,message:""}),[ne,x]=i(!1),[f,S]=i([]),[re,C]=i(!1),[N,d]=i({type:null,message:""}),[_,c]=i({}),[ie,U]=i(!1),o=he({subtotal:"NegotiableQuote.Manage.quotePricesSummary.subtotal.excludingTax",grandTotal:"NegotiableQuote.Manage.quotePricesSummary.grandTotal.includingTax",appliedTaxes:"NegotiableQuote.Manage.quotePricesSummary.appliedTaxes",modalTitle:"NegotiableQuote.Manage.updateQuantitiesModal.title",modalDescription:"NegotiableQuote.Manage.updateQuantitiesModal.description",modalCancelButton:"NegotiableQuote.Manage.updateQuantitiesModal.cancelButton",modalUpdateButton:"NegotiableQuote.Manage.updateQuantitiesModal.updateButton",successHeading:"NegotiableQuote.Manage.updateQuantitiesModal.successHeading",successMessage:"NegotiableQuote.Manage.updateQuantitiesModal.successMessage",errorHeading:"NegotiableQuote.Manage.updateQuantitiesModal.errorHeading",errorMessage:"NegotiableQuote.Manage.updateQuantitiesModal.errorMessage",removeModalTitle:"NegotiableQuote.Manage.removeItemsModal.title",removeModalDescription:"NegotiableQuote.Manage.removeItemsModal.description",removeModalCancelButton:"NegotiableQuote.Manage.removeItemsModal.cancelButton",removeModalConfirmButton:"NegotiableQuote.Manage.removeItemsModal.confirmButton",removeModalConfirmButtonRemoving:"NegotiableQuote.Manage.removeItemsModal.confirmButtonRemoving",removeSuccessHeading:"NegotiableQuote.Manage.removeItemsModal.successHeading",removeSuccessMessage:"NegotiableQuote.Manage.removeItemsModal.successMessage",removeErrorHeading:"NegotiableQuote.Manage.removeItemsModal.errorHeading",removeErrorMessage:"NegotiableQuote.Manage.removeItemsModal.errorMessage"});T(()=>{const t=P.on("quote-management/quote-data",e=>{h(e.quote),q({}),l({type:null,message:""}),c({})},{eager:!0});return()=>t==null?void 0:t.off()},[]),T(()=>{const t=P.on("quote-management/quantities-updated",e=>{h(e.quote),q({}),l({type:"success",message:o.successMessage}),setTimeout(()=>{Q(!1),l({type:null,message:""})},3e3)});return()=>t==null?void 0:t.off()},[o.successMessage]),T(()=>{const t=P.on("quote-management/quote-items-removed",e=>{h(e.quote),S([]),C(!1),d({type:"success",message:o.removeSuccessMessage}),setTimeout(()=>{x(!1),d({type:null,message:""}),m==null||m(!1)},qe)});return()=>t==null?void 0:t.off()},[o.removeSuccessMessage,m]);const O=H(t=>{!t||t.length===0||(S(t),d({type:null,message:""}),x(!0))},[]);T(()=>{b==null||b(O)},[O,b]);const W=()=>{d({type:null,message:""})},w=(t,e)=>{const a=t;if(e==="edit"){j(a),A(!0),c(r=>({...r,[a.uid]:""}));return}if(e==="remove"){c(r=>({...r,[a.uid]:e})),O([a]),g==null||g(a,e),c(r=>({...r,[a.uid]:""}));return}e&&(g==null||g(a,e)),c(r=>{if(!(a.uid in r))return r;const M={...r};return delete M[a.uid],M})},ue=async()=>{if(!s||f.length===0)return;const t=f.map(e=>e.uid);C(!0),d({type:null,message:""});try{await Ie({quoteUid:s.uid,quoteItemUids:t})}catch(e){const a=e instanceof Error?e.message:o.removeErrorMessage;if(d({type:"error",message:a}),f.length===1){const r=f[0];c(M=>{if(!(r.uid in M))return M;const J={...M};return delete J[r.uid],J})}C(!1)}},le=()=>{if(x(!1),d({type:null,message:""}),m==null||m(!1),f.length===1){const t=f[0];c(e=>{if(!(t.uid in e))return e;const a={...e};return delete a[t.uid],a})}S([])},E=H(()=>{u&&c(t=>{const e={...t};return delete e[u.uid],e}),A(!1),j(null),U(!1),B("")},[u]),ce=H(async(t,e)=>{if(!(!u||!s)){U(!0);try{e!==u.quantity&&await R({quoteUid:s.uid,items:[{quoteItemUid:u.uid,quantity:e}]}),await Te({quoteUid:s.uid,itemUid:u.uid,note:t,quantity:e}),E()}catch(a){console.error("Failed to set line item note:",a);const r=a instanceof Error?a.message:"Unable to update the item. Please try again.";B(r),U(!1)}}},[u,s,E]);if(!s)return n(X,{loading:!0});const Y=!!s.canUpdateQuote,$=(t,e)=>{q(a=>({...a,[t.uid]:e}))},z=t=>{t.preventDefault(),l({type:null,message:""}),Q(!0)},me=async()=>{if(!s)return;if(Object.keys(F).length===0){Q(!1);return}l({type:null,message:""});const t=Object.entries(F).map(([e,a])=>({quoteItemUid:e,quantity:a}));try{await R({quoteUid:s.uid,items:t})}catch(e){const a=e instanceof Error?e.message:o.errorMessage;l({type:"error",message:a}),console.error("Failed to update quantities:",e)}},de=()=>{Q(!1),l({type:null,message:""})},G=()=>{l({type:null,message:""})},L=[];s.prices.subtotalExcludingTax&&L.push({label:o.subtotal,id:"subtotal",value:n(V,{amount:s.prices.subtotalExcludingTax.value,currency:s.prices.subtotalExcludingTax.currency,weight:"normal"})}),s.prices.grandTotal&&L.push({label:o.grandTotal,id:"total",value:n(V,{amount:s.prices.grandTotal.value,currency:s.prices.grandTotal.currency}),strong:!0});const ge=v.type==="success"?n(y,{type:"success",variant:"primary",icon:n(ee,{}),heading:o.successHeading,description:v.message,onDismiss:G,"data-testid":"update-quantities-success-banner"}):v.type==="error"?n(y,{type:"error",variant:"primary",icon:n(D,{}),heading:o.errorHeading,description:v.message,onDismiss:G,"data-testid":"update-quantities-error-banner"}):null,pe=I?(t,e)=>{I(t,e)}:void 0,fe=N.type==="success"?n(y,{type:"success",variant:"primary",icon:n(ee,{}),heading:o.removeSuccessHeading,description:N.message,onDismiss:W,"data-testid":"remove-items-success-banner"}):N.type==="error"?n(y,{type:"error",variant:"primary",icon:n(D,{}),heading:o.removeErrorHeading,description:N.message,onDismiss:W,"data-testid":"remove-items-error-banner"}):null,Me=k?n(y,{type:"error",variant:"primary",icon:n(D,{}),heading:o.errorHeading,description:k,onDismiss:()=>B(""),"data-testid":"line-item-note-error-banner"}):null;return ye(be,{children:[n(X,{"data-testid":"items-quoted-container",...ae,loading:!1,table:n(K,{name:"ProductListTable",slot:p==null?void 0:p.ProductListTable,context:{items:s.items,canEdit:Y,readOnly:s.readOnly,onItemCheckboxChange:I,onItemDropdownChange:w,onQuantityChange:$,onUpdate:z,dropdownSelections:_},children:n(ve,{items:s.items,canEdit:Y,onItemCheckboxChange:pe,readOnly:s.readOnly,onItemDropdownChange:w,onQuantityChange:$,onUpdate:z,dropdownSelections:_})}),pricesSummary:n(K,{name:"QuotePricesSummary",slot:p==null?void 0:p.QuotePricesSummary,context:{items:s.items,prices:s.prices},children:n(Qe,{entries:L})})}),n(Z,{open:se,title:o.modalTitle,message:o.modalDescription,cancelLabel:o.modalCancelButton,confirmLabel:o.modalUpdateButton,onCancel:de,onConfirm:me,confirmationBanner:ge,"data-testid":"update-quantities-modal"}),n(Z,{open:ne,title:o.removeModalTitle,message:o.removeModalDescription,cancelLabel:o.removeModalCancelButton,confirmLabel:re?o.removeModalConfirmButtonRemoving:o.removeModalConfirmButton,onCancel:le,onConfirm:ue,confirmationBanner:fe,"data-testid":"remove-items-modal"}),u&&n(Ne,{open:oe,item:u,onClose:E,onConfirm:ce,isSubmitting:ie,errorBanner:Me||void 0})]})};export{_e as I};
|
|
4
4
|
//# sourceMappingURL=ItemsQuoted.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemsQuoted.js","sources":["/@dropins/storefront-quote-management/src/containers/ItemsQuoted/ItemsQuoted.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 {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Price, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n NegotiableQuoteModel,\n NegotiableQuoteCartItem,\n} from '@/quote-management/data/models/negotiable-quote-model';\nimport {\n ProductListTable,\n ProductListTableItem,\n QuotePricesSummary,\n ItemsQuoted as ItemsQuotedComponent,\n} from '@/quote-management/components';\nimport { CheckWithCircle, WarningFilled } from '@adobe-commerce/elsie/icons';\nimport { ConfirmationModal } from '@/quote-management/components/ConfirmationModal';\nimport { LineItemNoteModal } from '@/quote-management/components/LineItemNoteModal';\nimport { updateQuantities, setLineItemNote } from '@/quote-management/api';\nimport { removeNegotiableQuoteItems } from '@/quote-management/api/removeNegotiableQuoteItems';\n\nconst NOTIFICATION_AUTO_DISMISS_DELAY = 3000;\n\nexport interface ItemsQuotedProps extends HTMLAttributes<HTMLDivElement> {\n quoteData?: NegotiableQuoteModel;\n onItemCheckboxChange?: (\n item: NegotiableQuoteCartItem,\n isSelected: boolean\n ) => void;\n onItemDropdownChange?: (\n item: NegotiableQuoteCartItem,\n action: string\n ) => void;\n onUpdate?: (e: SubmitEvent) => void;\n onRemoveItemsRef?: (\n handler: (items: NegotiableQuoteCartItem[]) => void\n ) => void;\n onRemoveModalStateChange?: (isOpen: boolean) => void;\n slots?: {\n ProductListTable?: SlotProps<{\n items: NegotiableQuoteModel['items'];\n canEdit: boolean;\n readOnly?: boolean;\n onItemCheckboxChange?: (\n item: NegotiableQuoteCartItem,\n isSelected: boolean\n ) => void;\n onItemDropdownChange?: (\n item: NegotiableQuoteCartItem,\n action: string\n ) => void;\n onQuantityChange?: (\n item: NegotiableQuoteCartItem,\n newQuantity: number\n ) => void;\n onUpdate?: (e: SubmitEvent) => void;\n dropdownSelections?: Record<string, string | undefined>;\n }>;\n QuotePricesSummary?: SlotProps<{\n items: NegotiableQuoteModel['items'];\n prices: NegotiableQuoteModel['prices'];\n }>;\n };\n}\n\nexport const ItemsQuoted: Container<ItemsQuotedProps> = ({\n quoteData: initialData,\n onItemCheckboxChange,\n onItemDropdownChange,\n onRemoveItemsRef,\n onRemoveModalStateChange,\n slots,\n ...props\n}) => {\n const [quoteData, setQuoteData] = useState<NegotiableQuoteModel | undefined>(\n initialData\n );\n const [quantityChanges, setQuantityChanges] = useState<{\n [itemUid: string]: number;\n }>({});\n const [selectedItem, setSelectedItem] =\n useState<NegotiableQuoteCartItem | null>(null);\n const [isUpdateQuantitiesModalOpen, setIsUpdateQuantitiesModalOpen] =\n useState(false);\n const [isLineItemNoteModalOpen, setIsLineItemNoteModalOpen] = useState(false);\n const [modalErrorMessage, setModalErrorMessage] = useState('');\n const [notificationState, setNotificationState] = useState<{\n type: 'success' | 'error' | null;\n message: string;\n }>({ type: null, message: '' });\n // State for remove items functionality\n const [isRemoveModalOpen, setIsRemoveModalOpen] = useState(false);\n const [itemsToRemove, setItemsToRemove] = useState<NegotiableQuoteCartItem[]>(\n []\n );\n const [isRemoving, setIsRemoving] = useState(false);\n const [removeNotificationState, setRemoveNotificationState] = useState<{\n type: 'success' | 'error' | null;\n message: string;\n }>({ type: null, message: '' });\n const [dropdownSelections, setDropdownSelections] = useState<\n Record<string, string>\n >({});\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const dictionary = useText({\n subtotal: 'NegotiableQuote.Manage.quotePricesSummary.subtotal.excludingTax',\n grandTotal:\n 'NegotiableQuote.Manage.quotePricesSummary.grandTotal.includingTax',\n appliedTaxes: 'NegotiableQuote.Manage.quotePricesSummary.appliedTaxes',\n modalTitle: 'NegotiableQuote.Manage.updateQuantitiesModal.title',\n modalDescription:\n 'NegotiableQuote.Manage.updateQuantitiesModal.description',\n modalCancelButton:\n 'NegotiableQuote.Manage.updateQuantitiesModal.cancelButton',\n modalUpdateButton:\n 'NegotiableQuote.Manage.updateQuantitiesModal.updateButton',\n successHeading:\n 'NegotiableQuote.Manage.updateQuantitiesModal.successHeading',\n successMessage:\n 'NegotiableQuote.Manage.updateQuantitiesModal.successMessage',\n errorHeading: 'NegotiableQuote.Manage.updateQuantitiesModal.errorHeading',\n errorMessage: 'NegotiableQuote.Manage.updateQuantitiesModal.errorMessage',\n removeModalTitle: 'NegotiableQuote.Manage.removeItemsModal.title',\n removeModalDescription:\n 'NegotiableQuote.Manage.removeItemsModal.description',\n removeModalCancelButton:\n 'NegotiableQuote.Manage.removeItemsModal.cancelButton',\n removeModalConfirmButton:\n 'NegotiableQuote.Manage.removeItemsModal.confirmButton',\n removeModalConfirmButtonRemoving:\n 'NegotiableQuote.Manage.removeItemsModal.confirmButtonRemoving',\n removeSuccessHeading:\n 'NegotiableQuote.Manage.removeItemsModal.successHeading',\n removeSuccessMessage:\n 'NegotiableQuote.Manage.removeItemsModal.successMessage',\n removeErrorHeading: 'NegotiableQuote.Manage.removeItemsModal.errorHeading',\n removeErrorMessage: 'NegotiableQuote.Manage.removeItemsModal.errorMessage',\n });\n\n useEffect(() => {\n const quoteDataEvent = events.on(\n 'quote-management/quote-data',\n\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n setQuantityChanges({});\n setNotificationState({ type: null, message: '' });\n setDropdownSelections({});\n },\n\n {\n eager: true,\n }\n );\n return () => quoteDataEvent?.off();\n }, []);\n\n useEffect(() => {\n const quantitiesUpdatedEvent = events.on(\n 'quote-management/quantities-updated',\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n setQuantityChanges({});\n setNotificationState({\n type: 'success',\n message: dictionary.successMessage,\n });\n // Auto-close success notification after 3 seconds\n setTimeout(() => {\n setIsUpdateQuantitiesModalOpen(false);\n setNotificationState({ type: null, message: '' });\n }, 3000);\n }\n );\n return () => quantitiesUpdatedEvent?.off();\n }, [dictionary.successMessage]);\n\n // Listen for quote items removed event\n useEffect(() => {\n const itemsRemovedEvent = events.on(\n 'quote-management/quote-items-removed',\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n setItemsToRemove([]);\n setIsRemoving(false);\n setRemoveNotificationState({\n type: 'success',\n message: dictionary.removeSuccessMessage,\n });\n // Auto-close success notification after 3 seconds\n setTimeout(() => {\n setIsRemoveModalOpen(false);\n setRemoveNotificationState({ type: null, message: '' });\n onRemoveModalStateChange?.(false);\n }, NOTIFICATION_AUTO_DISMISS_DELAY);\n }\n );\n return () => itemsRemovedEvent?.off();\n }, [dictionary.removeSuccessMessage, onRemoveModalStateChange]);\n\n // Unified handler for removing items (single or multiple)\n const handleRemoveItems = useCallback((items: NegotiableQuoteCartItem[]) => {\n if (!items || items.length === 0) {\n return;\n }\n setItemsToRemove(items);\n setRemoveNotificationState({ type: null, message: '' });\n setIsRemoveModalOpen(true);\n }, []);\n\n // Expose handler to parent component\n useEffect(() => {\n onRemoveItemsRef?.(handleRemoveItems);\n }, [handleRemoveItems, onRemoveItemsRef]);\n\n const handleDismissRemoveBanner = () => {\n setRemoveNotificationState({ type: null, message: '' });\n };\n\n const handleItemDropdownChange = (\n item: ProductListTableItem,\n action: string\n ) => {\n const cartItem = item as NegotiableQuoteCartItem;\n // Handle edit action - open line item note modal\n if (action === 'edit') {\n setSelectedItem(cartItem);\n setIsLineItemNoteModalOpen(true);\n // Reset dropdown immediately\n setDropdownSelections((prev) => ({ ...prev, [cartItem.uid]: '' }));\n return;\n }\n\n // Handle remove action\n if (action === 'remove') {\n setDropdownSelections((prev) => ({\n ...prev,\n [cartItem.uid]: action,\n }));\n handleRemoveItems([cartItem]); // Use unified handler\n onItemDropdownChange?.(cartItem, action);\n // Reset dropdown immediately (consistent with edit action)\n setDropdownSelections((prev) => ({ ...prev, [cartItem.uid]: '' }));\n return;\n }\n\n // For any other actions, pass through to parent (but ignore empty/placeholder selections)\n if (action) {\n onItemDropdownChange?.(cartItem, action);\n }\n\n // Clear dropdown selection for non-edit/remove actions\n /* istanbul ignore next: defensive cleanup - custom actions shouldn't have dropdown state due to proper cleanup in edit/remove handlers */\n setDropdownSelections((prev) => {\n if (!(cartItem.uid in prev)) {\n return prev;\n }\n const next = { ...prev };\n delete next[cartItem.uid];\n return next;\n });\n };\n\n const handleConfirmRemove = async () => {\n /* istanbul ignore next */\n if (!quoteData || itemsToRemove.length === 0) {\n return;\n }\n\n const uidsToRemove = itemsToRemove.map((item) => item.uid);\n\n setIsRemoving(true);\n setRemoveNotificationState({ type: null, message: '' });\n\n try {\n await removeNegotiableQuoteItems({\n quoteUid: quoteData.uid,\n quoteItemUids: uidsToRemove,\n });\n // Success is handled by the event listener\n } catch (err) {\n const errorMessage =\n /* istanbul ignore next */\n err instanceof Error ? err.message : dictionary.removeErrorMessage;\n setRemoveNotificationState({\n type: 'error',\n message: errorMessage,\n });\n // Clear dropdown selections for failed items (single item only)\n /* istanbul ignore next */ // UI-driven state; covered by tests but line sometimes mis-attributed in source maps\n if (itemsToRemove.length === 1) {\n const failedItem = itemsToRemove[0];\n setDropdownSelections((prev) => {\n if (!(failedItem.uid in prev)) {\n return prev;\n }\n const next = { ...prev };\n delete next[failedItem.uid];\n return next;\n });\n }\n setIsRemoving(false);\n }\n };\n\n const handleCancelRemove = () => {\n setIsRemoveModalOpen(false);\n setRemoveNotificationState({ type: null, message: '' });\n onRemoveModalStateChange?.(false);\n // Clear dropdown selections for single item cancellation\n /* istanbul ignore next */ // UI-driven state; covered by tests but line sometimes mis-attributed in source maps\n if (itemsToRemove.length === 1) {\n const cancelledItem = itemsToRemove[0];\n setDropdownSelections((prev) => {\n if (!(cancelledItem.uid in prev)) {\n return prev;\n }\n const next = { ...prev };\n delete next[cancelledItem.uid];\n return next;\n });\n }\n setItemsToRemove([]);\n };\n\n // Handle modal close\n const handleModalClose = useCallback(() => {\n // Clean up dropdown selection for the selected item before clearing it\n /* istanbul ignore else: defensive check - selectedItem should always be truthy when modal is open */\n if (selectedItem) {\n setDropdownSelections((prev) => {\n const next = { ...prev };\n delete next[selectedItem.uid];\n return next;\n });\n }\n setIsLineItemNoteModalOpen(false);\n setSelectedItem(null);\n setIsSubmitting(false);\n setModalErrorMessage('');\n }, [selectedItem]);\n\n // Handle modal confirm - submit note and quantity\n const handleModalConfirm = useCallback(\n async (note: string, quantity: number) => {\n /* istanbul ignore next: defensive guard for async race conditions - unreachable in normal flow as modal only renders with selectedItem and quoteData */\n if (!selectedItem || !quoteData) return;\n\n setIsSubmitting(true);\n try {\n // Check if quantity has changed from the original\n const quantityChanged = quantity !== selectedItem.quantity;\n\n // If quantity changed, update it first\n if (quantityChanged) {\n await updateQuantities({\n quoteUid: quoteData.uid,\n items: [{ quoteItemUid: selectedItem.uid, quantity }],\n });\n }\n\n // Then set the line item note\n await setLineItemNote({\n quoteUid: quoteData.uid,\n itemUid: selectedItem.uid,\n note,\n quantity,\n });\n\n // Close modal on success\n handleModalClose();\n } catch (error) {\n console.error('Failed to set line item note:', error);\n // Extract error message from API\n const errorMessage =\n /* istanbul ignore next */\n error instanceof Error\n ? error.message\n : 'Unable to update the item. Please try again.';\n setModalErrorMessage(errorMessage);\n setIsSubmitting(false);\n }\n },\n [selectedItem, quoteData, handleModalClose]\n );\n\n if (!quoteData) {\n return <ItemsQuotedComponent loading={true} />;\n }\n\n const canEdit = Boolean(quoteData.canUpdateQuote);\n\n const handleQuantityChange = (\n item: ProductListTableItem,\n newQuantity: number\n ) => {\n setQuantityChanges((prev) => ({\n ...prev,\n [(item as NegotiableQuoteCartItem).uid]: newQuantity,\n }));\n };\n\n const handleUpdate = (e: SubmitEvent) => {\n e.preventDefault();\n setNotificationState({ type: null, message: '' });\n setIsUpdateQuantitiesModalOpen(true);\n };\n\n const handleConfirmUpdate = async () => {\n /* istanbul ignore next */\n if (!quoteData) {\n return;\n }\n\n if (Object.keys(quantityChanges).length === 0) {\n setIsUpdateQuantitiesModalOpen(false);\n return;\n }\n\n // Clear any previous notifications\n setNotificationState({ type: null, message: '' });\n\n const items = Object.entries(quantityChanges).map(\n ([quoteItemUid, quantity]) => ({\n quoteItemUid,\n quantity,\n })\n );\n\n try {\n await updateQuantities({\n quoteUid: quoteData.uid,\n items,\n });\n // Success is handled by the event listener\n } catch (err) {\n const errorMessage =\n /* istanbul ignore next */\n err instanceof Error ? err.message : dictionary.errorMessage;\n setNotificationState({\n type: 'error',\n message: errorMessage,\n });\n console.error('Failed to update quantities:', err);\n }\n };\n\n const handleCancelUpdate = () => {\n setIsUpdateQuantitiesModalOpen(false);\n setNotificationState({ type: null, message: '' });\n };\n\n const handleDismissBanner = () => {\n setNotificationState({ type: null, message: '' });\n };\n\n const quotePricesSummaryEntries = [];\n\n quoteData.prices.subtotalExcludingTax &&\n quotePricesSummaryEntries.push({\n label: dictionary.subtotal,\n id: 'subtotal',\n value: (\n <Price\n amount={quoteData.prices.subtotalExcludingTax.value}\n currency={quoteData.prices.subtotalExcludingTax.currency}\n weight=\"normal\"\n />\n ),\n });\n\n quoteData.prices.grandTotal &&\n quotePricesSummaryEntries.push({\n label: dictionary.grandTotal,\n id: 'total',\n value: (\n <Price\n amount={quoteData.prices.grandTotal.value}\n currency={quoteData.prices.grandTotal.currency}\n />\n ),\n strong: true,\n });\n\n // Create confirmation banner based on notification state\n const confirmationBanner =\n notificationState.type === 'success' ? (\n <InLineAlert\n type=\"success\"\n variant=\"primary\"\n icon={<CheckWithCircle />}\n heading={dictionary.successHeading}\n description={notificationState.message}\n onDismiss={handleDismissBanner}\n data-testid=\"update-quantities-success-banner\"\n />\n ) : notificationState.type === 'error' ? (\n <InLineAlert\n type=\"error\"\n variant=\"primary\"\n icon={<WarningFilled />}\n heading={dictionary.errorHeading}\n description={notificationState.message}\n onDismiss={handleDismissBanner}\n data-testid=\"update-quantities-error-banner\"\n />\n ) : null;\n\n // Create wrapper that converts ProductListTableItem back to NegotiableQuoteCartItem\n const handleItemCheckboxChange = onItemCheckboxChange\n ? (item: ProductListTableItem, isSelected: boolean) => {\n onItemCheckboxChange(item as NegotiableQuoteCartItem, isSelected);\n }\n : undefined;\n\n // Create remove confirmation banner based on notification state\n const removeConfirmationBanner =\n removeNotificationState.type === 'success' ? (\n <InLineAlert\n type=\"success\"\n variant=\"primary\"\n icon={<CheckWithCircle />}\n heading={dictionary.removeSuccessHeading}\n description={removeNotificationState.message}\n onDismiss={handleDismissRemoveBanner}\n data-testid=\"remove-items-success-banner\"\n />\n ) : removeNotificationState.type === 'error' ? (\n <InLineAlert\n type=\"error\"\n variant=\"primary\"\n icon={<WarningFilled />}\n heading={dictionary.removeErrorHeading}\n description={removeNotificationState.message}\n onDismiss={handleDismissRemoveBanner}\n data-testid=\"remove-items-error-banner\"\n />\n ) : null;\n\n // Create modal error banner\n const modalErrorBanner = modalErrorMessage ? (\n <InLineAlert\n type=\"error\"\n variant=\"primary\"\n icon={<WarningFilled />}\n heading={dictionary.errorHeading}\n description={modalErrorMessage}\n onDismiss={() => setModalErrorMessage('')}\n data-testid=\"line-item-note-error-banner\"\n />\n ) : null;\n\n return (\n <>\n <ItemsQuotedComponent\n data-testid=\"items-quoted-container\"\n {...props}\n loading={false}\n table={\n <Slot\n name=\"ProductListTable\"\n slot={slots?.ProductListTable}\n context={{\n items: quoteData.items,\n canEdit,\n readOnly: quoteData.readOnly,\n onItemCheckboxChange,\n onItemDropdownChange: handleItemDropdownChange,\n onQuantityChange: handleQuantityChange,\n onUpdate: handleUpdate,\n dropdownSelections,\n }}\n >\n <ProductListTable\n items={quoteData.items}\n canEdit={canEdit}\n onItemCheckboxChange={handleItemCheckboxChange}\n readOnly={quoteData.readOnly}\n onItemDropdownChange={handleItemDropdownChange}\n onQuantityChange={handleQuantityChange}\n onUpdate={handleUpdate}\n dropdownSelections={dropdownSelections}\n />\n </Slot>\n }\n pricesSummary={\n <Slot\n name=\"QuotePricesSummary\"\n slot={slots?.QuotePricesSummary}\n context={{\n items: quoteData.items,\n prices: quoteData.prices,\n }}\n >\n <QuotePricesSummary entries={quotePricesSummaryEntries} />\n </Slot>\n }\n />\n\n {/* Update Quantities Modal */}\n <ConfirmationModal\n open={isUpdateQuantitiesModalOpen}\n title={dictionary.modalTitle}\n message={dictionary.modalDescription}\n cancelLabel={dictionary.modalCancelButton}\n confirmLabel={dictionary.modalUpdateButton}\n onCancel={handleCancelUpdate}\n onConfirm={handleConfirmUpdate}\n confirmationBanner={confirmationBanner}\n data-testid=\"update-quantities-modal\"\n />\n\n {/* Remove Items Modal */}\n <ConfirmationModal\n open={isRemoveModalOpen}\n title={dictionary.removeModalTitle}\n message={dictionary.removeModalDescription}\n cancelLabel={dictionary.removeModalCancelButton}\n confirmLabel={\n isRemoving\n ? dictionary.removeModalConfirmButtonRemoving\n : dictionary.removeModalConfirmButton\n }\n onCancel={handleCancelRemove}\n onConfirm={handleConfirmRemove}\n confirmationBanner={removeConfirmationBanner}\n data-testid=\"remove-items-modal\"\n />\n {/* Line Item Note Modal */}\n {selectedItem && (\n <LineItemNoteModal\n open={isLineItemNoteModalOpen}\n item={selectedItem}\n onClose={handleModalClose}\n onConfirm={handleModalConfirm}\n isSubmitting={isSubmitting}\n errorBanner={modalErrorBanner || undefined}\n />\n )}\n </>\n );\n};\n"],"names":["NOTIFICATION_AUTO_DISMISS_DELAY","ItemsQuoted","initialData","onItemCheckboxChange","onItemDropdownChange","onRemoveItemsRef","onRemoveModalStateChange","slots","props","quoteData","setQuoteData","useState","quantityChanges","setQuantityChanges","selectedItem","setSelectedItem","isUpdateQuantitiesModalOpen","setIsUpdateQuantitiesModalOpen","isLineItemNoteModalOpen","setIsLineItemNoteModalOpen","modalErrorMessage","setModalErrorMessage","notificationState","setNotificationState","isRemoveModalOpen","setIsRemoveModalOpen","itemsToRemove","setItemsToRemove","isRemoving","setIsRemoving","removeNotificationState","setRemoveNotificationState","dropdownSelections","setDropdownSelections","isSubmitting","setIsSubmitting","dictionary","useText","useEffect","quoteDataEvent","events","data","quantitiesUpdatedEvent","itemsRemovedEvent","handleRemoveItems","useCallback","items","handleDismissRemoveBanner","handleItemDropdownChange","item","action","cartItem","prev","next","handleConfirmRemove","uidsToRemove","removeNegotiableQuoteItems","err","errorMessage","failedItem","handleCancelRemove","cancelledItem","handleModalClose","handleModalConfirm","note","quantity","updateQuantities","setLineItemNote","error","jsx","ItemsQuotedComponent","canEdit","handleQuantityChange","newQuantity","handleUpdate","e","handleConfirmUpdate","quoteItemUid","handleCancelUpdate","handleDismissBanner","quotePricesSummaryEntries","Price","confirmationBanner","InLineAlert","CheckWithCircle","WarningFilled","handleItemCheckboxChange","isSelected","removeConfirmationBanner","modalErrorBanner","jsxs","Fragment","Slot","ProductListTable","QuotePricesSummary","ConfirmationModal","LineItemNoteModal"],"mappings":"qtBAmCA,MAAMA,GAAkC,IA4C3BC,GAA2C,CAAC,CACvD,UAAWC,GACX,qBAAAC,EACA,qBAAAC,EACA,iBAAAC,EACA,yBAAAC,EACA,MAAAC,EACA,GAAGC,EACL,IAAM,CACJ,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAChCT,EAAA,EAEI,CAACU,EAAiBC,CAAkB,EAAIF,EAE3C,CAAA,CAAE,EACC,CAACG,EAAcC,CAAe,EAClCJ,EAAyC,IAAI,EACzC,CAACK,GAA6BC,CAA8B,EAChEN,EAAS,EAAK,EACV,CAACO,GAAyBC,CAA0B,EAAIR,EAAS,EAAK,EACtE,CAACS,EAAmBC,CAAoB,EAAIV,EAAS,EAAE,EACvD,CAACW,EAAmBC,CAAoB,EAAIZ,EAG/C,CAAE,KAAM,KAAM,QAAS,GAAI,EAExB,CAACa,GAAmBC,CAAoB,EAAId,EAAS,EAAK,EAC1D,CAACe,EAAeC,CAAgB,EAAIhB,EACxC,CAAA,CAAC,EAEG,CAACiB,GAAYC,CAAa,EAAIlB,EAAS,EAAK,EAC5C,CAACmB,EAAyBC,CAA0B,EAAIpB,EAG3D,CAAE,KAAM,KAAM,QAAS,GAAI,EACxB,CAACqB,EAAoBC,CAAqB,EAAItB,EAElD,CAAA,CAAE,EACE,CAACuB,GAAcC,CAAe,EAAIxB,EAAS,EAAK,EAEhDyB,EAAaC,GAAQ,CACzB,SAAU,kEACV,WACE,oEACF,aAAc,yDACd,WAAY,qDACZ,iBACE,2DACF,kBACE,4DACF,kBACE,4DACF,eACE,8DACF,eACE,8DACF,aAAc,4DACd,aA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ACpB,YAAaA,EAAW,kBACxB,aAAcA,EAAW,kBACzB,SAAU0C,GACV,UAAWF,GACX,mBAAAM,GACA,cAAY,yBAAA,CAAA,EAIdb,EAAC0B,EAAA,CACC,KAAMvE,GACN,MAAOY,EAAW,iBAClB,QAASA,EAAW,uBACpB,YAAaA,EAAW,wBACxB,aACER,GACIQ,EAAW,iCACXA,EAAW,yBAEjB,SAAUwB,GACV,UAAWN,GACX,mBAAoBkC,GACpB,cAAY,oBAAA,CAAA,EAGb1E,GACCuD,EAAC2B,GAAA,CACC,KAAM9E,GACN,KAAMJ,EACN,QAASgD,EACT,UAAWC,GACX,aAAA7B,GACA,YAAauD,IAAoB,MAAA,CAAA,CACnC,EAEJ,CAEJ"}
|
|
1
|
+
{"version":3,"file":"ItemsQuoted.js","sources":["/@dropins/storefront-quote-management/src/containers/ItemsQuoted/ItemsQuoted.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 {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Price, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n NegotiableQuoteModel,\n CartItemModel,\n} from '@/quote-management/data/models/negotiable-quote-model';\nimport {\n ProductListTable,\n QuotePricesSummary,\n ItemsQuoted as ItemsQuotedComponent,\n} from '@/quote-management/components';\nimport { CheckWithCircle, WarningFilled } from '@adobe-commerce/elsie/icons';\nimport { ConfirmationModal } from '@/quote-management/components/ConfirmationModal';\nimport { LineItemNoteModal } from '@/quote-management/components/LineItemNoteModal';\nimport { updateQuantities, setLineItemNote } from '@/quote-management/api';\nimport { removeNegotiableQuoteItems } from '@/quote-management/api/removeNegotiableQuoteItems';\n\nconst NOTIFICATION_AUTO_DISMISS_DELAY = 3000;\n\nexport interface ItemsQuotedProps extends HTMLAttributes<HTMLDivElement> {\n quoteData?: NegotiableQuoteModel;\n onItemCheckboxChange?: (\n item: CartItemModel,\n isSelected: boolean\n ) => void;\n onItemDropdownChange?: (\n item: CartItemModel,\n action: string\n ) => void;\n onUpdate?: (e: SubmitEvent) => void;\n onRemoveItemsRef?: (\n handler: (items: CartItemModel[]) => void\n ) => void;\n onRemoveModalStateChange?: (isOpen: boolean) => void;\n slots?: {\n ProductListTable?: SlotProps<{\n items: NegotiableQuoteModel['items'];\n canEdit: boolean;\n readOnly?: boolean;\n onItemCheckboxChange?: (\n item: CartItemModel,\n isSelected: boolean\n ) => void;\n onItemDropdownChange?: (\n item: CartItemModel,\n action: string\n ) => void;\n onQuantityChange?: (\n item: CartItemModel,\n newQuantity: number\n ) => void;\n onUpdate?: (e: SubmitEvent) => void;\n dropdownSelections?: Record<string, string | undefined>;\n }>;\n QuotePricesSummary?: SlotProps<{\n items: NegotiableQuoteModel['items'];\n prices: NegotiableQuoteModel['prices'];\n }>;\n };\n}\n\nexport const ItemsQuoted: Container<ItemsQuotedProps> = ({\n quoteData: initialData,\n onItemCheckboxChange,\n onItemDropdownChange,\n onRemoveItemsRef,\n onRemoveModalStateChange,\n slots,\n ...props\n}) => {\n const [quoteData, setQuoteData] = useState<NegotiableQuoteModel | undefined>(\n initialData\n );\n const [quantityChanges, setQuantityChanges] = useState<{\n [itemUid: string]: number;\n }>({});\n const [selectedItem, setSelectedItem] =\n useState<CartItemModel | null>(null);\n const [isUpdateQuantitiesModalOpen, setIsUpdateQuantitiesModalOpen] =\n useState(false);\n const [isLineItemNoteModalOpen, setIsLineItemNoteModalOpen] = useState(false);\n const [modalErrorMessage, setModalErrorMessage] = useState('');\n const [notificationState, setNotificationState] = useState<{\n type: 'success' | 'error' | null;\n message: string;\n }>({ type: null, message: '' });\n // State for remove items functionality\n const [isRemoveModalOpen, setIsRemoveModalOpen] = useState(false);\n const [itemsToRemove, setItemsToRemove] = useState<CartItemModel[]>(\n []\n );\n const [isRemoving, setIsRemoving] = useState(false);\n const [removeNotificationState, setRemoveNotificationState] = useState<{\n type: 'success' | 'error' | null;\n message: string;\n }>({ type: null, message: '' });\n const [dropdownSelections, setDropdownSelections] = useState<\n Record<string, string>\n >({});\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const dictionary = useText({\n subtotal: 'NegotiableQuote.Manage.quotePricesSummary.subtotal.excludingTax',\n grandTotal:\n 'NegotiableQuote.Manage.quotePricesSummary.grandTotal.includingTax',\n appliedTaxes: 'NegotiableQuote.Manage.quotePricesSummary.appliedTaxes',\n modalTitle: 'NegotiableQuote.Manage.updateQuantitiesModal.title',\n modalDescription:\n 'NegotiableQuote.Manage.updateQuantitiesModal.description',\n modalCancelButton:\n 'NegotiableQuote.Manage.updateQuantitiesModal.cancelButton',\n modalUpdateButton:\n 'NegotiableQuote.Manage.updateQuantitiesModal.updateButton',\n successHeading:\n 'NegotiableQuote.Manage.updateQuantitiesModal.successHeading',\n successMessage:\n 'NegotiableQuote.Manage.updateQuantitiesModal.successMessage',\n errorHeading: 'NegotiableQuote.Manage.updateQuantitiesModal.errorHeading',\n errorMessage: 'NegotiableQuote.Manage.updateQuantitiesModal.errorMessage',\n removeModalTitle: 'NegotiableQuote.Manage.removeItemsModal.title',\n removeModalDescription:\n 'NegotiableQuote.Manage.removeItemsModal.description',\n removeModalCancelButton:\n 'NegotiableQuote.Manage.removeItemsModal.cancelButton',\n removeModalConfirmButton:\n 'NegotiableQuote.Manage.removeItemsModal.confirmButton',\n removeModalConfirmButtonRemoving:\n 'NegotiableQuote.Manage.removeItemsModal.confirmButtonRemoving',\n removeSuccessHeading:\n 'NegotiableQuote.Manage.removeItemsModal.successHeading',\n removeSuccessMessage:\n 'NegotiableQuote.Manage.removeItemsModal.successMessage',\n removeErrorHeading: 'NegotiableQuote.Manage.removeItemsModal.errorHeading',\n removeErrorMessage: 'NegotiableQuote.Manage.removeItemsModal.errorMessage',\n });\n\n useEffect(() => {\n const quoteDataEvent = events.on(\n 'quote-management/quote-data',\n\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n setQuantityChanges({});\n setNotificationState({ type: null, message: '' });\n setDropdownSelections({});\n },\n\n {\n eager: true,\n }\n );\n return () => quoteDataEvent?.off();\n }, []);\n\n useEffect(() => {\n const quantitiesUpdatedEvent = events.on(\n 'quote-management/quantities-updated',\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n setQuantityChanges({});\n setNotificationState({\n type: 'success',\n message: dictionary.successMessage,\n });\n // Auto-close success notification after 3 seconds\n setTimeout(() => {\n setIsUpdateQuantitiesModalOpen(false);\n setNotificationState({ type: null, message: '' });\n }, 3000);\n }\n );\n return () => quantitiesUpdatedEvent?.off();\n }, [dictionary.successMessage]);\n\n // Listen for quote items removed event\n useEffect(() => {\n const itemsRemovedEvent = events.on(\n 'quote-management/quote-items-removed',\n (data: { quote: NegotiableQuoteModel }) => {\n setQuoteData(data.quote);\n setItemsToRemove([]);\n setIsRemoving(false);\n setRemoveNotificationState({\n type: 'success',\n message: dictionary.removeSuccessMessage,\n });\n // Auto-close success notification after 3 seconds\n setTimeout(() => {\n setIsRemoveModalOpen(false);\n setRemoveNotificationState({ type: null, message: '' });\n onRemoveModalStateChange?.(false);\n }, NOTIFICATION_AUTO_DISMISS_DELAY);\n }\n );\n return () => itemsRemovedEvent?.off();\n }, [dictionary.removeSuccessMessage, onRemoveModalStateChange]);\n\n // Unified handler for removing items (single or multiple)\n const handleRemoveItems = useCallback((items: CartItemModel[]) => {\n if (!items || items.length === 0) {\n return;\n }\n setItemsToRemove(items);\n setRemoveNotificationState({ type: null, message: '' });\n setIsRemoveModalOpen(true);\n }, []);\n\n // Expose handler to parent component\n useEffect(() => {\n onRemoveItemsRef?.(handleRemoveItems);\n }, [handleRemoveItems, onRemoveItemsRef]);\n\n const handleDismissRemoveBanner = () => {\n setRemoveNotificationState({ type: null, message: '' });\n };\n\n const handleItemDropdownChange = (\n item: CartItemModel,\n action: string\n ) => {\n const cartItem = item;\n // Handle edit action - open line item note modal\n if (action === 'edit') {\n setSelectedItem(cartItem);\n setIsLineItemNoteModalOpen(true);\n // Reset dropdown immediately\n setDropdownSelections((prev) => ({ ...prev, [cartItem.uid]: '' }));\n return;\n }\n\n // Handle remove action\n if (action === 'remove') {\n setDropdownSelections((prev) => ({\n ...prev,\n [cartItem.uid]: action,\n }));\n handleRemoveItems([cartItem]); // Use unified handler\n onItemDropdownChange?.(cartItem, action);\n // Reset dropdown immediately (consistent with edit action)\n setDropdownSelections((prev) => ({ ...prev, [cartItem.uid]: '' }));\n return;\n }\n\n // For any other actions, pass through to parent (but ignore empty/placeholder selections)\n if (action) {\n onItemDropdownChange?.(cartItem, action);\n }\n\n // Clear dropdown selection for non-edit/remove actions\n /* istanbul ignore next: defensive cleanup - custom actions shouldn't have dropdown state due to proper cleanup in edit/remove handlers */\n setDropdownSelections((prev) => {\n if (!(cartItem.uid in prev)) {\n return prev;\n }\n const next = { ...prev };\n delete next[cartItem.uid];\n return next;\n });\n };\n\n const handleConfirmRemove = async () => {\n /* istanbul ignore next */\n if (!quoteData || itemsToRemove.length === 0) {\n return;\n }\n\n const uidsToRemove = itemsToRemove.map((item) => item.uid);\n\n setIsRemoving(true);\n setRemoveNotificationState({ type: null, message: '' });\n\n try {\n await removeNegotiableQuoteItems({\n quoteUid: quoteData.uid,\n quoteItemUids: uidsToRemove,\n });\n // Success is handled by the event listener\n } catch (err) {\n const errorMessage =\n /* istanbul ignore next */\n err instanceof Error ? err.message : dictionary.removeErrorMessage;\n setRemoveNotificationState({\n type: 'error',\n message: errorMessage,\n });\n // Clear dropdown selections for failed items (single item only)\n /* istanbul ignore next */ // UI-driven state; covered by tests but line sometimes mis-attributed in source maps\n if (itemsToRemove.length === 1) {\n const failedItem = itemsToRemove[0];\n setDropdownSelections((prev) => {\n if (!(failedItem.uid in prev)) {\n return prev;\n }\n const next = { ...prev };\n delete next[failedItem.uid];\n return next;\n });\n }\n setIsRemoving(false);\n }\n };\n\n const handleCancelRemove = () => {\n setIsRemoveModalOpen(false);\n setRemoveNotificationState({ type: null, message: '' });\n onRemoveModalStateChange?.(false);\n // Clear dropdown selections for single item cancellation\n /* istanbul ignore next */ // UI-driven state; covered by tests but line sometimes mis-attributed in source maps\n if (itemsToRemove.length === 1) {\n const cancelledItem = itemsToRemove[0];\n setDropdownSelections((prev) => {\n if (!(cancelledItem.uid in prev)) {\n return prev;\n }\n const next = { ...prev };\n delete next[cancelledItem.uid];\n return next;\n });\n }\n setItemsToRemove([]);\n };\n\n // Handle modal close\n const handleModalClose = useCallback(() => {\n // Clean up dropdown selection for the selected item before clearing it\n /* istanbul ignore else: defensive check - selectedItem should always be truthy when modal is open */\n if (selectedItem) {\n setDropdownSelections((prev) => {\n const next = { ...prev };\n delete next[selectedItem.uid];\n return next;\n });\n }\n setIsLineItemNoteModalOpen(false);\n setSelectedItem(null);\n setIsSubmitting(false);\n setModalErrorMessage('');\n }, [selectedItem]);\n\n // Handle modal confirm - submit note and quantity\n const handleModalConfirm = useCallback(\n async (note: string, quantity: number) => {\n /* istanbul ignore next: defensive guard for async race conditions - unreachable in normal flow as modal only renders with selectedItem and quoteData */\n if (!selectedItem || !quoteData) return;\n\n setIsSubmitting(true);\n try {\n // Check if quantity has changed from the original\n const quantityChanged = quantity !== selectedItem.quantity;\n\n // If quantity changed, update it first\n if (quantityChanged) {\n await updateQuantities({\n quoteUid: quoteData.uid,\n items: [{ quoteItemUid: selectedItem.uid, quantity }],\n });\n }\n\n // Then set the line item note\n await setLineItemNote({\n quoteUid: quoteData.uid,\n itemUid: selectedItem.uid,\n note,\n quantity,\n });\n\n // Close modal on success\n handleModalClose();\n } catch (error) {\n console.error('Failed to set line item note:', error);\n // Extract error message from API\n const errorMessage =\n /* istanbul ignore next */\n error instanceof Error\n ? error.message\n : 'Unable to update the item. Please try again.';\n setModalErrorMessage(errorMessage);\n setIsSubmitting(false);\n }\n },\n [selectedItem, quoteData, handleModalClose]\n );\n\n if (!quoteData) {\n return <ItemsQuotedComponent loading={true} />;\n }\n\n const canEdit = Boolean(quoteData.canUpdateQuote);\n\n const handleQuantityChange = (\n item: CartItemModel,\n newQuantity: number\n ) => {\n setQuantityChanges((prev) => ({\n ...prev,\n [item.uid]: newQuantity,\n }));\n };\n\n const handleUpdate = (e: SubmitEvent) => {\n e.preventDefault();\n setNotificationState({ type: null, message: '' });\n setIsUpdateQuantitiesModalOpen(true);\n };\n\n const handleConfirmUpdate = async () => {\n /* istanbul ignore next */\n if (!quoteData) {\n return;\n }\n\n if (Object.keys(quantityChanges).length === 0) {\n setIsUpdateQuantitiesModalOpen(false);\n return;\n }\n\n // Clear any previous notifications\n setNotificationState({ type: null, message: '' });\n\n const items = Object.entries(quantityChanges).map(\n ([quoteItemUid, quantity]) => ({\n quoteItemUid,\n quantity,\n })\n );\n\n try {\n await updateQuantities({\n quoteUid: quoteData.uid,\n items,\n });\n // Success is handled by the event listener\n } catch (err) {\n const errorMessage =\n /* istanbul ignore next */\n err instanceof Error ? err.message : dictionary.errorMessage;\n setNotificationState({\n type: 'error',\n message: errorMessage,\n });\n console.error('Failed to update quantities:', err);\n }\n };\n\n const handleCancelUpdate = () => {\n setIsUpdateQuantitiesModalOpen(false);\n setNotificationState({ type: null, message: '' });\n };\n\n const handleDismissBanner = () => {\n setNotificationState({ type: null, message: '' });\n };\n\n const quotePricesSummaryEntries = [];\n\n quoteData.prices.subtotalExcludingTax &&\n quotePricesSummaryEntries.push({\n label: dictionary.subtotal,\n id: 'subtotal',\n value: (\n <Price\n amount={quoteData.prices.subtotalExcludingTax.value}\n currency={quoteData.prices.subtotalExcludingTax.currency}\n weight=\"normal\"\n />\n ),\n });\n\n quoteData.prices.grandTotal &&\n quotePricesSummaryEntries.push({\n label: dictionary.grandTotal,\n id: 'total',\n value: (\n <Price\n amount={quoteData.prices.grandTotal.value}\n currency={quoteData.prices.grandTotal.currency}\n />\n ),\n strong: true,\n });\n\n // Create confirmation banner based on notification state\n const confirmationBanner =\n notificationState.type === 'success' ? (\n <InLineAlert\n type=\"success\"\n variant=\"primary\"\n icon={<CheckWithCircle />}\n heading={dictionary.successHeading}\n description={notificationState.message}\n onDismiss={handleDismissBanner}\n data-testid=\"update-quantities-success-banner\"\n />\n ) : notificationState.type === 'error' ? (\n <InLineAlert\n type=\"error\"\n variant=\"primary\"\n icon={<WarningFilled />}\n heading={dictionary.errorHeading}\n description={notificationState.message}\n onDismiss={handleDismissBanner}\n data-testid=\"update-quantities-error-banner\"\n />\n ) : null;\n\n // Create wrapper for checkbox change handler\n const handleItemCheckboxChange = onItemCheckboxChange\n ? (item: CartItemModel, isSelected: boolean) => {\n onItemCheckboxChange(item, isSelected);\n }\n : undefined;\n\n // Create remove confirmation banner based on notification state\n const removeConfirmationBanner =\n removeNotificationState.type === 'success' ? (\n <InLineAlert\n type=\"success\"\n variant=\"primary\"\n icon={<CheckWithCircle />}\n heading={dictionary.removeSuccessHeading}\n description={removeNotificationState.message}\n onDismiss={handleDismissRemoveBanner}\n data-testid=\"remove-items-success-banner\"\n />\n ) : removeNotificationState.type === 'error' ? (\n <InLineAlert\n type=\"error\"\n variant=\"primary\"\n icon={<WarningFilled />}\n heading={dictionary.removeErrorHeading}\n description={removeNotificationState.message}\n onDismiss={handleDismissRemoveBanner}\n data-testid=\"remove-items-error-banner\"\n />\n ) : null;\n\n // Create modal error banner\n const modalErrorBanner = modalErrorMessage ? (\n <InLineAlert\n type=\"error\"\n variant=\"primary\"\n icon={<WarningFilled />}\n heading={dictionary.errorHeading}\n description={modalErrorMessage}\n onDismiss={() => setModalErrorMessage('')}\n data-testid=\"line-item-note-error-banner\"\n />\n ) : null;\n\n return (\n <>\n <ItemsQuotedComponent\n data-testid=\"items-quoted-container\"\n {...props}\n loading={false}\n table={\n <Slot\n name=\"ProductListTable\"\n slot={slots?.ProductListTable}\n context={{\n items: quoteData.items,\n canEdit,\n readOnly: quoteData.readOnly,\n onItemCheckboxChange,\n onItemDropdownChange: handleItemDropdownChange,\n onQuantityChange: handleQuantityChange,\n onUpdate: handleUpdate,\n dropdownSelections,\n }}\n >\n <ProductListTable\n items={quoteData.items}\n canEdit={canEdit}\n onItemCheckboxChange={handleItemCheckboxChange}\n readOnly={quoteData.readOnly}\n onItemDropdownChange={handleItemDropdownChange}\n onQuantityChange={handleQuantityChange}\n onUpdate={handleUpdate}\n dropdownSelections={dropdownSelections}\n />\n </Slot>\n }\n pricesSummary={\n <Slot\n name=\"QuotePricesSummary\"\n slot={slots?.QuotePricesSummary}\n context={{\n items: quoteData.items,\n prices: quoteData.prices,\n }}\n >\n <QuotePricesSummary entries={quotePricesSummaryEntries} />\n </Slot>\n }\n />\n\n {/* Update Quantities Modal */}\n <ConfirmationModal\n open={isUpdateQuantitiesModalOpen}\n title={dictionary.modalTitle}\n message={dictionary.modalDescription}\n cancelLabel={dictionary.modalCancelButton}\n confirmLabel={dictionary.modalUpdateButton}\n onCancel={handleCancelUpdate}\n onConfirm={handleConfirmUpdate}\n confirmationBanner={confirmationBanner}\n data-testid=\"update-quantities-modal\"\n />\n\n {/* Remove Items Modal */}\n <ConfirmationModal\n open={isRemoveModalOpen}\n title={dictionary.removeModalTitle}\n message={dictionary.removeModalDescription}\n cancelLabel={dictionary.removeModalCancelButton}\n confirmLabel={\n isRemoving\n ? dictionary.removeModalConfirmButtonRemoving\n : dictionary.removeModalConfirmButton\n }\n onCancel={handleCancelRemove}\n onConfirm={handleConfirmRemove}\n confirmationBanner={removeConfirmationBanner}\n data-testid=\"remove-items-modal\"\n />\n {/* Line Item Note Modal */}\n {selectedItem && (\n <LineItemNoteModal\n open={isLineItemNoteModalOpen}\n item={selectedItem}\n onClose={handleModalClose}\n onConfirm={handleModalConfirm}\n isSubmitting={isSubmitting}\n errorBanner={modalErrorBanner || undefined}\n />\n )}\n </>\n );\n};\n"],"names":["NOTIFICATION_AUTO_DISMISS_DELAY","ItemsQuoted","initialData","onItemCheckboxChange","onItemDropdownChange","onRemoveItemsRef","onRemoveModalStateChange","slots","props","quoteData","setQuoteData","useState","quantityChanges","setQuantityChanges","selectedItem","setSelectedItem","isUpdateQuantitiesModalOpen","setIsUpdateQuantitiesModalOpen","isLineItemNoteModalOpen","setIsLineItemNoteModalOpen","modalErrorMessage","setModalErrorMessage","notificationState","setNotificationState","isRemoveModalOpen","setIsRemoveModalOpen","itemsToRemove","setItemsToRemove","isRemoving","setIsRemoving","removeNotificationState","setRemoveNotificationState","dropdownSelections","setDropdownSelections","isSubmitting","setIsSubmitting","dictionary","useText","useEffect","quoteDataEvent","events","data","quantitiesUpdatedEvent","itemsRemovedEvent","handleRemoveItems","useCallback","items","handleDismissRemoveBanner","handleItemDropdownChange","item","action","cartItem","prev","next","handleConfirmRemove","uidsToRemove","removeNegotiableQuoteItems","err","errorMessage","failedItem","handleCancelRemove","cancelledItem","handleModalClose","handleModalConfirm","note","quantity","updateQuantities","setLineItemNote","error","jsx","ItemsQuotedComponent","canEdit","handleQuantityChange","newQuantity","handleUpdate","e","handleConfirmUpdate","quoteItemUid","handleCancelUpdate","handleDismissBanner","quotePricesSummaryEntries","Price","confirmationBanner","InLineAlert","CheckWithCircle","WarningFilled","handleItemCheckboxChange","isSelected","removeConfirmationBanner","modalErrorBanner","jsxs","Fragment","Slot","ProductListTable","QuotePricesSummary","ConfirmationModal","LineItemNoteModal"],"mappings":"uvBAkCA,MAAMA,GAAkC,IA4C3BC,GAA2C,CAAC,CACvD,UAAWC,GACX,qBAAAC,EACA,qBAAAC,EACA,iBAAAC,EACA,yBAAAC,EACA,MAAAC,EACA,GAAGC,EACL,IAAM,CACJ,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAChCT,EAAA,EAEI,CAACU,EAAiBC,CAAkB,EAAIF,EAE3C,CAAA,CAAE,EACC,CAACG,EAAcC,CAAe,EAClCJ,EAA+B,IAAI,EAC/B,CAACK,GAA6BC,CAA8B,EAChEN,EAAS,EAAK,EAC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KAAMrF,GAAA,YAAAA,EAAO,iBACb,QAAS,CACP,MAAOE,EAAU,MACjB,QAAA8D,EACA,SAAU9D,EAAU,SACpB,qBAAAN,EACA,qBAAsB6C,EACtB,iBAAkBwB,EAClB,SAAUE,EACV,mBAAA1C,CAAA,EAGF,SAAAqC,EAACwB,GAAA,CACC,MAAOpF,EAAU,MACjB,QAAA8D,EACA,qBAAsBe,GACtB,SAAU7E,EAAU,SACpB,qBAAsBuC,EACtB,iBAAkBwB,EAClB,SAAUE,EACV,mBAAA1C,CAAA,CAAA,CACF,CAAA,EAGJ,cACEqC,EAACuB,EAAA,CACC,KAAK,qBACL,KAAMrF,GAAA,YAAAA,EAAO,mBACb,QAAS,CACP,MAAOE,EAAU,MACjB,OAAQA,EAAU,MAAA,EAGpB,SAAA4D,EAACyB,GAAA,CAAmB,QAASd,CAAA,CAA2B,CAAA,CAAA,CAC1D,CAAA,EAKJX,EAAC0B,EAAA,CACC,KAAM/E,GACN,MAAOoB,EAAW,WAClB,QAASA,EAAW,iBACpB,YAAaA,EAAW,kBACxB,aAAcA,EAAW,kBACzB,SAAU0C,GACV,UAAWF,GACX,mBAAAM,GACA,cAAY,yBAAA,CAAA,EAIdb,EAAC0B,EAAA,CACC,KAAMvE,GACN,MAAOY,EAAW,iBAClB,QAASA,EAAW,uBACpB,YAAaA,EAAW,wBACxB,aACER,GACIQ,EAAW,iCACXA,EAAW,yBAEjB,SAAUwB,GACV,UAAWN,GACX,mBAAoBkC,GACpB,cAAY,oBAAA,CAAA,EAGb1E,GACCuD,EAAC2B,GAAA,CACC,KAAM9E,GACN,KAAMJ,EACN,QAASgD,EACT,UAAWC,GACX,aAAA7B,GACA,YAAauD,IAAoB,MAAA,CAAA,CACnC,EAEJ,CAEJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as o,jsxs as ne,Fragment as se}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useEffect as O,useCallback as p}from"@dropins/tools/preact-compat.js";import{Slot as W}from"@dropins/tools/lib.js";import{events as H}from"@dropins/tools/event-bus.js";import{InLineAlert as B,Price as Y}from"@dropins/tools/components.js";/* empty css */import{I as $,Q as re,P as ie,L as le}from"./LineItemNoteModal.js";import{C as me}from"./ConfirmationModal.js";/* empty css *//* empty css */import"./state.js";import{r as de,u as ue,a as ce}from"./addQuoteTemplateLineItemNote.js";import{S as z
|
|
3
|
+
import{jsx as o,jsxs as ne,Fragment as se}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useEffect as O,useCallback as p}from"@dropins/tools/preact-compat.js";import{Slot as W}from"@dropins/tools/lib.js";import{events as H}from"@dropins/tools/event-bus.js";import{InLineAlert as B,Price as Y}from"@dropins/tools/components.js";/* empty css */import{I as $,Q as re,P as ie,L as le}from"./LineItemNoteModal.js";import{C as me}from"./ConfirmationModal.js";/* empty css *//* empty css */import"./state.js";import{r as de,u as ue,a as ce}from"./addQuoteTemplateLineItemNote.js";import{S as z}from"./CheckWithCircle.js";import{S as U}from"./WarningFilled.js";import{useText as pe}from"@dropins/tools/i18n.js";const ge=3e3,Me=b=>{const{templateId:r,onRemoveModalStateChange:a,removeSuccessMessage:e,removeErrorMessage:T}=b,[i,g]=l(!1),[M,s]=l([]),[u,m]=l(!1),[S,n]=l({type:null,message:""});O(()=>{const d=H.on("quote-management/quote-template-data",()=>{s([]),m(!1),n({type:"success",message:e}),setTimeout(()=>{g(!1),n({type:null,message:""}),a==null||a(!1)},ge)});return()=>d==null?void 0:d.off()},[e,a]);const N=p(d=>{!d||d.length===0||(s(d),n({type:null,message:""}),g(!0))},[]),Q=p(async()=>{if(!r||M.length===0)return;const d=M.map(I=>I.uid).filter(Boolean);if(d.length!==0){m(!0),n({type:null,message:""});try{await de({templateId:r,itemUids:d})}catch(I){const c=I instanceof Error?I.message:T;n({type:"error",message:c}),m(!1)}}},[r,M,T]),t=p(()=>{g(!1),n({type:null,message:""}),a==null||a(!1),s([])},[a]);return{handleRemoveItems:N,handleConfirmRemove:Q,handleCancelRemove:t,isRemoveModalOpen:i,itemsToRemove:M,isRemoving:u,removeNotificationState:S}},fe=b=>{const{handleRemoveItems:r}=b,[a,e]=l({}),T=p(()=>{},[]),i=p((g,M)=>{const s=g;if(M==="remove"){e(u=>({...u,[s.uid||""]:M})),r([s]),e(u=>({...u,[s.uid||""]:""}));return}e(u=>{if(!s.uid||!(s.uid in u))return u;const m={...u};return delete m[s.uid],m})},[r]);return{dropdownSelections:a,handleItemDropdownChange:i,handleDismissRemoveBanner:T}},ve=3e3,Te=b=>{const{templateId:r,onUpdateModalStateChange:a,updateSuccessMessage:e,updateErrorMessage:T}=b,[i,g]=l({}),[M,s]=l(!1),[u,m]=l(!1),[S,n]=l({type:null,message:""});O(()=>{const c=H.on("quote-management/quote-template-data",()=>{g({}),m(!1),n({type:"success",message:e}),setTimeout(()=>{s(!1),n({type:null,message:""}),a==null||a(!1)},ve)});return()=>c==null?void 0:c.off()},[e,a]);const N=p((c,y)=>{const h=c;if(!h.uid)return;const C=h.uid;g(R=>({...R,[C]:y}))},[]),Q=p(c=>{c.preventDefault(),n({type:null,message:""}),s(!0)},[]),t=p(async()=>{if(!r||Object.keys(i).length===0){s(!1);return}m(!0),n({type:null,message:""});const c=Object.entries(i).map(([y,h])=>({itemId:y,quantity:h}));try{await ue({templateId:r,items:c})}catch(y){const h=y instanceof Error?y.message:T;n({type:"error",message:h}),m(!1)}},[r,i,T]),d=p(()=>{s(!1),n({type:null,message:""}),a==null||a(!1),g({})},[a]),I=p(()=>{n({type:null,message:""})},[]);return{quantityChanges:i,handleQuantityChange:N,handleUpdate:Q,handleConfirmUpdate:t,handleCancelUpdate:d,handleDismissBanner:I,isUpdateModalOpen:M,isUpdating:u,updateNotificationState:S}},Oe=({templateData:b,slots:r,...a})=>{const[e,T]=l(b),[i,g]=l(null),[M,s]=l(!1),[u,m]=l(!1),[S,n]=l(""),[N,Q]=l({}),t=pe({subtotal:"NegotiableQuoteTemplate.Manage.quotePricesSummary.subtotal.excludingTax",grandTotal:"NegotiableQuoteTemplate.Manage.quotePricesSummary.grandTotal.includingTax",appliedTaxes:"NegotiableQuoteTemplate.Manage.quotePricesSummary.appliedTaxes",removeModalTitle:"NegotiableQuoteTemplate.Manage.removeItemsModal.title",removeModalDescription:"NegotiableQuoteTemplate.Manage.removeItemsModal.description",removeModalCancelButton:"NegotiableQuoteTemplate.Manage.removeItemsModal.cancelButton",removeModalConfirmButton:"NegotiableQuoteTemplate.Manage.removeItemsModal.confirmButton",removeModalConfirmButtonRemoving:"NegotiableQuoteTemplate.Manage.removeItemsModal.confirmButtonRemoving",removeSuccessHeading:"NegotiableQuoteTemplate.Manage.removeItemsModal.successHeading",removeSuccessMessage:"NegotiableQuoteTemplate.Manage.removeItemsModal.successMessage",removeErrorHeading:"NegotiableQuoteTemplate.Manage.removeItemsModal.errorHeading",removeErrorMessage:"NegotiableQuoteTemplate.Manage.removeItemsModal.errorMessage",updateModalTitle:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.title",updateModalDescription:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.description",updateModalCancelButton:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.cancelButton",updateModalUpdateButton:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.updateButton",updateSuccessHeading:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.successHeading",updateSuccessMessage:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.successMessage",updateErrorHeading:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.errorHeading",updateErrorMessage:"NegotiableQuoteTemplate.Manage.updateQuantitiesModal.errorMessage",errorHeading:"NegotiableQuoteTemplate.Manage.lineItemNoteModal.errorHeading"}),{handleRemoveItems:d,handleConfirmRemove:I,handleCancelRemove:c,isRemoveModalOpen:y,isRemoving:h,removeNotificationState:C}=Me({templateId:e==null?void 0:e.id,removeSuccessMessage:t.removeSuccessMessage,removeErrorMessage:t.removeErrorMessage}),{dropdownSelections:R,handleItemDropdownChange:P,handleDismissRemoveBanner:q}=fe({handleRemoveItems:d}),{handleQuantityChange:L,handleUpdate:A,handleConfirmUpdate:G,handleCancelUpdate:J,handleDismissBanner:F,isUpdateModalOpen:K,updateNotificationState:E}=Te({templateId:e==null?void 0:e.id,updateSuccessMessage:t.updateSuccessMessage,updateErrorMessage:t.updateErrorMessage});O(()=>{const v=H.on("quote-management/quote-template-data",f=>{T(f.quoteTemplate),Q({})},{eager:!0});return()=>v==null?void 0:v.off()},[]);const _=p((v,f)=>{const D=v;if(f==="edit"){g(D),s(!0),Q(oe=>({...oe,[D.uid]:""}));return}P(v,f)},[P]),k={...R,...N},w=p(()=>{i&&Q(v=>{const f={...v};return delete f[i.uid],f}),s(!1),g(null),m(!1),n("")},[i]),V=p(async v=>{if(!(!i||!e)){m(!0),n("");try{await ce({templateId:e.id,itemId:i.uid,note:v}),w()}catch(f){console.error("Failed to set template line item note:",f);const D=f instanceof Error?f.message:"Unable to update the item. Please try again.";n(D),m(!1)}}},[i,e,w]),X=C.type==="success"?o(B,{type:"success",variant:"primary",icon:o(z,{}),heading:t.removeSuccessHeading,description:C.message,onDismiss:q,"data-testid":"remove-items-success-banner"}):C.type==="error"?o(B,{type:"error",variant:"primary",icon:o(U,{}),heading:t.removeErrorHeading,description:C.message,onDismiss:q,"data-testid":"remove-items-error-banner"}):null,Z=E.type==="success"?o(B,{type:"success",variant:"primary",icon:o(z,{}),heading:t.updateSuccessHeading,description:E.message,onDismiss:F,"data-testid":"update-quantities-success-banner"}):E.type==="error"?o(B,{type:"error",variant:"primary",icon:o(U,{}),heading:t.updateErrorHeading,description:E.message,onDismiss:F,"data-testid":"update-quantities-error-banner"}):null;if(!e)return o($,{loading:!0});const ee=y?{open:!0,title:t.removeModalTitle,message:t.removeModalDescription,cancelLabel:t.removeModalCancelButton,confirmLabel:h?t.removeModalConfirmButtonRemoving:t.removeModalConfirmButton,onCancel:c,onConfirm:I,confirmationBanner:X}:null,te=K?{open:!0,title:t.updateModalTitle,message:t.updateModalDescription,cancelLabel:t.updateModalCancelButton,confirmLabel:t.updateModalUpdateButton,onCancel:J,onConfirm:G,confirmationBanner:Z}:null,j=ee||te,x=[];e.prices.subtotalExcludingTax&&x.push({label:t.subtotal,id:"subtotal",value:o(Y,{amount:e.prices.subtotalExcludingTax.value,currency:e.prices.subtotalExcludingTax.currency,weight:"normal"})}),e.prices.grandTotal&&x.push({label:t.grandTotal,id:"total",value:o(Y,{amount:e.prices.grandTotal.value,currency:e.prices.grandTotal.currency}),strong:!0});const ae=S?o(B,{type:"error",variant:"primary",icon:o(U,{}),heading:t.errorHeading,description:S,onDismiss:()=>n(""),"data-testid":"line-item-note-error-banner"}):null;return ne(se,{children:[o($,{"data-testid":"items-quoted-template-container",...a,loading:!1,table:o(W,{name:"ProductListTable",slot:r==null?void 0:r.ProductListTable,context:{items:e.items,canEdit:e.canSendForReview,dropdownSelections:k,handleItemDropdownChange:_,handleQuantityChange:L,handleUpdate:A},children:o(ie,{items:e.items,canEdit:e.canSendForReview,showActions:e.canEditTemplateItems,onItemDropdownChange:_,onQuantityChange:L,onUpdate:A,dropdownSelections:k})}),pricesSummary:o(W,{name:"QuotePricesSummary",slot:r==null?void 0:r.QuotePricesSummary,context:{items:e.items,prices:e.prices},children:o(re,{entries:x})})}),j&&o(me,{...j}),i&&o(le,{open:M,item:i,onClose:w,onConfirm:V,isSubmitting:u,readOnlyQuantity:!0,errorBanner:ae||void 0})]})};export{Oe as I};
|
|
4
4
|
//# sourceMappingURL=ItemsQuotedTemplate.js.map
|