@dropins/storefront-quote-management 0.0.1-alpha28 → 0.0.1-alpha29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/duplicateNegotiableQuote/duplicateNegotiableQuote.d.ts +8 -0
- package/api/duplicateNegotiableQuote/graphql/duplicateNegotiableQuoteMutation.d.ts +10 -0
- package/api/duplicateNegotiableQuote/index.d.ts +10 -0
- package/api/index.d.ts +2 -0
- package/api/setLineItemNote/graphql/SetLineItemNoteMutation.d.ts +10 -0
- package/api/setLineItemNote/index.d.ts +10 -0
- package/api/setLineItemNote/setLineItemNote.d.ts +10 -0
- package/api.js +17 -41
- package/api.js.map +1 -1
- package/chunks/ConfirmationModal.js +4 -0
- package/chunks/ConfirmationModal.js.map +1 -0
- package/chunks/ItemsQuoted.js +1 -1
- package/chunks/ItemsQuoted.js.map +1 -1
- package/chunks/ItemsQuotedTemplate.js +1 -1
- package/chunks/ItemsQuotedTemplate.js.map +1 -1
- package/chunks/OrderSummaryLine.js +1 -1
- package/chunks/OrderSummaryLine.js.map +1 -1
- package/chunks/QuotePricesSummary.js +1 -1
- package/chunks/QuotePricesSummary.js.map +1 -1
- package/chunks/TabbedContent.js +1 -1
- package/chunks/TabbedContent.js.map +1 -1
- package/chunks/dateUtils.js +1 -1
- package/chunks/dateUtils.js.map +1 -1
- package/chunks/duplicateNegotiableQuote.js +121 -0
- package/chunks/duplicateNegotiableQuote.js.map +1 -0
- package/chunks/generateQuoteFromTemplate.js +12 -0
- package/chunks/generateQuoteFromTemplate.js.map +1 -0
- package/chunks/openQuoteTemplate.js +31 -0
- package/chunks/openQuoteTemplate.js.map +1 -0
- package/chunks/setLineItemNote.js +47 -0
- package/chunks/setLineItemNote.js.map +1 -0
- package/chunks/state.js +1 -1
- package/chunks/state.js.map +1 -1
- package/chunks/transform-quote-template.js +1 -1
- package/chunks/transform-quote-template.js.map +1 -1
- package/chunks/transform-quote.js +1 -1
- package/chunks/transform-quote.js.map +1 -1
- package/components/LineItemNoteModal/LineItemNoteModal.d.ts +16 -0
- package/components/LineItemNoteModal/index.d.ts +11 -0
- package/components/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +0 -2
- package/components/ProductListTable/ProductListTable.d.ts +8 -0
- package/components/index.d.ts +1 -0
- package/containers/ItemsQuoted/ItemsQuoted.d.ts +1 -1
- package/containers/ItemsQuoted.js +1 -1
- package/containers/ItemsQuotedTemplate.js +1 -1
- package/containers/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +4 -0
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +4 -0
- package/containers/ManageNegotiableQuoteTemplate.js +1 -1
- package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
- package/containers/OrderSummary.js +1 -1
- package/containers/OrderSummary.js.map +1 -1
- package/containers/OrderSummaryLine.js +1 -1
- package/containers/QuoteSummaryList.js +1 -1
- package/containers/QuoteSummaryList.js.map +1 -1
- package/containers/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +2 -0
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuoteTemplatesListTable.js.map +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/QuotesListTable.js.map +1 -1
- package/data/models/negotiable-quote-template-model.d.ts +16 -7
- package/i18n/en_US.json.d.ts +57 -1
- package/package.json +1 -1
- package/render.js +3 -3
- package/render.js.map +1 -1
- package/types/state.types.d.ts +1 -0
- package/chunks/removeNegotiableQuoteItems.js +0 -38
- package/chunks/removeNegotiableQuoteItems.js.map +0 -1
- package/chunks/renameNegotiableQuote.js +0 -112
- package/chunks/renameNegotiableQuote.js.map +0 -1
- package/chunks/sendQuoteTemplateForReview.js +0 -15
- package/chunks/sendQuoteTemplateForReview.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{FetchGraphQL as I}from"@dropins/tools/fetch-graphql.js";import{s as g}from"./state.js";var x=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(x||{});const{setEndpoint:M,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:G,setFetchGraphQlHeaders:z,fetchGraphQl:W,getConfig:H}=new I().getMethods(),b=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function P(e){if(!e.items)return 0;const r=g.config;return(r==null?void 0:r.quoteSummaryDisplayTotal)===0?e.items.length:(r==null?void 0:r.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function w(e){var n,c,i,l;const r=g.config;return{src:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(n=e.configured_variant)==null?void 0:n.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.label:((l=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:l.label)||e.product.thumbnail.label}}function C(e){var r;return((r=e.links)==null?void 0:r.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function T(e,r){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>r>=c.quantity)||null}function A(e){var s,o;const r=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(s=e.configured_variant)==null?void 0:s.price_tiers:e.product.price_tiers,i=n?(o=e.configured_variant)==null?void 0:o.price_range:e.product.price_range,l=T(c,r);return l?l.discount.amount_off>0:(i==null?void 0:i.maximum_price.discount.amount_off)>0}function O(e){var i,l,s,o,d,a,u,p;const r=e.quantity,n=T(e.product.price_tiers,r);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(o=(s=(l=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:l.maximum_price)==null?void 0:s.discount)==null?void 0:o.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(p=(u=(a=(d=e==null?void 0:e.product)==null?void 0:d.price_range)==null?void 0:a.maximum_price)==null?void 0:u.discount)==null?void 0:p.percent_off}if(c!==0)return Math.round(c)}function R(e){var r,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(r=e.configured_variant)==null?void 0:r.price_range)==null?void 0:n.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function N(e){var c,i,l,s,o,d;let r,n;if(r=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((s=(l=e==null?void 0:e.prices)==null?void 0:l.row_total)==null?void 0:s.value),n=(d=(o=e==null?void 0:e.prices)==null?void 0:o.row_total)==null?void 0:d.currency,r!==0)return{value:r,currency:n}}function S(e){var n,c,i,l,s,o,d;const r=D(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:r?x.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:P(e),comments:(n=e.comments)==null?void 0:n.map(a=>{const u={uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},text:a.text};return Array.isArray(a.attachments)&&a.attachments.length>0&&(u.attachments=a.attachments.map(p=>({name:p.name,url:p.url}))),u}),prices:e.prices&&{appliedDiscounts:(c=e.prices.discounts)==null?void 0:c.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label,coupon:a.coupon})),appliedTaxes:(i=e.prices.applied_taxes)==null?void 0:i.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label})),discount:e.prices.discounts&&e.prices.grand_total&&E(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...F(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&E(e.prices.applied_taxes,e.prices.grand_total.currency)},history:(l=e.history)==null?void 0:l.map(a=>{var u,p,f,m,v,y,h;return{uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},changeType:a.change_type,changes:{commentAdded:((u=a.changes)==null?void 0:u.comment_added)&&{comment:a.changes.comment_added.comment},customChanges:((p=a.changes)==null?void 0:p.custom_changes)&&{new_value:a.changes.custom_changes.new_value,old_value:a.changes.custom_changes.old_value,title:a.changes.custom_changes.title},expiration:((f=a.changes)==null?void 0:f.expiration)&&{newExpiration:a.changes.expiration.new_expiration,oldExpiration:a.changes.expiration.old_expiration},productsRemoved:((m=a.changes)==null?void 0:m.products_removed)&&{productsRemovedFromCatalog:a.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:a.changes.products_removed.products_removed_from_quote||[]},statuses:((v=a.changes)==null?void 0:v.statuses)&&{changes:((y=a.changes.statuses.changes)==null?void 0:y.map(t=>({newStatus:t.new_status,oldStatus:t.old_status})))||[]},total:((h=a.changes)==null?void 0:h.total)&&a.changes.total.new_price&&a.changes.total.old_price&&{newPrice:{value:a.changes.total.new_price.value,currency:a.changes.total.new_price.currency},oldPrice:{value:a.changes.total.old_price.value,currency:a.changes.total.old_price.currency}}}}}),items:((s=e.items)==null?void 0:s.map(a=>{var u,p,f,m,v,y,h;return{itemType:a.__typename,uid:a.uid,product:{uid:a.product.uid,sku:a.product.sku,name:a.product.name,priceRange:{maximumPrice:{regularPrice:{value:a.product.price_range.maximum_price.regular_price.value,currency:a.product.price_range.maximum_price.regular_price.currency}}}},image:w(a),links:C(a),discounted:A(a),discountedTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},catalogDiscount:{amountOff:a.prices.catalog_discount.amount_off,percentOff:a.prices.catalog_discount.percent_off},discounts:((p=(u=a.prices)==null?void 0:u.discounts)==null?void 0:p.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:O(a),insufficientQuantity:(a.__typename==="ConfigurableCartItem"?a.configured_variant:a.product).stock_status==="IN_STOCK"&&!a.is_available,outOfStock:a.product.stock_status==="OUT_OF_STOCK",stockStatus:a.product.stock_status,quantity:a.quantity,prices:{regularPrice:R(a),priceIncludingTax:{value:a.prices.price_including_tax.value,currency:a.prices.price_including_tax.currency},originalItemPrice:{value:a.prices.original_item_price.value,currency:a.prices.original_item_price.currency},originalRowTotal:{value:a.prices.original_row_total.value,currency:a.prices.original_row_total.currency},rowTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},rowTotalIncludingTax:{value:a.prices.row_total_including_tax.value,currency:a.prices.row_total_including_tax.currency}},savingsAmount:N(a),noteFromBuyer:(f=a.note_from_buyer)==null?void 0:f.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(m=a.note_from_seller)==null?void 0:m.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(v=a.configurable_options)==null?void 0:v.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(y=a.bundle_options)==null?void 0:y.map(t=>({label:t.label,values:t.values.map(_=>({label:_.label,quantity:_.quantity,originalPrice:{value:_.original_price.value,currency:_.original_price.currency},price:{value:_.priceV2.value,currency:_.priceV2.currency}}))})),customizableOptions:(h=a.customizable_options)==null?void 0:h.map(t=>({type:t.type,label:t.label,values:t.values.map(_=>({label:_.label,value:_.value}))}))}}))||[],shippingAddresses:(o=e.shipping_addresses)==null?void 0:o.map(a=>{const u={uid:a.uid,firstname:a.firstname,lastname:a.lastname,company:a.company,street:a.street,city:a.city,postcode:a.postcode,country:{code:a.country.code,label:a.country.label},telephone:a.telephone};return a.region&&(u.region={code:a.region.code,label:a.region.label,regionId:a.region.region_id}),u}),canCheckout:["UPDATED","DECLINED","OPEN"].includes(e.status)&&g.permissions.checkoutQuote&&((d=e.shipping_addresses)==null?void 0:d.length)>0,canSendForReview:(r||b.includes(e.status))&&g.permissions.editQuote,canUpdateQuote:(r||b.includes(e.status))&&g.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&g.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!g.permissions.editQuote}}function V(e){return e?S(e):null}function D(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(r=>{var n,c;return r.change_type==="UPDATED"&&(((c=(n=r.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function U(e){const r=D(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:r?x.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function X(e){var c;if(!e)return null;const r={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(U))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},n=Q(r);return{...r,paginationInfo:n||void 0}}function Q(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:r,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,l=i>0?(r-1)*n+1:0,s=Math.min(r*n,i);return{currentPage:r,totalCount:i,pageSize:n,startItem:l,endItem:s,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const K=()=>[20,30,50,100,200];function E(e,r){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:r}):{value:0,currency:r}}function F(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const n=e.shipping_addresses[0].selected_shipping_method;return n?{shippingIncludingTax:n.price_incl_tax&&{value:n.price_incl_tax.value,currency:n.price_incl_tax.currency},shippingExcludingTax:n.price_excl_tax&&{value:n.price_excl_tax.value,currency:n.price_excl_tax.currency}}:{}}export{V as a,X as b,B as c,z as d,H as e,W as f,K as g,G as r,M as s,Q as t};
|
|
3
|
+
import{FetchGraphQL as I}from"@dropins/tools/fetch-graphql.js";import{s as g}from"./state.js";var x=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(x||{});const{setEndpoint:M,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:G,setFetchGraphQlHeaders:z,fetchGraphQl:W,getConfig:H}=new I().getMethods(),b=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function P(e){if(!e.items)return 0;const r=g.config;return(r==null?void 0:r.quoteSummaryDisplayTotal)===0?e.items.length:(r==null?void 0:r.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function w(e){var n,c,i,l;const r=g.config;return{src:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(n=e.configured_variant)==null?void 0:n.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.label:((l=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:l.label)||e.product.thumbnail.label}}function C(e){var r;return((r=e.links)==null?void 0:r.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function T(e,r){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>r>=c.quantity)||null}function A(e){var s,o;const r=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(s=e.configured_variant)==null?void 0:s.price_tiers:e.product.price_tiers,i=n?(o=e.configured_variant)==null?void 0:o.price_range:e.product.price_range,l=T(c,r);return l?l.discount.amount_off>0:(i==null?void 0:i.maximum_price.discount.amount_off)>0}function O(e){var i,l,s,o,d,a,u,p;const r=e.quantity,n=T(e.product.price_tiers,r);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(o=(s=(l=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:l.maximum_price)==null?void 0:s.discount)==null?void 0:o.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(p=(u=(a=(d=e==null?void 0:e.product)==null?void 0:d.price_range)==null?void 0:a.maximum_price)==null?void 0:u.discount)==null?void 0:p.percent_off}if(c!==0)return Math.round(c)}function R(e){var r,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(r=e.configured_variant)==null?void 0:r.price_range)==null?void 0:n.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function N(e){var c,i,l,s,o,d;let r,n;if(r=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((s=(l=e==null?void 0:e.prices)==null?void 0:l.row_total)==null?void 0:s.value),n=(d=(o=e==null?void 0:e.prices)==null?void 0:o.row_total)==null?void 0:d.currency,r!==0)return{value:r,currency:n}}function S(e){var n,c,i,l,s,o,d;const r=D(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:r?x.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:P(e),comments:(n=e.comments)==null?void 0:n.map(a=>{const u={uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},text:a.text};return Array.isArray(a.attachments)&&a.attachments.length>0&&(u.attachments=a.attachments.map(p=>({name:p.name,url:p.url}))),u}),prices:e.prices&&{appliedDiscounts:(c=e.prices.discounts)==null?void 0:c.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label,coupon:a.coupon})),appliedTaxes:(i=e.prices.applied_taxes)==null?void 0:i.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label})),discount:e.prices.discounts&&e.prices.grand_total&&E(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...F(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&E(e.prices.applied_taxes,e.prices.grand_total.currency)},history:(l=e.history)==null?void 0:l.map(a=>{var u,p,f,m,v,y,h;return{uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},changeType:a.change_type,changes:{commentAdded:((u=a.changes)==null?void 0:u.comment_added)&&{comment:a.changes.comment_added.comment},customChanges:((p=a.changes)==null?void 0:p.custom_changes)&&{new_value:a.changes.custom_changes.new_value,old_value:a.changes.custom_changes.old_value,title:a.changes.custom_changes.title},expiration:((f=a.changes)==null?void 0:f.expiration)&&{newExpiration:a.changes.expiration.new_expiration,oldExpiration:a.changes.expiration.old_expiration},productsRemoved:((m=a.changes)==null?void 0:m.products_removed)&&{productsRemovedFromCatalog:a.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:a.changes.products_removed.products_removed_from_quote||[]},statuses:((v=a.changes)==null?void 0:v.statuses)&&{changes:((y=a.changes.statuses.changes)==null?void 0:y.map(t=>({newStatus:t.new_status,oldStatus:t.old_status})))||[]},total:((h=a.changes)==null?void 0:h.total)&&a.changes.total.new_price&&a.changes.total.old_price&&{newPrice:{value:a.changes.total.new_price.value,currency:a.changes.total.new_price.currency},oldPrice:{value:a.changes.total.old_price.value,currency:a.changes.total.old_price.currency}}}}}),items:((s=e.items)==null?void 0:s.map(a=>{var u,p,f,m,v,y,h;return{itemType:a.__typename,uid:a.uid,product:{uid:a.product.uid,sku:a.product.sku,name:a.product.name,priceRange:{maximumPrice:{regularPrice:{value:a.product.price_range.maximum_price.regular_price.value,currency:a.product.price_range.maximum_price.regular_price.currency}}}},image:w(a),links:C(a),discounted:A(a),discountedTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},catalogDiscount:{amountOff:a.prices.catalog_discount.amount_off,percentOff:a.prices.catalog_discount.percent_off},discounts:((p=(u=a.prices)==null?void 0:u.discounts)==null?void 0:p.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:O(a),insufficientQuantity:(a.__typename==="ConfigurableCartItem"?a.configured_variant:a.product).stock_status==="IN_STOCK"&&!a.is_available,outOfStock:a.product.stock_status==="OUT_OF_STOCK",stockStatus:a.product.stock_status,quantity:a.quantity,prices:{regularPrice:R(a),priceIncludingTax:{value:a.prices.price_including_tax.value,currency:a.prices.price_including_tax.currency},originalItemPrice:{value:a.prices.original_item_price.value,currency:a.prices.original_item_price.currency},originalRowTotal:{value:a.prices.original_row_total.value,currency:a.prices.original_row_total.currency},rowTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},rowTotalIncludingTax:{value:a.prices.row_total_including_tax.value,currency:a.prices.row_total_including_tax.currency}},savingsAmount:N(a),noteFromBuyer:(f=a.note_from_buyer)==null?void 0:f.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(m=a.note_from_seller)==null?void 0:m.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(v=a.configurable_options)==null?void 0:v.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(y=a.bundle_options)==null?void 0:y.map(t=>({label:t.label,values:t.values.map(_=>({label:_.label,quantity:_.quantity,originalPrice:{value:_.original_price.value,currency:_.original_price.currency},price:{value:_.priceV2.value,currency:_.priceV2.currency}}))})),customizableOptions:(h=a.customizable_options)==null?void 0:h.map(t=>({type:t.type,label:t.label,values:t.values.map(_=>({label:_.label,value:_.value}))}))}}))||[],shippingAddresses:(o=e.shipping_addresses)==null?void 0:o.map(a=>{const u={uid:a.uid,firstname:a.firstname,lastname:a.lastname,company:a.company,street:a.street,city:a.city,postcode:a.postcode,country:{code:a.country.code,label:a.country.label},telephone:a.telephone};return a.region&&(u.region={code:a.region.code,label:a.region.label,regionId:a.region.region_id}),u}),canCheckout:["UPDATED","DECLINED","OPEN"].includes(e.status)&&g.permissions.checkoutQuote&&((d=e.shipping_addresses)==null?void 0:d.length)>0,canSendForReview:(r||b.includes(e.status))&&g.permissions.editQuote,canUpdateQuote:(r||b.includes(e.status))&&g.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&g.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:!r&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!g.permissions.editQuote}}function V(e){return e?S(e):null}function D(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(r=>{var n,c;return r.change_type==="UPDATED"&&(((c=(n=r.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function U(e){const r=D(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:r?x.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function X(e){var c;if(!e)return null;const r={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(U))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},n=Q(r);return{...r,paginationInfo:n||void 0}}function Q(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:r,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,l=i>0?(r-1)*n+1:0,s=Math.min(r*n,i);return{currentPage:r,totalCount:i,pageSize:n,startItem:l,endItem:s,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const K=()=>[20,30,50,100,200];function E(e,r){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:r}):{value:0,currency:r}}function F(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const n=e.shipping_addresses[0].selected_shipping_method;return n?{shippingIncludingTax:n.price_incl_tax&&{value:n.price_incl_tax.value,currency:n.price_incl_tax.currency},shippingExcludingTax:n.price_excl_tax&&{value:n.price_excl_tax.value,currency:n.price_excl_tax.currency}}:{}}export{V as a,X as b,B as c,z as d,H as e,W as f,K as g,G as r,M as s,Q as t};
|
|
4
4
|
//# sourceMappingURL=transform-quote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-quote.js","sources":["/@dropins/storefront-quote-management/src/data/models/negotiable-quote-model.ts","/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport interface ShippingAddress {\n /**\n * The unique string identifier of the address\n */\n uid?: string;\n firstname: string;\n lastname: string;\n company?: string;\n street: string[];\n city: string;\n region?: {\n code: string;\n label: string;\n regionId: number;\n };\n postcode: string;\n country: {\n code: string;\n label: string;\n };\n telephone: string;\n}\n\nexport interface NegotiableQuoteModel {\n uid: string;\n name: string;\n createdAt: string;\n salesRepName: string;\n expirationDate: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n isVirtual: boolean;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName?: string;\n totalQuantity: number;\n comments?: {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n }[];\n history?: NegotiableQuoteHistoryEntry[];\n prices: {\n appliedDiscounts?: Discount[];\n appliedTaxes?: Tax[];\n discount?: Currency;\n grandTotal?: Currency;\n grandTotalExcludingTax?: Currency;\n shippingExcludingTax?: Currency;\n shippingIncludingTax?: Currency;\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n totalTax?: Currency;\n };\n items: NegotiableQuoteCartItem[];\n shippingAddresses?: ShippingAddress[];\n canCheckout: boolean;\n canSendForReview: boolean;\n lockedForEditing?: boolean;\n canDelete: boolean;\n canClose: boolean;\n canUpdateQuote: boolean;\n readOnly: boolean;\n}\n\nexport interface ConfigurableOption {\n optionLabel: string;\n valueLabel: string;\n}\n\nexport interface BundleOption {\n label: string;\n values: {\n label: string;\n quantity: number;\n originalPrice: Currency;\n price: Currency;\n }[];\n}\n\nexport interface CustomizableOption {\n type: string;\n label: string;\n values: {\n label: string;\n value: string;\n }[];\n}\n\nexport interface NegotiableQuoteCartItem {\n itemType: string;\n uid: string;\n product: {\n uid: string;\n sku: string;\n name: string;\n templateId?: string;\n templateName?: string;\n priceRange: {\n maximumPrice: {\n regularPrice: Currency;\n };\n };\n };\n image: ItemImage;\n links?: ItemLinks;\n discounted: boolean;\n discountedTotal: Currency;\n catalogDiscount: {\n amountOff: number;\n percentOff: number;\n };\n discounts: {\n label: string;\n value: string;\n amount: Currency;\n }[];\n discountPercentage?: number;\n insufficientQuantity?: boolean;\n outOfStock?: boolean;\n stockStatus: string;\n quantity: number;\n prices: {\n regularPrice: Currency;\n priceIncludingTax: Currency;\n originalItemPrice: Currency;\n originalRowTotal: Currency;\n rowTotal: Currency;\n rowTotalIncludingTax: Currency;\n };\n savingsAmount?: Currency;\n configurableOptions?: ConfigurableOption[];\n bundleOptions?: BundleOption[];\n customizableOptions?: CustomizableOption[];\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n}\n\ninterface ItemImage {\n src: string;\n alt: string;\n}\n\ninterface ItemLinks {\n count: number;\n result: string;\n}\n\nexport interface ItemNote {\n createdAt: string;\n creatorId: number;\n creatorType: number;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n}\n\nexport interface Currency {\n value: number;\n currency: string;\n}\n\nexport interface Tax {\n amount: Currency;\n label: string;\n}\n\nexport interface Discount {\n amount: Currency;\n label: string;\n coupon?: Coupon;\n}\n\nexport interface Coupon {\n code: string;\n}\n\nexport interface NegotiableQuoteListEntry {\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName: string;\n prices: {\n grandTotal: Currency;\n };\n}\nexport interface NegotiableQuotesListModel {\n items: NegotiableQuoteListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteHistoryEntry {\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: NegotiableQuoteHistoryEntryChangeType;\n changes: {\n commentAdded?: {\n comment: string;\n };\n customChanges?: {\n new_value: string;\n old_value: string;\n title: string;\n };\n expiration?: {\n newExpiration: string;\n oldExpiration: string;\n };\n productsRemoved?: {\n productsRemovedFromCatalog: string[];\n productsRemovedFromQuote?: {\n uid: string;\n name: string;\n sku: string;\n quantity: number;\n }[];\n };\n statuses?: {\n changes: {\n newStatus: string;\n oldStatus: string;\n }[];\n };\n total?: {\n newPrice: Currency;\n oldPrice: Currency;\n };\n };\n createdAt: string;\n uid: string;\n}\n\nexport enum NegotiableQuoteHistoryEntryChangeType {\n CREATED = 'CREATED',\n UPDATED = 'UPDATED',\n CLOSED = 'CLOSED',\n UPDATED_BY_SYSTEM = 'UPDATED_BY_SYSTEM',\n}\n\n// See: https://experienceleague.adobe.com/en/docs/commerce-admin/b2b/quotes/quotes#quote-status\nexport enum NegotiableQuoteStatus {\n NEW = 'NEW', // Currently not returned by the API, but is used to indicate a new quote\n SUBMITTED = 'SUBMITTED',\n PENDING = 'PENDING',\n UPDATED = 'UPDATED',\n OPEN = 'OPEN',\n ORDERED = 'ORDERED',\n CLOSED = 'CLOSED',\n DECLINED = 'DECLINED',\n EXPIRED = 'EXPIRED',\n DRAFT = 'DRAFT',\n}\n\nexport interface PaginationInfo {\n currentPage: number;\n totalCount: number;\n pageSize: number;\n startItem: number;\n endItem: number;\n totalPages: number;\n pageSizeOptions?: number[];\n}\n","import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n NegotiableQuoteListEntry,\n NegotiableQuoteModel,\n NegotiableQuotesListModel,\n NegotiableQuoteStatus,\n PaginationInfo,\n ShippingAddress,\n} from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\n// Quote statuses that allow editing/sending for review\nconst EDITABLE_QUOTE_STATUSES = [\n 'DRAFT',\n 'UPDATED',\n 'DECLINED',\n 'EXPIRED',\n 'NEW',\n 'OPEN',\n] as const;\n\n// Helper function to get the total quantity of a quote (number of quote line items or total quantity)\nfunction getTotalQuantity(quote: any) {\n if (!quote.items) return 0;\n\n const config = state.config;\n\n if (config?.quoteSummaryDisplayTotal === 0) return quote.items.length;\n if (config?.quoteSummaryDisplayTotal === 1) return quote.total_quantity;\n // Default to items count if unexpected config value or error returned\n return quote.items.length;\n}\n\n// Helper function to get the image for a cart item component\nfunction getImage(item: any) {\n const config = state.config;\n\n return {\n // Use parent thumbnail if configured, otherwise use own variant. Use the parent thumbnail as a fallback\n src: config?.useConfigurableParentThumbnail\n ? item.product.thumbnail.url\n : item.configured_variant?.thumbnail?.url || item.product.thumbnail.url,\n alt: config?.useConfigurableParentThumbnail\n ? item.product.thumbnail.label\n : item.configured_variant?.thumbnail?.label ||\n item.product.thumbnail.label,\n };\n}\n\n// Helper function to get downloadable links for a cart item component\nfunction getLinks(item: any) {\n return item.links?.length > 0\n ? {\n count: item.links.length,\n result: item.links.map((link: any) => link.title).join(', '),\n }\n : null;\n}\n\n/**\n * Finds the most applicable price tier for a given quantity\n * @param priceTiers - Array of price tier objects\n * @param quantity - Current item quantity\n * @returns The applicable tier or null if none found\n */\nfunction findApplicablePriceTier(priceTiers: any[], quantity: number) {\n if (!priceTiers?.length) return null;\n\n // Sort price tiers by quantity in descending order to find the highest applicable tier\n const sortedTiers = [...priceTiers].sort(\n (a: any, b: any) => b.quantity - a.quantity\n );\n\n // Find the highest tier where the current quantity meets or exceeds the tier's minimum quantity\n return sortedTiers.find((tier: any) => quantity >= tier.quantity) || null;\n}\n\n// Helper function to check if an item is discounted\nfunction getDiscounted(item: any) {\n const quantity = item.quantity;\n const isConfigurable = item.__typename === 'ConfigurableCartItem';\n\n // Get price tiers and price range based on item type\n const priceTiers = isConfigurable\n ? item.configured_variant?.price_tiers\n : item.product.price_tiers;\n const priceRange = isConfigurable\n ? item.configured_variant?.price_range\n : item.product.price_range;\n\n // Check price tiers first for discount eligibility\n const applicableTier = findApplicablePriceTier(priceTiers, quantity);\n if (applicableTier) {\n return applicableTier.discount.amount_off > 0;\n }\n\n // Fallback to regular price range discount\n return priceRange?.maximum_price.discount.amount_off > 0;\n}\n\n// Helper function to get the discount percentage of an item\nfunction getDiscountPercentage(item: any) {\n const quantity = item.quantity;\n\n // Check price tiers first for discount percentage\n const applicableTier = findApplicablePriceTier(\n item.product.price_tiers,\n quantity\n );\n\n if (applicableTier) {\n return Math.round(applicableTier.discount.percent_off);\n }\n\n // Fallback to product-specific discount percentage\n let percent_off;\n\n if (item.__typename === 'ConfigurableCartItem') {\n percent_off =\n item?.configured_variant?.price_range?.maximum_price?.discount\n ?.percent_off;\n } else if (item.__typename === 'BundleCartItem') {\n return undefined;\n } else {\n percent_off =\n item?.product?.price_range?.maximum_price?.discount?.percent_off;\n }\n\n if (percent_off === 0) {\n return undefined;\n }\n\n return Math.round(percent_off);\n}\n\n// Helper function to get the regular price of an item\nfunction getRegularPrice(item: any) {\n if (item.__typename === 'ConfigurableCartItem') {\n return {\n value:\n item.configured_variant?.price_range?.maximum_price.regular_price.value,\n currency:\n item.configured_variant?.price_range?.maximum_price.regular_price\n .currency,\n };\n }\n return {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n };\n}\n\n// Helper function to get the savings amount of an item\nfunction getSavingsAmount(item: any) {\n let amount_off;\n let currency;\n\n amount_off =\n item?.prices?.original_row_total?.value - item?.prices?.row_total?.value;\n currency = item?.prices?.row_total?.currency;\n\n if (amount_off === 0) {\n return undefined;\n }\n return {\n value: amount_off,\n currency,\n };\n}\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n expirationDate: quote.expiration_date,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n isVirtual: Boolean(quote.is_virtual),\n salesRepName: quote.sales_rep_name,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n totalQuantity: getTotalQuantity(quote),\n comments: quote.comments?.map((comment: any) => {\n const baseComment: any = {\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n text: comment.text,\n };\n\n if (\n Array.isArray(comment.attachments) &&\n comment.attachments.length > 0\n ) {\n baseComment.attachments = comment.attachments.map((a: any) => ({\n name: a.name,\n url: a.url,\n }));\n }\n\n return baseComment;\n }),\n prices: quote.prices && {\n appliedDiscounts: quote.prices.discounts?.map((discount: any) => ({\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n label: discount.label,\n coupon: discount.coupon,\n })),\n appliedTaxes: quote.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n discount:\n quote.prices.discounts &&\n quote.prices.grand_total &&\n calculateTotal(\n quote.prices.discounts,\n quote.prices.grand_total.currency\n ),\n grandTotal: quote.prices.grand_total && {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n grandTotalExcludingTax: quote.prices.grand_total_excluding_tax && {\n value: quote.prices.grand_total_excluding_tax.value,\n currency: quote.prices.grand_total_excluding_tax.currency,\n },\n subtotalExcludingTax: quote.prices.subtotal_excluding_tax && {\n value: quote.prices.subtotal_excluding_tax.value,\n currency: quote.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: quote.prices.subtotal_including_tax && {\n value: quote.prices.subtotal_including_tax.value,\n currency: quote.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: quote.prices\n .subtotal_with_discount_excluding_tax && {\n value: quote.prices.subtotal_with_discount_excluding_tax.value,\n currency: quote.prices.subtotal_with_discount_excluding_tax.currency,\n },\n ...transformShippingPrices(quote),\n totalTax:\n quote.prices.applied_taxes &&\n quote.prices.grand_total &&\n calculateTotal(\n quote.prices.applied_taxes,\n quote.prices.grand_total.currency\n ),\n },\n history: quote.history?.map((history: any) => ({\n uid: history.uid,\n createdAt: history.created_at,\n author: {\n firstname: history.author.firstname,\n lastname: history.author.lastname,\n },\n changeType: history.change_type,\n changes: {\n commentAdded: history.changes?.comment_added && {\n comment: history.changes.comment_added.comment,\n },\n customChanges: history.changes?.custom_changes && {\n new_value: history.changes.custom_changes.new_value,\n old_value: history.changes.custom_changes.old_value,\n title: history.changes.custom_changes.title,\n },\n expiration: history.changes?.expiration && {\n newExpiration: history.changes.expiration.new_expiration,\n oldExpiration: history.changes.expiration.old_expiration,\n },\n productsRemoved: history.changes?.products_removed && {\n productsRemovedFromCatalog:\n history.changes.products_removed.products_removed_from_catalog ||\n [],\n productsRemovedFromQuote:\n history.changes.products_removed.products_removed_from_quote || [],\n },\n statuses: history.changes?.statuses && {\n changes:\n history.changes.statuses.changes?.map((change: any) => ({\n newStatus: change.new_status,\n oldStatus: change.old_status,\n })) || [],\n },\n total: history.changes?.total &&\n history.changes.total.new_price &&\n history.changes.total.old_price && {\n newPrice: {\n value: history.changes.total.new_price.value,\n currency: history.changes.total.new_price.currency,\n },\n oldPrice: {\n value: history.changes.total.old_price.value,\n currency: history.changes.total.old_price.currency,\n },\n },\n },\n })),\n items:\n quote.items?.map((item: any) => ({\n itemType: item.__typename,\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n priceRange: {\n maximumPrice: {\n regularPrice: {\n value:\n item.product.price_range.maximum_price.regular_price.value,\n currency:\n item.product.price_range.maximum_price.regular_price.currency,\n },\n },\n },\n },\n image: getImage(item),\n links: getLinks(item),\n discounted: getDiscounted(item),\n discountedTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n catalogDiscount: {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts:\n item.prices?.discounts?.map((discount: any) => ({\n label: discount.label,\n value: discount.value,\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })) ?? [],\n discountPercentage: getDiscountPercentage(item),\n insufficientQuantity:\n (item.__typename === 'ConfigurableCartItem'\n ? item.configured_variant\n : item.product\n ).stock_status === 'IN_STOCK' && !item.is_available,\n outOfStock: item.product.stock_status === 'OUT_OF_STOCK',\n stockStatus: item.product.stock_status,\n quantity: item.quantity,\n prices: {\n regularPrice: getRegularPrice(item),\n priceIncludingTax: {\n value: item.prices.price_including_tax.value,\n currency: item.prices.price_including_tax.currency,\n },\n originalItemPrice: {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n },\n originalRowTotal: {\n value: item.prices.original_row_total.value,\n currency: item.prices.original_row_total.currency,\n },\n rowTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n rowTotalIncludingTax: {\n value: item.prices.row_total_including_tax.value,\n currency: item.prices.row_total_including_tax.currency,\n },\n },\n savingsAmount: getSavingsAmount(item),\n noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n customizableOptions: item.customizable_options?.map((option: any) => ({\n type: option.type,\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n value: value.value,\n })),\n })),\n })) || [],\n shippingAddresses: quote.shipping_addresses?.map((address: any) => {\n const shippingAddress: ShippingAddress = {\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n };\n\n if (address.region) {\n shippingAddress.region = {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n };\n }\n\n return shippingAddress;\n }),\n canCheckout:\n ['UPDATED', 'DECLINED', 'OPEN'].includes(quote.status) &&\n state.permissions.checkoutQuote &&\n quote.shipping_addresses?.length > 0,\n canSendForReview:\n (isQuoteNew || EDITABLE_QUOTE_STATUSES.includes(quote.status)) &&\n state.permissions.editQuote,\n canUpdateQuote:\n (isQuoteNew || EDITABLE_QUOTE_STATUSES.includes(quote.status)) &&\n state.permissions.editQuote,\n canDelete:\n !['PENDING', 'SUBMITTED', 'ORDERED'].includes(quote.status) &&\n state.permissions.deleteQuote,\n canClose: quote.status\n ? !['DRAFT', 'CLOSED', 'ORDERED', 'OPEN'].includes(quote.status)\n : false,\n readOnly:\n ['ORDERED', 'SUBMITTED', 'CLOSED', 'PENDING'].includes(quote.status) ||\n !state.permissions.editQuote,\n };\n}\n\nexport function transformQuote(quoteData: any): NegotiableQuoteModel | null {\n if (!quoteData) {\n return null;\n }\n\n return transformSingleQuote(quoteData);\n}\n\n// quote is new if it has a status of SUBMITTED and there is no history entry that\n// has a change_type of UPDATED with a non-empty array of status changes\nfunction isNewQuote(quote: any): boolean {\n return (\n quote.status === 'SUBMITTED' &&\n !(quote.history ?? []).some(\n (history: any) =>\n history.change_type === 'UPDATED' &&\n (history.changes?.statuses?.changes ?? []).length > 0\n )\n );\n}\n\nfunction transformNegotiableQuoteListEntry(\n quote: any\n): NegotiableQuoteListEntry {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n prices: {\n grandTotal: {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n },\n };\n}\n\nexport function transformNegotiableQuotesList(\n quotesData: any\n): NegotiableQuotesListModel | null {\n if (!quotesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n quotesData.items\n ?.filter((quote: any) => quote?.uid)\n .map(transformNegotiableQuoteListEntry) || [],\n pageInfo: {\n currentPage: quotesData.page_info.current_page,\n pageSize: quotesData.page_info.page_size,\n totalPages: quotesData.page_info.total_pages,\n },\n totalCount: quotesData.total_count,\n sortFields: quotesData.sort_fields\n ? {\n default: quotesData.sort_fields.default,\n options: quotesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n\nexport function transformPaginationInfo(\n quotesData: NegotiableQuotesListModel | null\n): PaginationInfo | null {\n if (!quotesData?.pageInfo || !quotesData.totalCount) {\n return null;\n }\n\n const { currentPage, pageSize, totalPages } = quotesData.pageInfo;\n const { totalCount } = quotesData;\n\n const startItem = totalCount > 0 ? (currentPage - 1) * pageSize + 1 : 0;\n const endItem = Math.min(currentPage * pageSize, totalCount);\n\n const pageSizeOptions = [20, 30, 50, 100, 200]; // Default page size options\n\n return {\n currentPage,\n totalCount,\n pageSize,\n startItem,\n endItem,\n totalPages,\n pageSizeOptions,\n };\n}\n\n// TODO: Check if admin has this configuration\nexport const getDefaultPageSizeOptions = () => [20, 30, 50, 100, 200];\n\nexport function calculateTotal(data: any[], currency: string) {\n if (!data?.length)\n return {\n value: 0,\n currency,\n };\n\n return data.reduce(\n (acc: any, item: any) => {\n return {\n value: acc.value + item.amount.value,\n currency: item.amount.currency,\n };\n },\n { value: 0, currency }\n );\n}\n\nexport function transformShippingPrices(quote: any) {\n if (!quote || !quote.shipping_addresses?.length) {\n return {};\n }\n\n const shippingAddress = quote.shipping_addresses[0];\n const selectedShippingMethod = shippingAddress.selected_shipping_method;\n\n if (!selectedShippingMethod) {\n return {};\n }\n\n return {\n shippingIncludingTax: selectedShippingMethod.price_incl_tax && {\n value: selectedShippingMethod.price_incl_tax.value,\n currency: selectedShippingMethod.price_incl_tax.currency,\n },\n shippingExcludingTax: selectedShippingMethod.price_excl_tax && {\n value: selectedShippingMethod.price_excl_tax.value,\n currency: selectedShippingMethod.price_excl_tax.currency,\n },\n };\n}\n"],"names":["NegotiableQuoteStatus","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","EDITABLE_QUOTE_STATUSES","getTotalQuantity","quote","config","state","getImage","item","_b","_a","_d","_c","getLinks","link","findApplicablePriceTier","priceTiers","quantity","a","b","tier","getDiscounted","isConfigurable","priceRange","applicableTier","getDiscountPercentage","percent_off","_h","_g","_f","_e","getRegularPrice","getSavingsAmount","amount_off","currency","transformSingleQuote","isQuoteNew","isNewQuote","comment","baseComment","discount","tax","calculateTotal","transformShippingPrices","history","change","note","option","value","address","shippingAddress","transformQuote","quoteData","transformNegotiableQuoteListEntry","transformNegotiableQuotesList","quotesData","transformedModel","paginationInfo","transformPaginationInfo","currentPage","pageSize","totalPages","totalCount","startItem","endItem","getDefaultPageSizeOptions","data","acc","selectedShippingMethod"],"mappings":"8FAyRO,IAAKA,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAVEA,IAAAA,GAAA,CAAA,CAAA,ECvRL,KAAM,CACX,YAAAC,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECWjBC,EAA0B,CAC9B,QACA,UACA,WACA,UACA,MACA,MACF,EAGA,SAASC,EAAiBC,EAAY,CACpC,GAAI,CAACA,EAAM,MAAO,MAAO,GAEzB,MAAMC,EAASC,EAAM,OAErB,OAAID,GAAA,YAAAA,EAAQ,4BAA6B,EAAUD,EAAM,MAAM,QAC3DC,GAAA,YAAAA,EAAQ,4BAA6B,EAAUD,EAAM,eAElDA,EAAM,MAAM,MACrB,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AQ3D,EAAK,OAAO,MAC/B,SAAUA,EAAK,OAAO,QAAA,GAG1B,CAAE,MAAO,EAAG,SAAA0B,CAAA,CAAS,EAZd,CACL,MAAO,EACP,SAAAA,CAAA,CAYN,CAEO,SAASS,EAAwBvC,EAAY,OAClD,GAAI,CAACA,GAAS,GAACM,EAAAN,EAAM,qBAAN,MAAAM,EAA0B,QACvC,MAAO,CAAA,EAIT,MAAM0D,EADkBhE,EAAM,mBAAmB,CAAC,EACH,yBAE/C,OAAKgE,EAIE,CACL,qBAAsBA,EAAuB,gBAAkB,CAC7D,MAAOA,EAAuB,eAAe,MAC7C,SAAUA,EAAuB,eAAe,QAAA,EAElD,qBAAsBA,EAAuB,gBAAkB,CAC7D,MAAOA,EAAuB,eAAe,MAC7C,SAAUA,EAAuB,eAAe,QAAA,CAClD,EAXO,CAAA,CAaX"}
|
|
1
|
+
{"version":3,"file":"transform-quote.js","sources":["/@dropins/storefront-quote-management/src/data/models/negotiable-quote-model.ts","/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport interface ShippingAddress {\n /**\n * The unique string identifier of the address\n */\n uid?: string;\n firstname: string;\n lastname: string;\n company?: string;\n street: string[];\n city: string;\n region?: {\n code: string;\n label: string;\n regionId: number;\n };\n postcode: string;\n country: {\n code: string;\n label: string;\n };\n telephone: string;\n}\n\nexport interface NegotiableQuoteModel {\n uid: string;\n name: string;\n createdAt: string;\n salesRepName: string;\n expirationDate: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n isVirtual: boolean;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName?: string;\n totalQuantity: number;\n comments?: {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n }[];\n history?: NegotiableQuoteHistoryEntry[];\n prices: {\n appliedDiscounts?: Discount[];\n appliedTaxes?: Tax[];\n discount?: Currency;\n grandTotal?: Currency;\n grandTotalExcludingTax?: Currency;\n shippingExcludingTax?: Currency;\n shippingIncludingTax?: Currency;\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n totalTax?: Currency;\n };\n items: NegotiableQuoteCartItem[];\n shippingAddresses?: ShippingAddress[];\n canCheckout: boolean;\n canSendForReview: boolean;\n lockedForEditing?: boolean;\n canDelete: boolean;\n canClose: boolean;\n canUpdateQuote: boolean;\n readOnly: boolean;\n}\n\nexport interface ConfigurableOption {\n optionLabel: string;\n valueLabel: string;\n}\n\nexport interface BundleOption {\n label: string;\n values: {\n label: string;\n quantity: number;\n originalPrice: Currency;\n price: Currency;\n }[];\n}\n\nexport interface CustomizableOption {\n type: string;\n label: string;\n values: {\n label: string;\n value: string;\n }[];\n}\n\nexport interface NegotiableQuoteCartItem {\n itemType: string;\n uid: string;\n product: {\n uid: string;\n sku: string;\n name: string;\n templateId?: string;\n templateName?: string;\n priceRange: {\n maximumPrice: {\n regularPrice: Currency;\n };\n };\n };\n image: ItemImage;\n links?: ItemLinks;\n discounted: boolean;\n discountedTotal: Currency;\n catalogDiscount: {\n amountOff: number;\n percentOff: number;\n };\n discounts: {\n label: string;\n value: string;\n amount: Currency;\n }[];\n discountPercentage?: number;\n insufficientQuantity?: boolean;\n outOfStock?: boolean;\n stockStatus: string;\n quantity: number;\n prices: {\n regularPrice: Currency;\n priceIncludingTax: Currency;\n originalItemPrice: Currency;\n originalRowTotal: Currency;\n rowTotal: Currency;\n rowTotalIncludingTax: Currency;\n };\n savingsAmount?: Currency;\n configurableOptions?: ConfigurableOption[];\n bundleOptions?: BundleOption[];\n customizableOptions?: CustomizableOption[];\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n}\n\ninterface ItemImage {\n src: string;\n alt: string;\n}\n\ninterface ItemLinks {\n count: number;\n result: string;\n}\n\nexport interface ItemNote {\n createdAt: string;\n creatorId: number;\n creatorType: number;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n}\n\nexport interface Currency {\n value: number;\n currency: string;\n}\n\nexport interface Tax {\n amount: Currency;\n label: string;\n}\n\nexport interface Discount {\n amount: Currency;\n label: string;\n coupon?: Coupon;\n}\n\nexport interface Coupon {\n code: string;\n}\n\nexport interface NegotiableQuoteListEntry {\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName: string;\n prices: {\n grandTotal: Currency;\n };\n}\nexport interface NegotiableQuotesListModel {\n items: NegotiableQuoteListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteHistoryEntry {\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: NegotiableQuoteHistoryEntryChangeType;\n changes: {\n commentAdded?: {\n comment: string;\n };\n customChanges?: {\n new_value: string;\n old_value: string;\n title: string;\n };\n expiration?: {\n newExpiration: string;\n oldExpiration: string;\n };\n productsRemoved?: {\n productsRemovedFromCatalog: string[];\n productsRemovedFromQuote?: {\n uid: string;\n name: string;\n sku: string;\n quantity: number;\n }[];\n };\n statuses?: {\n changes: {\n newStatus: string;\n oldStatus: string;\n }[];\n };\n total?: {\n newPrice: Currency;\n oldPrice: Currency;\n };\n };\n createdAt: string;\n uid: string;\n}\n\nexport enum NegotiableQuoteHistoryEntryChangeType {\n CREATED = 'CREATED',\n UPDATED = 'UPDATED',\n CLOSED = 'CLOSED',\n UPDATED_BY_SYSTEM = 'UPDATED_BY_SYSTEM',\n}\n\n// See: https://experienceleague.adobe.com/en/docs/commerce-admin/b2b/quotes/quotes#quote-status\nexport enum NegotiableQuoteStatus {\n NEW = 'NEW', // Currently not returned by the API, but is used to indicate a new quote\n SUBMITTED = 'SUBMITTED',\n PENDING = 'PENDING',\n UPDATED = 'UPDATED',\n OPEN = 'OPEN',\n ORDERED = 'ORDERED',\n CLOSED = 'CLOSED',\n DECLINED = 'DECLINED',\n EXPIRED = 'EXPIRED',\n DRAFT = 'DRAFT',\n}\n\nexport interface PaginationInfo {\n currentPage: number;\n totalCount: number;\n pageSize: number;\n startItem: number;\n endItem: number;\n totalPages: number;\n pageSizeOptions?: number[];\n}\n","import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n NegotiableQuoteListEntry,\n NegotiableQuoteModel,\n NegotiableQuotesListModel,\n NegotiableQuoteStatus,\n PaginationInfo,\n ShippingAddress,\n} from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\n// Quote statuses that allow editing/sending for review\nconst EDITABLE_QUOTE_STATUSES = [\n 'DRAFT',\n 'UPDATED',\n 'DECLINED',\n 'EXPIRED',\n 'NEW',\n 'OPEN',\n] as const;\n\n// Helper function to get the total quantity of a quote (number of quote line items or total quantity)\nfunction getTotalQuantity(quote: any) {\n if (!quote.items) return 0;\n\n const config = state.config;\n\n if (config?.quoteSummaryDisplayTotal === 0) return quote.items.length;\n if (config?.quoteSummaryDisplayTotal === 1) return quote.total_quantity;\n // Default to items count if unexpected config value or error returned\n return quote.items.length;\n}\n\n// Helper function to get the image for a cart item component\nfunction getImage(item: any) {\n const config = state.config;\n\n return {\n // Use parent thumbnail if configured, otherwise use own variant. Use the parent thumbnail as a fallback\n src: config?.useConfigurableParentThumbnail\n ? item.product.thumbnail.url\n : item.configured_variant?.thumbnail?.url || item.product.thumbnail.url,\n alt: config?.useConfigurableParentThumbnail\n ? item.product.thumbnail.label\n : item.configured_variant?.thumbnail?.label ||\n item.product.thumbnail.label,\n };\n}\n\n// Helper function to get downloadable links for a cart item component\nfunction getLinks(item: any) {\n return item.links?.length > 0\n ? {\n count: item.links.length,\n result: item.links.map((link: any) => link.title).join(', '),\n }\n : null;\n}\n\n/**\n * Finds the most applicable price tier for a given quantity\n * @param priceTiers - Array of price tier objects\n * @param quantity - Current item quantity\n * @returns The applicable tier or null if none found\n */\nfunction findApplicablePriceTier(priceTiers: any[], quantity: number) {\n if (!priceTiers?.length) return null;\n\n // Sort price tiers by quantity in descending order to find the highest applicable tier\n const sortedTiers = [...priceTiers].sort(\n (a: any, b: any) => b.quantity - a.quantity\n );\n\n // Find the highest tier where the current quantity meets or exceeds the tier's minimum quantity\n return sortedTiers.find((tier: any) => quantity >= tier.quantity) || null;\n}\n\n// Helper function to check if an item is discounted\nfunction getDiscounted(item: any) {\n const quantity = item.quantity;\n const isConfigurable = item.__typename === 'ConfigurableCartItem';\n\n // Get price tiers and price range based on item type\n const priceTiers = isConfigurable\n ? item.configured_variant?.price_tiers\n : item.product.price_tiers;\n const priceRange = isConfigurable\n ? item.configured_variant?.price_range\n : item.product.price_range;\n\n // Check price tiers first for discount eligibility\n const applicableTier = findApplicablePriceTier(priceTiers, quantity);\n if (applicableTier) {\n return applicableTier.discount.amount_off > 0;\n }\n\n // Fallback to regular price range discount\n return priceRange?.maximum_price.discount.amount_off > 0;\n}\n\n// Helper function to get the discount percentage of an item\nfunction getDiscountPercentage(item: any) {\n const quantity = item.quantity;\n\n // Check price tiers first for discount percentage\n const applicableTier = findApplicablePriceTier(\n item.product.price_tiers,\n quantity\n );\n\n if (applicableTier) {\n return Math.round(applicableTier.discount.percent_off);\n }\n\n // Fallback to product-specific discount percentage\n let percent_off;\n\n if (item.__typename === 'ConfigurableCartItem') {\n percent_off =\n item?.configured_variant?.price_range?.maximum_price?.discount\n ?.percent_off;\n } else if (item.__typename === 'BundleCartItem') {\n return undefined;\n } else {\n percent_off =\n item?.product?.price_range?.maximum_price?.discount?.percent_off;\n }\n\n if (percent_off === 0) {\n return undefined;\n }\n\n return Math.round(percent_off);\n}\n\n// Helper function to get the regular price of an item\nfunction getRegularPrice(item: any) {\n if (item.__typename === 'ConfigurableCartItem') {\n return {\n value:\n item.configured_variant?.price_range?.maximum_price.regular_price.value,\n currency:\n item.configured_variant?.price_range?.maximum_price.regular_price\n .currency,\n };\n }\n return {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n };\n}\n\n// Helper function to get the savings amount of an item\nfunction getSavingsAmount(item: any) {\n let amount_off;\n let currency;\n\n amount_off =\n item?.prices?.original_row_total?.value - item?.prices?.row_total?.value;\n currency = item?.prices?.row_total?.currency;\n\n if (amount_off === 0) {\n return undefined;\n }\n return {\n value: amount_off,\n currency,\n };\n}\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n expirationDate: quote.expiration_date,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n isVirtual: Boolean(quote.is_virtual),\n salesRepName: quote.sales_rep_name,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n totalQuantity: getTotalQuantity(quote),\n comments: quote.comments?.map((comment: any) => {\n const baseComment: any = {\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n text: comment.text,\n };\n\n if (\n Array.isArray(comment.attachments) &&\n comment.attachments.length > 0\n ) {\n baseComment.attachments = comment.attachments.map((a: any) => ({\n name: a.name,\n url: a.url,\n }));\n }\n\n return baseComment;\n }),\n prices: quote.prices && {\n appliedDiscounts: quote.prices.discounts?.map((discount: any) => ({\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n label: discount.label,\n coupon: discount.coupon,\n })),\n appliedTaxes: quote.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n discount:\n quote.prices.discounts &&\n quote.prices.grand_total &&\n calculateTotal(\n quote.prices.discounts,\n quote.prices.grand_total.currency\n ),\n grandTotal: quote.prices.grand_total && {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n grandTotalExcludingTax: quote.prices.grand_total_excluding_tax && {\n value: quote.prices.grand_total_excluding_tax.value,\n currency: quote.prices.grand_total_excluding_tax.currency,\n },\n subtotalExcludingTax: quote.prices.subtotal_excluding_tax && {\n value: quote.prices.subtotal_excluding_tax.value,\n currency: quote.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: quote.prices.subtotal_including_tax && {\n value: quote.prices.subtotal_including_tax.value,\n currency: quote.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: quote.prices\n .subtotal_with_discount_excluding_tax && {\n value: quote.prices.subtotal_with_discount_excluding_tax.value,\n currency: quote.prices.subtotal_with_discount_excluding_tax.currency,\n },\n ...transformShippingPrices(quote),\n totalTax:\n quote.prices.applied_taxes &&\n quote.prices.grand_total &&\n calculateTotal(\n quote.prices.applied_taxes,\n quote.prices.grand_total.currency\n ),\n },\n history: quote.history?.map((history: any) => ({\n uid: history.uid,\n createdAt: history.created_at,\n author: {\n firstname: history.author.firstname,\n lastname: history.author.lastname,\n },\n changeType: history.change_type,\n changes: {\n commentAdded: history.changes?.comment_added && {\n comment: history.changes.comment_added.comment,\n },\n customChanges: history.changes?.custom_changes && {\n new_value: history.changes.custom_changes.new_value,\n old_value: history.changes.custom_changes.old_value,\n title: history.changes.custom_changes.title,\n },\n expiration: history.changes?.expiration && {\n newExpiration: history.changes.expiration.new_expiration,\n oldExpiration: history.changes.expiration.old_expiration,\n },\n productsRemoved: history.changes?.products_removed && {\n productsRemovedFromCatalog:\n history.changes.products_removed.products_removed_from_catalog ||\n [],\n productsRemovedFromQuote:\n history.changes.products_removed.products_removed_from_quote || [],\n },\n statuses: history.changes?.statuses && {\n changes:\n history.changes.statuses.changes?.map((change: any) => ({\n newStatus: change.new_status,\n oldStatus: change.old_status,\n })) || [],\n },\n total: history.changes?.total &&\n history.changes.total.new_price &&\n history.changes.total.old_price && {\n newPrice: {\n value: history.changes.total.new_price.value,\n currency: history.changes.total.new_price.currency,\n },\n oldPrice: {\n value: history.changes.total.old_price.value,\n currency: history.changes.total.old_price.currency,\n },\n },\n },\n })),\n items:\n quote.items?.map((item: any) => ({\n itemType: item.__typename,\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n priceRange: {\n maximumPrice: {\n regularPrice: {\n value:\n item.product.price_range.maximum_price.regular_price.value,\n currency:\n item.product.price_range.maximum_price.regular_price.currency,\n },\n },\n },\n },\n image: getImage(item),\n links: getLinks(item),\n discounted: getDiscounted(item),\n discountedTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n catalogDiscount: {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts:\n item.prices?.discounts?.map((discount: any) => ({\n label: discount.label,\n value: discount.value,\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })) ?? [],\n discountPercentage: getDiscountPercentage(item),\n insufficientQuantity:\n (item.__typename === 'ConfigurableCartItem'\n ? item.configured_variant\n : item.product\n ).stock_status === 'IN_STOCK' && !item.is_available,\n outOfStock: item.product.stock_status === 'OUT_OF_STOCK',\n stockStatus: item.product.stock_status,\n quantity: item.quantity,\n prices: {\n regularPrice: getRegularPrice(item),\n priceIncludingTax: {\n value: item.prices.price_including_tax.value,\n currency: item.prices.price_including_tax.currency,\n },\n originalItemPrice: {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n },\n originalRowTotal: {\n value: item.prices.original_row_total.value,\n currency: item.prices.original_row_total.currency,\n },\n rowTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n rowTotalIncludingTax: {\n value: item.prices.row_total_including_tax.value,\n currency: item.prices.row_total_including_tax.currency,\n },\n },\n savingsAmount: getSavingsAmount(item),\n noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n customizableOptions: item.customizable_options?.map((option: any) => ({\n type: option.type,\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n value: value.value,\n })),\n })),\n })) || [],\n shippingAddresses: quote.shipping_addresses?.map((address: any) => {\n const shippingAddress: ShippingAddress = {\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n };\n\n if (address.region) {\n shippingAddress.region = {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n };\n }\n\n return shippingAddress;\n }),\n canCheckout:\n ['UPDATED', 'DECLINED', 'OPEN'].includes(quote.status) &&\n state.permissions.checkoutQuote &&\n quote.shipping_addresses?.length > 0,\n canSendForReview:\n (isQuoteNew || EDITABLE_QUOTE_STATUSES.includes(quote.status)) &&\n state.permissions.editQuote,\n canUpdateQuote:\n (isQuoteNew || EDITABLE_QUOTE_STATUSES.includes(quote.status)) &&\n state.permissions.editQuote,\n canDelete:\n !['PENDING', 'SUBMITTED', 'ORDERED'].includes(quote.status) &&\n state.permissions.deleteQuote,\n canClose: quote.status\n ? !['DRAFT', 'CLOSED', 'ORDERED', 'OPEN'].includes(quote.status)\n : false,\n readOnly:\n (!isQuoteNew &&\n ['ORDERED', 'SUBMITTED', 'CLOSED', 'PENDING'].includes(quote.status)) ||\n !state.permissions.editQuote,\n };\n}\n\nexport function transformQuote(quoteData: any): NegotiableQuoteModel | null {\n if (!quoteData) {\n return null;\n }\n\n return transformSingleQuote(quoteData);\n}\n\n// quote is new if it has a status of SUBMITTED and there is no history entry that\n// has a change_type of UPDATED with a non-empty array of status changes\nfunction isNewQuote(quote: any): boolean {\n return (\n quote.status === 'SUBMITTED' &&\n !(quote.history ?? []).some(\n (history: any) =>\n history.change_type === 'UPDATED' &&\n (history.changes?.statuses?.changes ?? []).length > 0\n )\n );\n}\n\nfunction transformNegotiableQuoteListEntry(\n quote: any\n): NegotiableQuoteListEntry {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n prices: {\n grandTotal: {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n },\n };\n}\n\nexport function transformNegotiableQuotesList(\n quotesData: any\n): NegotiableQuotesListModel | null {\n if (!quotesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n quotesData.items\n ?.filter((quote: any) => quote?.uid)\n .map(transformNegotiableQuoteListEntry) || [],\n pageInfo: {\n currentPage: quotesData.page_info.current_page,\n pageSize: quotesData.page_info.page_size,\n totalPages: quotesData.page_info.total_pages,\n },\n totalCount: quotesData.total_count,\n sortFields: quotesData.sort_fields\n ? {\n default: quotesData.sort_fields.default,\n options: quotesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n\nexport function transformPaginationInfo(\n quotesData: NegotiableQuotesListModel | null\n): PaginationInfo | null {\n if (!quotesData?.pageInfo || !quotesData.totalCount) {\n return null;\n }\n\n const { currentPage, pageSize, totalPages } = quotesData.pageInfo;\n const { totalCount } = quotesData;\n\n const startItem = totalCount > 0 ? (currentPage - 1) * pageSize + 1 : 0;\n const endItem = Math.min(currentPage * pageSize, totalCount);\n\n const pageSizeOptions = [20, 30, 50, 100, 200]; // Default page size options\n\n return {\n currentPage,\n totalCount,\n pageSize,\n startItem,\n endItem,\n totalPages,\n pageSizeOptions,\n };\n}\n\n// TODO: Check if admin has this configuration\nexport const getDefaultPageSizeOptions = () => [20, 30, 50, 100, 200];\n\nexport function calculateTotal(data: any[], currency: string) {\n if (!data?.length)\n return {\n value: 0,\n currency,\n };\n\n return data.reduce(\n (acc: any, item: any) => {\n return {\n value: acc.value + item.amount.value,\n currency: item.amount.currency,\n };\n },\n { value: 0, currency }\n );\n}\n\nexport function transformShippingPrices(quote: any) {\n if (!quote || !quote.shipping_addresses?.length) {\n return {};\n }\n\n const shippingAddress = quote.shipping_addresses[0];\n const selectedShippingMethod = shippingAddress.selected_shipping_method;\n\n if (!selectedShippingMethod) {\n return {};\n }\n\n return {\n shippingIncludingTax: selectedShippingMethod.price_incl_tax && {\n value: selectedShippingMethod.price_incl_tax.value,\n currency: selectedShippingMethod.price_incl_tax.currency,\n },\n shippingExcludingTax: selectedShippingMethod.price_excl_tax && {\n value: selectedShippingMethod.price_excl_tax.value,\n currency: selectedShippingMethod.price_excl_tax.currency,\n },\n };\n}\n"],"names":["NegotiableQuoteStatus","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","EDITABLE_QUOTE_STATUSES","getTotalQuantity","quote","config","state","getImage","item","_b","_a","_d","_c","getLinks","link","findApplicablePriceTier","priceTiers","quantity","a","b","tier","getDiscounted","isConfigurable","priceRange","applicableTier","getDiscountPercentage","percent_off","_h","_g","_f","_e","getRegularPrice","getSavingsAmount","amount_off","currency","transformSingleQuote","isQuoteNew","isNewQuote","comment","baseComment","discount","tax","calculateTotal","transformShippingPrices","history","change","note","option","value","address","shippingAddress","transformQuote","quoteData","transformNegotiableQuoteListEntry","transformNegotiableQuotesList","quotesData","transformedModel","paginationInfo","transformPaginationInfo","currentPage","pageSize","totalPages","totalCount","startItem","endItem","getDefaultPageSizeOptions","data","acc","selectedShippingMethod"],"mappings":"8FAyRO,IAAKA,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAVEA,IAAAA,GAAA,CAAA,CAAA,ECvRL,KAAM,CACX,YAAAC,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECWjBC,EAA0B,CAC9B,QACA,UACA,WACA,UACA,MACA,MACF,EAGA,SAASC,EAAiBC,EAAY,CACpC,GAAI,CAACA,EAAM,MAAO,MAAO,GAEzB,MAAMC,EAASC,EAAM,OAErB,OAAID,GAAA,YAAAA,EAAQ,4B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AAewB,EAAahC,EAAkB,CAC5D,OAAKgC,GAAA,MAAAA,EAAM,OAMJA,EAAK,OACV,CAACC,EAAU3D,KACF,CACL,MAAO2D,EAAI,MAAQ3D,EAAK,OAAO,MAC/B,SAAUA,EAAK,OAAO,QAAA,GAG1B,CAAE,MAAO,EAAG,SAAA0B,CAAA,CAAS,EAZd,CACL,MAAO,EACP,SAAAA,CAAA,CAYN,CAEO,SAASS,EAAwBvC,EAAY,OAClD,GAAI,CAACA,GAAS,GAACM,EAAAN,EAAM,qBAAN,MAAAM,EAA0B,QACvC,MAAO,CAAA,EAIT,MAAM0D,EADkBhE,EAAM,mBAAmB,CAAC,EACH,yBAE/C,OAAKgE,EAIE,CACL,qBAAsBA,EAAuB,gBAAkB,CAC7D,MAAOA,EAAuB,eAAe,MAC7C,SAAUA,EAAuB,eAAe,QAAA,EAElD,qBAAsBA,EAAuB,gBAAkB,CAC7D,MAAOA,EAAuB,eAAe,MAC7C,SAAUA,EAAuB,eAAe,QAAA,CAClD,EAXO,CAAA,CAaX"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionComponent, VNode } from 'preact';
|
|
2
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
+
import { NegotiableQuoteCartItem } from '../../data/models/negotiable-quote-model';
|
|
4
|
+
|
|
5
|
+
export interface LineItemNoteModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
6
|
+
open: boolean;
|
|
7
|
+
item: NegotiableQuoteCartItem;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
onConfirm: (note: string, quantity: number) => void;
|
|
10
|
+
isSubmitting?: boolean;
|
|
11
|
+
errorBanner?: VNode;
|
|
12
|
+
successBanner?: VNode;
|
|
13
|
+
showCloseButton?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const LineItemNoteModal: FunctionComponent<LineItemNoteModalProps>;
|
|
16
|
+
//# sourceMappingURL=LineItemNoteModal.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* Copyright 2025 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
+
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
+
* accompanying it.
|
|
8
|
+
*******************************************************************/
|
|
9
|
+
export * from './LineItemNoteModal';
|
|
10
|
+
export { LineItemNoteModal as default } from './LineItemNoteModal';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,8 +13,6 @@ export interface ManageNegotiableQuoteTemplateProps extends Omit<HTMLAttributes<
|
|
|
13
13
|
itemsTable: VNode;
|
|
14
14
|
commentsTitle: VNode;
|
|
15
15
|
comments: VNode;
|
|
16
|
-
historyLogTitle: VNode;
|
|
17
|
-
historyLog: VNode;
|
|
18
16
|
footer?: VNode;
|
|
19
17
|
}
|
|
20
18
|
export declare const ManageNegotiableQuoteTemplate: FunctionComponent<ManageNegotiableQuoteTemplateProps>;
|
|
@@ -37,6 +37,14 @@ export interface ProductListTableItem {
|
|
|
37
37
|
};
|
|
38
38
|
}>;
|
|
39
39
|
}>;
|
|
40
|
+
noteFromBuyer?: Array<{
|
|
41
|
+
createdAt: string;
|
|
42
|
+
creatorId: number;
|
|
43
|
+
creatorType: number;
|
|
44
|
+
negotiableQuoteItemUid: string;
|
|
45
|
+
note: string;
|
|
46
|
+
noteUid: string;
|
|
47
|
+
}>;
|
|
40
48
|
}
|
|
41
49
|
export interface ProductListTableProps extends HTMLAttributes<HTMLDivElement | HTMLFormElement> {
|
|
42
50
|
items: ProductListTableItem[];
|
package/components/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface ItemsQuotedProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
18
18
|
onItemDropdownChange?: (item: NegotiableQuoteCartItem, action: string) => void;
|
|
19
19
|
onQuantityChange?: (item: NegotiableQuoteCartItem, newQuantity: number) => void;
|
|
20
20
|
onUpdate?: (e: SubmitEvent) => void;
|
|
21
|
-
dropdownSelections?: Record<string, string>;
|
|
21
|
+
dropdownSelections?: Record<string, string | undefined>;
|
|
22
22
|
}>;
|
|
23
23
|
QuotePricesSummary?: SlotProps<{
|
|
24
24
|
items: NegotiableQuoteModel['items'];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{I as
|
|
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/QuotePricesSummary.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"../chunks/dateUtils.js";import"@dropins/tools/i18n.js";import"../chunks/ConfirmationModal.js";/* empty css *//* 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/WarningFilled.js";export{q as ItemsQuoted,v as default};
|
|
4
4
|
//# sourceMappingURL=ItemsQuoted.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{I as
|
|
3
|
+
import{I as T,I as b}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/QuotePricesSummary.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"../chunks/dateUtils.js";import"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */export{T as ItemsQuotedTemplate,b as default};
|
|
4
4
|
//# sourceMappingURL=ItemsQuotedTemplate.js.map
|
|
@@ -9,6 +9,10 @@ export interface ManageNegotiableQuoteProps extends HTMLAttributes<HTMLDivElemen
|
|
|
9
9
|
quoteData: NegotiableQuoteModel;
|
|
10
10
|
comment?: string;
|
|
11
11
|
}) => void;
|
|
12
|
+
onDuplicateQuote?: (params: {
|
|
13
|
+
quoteData: NegotiableQuoteModel;
|
|
14
|
+
newQuote: NegotiableQuoteModel;
|
|
15
|
+
}) => void;
|
|
12
16
|
slots?: {
|
|
13
17
|
QuoteName?: SlotProps<{
|
|
14
18
|
quoteName?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as t,jsxs as d,Fragment as Ue}from"@dropins/tools/preact-jsx-runtime.js";import*as ke from"@dropins/tools/preact-compat.js";import{useState as c,useRef as de,useEffect as _,useCallback as s,useMemo as f,createPortal as P}from"@dropins/tools/preact-compat.js";import{classes as m,VComponent as h,Slot as g}from"@dropins/tools/lib.js";import{f as Pe}from"../chunks/dateUtils.js";/* empty css */import{Picker as Ma,Skeleton as ha,SkeletonRow as F,Modal as Na,Input as qa,TextArea as ze,Button as Y,InLineAlert as y}from"@dropins/tools/components.js";import{events as E}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{I as Qa,C as J}from"../chunks/ItemsQuoted.js";/* empty css *//* empty css */import{T as va}from"../chunks/TabbedContent.js";/* empty css */import{useText as We}from"@dropins/tools/i18n.js";import{S as Ta}from"../chunks/ShippingAddressDisplay.js";import{Q as Sa}from"../chunks/QuoteHistoryLog3.js";import{g as Ca,r as _a,c as ya,a as Ia,s as La,d as wa}from"../chunks/renameNegotiableQuote.js";import"../chunks/state.js";import{Q as Ea}from"../chunks/QuoteCommentsList3.js";import{a as U,S as K}from"../chunks/WarningFilled.js";import"../chunks/QuotePricesSummary.js";import"../chunks/removeNegotiableQuoteItems.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/QuoteHistoryLog.js";import"../chunks/transform-quote-template.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/QuoteCommentsList.js";const xa=p=>ke.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",...p},ke.createElement("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})),Ra=({className:p,dropdownPlaceholder:a,dropdownOptions:l,dropdownValue:N,handleDropdownChange:v,buttons:e,...u})=>{const q=l&&l.length>0,T=e&&e.length>0,S=(l==null?void 0:l.map(M=>({text:M.label,value:M.value})))||[];return S.unshift({text:a||"",value:""}),t("div",{className:"quote-management-actions-bar__container","data-testid":"actions-bar-container",children:d("div",{className:m(["quote-management-actions-bar",p]),"data-testid":"actions-bar",...u,children:[q&&t(Ma,{name:"dropdown",id:"dropdown",handleSelect:v,className:"quote-management-actions-bar__dropdown","data-testid":"dropdown",options:S,value:N||""},`actions-bar-picker-${N||"empty"}`),T&&t("div",{className:"quote-management-actions-bar__buttons","data-testid":"buttons-container",children:e==null?void 0:e.map((M,C)=>t(h,{node:M,className:m(["quote-management-actions-bar__button"])},C))})]})})},Ha=({className:p,loading:a,quoteName:l,quoteStatus:N,banner:v,details:e,actionBar:u,quoteContent:q,shippingInformationTitle:T,shippingInformation:S,quoteCommentsTitle:M,quoteComments:C,footer:b,...I})=>a?t(Fa,{}):d("div",{...I,className:m(["quote-management-manage-negotiable-quote",p]),children:[d("div",{className:m(["quote-management-manage-negotiable-quote__header"]),children:[l&&t(h,{node:l,className:m(["quote-management-manage-negotiable-quote__quote-name"])}),N&&t(h,{node:N,className:m(["quote-management-manage-negotiable-quote__quote-status"])})]}),v&&t(h,{node:v,className:m(["quote-management-manage-negotiable-quote__banner"])}),e&&t(h,{node:e,className:m(["quote-management-manage-negotiable-quote__details"])}),u&&t(h,{node:u,className:m(["quote-management-manage-negotiable-quote__action-bar"])}),q&&t(h,{node:q,className:m(["quote-management-manage-negotiable-quote__quote-content"])}),d("div",{"data-testid":"quote-shipping-information-container",className:m(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[T&&t(h,{node:T,className:m(["quote-management-manage-negotiable-quote__shipping-information-title"])}),S&&t(h,{node:S,className:m(["quote-management-manage-negotiable-quote__shipping-information"])})]}),d("div",{"data-testid":"quote-comments-container",className:m(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[M&&t(h,{node:M,className:m(["quote-management-manage-negotiable-quote__quote-comments-title"])}),C&&t(h,{node:C,className:m(["quote-management-manage-negotiable-quote__quote-comments"])})]}),t(h,{node:b,className:m(["quote-management-manage-negotiable-quote__footer"])})]}),Fa=()=>d(ha,{"data-testid":"manage-negotiable-quote-skeleton",children:[t(F,{variant:"heading",fullWidth:!0,size:"large"}),t(F,{variant:"row",fullWidth:!1,size:"small"}),t(F,{variant:"row",fullWidth:!1,size:"small"}),t(F,{variant:"row",fullWidth:!0}),t(F,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),t(F,{variant:"row",fullWidth:!1,size:"small"})]}),Da=({className:p,open:a,quoteName:l,renameReason:N,quoteNameError:v,errorBanner:e,successBanner:u,showCloseButton:q=!0,onQuoteNameChange:T,onRenameReasonChange:S,onSave:M,onClose:C})=>{const b=We({title:"NegotiableQuote.Manage.rename.title",quoteNameLabel:"NegotiableQuote.Manage.rename.quoteNameLabel",reasonLabel:"NegotiableQuote.Manage.rename.reasonLabel",renameButton:"NegotiableQuote.Manage.rename.renameButton",cancelButton:"NegotiableQuote.Manage.rename.cancelButton"});return a?d(Na,{open:a,size:"medium",title:t(Ue,{children:b.title}),onClose:C,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:q,className:m(["quote-management-rename-quote-modal",p]),"data-testid":"rename-quote-modal",children:[e&&t("div",{className:m(["quote-management-rename-quote-modal__error-banner"]),"data-testid":"rename-quote-modal-error-banner",children:e}),u&&t("div",{className:m(["quote-management-rename-quote-modal__success-banner"]),"data-testid":"rename-quote-modal-success-banner",children:u}),d("div",{className:m(["quote-management-rename-quote-modal__content"]),children:[d("div",{children:[t(qa,{name:"quoteName",type:"text",value:l,onInput:I=>T(I.target.value),floatingLabel:b.quoteNameLabel,required:!0,error:!!v}),v&&t("span",{className:m(["quote-management-rename-quote-modal__error-text"]),children:v})]}),t(ze,{name:"quoteComment",value:N,onInput:I=>S(I.target.value),label:b.reasonLabel,rows:3})]}),d("div",{className:m(["quote-management-rename-quote-modal__actions"]),children:[t(Y,{variant:"secondary",size:"medium",onClick:C,className:m(["quote-management-rename-quote-modal__cancel-button"]),children:b.cancelButton}),t(Y,{variant:"primary",size:"medium",onClick:M,className:m(["quote-management-rename-quote-modal__save-button"]),children:b.renameButton})]})]}):null},ft=({onActionsDropdownChange:p,slots:a,onActionsButtonClick:l,onSendForReview:N,...v})=>{const[e,u]=c(void 0),[q,T]=c(!0),[S,M]=c(!1),[C,b]=c(null),[I,z]=c(!1),[L,ue]=c(""),[D,Z]=c(!1),[ge,A]=c(!1),[be,ee]=c(!1),[fe,x]=c(""),[pe,B]=c(""),[Me,he]=c(!1),[Ne,qe]=c(!1),[Qe,W]=c(""),[ve,O]=c(""),[Te,ae]=c(!1),[V,j]=c(""),[te,$]=c(""),[ne,k]=c(""),[Oe,R]=c(""),[oe,G]=c(""),[re,Se]=c(new Set),Ce=de(re),ie=de(null),[H,le]=c(""),X=de(H),[_e,ye]=c(!1);_(()=>{Ce.current=re},[re]),_(()=>{X.current=H},[H]);const o=We({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",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription"});_(()=>{const n=E.on("quote-management/quote-data",r=>{const{quote:i}=r;i&&(u(i),T(!1))},{eager:!0});return()=>n==null?void 0:n.off()},[]),_(()=>{const n=E.on("quote-management/shipping-address-set",r=>{const{quote:i}=r;i&&u(i)},{eager:!0});return()=>n==null?void 0:n.off()},[]),_(()=>{const n=E.on("quote-management/quote-sent-for-review",r=>{const{quote:i}=r;u(i),ue(""),Z(!1)},{eager:!0});return()=>n==null?void 0:n.off()},[]),_(()=>{const n=E.on("quote-management/quote-items-removed",r=>{const{quote:i,removedItemUids:Q}=r;i&&u(i),Q&&Se(w=>{const Be=new Set(w);return Q.forEach(pa=>Be.delete(pa)),Be})},{eager:!0});return()=>n==null?void 0:n.off()},[]);const Ie=s((n,r)=>{Se(i=>{const Q=new Set(i);return r?Q.add(n.uid):Q.delete(n.uid),Q})},[]),Le=s(n=>{const r=n.target.value,i=Ce.current;if(r==="remove"){if(le(r),X.current=r,i.size===0)ye(!0);else if(e&&ie.current){const Q=e.items.filter(w=>i.has(w.uid));ie.current(Q)}}p==null||p(n)},[p,e]),we=s(()=>{ye(!1),le(""),X.current=""},[]);_(()=>{const n=E.on("quote-management/negotiable-quote-closed",async r=>{ee(!1),B(""),x(o.closeSuccessMessage),u(i=>{var Q;return i!=null&&i.uid&&((Q=r.closedQuoteUids)!=null&&Q.includes(i.uid))&&Ca(i.uid).then(w=>{u(w)}).catch(w=>{console.warn("Failed to refresh quote data after closure:",w)}),i}),setTimeout(()=>{A(!1),x("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.closeSuccessMessage]),_(()=>{const n=E.on("quote-management/negotiable-quote-close-error",r=>{console.log("Close error event received:",r),ee(!1),x("");const i=r.error.message||o.errorFallback;B(i)},{eager:!0});return()=>n==null?void 0:n.off()},[o.errorFallback]),_(()=>{const n=E.on("quote-management/quote-renamed",r=>{const{quote:i}=r;u(i),k(""),R(""),G(o.renameSuccessMessage),setTimeout(()=>{ae(!1),j(""),$(""),G("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.renameSuccessMessage]);const Ee=s(()=>{j((e==null?void 0:e.name)||""),$(""),k(""),R(""),G(""),ae(!0)},[e]),Ve=s(()=>{ae(!1),j(""),$(""),k(""),R(""),G("")},[]),je=s(n=>{j(n),n.trim()&&R("")},[]),$e=s(async()=>{if(!V.trim()){R(o.renameQuoteNameRequired);return}try{k(""),R(""),await _a({quoteUid:e.uid,quoteName:V,quoteComment:te.trim()||void 0})}catch(n){k(n.message||o.renameErrorDefault)}},[e,V,te,o.renameQuoteNameRequired,o.renameErrorDefault]),Ge=f(()=>{const n=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return t(g,{name:"QuoteName",slot:a==null?void 0:a.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:d("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[t("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),t("button",{onClick:Ee,disabled:n,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:t(xa,{})})]})})},[a==null?void 0:a.QuoteName,e,Ee]),Xe=f(()=>t(g,{name:"QuoteStatus",slot:a==null?void 0:a.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:t("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[a==null?void 0:a.QuoteStatus,e]),xe=s(n=>{switch(n){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),Re=xe&&t(y,{type:"warning",variant:"secondary",icon:t(U,{}),heading:o.bannerTitle,description:xe}),Je=Re&&t(g,{name:"Banner","data-testid":"banner",slot:a==null?void 0:a.Banner,context:{quoteData:e},children:Re}),Ke=f(()=>{if(!e)return;const n=e.expirationDate?Pe(e.expirationDate,"short"):void 0;return d(g,{name:"Details",slot:a==null?void 0:a.Details,context:{quoteData:e},children:[d("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),d("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[Pe(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),d("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),d("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:n})]})]})},[a==null?void 0:a.Details,o,e]),He=f(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate"},{label:o.createCopy,value:"createCopy"}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose]),Ye=f(()=>{const n=r=>{switch(r){case"close":A(!0),B(""),x(""),l==null||l(r);break;case"delete":M(!0),l==null||l(r);break;case"print":l==null||l(r);break;case"createTemplate":he(!0),O(""),W(""),l==null||l(r);break;case"createCopy":l==null||l(r);break}};return t(g,{name:"ActionBar",slot:a==null?void 0:a.ActionBar,context:{quoteData:e,actionsBarDropdownValue:H},children:t(Ra,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:H,handleDropdownChange:Le,buttons:He.map(r=>t(Y,{variant:"tertiary",onClick:()=>n(r.value),"data-testid":`actions-bar-${r.value}-button`,"data-action":r.value,disabled:r.disabled,children:r.label},r.value))})})},[He,o,a==null?void 0:a.ActionBar,e,Le,l,H]),Ze=f(()=>t(g,{name:"QuoteContent",slot:a==null?void 0:a.QuoteContent,context:{quoteData:e},children:t(va,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",t(g,{name:"ItemsQuotedTab",slot:a==null?void 0:a.ItemsQuotedTab,context:{quoteData:e},children:t(Qa,{quoteData:e,onItemCheckboxChange:Ie,onRemoveItemsRef:n=>{ie.current=n},onRemoveModalStateChange:n=>{!n&&X.current==="remove"&&le("")}})},"items-quoted")],["comments",t(g,{name:"CommentsTab",slot:a==null?void 0:a.CommentsTab,context:{quoteData:e},children:t(Ea,{quoteData:e})},"comments")],["history-log",t(g,{name:"HistoryLogTab",slot:a==null?void 0:a.HistoryLogTab,context:{quoteData:e},children:t(Sa,{quoteData:e})},"history-log")]])})}),[a==null?void 0:a.QuoteContent,a==null?void 0:a.HistoryLogTab,a==null?void 0:a.CommentsTab,a==null?void 0:a.ItemsQuotedTab,e,Ie]),Ae=f(()=>t(g,{name:"ShippingInformationTitle",slot:a==null?void 0:a.ShippingInformationTitle,context:{quoteData:e},children:t("h2",{children:o.shippingInformationTitle})}),[a==null?void 0:a.ShippingInformationTitle,e,o]),ea=f(()=>t(g,{name:"ShippingInformation",slot:a==null?void 0:a.ShippingInformation,context:{quoteData:e,loading:q,setLoading:T},children:t(Ta,{quoteData:e,loading:q,"data-testid":"manage-quote-shipping-address"})}),[a==null?void 0:a.ShippingInformation,e,q,T]),aa=f(()=>t(g,{name:"QuoteCommentsTitle",slot:a==null?void 0:a.QuoteCommentsTitle,context:{quoteData:e},children:t("h2",{children:o.quoteCommentsTitle})}),[a==null?void 0:a.QuoteCommentsTitle,o,e]),ta=f(()=>t(g,{name:"QuoteComments",slot:a==null?void 0:a.QuoteComments,context:{quoteData:e},children:t(ze,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:L,onInput:n=>{ue(n.target.value)},disabled:!(e!=null&&e.canSendForReview)||D})}),[a==null?void 0:a.QuoteComments,o,e,L,D]),na=s(async()=>{if(e!=null&&e.uid){ee(!0),B(""),x("");try{await ya({quoteUids:[e.uid]})}catch(n){console.error("Failed to close quote:",n)}}},[e]),oa=s(()=>{A(!1),B(""),x("")},[]),ra=s(async()=>{if(e!=null&&e.uid){qe(!0),O(""),W("");try{await Ia(e.uid),W(o.createTemplateSuccessMessage)}catch(n){console.error("Failed to create quote template:",n);const r=n instanceof Error?n.message:o.createTemplateErrorFallback;O(r)}finally{qe(!1)}}},[e,o.createTemplateSuccessMessage,o.createTemplateErrorFallback]),ia=s(()=>{he(!1),O(""),W("")},[]),Fe=s(async()=>{if(N){N({quoteData:e,comment:L.trim()||void 0});return}Z(!0);try{await La({quoteUid:e.uid,comment:L.trim()||void 0})}catch(n){console.error("Failed to send quote for review:",n),Z(!1)}},[e,N,L]),la=f(()=>t(g,{name:"Footer",slot:a==null?void 0:a.Footer,context:{quoteData:e,comment:L,isSubmitting:D},children:t(Y,{variant:"primary",onClick:Fe,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||D,children:o.sendForReview})}),[a==null?void 0:a.Footer,o,e,L,D,Fe]),ma=f(()=>ne?t(y,{type:"error",variant:"primary",icon:t(U,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:ne}):void 0,[ne,o.renameErrorHeading]),ca=f(()=>oe?t(y,{type:"success",variant:"primary",icon:t(K,{}),heading:o.renameSuccessHeading,description:oe}):void 0,[oe,o.renameSuccessHeading]),me=s(n=>n.errors&&Array.isArray(n.errors)&&n.errors.length>0?n.errors[0].message||o.confirmationModalDeleteErrorFallback:(n==null?void 0:n.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),sa=s(()=>{M(!1),b(null),z(!1)},[]),da=s(async()=>{if(e!=null&&e.uid){b(null),z(!1);try{const{operationResults:n}=await wa(e.uid),r=n.find(i=>i.__typename==="DeleteNegotiableQuoteOperationFailure");if(r){const i=me(r);b(i);return}z(!0)}catch(n){const r=me(n);b(r)}}},[e,me]),ua=s(()=>{b(null)},[]),ga=s(()=>{z(!1)},[]),ba=C?t(y,{type:"error",variant:"primary",icon:t(U,{}),heading:o.confirmationModalDeleteErrorHeading,description:C,onDismiss:ua,"data-testid":"confirmation-modal-error-banner"}):null,De=(I?t(y,{type:"success",variant:"primary",icon:t(K,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:ga,"data-testid":"confirmation-modal-success-banner"}):null)||ba,fa={...v,loading:q,quoteName:Ge,quoteStatus:Xe,banner:Je||void 0,details:Ke,actionBar:Ye,quoteContent:Ze,shippingInformationTitle:Ae,shippingInformation:ea,quoteCommentsTitle:aa,quoteComments:ta,footer:la};let ce=null;fe?ce=t(y,{type:"success",variant:"primary",icon:t(K,{}),heading:o.closeModalSuccessHeading,description:fe,"data-testid":"close-quote-success-banner"}):pe&&(ce=t(y,{type:"error",variant:"primary",icon:t(U,{}),heading:o.confirmationModalDeleteErrorHeading,description:pe,"data-testid":"close-quote-error-banner"}));let se=null;return Qe?se=t(y,{type:"success",variant:"primary",icon:t(K,{}),heading:o.createTemplateModalSuccessHeading,description:Qe,"data-testid":"create-template-success-banner"}):ve&&(se=t(y,{type:"error",variant:"primary",icon:t(U,{}),heading:o.createTemplateModalErrorHeading,description:ve,"data-testid":"create-template-error-banner"})),d(Ue,{children:[t(Ha,{...fa}),Te&&P(t(Da,{open:Te,quoteName:V,renameReason:te,quoteNameError:Oe,errorBanner:ma,successBanner:ca,onQuoteNameChange:je,onRenameReasonChange:$,onSave:$e,onClose:Ve}),document.body),S&&P(t(J,{open:S,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:sa,onConfirm:da,showCloseButton:!De,confirmationBanner:De}),document.body),ge&&P(t(J,{open:ge,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:be?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:oa,onConfirm:be?void 0:na,showCloseButton:!0,confirmationBanner:ce,"data-testid":"close-quote-confirmation-modal"}),document.body),Me&&P(t(J,{open:Me,title:o.createTemplateModalTitle,message:o.createTemplateModalMessage,cancelLabel:o.createTemplateModalCancel,confirmLabel:Ne?o.createTemplateModalConfirmLoading:o.createTemplateModalConfirm,onCancel:ia,onConfirm:Ne?void 0:ra,showCloseButton:!0,confirmationBanner:se,"data-testid":"create-template-confirmation-modal"}),document.body),_e&&P(t(J,{open:_e,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:we,onClose:we,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{ft as ManageNegotiableQuote,ft as default};
|
|
3
|
+
import{jsx as a,jsxs as d,Fragment as Xe}from"@dropins/tools/preact-jsx-runtime.js";import*as Ge from"@dropins/tools/preact-compat.js";import{useState as l,useRef as pe,useEffect as S,useCallback as c,useMemo as p,createPortal as B}from"@dropins/tools/preact-compat.js";import{classes as s,VComponent as b,Slot as u}from"@dropins/tools/lib.js";import{f as $e}from"../chunks/dateUtils.js";/* empty css */import{Skeleton as La,SkeletonRow as k,Modal as Ra,Input as xa,TextArea as Je,Button as A,InLineAlert as h}from"@dropins/tools/components.js";import{events as D}from"@dropins/tools/event-bus.js";import{A as Ha,T as Fa}from"../chunks/TabbedContent.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{C as W}from"../chunks/ConfirmationModal.js";/* empty css *//* empty css *//* empty css */import{useText as Ke}from"@dropins/tools/i18n.js";import{S as Ba}from"../chunks/ShippingAddressDisplay.js";import{Q as ka}from"../chunks/QuoteHistoryLog3.js";import{g as Ua,r as Oa,c as za,a as Pa,s as Wa,d as Va,b as ja}from"../chunks/duplicateNegotiableQuote.js";import"../chunks/state.js";import{I as Ga}from"../chunks/ItemsQuoted.js";import{Q as $a}from"../chunks/QuoteCommentsList3.js";import{a as U,S as V}from"../chunks/WarningFilled.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/QuotePricesSummary.js";import"../chunks/setLineItemNote.js";import"../chunks/QuoteCommentsList.js";const Xa=N=>Ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",...N},Ge.createElement("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})),Ja=({className:N,loading:t,quoteName:m,quoteStatus:C,banner:q,details:I,actionBar:e,quoteContent:f,shippingInformationTitle:T,shippingInformation:y,quoteCommentsTitle:E,quoteComments:_,footer:Q,...M})=>t?a(Ka,{}):d("div",{...M,className:s(["quote-management-manage-negotiable-quote",N]),children:[d("div",{className:s(["quote-management-manage-negotiable-quote__header"]),children:[m&&a(b,{node:m,className:s(["quote-management-manage-negotiable-quote__quote-name"])}),C&&a(b,{node:C,className:s(["quote-management-manage-negotiable-quote__quote-status"])})]}),q&&a(b,{node:q,className:s(["quote-management-manage-negotiable-quote__banner"])}),I&&a(b,{node:I,className:s(["quote-management-manage-negotiable-quote__details"])}),e&&a(b,{node:e,className:s(["quote-management-manage-negotiable-quote__action-bar"])}),f&&a(b,{node:f,className:s(["quote-management-manage-negotiable-quote__quote-content"])}),d("div",{"data-testid":"quote-shipping-information-container",className:s(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[T&&a(b,{node:T,className:s(["quote-management-manage-negotiable-quote__shipping-information-title"])}),y&&a(b,{node:y,className:s(["quote-management-manage-negotiable-quote__shipping-information"])})]}),d("div",{"data-testid":"quote-comments-container",className:s(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[E&&a(b,{node:E,className:s(["quote-management-manage-negotiable-quote__quote-comments-title"])}),_&&a(b,{node:_,className:s(["quote-management-manage-negotiable-quote__quote-comments"])})]}),a(b,{node:Q,className:s(["quote-management-manage-negotiable-quote__footer"])})]}),Ka=()=>d(La,{"data-testid":"manage-negotiable-quote-skeleton",children:[a(k,{variant:"heading",fullWidth:!0,size:"large"}),a(k,{variant:"row",fullWidth:!1,size:"small"}),a(k,{variant:"row",fullWidth:!1,size:"small"}),a(k,{variant:"row",fullWidth:!0}),a(k,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),a(k,{variant:"row",fullWidth:!1,size:"small"})]}),Ya=({className:N,open:t,quoteName:m,renameReason:C,quoteNameError:q,errorBanner:I,successBanner:e,showCloseButton:f=!0,onQuoteNameChange:T,onRenameReasonChange:y,onSave:E,onClose:_})=>{const Q=Ke({title:"NegotiableQuote.Manage.rename.title",quoteNameLabel:"NegotiableQuote.Manage.rename.quoteNameLabel",reasonLabel:"NegotiableQuote.Manage.rename.reasonLabel",renameButton:"NegotiableQuote.Manage.rename.renameButton",cancelButton:"NegotiableQuote.Manage.rename.cancelButton"});return t?d(Ra,{open:t,size:"medium",title:a(Xe,{children:Q.title}),onClose:_,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:f,className:s(["quote-management-rename-quote-modal",N]),"data-testid":"rename-quote-modal",children:[I&&a("div",{className:s(["quote-management-rename-quote-modal__error-banner"]),"data-testid":"rename-quote-modal-error-banner",children:I}),e&&a("div",{className:s(["quote-management-rename-quote-modal__success-banner"]),"data-testid":"rename-quote-modal-success-banner",children:e}),d("div",{className:s(["quote-management-rename-quote-modal__content"]),children:[d("div",{children:[a(xa,{name:"quoteName",type:"text",value:m,onInput:M=>T(M.target.value),floatingLabel:Q.quoteNameLabel,required:!0,error:!!q}),q&&a("span",{className:s(["quote-management-rename-quote-modal__error-text"]),children:q})]}),a(Je,{name:"quoteComment",value:C,onInput:M=>y(M.target.value),label:Q.reasonLabel,rows:3})]}),d("div",{className:s(["quote-management-rename-quote-modal__actions"]),children:[a(A,{variant:"secondary",size:"medium",onClick:_,className:s(["quote-management-rename-quote-modal__cancel-button"]),children:Q.cancelButton}),a(A,{variant:"primary",size:"medium",onClick:E,className:s(["quote-management-rename-quote-modal__save-button"]),children:Q.renameButton})]})]}):null},Lt=({onActionsDropdownChange:N,slots:t,onActionsButtonClick:m,onSendForReview:C,onDuplicateQuote:q,...I})=>{const[e,f]=l(void 0),[T,y]=l(!0),[E,_]=l(!1),[Q,M]=l(null),[Ye,j]=l(!1),[fe,ee]=l(!1),[Me,w]=l(null),[Ze,R]=l(!1),[L,be]=l(""),[O,ae]=l(!1),[he,te]=l(!1),[Ne,ne]=l(!1),[qe,x]=l(""),[Qe,z]=l(""),[Se,Te]=l(!1),[ve,Ce]=l(!1),[ye,G]=l(""),[_e,$]=l(""),[De,oe]=l(!1),[X,J]=l(""),[re,K]=l(""),[ie,P]=l(""),[Ae,H]=l(""),[le,Y]=l(""),[ce,Ie]=l(new Set),Ee=pe(ce),se=pe(null),[F,me]=l(""),Z=pe(F),[we,Le]=l(!1);S(()=>{Ee.current=ce},[ce]),S(()=>{Z.current=F},[F]);const o=Ke({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",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm"});S(()=>{const n=D.on("quote-management/quote-data",r=>{const{quote:i}=r;i&&(f(i),y(!1))},{eager:!0});return()=>n==null?void 0:n.off()},[]),S(()=>{const n=D.on("quote-management/shipping-address-set",r=>{const{quote:i}=r;i&&f(i)},{eager:!0});return()=>n==null?void 0:n.off()},[]),S(()=>{const n=D.on("quote-management/quote-sent-for-review",r=>{const{quote:i}=r;f(i),be(""),ae(!1)},{eager:!0});return()=>n==null?void 0:n.off()},[]),S(()=>{const n=D.on("quote-management/quote-items-removed",r=>{const{quote:i,removedItemUids:g}=r;i&&f(i),g&&Ie(v=>{const je=new Set(v);return g.forEach(wa=>je.delete(wa)),je})},{eager:!0});return()=>n==null?void 0:n.off()},[]);const Re=c((n,r)=>{Ie(i=>{const g=new Set(i);return r?g.add(n.uid):g.delete(n.uid),g})},[]),xe=c(n=>{const r=n.target.value,i=Ee.current;if(r==="remove"){if(me(r),Z.current=r,i.size===0)Le(!0);else if(e&&se.current){const g=e.items.filter(v=>i.has(v.uid));se.current(g)}}N==null||N(n)},[N,e]),He=c(()=>{Le(!1),me(""),Z.current=""},[]);S(()=>{const n=D.on("quote-management/negotiable-quote-closed",async r=>{ne(!1),z(""),x(o.closeSuccessMessage),f(i=>{var g;return i!=null&&i.uid&&((g=r.closedQuoteUids)!=null&&g.includes(i.uid))&&Ua(i.uid).then(v=>{f(v)}).catch(v=>{console.warn("Failed to refresh quote data after closure:",v)}),i}),setTimeout(()=>{te(!1),x("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.closeSuccessMessage]),S(()=>{const n=D.on("quote-management/negotiable-quote-close-error",r=>{console.log("Close error event received:",r),ne(!1),x("");const i=r.error.message||o.errorFallback;z(i)},{eager:!0});return()=>n==null?void 0:n.off()},[o.errorFallback]),S(()=>{const n=D.on("quote-management/quote-renamed",r=>{const{quote:i}=r;f(i),P(""),H(""),Y(o.renameSuccessMessage),setTimeout(()=>{oe(!1),J(""),K(""),Y("")},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[o.renameSuccessMessage]),S(()=>{const n=D.on("quote-management/quote-duplicated",r=>{const{quote:i}=r;e&&q&&q({quoteData:e,newQuote:i}),R(!0),w(null),setTimeout(()=>{ee(!1),R(!1),w(null)},2e3)},{eager:!0});return()=>n==null?void 0:n.off()},[e,q]);const Fe=c(()=>{J((e==null?void 0:e.name)||""),K(""),P(""),H(""),Y(""),oe(!0)},[e]),ea=c(()=>{oe(!1),J(""),K(""),P(""),H(""),Y("")},[]),aa=c(n=>{J(n),n.trim()&&H("")},[]),Be=c(()=>{ee(!0),w(null),R(!1)},[]),ta=c(async()=>{if(!X.trim()){H(o.renameQuoteNameRequired);return}try{P(""),H(""),await Oa({quoteUid:e.uid,quoteName:X,quoteComment:re.trim()||void 0})}catch(n){P(n.message||o.renameErrorDefault)}},[e,X,re,o.renameQuoteNameRequired,o.renameErrorDefault]),na=p(()=>{const n=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return a(u,{name:"QuoteName",slot:t==null?void 0:t.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:d("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[a("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),a("button",{onClick:Fe,disabled:n,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:a(Xa,{})})]})})},[t==null?void 0:t.QuoteName,e,Fe]),oa=p(()=>a(u,{name:"QuoteStatus",slot:t==null?void 0:t.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:a("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[t==null?void 0:t.QuoteStatus,e]),ke=c(n=>{switch(n){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),Ue=ke&&a(h,{type:"warning",variant:"secondary",icon:a(U,{}),heading:o.bannerTitle,description:ke}),ra=Ue&&a(u,{name:"Banner","data-testid":"banner",slot:t==null?void 0:t.Banner,context:{quoteData:e},children:Ue}),ia=p(()=>{if(!e)return;const n=e.expirationDate?$e(e.expirationDate,"short"):void 0;return d(u,{name:"Details",slot:t==null?void 0:t.Details,context:{quoteData:e},children:[d("div",{className:"quote-management-manage-negotiable-quote__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),d("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[$e(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),d("div",{className:"quote-management-manage-negotiable-quote__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),a("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),d("div",{className:"quote-management-manage-negotiable-quote__detail",children:[a("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),a("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:n})]})]})},[t==null?void 0:t.Details,o,e]),Oe=p(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate"},{label:o.createCopy,value:"createCopy"}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose]),la=p(()=>{const n=r=>{switch(r){case"close":te(!0),z(""),x(""),m==null||m(r);break;case"delete":_(!0),m==null||m(r);break;case"print":m==null||m(r);break;case"createTemplate":Te(!0),$(""),G(""),m==null||m(r);break;case"createCopy":Be(),m==null||m(r);break}};return a(u,{name:"ActionBar",slot:t==null?void 0:t.ActionBar,context:{quoteData:e,actionsBarDropdownValue:F},children:a(Ha,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:F,handleDropdownChange:xe,buttons:Oe.map(r=>a(A,{variant:"tertiary",onClick:()=>n(r.value),"data-testid":`actions-bar-${r.value}-button`,"data-action":r.value,disabled:r.disabled,children:r.label},r.value))})})},[Oe,o,t==null?void 0:t.ActionBar,e,xe,m,Be,F]),ca=p(()=>a(u,{name:"QuoteContent",slot:t==null?void 0:t.QuoteContent,context:{quoteData:e},children:a(Fa,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",a(u,{name:"ItemsQuotedTab",slot:t==null?void 0:t.ItemsQuotedTab,context:{quoteData:e},children:a(Ga,{quoteData:e,onItemCheckboxChange:Re,onRemoveItemsRef:n=>{se.current=n},onRemoveModalStateChange:n=>{!n&&Z.current==="remove"&&me("")}})},"items-quoted")],["comments",a(u,{name:"CommentsTab",slot:t==null?void 0:t.CommentsTab,context:{quoteData:e},children:a($a,{quoteData:e})},"comments")],["history-log",a(u,{name:"HistoryLogTab",slot:t==null?void 0:t.HistoryLogTab,context:{quoteData:e},children:a(ka,{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,Re]),sa=p(()=>a(u,{name:"ShippingInformationTitle",slot:t==null?void 0:t.ShippingInformationTitle,context:{quoteData:e},children:a("h2",{children:o.shippingInformationTitle})}),[t==null?void 0:t.ShippingInformationTitle,e,o]),ma=p(()=>a(u,{name:"ShippingInformation",slot:t==null?void 0:t.ShippingInformation,context:{quoteData:e,loading:T,setLoading:y},children:a(Ba,{quoteData:e,loading:T,"data-testid":"manage-quote-shipping-address"})}),[t==null?void 0:t.ShippingInformation,e,T,y]),da=p(()=>a(u,{name:"QuoteCommentsTitle",slot:t==null?void 0:t.QuoteCommentsTitle,context:{quoteData:e},children:a("h2",{children:o.quoteCommentsTitle})}),[t==null?void 0:t.QuoteCommentsTitle,o,e]),ua=p(()=>a(u,{name:"QuoteComments",slot:t==null?void 0:t.QuoteComments,context:{quoteData:e},children:a(Je,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:L,onInput:n=>{be(n.target.value)},disabled:!(e!=null&&e.canSendForReview)||O})}),[t==null?void 0:t.QuoteComments,o,e,L,O]),ga=c(async()=>{if(e!=null&&e.uid){ne(!0),z(""),x("");try{await za({quoteUids:[e.uid]})}catch(n){console.error("Failed to close quote:",n)}}},[e]),pa=c(()=>{te(!1),z(""),x("")},[]),fa=c(async()=>{if(e!=null&&e.uid){Ce(!0),$(""),G("");try{await Pa(e.uid),G(o.createTemplateSuccessMessage)}catch(n){console.error("Failed to create quote template:",n);const r=n instanceof Error?n.message:o.createTemplateErrorFallback;$(r)}finally{Ce(!1)}}},[e,o.createTemplateSuccessMessage,o.createTemplateErrorFallback]),Ma=c(()=>{Te(!1),$(""),G("")},[]),ze=c(async()=>{if(C){C({quoteData:e,comment:L.trim()||void 0});return}ae(!0);try{await Wa({quoteUid:e.uid,comment:L.trim()||void 0})}catch(n){console.error("Failed to send quote for review:",n),ae(!1)}},[e,C,L]),ba=p(()=>a(u,{name:"Footer",slot:t==null?void 0:t.Footer,context:{quoteData:e,comment:L,isSubmitting:O},children:a(A,{variant:"primary",onClick:ze,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||O,children:o.sendForReview})}),[t==null?void 0:t.Footer,o,e,L,O,ze]),ha=p(()=>ie?a(h,{type:"error",variant:"primary",icon:a(U,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:ie}):void 0,[ie,o.renameErrorHeading]),Na=p(()=>le?a(h,{type:"success",variant:"primary",icon:a(V,{}),heading:o.renameSuccessHeading,description:le}):void 0,[le,o.renameSuccessHeading]),de=c(n=>n.errors&&Array.isArray(n.errors)&&n.errors.length>0?n.errors[0].message||o.confirmationModalDeleteErrorFallback:(n==null?void 0:n.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),qa=c(()=>{_(!1),M(null),j(!1)},[]),Qa=c(async()=>{if(e!=null&&e.uid){M(null),j(!1);try{const{operationResults:n}=await Va(e.uid),r=n.find(i=>i.__typename==="DeleteNegotiableQuoteOperationFailure");if(r){const i=de(r);M(i);return}j(!0)}catch(n){const r=de(n);M(r)}}},[e,de]),Sa=c(()=>{M(null)},[]),Ta=c(()=>{j(!1)},[]),Pe=c(n=>(n==null?void 0:n.message)||o.confirmationModalDuplicateErrorFallback,[o.confirmationModalDuplicateErrorFallback]),va=c(()=>{ee(!1),w(null),R(!1)},[]),Ca=c(async()=>{if(e!=null&&e.uid){w(null),R(!1);try{const r=(i=>{const g=i.slice(0,-8),v=crypto.randomUUID().slice(0,8);return g+v})(e.uid);await ja({quoteUid:e.uid,duplicatedQuoteUid:r})}catch(n){const r=Pe(n);w(r)}}},[e,Pe]),ya=c(()=>{w(null)},[]),_a=c(()=>{R(!1)},[]),Da=Q?a(h,{type:"error",variant:"primary",icon:a(U,{}),heading:o.confirmationModalDeleteErrorHeading,description:Q,onDismiss:Sa,"data-testid":"confirmation-modal-error-banner"}):null,We=(Ye?a(h,{type:"success",variant:"primary",icon:a(V,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:Ta,"data-testid":"confirmation-modal-success-banner"}):null)||Da,Ia=Me?a(h,{type:"error",variant:"primary",icon:a(U,{}),heading:o.confirmationModalDuplicateErrorHeading,description:Me,onDismiss:ya,"data-testid":"confirmation-modal-duplicate-error-banner"}):null,Ve=(Ze?a(h,{type:"success",variant:"primary",icon:a(V,{}),heading:o.confirmationModalDuplicateSuccessHeading,description:o.confirmationModalDuplicateSuccessDescription,onDismiss:_a,"data-testid":"confirmation-modal-duplicate-success-banner"}):null)||Ia,Ea={...I,loading:T,quoteName:na,quoteStatus:oa,banner:ra||void 0,details:ia,actionBar:la,quoteContent:ca,shippingInformationTitle:sa,shippingInformation:ma,quoteCommentsTitle:da,quoteComments:ua,footer:ba};let ue=null;qe?ue=a(h,{type:"success",variant:"primary",icon:a(V,{}),heading:o.closeModalSuccessHeading,description:qe,"data-testid":"close-quote-success-banner"}):Qe&&(ue=a(h,{type:"error",variant:"primary",icon:a(U,{}),heading:o.confirmationModalDeleteErrorHeading,description:Qe,"data-testid":"close-quote-error-banner"}));let ge=null;return ye?ge=a(h,{type:"success",variant:"primary",icon:a(V,{}),heading:o.createTemplateModalSuccessHeading,description:ye,"data-testid":"create-template-success-banner"}):_e&&(ge=a(h,{type:"error",variant:"primary",icon:a(U,{}),heading:o.createTemplateModalErrorHeading,description:_e,"data-testid":"create-template-error-banner"})),d(Xe,{children:[a(Ja,{...Ea}),De&&B(a(Ya,{open:De,quoteName:X,renameReason:re,quoteNameError:Ae,errorBanner:ha,successBanner:Na,onQuoteNameChange:aa,onRenameReasonChange:K,onSave:ta,onClose:ea}),document.body),E&&B(a(W,{open:E,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:qa,onConfirm:Qa,showCloseButton:!We,confirmationBanner:We}),document.body),fe&&B(a(W,{open:fe,title:o.confirmationModalDuplicateTitle,message:o.confirmationModalDuplicateMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDuplicateConfirm,onCancel:va,onConfirm:Ca,showCloseButton:!Ve,confirmationBanner:Ve}),document.body),he&&B(a(W,{open:he,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:Ne?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:pa,onConfirm:Ne?void 0:ga,showCloseButton:!0,confirmationBanner:ue,"data-testid":"close-quote-confirmation-modal"}),document.body),Se&&B(a(W,{open:Se,title:o.createTemplateModalTitle,message:o.createTemplateModalMessage,cancelLabel:o.createTemplateModalCancel,confirmLabel:ve?o.createTemplateModalConfirmLoading:o.createTemplateModalConfirm,onCancel:Ma,onConfirm:ve?void 0:fa,showCloseButton:!0,confirmationBanner:ge,"data-testid":"create-template-confirmation-modal"}),document.body),we&&B(a(W,{open:we,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:He,onClose:He,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{Lt as ManageNegotiableQuote,Lt as default};
|
|
4
4
|
//# sourceMappingURL=ManageNegotiableQuote.js.map
|