@dropins/storefront-quote-management 1.0.0-beta3 → 1.0.0-beta4
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/graphql/NegotiableQuoteTemplateFragment.d.ts +1 -1
- package/api.js +1 -1
- package/chunks/ItemsQuoted.js.map +1 -1
- package/chunks/ItemsQuotedTemplate.js +1 -1
- package/chunks/ItemsQuotedTemplate.js.map +1 -1
- package/chunks/LineItemNoteModal.js.map +1 -1
- package/chunks/NegotiableQuoteTemplateFragment.js +144 -2
- package/chunks/NegotiableQuoteTemplateFragment.js.map +1 -1
- package/chunks/negotiableQuotes.js +1 -1
- package/chunks/transform-quote-template.js +1 -1
- package/chunks/transform-quote-template.js.map +1 -1
- package/chunks/transform-quote.js +1 -1
- package/chunks/transform-quote.js.map +1 -1
- package/components/LineItemNoteModal/LineItemNoteModal.d.ts +2 -2
- package/containers/ItemsQuoted/ItemsQuoted.d.ts +7 -7
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/QuoteSummaryList/QuoteSummaryList.d.ts +1 -1
- package/containers/QuoteSummaryList.js.map +1 -1
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuoteTemplatesListTable.js.map +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/QuotesListTable.js.map +1 -1
- package/data/models/__fixtures__/negotiableQuoteModel.d.ts +5 -5
- package/data/models/negotiable-quote-model.d.ts +2 -2
- package/data/models/negotiable-quote-template-model.d.ts +3 -39
- package/data/transforms/__fixtures__/negotiableQuoteTemplateData.d.ts +560 -75
- package/data/transforms/transform-history.d.ts +15 -0
- package/data/transforms/transform-quote-items.d.ts +15 -0
- package/hooks/useItemsQuotedTemplate.d.ts +2 -2
- package/hooks/useRemoveTemplateItems.d.ts +3 -3
- package/lib/itemFormatters.d.ts +1 -1
- package/lib/priceCalculators.d.ts +1 -1
- package/package.json +1 -1
- package/render.js +1 -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 d}from"./state.js";var g=(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))(g||{});const{setEndpoint:B,setFetchGraphQlHeader:G,removeFetchGraphQlHeader:z,setFetchGraphQlHeaders:W,fetchGraphQl:H,getConfig:V}=new I().getMethods(),x=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function D(e){if(!e.items)return 0;const n=d.config;return(n==null?void 0:n.quoteSummaryDisplayTotal)===0?e.items.length:(n==null?void 0:n.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function P(e){var a,t,i,l;const n=d.config;return{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((t=(a=e.configured_variant)==null?void 0:a.thumbnail)==null?void 0:t.url)||e.product.thumbnail.url,alt:n!=null&&n.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 w(e){var n;return((n=e.links)==null?void 0:n.length)>0?{count:e.links.length,result:e.links.map(a=>a.title).join(", ")}:null}function E(e,n){return e!=null&&e.length&&[...e].sort((t,i)=>i.quantity-t.quantity).find(t=>n>=t.quantity)||null}function C(e){var u,s;const n=e.quantity,a=e.__typename==="ConfigurableCartItem",t=a?(u=e.configured_variant)==null?void 0:u.price_tiers:e.product.price_tiers,i=a?(s=e.configured_variant)==null?void 0:s.price_range:e.product.price_range,l=E(t,n);return l?l.discount.amount_off>0:(i==null?void 0:i.maximum_price.discount.amount_off)>0}function A(e){var i,l,u,s,_,r,o,c;const n=e.quantity,a=E(e.product.price_tiers,n);if(a)return Math.round(a.discount.percent_off);let t;if(e.__typename==="ConfigurableCartItem")t=(s=(u=(l=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:l.maximum_price)==null?void 0:u.discount)==null?void 0:s.percent_off;else{if(e.__typename==="BundleCartItem")return;t=(c=(o=(r=(_=e==null?void 0:e.product)==null?void 0:_.price_range)==null?void 0:r.maximum_price)==null?void 0:o.discount)==null?void 0:c.percent_off}if(t!==0)return Math.round(t)}function O(e){var n,a,t,i;return e.__typename==="ConfigurableCartItem"?{value:(a=(n=e.configured_variant)==null?void 0:n.price_range)==null?void 0:a.maximum_price.regular_price.value,currency:(i=(t=e.configured_variant)==null?void 0:t.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 R(e){var t,i,l,u,s,_;let n,a;if(n=((i=(t=e==null?void 0:e.prices)==null?void 0:t.original_row_total)==null?void 0:i.value)-((u=(l=e==null?void 0:e.prices)==null?void 0:l.row_total)==null?void 0:u.value),a=(_=(s=e==null?void 0:e.prices)==null?void 0:s.row_total)==null?void 0:_.currency,n!==0)return{value:n,currency:a}}function S(e){var n;return((n=e.items)==null?void 0:n.map(a=>{var t,i,l,u,s,_,r,o;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:P(a),links:w(a),discounted:C(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:((i=(t=a.prices)==null?void 0:t.discounts)==null?void 0:i.map(c=>({label:c.label,value:c.value,amount:{value:c.amount.value,currency:c.amount.currency}})))??[],discountPercentage:A(a),insufficientQuantity:(a.__typename==="ConfigurableCartItem"?((l=a.configured_variant)==null?void 0:l.stock_status)??a.product.stock_status: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:O(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:R(a),noteFromBuyer:(u=a.note_from_buyer)==null?void 0:u.map(c=>({createdAt:c.created_at,creatorId:c.creator_id,creatorType:c.creator_type,negotiableQuoteItemUid:c.negotiable_quote_item_uid,note:c.note,noteUid:c.note_uid})),noteFromSeller:(s=a.note_from_seller)==null?void 0:s.map(c=>({createdAt:c.created_at,creatorId:c.creator_id,creatorType:c.creator_type,negotiableQuoteItemUid:c.negotiable_quote_item_uid,note:c.note,noteUid:c.note_uid})),configurableOptions:(_=a.configurable_options)==null?void 0:_.map(c=>({optionLabel:c.option_label,valueLabel:c.value_label})),bundleOptions:(r=a.bundle_options)==null?void 0:r.map(c=>({label:c.label,values:c.values.map(p=>({label:p.label,quantity:p.quantity,originalPrice:{value:p.original_price.value,currency:p.original_price.currency},price:{value:p.priceV2.value,currency:p.priceV2.currency}}))})),customizableOptions:(o=a.customizable_options)==null?void 0:o.map(c=>({type:c.type,label:c.label,values:c.values.map(p=>({label:p.label,value:p.value}))}))}}))||[]}function N(e){return e.every(n=>!n.outOfStock&&!n.insufficientQuantity)}function k(e){var t,i,l,u,s,_;const n=T(e),a=S(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:n?g.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:D(e),comments:(t=e.comments)==null?void 0:t.map(r=>{const o={uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text};return Array.isArray(r.attachments)&&r.attachments.length>0&&(o.attachments=r.attachments.map(c=>({name:c.name,url:c.url}))),o}),prices:e.prices&&{appliedDiscounts:(i=e.prices.discounts)==null?void 0:i.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label,coupon:r.coupon})),appliedTaxes:(l=e.prices.applied_taxes)==null?void 0:l.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),discount:e.prices.discounts&&e.prices.grand_total&&b(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&&b(e.prices.applied_taxes,e.prices.grand_total.currency)},history:(u=e.history)==null?void 0:u.map(r=>{var o,c,p,f,m,v,y;return{uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},changeType:r.change_type,changes:{commentAdded:((o=r.changes)==null?void 0:o.comment_added)&&{comment:r.changes.comment_added.comment},customChanges:((c=r.changes)==null?void 0:c.custom_changes)&&{new_value:r.changes.custom_changes.new_value,old_value:r.changes.custom_changes.old_value,title:r.changes.custom_changes.title},expiration:((p=r.changes)==null?void 0:p.expiration)&&{newExpiration:r.changes.expiration.new_expiration,oldExpiration:r.changes.expiration.old_expiration},productsRemoved:((f=r.changes)==null?void 0:f.products_removed)&&{productsRemovedFromCatalog:r.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:r.changes.products_removed.products_removed_from_quote||[]},statuses:((m=r.changes)==null?void 0:m.statuses)&&{changes:((v=r.changes.statuses.changes)==null?void 0:v.map(h=>({newStatus:h.new_status,oldStatus:h.old_status})))||[]},total:((y=r.changes)==null?void 0:y.total)&&r.changes.total.new_price&&r.changes.total.old_price&&{newPrice:{value:r.changes.total.new_price.value,currency:r.changes.total.new_price.currency},oldPrice:{value:r.changes.total.old_price.value,currency:r.changes.total.old_price.currency}}}}}),items:a,shippingAddresses:(s=e.shipping_addresses)==null?void 0:s.map(r=>{const o={uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone};return r.region&&(o.region={code:r.region.code,label:r.region.label,regionId:r.region.region_id}),o}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&d.permissions.checkoutQuote&&((_=e.shipping_addresses)==null?void 0:_.length)>0&&N(a),canSendForReview:(n||x.includes(e.status))&&d.permissions.editQuote,canUpdateQuote:(n||x.includes(e.status))&&d.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&d.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:!n&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!d.permissions.editQuote}}function X(e){return e?k(e):null}function T(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(n=>{var a,t;return n.change_type==="UPDATED"&&(((t=(a=n.changes)==null?void 0:a.statuses)==null?void 0:t.changes)??[]).length>0})}function Q(e){const n=T(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:n?g.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 K(e){var t;if(!e)return null;const n={items:((t=e.items)==null?void 0:t.filter(i=>i==null?void 0:i.uid).map(Q))||[],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},a=U(n);return{...n,paginationInfo:a||void 0}}function U(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:n,pageSize:a,totalPages:t}=e.pageInfo,{totalCount:i}=e,l=i>0?(n-1)*a+1:0,u=Math.min(n*a,i);return{currentPage:n,totalCount:i,pageSize:a,startItem:l,endItem:u,totalPages:t,pageSizeOptions:[20,30,50,100,200]}}const j=()=>[20,30,50,100,200];function b(e,n){return e!=null&&e.length?e.reduce((a,t)=>({value:a.value+t.amount.value,currency:t.amount.currency}),{value:0,currency:n}):{value:0,currency:n}}function F(e){var t;if(!e||!((t=e.shipping_addresses)!=null&&t.length))return{};const a=e.shipping_addresses[0].selected_shipping_method;return a?{shippingIncludingTax:a.price_incl_tax&&{value:a.price_incl_tax.value,currency:a.price_incl_tax.currency},shippingExcludingTax:a.price_excl_tax&&{value:a.price_excl_tax.value,currency:a.price_excl_tax.currency}}:{}}export{U as a,K as b,G as c,W as d,V as e,H as f,j as g,z as r,B as s,X as t};
|
|
3
|
+
import{FetchGraphQL as x}from"@dropins/tools/fetch-graphql.js";import{s as p}from"./state.js";var _=(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))(_||{});const{setEndpoint:F,setFetchGraphQlHeader:L,removeFetchGraphQlHeader:M,setFetchGraphQlHeaders:B,fetchGraphQl:G,getConfig:z}=new x().getMethods();function b(e){var a,n,c,i,u,l,s;return{uid:e.uid,createdAt:e.created_at,author:{firstname:e.author.firstname,lastname:e.author.lastname},changeType:e.change_type,changes:{commentAdded:((a=e.changes)==null?void 0:a.comment_added)&&{comment:e.changes.comment_added.comment},customChanges:((n=e.changes)==null?void 0:n.custom_changes)&&{new_value:e.changes.custom_changes.new_value,old_value:e.changes.custom_changes.old_value,title:e.changes.custom_changes.title},expiration:((c=e.changes)==null?void 0:c.expiration)&&{newExpiration:e.changes.expiration.new_expiration,oldExpiration:e.changes.expiration.old_expiration},productsRemoved:((i=e.changes)==null?void 0:i.products_removed)&&{productsRemovedFromCatalog:e.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:e.changes.products_removed.products_removed_from_quote||[]},statuses:((u=e.changes)==null?void 0:u.statuses)&&{changes:((l=e.changes.statuses.changes)==null?void 0:l.map(r=>({newStatus:r==null?void 0:r.new_status,oldStatus:r==null?void 0:r.old_status})))||[]},total:((s=e.changes)==null?void 0:s.total)&&e.changes.total.new_price&&e.changes.total.old_price&&{newPrice:{value:e.changes.total.new_price.value,currency:e.changes.total.new_price.currency},oldPrice:{value:e.changes.total.old_price.value,currency:e.changes.total.old_price.currency}}}}}function h(e){if(e)return e.map(b)}function m(e,a){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>a>=c.quantity)||null}function y(e){var n,c,i,u;const a=p.config;return{src:a!=null&&a.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:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.label:((u=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:u.label)||e.product.thumbnail.label}}function T(e){var a;return((a=e.links)==null?void 0:a.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function I(e){var l,s,r,t;const a=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(l=e.configured_variant)==null?void 0:l.price_tiers:e.product.price_tiers,i=n?(s=e.configured_variant)==null?void 0:s.price_range:e.product.price_range,u=m(c,a);return u?u.discount.amount_off>0:(((t=(r=i==null?void 0:i.maximum_price)==null?void 0:r.discount)==null?void 0:t.amount_off)??0)>0}function D(e){var i,u,l,s,r,t,o,d;const a=e.quantity,n=m(e.product.price_tiers,a);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(s=(l=(u=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:u.maximum_price)==null?void 0:l.discount)==null?void 0:s.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(d=(o=(t=(r=e==null?void 0:e.product)==null?void 0:r.price_range)==null?void 0:t.maximum_price)==null?void 0:o.discount)==null?void 0:d.percent_off}if(c!==0)return Math.round(c)}function E(e){var a,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(a=e.configured_variant)==null?void 0:a.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 P(e){var c,i,u,l,s,r;let a,n;if(a=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((l=(u=e==null?void 0:e.prices)==null?void 0:u.row_total)==null?void 0:l.value),n=(r=(s=e==null?void 0:e.prices)==null?void 0:s.row_total)==null?void 0:r.currency,a!==0)return{value:a,currency:n}}function w(e){var a,n,c,i,u,l,s,r;return{itemType:e.__typename,uid:e.uid,product:{uid:e.product.uid,sku:e.product.sku,name:e.product.name,priceRange:{maximumPrice:{regularPrice:{value:e.product.price_range.maximum_price.regular_price.value,currency:e.product.price_range.maximum_price.regular_price.currency}}}},image:y(e),links:T(e),discounted:I(e),discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},catalogDiscount:{amountOff:e.prices.catalog_discount.amount_off,percentOff:e.prices.catalog_discount.percent_off},discounts:((n=(a=e.prices)==null?void 0:a.discounts)==null?void 0:n.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:D(e),insufficientQuantity:(e.__typename==="ConfigurableCartItem"?((c=e.configured_variant)==null?void 0:c.stock_status)??e.product.stock_status:e.product.stock_status)==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockStatus:e.product.stock_status,quantity:e.quantity,prices:{regularPrice:E(e),priceIncludingTax:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},originalItemPrice:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency},originalRowTotal:{value:e.prices.original_row_total.value,currency:e.prices.original_row_total.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency}},savingsAmount:P(e),noteFromBuyer:(i=e.note_from_buyer)==null?void 0:i.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(u=e.note_from_seller)==null?void 0:u.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(l=e.configurable_options)==null?void 0:l.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(s=e.bundle_options)==null?void 0:s.map(t=>({label:t.label,values:t.values.map(o=>({label:o.label,quantity:o.quantity,originalPrice:{value:o.original_price.value,currency:o.original_price.currency},price:{value:o.priceV2.value,currency:o.priceV2.currency}}))})),customizableOptions:(r=e.customizable_options)==null?void 0:r.map(t=>({type:t.type,label:t.label,values:t.values.map(o=>({label:o.label,value:o.value}))}))}}function C(e){return e?e.map(w):[]}const g=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function A(e){if(!e.items)return 0;const a=p.config;return(a==null?void 0:a.quoteSummaryDisplayTotal)===0?e.items.length:(a==null?void 0:a.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function O(e){return e.every(a=>!a.outOfStock&&!a.insufficientQuantity)}function R(e){var c,i,u,l,s;const a=v(e),n=C(e.items);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:a?_.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:A(e),comments:(c=e.comments)==null?void 0:c.map(r=>{const t={uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text};return Array.isArray(r.attachments)&&r.attachments.length>0&&(t.attachments=r.attachments.map(o=>({name:o.name,url:o.url}))),t}),prices:e.prices&&{appliedDiscounts:(i=e.prices.discounts)==null?void 0:i.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label,coupon:r.coupon})),appliedTaxes:(u=e.prices.applied_taxes)==null?void 0:u.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),discount:e.prices.discounts&&e.prices.grand_total&&f(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},...k(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&f(e.prices.applied_taxes,e.prices.grand_total.currency)},history:h(e.history),items:n,shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(r=>{const t={uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone};return r.region&&(t.region={code:r.region.code,label:r.region.label,regionId:r.region.region_id}),t}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&p.permissions.checkoutQuote&&((s=e.shipping_addresses)==null?void 0:s.length)>0&&O(n),canSendForReview:(a||g.includes(e.status))&&p.permissions.editQuote,canUpdateQuote:(a||g.includes(e.status))&&p.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&p.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:!a&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!p.permissions.editQuote}}function H(e){return e?R(e):null}function v(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(a=>{var n,c;return a.change_type==="UPDATED"&&(((c=(n=a.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function S(e){const a=v(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:a?_.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 W(e){var c;if(!e)return null;const a={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(S))||[],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=N(a);return{...a,paginationInfo:n||void 0}}function N(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:a,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,u=i>0?(a-1)*n+1:0,l=Math.min(a*n,i);return{currentPage:a,totalCount:i,pageSize:n,startItem:u,endItem:l,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const V=()=>[20,30,50,100,200];function f(e,a){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:a}):{value:0,currency:a}}function k(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{C as a,h as b,N as c,W as d,L as e,G as f,V as g,B as h,z as i,M as r,F as s,H 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 NegotiableQuoteCartItem,\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\nfunction transformQuoteItems(quote: any): NegotiableQuoteCartItem[] {\n return (\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: 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?.stock_status ?? item.product.stock_status\n : item.product.stock_status\n ) === '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 );\n}\n\nfunction checkAllItemsHaveStock(items: NegotiableQuoteCartItem[]): boolean {\n return items.every((item) => !item.outOfStock && !item.insufficientQuantity);\n}\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n const isQuoteNew = isNewQuote(quote);\n const quoteItems = transformQuoteItems(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: quoteItems,\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'].includes(quote.status) &&\n state.permissions.checkoutQuote &&\n quote.shipping_addresses?.length > 0 &&\n checkAllItemsHaveStock(quoteItems),\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","transformQuoteItems","discount","note","option","value","checkAllItemsHaveStock","items","transformSingleQuote","isQuoteNew","isNewQuote","quoteItems","comment","baseComment","tax","calculateTotal","transformShippingPrices","history","change","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,MACN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B,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-history.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote-items.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: CartItemModel[];\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 CartItemModel {\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 { NegotiableQuoteHistoryEntry, NegotiableQuoteHistoryEntryChangeType } from '../models/negotiable-quote-model';\n\n/**\n * Transforms a history entry from the API format to the model format\n * @param historyEntry - Raw history entry from API\n * @returns Transformed history entry\n */\nexport function transformHistoryEntry(\n historyEntry: any\n): NegotiableQuoteHistoryEntry {\n return {\n uid: historyEntry.uid,\n createdAt: historyEntry.created_at,\n author: {\n firstname: historyEntry.author.firstname,\n lastname: historyEntry.author.lastname,\n },\n changeType: historyEntry.change_type as NegotiableQuoteHistoryEntryChangeType,\n changes: {\n commentAdded: historyEntry.changes?.comment_added && {\n comment: historyEntry.changes.comment_added.comment,\n },\n customChanges: historyEntry.changes?.custom_changes && {\n new_value: historyEntry.changes.custom_changes.new_value,\n old_value: historyEntry.changes.custom_changes.old_value,\n title: historyEntry.changes.custom_changes.title,\n },\n expiration: historyEntry.changes?.expiration && {\n newExpiration: historyEntry.changes.expiration.new_expiration,\n oldExpiration: historyEntry.changes.expiration.old_expiration,\n },\n productsRemoved: historyEntry.changes?.products_removed && {\n productsRemovedFromCatalog:\n historyEntry.changes.products_removed.products_removed_from_catalog ||\n [],\n productsRemovedFromQuote:\n historyEntry.changes.products_removed.products_removed_from_quote ||\n [],\n },\n statuses: historyEntry.changes?.statuses && {\n changes:\n historyEntry.changes.statuses.changes?.map((change: any) => ({\n newStatus: change?.new_status,\n oldStatus: change?.old_status,\n })) || [],\n },\n total:\n historyEntry.changes?.total &&\n historyEntry.changes.total.new_price &&\n historyEntry.changes.total.old_price && {\n newPrice: {\n value: historyEntry.changes.total.new_price.value,\n currency: historyEntry.changes.total.new_price.currency,\n },\n oldPrice: {\n value: historyEntry.changes.total.old_price.value,\n currency: historyEntry.changes.total.old_price.currency,\n },\n },\n },\n };\n}\n\n/**\n * Transforms an array of history entries from the API format to the model format\n * @param historyEntries - Array of raw history entries from API\n * @returns Array of transformed history entries\n */\nexport function transformHistory(\n historyEntries: any[] | null | undefined\n): NegotiableQuoteHistoryEntry[] | undefined {\n if (!historyEntries) {\n return undefined;\n }\n\n return historyEntries.map(transformHistoryEntry);\n}\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { CartItemModel } from '../models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\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/**\n * Helper function to get the image for a cart item component\n * @param item - Cart item from API\n * @returns Image object with src and alt\n */\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/**\n * Helper function to get downloadable links for a cart item component\n * @param item - Cart item from API\n * @returns Links object with count and result, or null if no links\n */\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 * Helper function to check if an item is discounted\n * @param item - Cart item from API\n * @returns True if the item has a discount\n */\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) > 0;\n}\n\n/**\n * Helper function to get the discount percentage of an item\n * @param item - Cart item from API\n * @returns Discount percentage rounded to nearest integer, or undefined if no discount\n */\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/**\n * Helper function to get the regular price of an item\n * @param item - Cart item from API\n * @returns Regular price object with value and currency\n */\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/**\n * Helper function to get the savings amount of an item\n * @param item - Cart item from API\n * @returns Savings amount object with value and currency, or undefined if no savings\n */\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/**\n * Transforms a single quote item from the API format to the model format\n * @param item - Raw quote item from API\n * @returns Transformed quote item\n */\nexport function transformQuoteItem(item: any): CartItemModel {\n return {\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?.stock_status ?? item.product.stock_status\n : item.product.stock_status\n ) === '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}\n\n/**\n * Transforms an array of quote items from the API format to the model format\n * @param items - Array of raw quote items from API\n * @returns Array of transformed quote items\n */\nexport function transformQuoteItems(\n items: any[] | null | undefined\n): CartItemModel[] {\n if (!items) {\n return [];\n }\n\n return items.map(transformQuoteItem);\n}\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n CartItemModel,\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';\nimport { transformHistory } from './transform-history';\nimport { transformQuoteItems } from './transform-quote-items';\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\nfunction checkAllItemsHaveStock(items: CartItemModel[]): boolean {\n return items.every((item) => !item.outOfStock && !item.insufficientQuantity);\n}\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n const isQuoteNew = isNewQuote(quote);\n const quoteItems = transformQuoteItems(quote.items);\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: transformHistory(quote.history),\n items: quoteItems,\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'].includes(quote.status) &&\n state.permissions.checkoutQuote &&\n quote.shipping_addresses?.length > 0 &&\n checkAllItemsHaveStock(quoteItems),\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","transformHistoryEntry","historyEntry","_a","_b","_c","_d","_e","_f","change","_g","transformHistory","historyEntries","findApplicablePriceTier","priceTiers","quantity","a","b","tier","getImage","item","config","state","getLinks","link","getDiscounted","isConfigurable","priceRange","applicableTier","getDiscountPercentage","percent_off","_h","getRegularPrice","getSavingsAmount","amount_off","currency","transformQuoteItem","discount","note","option","value","transformQuoteItems","items","EDITABLE_QUOTE_STATUSES","getTotalQuantity","quote","checkAllItemsHaveStock","transformSingleQuote","isQuoteNew","isNewQuote","quoteItems","comment","baseComment","tax","calculateTotal","transformShippingPrices","address","shippingAddress","transformQuote","quoteData","history","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,E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AA,CAClD,EAXO,CAAA,CAaX"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FunctionComponent, VNode } from 'preact';
|
|
2
2
|
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
-
import {
|
|
3
|
+
import { CartItemModel } from '../../data/models/negotiable-quote-model';
|
|
4
4
|
|
|
5
5
|
export interface LineItemNoteModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
6
6
|
open: boolean;
|
|
7
|
-
item:
|
|
7
|
+
item: CartItemModel;
|
|
8
8
|
onClose?: () => void;
|
|
9
9
|
onConfirm: (note: string, quantity: number) => void;
|
|
10
10
|
isSubmitting?: boolean;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
2
|
import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
|
|
3
|
-
import { NegotiableQuoteModel,
|
|
3
|
+
import { NegotiableQuoteModel, CartItemModel } from '../../data/models/negotiable-quote-model';
|
|
4
4
|
|
|
5
5
|
export interface ItemsQuotedProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
quoteData?: NegotiableQuoteModel;
|
|
7
|
-
onItemCheckboxChange?: (item:
|
|
8
|
-
onItemDropdownChange?: (item:
|
|
7
|
+
onItemCheckboxChange?: (item: CartItemModel, isSelected: boolean) => void;
|
|
8
|
+
onItemDropdownChange?: (item: CartItemModel, action: string) => void;
|
|
9
9
|
onUpdate?: (e: SubmitEvent) => void;
|
|
10
|
-
onRemoveItemsRef?: (handler: (items:
|
|
10
|
+
onRemoveItemsRef?: (handler: (items: CartItemModel[]) => void) => void;
|
|
11
11
|
onRemoveModalStateChange?: (isOpen: boolean) => void;
|
|
12
12
|
slots?: {
|
|
13
13
|
ProductListTable?: SlotProps<{
|
|
14
14
|
items: NegotiableQuoteModel['items'];
|
|
15
15
|
canEdit: boolean;
|
|
16
16
|
readOnly?: boolean;
|
|
17
|
-
onItemCheckboxChange?: (item:
|
|
18
|
-
onItemDropdownChange?: (item:
|
|
19
|
-
onQuantityChange?: (item:
|
|
17
|
+
onItemCheckboxChange?: (item: CartItemModel, isSelected: boolean) => void;
|
|
18
|
+
onItemDropdownChange?: (item: CartItemModel, action: string) => void;
|
|
19
|
+
onQuantityChange?: (item: CartItemModel, newQuantity: number) => void;
|
|
20
20
|
onUpdate?: (e: SubmitEvent) => void;
|
|
21
21
|
dropdownSelections?: Record<string, string | undefined>;
|
|
22
22
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as p,Fragment as la}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useRef as ye,useEffect as q,useCallback as c,useMemo as f,createPortal as W}from"@dropins/tools/preact-compat.js";import{classes as u,VComponent as M,Slot as g}from"@dropins/tools/lib.js";import{f as ca}from"../chunks/dateUtils.js";/* empty css */import{Skeleton as ja,SkeletonRow as z,InLineAlert as h,Button as sa,TextArea as Ga,InputFile as Ka}from"@dropins/tools/components.js";import{events as T}from"@dropins/tools/event-bus.js";import{S as Xa,A as Ja,T as Ya,R as Za}from"../chunks/RenameQuoteModal.js";import{v as Aa,f as et,a as at,S as tt,A as nt}from"../chunks/AttachedFilesList.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{C as K}from"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import{S as ot}from"../chunks/ShippingAddressDisplay.js";import{Q as it}from"../chunks/QuoteHistoryLog3.js";import{g as rt,r as lt,c as ct,a as st,s as mt,d as dt,b as ut}from"../chunks/duplicateNegotiableQuote.js";import"../chunks/state.js";import{u as gt}from"../chunks/uploadFile.js";import{I as ft}from"../chunks/ItemsQuoted.js";import{Q as pt}from"../chunks/QuoteCommentsList3.js";import{a as w,S as X}from"../chunks/WarningFilled.js";import{useText as Mt}from"@dropins/tools/i18n.js";import"../chunks/QuoteHistoryLog.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/transform-quote-template.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/LineItemNoteModal.js";import"../chunks/setLineItemNote.js";import"../chunks/QuoteCommentsList.js";const bt=({className:x,loading:t,quoteName:m,quoteStatus:R,banner:y,details:_,actionBar:N,quoteContent:L,shippingInformationTitle:J,shippingInformation:e,quoteCommentsTitle:S,quoteComments:E,attachFilesField:k,attachedFilesList:P,footer:Y,...Z})=>t?n(ht,{}):p("div",{...Z,className:u(["quote-management-manage-negotiable-quote",x]),children:[p("div",{className:u(["quote-management-manage-negotiable-quote__header"]),children:[m&&n(M,{node:m,className:u(["quote-management-manage-negotiable-quote__quote-name"])}),R&&n(M,{node:R,className:u(["quote-management-manage-negotiable-quote__quote-status"])})]}),y&&n(M,{node:y,className:u(["quote-management-manage-negotiable-quote__banner"])}),_&&n(M,{node:_,className:u(["quote-management-manage-negotiable-quote__details"])}),N&&n(M,{node:N,className:u(["quote-management-manage-negotiable-quote__action-bar"])}),L&&n(M,{node:L,className:u(["quote-management-manage-negotiable-quote__quote-content"])}),p("div",{"data-testid":"quote-shipping-information-container",className:u(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[J&&n(M,{node:J,className:u(["quote-management-manage-negotiable-quote__shipping-information-title"])}),e&&n(M,{node:e,className:u(["quote-management-manage-negotiable-quote__shipping-information"])})]}),p("div",{"data-testid":"quote-comments-container",className:u(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[S&&n(M,{node:S,className:u(["quote-management-manage-negotiable-quote__quote-comments-title"])}),E&&n(M,{node:E,className:u(["quote-management-manage-negotiable-quote__quote-comments"])}),k&&n(M,{node:k,className:u(["quote-management-manage-negotiable-quote__attach-files-field"])}),P&&n(M,{node:P,className:u(["quote-management-manage-negotiable-quote__attached-files-list"])})]}),n(M,{node:Y,className:u(["quote-management-manage-negotiable-quote__footer"])})]}),ht=()=>p(ja,{"data-testid":"manage-negotiable-quote-skeleton",children:[n(z,{variant:"heading",fullWidth:!0,size:"large"}),n(z,{variant:"row",fullWidth:!1,size:"small"}),n(z,{variant:"row",fullWidth:!1,size:"small"}),n(z,{variant:"row",fullWidth:!0}),n(z,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),n(z,{variant:"row",fullWidth:!1,size:"small"})]}),en=({onActionsDropdownChange:x,slots:t,onActionsButtonClick:m,onSendForReview:R,maxFiles:y,maxFileSize:_,acceptedFileTypes:N,onDuplicateQuote:L,...J})=>{const[e,S]=l(void 0),[E,k]=l(!0),[P,Y]=l(!1),[Z,$]=l(null),[ma,A]=l(!1),[_e,se]=l(!1),[Ee,D]=l(null),[da,H]=l(!1),[De,Fe]=l(!1),[F,Ie]=l(""),[Q,me]=l(!1),[we,de]=l(!1),[xe,ue]=l(!1),[Re,O]=l(""),[Le,V]=l(""),[ke,He]=l(!1),[Oe,Ue]=l(!1),[Be,ee]=l(""),[We,ae]=l(""),[ze,ge]=l(!1),[te,ne]=l(""),[fe,oe]=l(""),[pe,j]=l(""),[ua,U]=l(""),[Me,ie]=l(""),[b,G]=l([]),[re,le]=l(void 0),[be,Pe]=l(new Set),$e=ye(be),he=ye(null),[B,Ne]=l(""),ce=ye(B),[Ve,je]=l(!1);q(()=>{$e.current=be},[be]),q(()=>{ce.current=B},[B]);const o=Mt({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired",errorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",closeSuccessMessage:"NegotiableQuote.Manage.confirmationModal.close.successDescription",closeModalTitle:"NegotiableQuote.Manage.actionButtons.close",closeModalMessage:"NegotiableQuote.Manage.confirmationModal.close.message",closeModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",closeModalConfirm:"NegotiableQuote.Manage.confirmationModal.close.confirm",closeModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.close.confirmLoading",closeModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.close.successHeading",createTemplateModalTitle:"NegotiableQuote.Manage.actionButtons.createTemplate",createTemplateModalMessage:"NegotiableQuote.Manage.confirmationModal.createTemplate.message",createTemplateModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",createTemplateModalConfirm:"NegotiableQuote.Manage.confirmationModal.createTemplate.confirm",createTemplateModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.createTemplate.confirmLoading",createTemplateModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.createTemplate.successHeading",createTemplateSuccessMessage:"NegotiableQuote.Manage.confirmationModal.createTemplate.successDescription",createTemplateModalErrorHeading:"NegotiableQuote.Manage.confirmationModal.createTemplate.errorHeading",createTemplateErrorFallback:"NegotiableQuote.Manage.confirmationModal.createTemplate.errorFallback",renameErrorHeading:"NegotiableQuote.Manage.rename.errorHeading",renameQuoteNameRequired:"NegotiableQuote.Manage.rename.quoteNameRequired",renameErrorDefault:"NegotiableQuote.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuote.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuote.Manage.rename.successMessage",confirmationModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",confirmationModalDeleteTitle:"NegotiableQuote.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuote.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuote.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuote.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription",confirmationModalDuplicateTitle:"NegotiableQuote.Manage.confirmationModal.duplicate.title",confirmationModalDuplicateMessage:"NegotiableQuote.Manage.confirmationModal.duplicate.message",confirmationModalDuplicateConfirm:"NegotiableQuote.Manage.confirmationModal.duplicate.confirm",confirmationModalDuplicateErrorHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.errorHeading",confirmationModalDuplicateErrorFallback:"NegotiableQuote.Manage.confirmationModal.duplicate.errorFallback",confirmationModalDuplicateSuccessHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.successHeading",confirmationModalDuplicateSuccessDescription:"NegotiableQuote.Manage.confirmationModal.duplicate.successDescription",duplicateOutOfStockWarningHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.outOfStockWarningHeading",duplicateOutOfStockWarningMessage:"NegotiableQuote.Manage.confirmationModal.duplicate.outOfStockWarningMessage",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm",attachFiles:"NegotiableQuote.Manage.attachFiles",fileUploadError:"NegotiableQuote.Manage.fileUploadError",maxFilesExceeded:"NegotiableQuote.Manage.maxFilesExceeded",maxFileSizeExceeded:"NegotiableQuote.Manage.maxFileSizeExceeded",invalidFileType:"NegotiableQuote.Manage.invalidFileType"});q(()=>{const a=T.on("quote-management/quote-data",i=>{const{quote:r}=i;if(r){S(r),k(!1);const s=`duplicate-outOfStock-warning-${r.uid}`;sessionStorage.getItem(s)==="true"&&(Fe(!0),sessionStorage.removeItem(s))}},{eager:!0});return()=>a==null?void 0:a.off()},[]),q(()=>{const a=T.on("quote-management/shipping-address-set",i=>{const{quote:r}=i;r&&S(r)},{eager:!0});return()=>a==null?void 0:a.off()},[]),q(()=>{const a=T.on("quote-management/quote-sent-for-review",i=>{const{quote:r}=i;S(r),Ie(""),G([]),me(!1)},{eager:!0});return()=>a==null?void 0:a.off()},[]),q(()=>{const a=T.on("quote-management/quote-items-removed",i=>{const{quote:r,removedItemUids:s}=i;r&&S(r),s&&Pe(d=>{const v=new Set(d);return s.forEach(I=>v.delete(I)),v})},{eager:!0});return()=>a==null?void 0:a.off()},[]);const Ge=c((a,i)=>{Pe(r=>{const s=new Set(r);return i?s.add(a.uid):s.delete(a.uid),s})},[]),Ke=c(a=>{const i=a.target.value,r=$e.current;if(i==="remove"){if(Ne(i),ce.current=i,r.size===0)je(!0);else if(e&&he.current){const s=e.items.filter(d=>r.has(d.uid));he.current(s)}}x==null||x(a)},[x,e]),Xe=c(()=>{je(!1),Ne(""),ce.current=""},[]);q(()=>{const a=T.on("quote-management/negotiable-quote-closed",async i=>{ue(!1),V(""),O(o.closeSuccessMessage),S(r=>{var s;return r!=null&&r.uid&&((s=i.closedQuoteUids)!=null&&s.includes(r.uid))&&rt(r.uid).then(d=>{S(d)}).catch(d=>{console.warn("Failed to refresh quote data after closure:",d)}),r}),setTimeout(()=>{de(!1),O("")},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[o.closeSuccessMessage]),q(()=>{const a=T.on("quote-management/negotiable-quote-close-error",i=>{console.log("Close error event received:",i),ue(!1),O("");const r=i.error.message||o.errorFallback;V(r)},{eager:!0});return()=>a==null?void 0:a.off()},[o.errorFallback]),q(()=>{const a=T.on("quote-management/quote-renamed",i=>{const{quote:r}=i;S(r),j(""),U(""),ie(o.renameSuccessMessage),setTimeout(()=>{ge(!1),ne(""),oe(""),ie("")},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[o.renameSuccessMessage]),q(()=>{const a=T.on("quote-management/quote-duplicated",i=>{const{quote:r}=i;e&&L&&L({quoteData:e,newQuote:r}),H(!0),D(null),setTimeout(()=>{se(!1),H(!1),D(null)},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[e,L]);const Se=c(async a=>{if(y&&b.length+a.length>y){le(o.maxFilesExceeded.replace("{maxFiles}",String(y)));return}for(const r of a){if(_&&!Aa(r.size,_)){le(o.maxFileSizeExceeded.replace("{maxSize}",et(_)));return}if(N&&!at(r.type,N)){le(o.invalidFileType);return}}le(void 0);const i=a.map(r=>({key:`temp-${Date.now()}-${Math.random()}-${r.name}`,name:r.name,size:r.size,status:"uploading"}));G(r=>[...r,...i]);for(let r=0;r<a.length;r++){const s=a[r],d=i[r].key;try{const v=await gt(s);G(I=>I.map(C=>C.key===d?{...C,key:v.key,status:"success"}:C))}catch(v){G(I=>I.map(C=>C.key===d?{...C,status:"error",error:v.message}:C))}}},[y,_,N,b,o]),Qe=c(a=>{G(i=>i.filter(r=>r.key!==a))},[]),Je=c(()=>{ne((e==null?void 0:e.name)||""),oe(""),j(""),U(""),ie(""),ge(!0)},[e]),ga=c(()=>{ge(!1),ne(""),oe(""),j(""),U(""),ie("")},[]),fa=c(a=>{ne(a),a.trim()&&U("")},[]),Ye=c(()=>{se(!0),D(null),H(!1)},[]),pa=c(async()=>{if(!te.trim()){U(o.renameQuoteNameRequired);return}try{j(""),U(""),await lt({quoteUid:e.uid,quoteName:te,quoteComment:fe.trim()||void 0})}catch(a){j(a.message||o.renameErrorDefault)}},[e,te,fe,o.renameQuoteNameRequired,o.renameErrorDefault]),Ma=f(()=>{const a=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return n(g,{name:"QuoteName",slot:t==null?void 0:t.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:p("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[n("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),n("button",{onClick:Je,disabled:a,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:n(Xa,{})})]})})},[t==null?void 0:t.QuoteName,e,Je]),ba=f(()=>n(g,{name:"QuoteStatus",slot:t==null?void 0:t.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:n("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[t==null?void 0:t.QuoteStatus,e]),Ze=c(a=>{switch(a){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),Ae=Ze&&n(h,{type:"warning",variant:"secondary",icon:n(w,{}),heading:o.bannerTitle,description:Ze}),ea=Ae&&n(g,{name:"Banner","data-testid":"banner",slot:t==null?void 0:t.Banner,context:{quoteData:e},children:Ae}),ha=c(()=>{Fe(!1)},[]),aa=De&&n(g,{name:"DuplicateQuoteWarningBanner","data-testid":"duplicate-outOfStock-warning-banner",slot:t==null?void 0:t.DuplicateQuoteWarningBanner,context:{outOfStockWarning:De},children:n(h,{type:"warning",variant:"primary",icon:n(w,{}),heading:o.duplicateOutOfStockWarningHeading,description:o.duplicateOutOfStockWarningMessage,onDismiss:ha,"data-testid":"duplicate-outOfStock-warning-alert"})}),Na=f(()=>{if(!e)return;const a=e.expirationDate?ca(e.expirationDate,"short"):void 0;return p(g,{name:"Details",slot:t==null?void 0:t.Details,context:{quoteData:e},children:[p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),p("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[ca(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),n("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),n("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:a})]})]})},[t==null?void 0:t.Details,o,e]),ta=f(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate"},{label:o.createCopy,value:"createCopy"}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose]),Sa=f(()=>{const a=i=>{switch(i){case"close":de(!0),V(""),O(""),m==null||m(i);break;case"delete":Y(!0),m==null||m(i);break;case"print":m==null||m(i);break;case"createTemplate":He(!0),ae(""),ee(""),m==null||m(i);break;case"createCopy":Ye(),m==null||m(i);break}};return n(g,{name:"ActionBar",slot:t==null?void 0:t.ActionBar,context:{quoteData:e,actionsBarDropdownValue:B},children:n(Ja,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:B,handleDropdownChange:Ke,buttons:ta.map(i=>n(sa,{variant:"tertiary",onClick:()=>a(i.value),"data-testid":`actions-bar-${i.value}-button`,"data-action":i.value,disabled:i.disabled,children:i.label},i.value))})})},[ta,o,t==null?void 0:t.ActionBar,e,Ke,m,Ye,B]),Qa=f(()=>n(g,{name:"QuoteContent",slot:t==null?void 0:t.QuoteContent,context:{quoteData:e},children:n(Ya,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",n(g,{name:"ItemsQuotedTab",slot:t==null?void 0:t.ItemsQuotedTab,context:{quoteData:e},children:n(ft,{quoteData:e,onItemCheckboxChange:Ge,onRemoveItemsRef:a=>{he.current=a},onRemoveModalStateChange:a=>{!a&&ce.current==="remove"&&Ne("")}})},"items-quoted")],["comments",n(g,{name:"CommentsTab",slot:t==null?void 0:t.CommentsTab,context:{quoteData:e},children:n(pt,{quoteData:e})},"comments")],["history-log",n(g,{name:"HistoryLogTab",slot:t==null?void 0:t.HistoryLogTab,context:{quoteData:e},children:n(it,{quoteData:e})},"history-log")]])})}),[t==null?void 0:t.QuoteContent,t==null?void 0:t.HistoryLogTab,t==null?void 0:t.CommentsTab,t==null?void 0:t.ItemsQuotedTab,e,Ge]),va=f(()=>n(g,{name:"ShippingInformationTitle",slot:t==null?void 0:t.ShippingInformationTitle,context:{quoteData:e},children:n("h2",{children:o.shippingInformationTitle})}),[t==null?void 0:t.ShippingInformationTitle,e,o]),qa=f(()=>{var a;return n(g,{name:"ShippingInformation",slot:t==null?void 0:t.ShippingInformation,context:{quoteData:e,loading:E,setLoading:k},children:n(ot,{shippingAddress:(a=e==null?void 0:e.shippingAddresses)==null?void 0:a[0],loading:E,"data-testid":"manage-quote-shipping-address"})})},[t==null?void 0:t.ShippingInformation,e,E,k]),Ca=f(()=>n(g,{name:"QuoteCommentsTitle",slot:t==null?void 0:t.QuoteCommentsTitle,context:{quoteData:e},children:n("h2",{children:o.quoteCommentsTitle})}),[t==null?void 0:t.QuoteCommentsTitle,o,e]),Ta=f(()=>n(g,{name:"QuoteComments",slot:t==null?void 0:t.QuoteComments,context:{quoteData:e},children:n(Ga,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:F,onInput:a=>{Ie(a.target.value)},disabled:!(e!=null&&e.canSendForReview)||Q})}),[t==null?void 0:t.QuoteComments,o,e,F,Q]),na=f(()=>!(e!=null&&e.canSendForReview),[e]),ya=f(()=>{const a=Q||na;return n(g,{name:"AttachFilesField",slot:t==null?void 0:t.AttachFilesField,context:{onFileChange:Se,attachedFiles:b,fileUploadError:re,disabled:a},children:p("div",{className:"quote-management-manage-negotiable-quote__attach-files",...a?{"data-disabled":!0}:{},"aria-disabled":a,children:[n(Ka,{multiple:!0,onChange:i=>{const r=i.target,s=r==null?void 0:r.files,d=s?Array.from(s):[];d.length>0&&Se(d)},icon:n(tt,{}),disabled:a,"data-testid":"manage-quote-attach-files",accept:N==null?void 0:N.join(","),children:o.attachFiles}),re&&n("div",{className:"quote-management-manage-negotiable-quote__file-error","data-testid":"file-upload-error",children:re})]})})},[t==null?void 0:t.AttachFilesField,Se,Q,na,N,re,o,b]),_a=f(()=>{if(b.length)return n(g,{name:"AttachedFilesList",slot:t==null?void 0:t.AttachedFilesList,context:{files:b,onRemove:Qe,disabled:Q},children:n(nt,{files:b,onRemove:Qe,disabled:Q})})},[b,Qe,Q,t==null?void 0:t.AttachedFilesList]),Ea=c(async()=>{if(e!=null&&e.uid){ue(!0),V(""),O("");try{await ct({quoteUids:[e.uid]})}catch(a){console.error("Failed to close quote:",a)}}},[e]),Da=c(()=>{de(!1),V(""),O("")},[]),Fa=c(async()=>{if(e!=null&&e.uid){Ue(!0),ae(""),ee("");try{await st(e.uid),ee(o.createTemplateSuccessMessage)}catch(a){console.error("Failed to create quote template:",a);const i=a instanceof Error?a.message:o.createTemplateErrorFallback;ae(i)}finally{Ue(!1)}}},[e,o.createTemplateSuccessMessage,o.createTemplateErrorFallback]),Ia=c(()=>{He(!1),ae(""),ee("")},[]),ve=c(async()=>{const a=b.filter(i=>i.status==="success");if(R){R({quoteData:e,comment:F.trim()||void 0,attachments:a.length?a:void 0});return}me(!0);try{await mt({quoteUid:e.uid,comment:F.trim()||void 0,attachments:a.length?a.map(i=>({key:i.key})):void 0})}catch(i){console.error("Failed to send quote for review:",i),me(!1)}},[e,R,F,b]),wa=f(()=>n(g,{name:"Footer",slot:t==null?void 0:t.Footer,context:{quoteData:e,comment:F,isSubmitting:Q,attachments:b,handleSendForReview:ve},children:n(sa,{variant:"primary",onClick:ve,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||Q,children:o.sendForReview})}),[t==null?void 0:t.Footer,o,e,F,Q,b,ve]),xa=f(()=>pe?n(h,{type:"error",variant:"primary",icon:n(w,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:pe}):void 0,[pe,o.renameErrorHeading]),Ra=f(()=>Me?n(h,{type:"success",variant:"primary",icon:n(X,{}),heading:o.renameSuccessHeading,description:Me}):void 0,[Me,o.renameSuccessHeading]),qe=c(a=>a.errors&&Array.isArray(a.errors)&&a.errors.length>0?a.errors[0].message||o.confirmationModalDeleteErrorFallback:(a==null?void 0:a.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),La=c(()=>{Y(!1),$(null),A(!1)},[]),ka=c(async()=>{if(e!=null&&e.uid){$(null),A(!1);try{const{operationResults:a}=await dt(e.uid),i=a.find(r=>r.__typename==="DeleteNegotiableQuoteOperationFailure");if(i){const r=qe(i);$(r);return}A(!0)}catch(a){const i=qe(a);$(i)}}},[e,qe]),Ha=c(()=>{$(null)},[]),Oa=c(()=>{A(!1)},[]),oa=c(a=>(a==null?void 0:a.message)||o.confirmationModalDuplicateErrorFallback,[o.confirmationModalDuplicateErrorFallback]),Ua=c(()=>{se(!1),D(null),H(!1)},[]),Ba=c(async()=>{var a;if(e!=null&&e.uid){D(null),H(!1);try{const i=((a=e.items)==null?void 0:a.filter(v=>v.outOfStock))||[],s=(v=>{const I=v.slice(0,-8),C=crypto.randomUUID().slice(0,8);return I+C})(e.uid),d=i.length>0;d&&sessionStorage.setItem(`duplicate-outOfStock-warning-${s}`,"true"),await ut({quoteUid:e.uid,duplicatedQuoteUid:s,hasOutOfStockItems:d})}catch(i){const r=oa(i);D(r)}}},[e,oa]),Wa=c(()=>{D(null)},[]),za=c(()=>{H(!1)},[]),Pa=Z?n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.confirmationModalDeleteErrorHeading,description:Z,onDismiss:Ha,"data-testid":"confirmation-modal-error-banner"}):null,ia=(ma?n(h,{type:"success",variant:"primary",icon:n(X,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:Oa,"data-testid":"confirmation-modal-success-banner"}):null)||Pa,$a=Ee?n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.confirmationModalDuplicateErrorHeading,description:Ee,onDismiss:Wa,"data-testid":"confirmation-modal-duplicate-error-banner"}):null,ra=(da?n(h,{type:"success",variant:"primary",icon:n(X,{}),heading:o.confirmationModalDuplicateSuccessHeading,description:o.confirmationModalDuplicateSuccessDescription,onDismiss:za,"data-testid":"confirmation-modal-duplicate-success-banner"}):null)||$a,Va={...J,loading:E,quoteName:Ma,quoteStatus:ba,banner:aa||ea?p(la,{children:[aa,ea]}):void 0,details:Na,actionBar:Sa,quoteContent:Qa,shippingInformationTitle:va,shippingInformation:qa,quoteCommentsTitle:Ca,quoteComments:Ta,attachFilesField:ya,attachedFilesList:_a,footer:wa};let Ce=null;Re?Ce=n(h,{type:"success",variant:"primary",icon:n(X,{}),heading:o.closeModalSuccessHeading,description:Re,"data-testid":"close-quote-success-banner"}):Le&&(Ce=n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.confirmationModalDeleteErrorHeading,description:Le,"data-testid":"close-quote-error-banner"}));let Te=null;return Be?Te=n(h,{type:"success",variant:"primary",icon:n(X,{}),heading:o.createTemplateModalSuccessHeading,description:Be,"data-testid":"create-template-success-banner"}):We&&(Te=n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.createTemplateModalErrorHeading,description:We,"data-testid":"create-template-error-banner"})),p(la,{children:[n(bt,{...Va}),ze&&W(n(Za,{open:ze,quoteName:te,renameReason:fe,quoteNameError:ua,errorBanner:xa,successBanner:Ra,onQuoteNameChange:fa,onRenameReasonChange:oe,onSave:pa,onClose:ga}),document.body),P&&W(n(K,{open:P,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:La,onConfirm:ka,showCloseButton:!ia,confirmationBanner:ia}),document.body),_e&&W(n(K,{open:_e,title:o.confirmationModalDuplicateTitle,message:o.confirmationModalDuplicateMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDuplicateConfirm,onCancel:Ua,onConfirm:Ba,showCloseButton:!ra,confirmationBanner:ra}),document.body),we&&W(n(K,{open:we,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:xe?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:Da,onConfirm:xe?void 0:Ea,showCloseButton:!0,confirmationBanner:Ce,"data-testid":"close-quote-confirmation-modal"}),document.body),ke&&W(n(K,{open:ke,title:o.createTemplateModalTitle,message:o.createTemplateModalMessage,cancelLabel:o.createTemplateModalCancel,confirmLabel:Oe?o.createTemplateModalConfirmLoading:o.createTemplateModalConfirm,onCancel:Ia,onConfirm:Oe?void 0:Fa,showCloseButton:!0,confirmationBanner:Te,"data-testid":"create-template-confirmation-modal"}),document.body),Ve&&W(n(K,{open:Ve,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:Xe,onClose:Xe,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{en as ManageNegotiableQuote,en as default};
|
|
3
|
+
import{jsx as n,jsxs as p,Fragment as la}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useRef as _e,useEffect as v,useCallback as c,useMemo as f,createPortal as W}from"@dropins/tools/preact-compat.js";import{classes as u,VComponent as M,Slot as g}from"@dropins/tools/lib.js";import{f as ca}from"../chunks/dateUtils.js";/* empty css */import{Skeleton as ja,SkeletonRow as z,InLineAlert as h,Button as sa,TextArea as Ga,InputFile as Ka}from"@dropins/tools/components.js";import{events as C}from"@dropins/tools/event-bus.js";import{S as Xa,A as Ja,T as Ya,R as Za}from"../chunks/RenameQuoteModal.js";import{v as Aa,f as et,a as at,S as tt,A as nt}from"../chunks/AttachedFilesList.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import{C as X}from"../chunks/ConfirmationModal.js";/* empty css *//* empty css */import{S as ot}from"../chunks/ShippingAddressDisplay.js";import{Q as it}from"../chunks/QuoteHistoryLog3.js";import{g as rt,r as lt,c as ct,a as st,s as mt,d as dt,b as ut}from"../chunks/duplicateNegotiableQuote.js";import"../chunks/state.js";import{u as gt}from"../chunks/uploadFile.js";import{I as ft}from"../chunks/ItemsQuoted.js";import{Q as pt}from"../chunks/QuoteCommentsList3.js";import{a as w,S as J}from"../chunks/WarningFilled.js";import{useText as Mt}from"@dropins/tools/i18n.js";import"../chunks/QuoteHistoryLog.js";import"../chunks/transform-quote.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";import"../chunks/transform-quote-template.js";import"../chunks/NegotiableQuoteTemplateFragment.js";import"../chunks/LineItemNoteModal.js";import"../chunks/setLineItemNote.js";import"../chunks/QuoteCommentsList.js";const bt=({className:x,loading:t,quoteName:m,quoteStatus:R,banner:y,details:_,actionBar:N,quoteContent:L,shippingInformationTitle:Y,shippingInformation:e,quoteCommentsTitle:S,quoteComments:E,attachFilesField:k,attachedFilesList:P,footer:Z,...A})=>t?n(ht,{}):p("div",{...A,className:u(["quote-management-manage-negotiable-quote",x]),children:[p("div",{className:u(["quote-management-manage-negotiable-quote__header"]),children:[m&&n(M,{node:m,className:u(["quote-management-manage-negotiable-quote__quote-name"])}),R&&n(M,{node:R,className:u(["quote-management-manage-negotiable-quote__quote-status"])})]}),y&&n(M,{node:y,className:u(["quote-management-manage-negotiable-quote__banner"])}),_&&n(M,{node:_,className:u(["quote-management-manage-negotiable-quote__details"])}),N&&n(M,{node:N,className:u(["quote-management-manage-negotiable-quote__action-bar"])}),L&&n(M,{node:L,className:u(["quote-management-manage-negotiable-quote__quote-content"])}),p("div",{"data-testid":"quote-shipping-information-container",className:u(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[Y&&n(M,{node:Y,className:u(["quote-management-manage-negotiable-quote__shipping-information-title"])}),e&&n(M,{node:e,className:u(["quote-management-manage-negotiable-quote__shipping-information"])})]}),p("div",{"data-testid":"quote-comments-container",className:u(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[S&&n(M,{node:S,className:u(["quote-management-manage-negotiable-quote__quote-comments-title"])}),E&&n(M,{node:E,className:u(["quote-management-manage-negotiable-quote__quote-comments"])}),k&&n(M,{node:k,className:u(["quote-management-manage-negotiable-quote__attach-files-field"])}),P&&n(M,{node:P,className:u(["quote-management-manage-negotiable-quote__attached-files-list"])})]}),n(M,{node:Z,className:u(["quote-management-manage-negotiable-quote__footer"])})]}),ht=()=>p(ja,{"data-testid":"manage-negotiable-quote-skeleton",children:[n(z,{variant:"heading",fullWidth:!0,size:"large"}),n(z,{variant:"row",fullWidth:!1,size:"small"}),n(z,{variant:"row",fullWidth:!1,size:"small"}),n(z,{variant:"row",fullWidth:!0}),n(z,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),n(z,{variant:"row",fullWidth:!1,size:"small"})]}),en=({onActionsDropdownChange:x,slots:t,onActionsButtonClick:m,onSendForReview:R,maxFiles:y,maxFileSize:_,acceptedFileTypes:N,onDuplicateQuote:L,...Y})=>{const[e,S]=l(void 0),[E,k]=l(!0),[P,Z]=l(!1),[A,$]=l(null),[ma,ee]=l(!1),[Ee,se]=l(!1),[De,D]=l(null),[da,H]=l(!1),[Fe,Ie]=l(!1),[F,we]=l(""),[Q,me]=l(!1),[xe,de]=l(!1),[Re,ue]=l(!1),[Le,O]=l(""),[ke,V]=l(""),[He,ge]=l(!1),[Oe,Ue]=l(!1),[Be,j]=l(""),[We,ae]=l(""),[ze,fe]=l(!1),[te,ne]=l(""),[pe,oe]=l(""),[Me,G]=l(""),[ua,U]=l(""),[be,ie]=l(""),[b,K]=l([]),[re,le]=l(void 0),[he,Pe]=l(new Set),$e=_e(he),Ne=_e(null),[B,Se]=l(""),ce=_e(B),[Ve,je]=l(!1);v(()=>{$e.current=he},[he]),v(()=>{ce.current=B},[B]);const o=Mt({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired",errorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",closeSuccessMessage:"NegotiableQuote.Manage.confirmationModal.close.successDescription",closeModalTitle:"NegotiableQuote.Manage.actionButtons.close",closeModalMessage:"NegotiableQuote.Manage.confirmationModal.close.message",closeModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",closeModalConfirm:"NegotiableQuote.Manage.confirmationModal.close.confirm",closeModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.close.confirmLoading",closeModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.close.successHeading",createTemplateModalTitle:"NegotiableQuote.Manage.actionButtons.createTemplate",createTemplateModalMessage:"NegotiableQuote.Manage.confirmationModal.createTemplate.message",createTemplateModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",createTemplateModalConfirm:"NegotiableQuote.Manage.confirmationModal.createTemplate.confirm",createTemplateModalConfirmLoading:"NegotiableQuote.Manage.confirmationModal.createTemplate.confirmLoading",createTemplateModalSuccessHeading:"NegotiableQuote.Manage.confirmationModal.createTemplate.successHeading",createTemplateSuccessMessage:"NegotiableQuote.Manage.confirmationModal.createTemplate.successDescription",createTemplateModalErrorHeading:"NegotiableQuote.Manage.confirmationModal.createTemplate.errorHeading",createTemplateErrorFallback:"NegotiableQuote.Manage.confirmationModal.createTemplate.errorFallback",renameErrorHeading:"NegotiableQuote.Manage.rename.errorHeading",renameQuoteNameRequired:"NegotiableQuote.Manage.rename.quoteNameRequired",renameErrorDefault:"NegotiableQuote.Manage.rename.errorDefault",renameSuccessHeading:"NegotiableQuote.Manage.rename.successHeading",renameSuccessMessage:"NegotiableQuote.Manage.rename.successMessage",confirmationModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",confirmationModalDeleteTitle:"NegotiableQuote.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuote.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuote.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuote.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription",confirmationModalDuplicateTitle:"NegotiableQuote.Manage.confirmationModal.duplicate.title",confirmationModalDuplicateMessage:"NegotiableQuote.Manage.confirmationModal.duplicate.message",confirmationModalDuplicateConfirm:"NegotiableQuote.Manage.confirmationModal.duplicate.confirm",confirmationModalDuplicateErrorHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.errorHeading",confirmationModalDuplicateErrorFallback:"NegotiableQuote.Manage.confirmationModal.duplicate.errorFallback",confirmationModalDuplicateSuccessHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.successHeading",confirmationModalDuplicateSuccessDescription:"NegotiableQuote.Manage.confirmationModal.duplicate.successDescription",duplicateOutOfStockWarningHeading:"NegotiableQuote.Manage.confirmationModal.duplicate.outOfStockWarningHeading",duplicateOutOfStockWarningMessage:"NegotiableQuote.Manage.confirmationModal.duplicate.outOfStockWarningMessage",noItemsSelectedModalTitle:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.title",noItemsSelectedModalMessage:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.message",noItemsSelectedModalConfirm:"NegotiableQuote.Manage.confirmationModal.noItemsSelected.confirm",attachFiles:"NegotiableQuote.Manage.attachFiles",fileUploadError:"NegotiableQuote.Manage.fileUploadError",maxFilesExceeded:"NegotiableQuote.Manage.maxFilesExceeded",maxFileSizeExceeded:"NegotiableQuote.Manage.maxFileSizeExceeded",invalidFileType:"NegotiableQuote.Manage.invalidFileType"});v(()=>{const a=C.on("quote-management/quote-data",i=>{const{quote:r}=i;if(r){S(r),k(!1);const s=`duplicate-outOfStock-warning-${r.uid}`;sessionStorage.getItem(s)==="true"&&(Ie(!0),sessionStorage.removeItem(s))}},{eager:!0});return()=>a==null?void 0:a.off()},[]),v(()=>{const a=C.on("quote-management/shipping-address-set",i=>{const{quote:r}=i;r&&S(r)},{eager:!0});return()=>a==null?void 0:a.off()},[]),v(()=>{const a=C.on("quote-management/quote-sent-for-review",i=>{const{quote:r}=i;S(r),we(""),K([]),me(!1)},{eager:!0});return()=>a==null?void 0:a.off()},[]),v(()=>{const a=C.on("quote-management/quote-items-removed",i=>{const{quote:r,removedItemUids:s}=i;r&&S(r),s&&Pe(d=>{const q=new Set(d);return s.forEach(I=>q.delete(I)),q})},{eager:!0});return()=>a==null?void 0:a.off()},[]);const Ge=c((a,i)=>{Pe(r=>{const s=new Set(r);return i?s.add(a.uid):s.delete(a.uid),s})},[]),Ke=c(a=>{const i=a.target.value,r=$e.current;if(i==="remove"){if(Se(i),ce.current=i,r.size===0)je(!0);else if(e&&Ne.current){const s=e.items.filter(d=>r.has(d.uid));Ne.current(s)}}x==null||x(a)},[x,e]),Xe=c(()=>{je(!1),Se(""),ce.current=""},[]);v(()=>{const a=C.on("quote-management/negotiable-quote-closed",async i=>{ue(!1),V(""),O(o.closeSuccessMessage),S(r=>{var s;return r!=null&&r.uid&&((s=i.closedQuoteUids)!=null&&s.includes(r.uid))&&rt(r.uid).then(d=>{S(d)}).catch(d=>{console.warn("Failed to refresh quote data after closure:",d)}),r}),setTimeout(()=>{de(!1),O("")},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[o.closeSuccessMessage]),v(()=>{const a=C.on("quote-management/negotiable-quote-close-error",i=>{console.log("Close error event received:",i),ue(!1),O("");const r=i.error.message||o.errorFallback;V(r)},{eager:!0});return()=>a==null?void 0:a.off()},[o.errorFallback]),v(()=>{const a=C.on("quote-management/quote-renamed",i=>{const{quote:r}=i;S(r),G(""),U(""),ie(o.renameSuccessMessage),setTimeout(()=>{fe(!1),ne(""),oe(""),ie("")},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[o.renameSuccessMessage]),v(()=>{const a=C.on("quote-management/quote-duplicated",i=>{const{quote:r}=i;e&&L&&L({quoteData:e,newQuote:r}),H(!0),D(null),setTimeout(()=>{se(!1),H(!1),D(null)},2e3)},{eager:!0});return()=>a==null?void 0:a.off()},[e,L]);const Qe=c(async a=>{if(y&&b.length+a.length>y){le(o.maxFilesExceeded.replace("{maxFiles}",String(y)));return}for(const r of a){if(_&&!Aa(r.size,_)){le(o.maxFileSizeExceeded.replace("{maxSize}",et(_)));return}if(N&&!at(r.type,N)){le(o.invalidFileType);return}}le(void 0);const i=a.map(r=>({key:`temp-${Date.now()}-${Math.random()}-${r.name}`,name:r.name,size:r.size,status:"uploading"}));K(r=>[...r,...i]);for(let r=0;r<a.length;r++){const s=a[r],d=i[r].key;try{const q=await gt(s);K(I=>I.map(T=>T.key===d?{...T,key:q.key,status:"success"}:T))}catch(q){K(I=>I.map(T=>T.key===d?{...T,status:"error",error:q.message}:T))}}},[y,_,N,b,o]),qe=c(a=>{K(i=>i.filter(r=>r.key!==a))},[]),Je=c(()=>{ne((e==null?void 0:e.name)||""),oe(""),G(""),U(""),ie(""),fe(!0)},[e]),ga=c(()=>{fe(!1),ne(""),oe(""),G(""),U(""),ie("")},[]),fa=c(a=>{ne(a),a.trim()&&U("")},[]),Ye=c(()=>{se(!0),D(null),H(!1)},[]),pa=c(async()=>{if(!te.trim()){U(o.renameQuoteNameRequired);return}try{G(""),U(""),await lt({quoteUid:e.uid,quoteName:te,quoteComment:pe.trim()||void 0})}catch(a){G(a.message||o.renameErrorDefault)}},[e,te,pe,o.renameQuoteNameRequired,o.renameErrorDefault]),Ma=f(()=>{const a=e&&(e.lockedForEditing===!0||e.lockedForEditing===void 0&&(e.status==="SUBMITTED"||e.status==="PENDING"||e.status==="ORDERED"||e.status==="CLOSED"));return n(g,{name:"QuoteName",slot:t==null?void 0:t.QuoteName,context:{quoteName:e==null?void 0:e.name,quoteData:e},children:p("div",{className:"quote-management-manage-negotiable-quote__quote-name-wrapper",children:[n("h1",{"data-testid":"quote-name",className:"quote-management-manage-negotiable-quote__quote-name-title",children:e==null?void 0:e.name}),n("button",{onClick:Je,disabled:a,"data-testid":"rename-quote-button",className:"quote-management-manage-negotiable-quote__rename-button","aria-label":"Rename quote",children:n(Xa,{})})]})})},[t==null?void 0:t.QuoteName,e,Je]),ba=f(()=>n(g,{name:"QuoteStatus",slot:t==null?void 0:t.QuoteStatus,context:{quoteStatus:e==null?void 0:e.status,quoteData:e},children:n("div",{"data-testid":"quote-status",children:e==null?void 0:e.status})}),[t==null?void 0:t.QuoteStatus,e]),Ze=c(a=>{switch(a){case"SUBMITTED":return o.statusSubmitted;case"PENDING":return o.statusPending;case"EXPIRED":return o.statusExpired;default:return null}},[o])(e==null?void 0:e.status),Ae=Ze&&n(h,{type:"warning",variant:"secondary",icon:n(w,{}),heading:o.bannerTitle,description:Ze}),ea=Ae&&n(g,{name:"Banner","data-testid":"banner",slot:t==null?void 0:t.Banner,context:{quoteData:e},children:Ae}),ha=c(()=>{Ie(!1)},[]),aa=Fe&&n(g,{name:"DuplicateQuoteWarningBanner","data-testid":"duplicate-outOfStock-warning-banner",slot:t==null?void 0:t.DuplicateQuoteWarningBanner,context:{outOfStockWarning:Fe},children:n(h,{type:"warning",variant:"primary",icon:n(w,{}),heading:o.duplicateOutOfStockWarningHeading,description:o.duplicateOutOfStockWarningMessage,onDismiss:ha,"data-testid":"duplicate-outOfStock-warning-alert"})}),Na=f(()=>{if(!e)return;const a=e.expirationDate?ca(e.expirationDate,"short"):void 0;return p(g,{name:"Details",slot:t==null?void 0:t.Details,context:{quoteData:e},children:[p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:o.createdLabel}),p("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[ca(e.createdAt,"short")," (",e.buyer.firstname," ",e.buyer.lastname,")"]})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:o.salesRepLabel}),n("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:e.salesRepName})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[n("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:o.expiresLabel}),n("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:a})]})]})},[t==null?void 0:t.Details,o,e]),ta=f(()=>[{label:o.close,value:"close",disabled:!(e!=null&&e.canClose)},{label:o.delete,value:"delete",disabled:!(e!=null&&e.canDelete)},{label:o.print,value:"print"},{label:o.createTemplate,value:"createTemplate"},{label:o.createCopy,value:"createCopy"}],[o,e==null?void 0:e.canDelete,e==null?void 0:e.canClose]),Sa=f(()=>{const a=i=>{switch(i){case"close":de(!0),V(""),O(""),m==null||m(i);break;case"delete":Z(!0),m==null||m(i);break;case"print":m==null||m(i);break;case"createTemplate":ge(!0),ae(""),j(""),m==null||m(i);break;case"createCopy":Ye(),m==null||m(i);break}};return n(g,{name:"ActionBar",slot:t==null?void 0:t.ActionBar,context:{quoteData:e,actionsBarDropdownValue:B},children:n(Ja,{dropdownPlaceholder:o.actionsLabel,dropdownOptions:[{label:o.remove,value:"remove"}],dropdownValue:B,handleDropdownChange:Ke,buttons:ta.map(i=>n(sa,{variant:"tertiary",onClick:()=>a(i.value),"data-testid":`actions-bar-${i.value}-button`,"data-action":i.value,disabled:i.disabled,children:i.label},i.value))})})},[ta,o,t==null?void 0:t.ActionBar,e,Ke,m,Ye,B]),Qa=f(()=>n(g,{name:"QuoteContent",slot:t==null?void 0:t.QuoteContent,context:{quoteData:e},children:n(Ya,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",n(g,{name:"ItemsQuotedTab",slot:t==null?void 0:t.ItemsQuotedTab,context:{quoteData:e},children:n(ft,{quoteData:e,onItemCheckboxChange:Ge,onRemoveItemsRef:a=>{Ne.current=a},onRemoveModalStateChange:a=>{!a&&ce.current==="remove"&&Se("")}})},"items-quoted")],["comments",n(g,{name:"CommentsTab",slot:t==null?void 0:t.CommentsTab,context:{quoteData:e},children:n(pt,{quoteData:e})},"comments")],["history-log",n(g,{name:"HistoryLogTab",slot:t==null?void 0:t.HistoryLogTab,context:{quoteData:e},children:n(it,{quoteData:e})},"history-log")]])})}),[t==null?void 0:t.QuoteContent,t==null?void 0:t.HistoryLogTab,t==null?void 0:t.CommentsTab,t==null?void 0:t.ItemsQuotedTab,e,Ge]),qa=f(()=>n(g,{name:"ShippingInformationTitle",slot:t==null?void 0:t.ShippingInformationTitle,context:{quoteData:e},children:n("h2",{children:o.shippingInformationTitle})}),[t==null?void 0:t.ShippingInformationTitle,e,o]),va=f(()=>{var a;return n(g,{name:"ShippingInformation",slot:t==null?void 0:t.ShippingInformation,context:{quoteData:e,loading:E,setLoading:k},children:n(ot,{shippingAddress:(a=e==null?void 0:e.shippingAddresses)==null?void 0:a[0],loading:E,"data-testid":"manage-quote-shipping-address"})})},[t==null?void 0:t.ShippingInformation,e,E,k]),Ta=f(()=>n(g,{name:"QuoteCommentsTitle",slot:t==null?void 0:t.QuoteCommentsTitle,context:{quoteData:e},children:n("h2",{children:o.quoteCommentsTitle})}),[t==null?void 0:t.QuoteCommentsTitle,o,e]),Ca=f(()=>n(g,{name:"QuoteComments",slot:t==null?void 0:t.QuoteComments,context:{quoteData:e},children:n(Ga,{name:"quoteComments",placeholder:o.quoteCommentsPlaceholder,rows:3,value:F,onInput:a=>{we(a.target.value)},disabled:!(e!=null&&e.canSendForReview)||Q})}),[t==null?void 0:t.QuoteComments,o,e,F,Q]),na=f(()=>!(e!=null&&e.canSendForReview),[e]),ya=f(()=>{const a=Q||na;return n(g,{name:"AttachFilesField",slot:t==null?void 0:t.AttachFilesField,context:{onFileChange:Qe,attachedFiles:b,fileUploadError:re,disabled:a},children:p("div",{className:"quote-management-manage-negotiable-quote__attach-files",...a?{"data-disabled":!0}:{},"aria-disabled":a,children:[n(Ka,{id:"manage-quote-attach-files",multiple:!0,onChange:i=>{const r=i.target,s=r==null?void 0:r.files,d=s?Array.from(s):[];d.length>0&&Qe(d)},icon:n(tt,{}),disabled:a,"data-testid":"manage-quote-attach-files",accept:N==null?void 0:N.join(","),children:o.attachFiles}),re&&n("div",{className:"quote-management-manage-negotiable-quote__file-error","data-testid":"file-upload-error",children:re})]})})},[t==null?void 0:t.AttachFilesField,Qe,Q,na,N,re,o,b]),_a=f(()=>{if(b.length)return n(g,{name:"AttachedFilesList",slot:t==null?void 0:t.AttachedFilesList,context:{files:b,onRemove:qe,disabled:Q},children:n(nt,{files:b,onRemove:qe,disabled:Q})})},[b,qe,Q,t==null?void 0:t.AttachedFilesList]),Ea=c(async()=>{if(e!=null&&e.uid){ue(!0),V(""),O("");try{await ct({quoteUids:[e.uid]})}catch(a){console.error("Failed to close quote:",a)}}},[e]),Da=c(()=>{de(!1),V(""),O("")},[]),Fa=c(async()=>{if(e!=null&&e.uid){Ue(!0),ae(""),j("");try{await st(e.uid),j(o.createTemplateSuccessMessage),setTimeout(()=>{ge(!1),j("")},2e3)}catch(a){console.error("Failed to create quote template:",a);const i=a instanceof Error?a.message:o.createTemplateErrorFallback;ae(i)}finally{Ue(!1)}}},[e,o.createTemplateSuccessMessage,o.createTemplateErrorFallback]),Ia=c(()=>{ge(!1),ae(""),j("")},[]),ve=c(async()=>{const a=b.filter(i=>i.status==="success");if(R){R({quoteData:e,comment:F.trim()||void 0,attachments:a.length?a:void 0});return}me(!0);try{await mt({quoteUid:e.uid,comment:F.trim()||void 0,attachments:a.length?a.map(i=>({key:i.key})):void 0})}catch(i){console.error("Failed to send quote for review:",i),me(!1)}},[e,R,F,b]),wa=f(()=>n(g,{name:"Footer",slot:t==null?void 0:t.Footer,context:{quoteData:e,comment:F,isSubmitting:Q,attachments:b,handleSendForReview:ve},children:n(sa,{variant:"primary",onClick:ve,"data-testid":"send-for-review-button",disabled:!(e!=null&&e.canSendForReview)||Q,children:o.sendForReview})}),[t==null?void 0:t.Footer,o,e,F,Q,b,ve]),xa=f(()=>Me?n(h,{type:"error",variant:"primary",icon:n(w,{color:"var(--color-error)"}),heading:o.renameErrorHeading,description:Me}):void 0,[Me,o.renameErrorHeading]),Ra=f(()=>be?n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.renameSuccessHeading,description:be}):void 0,[be,o.renameSuccessHeading]),Te=c(a=>a.errors&&Array.isArray(a.errors)&&a.errors.length>0?a.errors[0].message||o.confirmationModalDeleteErrorFallback:(a==null?void 0:a.message)||o.confirmationModalDeleteErrorFallback,[o.confirmationModalDeleteErrorFallback]),La=c(()=>{Z(!1),$(null),ee(!1)},[]),ka=c(async()=>{if(e!=null&&e.uid){$(null),ee(!1);try{const{operationResults:a}=await dt(e.uid),i=a.find(r=>r.__typename==="DeleteNegotiableQuoteOperationFailure");if(i){const r=Te(i);$(r);return}ee(!0)}catch(a){const i=Te(a);$(i)}}},[e,Te]),Ha=c(()=>{$(null)},[]),Oa=c(()=>{ee(!1)},[]),oa=c(a=>(a==null?void 0:a.message)||o.confirmationModalDuplicateErrorFallback,[o.confirmationModalDuplicateErrorFallback]),Ua=c(()=>{se(!1),D(null),H(!1)},[]),Ba=c(async()=>{var a;if(e!=null&&e.uid){D(null),H(!1);try{const i=((a=e.items)==null?void 0:a.filter(q=>q.outOfStock))||[],s=(q=>{const I=q.slice(0,-8),T=crypto.randomUUID().slice(0,8);return I+T})(e.uid),d=i.length>0;d&&sessionStorage.setItem(`duplicate-outOfStock-warning-${s}`,"true"),await ut({quoteUid:e.uid,duplicatedQuoteUid:s,hasOutOfStockItems:d})}catch(i){const r=oa(i);D(r)}}},[e,oa]),Wa=c(()=>{D(null)},[]),za=c(()=>{H(!1)},[]),Pa=A?n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.confirmationModalDeleteErrorHeading,description:A,onDismiss:Ha,"data-testid":"confirmation-modal-error-banner"}):null,ia=(ma?n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.confirmationModalDeleteSuccessHeading,description:o.confirmationModalDeleteSuccessDescription,onDismiss:Oa,"data-testid":"confirmation-modal-success-banner"}):null)||Pa,$a=De?n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.confirmationModalDuplicateErrorHeading,description:De,onDismiss:Wa,"data-testid":"confirmation-modal-duplicate-error-banner"}):null,ra=(da?n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.confirmationModalDuplicateSuccessHeading,description:o.confirmationModalDuplicateSuccessDescription,onDismiss:za,"data-testid":"confirmation-modal-duplicate-success-banner"}):null)||$a,Va={...Y,loading:E,quoteName:Ma,quoteStatus:ba,banner:aa||ea?p(la,{children:[aa,ea]}):void 0,details:Na,actionBar:Sa,quoteContent:Qa,shippingInformationTitle:qa,shippingInformation:va,quoteCommentsTitle:Ta,quoteComments:Ca,attachFilesField:ya,attachedFilesList:_a,footer:wa};let Ce=null;Le?Ce=n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.closeModalSuccessHeading,description:Le,"data-testid":"close-quote-success-banner"}):ke&&(Ce=n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.confirmationModalDeleteErrorHeading,description:ke,"data-testid":"close-quote-error-banner"}));let ye=null;return Be?ye=n(h,{type:"success",variant:"primary",icon:n(J,{}),heading:o.createTemplateModalSuccessHeading,description:Be,"data-testid":"create-template-success-banner"}):We&&(ye=n(h,{type:"error",variant:"primary",icon:n(w,{}),heading:o.createTemplateModalErrorHeading,description:We,"data-testid":"create-template-error-banner"})),p(la,{children:[n(bt,{...Va}),ze&&W(n(Za,{open:ze,quoteName:te,renameReason:pe,quoteNameError:ua,errorBanner:xa,successBanner:Ra,onQuoteNameChange:fa,onRenameReasonChange:oe,onSave:pa,onClose:ga}),document.body),P&&W(n(X,{open:P,title:o.confirmationModalDeleteTitle,message:o.confirmationModalDeleteMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDeleteConfirm,onCancel:La,onConfirm:ka,showCloseButton:!ia,confirmationBanner:ia}),document.body),Ee&&W(n(X,{open:Ee,title:o.confirmationModalDuplicateTitle,message:o.confirmationModalDuplicateMessage,cancelLabel:o.confirmationModalCancel,confirmLabel:o.confirmationModalDuplicateConfirm,onCancel:Ua,onConfirm:Ba,showCloseButton:!ra,confirmationBanner:ra}),document.body),xe&&W(n(X,{open:xe,title:o.closeModalTitle,message:o.closeModalMessage,cancelLabel:o.closeModalCancel,confirmLabel:Re?o.closeModalConfirmLoading:o.closeModalConfirm,onCancel:Da,onConfirm:Re?void 0:Ea,showCloseButton:!0,confirmationBanner:Ce,"data-testid":"close-quote-confirmation-modal"}),document.body),He&&W(n(X,{open:He,title:o.createTemplateModalTitle,message:o.createTemplateModalMessage,cancelLabel:o.createTemplateModalCancel,confirmLabel:Oe?o.createTemplateModalConfirmLoading:o.createTemplateModalConfirm,onCancel:Ia,onConfirm:Oe?void 0:Fa,showCloseButton:!0,confirmationBanner:ye,"data-testid":"create-template-confirmation-modal"}),document.body),Ve&&W(n(X,{open:Ve,title:o.noItemsSelectedModalTitle,message:o.noItemsSelectedModalMessage,confirmLabel:o.noItemsSelectedModalConfirm,onConfirm:Xe,onClose:Xe,showCloseButton:!0,"data-testid":"no-items-selected-modal"}),document.body)]})};export{en as ManageNegotiableQuote,en as default};
|
|
4
4
|
//# sourceMappingURL=ManageNegotiableQuote.js.map
|