@dropins/storefront-quote-management 1.0.0-beta9 → 1.0.0
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/sendQuoteTemplateForReview/sendQuoteTemplateForReview.d.ts +3 -0
- package/api.js +1 -1
- package/chunks/AttachedFilesList.js +1 -1
- package/chunks/CheckWithCircle.js +1 -1
- package/chunks/ChevronDown.js +1 -1
- package/chunks/ConfirmationModal.js +1 -1
- package/chunks/ItemsQuoted.js +1 -1
- package/chunks/ItemsQuotedTemplate.js +1 -1
- package/chunks/LineItemNoteModal.js +1 -1
- package/chunks/NegotiableQuoteFragment.js +1 -1
- package/chunks/NegotiableQuoteTemplateFragment.js +1 -1
- package/chunks/OrderSummaryLine.js +1 -1
- package/chunks/QuoteCommentsList.js +1 -1
- package/chunks/QuoteCommentsList3.js +1 -1
- package/chunks/QuoteHistoryLog.js +1 -1
- package/chunks/QuoteHistoryLog3.js +1 -1
- package/chunks/QuoteTemplateCommentsList.js +2 -2
- package/chunks/QuoteTemplateCommentsList.js.map +1 -1
- package/chunks/QuoteTemplateHistoryLog.js +1 -1
- package/chunks/RenameQuoteModal.js +1 -1
- package/chunks/ShippingAddressDisplay.js +1 -1
- package/chunks/WarningFilled.js +1 -1
- package/chunks/addQuoteTemplateLineItemNote.js +1 -1
- package/chunks/dateUtils.js +1 -1
- package/chunks/duplicateNegotiableQuote.js +1 -1
- package/chunks/generateQuoteFromTemplate.js +1 -1
- package/chunks/getQuoteTemplates.js +1 -1
- package/chunks/negotiableQuotes.js +1 -1
- package/chunks/openQuoteTemplate.js +13 -12
- package/chunks/openQuoteTemplate.js.map +1 -1
- package/chunks/requestNegotiableQuote.js +1 -1
- package/chunks/setLineItemNote.js +1 -1
- package/chunks/state.js +1 -1
- package/chunks/transform-quote-template.js +1 -1
- package/chunks/transform-quote.js +1 -1
- package/chunks/uploadFile.js +1 -1
- package/components/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +2 -0
- package/containers/ItemsQuoted.js +1 -1
- package/containers/ItemsQuotedTemplate.js +1 -1
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +19 -1
- package/containers/ManageNegotiableQuoteTemplate.js +3 -3
- package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
- package/containers/OrderSummary.js +1 -1
- package/containers/OrderSummaryLine.js +1 -1
- package/containers/QuoteCommentsList.js +1 -1
- package/containers/QuoteHistoryLog.js +1 -1
- package/containers/QuoteSummaryList.js +1 -1
- package/containers/QuoteTemplateCommentsList.js +1 -1
- package/containers/QuoteTemplateHistoryLog.js +1 -1
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/RequestNegotiableQuoteForm.js +1 -1
- package/containers/ShippingAddressDisplay.js +1 -1
- package/package.json +1 -1
- package/render.js +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Copyright
|
|
1
|
+
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{FetchGraphQL as b}from"@dropins/tools/fetch-graphql.js";import{s as _}from"./state.js";var d=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(d||{});const{setEndpoint:L,setFetchGraphQlHeader:M,removeFetchGraphQlHeader:B,setFetchGraphQlHeaders:G,fetchGraphQl:z,getConfig:H}=new b().getMethods();function h(e){var a,r,c,i,u,s,o;return{uid:e.uid,createdAt:e.created_at,author:{firstname:e.author.firstname,lastname:e.author.lastname},changeType:e.change_type,changes:{commentAdded:((a=e.changes)==null?void 0:a.comment_added)&&{comment:e.changes.comment_added.comment},customChanges:((r=e.changes)==null?void 0:r.custom_changes)&&{new_value:e.changes.custom_changes.new_value,old_value:e.changes.custom_changes.old_value,title:e.changes.custom_changes.title},expiration:((c=e.changes)==null?void 0:c.expiration)&&{newExpiration:e.changes.expiration.new_expiration,oldExpiration:e.changes.expiration.old_expiration},productsRemoved:((i=e.changes)==null?void 0:i.products_removed)&&{productsRemovedFromCatalog:e.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:e.changes.products_removed.products_removed_from_quote||[]},statuses:((u=e.changes)==null?void 0:u.statuses)&&{changes:((s=e.changes.statuses.changes)==null?void 0:s.map(l=>({newStatus:l==null?void 0:l.new_status,oldStatus:l==null?void 0:l.old_status})))||[]},total:((o=e.changes)==null?void 0:o.total)&&e.changes.total.new_price&&e.changes.total.old_price&&{newPrice:{value:e.changes.total.new_price.value,currency:e.changes.total.new_price.currency},oldPrice:{value:e.changes.total.old_price.value,currency:e.changes.total.old_price.currency}}}}}function y(e){if(e)return e.map(h)}function v(e,a){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>a>=c.quantity)||null}function T(e){var r,c,i,u;const a=_.config;return{src:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(r=e.configured_variant)==null?void 0:r.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.label:((u=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:u.label)||e.product.thumbnail.label}}function I(e){var a;return((a=e.links)==null?void 0:a.length)>0?{count:e.links.length,result:e.links.map(r=>r.title).join(", ")}:null}function D(e){var s,o,l,t;const a=e.quantity,r=e.__typename==="ConfigurableCartItem",c=r?(s=e.configured_variant)==null?void 0:s.price_tiers:e.product.price_tiers,i=r?(o=e.configured_variant)==null?void 0:o.price_range:e.product.price_range,u=v(c,a);return u?u.discount.amount_off>0:(((t=(l=i==null?void 0:i.maximum_price)==null?void 0:l.discount)==null?void 0:t.amount_off)??0)>0}function E(e){var i,u,s,o,l,t,n,p;const a=e.quantity,r=v(e.product.price_tiers,a);if(r)return Math.round(r.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(o=(s=(u=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:u.maximum_price)==null?void 0:s.discount)==null?void 0:o.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(p=(n=(t=(l=e==null?void 0:e.product)==null?void 0:l.price_range)==null?void 0:t.maximum_price)==null?void 0:n.discount)==null?void 0:p.percent_off}if(c!==0)return Math.round(c)}function P(e){var a,r,c,i;return e.__typename==="ConfigurableCartItem"?{value:(r=(a=e.configured_variant)==null?void 0:a.price_range)==null?void 0:r.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function w(e){var c,i,u,s,o,l;let a,r;if(a=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((s=(u=e==null?void 0:e.prices)==null?void 0:u.row_total)==null?void 0:s.value),r=(l=(o=e==null?void 0:e.prices)==null?void 0:o.row_total)==null?void 0:l.currency,a!==0)return{value:a,currency:r}}function C(e){var a,r,c,i,u,s,o,l;return{itemType:e.__typename,uid:e.uid,product:{uid:e.product.uid,sku:e.product.sku,name:e.product.name,priceRange:{maximumPrice:{regularPrice:{value:e.product.price_range.maximum_price.regular_price.value,currency:e.product.price_range.maximum_price.regular_price.currency}}}},image:T(e),links:I(e),discounted:D(e),discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},catalogDiscount:{amountOff:e.prices.catalog_discount.amount_off,percentOff:e.prices.catalog_discount.percent_off},discounts:((r=(a=e.prices)==null?void 0:a.discounts)==null?void 0:r.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:E(e),insufficientQuantity:(e.__typename==="ConfigurableCartItem"?((c=e.configured_variant)==null?void 0:c.stock_status)??e.product.stock_status:e.product.stock_status)==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockStatus:e.product.stock_status,quantity:e.quantity,prices:{regularPrice:P(e),priceIncludingTax:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},originalItemPrice:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency},originalRowTotal:{value:e.prices.original_row_total.value,currency:e.prices.original_row_total.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency}},savingsAmount:w(e),noteFromBuyer:(i=e.note_from_buyer)==null?void 0:i.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(u=e.note_from_seller)==null?void 0:u.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(s=e.configurable_options)==null?void 0:s.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(o=e.bundle_options)==null?void 0:o.map(t=>({label:t.label,values:t.values.map(n=>({label:n.label,quantity:n.quantity,originalPrice:{value:n.original_price.value,currency:n.original_price.currency},price:{value:n.priceV2.value,currency:n.priceV2.currency}}))})),customizableOptions:(l=e.customizable_options)==null?void 0:l.map(t=>({type:t.type,label:t.label,values:t.values.map(n=>({label:n.label,value:n.value}))}))}}function A(e){return e?e.map(C):[]}const f=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function O(e){if(!e.items)return 0;const a=_.config;return(a==null?void 0:a.quoteSummaryDisplayTotal)===0?e.items.length:(a==null?void 0:a.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function R(e){return e.every(a=>!a.outOfStock&&!a.insufficientQuantity)}function S(e){var i,u,s,o,l,t;const a=x(e),r=!!((i=e.template_name)!=null&&i.trim()),c=A(e.items);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:a?d.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},email:e.email,templateName:e.template_name,totalQuantity:O(e),comments:(u=e.comments)==null?void 0:u.map(n=>{const p={uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},text:n.text};return Array.isArray(n.attachments)&&n.attachments.length>0&&(p.attachments=n.attachments.map(g=>({name:g.name,url:g.url}))),p}),prices:e.prices&&{appliedDiscounts:(s=e.prices.discounts)==null?void 0:s.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label,coupon:n.coupon})),appliedTaxes:(o=e.prices.applied_taxes)==null?void 0:o.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})),discount:e.prices.discounts&&e.prices.grand_total&&m(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...Q(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&m(e.prices.applied_taxes,e.prices.grand_total.currency)},history:y(e.history),items:c,shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(n=>{const p={uid:n.uid,firstname:n.firstname,lastname:n.lastname,company:n.company,street:n.street,city:n.city,postcode:n.postcode,country:{code:n.country.code,label:n.country.label},telephone:n.telephone};return n.region&&(p.region={code:n.region.code,label:n.region.label,regionId:n.region.region_id}),p}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&_.permissions.checkoutQuote&&((t=e.shipping_addresses)==null?void 0:t.length)>0&&R(c),canSendForReview:!r&&(a||f.includes(e.status))&&_.permissions.editQuote,canUpdateQuote:!r&&(a||f.includes(e.status))&&_.permissions.editQuote,canDelete:!r&&!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&_.permissions.deleteQuote,canClose:e.status?!r&&!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:r||!a&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!_.permissions.editQuote}}function W(e){return e?S(e):null}function x(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(a=>{var r,c;return a.change_type==="UPDATED"&&(((c=(r=a.changes)==null?void 0:r.statuses)==null?void 0:c.changes)??[]).length>0})}function N(e){const a=x(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:a?d.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function V(e){var c;if(!e)return null;const a={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(N))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},r=k(a);return{...a,paginationInfo:r||void 0}}function k(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:a,pageSize:r,totalPages:c}=e.pageInfo,{totalCount:i}=e,u=i>0?(a-1)*r+1:0,s=Math.min(a*r,i);return{currentPage:a,totalCount:i,pageSize:r,startItem:u,endItem:s,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const X=()=>[20,30,50,100,200];function m(e,a){return e!=null&&e.length?e.reduce((r,c)=>({value:r.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:a}):{value:0,currency:a}}function Q(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const r=e.shipping_addresses[0].selected_shipping_method;return r?{shippingIncludingTax:r.price_incl_tax&&{value:r.price_incl_tax.value,currency:r.price_incl_tax.currency},shippingExcludingTax:r.price_excl_tax&&{value:r.price_excl_tax.value,currency:r.price_excl_tax.currency}}:{}}export{A as a,y as b,k as c,V as d,M as e,z as f,X as g,G as h,H as i,B as r,L as s,W as t};
|
|
4
4
|
//# sourceMappingURL=transform-quote.js.map
|
package/chunks/uploadFile.js
CHANGED
|
@@ -14,6 +14,8 @@ export interface ManageNegotiableQuoteTemplateProps extends Omit<HTMLAttributes<
|
|
|
14
14
|
shippingInformation?: VNode;
|
|
15
15
|
commentsTitle: VNode;
|
|
16
16
|
comments: VNode;
|
|
17
|
+
attachFilesField?: VNode;
|
|
18
|
+
attachedFilesList?: VNode;
|
|
17
19
|
footer?: VNode;
|
|
18
20
|
}
|
|
19
21
|
export declare const ManageNegotiableQuoteTemplate: FunctionComponent<ManageNegotiableQuoteTemplateProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Copyright
|
|
1
|
+
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{I as q,I as v}from"../chunks/ItemsQuoted.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/components.js";/* empty css */import"../chunks/LineItemNoteModal.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"../chunks/dateUtils.js";import"../chunks/WarningFilled.js";import"@dropins/tools/i18n.js";import"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import"../chunks/state.js";import"../chunks/setLineItemNote.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/CheckWithCircle.js";export{q as ItemsQuoted,v as default};
|
|
4
4
|
//# sourceMappingURL=ItemsQuoted.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Copyright
|
|
1
|
+
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{I as q,I as v}from"../chunks/ItemsQuotedTemplate.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/components.js";/* empty css */import"../chunks/LineItemNoteModal.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"../chunks/dateUtils.js";import"../chunks/WarningFilled.js";import"@dropins/tools/i18n.js";import"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import"../chunks/state.js";import"../chunks/addQuoteTemplateLineItemNote.js";import"../chunks/transform-quote-template.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/CheckWithCircle.js";export{q as ItemsQuotedTemplate,v as default};
|
|
4
4
|
//# sourceMappingURL=ItemsQuotedTemplate.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Copyright
|
|
1
|
+
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{jsx as n,jsxs as p,Fragment as la}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useRef as _e,useEffect as q,useCallback as c,useMemo as f,createPortal as W}from"@dropins/tools/preact-compat.js";import{classes as u,VComponent as M,Slot as g}from"@dropins/tools/lib.js";import{f as ca}from"../chunks/dateUtils.js";/* empty css */import{Skeleton as ja,SkeletonRow as z,InLineAlert as h,Button as sa,TextArea as Ga,InputFile as Ka}from"@dropins/tools/components.js";import{events as C}from"@dropins/tools/event-bus.js";import{S as Xa,A as Ja,T as Ya,R as Za}from"../chunks/RenameQuoteModal.js";import{v as Aa,f as et,a as at,S as tt,A as nt}from"../chunks/AttachedFilesList.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{C as X}from"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import{S as ot}from"../chunks/ShippingAddressDisplay.js";import{Q as it}from"../chunks/QuoteHistoryLog3.js";import{g as rt,r as lt,c as ct,a as st,s as mt,d as dt,b as ut}from"../chunks/duplicateNegotiableQuote.js";import"../chunks/state.js";import{u as gt}from"../chunks/uploadFile.js";import{I as ft}from"../chunks/ItemsQuoted.js";import{Q as pt}from"../chunks/QuoteCommentsList3.js";import{S as D}from"../chunks/WarningFilled.js";import{S as J}from"../chunks/CheckWithCircle.js";import{useText as Mt}from"@dropins/tools/i18n.js";import"../chunks/QuoteHistoryLog.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/transform-quote-template.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/LineItemNoteModal.js";import"../chunks/setLineItemNote.js";import"../chunks/QuoteCommentsList.js";const bt=({className:x,loading:t,quoteName:m,quoteStatus:R,banner:y,details:_,actionBar:N,quoteContent:L,shippingInformationTitle:Y,shippingInformation:e,quoteCommentsTitle:S,quoteComments:E,attachFilesField:k,attachedFilesList:P,footer:Z,...A})=>t?n(ht,{}):p("div",{...A,className:u(["quote-management-manage-negotiable-quote",x]),children:[p("div",{className:u(["quote-management-manage-negotiable-quote__header"]),children:[m&&n(M,{node:m,className:u(["quote-management-manage-negotiable-quote__quote-name"])}),R&&n(M,{node:R,className:u(["quote-management-manage-negotiable-quote__quote-status"])})]}),y&&n(M,{node:y,className:u(["quote-management-manage-negotiable-quote__banner"])}),_&&n(M,{node:_,className:u(["quote-management-manage-negotiable-quote__details"])}),N&&n(M,{node:N,className:u(["quote-management-manage-negotiable-quote__action-bar"])}),L&&n(M,{node:L,className:u(["quote-management-manage-negotiable-quote__quote-content"])}),p("div",{"data-testid":"quote-shipping-information-container",className:u(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[Y&&n(M,{node:Y,className:u(["quote-management-manage-negotiable-quote__shipping-information-title"])}),e&&n(M,{node:e,className:u(["quote-management-manage-negotiable-quote__shipping-information"])})]}),p("div",{"data-testid":"quote-comments-container",className:u(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[S&&n(M,{node:S,className:u(["quote-management-manage-negotiable-quote__quote-comments-title"])}),E&&n(M,{node:E,className:u(["quote-management-manage-negotiable-quote__quote-comments"])}),k&&n(M,{node:k,className:u(["quote-management-manage-negotiable-quote__attach-files-field"])}),P&&n(M,{node:P,className:u(["quote-management-manage-negotiable-quote__attached-files-list"])})]}),n(M,{node:Z,className:u(["quote-management-manage-negotiable-quote__footer"])})]}),ht=()=>p(ja,{"data-testid":"manage-negotiable-quote-skeleton",children:[n(z,{variant:"heading",fullWidth:!0,size:"large"}),n(z,{variant:"row",fullWidth:!1,size:"small"}),n(z,{variant:"row",fullWidth:!1,size:"small"}),n(z,{variant:"row",fullWidth:!0}),n(z,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),n(z,{variant:"row",fullWidth:!1,size:"small"})]}),an=({onActionsDropdownChange:x,slots:t,onActionsButtonClick:m,onSendForReview:R,maxFiles:y,maxFileSize:_,acceptedFileTypes:N,onDuplicateQuote:L,...Y})=>{const[e,S]=l(void 0),[E,k]=l(!0),[P,Z]=l(!1),[A,$]=l(null),[ma,ee]=l(!1),[Ee,se]=l(!1),[Fe,F]=l(null),[da,H]=l(!1),[Ie,we]=l(!1),[I,De]=l(""),[Q,me]=l(!1),[xe,de]=l(!1),[Re,ue]=l(!1),[Le,O]=l(""),[ke,V]=l(""),[He,ge]=l(!1),[Oe,Be]=l(!1),[Ue,j]=l(""),[We,ae]=l(""),[ze,fe]=l(!1),[te,ne]=l(""),[pe,oe]=l(""),[Me,G]=l(""),[ua,B]=l(""),[be,ie]=l(""),[b,K]=l([]),[re,le]=l(void 0),[he,Pe]=l(new Set),$e=_e(he),Ne=_e(null),[U,Se]=l(""),ce=_e(U),[Ve,je]=l(!1);q(()=>{$e.current=he},[he]),q(()=>{ce.current=U},[U]);const o=Mt({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired",errorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",closeSuccessMessage:"NegotiableQuote.Manage.confirmationModal.close.successDescription",closeModalTitle:"NegotiableQuote.Manage.actionButtons.close",closeModalMessage:"NegotiableQuote.Manage.confirmationModal.close.message",closeModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",closeModalConfirm:"NegotiableQuote.Manage.confirmationModal.close.confirm",closeModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.close.confirmLoading",closeModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.close.successHeading",createTemplateModalTitle:"NegotiableQuote.Manage.actionButtons.createTemplate",createTemplateModalMessage:"NegotiableQuote.Manage.confirmationModal.createTemplate.message",createTemplateModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",createTemplateModalConfirm:"NegotiableQuote.Manage.confirmationModal.createTemplate.confirm",createTemplateModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.createTemplate.confirmLoading",createTemplateModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.createTemplate.successHeading",createTemplateSuccessMessage:"NegotiableQuote.Manage.confirmationModal.createTemplate.successDescription",createTemplateModalErrorHeading:"NegotiableQuote.Manage.confirmationModal.createTemplate.errorHeading",createTemplateErrorFallback:"NegotiableQuote.Manage.confirmationModal.createTemplate.errorFallback",renameErrorHeading:"NegotiableQuote.Manage.rename.errorHeading",renameQuoteNameRequired:"NegotiableQuote.Manage.rename.quoteNameRequired",renameErrorDefault:"NegotiableQuote.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuote.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuote.Manage.rename.successMessage",confirmationModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",confirmationModalDeleteTitle:"NegotiableQuote.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuote.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuote.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuote.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription",confirmationModalDuplicateTitle:"NegotiableQuote.Manage.confirmationModal.duplicate.title",confirmationModalDuplicateMessage:"NegotiableQuote.Manage.confirmationModal.duplicate.message",confirmationModalDuplicateConfirm:"NegotiableQuote.Manage.confirmationModal.duplicate.confirm",confirmationModalDuplicateErrorHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.errorHeading",confirmationModalDuplicateErrorFallback:"NegotiableQuote.Manage.confirmationModal.duplicate.errorFallback",confirmationModalDuplicateSuccessHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.successHeading",confirmationModalDuplicateSuccessDescription:"NegotiableQuote.Manage.confirmationModal.duplicate.successDescription",duplicateOutOfStockWarningHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.outOfStockWarningHeading",duplicateOutOfStockWarningMessage:"NegotiableQuote.Manage.confirmationModal.duplicate.outOfStockWarningMessage",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm",attachFiles:"NegotiableQuote.Manage.attachFiles",fileUploadError:"NegotiableQuote.Manage.fileUploadError",maxFilesExceeded:"NegotiableQuote.Manage.maxFilesExceeded",maxFileSizeExceeded:"NegotiableQuote.Manage.maxFileSizeExceeded",invalidFileType:"NegotiableQuote.Manage.invalidFileType"});q(()=>{const a=C.on("quote-management/quote-data",i=>{const{quote:r}=i;if(r){S(r),k(!1);const s=`duplicate-outOfStock-warning-${r.uid}`;sessionStorage.getItem(s)==="true"&&(we(!0),sessionStorage.removeItem(s))}},{eager:!0});return()=>a==null?void 0:a.off()},[]),q(()=>{const a=C.on("quote-management/shipping-address-set",i=>{const{quote:r}=i;r&&S(r)},{eager:!0});return()=>a==null?void 0:a.off()},[]),q(()=>{const a=C.on("quote-management/quote-sent-for-review",i=>{const{quote:r}=i;S(r),De(""),K([]),me(!1)},{eager:!0});return()=>a==null?void 0:a.off()},[]),q(()=>{const a=C.on("quote-management/quote-items-removed",i=>{const{quote:r,removedItemUids:s}=i;r&&S(r),s&&Pe(d=>{const v=new Set(d);return s.forEach(w=>v.delete(w)),v})},{eager:!0});return()=>a==null?void 0:a.off()},[]);const Ge=c((a,i)=>{Pe(r=>{const s=new Set(r);return i?s.add(a.uid):s.delete(a.uid),s})},[]),Ke=c(a=>{const i=a.target.value,r=$e.current;if(i==="remove"){if(Se(i),ce.current=i,r.size===0)je(!0);else if(e&&Ne.current){const s=e.items.filter(d=>r.has(d.uid));Ne.current(s)}}x==null||x(a)},[x,e]),Xe=c(()=>{je(!1),Se(""),ce.current=""},[]);q(()=>{const a=C.on("quote-management/negotiable-quote-closed",async i=>{ue(!1),V(""),O(o.closeSuccessMessage),S(r=>{var s;return r!=null&&r.uid&&((s=i.closedQuoteUids)!=null&&s.includes(r.uid))&&rt(r.uid).then(d=>{S(d)}).catch(d=>{console.warn("Failed to refresh quote data after closure:",d)}),r}),setTimeout(()=>{de(!1),O("")},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[o.closeSuccessMessage]),q(()=>{const a=C.on("quote-management/negotiable-quote-close-error",i=>{console.log("Close error event received:",i),ue(!1),O("");const r=i.error.message||o.errorFallback;V(r)},{eager:!0});return()=>a==null?void 0:a.off()},[o.errorFallback]),q(()=>{const a=C.on("quote-management/quote-renamed",i=>{const{quote:r}=i;S(r),G(""),B(""),ie(o.renameSuccessMessage),setTimeout(()=>{fe(!1),ne(""),oe(""),ie("")},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[o.renameSuccessMessage]),q(()=>{const a=C.on("quote-management/quote-duplicated",i=>{const{quote:r}=i;e&&L&&L({quoteData:e,newQuote:r}),H(!0),F(null),setTimeout(()=>{se(!1),H(!1),F(null)},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[e,L]);const Qe=c(async a=>{if(y&&b.length+a.length>y){le(o.maxFilesExceeded.replace("{maxFiles}",String(y)));return}for(const r of a){if(_&&!Aa(r.size,_)){le(o.maxFileSizeExceeded.replace("{maxSize}",et(_)));return}if(N&&!at(r.type,N)){le(o.invalidFileType);return}}le(void 0);const i=a.map(r=>({key:`temp-${Date.now()}-${Math.random()}-${r.name}`,name:r.name,size:r.size,status:"uploading"}));K(r=>[...r,...i]);for(let r=0;r<a.length;r++){const s=a[r],d=i[r].key;try{const v=await gt(s);K(w=>w.map(T=>T.key===d?{...T,key:v.key,status:"success"}:T))}catch(v){K(w=>w.map(T=>T.key===d?{...T,status:"error",error:v.message}:T))}}},[y,_,N,b,o]),ve=c(a=>{K(i=>i.filter(r=>r.key!==a))},[]),Je=c(()=>{ne((e==null?void 0:e.name)||""),oe(""),G(""),B(""),ie(""),fe(!0)},[e]),ga=c(()=>{fe(!1),ne(""),oe(""),G(""),B(""),ie("")},[]),fa=c(a=>{ne(a),a.trim()&&B("")},[]),Ye=c(()=>{se(!0),F(null),H(!1)},[]),pa=c(async()=>{if(!te.trim()){B(o.renameQuoteNameRequired);return}try{G(""),B(""),await lt({quoteUid:e.uid,quoteName:te,quoteComment:pe.trim()||void 0})}catch(a){G(a.message||o.renameErrorDefault)}},[e,te,pe,o.renameQuoteNameRequired,o.renameErrorDefault]),Ma=f(()=>{const a=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return n(g,{name:"QuoteName",slot:t==null?void 0:t.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:p("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[n("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),n("button",{onClick:Je,disabled:a,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:n(Xa,{})})]})})},[t==null?void 0:t.QuoteName,e,Je]),ba=f(()=>n(g,{name:"QuoteStatus",slot:t==null?void 0:t.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:n("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[t==null?void 0:t.QuoteStatus,e]),Ze=c(a=>{switch(a){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),Ae=Ze&&n(h,{type:"warning",variant:"secondary",icon:n(D,{}),heading:o.bannerTitle,description:Ze}),ea=Ae&&n(g,{name:"Banner","data-testid":"banner",slot:t==null?void 0:t.Banner,context:{quoteData:e},children:Ae}),ha=c(()=>{we(!1)},[]),aa=Ie&&n(g,{name:"DuplicateQuoteWarningBanner","data-testid":"duplicate-outOfStock-warning-banner",slot:t==null?void 0:t.DuplicateQuoteWarningBanner,context:{outOfStockWarning:Ie},children:n(h,{type:"warning",variant:"primary",icon:n(D,{}),heading:o.duplicateOutOfStockWarningHeading,description:o.duplicateOutOfStockWarningMessage,onDismiss:ha,"data-testid":"duplicate-outOfStock-warning-alert"})}),Na=f(()=>{if(!e)return;const a=e.expirationDate?ca(e.expirationDate,"short"):void 0;return p(g,{name:"Details",slot:t==null?void 0:t.Details,context:{quoteData:e},children:[p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),p("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[ca(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),n("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),n("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:a})]})]})},[t==null?void 0:t.Details,o,e]),ta=f(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate",disabled:!!(e!=null&&e.templateName)},{label:o.createCopy,value:"createCopy",disabled:!!(e!=null&&e.templateName)}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose,e==null?void 0:e.templateName]),Sa=f(()=>{const a=i=>{switch(i){case"close":de(!0),V(""),O(""),m==null||m(i);break;case"delete":Z(!0),m==null||m(i);break;case"print":m==null||m(i);break;case"createTemplate":ge(!0),ae(""),j(""),m==null||m(i);break;case"createCopy":Ye(),m==null||m(i);break}};return n(g,{name:"ActionBar",slot:t==null?void 0:t.ActionBar,context:{quoteData:e,actionsBarDropdownValue:U},children:n(Ja,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:U,handleDropdownChange:Ke,buttons:ta.map(i=>n(sa,{variant:"tertiary",onClick:()=>a(i.value),"data-testid":`actions-bar-${i.value}-button`,"data-action":i.value,disabled:i.disabled,children:i.label},i.value))})})},[ta,o,t==null?void 0:t.ActionBar,e,Ke,m,Ye,U]),Qa=f(()=>n(g,{name:"QuoteContent",slot:t==null?void 0:t.QuoteContent,context:{quoteData:e},children:n(Ya,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",n(g,{name:"ItemsQuotedTab",slot:t==null?void 0:t.ItemsQuotedTab,context:{quoteData:e},children:n(ft,{quoteData:e,onItemCheckboxChange:Ge,onRemoveItemsRef:a=>{Ne.current=a},onRemoveModalStateChange:a=>{!a&&ce.current==="remove"&&Se("")}})},"items-quoted")],["comments",n(g,{name:"CommentsTab",slot:t==null?void 0:t.CommentsTab,context:{quoteData:e},children:n(pt,{quoteData:e})},"comments")],["history-log",n(g,{name:"HistoryLogTab",slot:t==null?void 0:t.HistoryLogTab,context:{quoteData:e},children:n(it,{quoteData:e})},"history-log")]])})}),[t==null?void 0:t.QuoteContent,t==null?void 0:t.HistoryLogTab,t==null?void 0:t.CommentsTab,t==null?void 0:t.ItemsQuotedTab,e,Ge]),va=f(()=>n(g,{name:"ShippingInformationTitle",slot:t==null?void 0:t.ShippingInformationTitle,context:{quoteData:e},children:n("h2",{children:o.shippingInformationTitle})}),[t==null?void 0:t.ShippingInformationTitle,e,o]),qa=f(()=>{var a;return n(g,{name:"ShippingInformation",slot:t==null?void 0:t.ShippingInformation,context:{quoteData:e,loading:E,setLoading:k},children:n(ot,{shippingAddress:(a=e==null?void 0:e.shippingAddresses)==null?void 0:a[0],loading:E,"data-testid":"manage-quote-shipping-address"})})},[t==null?void 0:t.ShippingInformation,e,E,k]),Ta=f(()=>n(g,{name:"QuoteCommentsTitle",slot:t==null?void 0:t.QuoteCommentsTitle,context:{quoteData:e},children:n("h2",{children:o.quoteCommentsTitle})}),[t==null?void 0:t.QuoteCommentsTitle,o,e]),Ca=f(()=>n(g,{name:"QuoteComments",slot:t==null?void 0:t.QuoteComments,context:{quoteData:e},children:n(Ga,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:I,onInput:a=>{De(a.target.value)},disabled:!(e!=null&&e.canSendForReview)||Q})}),[t==null?void 0:t.QuoteComments,o,e,I,Q]),na=f(()=>!(e!=null&&e.canSendForReview),[e]),ya=f(()=>{const a=Q||na;return n(g,{name:"AttachFilesField",slot:t==null?void 0:t.AttachFilesField,context:{onFileChange:Qe,attachedFiles:b,fileUploadError:re,disabled:a},children:p("div",{className:"quote-management-manage-negotiable-quote__attach-files",...a?{"data-disabled":!0}:{},"aria-disabled":a,children:[n(Ka,{id:"manage-quote-attach-files",multiple:!0,onChange:i=>{const r=i.target,s=r==null?void 0:r.files,d=s?Array.from(s):[];d.length>0&&Qe(d)},icon:n(tt,{}),disabled:a,"data-testid":"manage-quote-attach-files",accept:N==null?void 0:N.join(","),children:o.attachFiles}),re&&n("div",{className:"quote-management-manage-negotiable-quote__file-error","data-testid":"file-upload-error",children:re})]})})},[t==null?void 0:t.AttachFilesField,Qe,Q,na,N,re,o,b]),_a=f(()=>{if(b.length)return n(g,{name:"AttachedFilesList",slot:t==null?void 0:t.AttachedFilesList,context:{files:b,onRemove:ve,disabled:Q},children:n(nt,{files:b,onRemove:ve,disabled:Q})})},[b,ve,Q,t==null?void 0:t.AttachedFilesList]),Ea=c(async()=>{if(e!=null&&e.uid){ue(!0),V(""),O("");try{await ct({quoteUids:[e.uid]})}catch(a){console.error("Failed to close quote:",a)}}},[e]),Fa=c(()=>{de(!1),V(""),O("")},[]),Ia=c(async()=>{if(e!=null&&e.uid){Be(!0),ae(""),j("");try{await st(e.uid),j(o.createTemplateSuccessMessage),setTimeout(()=>{ge(!1),j("")},2e3)}catch(a){console.error("Failed to create quote template:",a);const i=a instanceof Error?a.message:o.createTemplateErrorFallback;ae(i)}finally{Be(!1)}}},[e,o.createTemplateSuccessMessage,o.createTemplateErrorFallback]),wa=c(()=>{ge(!1),ae(""),j("")},[]),qe=c(async()=>{const a=b.filter(i=>i.status==="success");if(R){R({quoteData:e,comment:I.trim()||void 0,attachments:a.length?a:void 0});return}me(!0);try{await mt({quoteUid:e.uid,comment:I.trim()||void 0,attachments:a.length?a.map(i=>({key:i.key})):void 0})}catch(i){console.error("Failed to send quote for review:",i),me(!1)}},[e,R,I,b]),Da=f(()=>n(g,{name:"Footer",slot:t==null?void 0:t.Footer,context:{quoteData:e,comment:I,isSubmitting:Q,attachments:b,handleSendForReview:qe},children:n(sa,{variant:"primary",onClick:qe,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||Q,children:o.sendForReview})}),[t==null?void 0:t.Footer,o,e,I,Q,b,qe]),xa=f(()=>Me?n(h,{type:"error",variant:"primary",icon:n(D,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:Me}):void 0,[Me,o.renameErrorHeading]),Ra=f(()=>be?n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.renameSuccessHeading,description:be}):void 0,[be,o.renameSuccessHeading]),Te=c(a=>a.errors&&Array.isArray(a.errors)&&a.errors.length>0?a.errors[0].message||o.confirmationModalDeleteErrorFallback:(a==null?void 0:a.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),La=c(()=>{Z(!1),$(null),ee(!1)},[]),ka=c(async()=>{if(e!=null&&e.uid){$(null),ee(!1);try{const{operationResults:a}=await dt(e.uid),i=a.find(r=>r.__typename==="DeleteNegotiableQuoteOperationFailure");if(i){const r=Te(i);$(r);return}ee(!0)}catch(a){const i=Te(a);$(i)}}},[e,Te]),Ha=c(()=>{$(null)},[]),Oa=c(()=>{ee(!1)},[]),oa=c(a=>(a==null?void 0:a.message)||o.confirmationModalDuplicateErrorFallback,[o.confirmationModalDuplicateErrorFallback]),Ba=c(()=>{se(!1),F(null),H(!1)},[]),Ua=c(async()=>{var a;if(e!=null&&e.uid){F(null),H(!1);try{const i=((a=e.items)==null?void 0:a.filter(v=>v.outOfStock))||[],s=(v=>{const w=v.slice(0,-8),T=crypto.randomUUID().slice(0,8);return w+T})(e.uid),d=i.length>0;d&&sessionStorage.setItem(`duplicate-outOfStock-warning-${s}`,"true"),await ut({quoteUid:e.uid,duplicatedQuoteUid:s,hasOutOfStockItems:d})}catch(i){const r=oa(i);F(r)}}},[e,oa]),Wa=c(()=>{F(null)},[]),za=c(()=>{H(!1)},[]),Pa=A?n(h,{type:"error",variant:"primary",icon:n(D,{}),heading:o.confirmationModalDeleteErrorHeading,description:A,onDismiss:Ha,"data-testid":"confirmation-modal-error-banner"}):null,ia=(ma?n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:Oa,"data-testid":"confirmation-modal-success-banner"}):null)||Pa,$a=Fe?n(h,{type:"error",variant:"primary",icon:n(D,{}),heading:o.confirmationModalDuplicateErrorHeading,description:Fe,onDismiss:Wa,"data-testid":"confirmation-modal-duplicate-error-banner"}):null,ra=(da?n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.confirmationModalDuplicateSuccessHeading,description:o.confirmationModalDuplicateSuccessDescription,onDismiss:za,"data-testid":"confirmation-modal-duplicate-success-banner"}):null)||$a,Va={...Y,loading:E,quoteName:Ma,quoteStatus:ba,banner:aa||ea?p(la,{children:[aa,ea]}):void 0,details:Na,actionBar:Sa,quoteContent:Qa,shippingInformationTitle:va,shippingInformation:qa,quoteCommentsTitle:Ta,quoteComments:Ca,attachFilesField:ya,attachedFilesList:_a,footer:Da};let Ce=null;Le?Ce=n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.closeModalSuccessHeading,description:Le,"data-testid":"close-quote-success-banner"}):ke&&(Ce=n(h,{type:"error",variant:"primary",icon:n(D,{}),heading:o.confirmationModalDeleteErrorHeading,description:ke,"data-testid":"close-quote-error-banner"}));let ye=null;return Ue?ye=n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.createTemplateModalSuccessHeading,description:Ue,"data-testid":"create-template-success-banner"}):We&&(ye=n(h,{type:"error",variant:"primary",icon:n(D,{}),heading:o.createTemplateModalErrorHeading,description:We,"data-testid":"create-template-error-banner"})),p(la,{children:[n(bt,{...Va}),ze&&W(n(Za,{open:ze,quoteName:te,renameReason:pe,quoteNameError:ua,errorBanner:xa,successBanner:Ra,onQuoteNameChange:fa,onRenameReasonChange:oe,onSave:pa,onClose:ga}),document.body),P&&W(n(X,{open:P,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:La,onConfirm:ka,showCloseButton:!ia,confirmationBanner:ia}),document.body),Ee&&W(n(X,{open:Ee,title:o.confirmationModalDuplicateTitle,message:o.confirmationModalDuplicateMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDuplicateConfirm,onCancel:Ba,onConfirm:Ua,showCloseButton:!ra,confirmationBanner:ra}),document.body),xe&&W(n(X,{open:xe,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:Re?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:Fa,onConfirm:Re?void 0:Ea,showCloseButton:!0,confirmationBanner:Ce,"data-testid":"close-quote-confirmation-modal"}),document.body),He&&W(n(X,{open:He,title:o.createTemplateModalTitle,message:o.createTemplateModalMessage,cancelLabel:o.createTemplateModalCancel,confirmLabel:Oe?o.createTemplateModalConfirmLoading:o.createTemplateModalConfirm,onCancel:wa,onConfirm:Oe?void 0:Ia,showCloseButton:!0,confirmationBanner:ye,"data-testid":"create-template-confirmation-modal"}),document.body),Ve&&W(n(X,{open:Ve,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:Xe,onClose:Xe,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{an as ManageNegotiableQuote,an as default};
|
|
4
4
|
//# sourceMappingURL=ManageNegotiableQuote.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
2
|
import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
|
|
3
3
|
import { NegotiableQuoteTemplateModel } from '../../data/models/negotiable-quote-template-model';
|
|
4
|
-
import { ReferenceDocument } from '../../components';
|
|
4
|
+
import { ReferenceDocument, AttachedFile } from '../../components';
|
|
5
5
|
import { ReferenceDocumentLinkInput } from '../../api';
|
|
6
6
|
|
|
7
7
|
export interface ManageNegotiableQuoteTemplateProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -11,7 +11,11 @@ export interface ManageNegotiableQuoteTemplateProps extends HTMLAttributes<HTMLD
|
|
|
11
11
|
name?: string;
|
|
12
12
|
comment?: string;
|
|
13
13
|
referenceDocumentLinks?: ReferenceDocumentLinkInput[];
|
|
14
|
+
attachments?: AttachedFile[];
|
|
14
15
|
}) => void;
|
|
16
|
+
maxFiles?: number;
|
|
17
|
+
maxFileSize?: number;
|
|
18
|
+
acceptedFileTypes?: string[];
|
|
15
19
|
slots?: {
|
|
16
20
|
TemplateName?: SlotProps<{
|
|
17
21
|
templateName?: string;
|
|
@@ -59,6 +63,19 @@ export interface ManageNegotiableQuoteTemplateProps extends HTMLAttributes<HTMLD
|
|
|
59
63
|
Comments?: SlotProps<{
|
|
60
64
|
templateData?: NegotiableQuoteTemplateModel;
|
|
61
65
|
}>;
|
|
66
|
+
AttachFilesField?: SlotProps<{
|
|
67
|
+
templateData?: NegotiableQuoteTemplateModel;
|
|
68
|
+
onFileChange: (files: File[]) => void;
|
|
69
|
+
attachedFiles: AttachedFile[];
|
|
70
|
+
fileUploadError: string | undefined;
|
|
71
|
+
disabled: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
AttachedFilesList?: SlotProps<{
|
|
74
|
+
templateData?: NegotiableQuoteTemplateModel;
|
|
75
|
+
files: AttachedFile[];
|
|
76
|
+
onRemove: (key: string) => void;
|
|
77
|
+
disabled: boolean;
|
|
78
|
+
}>;
|
|
62
79
|
HistoryLogTitle?: SlotProps<{
|
|
63
80
|
templateData?: NegotiableQuoteTemplateModel;
|
|
64
81
|
}>;
|
|
@@ -69,6 +86,7 @@ export interface ManageNegotiableQuoteTemplateProps extends HTMLAttributes<HTMLD
|
|
|
69
86
|
templateData?: NegotiableQuoteTemplateModel;
|
|
70
87
|
comment?: string;
|
|
71
88
|
isSubmitting?: boolean;
|
|
89
|
+
attachedFiles?: AttachedFile[];
|
|
72
90
|
referenceDocuments?: ReferenceDocument[];
|
|
73
91
|
hasUnsavedChanges?: boolean;
|
|
74
92
|
handleSendForReview: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Copyright
|
|
1
|
+
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as a,jsxs as p,Fragment as fe}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useEffect as ne,useCallback as s,useMemo as h,useRef as Sa,createPortal as x}from"@dropins/tools/preact-compat.js";import{classes as d,VComponent as I,Slot as D}from"@dropins/tools/lib.js";import{f as Oe}from"../chunks/dateUtils.js";import{events as Da}from"@dropins/tools/event-bus.js";import{Skeleton as La,SkeletonRow as W,InLineAlert as L,Modal as Ea,Input as ge,Button as k,TextArea as Ia,Icon as ee}from"@dropins/tools/components.js";import{N as Ge}from"../chunks/transform-quote-template.js";import{S as wa,A as ka,T as Ha,R as Ba}from"../chunks/RenameQuoteModal.js";/* empty css */import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{C as ae}from"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import{S as U}from"../chunks/WarningFilled.js";import{useText as be}from"@dropins/tools/i18n.js";import"../chunks/state.js";import{d as Fa,c as Aa,s as xa,a as Wa,o as Ua}from"../chunks/openQuoteTemplate.js";import{g as Oa}from"../chunks/generateQuoteFromTemplate.js";import{S as Ga}from"../chunks/ShippingAddressDisplay.js";import{I as $a}from"../chunks/ItemsQuotedTemplate.js";import{Q as za}from"../chunks/QuoteTemplateCommentsList.js";import{Q as Pa}from"../chunks/QuoteTemplateHistoryLog.js";import{S as pe}from"../chunks/CheckWithCircle.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/LineItemNoteModal.js";import"../chunks/addQuoteTemplateLineItemNote.js";import"../chunks/QuoteCommentsList.js";import"../chunks/QuoteHistoryLog.js";const ja=({className:n,loading:u,templateName:c,templateStatus:q,banner:e,details:N,actionBar:Q,referenceDocuments:b,itemsTable:M,shippingInformationTitle:m,shippingInformation:r,commentsTitle:v,comments:g,footer:T,...y})=>u?a(Va,{}):p("div",{...y,className:d(["quote-management-manage-negotiable-quote-template",n]),children:[p("div",{className:d(["quote-management-manage-negotiable-quote-template__header"]),children:[c&&a(I,{node:c,className:d(["quote-management-manage-negotiable-quote-template__template-name"])}),q&&a(I,{node:q,className:d(["quote-management-manage-negotiable-quote-template__template-status"])})]}),e&&a(I,{node:e,className:d(["quote-management-manage-negotiable-quote-template__banner"])}),N&&a(I,{node:N,className:d(["quote-management-manage-negotiable-quote-template__details"])}),Q&&a(I,{node:Q,className:d(["quote-management-manage-negotiable-quote-template__action-bar"])}),b&&a("div",{"data-testid":"reference-documents-container",className:d(["quote-management-manage-negotiable-quote-template__reference-documents-container"]),children:a(I,{node:b,className:d(["quote-management-manage-negotiable-quote-template__reference-documents"])})}),M&&a(I,{node:M,className:d(["quote-management-manage-negotiable-quote-template__items-table"])}),p("div",{"data-testid":"template-shipping-information-container",className:d(["quote-management-manage-negotiable-quote-template__shipping-information-container"]),children:[m&&a(I,{node:m,className:d(["quote-management-manage-negotiable-quote-template__shipping-information-title"])}),r&&a(I,{node:r,className:d(["quote-management-manage-negotiable-quote-template__shipping-information"])})]}),p("div",{"data-testid":"comments-container",className:d(["quote-management-manage-negotiable-quote-template__comments-container"]),children:[v&&a(I,{node:v,className:d(["quote-management-manage-negotiable-quote-template__comments-title"])}),g&&a(I,{node:g,className:d(["quote-management-manage-negotiable-quote-template__comments"])})]}),T&&a(I,{node:T,className:d(["quote-management-manage-negotiable-quote-template__footer"])})]}),Va=()=>p(La,{"data-testid":"manage-negotiable-quote-template-skeleton",children:[a(W,{variant:"heading",fullWidth:!0,size:"large"}),a(W,{variant:"row",fullWidth:!1,size:"small"}),a(W,{variant:"row",fullWidth:!1,size:"small"}),a(W,{variant:"row",fullWidth:!0}),a(W,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),a(W,{variant:"row",fullWidth:!1,size:"small"})]}),Ja=({className:n,open:u,document:c,errorMessage:q,errorBanner:e,successBanner:N,showCloseButton:Q=!0,isSubmitting:b=!1,onSave:M,onClose:m})=>{const[r,v]=l(""),[g,T]=l(""),[y,w]=l(""),[_,R]=l({}),C=be({title:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.title",documentNameLabel:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentNameLabel",documentIdentifierLabel:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentIdentifierLabel",referenceUrlLabel:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.referenceUrlLabel",addButton:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.addButton",updateButton:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.updateButton",cancelButton:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.cancelButton",documentNameRequired:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentNameRequired",documentIdentifierRequired:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentIdentifierRequired",referenceUrlRequired:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.referenceUrlRequired",invalidUrl:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.invalidUrl",errorHeading:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.errorHeading"}),H=e||(q?a(L,{type:"error",variant:"primary",icon:a(U,{}),heading:C.errorHeading,description:q,"data-testid":"reference-document-form-modal-error-banner-inline"}):null),A=!!c;ne(()=>{u&&(c?(v(c.name||""),T(c.identifier||""),w(c.url||"")):(v(""),T(""),w("")),R({}))},[u,c]);const S=s(f=>{if(!f.trim())return!1;try{return new URL(f),!0}catch{return!1}},[]),te=s(()=>{const f={};if(r.trim()||(f.documentName=C.documentNameRequired),y.trim()?S(y.trim())||(f.referenceUrl=C.invalidUrl):f.referenceUrl=C.referenceUrlRequired,g.trim()||(f.documentIdentifier=C.documentIdentifierRequired),Object.keys(f).length>0){R(f);return}M({uid:c==null?void 0:c.uid,name:r.trim(),identifier:g.trim(),url:y.trim()})},[r,g,y,c,C,S,M]),B=s(()=>{v(""),T(""),w(""),R({}),m==null||m()},[m]);return u?p(Ea,{open:u,size:"medium",title:a(fe,{children:C.title}),onClose:B,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:Q,className:d(["quote-management-reference-document-form-modal",n]),"data-testid":"reference-document-form-modal",children:[H&&a("div",{className:d(["quote-management-reference-document-form-modal__error-banner"]),"data-testid":"reference-document-form-modal-error-banner",children:H}),N&&a("div",{className:d(["quote-management-reference-document-form-modal__success-banner"]),"data-testid":"reference-document-form-modal-success-banner",children:N}),p("div",{className:d(["quote-management-reference-document-form-modal__content"]),children:[p("div",{children:[a(ge,{name:"documentName",type:"text",value:r,onInput:f=>{v(f.target.value),R({..._,documentName:void 0})},floatingLabel:C.documentNameLabel,required:!0,error:!!_.documentName,disabled:b,"data-testid":"reference-document-name-input"}),_.documentName&&a("span",{className:d(["quote-management-reference-document-form-modal__error-text"]),"data-testid":"reference-document-name-error",children:_.documentName})]}),p("div",{children:[a(ge,{name:"documentIdentifier",type:"text",value:g,onInput:f=>{T(f.target.value),R({..._,documentIdentifier:void 0})},floatingLabel:C.documentIdentifierLabel,error:!!_.documentIdentifier,disabled:b,"data-testid":"reference-document-identifier-input"}),_.documentIdentifier&&a("span",{className:d(["quote-management-reference-document-form-modal__error-text"]),"data-testid":"reference-document-identifier-error",children:_.documentIdentifier})]}),p("div",{children:[a(ge,{name:"referenceUrl",type:"url",value:y,onInput:f=>{w(f.target.value),R({..._,referenceUrl:void 0})},floatingLabel:C.referenceUrlLabel,required:!0,error:!!_.referenceUrl,disabled:b,"data-testid":"reference-document-url-input"}),_.referenceUrl&&a("span",{className:d(["quote-management-reference-document-form-modal__error-text"]),"data-testid":"reference-document-url-error",children:_.referenceUrl})]})]}),p("div",{className:d(["quote-management-reference-document-form-modal__actions"]),children:[a(k,{variant:"secondary",size:"medium",onClick:B,disabled:b,className:d(["quote-management-reference-document-form-modal__cancel-button"]),"data-testid":"reference-document-form-cancel-button",children:C.cancelButton}),a(k,{variant:"primary",size:"medium",onClick:te,disabled:b,className:d(["quote-management-reference-document-form-modal__save-button"]),"data-testid":"reference-document-form-save-button",children:A?C.updateButton:C.addButton})]})]}):null},Ka=({className:n,documents:u,isEditable:c=!1,onAdd:q,onEdit:e,onRemove:N,...Q})=>{const b=be({add:"NegotiableQuoteTemplate.Manage.referenceDocuments.add",edit:"NegotiableQuoteTemplate.Manage.referenceDocuments.edit",remove:"NegotiableQuoteTemplate.Manage.referenceDocuments.remove",noReferenceDocuments:"NegotiableQuoteTemplate.Manage.referenceDocuments.noReferenceDocuments"}),M=r=>r.identifier?`${r.name}, ${r.identifier}`:`${r.name} ${r.url}`,m=(r,v)=>{r.preventDefault(),window.open(v,"_blank","noopener,noreferrer")};return a("div",{className:d(["quote-management-reference-documents-list",n]),"data-testid":"reference-documents-list",...Q,children:p("div",{className:"quote-management-reference-documents-list__content",children:[u.map(r=>p("div",{className:"quote-management-reference-documents-list__document","data-testid":`reference-document-${r.uid||r.url}`,children:[a("a",{href:r.url,onClick:v=>m(v,r.url),className:"quote-management-reference-documents-list__document-link",target:"_blank",rel:"noopener noreferrer","data-testid":`reference-document-link-${r.uid||r.url}`,children:M(r)}),c&&p("div",{className:"quote-management-reference-documents-list__document-actions",children:[a(k,{variant:"tertiary",onClick:()=>e==null?void 0:e(r),className:"quote-management-reference-documents-list__edit-button","data-testid":`reference-document-edit-${r.uid||r.url}`,children:b.edit}),a("span",{className:"quote-management-reference-documents-list__separator",children:"|"}),a(k,{variant:"tertiary",onClick:()=>N==null?void 0:N(r),className:"quote-management-reference-documents-list__remove-button","data-testid":`reference-document-remove-${r.uid||r.url}`,children:b.remove})]})]},r.uid||r.url)),c&&p(k,{variant:"tertiary",onClick:q,className:"quote-management-reference-documents-list__add-button","data-testid":"reference-documents-add-button",children:["+ ",b.add]}),u.length===0&&!c&&a("div",{className:"quote-management-reference-documents-list__empty",children:b.noReferenceDocuments})]})})},Xa=n=>{const{templateReferenceDocuments:u,localReferenceDocuments:c}=n,q=s(m=>{if(u)return u.find(r=>m.uid&&r.uid?r.uid===m.uid:r.url===m.url)},[u]),e=s(m=>q(m)!==void 0,[q]),N=s((m,r)=>m.name!==r.name||m.identifier!==r.identifier||m.url!==r.url,[]),Q=s(()=>u?c.filter(m=>!u.some(r=>m.uid&&r.uid?r.uid===m.uid:r.url===m.url)):c,[u,c]),b=s(()=>c.map(m=>({uid:m.uid,name:m.name,identifier:m.identifier,url:m.url})),[c]),M=h(()=>u?c.some(g=>q(g)===void 0)||u.some(g=>!c.some(T=>T.uid&&g.uid?T.uid===g.uid:T.url===g.url))?!0:c.some(g=>{const T=q(g);return T?N(g,T):!1}):c.length>0,[u,c,q,N]);return{isDocumentInTemplateData:e,getNewDocuments:Q,getReferenceDocumentLinks:b,hasUnsavedChanges:M}},Ya=(n={})=>{const{initialTemplateName:u,templateNameRequiredErrorMessage:c="Template name is required"}=n,[q,e]=l(!1),[N,Q]=l(""),[b,M]=l(""),[m,r]=l(""),[v,g]=l(""),[T,y]=l(""),w=s(S=>{Q(S||u||""),M(""),r(""),g(""),y(""),e(!0)},[u]),_=s(()=>{e(!1),Q(""),M(""),r(""),g(""),y("")},[]),R=s(S=>{Q(S),S.trim()&&g("")},[]),C=s(S=>{M(S)},[]),H=s(()=>N.trim()?(r(""),g(""),e(!1),!0):(g(c),!1),[N,c]),A=s(()=>{Q(""),M(""),r(""),g(""),y("")},[]);return{isRenameModalOpen:q,renameTemplateName:N,renameReason:b,renameError:m,renameTemplateNameError:v,renameSuccess:T,handleRenameClick:w,handleRenameClose:_,handleRenameTemplateNameChange:R,handleRenameReasonChange:C,handleRenameSave:H,resetRenameState:A}},wn=({slots:n,onActionsButtonClick:u,onSendForReview:c,...q})=>{var Ue;const[e,N]=l(void 0),[Q,b]=l(!0),[M,m]=l(""),[r,v]=l(!1),[g,T]=l(!1),[y,w]=l(null),[_,R]=l(!1),[C,H]=l(!1),[A,S]=l(null),[te,B]=l(!1),[f,O]=l([]),[Me,P]=l(!1),[j,V]=l(void 0),[$e,J]=l(null),[he,Te]=l(!1),[Ne,Qe]=l(!1),[ve,K]=l(""),[Ce,X]=l(""),[qe,re]=l(!1),[_e,ye]=l(!1),[Re,G]=l(""),[Se,Y]=l(""),De=Sa(!1),{getReferenceDocumentLinks:Le,hasUnsavedChanges:Ee}=Xa({templateReferenceDocuments:e==null?void 0:e.referenceDocuments,localReferenceDocuments:f}),t=be({createdLabel:"NegotiableQuoteTemplate.Manage.createdLabel",salesRepLabel:"NegotiableQuoteTemplate.Manage.salesRepLabel",expiresLabel:"NegotiableQuoteTemplate.Manage.expiresLabel",templateIdLabel:"NegotiableQuoteTemplate.Manage.templateIdLabel",actionsLabel:"NegotiableQuoteTemplate.Manage.actionsLabel",referenceDocumentsTitle:"NegotiableQuoteTemplate.Manage.referenceDocuments.title",commentsTitle:"NegotiableQuoteTemplate.Manage.comments.title",historyLogTitle:"NegotiableQuoteTemplate.Manage.historyLog.title",itemsQuotedTab:"NegotiableQuoteTemplate.Manage.tabs.itemsQuoted",commentsTab:"NegotiableQuoteTemplate.Manage.tabs.comments",historyLogTab:"NegotiableQuoteTemplate.Manage.tabs.historyLog",templateCommentsPlaceholder:"NegotiableQuoteTemplate.Manage.templateComments.placeholder",sendForReview:"NegotiableQuoteTemplate.Manage.actionButtons.sendForReview",delete:"NegotiableQuoteTemplate.Manage.actionButtons.delete",cancel:"NegotiableQuoteTemplate.Manage.actionButtons.cancel",confirmationModalDeleteTitle:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.errorFallback",confirmationModalDeleteSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.successDescription",confirmationModalCancelTitle:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.title",confirmationModalCancelMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.message",confirmationModalCancelConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.confirm",confirmationModalCancelErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.errorHeading",confirmationModalCancelErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.errorFallback",confirmationModalCancelSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.successHeading",confirmationModalCancelSuccessDescription:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.successDescription",confirmationModalCancel:"NegotiableQuoteTemplate.Manage.confirmationModal.cancel",accept:"NegotiableQuoteTemplate.Manage.actionButtons.accept",generateQuote:"NegotiableQuoteTemplate.Manage.actionButtons.generateQuote",generateQuoteModalTitle:"NegotiableQuoteTemplate.Manage.actionButtons.generateQuote",generateQuoteModalMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.message",generateQuoteModalCancel:"NegotiableQuoteTemplate.Manage.confirmationModal.cancel",generateQuoteModalConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.confirm",generateQuoteModalConfirmLoading:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.confirmLoading",generateQuoteModalSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.successHeading",generateQuoteSuccessMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.successDescription",generateQuoteModalErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.errorHeading",generateQuoteErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.errorFallback",acceptModalTitle:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.title",acceptModalMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.message",acceptModalCancel:"NegotiableQuoteTemplate.Manage.confirmationModal.cancel",acceptModalConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.confirm",acceptModalConfirmLoading:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.confirmLoading",acceptModalSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.successHeading",acceptSuccessMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.successDescription",acceptModalErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.errorHeading",acceptErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.errorFallback",documentDuplicateUidError:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.duplicateUidError",renameTitle:"NegotiableQuoteTemplate.Manage.rename.title",renameTemplateNameLabel:"NegotiableQuoteTemplate.Manage.rename.templateNameLabel",renameReasonLabel:"NegotiableQuoteTemplate.Manage.rename.reasonLabel",renameButton:"NegotiableQuoteTemplate.Manage.rename.renameButton",renameCancelButton:"NegotiableQuoteTemplate.Manage.rename.cancelButton",renameErrorHeading:"NegotiableQuoteTemplate.Manage.rename.errorHeading",renameTemplateNameRequired:"NegotiableQuoteTemplate.Manage.rename.templateNameRequired",renameErrorDefault:"NegotiableQuoteTemplate.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuoteTemplate.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuoteTemplate.Manage.rename.successMessage",shippingInformationTitle:"NegotiableQuoteTemplate.Manage.shippingInformation.title",unsavedChangesWarningHeading:"NegotiableQuoteTemplate.Manage.unsavedChangesWarningHeading",unsavedChangesWarningMessage:"NegotiableQuoteTemplate.Manage.unsavedChangesWarningMessage",shippingAddressWarningHeading:"NegotiableQuoteTemplate.Manage.shippingAddressWarningHeading",shippingAddressWarningMessage:"NegotiableQuoteTemplate.Manage.shippingAddressWarningMessage"}),{isRenameModalOpen:Ie,renameTemplateName:E,renameReason:$,renameError:oe,renameTemplateNameError:ze,renameSuccess:ie,handleRenameClick:we,handleRenameClose:Pe,handleRenameTemplateNameChange:je,handleRenameReasonChange:Ve,handleRenameSave:Je,resetRenameState:ke}=Ya({initialTemplateName:e==null?void 0:e.name,templateNameRequiredErrorMessage:t.renameTemplateNameRequired}),He=h(()=>E!==""&&E!==(e==null?void 0:e.name),[E,e==null?void 0:e.name]),z=h(()=>Ee||He,[Ee,He]);ne(()=>{const o=Da.on("quote-management/quote-template-data",i=>{i.quoteTemplate&&(N(i.quoteTemplate),b(!1),m(""),v(!1),O(i.quoteTemplate.referenceDocuments||[]),ke())},{eager:!0});return()=>o==null?void 0:o.off()},[ke]),ne(()=>{e!=null&&e.referenceDocuments&&O(e.referenceDocuments)},[e==null?void 0:e.referenceDocuments]),ne(()=>{e&&e.status===Ge.UPDATED&&!De.current&&(De.current=!0,(async()=>{try{await Ua({templateId:e.id})}catch(i){console.error("Failed to auto-open quote template:",i)}})())},[e]);const Ke=s(()=>{T(!1),w(null),R(!1)},[]),Xe=s(async()=>{if(e!=null&&e.id){w(null),R(!1);try{await Fa({templateId:e.id}),R(!0),setTimeout(()=>{T(!1),R(!1)},2e3)}catch(o){const i=o.message||t.confirmationModalDeleteErrorFallback;w(i)}}},[e,t.confirmationModalDeleteErrorFallback]),Ye=s(()=>{w(null)},[]),Ze=s(()=>{R(!1)},[]),ea=s(()=>{H(!1),S(null),B(!1)},[]),aa=s(async()=>{if(e!=null&&e.id){S(null),B(!1);try{await Aa({templateId:e.id}),B(!0),setTimeout(()=>{H(!1),B(!1)},2e3)}catch(o){const i=o.message||t.confirmationModalCancelErrorFallback;S(i)}}},[e,t.confirmationModalCancelErrorFallback]),na=s(()=>{S(null)},[]),ta=s(()=>{B(!1)},[]),ce=s(async()=>{const o=Le(),i=[$.trim(),M.trim()].filter(Boolean).join(`
|
|
3
|
+
import{jsx as a,jsxs as p,Fragment as Se}from"@dropins/tools/preact-jsx-runtime.js";import{useState as m,useEffect as ue,useCallback as s,useMemo as M,useRef as $a,createPortal as O}from"@dropins/tools/preact-compat.js";import{classes as u,VComponent as D,Slot as R}from"@dropins/tools/lib.js";import{f as na}from"../chunks/dateUtils.js";import{events as Ga}from"@dropins/tools/event-bus.js";import{Skeleton as Pa,SkeletonRow as $,InLineAlert as L,Modal as ja,Input as ye,Button as A,TextArea as Ka,InputFile as Va,Icon as se}from"@dropins/tools/components.js";import{N as ta}from"../chunks/transform-quote-template.js";import{S as Ja,A as Xa,T as Ya,R as Za}from"../chunks/RenameQuoteModal.js";import{v as en,f as an,a as nn,S as tn,A as rn}from"../chunks/AttachedFilesList.js";/* empty css */import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{C as de}from"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import{S as G}from"../chunks/WarningFilled.js";import{useText as De}from"@dropins/tools/i18n.js";import"../chunks/state.js";import{u as on}from"../chunks/uploadFile.js";import{d as cn,c as ln,s as mn,a as sn,o as dn}from"../chunks/openQuoteTemplate.js";import{g as un}from"../chunks/generateQuoteFromTemplate.js";import{S as gn}from"../chunks/ShippingAddressDisplay.js";import{I as fn}from"../chunks/ItemsQuotedTemplate.js";import{Q as pn}from"../chunks/QuoteTemplateCommentsList.js";import{Q as bn}from"../chunks/QuoteTemplateHistoryLog.js";import{S as Re}from"../chunks/CheckWithCircle.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/LineItemNoteModal.js";import"../chunks/addQuoteTemplateLineItemNote.js";import"../chunks/QuoteCommentsList.js";import"../chunks/QuoteHistoryLog.js";const hn=({className:n,loading:f,templateName:l,templateStatus:T,banner:C,details:h,actionBar:S,referenceDocuments:e,itemsTable:_,shippingInformationTitle:c,shippingInformation:o,commentsTitle:N,comments:b,attachFilesField:d,attachedFilesList:y,footer:E,...Q})=>f?a(Mn,{}):p("div",{...Q,className:u(["quote-management-manage-negotiable-quote-template",n]),children:[p("div",{className:u(["quote-management-manage-negotiable-quote-template__header"]),children:[l&&a(D,{node:l,className:u(["quote-management-manage-negotiable-quote-template__template-name"])}),T&&a(D,{node:T,className:u(["quote-management-manage-negotiable-quote-template__template-status"])})]}),C&&a(D,{node:C,className:u(["quote-management-manage-negotiable-quote-template__banner"])}),h&&a(D,{node:h,className:u(["quote-management-manage-negotiable-quote-template__details"])}),S&&a(D,{node:S,className:u(["quote-management-manage-negotiable-quote-template__action-bar"])}),e&&a("div",{"data-testid":"reference-documents-container",className:u(["quote-management-manage-negotiable-quote-template__reference-documents-container"]),children:a(D,{node:e,className:u(["quote-management-manage-negotiable-quote-template__reference-documents"])})}),_&&a(D,{node:_,className:u(["quote-management-manage-negotiable-quote-template__items-table"])}),p("div",{"data-testid":"template-shipping-information-container",className:u(["quote-management-manage-negotiable-quote-template__shipping-information-container"]),children:[c&&a(D,{node:c,className:u(["quote-management-manage-negotiable-quote-template__shipping-information-title"])}),o&&a(D,{node:o,className:u(["quote-management-manage-negotiable-quote-template__shipping-information"])})]}),p("div",{"data-testid":"comments-container",className:u(["quote-management-manage-negotiable-quote-template__comments-container"]),children:[N&&a(D,{node:N,className:u(["quote-management-manage-negotiable-quote-template__comments-title"])}),b&&a(D,{node:b,className:u(["quote-management-manage-negotiable-quote-template__comments"])}),d&&a(D,{node:d,className:u(["quote-management-manage-negotiable-quote-template__attach-files-field"])}),y&&a(D,{node:y,className:u(["quote-management-manage-negotiable-quote-template__attached-files-list"])})]}),E&&a(D,{node:E,className:u(["quote-management-manage-negotiable-quote-template__footer"])})]}),Mn=()=>p(Pa,{"data-testid":"manage-negotiable-quote-template-skeleton",children:[a($,{variant:"heading",fullWidth:!0,size:"large"}),a($,{variant:"row",fullWidth:!1,size:"small"}),a($,{variant:"row",fullWidth:!1,size:"small"}),a($,{variant:"row",fullWidth:!0}),a($,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),a($,{variant:"row",fullWidth:!1,size:"small"})]}),Nn=({className:n,open:f,document:l,errorMessage:T,errorBanner:C,successBanner:h,showCloseButton:S=!0,isSubmitting:e=!1,onSave:_,onClose:c})=>{const[o,N]=m(""),[b,d]=m(""),[y,E]=m(""),[Q,w]=m({}),v=De({title:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.title",documentNameLabel:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentNameLabel",documentIdentifierLabel:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentIdentifierLabel",referenceUrlLabel:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.referenceUrlLabel",addButton:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.addButton",updateButton:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.updateButton",cancelButton:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.cancelButton",documentNameRequired:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentNameRequired",documentIdentifierRequired:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.documentIdentifierRequired",referenceUrlRequired:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.referenceUrlRequired",invalidUrl:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.invalidUrl",errorHeading:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.errorHeading"}),z=C||(T?a(L,{type:"error",variant:"primary",icon:a(G,{}),heading:v.errorHeading,description:T,"data-testid":"reference-document-form-modal-error-banner-inline"}):null),B=!!l;ue(()=>{f&&(l?(N(l.name||""),d(l.identifier||""),E(l.url||"")):(N(""),d(""),E("")),w({}))},[f,l]);const F=s(q=>{if(!q.trim())return!1;try{return new URL(q),!0}catch{return!1}},[]),P=s(()=>{const q={};if(o.trim()||(q.documentName=v.documentNameRequired),y.trim()?F(y.trim())||(q.referenceUrl=v.invalidUrl):q.referenceUrl=v.referenceUrlRequired,b.trim()||(q.documentIdentifier=v.documentIdentifierRequired),Object.keys(q).length>0){w(q);return}_({uid:l==null?void 0:l.uid,name:o.trim(),identifier:b.trim(),url:y.trim()})},[o,b,y,l,v,F,_]),j=s(()=>{N(""),d(""),E(""),w({}),c==null||c()},[c]);return f?p(ja,{open:f,size:"medium",title:a(Se,{children:v.title}),onClose:j,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:S,className:u(["quote-management-reference-document-form-modal",n]),"data-testid":"reference-document-form-modal",children:[z&&a("div",{className:u(["quote-management-reference-document-form-modal__error-banner"]),"data-testid":"reference-document-form-modal-error-banner",children:z}),h&&a("div",{className:u(["quote-management-reference-document-form-modal__success-banner"]),"data-testid":"reference-document-form-modal-success-banner",children:h}),p("div",{className:u(["quote-management-reference-document-form-modal__content"]),children:[p("div",{children:[a(ye,{name:"documentName",type:"text",value:o,onInput:q=>{N(q.target.value),w({...Q,documentName:void 0})},floatingLabel:v.documentNameLabel,required:!0,error:!!Q.documentName,disabled:e,"data-testid":"reference-document-name-input"}),Q.documentName&&a("span",{className:u(["quote-management-reference-document-form-modal__error-text"]),"data-testid":"reference-document-name-error",children:Q.documentName})]}),p("div",{children:[a(ye,{name:"documentIdentifier",type:"text",value:b,onInput:q=>{d(q.target.value),w({...Q,documentIdentifier:void 0})},floatingLabel:v.documentIdentifierLabel,error:!!Q.documentIdentifier,disabled:e,"data-testid":"reference-document-identifier-input"}),Q.documentIdentifier&&a("span",{className:u(["quote-management-reference-document-form-modal__error-text"]),"data-testid":"reference-document-identifier-error",children:Q.documentIdentifier})]}),p("div",{children:[a(ye,{name:"referenceUrl",type:"url",value:y,onInput:q=>{E(q.target.value),w({...Q,referenceUrl:void 0})},floatingLabel:v.referenceUrlLabel,required:!0,error:!!Q.referenceUrl,disabled:e,"data-testid":"reference-document-url-input"}),Q.referenceUrl&&a("span",{className:u(["quote-management-reference-document-form-modal__error-text"]),"data-testid":"reference-document-url-error",children:Q.referenceUrl})]})]}),p("div",{className:u(["quote-management-reference-document-form-modal__actions"]),children:[a(A,{variant:"secondary",size:"medium",onClick:j,disabled:e,className:u(["quote-management-reference-document-form-modal__cancel-button"]),"data-testid":"reference-document-form-cancel-button",children:v.cancelButton}),a(A,{variant:"primary",size:"medium",onClick:P,disabled:e,className:u(["quote-management-reference-document-form-modal__save-button"]),"data-testid":"reference-document-form-save-button",children:B?v.updateButton:v.addButton})]})]}):null},Tn=({className:n,documents:f,isEditable:l=!1,onAdd:T,onEdit:C,onRemove:h,...S})=>{const e=De({add:"NegotiableQuoteTemplate.Manage.referenceDocuments.add",edit:"NegotiableQuoteTemplate.Manage.referenceDocuments.edit",remove:"NegotiableQuoteTemplate.Manage.referenceDocuments.remove",noReferenceDocuments:"NegotiableQuoteTemplate.Manage.referenceDocuments.noReferenceDocuments"}),_=o=>o.identifier?`${o.name}, ${o.identifier}`:`${o.name} ${o.url}`,c=(o,N)=>{o.preventDefault(),window.open(N,"_blank","noopener,noreferrer")};return a("div",{className:u(["quote-management-reference-documents-list",n]),"data-testid":"reference-documents-list",...S,children:p("div",{className:"quote-management-reference-documents-list__content",children:[f.map(o=>p("div",{className:"quote-management-reference-documents-list__document","data-testid":`reference-document-${o.uid||o.url}`,children:[a("a",{href:o.url,onClick:N=>c(N,o.url),className:"quote-management-reference-documents-list__document-link",target:"_blank",rel:"noopener noreferrer","data-testid":`reference-document-link-${o.uid||o.url}`,children:_(o)}),l&&p("div",{className:"quote-management-reference-documents-list__document-actions",children:[a(A,{variant:"tertiary",onClick:()=>C==null?void 0:C(o),className:"quote-management-reference-documents-list__edit-button","data-testid":`reference-document-edit-${o.uid||o.url}`,children:e.edit}),a("span",{className:"quote-management-reference-documents-list__separator",children:"|"}),a(A,{variant:"tertiary",onClick:()=>h==null?void 0:h(o),className:"quote-management-reference-documents-list__remove-button","data-testid":`reference-document-remove-${o.uid||o.url}`,children:e.remove})]})]},o.uid||o.url)),l&&p(A,{variant:"tertiary",onClick:T,className:"quote-management-reference-documents-list__add-button","data-testid":"reference-documents-add-button",children:["+ ",e.add]}),f.length===0&&!l&&a("div",{className:"quote-management-reference-documents-list__empty",children:e.noReferenceDocuments})]})})},Qn=n=>{const{templateReferenceDocuments:f,localReferenceDocuments:l}=n,T=s(c=>{if(f)return f.find(o=>c.uid&&o.uid?o.uid===c.uid:o.url===c.url)},[f]),C=s(c=>T(c)!==void 0,[T]),h=s((c,o)=>c.name!==o.name||c.identifier!==o.identifier||c.url!==o.url,[]),S=s(()=>f?l.filter(c=>!f.some(o=>c.uid&&o.uid?o.uid===c.uid:o.url===c.url)):l,[f,l]),e=s(()=>l.map(c=>({uid:c.uid,name:c.name,identifier:c.identifier,url:c.url})),[l]),_=M(()=>f?l.some(b=>T(b)===void 0)||f.some(b=>!l.some(d=>d.uid&&b.uid?d.uid===b.uid:d.url===b.url))?!0:l.some(b=>{const d=T(b);return d?h(b,d):!1}):l.length>0,[f,l,T,h]);return{isDocumentInTemplateData:C,getNewDocuments:S,getReferenceDocumentLinks:e,hasUnsavedChanges:_}},vn=(n={})=>{const{initialTemplateName:f,templateNameRequiredErrorMessage:l="Template name is required"}=n,[T,C]=m(!1),[h,S]=m(""),[e,_]=m(""),[c,o]=m(""),[N,b]=m(""),[d,y]=m(""),E=s(F=>{S(F||f||""),_(""),o(""),b(""),y(""),C(!0)},[f]),Q=s(()=>{C(!1),S(""),_(""),o(""),b(""),y("")},[]),w=s(F=>{S(F),F.trim()&&b("")},[]),v=s(F=>{_(F)},[]),z=s(()=>h.trim()?(o(""),b(""),C(!1),!0):(b(l),!1),[h,l]),B=s(()=>{S(""),_(""),o(""),b(""),y("")},[]);return{isRenameModalOpen:T,renameTemplateName:h,renameReason:e,renameError:c,renameTemplateNameError:N,renameSuccess:d,handleRenameClick:E,handleRenameClose:Q,handleRenameTemplateNameChange:w,handleRenameReasonChange:v,handleRenameSave:z,resetRenameState:B}},rt=({slots:n,onActionsButtonClick:f,onSendForReview:l,maxFiles:T,maxFileSize:C,acceptedFileTypes:h,...S})=>{var aa;const[e,_]=m(void 0),[c,o]=m(!0),[N,b]=m(""),[d,y]=m(!1),[E,Q]=m(!1),[w,v]=m(null),[z,B]=m(!1),[F,P]=m(!1),[j,q]=m(null),[ra,K]=m(!1),[x,V]=m([]),[Le,ee]=m(!1),[ae,ne]=m(void 0),[oa,te]=m(null),[Ee,Fe]=m(!1),[ke,Ie]=m(!1),[we,re]=m(""),[He,oe]=m(""),[Ae,ge]=m(!1),[Be,xe]=m(!1),[Ue,J]=m(""),[We,ie]=m(""),ze=$a(!1),[k,X]=m([]),[ce,le]=m(void 0),{getReferenceDocumentLinks:Oe,hasUnsavedChanges:$e}=Qn({templateReferenceDocuments:e==null?void 0:e.referenceDocuments,localReferenceDocuments:x}),t=De({createdLabel:"NegotiableQuoteTemplate.Manage.createdLabel",salesRepLabel:"NegotiableQuoteTemplate.Manage.salesRepLabel",expiresLabel:"NegotiableQuoteTemplate.Manage.expiresLabel",templateIdLabel:"NegotiableQuoteTemplate.Manage.templateIdLabel",actionsLabel:"NegotiableQuoteTemplate.Manage.actionsLabel",referenceDocumentsTitle:"NegotiableQuoteTemplate.Manage.referenceDocuments.title",commentsTitle:"NegotiableQuoteTemplate.Manage.comments.title",historyLogTitle:"NegotiableQuoteTemplate.Manage.historyLog.title",itemsQuotedTab:"NegotiableQuoteTemplate.Manage.tabs.itemsQuoted",commentsTab:"NegotiableQuoteTemplate.Manage.tabs.comments",historyLogTab:"NegotiableQuoteTemplate.Manage.tabs.historyLog",templateCommentsPlaceholder:"NegotiableQuoteTemplate.Manage.templateComments.placeholder",sendForReview:"NegotiableQuoteTemplate.Manage.actionButtons.sendForReview",delete:"NegotiableQuoteTemplate.Manage.actionButtons.delete",cancel:"NegotiableQuoteTemplate.Manage.actionButtons.cancel",attachFiles:"NegotiableQuote.Manage.attachFiles",fileUploadError:"NegotiableQuote.Manage.fileUploadError",maxFilesExceeded:"NegotiableQuote.Manage.maxFilesExceeded",maxFileSizeExceeded:"NegotiableQuote.Manage.maxFileSizeExceeded",invalidFileType:"NegotiableQuote.Manage.invalidFileType",confirmationModalDeleteTitle:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.errorFallback",confirmationModalDeleteSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuoteTemplate.Manage.confirmationModal.delete.successDescription",confirmationModalCancelTitle:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.title",confirmationModalCancelMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.message",confirmationModalCancelConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.confirm",confirmationModalCancelErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.errorHeading",confirmationModalCancelErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.errorFallback",confirmationModalCancelSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.successHeading",confirmationModalCancelSuccessDescription:"NegotiableQuoteTemplate.Manage.confirmationModal.cancelTemplate.successDescription",confirmationModalCancel:"NegotiableQuoteTemplate.Manage.confirmationModal.cancel",accept:"NegotiableQuoteTemplate.Manage.actionButtons.accept",generateQuote:"NegotiableQuoteTemplate.Manage.actionButtons.generateQuote",generateQuoteModalTitle:"NegotiableQuoteTemplate.Manage.actionButtons.generateQuote",generateQuoteModalMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.message",generateQuoteModalCancel:"NegotiableQuoteTemplate.Manage.confirmationModal.cancel",generateQuoteModalConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.confirm",generateQuoteModalConfirmLoading:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.confirmLoading",generateQuoteModalSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.successHeading",generateQuoteSuccessMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.successDescription",generateQuoteModalErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.errorHeading",generateQuoteErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.generateQuote.errorFallback",acceptModalTitle:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.title",acceptModalMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.message",acceptModalCancel:"NegotiableQuoteTemplate.Manage.confirmationModal.cancel",acceptModalConfirm:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.confirm",acceptModalConfirmLoading:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.confirmLoading",acceptModalSuccessHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.successHeading",acceptSuccessMessage:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.successDescription",acceptModalErrorHeading:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.errorHeading",acceptErrorFallback:"NegotiableQuoteTemplate.Manage.confirmationModal.accept.errorFallback",documentDuplicateUidError:"NegotiableQuoteTemplate.Manage.referenceDocuments.form.duplicateUidError",renameTitle:"NegotiableQuoteTemplate.Manage.rename.title",renameTemplateNameLabel:"NegotiableQuoteTemplate.Manage.rename.templateNameLabel",renameReasonLabel:"NegotiableQuoteTemplate.Manage.rename.reasonLabel",renameButton:"NegotiableQuoteTemplate.Manage.rename.renameButton",renameCancelButton:"NegotiableQuoteTemplate.Manage.rename.cancelButton",renameErrorHeading:"NegotiableQuoteTemplate.Manage.rename.errorHeading",renameTemplateNameRequired:"NegotiableQuoteTemplate.Manage.rename.templateNameRequired",renameErrorDefault:"NegotiableQuoteTemplate.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuoteTemplate.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuoteTemplate.Manage.rename.successMessage",shippingInformationTitle:"NegotiableQuoteTemplate.Manage.shippingInformation.title",unsavedChangesWarningHeading:"NegotiableQuoteTemplate.Manage.unsavedChangesWarningHeading",unsavedChangesWarningMessage:"NegotiableQuoteTemplate.Manage.unsavedChangesWarningMessage",shippingAddressWarningHeading:"NegotiableQuoteTemplate.Manage.shippingAddressWarningHeading",shippingAddressWarningMessage:"NegotiableQuoteTemplate.Manage.shippingAddressWarningMessage"}),{isRenameModalOpen:Ge,renameTemplateName:I,renameReason:Y,renameError:fe,renameTemplateNameError:ia,renameSuccess:pe,handleRenameClick:Pe,handleRenameClose:ca,handleRenameTemplateNameChange:la,handleRenameReasonChange:ma,handleRenameSave:sa,resetRenameState:je}=vn({initialTemplateName:e==null?void 0:e.name,templateNameRequiredErrorMessage:t.renameTemplateNameRequired}),Ke=M(()=>I!==""&&I!==(e==null?void 0:e.name),[I,e==null?void 0:e.name]),Z=M(()=>$e||Ke,[$e,Ke]),be=s(async r=>{if(T&&k.length+r.length>T){le(t.maxFilesExceeded.replace("{maxFiles}",String(T)));return}for(const g of r){if(C&&!en(g.size,C)){le(t.maxFileSizeExceeded.replace("{maxSize}",an(C)));return}if(h&&!nn(g.type,h)){le(t.invalidFileType);return}}le(void 0);const i=r.map(g=>({key:`temp-${Date.now()}-${Math.random()}-${g.name}`,name:g.name,size:g.size,status:"uploading"}));X(g=>[...g,...i]);for(let g=0;g<r.length;g++){const U=r[g],H=i[g].key;try{const Ce=await on(U);X(_e=>_e.map(W=>W.key===H?{...W,key:Ce.key,status:"success"}:W))}catch(Ce){X(_e=>_e.map(W=>W.key===H?{...W,status:"error",error:Ce.message}:W))}}},[T,C,h,k,t]),he=s(r=>{X(i=>i.filter(g=>g.key!==r))},[]);ue(()=>{const r=Ga.on("quote-management/quote-template-data",i=>{i.quoteTemplate&&(_(i.quoteTemplate),o(!1),b(""),y(!1),X([]),V(i.quoteTemplate.referenceDocuments||[]),je())},{eager:!0});return()=>r==null?void 0:r.off()},[je]),ue(()=>{e!=null&&e.referenceDocuments&&V(e.referenceDocuments)},[e==null?void 0:e.referenceDocuments]),ue(()=>{e&&e.status===ta.UPDATED&&!ze.current&&(ze.current=!0,(async()=>{try{await dn({templateId:e.id})}catch(i){console.error("Failed to auto-open quote template:",i)}})())},[e]);const da=s(()=>{Q(!1),v(null),B(!1)},[]),ua=s(async()=>{if(e!=null&&e.id){v(null),B(!1);try{await cn({templateId:e.id}),B(!0),setTimeout(()=>{Q(!1),B(!1)},2e3)}catch(r){const i=r.message||t.confirmationModalDeleteErrorFallback;v(i)}}},[e,t.confirmationModalDeleteErrorFallback]),ga=s(()=>{v(null)},[]),fa=s(()=>{B(!1)},[]),pa=s(()=>{P(!1),q(null),K(!1)},[]),ba=s(async()=>{if(e!=null&&e.id){q(null),K(!1);try{await ln({templateId:e.id}),K(!0),setTimeout(()=>{P(!1),K(!1)},2e3)}catch(r){const i=r.message||t.confirmationModalCancelErrorFallback;q(i)}}},[e,t.confirmationModalCancelErrorFallback]),ha=s(()=>{q(null)},[]),Ma=s(()=>{K(!1)},[]),Me=s(async()=>{const r=Oe(),i=k.filter(H=>H.status==="success"),g=[Y.trim(),N.trim()].filter(Boolean).join(`
|
|
4
4
|
|
|
5
|
-
`).trim()||void 0,F=E&&E!==(e==null?void 0:e.name)?E:void 0;if(c){c({templateData:e,name:F,comment:i,referenceDocumentLinks:o});return}v(!0);try{await xa({templateId:e.id,name:F,comment:i,referenceDocumentLinks:o.length>0?o:void 0})}catch(Ra){console.error("Failed to send quote template for review:",Ra),v(!1)}},[e,c,M,$,E,Le]),me=s(()=>{V(void 0),J(null),P(!0)},[]),le=s(o=>{V(o),J(null),P(!0)},[]),se=s(o=>{O(i=>i.filter(F=>F.uid!==o.uid||F.url!==o.url))},[]),ra=s(o=>{J(null),O(j?i=>i.map(F=>F.identifier===j.identifier?o:F):i=>[...i,o]),P(!1),V(void 0)},[j]),oa=s(()=>{P(!1),V(void 0),J(null)},[]),ia=s(async()=>{Qe(!0),X(""),K("");try{await Oa({templateId:e.id}),K(t.generateQuoteSuccessMessage)}catch(o){console.error("Failed to generate quote from template:",o);const i=o instanceof Error?o.message:t.generateQuoteErrorFallback;X(i)}finally{Qe(!1)}},[e,t.generateQuoteSuccessMessage,t.generateQuoteErrorFallback]),ca=s(()=>{Te(!1),X(""),K("")},[]),ma=s(async()=>{ye(!0),Y(""),G("");try{await Wa({templateId:e.id}),G(t.acceptSuccessMessage),setTimeout(()=>{re(!1),G("")},2e3)}catch(o){console.error("Failed to accept quote template:",o);const i=o instanceof Error?o.message:t.acceptErrorFallback;Y(i)}finally{ye(!1)}},[e,t.acceptSuccessMessage,t.acceptErrorFallback]),la=s(()=>{re(!1),Y(""),G("")},[]),sa=h(()=>{const o=!(e!=null&&e.canSendForReview),i=E||(e==null?void 0:e.name);return a(D,{name:"TemplateName",slot:n==null?void 0:n.TemplateName,context:{templateName:e==null?void 0:e.name,templateData:e,templateDisplayName:i,isRenameDisabled:o},children:p("div",{className:"quote-management-manage-negotiable-quote-template__template-name-wrapper",children:[a("h1",{"data-testid":"template-name",className:"quote-management-manage-negotiable-quote-template__template-name-title",children:i}),a("button",{onClick:()=>we(i),disabled:o,"data-testid":"rename-template-button",className:"quote-management-manage-negotiable-quote-template__rename-button","aria-label":"Rename template",children:a(wa,{})})]})})},[n==null?void 0:n.TemplateName,e,we,E]),da=h(()=>a(D,{name:"TemplateStatus",slot:n==null?void 0:n.TemplateStatus,context:{templateStatus:e==null?void 0:e.status,templateData:e},children:a("div",{"data-testid":"template-status",children:e==null?void 0:e.status})}),[n==null?void 0:n.TemplateStatus,e]),ua=h(()=>{if(!e)return;const o=e.expirationDate?Oe(e.expirationDate,"short"):void 0;return p(D,{name:"Details",slot:n==null?void 0:n.Details,context:{templateData:e},children:[p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"template-id-label",children:t.templateIdLabel}),a("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"template-id-value",children:e.id})]}),p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"created-label",children:t.createdLabel}),p("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"created-value",children:[Oe(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"sales-rep-label",children:t.salesRepLabel}),a("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),o&&p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"expires-label",children:t.expiresLabel}),a("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"expires-value",children:o})]})]})},[n==null?void 0:n.Details,t,e]),Be=h(()=>[{label:t.generateQuote,value:"generateQuote",disabled:!(e!=null&&e.canGenerateQuoteFromTemplate)}],[t,e==null?void 0:e.canGenerateQuoteFromTemplate]),ga=h(()=>{const o=i=>{switch(i){case"generateQuote":Te(!0),X(""),K(""),u==null||u(i);break}};return a(D,{name:"ActionBar",slot:n==null?void 0:n.ActionBar,context:{templateData:e},children:a(ka,{dropdownPlaceholder:t.actionsLabel,dropdownOptions:[],buttons:Be.map(i=>a(k,{variant:"tertiary",onClick:()=>o(i.value),"data-testid":`actions-bar-${i.value}-button`,"data-action":i.value,disabled:i.disabled,children:i.label},i.value))})})},[Be,t,n==null?void 0:n.ActionBar,e,u]),Z=h(()=>{const o=e==null?void 0:e.status;return o==="Draft"||o==="Open"},[e==null?void 0:e.status]),pa=h(()=>{const o=f.length>0||Z,i=o?t.referenceDocumentsTitle:void 0;return a(D,{name:"ReferenceDocuments",slot:n==null?void 0:n.ReferenceDocuments,context:{templateData:e,referenceDocuments:f,isEditable:Z,onAddDocument:me,onEditDocument:le,onRemoveDocument:se,referenceDocumentsTitle:t.referenceDocumentsTitle},children:p("div",{"data-testid":"reference-documents",children:[o&&a("h2",{children:i}),a(Ka,{documents:f,isEditable:Z,onAdd:me,onEdit:le,onRemove:se})]})})},[n==null?void 0:n.ReferenceDocuments,t,e,f,Z,me,le,se]),fa=h(()=>a(D,{name:"ShippingInformationTitle",slot:n==null?void 0:n.ShippingInformationTitle,context:{templateData:e},children:a("h2",{children:t.shippingInformationTitle})}),[n==null?void 0:n.ShippingInformationTitle,e,t]),ba=h(()=>{var o;return a(D,{name:"ShippingInformation",slot:n==null?void 0:n.ShippingInformation,context:{templateData:e,loading:Q,setLoading:b},children:a(Ga,{shippingAddress:(o=e==null?void 0:e.shippingAddresses)==null?void 0:o[0],loading:Q,"data-testid":"manage-template-shipping-address"})})},[n==null?void 0:n.ShippingInformation,e,Q,b]),Ma=h(()=>a(D,{name:"ItemsTable",slot:n==null?void 0:n.ItemsTable,context:{templateData:e},children:a(Ha,{tabs:new Map([["items-quoted",t.itemsQuotedTab],["comments",t.commentsTab],["history-log",t.historyLogTab]]),tabsContent:new Map([["items-quoted",a(D,{name:"ItemsQuotedTab",slot:n==null?void 0:n.ItemsQuotedTab,context:{templateData:e},children:a($a,{templateData:e})},"items-quoted")],["comments",a(D,{name:"CommentsTab",slot:n==null?void 0:n.CommentsTab,context:{templateData:e},children:a(za,{templateData:e})},"comments")],["history-log",a(D,{name:"HistoryLogTab",slot:n==null?void 0:n.HistoryLogTab,context:{templateData:e},children:a(Pa,{templateData:e})},"history-log")]])})}),[n==null?void 0:n.ItemsTable,n==null?void 0:n.ItemsQuotedTab,n==null?void 0:n.CommentsTab,n==null?void 0:n.HistoryLogTab,t,e]),ha=h(()=>a(D,{name:"CommentsTitle",slot:n==null?void 0:n.CommentsTitle,context:{templateData:e},children:a("h2",{children:t.commentsTitle})}),[n==null?void 0:n.CommentsTitle,t,e]),Ta=h(()=>a(D,{name:"Comments",slot:n==null?void 0:n.Comments,context:{templateData:e},children:a(Ia,{name:"templateComments",placeholder:t.templateCommentsPlaceholder,rows:3,value:M,onInput:o=>{m(o.target.value)},disabled:!(e!=null&&e.canSendForReview)||r})}),[n==null?void 0:n.Comments,t,e,M,r]),Fe=h(()=>z?a(L,{type:"warning",variant:"primary",icon:a(U,{}),heading:t.unsavedChangesWarningHeading,description:t.unsavedChangesWarningMessage,"data-testid":"unsaved-changes-warning-alert"}):void 0,[z,t.unsavedChangesWarningHeading,t.unsavedChangesWarningMessage]),Ae=h(()=>{var o;return(o=e==null?void 0:e.shippingAddresses)!=null&&o.length?void 0:a(L,{type:"warning",variant:"primary",icon:a(U,{}),heading:t.shippingAddressWarningHeading,description:t.shippingAddressWarningMessage,"data-testid":"shipping-address-warning-alert"})},[(Ue=e==null?void 0:e.shippingAddresses)==null?void 0:Ue.length,t.shippingAddressWarningHeading,t.shippingAddressWarningMessage]),Na=h(()=>p(fe,{children:[Fe,Ae]}),[Fe,Ae]),Qa=h(()=>{var i;const o=(e==null?void 0:e.status)===Ge.OPEN&&(e==null?void 0:e.canAccept);return p(D,{name:"Footer",slot:n==null?void 0:n.Footer,context:{templateData:e,comment:M,isSubmitting:r,referenceDocuments:f,hasUnsavedChanges:z,handleSendForReview:ce,showAcceptButton:o,renameTemplateName:E,renameReason:$},children:[o&&a(k,{variant:"primary",onClick:()=>{re(!0),Y(""),G("")},"data-testid":"accept-button",disabled:r||z,children:t.accept}),(e==null?void 0:e.canSendForReview)&&a(k,{variant:"primary",onClick:ce,"data-testid":"send-for-review-button",disabled:r||!((i=e==null?void 0:e.shippingAddresses)!=null&&i.length),children:t.sendForReview}),(e==null?void 0:e.canCancel)&&a(k,{variant:"tertiary",onClick:()=>H(!0),"data-testid":"cancel-template-button",disabled:r,children:t.cancel}),(e==null?void 0:e.canDelete)&&a(k,{variant:"tertiary",onClick:()=>T(!0),"data-testid":"delete-template-button",disabled:r,children:t.delete})]})},[n==null?void 0:n.Footer,t,e,M,r,ce,f,z,E,$]),va=y?a(L,{type:"error",variant:"primary",icon:a(U,{}),heading:t.confirmationModalDeleteErrorHeading,description:y,onDismiss:Ye,"data-testid":"confirmation-modal-error-banner"}):null,xe=(_?a(L,{type:"success",variant:"primary",icon:a(pe,{}),heading:t.confirmationModalDeleteSuccessHeading,description:t.confirmationModalDeleteSuccessDescription,onDismiss:Ze,"data-testid":"confirmation-modal-success-banner"}):null)||va,Ca=A?a(L,{type:"error",variant:"primary",icon:a(U,{}),heading:t.confirmationModalCancelErrorHeading,description:A,onDismiss:na,"data-testid":"confirmation-modal-cancel-error-banner"}):null,We=(te?a(L,{type:"success",variant:"primary",icon:a(pe,{}),heading:t.confirmationModalCancelSuccessHeading,description:t.confirmationModalCancelSuccessDescription,onDismiss:ta,"data-testid":"confirmation-modal-cancel-success-banner"}):null)||Ca,qa=h(()=>oe?a(L,{type:"error",variant:"primary",icon:a(U,{color:"var(--color-error)"}),heading:t.renameErrorHeading,description:oe}):void 0,[oe,t.renameErrorHeading]),_a=h(()=>ie?a(L,{type:"success",variant:"primary",icon:a(pe,{}),heading:t.renameSuccessHeading,description:ie}):void 0,[ie,t.renameSuccessHeading]),ya={...q,loading:Q,templateName:sa,templateStatus:da,banner:Na,details:ua,actionBar:ga,referenceDocuments:pa,itemsTable:Ma,shippingInformationTitle:fa,shippingInformation:ba,commentsTitle:ha,comments:Ta,footer:Qa};let de=null;ve?de=a(L,{type:"success",variant:"primary",icon:a(ee,{source:"CheckWithCircle"}),heading:t.generateQuoteModalSuccessHeading,description:ve,"data-testid":"generate-quote-success-banner"}):Ce&&(de=a(L,{type:"error",variant:"primary",icon:a(ee,{source:"WarningFilled"}),heading:t.generateQuoteModalErrorHeading,description:Ce,"data-testid":"generate-quote-error-banner"}));let ue=null;return Re?ue=a(L,{type:"success",variant:"primary",icon:a(ee,{source:"CheckWithCircle"}),heading:t.acceptModalSuccessHeading,description:Re,"data-testid":"accept-success-banner"}):Se&&(ue=a(L,{type:"error",variant:"primary",icon:a(ee,{source:"WarningFilled"}),heading:t.acceptModalErrorHeading,description:Se,"data-testid":"accept-error-banner"})),p(fe,{children:[a(ja,{...ya}),g&&x(a(ae,{open:g,title:t.confirmationModalDeleteTitle,message:t.confirmationModalDeleteMessage,cancelLabel:t.confirmationModalCancel,confirmLabel:t.confirmationModalDeleteConfirm,onCancel:Ke,onConfirm:Xe,showCloseButton:!xe,confirmationBanner:xe}),document.body),C&&x(a(ae,{open:C,title:t.confirmationModalCancelTitle,message:t.confirmationModalCancelMessage,cancelLabel:t.confirmationModalCancel,confirmLabel:t.confirmationModalCancelConfirm,onCancel:ea,onConfirm:aa,showCloseButton:!We,confirmationBanner:We}),document.body),Me&&x(a(Ja,{open:Me,document:j,errorMessage:$e||void 0,onSave:ra,onClose:oa,isSubmitting:r}),document.body),he&&x(a(ae,{open:he,title:t.generateQuoteModalTitle,message:t.generateQuoteModalMessage,cancelLabel:t.generateQuoteModalCancel,confirmLabel:Ne?t.generateQuoteModalConfirmLoading:t.generateQuoteModalConfirm,onCancel:ca,onConfirm:Ne?void 0:ia,showCloseButton:!0,confirmationBanner:de,"data-testid":"generate-quote-confirmation-modal"}),document.body),qe&&x(a(ae,{open:qe,title:t.acceptModalTitle,message:t.acceptModalMessage,cancelLabel:t.acceptModalCancel,confirmLabel:_e?t.acceptModalConfirmLoading:t.acceptModalConfirm,onCancel:la,onConfirm:_e?void 0:ma,showCloseButton:!0,confirmationBanner:ue,"data-testid":"accept-confirmation-modal"}),document.body),Ie&&x(a(Ba,{open:Ie,quoteName:E,renameReason:$,quoteNameError:ze,errorBanner:qa,successBanner:_a,onQuoteNameChange:je,onRenameReasonChange:Ve,onSave:Je,onClose:Pe}),document.body)]})};export{wn as ManageNegotiableQuoteTemplate,wn as default};
|
|
5
|
+
`).trim()||void 0,U=I&&I!==(e==null?void 0:e.name)?I:void 0;if(l){l({templateData:e,name:U,comment:g,referenceDocumentLinks:r,attachments:i.length?i:void 0});return}y(!0);try{await mn({templateId:e.id,name:U,comment:g,referenceDocumentLinks:r.length>0?r:void 0,attachments:i.length?i.map(H=>({key:H.key})):void 0})}catch(H){console.error("Failed to send quote template for review:",H),y(!1)}},[e,l,N,Y,I,Oe,k]),Ne=s(()=>{ne(void 0),te(null),ee(!0)},[]),Te=s(r=>{ne(r),te(null),ee(!0)},[]),Qe=s(r=>{V(i=>i.filter(g=>g.uid!==r.uid||g.url!==r.url))},[]),Na=s(r=>{te(null),V(ae?i=>i.map(g=>g.identifier===ae.identifier?r:g):i=>[...i,r]),ee(!1),ne(void 0)},[ae]),Ta=s(()=>{ee(!1),ne(void 0),te(null)},[]),Qa=s(async()=>{Ie(!0),oe(""),re("");try{await un({templateId:e.id}),re(t.generateQuoteSuccessMessage)}catch(r){console.error("Failed to generate quote from template:",r);const i=r instanceof Error?r.message:t.generateQuoteErrorFallback;oe(i)}finally{Ie(!1)}},[e,t.generateQuoteSuccessMessage,t.generateQuoteErrorFallback]),va=s(()=>{Fe(!1),oe(""),re("")},[]),qa=s(async()=>{xe(!0),ie(""),J("");try{await sn({templateId:e.id}),J(t.acceptSuccessMessage),setTimeout(()=>{ge(!1),J("")},2e3)}catch(r){console.error("Failed to accept quote template:",r);const i=r instanceof Error?r.message:t.acceptErrorFallback;ie(i)}finally{xe(!1)}},[e,t.acceptSuccessMessage,t.acceptErrorFallback]),Ca=s(()=>{ge(!1),ie(""),J("")},[]),_a=M(()=>{const r=!(e!=null&&e.canSendForReview),i=I||(e==null?void 0:e.name);return a(R,{name:"TemplateName",slot:n==null?void 0:n.TemplateName,context:{templateName:e==null?void 0:e.name,templateData:e,templateDisplayName:i,isRenameDisabled:r},children:p("div",{className:"quote-management-manage-negotiable-quote-template__template-name-wrapper",children:[a("h1",{"data-testid":"template-name",className:"quote-management-manage-negotiable-quote-template__template-name-title",children:i}),a("button",{onClick:()=>Pe(i),disabled:r,"data-testid":"rename-template-button",className:"quote-management-manage-negotiable-quote-template__rename-button","aria-label":"Rename template",children:a(Ja,{})})]})})},[n==null?void 0:n.TemplateName,e,Pe,I]),ya=M(()=>a(R,{name:"TemplateStatus",slot:n==null?void 0:n.TemplateStatus,context:{templateStatus:e==null?void 0:e.status,templateData:e},children:a("div",{"data-testid":"template-status",children:e==null?void 0:e.status})}),[n==null?void 0:n.TemplateStatus,e]),Ra=M(()=>{if(!e)return;const r=e.expirationDate?na(e.expirationDate,"short"):void 0;return p(R,{name:"Details",slot:n==null?void 0:n.Details,context:{templateData:e},children:[p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"template-id-label",children:t.templateIdLabel}),a("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"template-id-value",children:e.id})]}),p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"created-label",children:t.createdLabel}),p("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"created-value",children:[na(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"sales-rep-label",children:t.salesRepLabel}),a("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),r&&p("div",{className:"quote-management-manage-negotiable-quote-template__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote-template__detail-title","data-testid":"expires-label",children:t.expiresLabel}),a("span",{className:"quote-management-manage-negotiable-quote-template__detail-content","data-testid":"expires-value",children:r})]})]})},[n==null?void 0:n.Details,t,e]),Ve=M(()=>[{label:t.generateQuote,value:"generateQuote",disabled:!(e!=null&&e.canGenerateQuoteFromTemplate)}],[t,e==null?void 0:e.canGenerateQuoteFromTemplate]),Sa=M(()=>{const r=i=>{switch(i){case"generateQuote":Fe(!0),oe(""),re(""),f==null||f(i);break}};return a(R,{name:"ActionBar",slot:n==null?void 0:n.ActionBar,context:{templateData:e},children:a(Xa,{dropdownPlaceholder:t.actionsLabel,dropdownOptions:[],buttons:Ve.map(i=>a(A,{variant:"tertiary",onClick:()=>r(i.value),"data-testid":`actions-bar-${i.value}-button`,"data-action":i.value,disabled:i.disabled,children:i.label},i.value))})})},[Ve,t,n==null?void 0:n.ActionBar,e,f]),me=M(()=>{const r=e==null?void 0:e.status;return r==="Draft"||r==="Open"},[e==null?void 0:e.status]),Da=M(()=>{const r=x.length>0||me,i=r?t.referenceDocumentsTitle:void 0;return a(R,{name:"ReferenceDocuments",slot:n==null?void 0:n.ReferenceDocuments,context:{templateData:e,referenceDocuments:x,isEditable:me,onAddDocument:Ne,onEditDocument:Te,onRemoveDocument:Qe,referenceDocumentsTitle:t.referenceDocumentsTitle},children:p("div",{"data-testid":"reference-documents",children:[r&&a("h2",{children:i}),a(Tn,{documents:x,isEditable:me,onAdd:Ne,onEdit:Te,onRemove:Qe})]})})},[n==null?void 0:n.ReferenceDocuments,t,e,x,me,Ne,Te,Qe]),La=M(()=>a(R,{name:"ShippingInformationTitle",slot:n==null?void 0:n.ShippingInformationTitle,context:{templateData:e},children:a("h2",{children:t.shippingInformationTitle})}),[n==null?void 0:n.ShippingInformationTitle,e,t]),Ea=M(()=>{var r;return a(R,{name:"ShippingInformation",slot:n==null?void 0:n.ShippingInformation,context:{templateData:e,loading:c,setLoading:o},children:a(gn,{shippingAddress:(r=e==null?void 0:e.shippingAddresses)==null?void 0:r[0],loading:c,"data-testid":"manage-template-shipping-address"})})},[n==null?void 0:n.ShippingInformation,e,c,o]),Fa=M(()=>a(R,{name:"ItemsTable",slot:n==null?void 0:n.ItemsTable,context:{templateData:e},children:a(Ya,{tabs:new Map([["items-quoted",t.itemsQuotedTab],["comments",t.commentsTab],["history-log",t.historyLogTab]]),tabsContent:new Map([["items-quoted",a(R,{name:"ItemsQuotedTab",slot:n==null?void 0:n.ItemsQuotedTab,context:{templateData:e},children:a(fn,{templateData:e})},"items-quoted")],["comments",a(R,{name:"CommentsTab",slot:n==null?void 0:n.CommentsTab,context:{templateData:e},children:a(pn,{templateData:e})},"comments")],["history-log",a(R,{name:"HistoryLogTab",slot:n==null?void 0:n.HistoryLogTab,context:{templateData:e},children:a(bn,{templateData:e})},"history-log")]])})}),[n==null?void 0:n.ItemsTable,n==null?void 0:n.ItemsQuotedTab,n==null?void 0:n.CommentsTab,n==null?void 0:n.HistoryLogTab,t,e]),ka=M(()=>a(R,{name:"CommentsTitle",slot:n==null?void 0:n.CommentsTitle,context:{templateData:e},children:a("h2",{children:t.commentsTitle})}),[n==null?void 0:n.CommentsTitle,t,e]),Ia=M(()=>a(R,{name:"Comments",slot:n==null?void 0:n.Comments,context:{templateData:e},children:a(Ka,{name:"templateComments",placeholder:t.templateCommentsPlaceholder,rows:3,value:N,onInput:r=>{b(r.target.value)},disabled:!(e!=null&&e.canSendForReview)||d})}),[n==null?void 0:n.Comments,t,e,N,d]),Je=M(()=>!(e!=null&&e.canSendForReview),[e]),wa=M(()=>{const r=d||Je;return a(R,{name:"AttachFilesField",slot:n==null?void 0:n.AttachFilesField,context:{templateData:e,onFileChange:be,attachedFiles:k,fileUploadError:ce,disabled:r},children:p("div",{className:"quote-management-manage-negotiable-quote-template__attach-files",...r?{"data-disabled":!0}:{},"aria-disabled":r,children:[a(Va,{id:"manage-template-attach-files",multiple:!0,onChange:i=>{const g=i.target,U=g==null?void 0:g.files,H=U?Array.from(U):[];H.length>0&&be(H)},icon:a(tn,{}),disabled:r,"data-testid":"manage-template-attach-files",accept:h==null?void 0:h.join(","),children:t.attachFiles}),ce&&a("div",{className:"quote-management-manage-negotiable-quote-template__file-error","data-testid":"file-upload-error",children:ce})]})})},[n==null?void 0:n.AttachFilesField,e,be,d,Je,h,ce,t,k]),Ha=M(()=>{if(k.length)return a(R,{name:"AttachedFilesList",slot:n==null?void 0:n.AttachedFilesList,context:{templateData:e,files:k,onRemove:he,disabled:d},children:a(rn,{files:k,onRemove:he,disabled:d})})},[k,he,d,n==null?void 0:n.AttachedFilesList,e]),Xe=M(()=>Z?a(L,{type:"warning",variant:"primary",icon:a(G,{}),heading:t.unsavedChangesWarningHeading,description:t.unsavedChangesWarningMessage,"data-testid":"unsaved-changes-warning-alert"}):void 0,[Z,t.unsavedChangesWarningHeading,t.unsavedChangesWarningMessage]),Ye=M(()=>{var r;return(r=e==null?void 0:e.shippingAddresses)!=null&&r.length?void 0:a(L,{type:"warning",variant:"primary",icon:a(G,{}),heading:t.shippingAddressWarningHeading,description:t.shippingAddressWarningMessage,"data-testid":"shipping-address-warning-alert"})},[(aa=e==null?void 0:e.shippingAddresses)==null?void 0:aa.length,t.shippingAddressWarningHeading,t.shippingAddressWarningMessage]),Aa=M(()=>p(Se,{children:[Xe,Ye]}),[Xe,Ye]),Ba=M(()=>{const r=(e==null?void 0:e.status)===ta.OPEN&&(e==null?void 0:e.canAccept);return p(R,{name:"Footer",slot:n==null?void 0:n.Footer,context:{templateData:e,comment:N,isSubmitting:d,attachedFiles:k,referenceDocuments:x,hasUnsavedChanges:Z,handleSendForReview:Me,showAcceptButton:r,renameTemplateName:I,renameReason:Y},children:[r&&a(A,{variant:"primary",onClick:()=>{ge(!0),ie(""),J("")},"data-testid":"accept-button",disabled:d||Z,children:t.accept}),(e==null?void 0:e.canSendForReview)&&a(A,{variant:"primary",onClick:Me,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||d,children:t.sendForReview}),(e==null?void 0:e.canCancel)&&a(A,{variant:"tertiary",onClick:()=>P(!0),"data-testid":"cancel-template-button",disabled:d,children:t.cancel}),(e==null?void 0:e.canDelete)&&a(A,{variant:"tertiary",onClick:()=>Q(!0),"data-testid":"delete-template-button",disabled:d,children:t.delete})]})},[n==null?void 0:n.Footer,t,e,N,d,k,Me,x,Z,I,Y]),xa=w?a(L,{type:"error",variant:"primary",icon:a(G,{}),heading:t.confirmationModalDeleteErrorHeading,description:w,onDismiss:ga,"data-testid":"confirmation-modal-error-banner"}):null,Ze=(z?a(L,{type:"success",variant:"primary",icon:a(Re,{}),heading:t.confirmationModalDeleteSuccessHeading,description:t.confirmationModalDeleteSuccessDescription,onDismiss:fa,"data-testid":"confirmation-modal-success-banner"}):null)||xa,Ua=j?a(L,{type:"error",variant:"primary",icon:a(G,{}),heading:t.confirmationModalCancelErrorHeading,description:j,onDismiss:ha,"data-testid":"confirmation-modal-cancel-error-banner"}):null,ea=(ra?a(L,{type:"success",variant:"primary",icon:a(Re,{}),heading:t.confirmationModalCancelSuccessHeading,description:t.confirmationModalCancelSuccessDescription,onDismiss:Ma,"data-testid":"confirmation-modal-cancel-success-banner"}):null)||Ua,Wa=M(()=>fe?a(L,{type:"error",variant:"primary",icon:a(G,{color:"var(--color-error)"}),heading:t.renameErrorHeading,description:fe}):void 0,[fe,t.renameErrorHeading]),za=M(()=>pe?a(L,{type:"success",variant:"primary",icon:a(Re,{}),heading:t.renameSuccessHeading,description:pe}):void 0,[pe,t.renameSuccessHeading]),Oa={...S,loading:c,templateName:_a,templateStatus:ya,banner:Aa,details:Ra,actionBar:Sa,referenceDocuments:Da,itemsTable:Fa,shippingInformationTitle:La,shippingInformation:Ea,commentsTitle:ka,comments:Ia,attachFilesField:wa,attachedFilesList:Ha,footer:Ba};let ve=null;we?ve=a(L,{type:"success",variant:"primary",icon:a(se,{source:"CheckWithCircle"}),heading:t.generateQuoteModalSuccessHeading,description:we,"data-testid":"generate-quote-success-banner"}):He&&(ve=a(L,{type:"error",variant:"primary",icon:a(se,{source:"WarningFilled"}),heading:t.generateQuoteModalErrorHeading,description:He,"data-testid":"generate-quote-error-banner"}));let qe=null;return Ue?qe=a(L,{type:"success",variant:"primary",icon:a(se,{source:"CheckWithCircle"}),heading:t.acceptModalSuccessHeading,description:Ue,"data-testid":"accept-success-banner"}):We&&(qe=a(L,{type:"error",variant:"primary",icon:a(se,{source:"WarningFilled"}),heading:t.acceptModalErrorHeading,description:We,"data-testid":"accept-error-banner"})),p(Se,{children:[a(hn,{...Oa}),E&&O(a(de,{open:E,title:t.confirmationModalDeleteTitle,message:t.confirmationModalDeleteMessage,cancelLabel:t.confirmationModalCancel,confirmLabel:t.confirmationModalDeleteConfirm,onCancel:da,onConfirm:ua,showCloseButton:!Ze,confirmationBanner:Ze}),document.body),F&&O(a(de,{open:F,title:t.confirmationModalCancelTitle,message:t.confirmationModalCancelMessage,cancelLabel:t.confirmationModalCancel,confirmLabel:t.confirmationModalCancelConfirm,onCancel:pa,onConfirm:ba,showCloseButton:!ea,confirmationBanner:ea}),document.body),Le&&O(a(Nn,{open:Le,document:ae,errorMessage:oa||void 0,onSave:Na,onClose:Ta,isSubmitting:d}),document.body),Ee&&O(a(de,{open:Ee,title:t.generateQuoteModalTitle,message:t.generateQuoteModalMessage,cancelLabel:t.generateQuoteModalCancel,confirmLabel:ke?t.generateQuoteModalConfirmLoading:t.generateQuoteModalConfirm,onCancel:va,onConfirm:ke?void 0:Qa,showCloseButton:!0,confirmationBanner:ve,"data-testid":"generate-quote-confirmation-modal"}),document.body),Ae&&O(a(de,{open:Ae,title:t.acceptModalTitle,message:t.acceptModalMessage,cancelLabel:t.acceptModalCancel,confirmLabel:Be?t.acceptModalConfirmLoading:t.acceptModalConfirm,onCancel:Ca,onConfirm:Be?void 0:qa,showCloseButton:!0,confirmationBanner:qe,"data-testid":"accept-confirmation-modal"}),document.body),Ge&&O(a(Za,{open:Ge,quoteName:I,renameReason:Y,quoteNameError:ia,errorBanner:Wa,successBanner:za,onQuoteNameChange:la,onRenameReasonChange:ma,onSave:sa,onClose:ca}),document.body)]})};export{rt as ManageNegotiableQuoteTemplate,rt as default};
|
|
6
6
|
//# sourceMappingURL=ManageNegotiableQuoteTemplate.js.map
|