@dropins/storefront-quote-management 0.0.1-alpha26 → 0.0.1-alpha27
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/initialize/initialize.d.ts +1 -0
- package/api.js +15 -15
- package/api.js.map +1 -1
- package/chunks/ItemsQuoted.js +1 -1
- package/chunks/ItemsQuoted.js.map +1 -1
- package/chunks/ItemsQuotedTemplate.js +4 -0
- package/chunks/ItemsQuotedTemplate.js.map +1 -0
- package/chunks/OrderSummaryLine.js +1 -1
- package/chunks/OrderSummaryLine.js.map +1 -1
- package/chunks/QuoteCommentsList.js +1 -1
- package/chunks/QuoteCommentsList.js.map +1 -1
- package/chunks/QuoteCommentsList3.js +4 -0
- package/chunks/QuoteCommentsList3.js.map +1 -0
- package/chunks/QuoteHistoryLog.js +1 -1
- package/chunks/QuoteHistoryLog.js.map +1 -1
- package/chunks/QuoteHistoryLog3.js +4 -0
- package/chunks/QuoteHistoryLog3.js.map +1 -0
- package/chunks/QuotePricesSummary.js +4 -0
- package/chunks/QuotePricesSummary.js.map +1 -0
- package/chunks/QuoteTemplateCommentsList.js +4 -0
- package/chunks/QuoteTemplateCommentsList.js.map +1 -0
- package/chunks/QuoteTemplateHistoryLog.js +4 -0
- package/chunks/QuoteTemplateHistoryLog.js.map +1 -0
- package/chunks/TabbedContent.js +4 -0
- package/chunks/TabbedContent.js.map +1 -0
- package/chunks/dateUtils.js +1 -1
- package/chunks/dateUtils.js.map +1 -1
- package/chunks/getQuoteTemplates.js +2 -2
- package/chunks/getQuoteTemplates.js.map +1 -1
- package/chunks/negotiableQuotes.js +1 -1
- package/chunks/negotiableQuotes.js.map +1 -1
- package/chunks/removeNegotiableQuoteItems.js +3 -3
- package/chunks/removeNegotiableQuoteItems.js.map +1 -1
- package/chunks/renameNegotiableQuote.js +1 -1
- package/chunks/renameNegotiableQuote.js.map +1 -1
- package/chunks/state.js +1 -1
- package/chunks/transform-quote.js +4 -0
- package/chunks/transform-quote.js.map +1 -0
- package/chunks/uploadFile.js +1 -1
- package/chunks/uploadFile.js.map +1 -1
- package/components/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +1 -1
- package/components/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +22 -0
- package/components/ManageNegotiableQuoteTemplate/__fixtures__/ManageNegotiableQuoteTemplateProps.d.ts +4 -0
- package/components/ManageNegotiableQuoteTemplate/index.d.ts +11 -0
- package/components/ProductListTable/ProductListTable.d.ts +41 -5
- package/components/QuoteHistoryLog/QuoteHistoryLog.d.ts +70 -2
- package/components/index.d.ts +1 -0
- package/containers/ItemsQuoted.js +1 -1
- package/containers/ItemsQuotedTemplate/ItemsQuotedTemplate.d.ts +19 -0
- package/containers/ItemsQuotedTemplate/index.d.ts +11 -0
- package/containers/ItemsQuotedTemplate.d.ts +3 -0
- package/containers/ItemsQuotedTemplate.js +4 -0
- package/containers/ItemsQuotedTemplate.js.map +1 -0
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/ManageNegotiableQuoteTemplate/ManageNegotiableQuoteTemplate.d.ts +54 -0
- package/containers/ManageNegotiableQuoteTemplate/index.d.ts +11 -0
- package/containers/ManageNegotiableQuoteTemplate.d.ts +3 -0
- package/containers/ManageNegotiableQuoteTemplate.js +4 -0
- package/containers/ManageNegotiableQuoteTemplate.js.map +1 -0
- package/containers/OrderSummary.js +1 -1
- package/containers/OrderSummary.js.map +1 -1
- package/containers/OrderSummaryLine.js +1 -1
- package/containers/QuoteCommentsList.js +1 -1
- package/containers/QuoteHistoryLog.js +1 -1
- package/containers/QuoteSummaryList.js +1 -1
- package/containers/QuoteSummaryList.js.map +1 -1
- package/containers/QuoteTemplateCommentsList/QuoteTemplateCommentsList.d.ts +9 -0
- package/containers/QuoteTemplateCommentsList/index.d.ts +11 -0
- package/containers/QuoteTemplateCommentsList.d.ts +3 -0
- package/containers/QuoteTemplateCommentsList.js +4 -0
- package/containers/QuoteTemplateCommentsList.js.map +1 -0
- package/containers/QuoteTemplateHistoryLog/QuoteTemplateHistoryLog.d.ts +9 -0
- package/containers/QuoteTemplateHistoryLog/index.d.ts +11 -0
- package/containers/QuoteTemplateHistoryLog.d.ts +3 -0
- package/containers/QuoteTemplateHistoryLog.js +4 -0
- package/containers/QuoteTemplateHistoryLog.js.map +1 -0
- package/containers/QuoteTemplatesListTable/QuoteTemplatesListTable.d.ts +2 -0
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuoteTemplatesListTable.js.map +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/QuotesListTable.js.map +1 -1
- package/containers/RequestNegotiableQuoteForm.js +1 -1
- package/containers/RequestNegotiableQuoteForm.js.map +1 -1
- package/containers/index.d.ts +4 -0
- package/data/models/__fixtures__/negotiableQuoteTemplateModel.d.ts +4 -0
- package/data/models/negotiable-quote-template-model.d.ts +1 -1
- package/i18n/en_US.json.d.ts +32 -4
- package/package.json +1 -1
- package/render.js +2 -3
- package/render.js.map +1 -1
- package/utils/dateUtils.d.ts +7 -2
- package/chunks/fetch-graphql.js +0 -4
- package/chunks/fetch-graphql.js.map +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as t,jsxs as n,Fragment as I}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b,VComponent as k}from"@dropins/tools/lib.js";/* empty css */import{Skeleton as R,SkeletonRow as V,Input as W,Picker as E,Price as _,Checkbox as J,Button as K,Table as X,Accordion as Y,AccordionSection as Z}from"@dropins/tools/components.js";import{h as L}from"@dropins/tools/preact.js";import{useState as H,useEffect as U}from"@dropins/tools/preact-hooks.js";import{useText as C}from"@dropins/tools/i18n.js";const ce=({className:g,loading:i,table:l,pricesSummary:r,...a})=>i?t(ee,{}):n("div",{className:b(["quote-management-items-quoted",g]),...a,children:[l&&t(k,{node:l,className:b(["quote-management-items-quoted__table"]),"data-testid":"quote-management-items-quoted__table"}),r&&t(k,{node:r,className:b(["quote-management-items-quoted__prices-summary"]),"data-testid":"quote-management-items-quoted__prices-summary"})]}),ee=()=>t(R,{"data-testid":"items-quoted-skeleton",children:t(V,{variant:"row",fullWidth:!0,size:"medium",lines:4,multilineGap:"xsmall"})}),ie=({className:g,items:i,canEdit:l,readOnly:r=!1,onItemCheckboxChange:a,onItemDropdownChange:m,onQuantityChange:p,onUpdate:N,dropdownSelections:h,...f})=>{const[x,P]=H({}),[y,T]=H({});U(()=>{const e={};i.forEach(s=>{e[s.uid]=s.quantity}),P(e),T(e)},[i]);const S=Object.keys(y).some(e=>y[e]!==x[e]),u=C({updateButton:"NegotiableQuote.Manage.productListTable.submitButton",productNameHeader:"NegotiableQuote.Manage.productListTable.headers.productName",skuHeader:"NegotiableQuote.Manage.productListTable.headers.sku",priceHeader:"NegotiableQuote.Manage.productListTable.headers.price",quantityHeader:"NegotiableQuote.Manage.productListTable.headers.quantity",discountHeader:"NegotiableQuote.Manage.productListTable.headers.discount",subtotalHeader:"NegotiableQuote.Manage.productListTable.headers.subtotal",actionsHeader:"NegotiableQuote.Manage.productListTable.headers.actions",editNoteToSeller:"NegotiableQuote.Manage.productListTable.actions.editNoteToSeller",remove:"NegotiableQuote.Manage.productListTable.actions.remove"}),v=[{label:u.productNameHeader,key:"productName"},{label:u.skuHeader,key:"sku"},{label:u.priceHeader,key:"price"},{label:u.quantityHeader,key:"quantity"},{label:u.discountHeader,key:"discount"},{label:u.subtotalHeader,key:"subtotal"}];l&&!r&&(v.unshift({label:"",key:"checkbox"}),v.push({label:u.actionsHeader,key:"actions"}));const M=(e,s)=>{const o=e.target.checked;a==null||a(s,o)},$=(e,s)=>{const o=e.target.value;m==null||m(s,o)},B=(e,s)=>{const o=parseInt(e.target.value,10);!isNaN(o)&&o>0&&(T(c=>({...c,[s.uid]:o})),p==null||p(s,o))},O=e=>{e.preventDefault(),N==null||N(e)},w=(e,s)=>e>0?n("div",{className:"quote-management-product-list-table__discount-container",children:[n("span",{className:"quote-management-product-list-table__discount-percent",children:[s,"%"]}),n("span",{className:"quote-management-product-list-table__discount-price",children:["(",t(_,{amount:e}),")"]})]}):void 0,j=e=>{var c,Q;const s=(c=e.configurableOptions)==null?void 0:c.map(d=>n("div",{className:"quote-management-product-list-table__configurable-option",children:[n("span",{className:"quote-management-product-list-table__configurable-option-label",children:[d.optionLabel,":"]}),t("span",{className:"quote-management-product-list-table__configurable-option-value",children:d.valueLabel})]},d.optionLabel)),o=(Q=e.bundleOptions)==null?void 0:Q.map(d=>n("div",{className:"quote-management-product-list-table__bundle-option",children:[t("span",{className:"quote-management-product-list-table__bundle-option-label",children:d.label}),t("div",{className:"quote-management-product-list-table__bundle-option-values",children:d.values.map(q=>n("span",{className:"quote-management-product-list-table__bundle-option-value",children:[n("span",{className:"quote-management-product-list-table__bundle-option-value-quantity",children:[q.quantity," x"]}),t("span",{className:"quote-management-product-list-table__bundle-option-value-label",children:q.label}),t(_,{className:"quote-management-product-list-table__bundle-option-value-original-price",amount:q.originalPrice.value,currency:q.originalPrice.currency,weight:"normal"})]},q.label))})]},d.label));return n("div",{className:"quote-management-product-list-table__product-name-container",children:[t("span",{className:"quote-management-product-list-table__product-name",children:e.product.name}),s,o]})},A=i.map(e=>{var o;const s=l?t(W,{className:"quote-management-product-list-table__quantity-input",type:"number",min:"1",value:((o=y[e.uid])==null?void 0:o.toString())||e.quantity.toString(),onChange:c=>B(c,e),disabled:r||!l,"data-testid":`quantity-input-${e.product.sku}`}):t("span",{className:"quote-management-product-list-table__quantity",children:e.quantity});return{checkbox:t(J,{className:"quote-management-product-list-table__checkbox",name:"itemSelected","data-testid":`item-checkbox-${e.product.sku}`,onChange:c=>M(c,e),value:e.product.sku}),productName:j(e),sku:t("span",{className:"quote-management-product-list-table__sku",children:e.product.sku}),price:t(_,{className:"quote-management-product-list-table__price",amount:e.prices.originalItemPrice.value,currency:e.prices.originalItemPrice.currency}),quantity:s,discount:e.catalogDiscount?w(e.catalogDiscount.amountOff,e.catalogDiscount.percentOff):void 0,subtotal:t(_,{className:"quote-management-product-list-table__subtotal",amount:e.prices.rowTotal.value,currency:e.prices.rowTotal.currency}),actions:t(E,{className:"quote-management-product-list-table__actions","data-testid":`item-dropdown-${e.product.sku}`,name:`item-dropdown-${e.product.sku}`,handleSelect:c=>$(c,e),placeholder:"Select",value:(h==null?void 0:h[e.uid])??"",options:[{text:u.editNoteToSeller,value:"edit"},{text:u.remove,value:"remove"}]})}}),D=t(X,{columns:v,rowData:A,"data-testid":"product-list-table",mobileLayout:"stacked"}),z=l?L("form",{}):L("div",{}),F=l?{onSubmit:O,...f}:f,G=t(K,{type:"submit",disabled:r||!l||!S,"data-testid":"product-list-table-submit-button",children:u.updateButton});return n(k,{node:z,className:b(["quote-management-product-list-table-container",g]),"data-testid":"product-list-table-container",...F,children:[D,t("div",{className:"quote-management-product-list-table-container__submit-container",children:G})]})},re=({className:g,entries:i,...l})=>{const r=a=>{var p;const m=(p=a.children)==null?void 0:p.map(r);return t("div",{className:"quote-management-quote-prices-summary__entry","data-testid":`quote-prices-summary-entry-${a.id}`,children:m?t(Y,{className:"quote-management-quote-prices-summary__accordion","data-testid":`quote-prices-summary-entry-accordion-${a.id}`,children:t(Z,{className:"quote-management-quote-prices-summary__accordion-section",title:a.label,ariaLabelTitle:a.label,secondaryText:a.value,children:m})}):n(I,{children:[t("span",{className:b(["quote-management-quote-prices-summary__label",["quote-management-quote-prices-summary__label--strong",a.strong]]),"data-testid":`quote-prices-summary-entry-label-${a.id}`,children:a.label}),t("span",{className:"quote-management-quote-prices-summary__value","data-testid":`quote-prices-summary-entry-value-${a.id}`,children:a.value})]})},a.id)};return t("div",{className:b(["quote-management-quote-prices-summary",g]),"data-testid":"quote-prices-summary",...l,children:i==null?void 0:i.map(r)})};export{ce as I,ie as P,re as Q};
|
|
4
|
+
//# sourceMappingURL=QuotePricesSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuotePricesSummary.js","sources":["/@dropins/storefront-quote-management/src/components/ItemsQuoted/ItemsQuoted.tsx","/@dropins/storefront-quote-management/src/components/ProductListTable/ProductListTable.tsx","/@dropins/storefront-quote-management/src/components/QuotePricesSummary/QuotePricesSummary.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/quote-management/components/ItemsQuoted/ItemsQuoted.css';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport interface ItemsQuotedProps extends Omit<HTMLAttributes<HTMLDivElement>, 'loading'> {\n loading?: boolean;\n table?: VNode;\n pricesSummary?: VNode;\n}\n\nexport const ItemsQuoted: FunctionComponent<ItemsQuotedProps> = ({\n className,\n loading,\n table,\n pricesSummary,\n ...props\n}) => {\n if (loading) {\n return <ItemsQuotedSkeleton />;\n }\n\n return (\n <div className={classes(['quote-management-items-quoted', className])} {...props}>\n {table && (\n <VComponent\n node={table}\n className={classes(['quote-management-items-quoted__table'])}\n data-testid=\"quote-management-items-quoted__table\"\n />\n )}\n {pricesSummary && (\n <VComponent\n node={pricesSummary}\n className={classes(['quote-management-items-quoted__prices-summary'])}\n data-testid=\"quote-management-items-quoted__prices-summary\"\n />\n )}\n </div>\n );\n};\n\nexport const ItemsQuotedSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"items-quoted-skeleton\">\n <SkeletonRow variant=\"row\" fullWidth={true} size=\"medium\" lines={4} multilineGap='xsmall' />\n </Skeleton>\n );\n};","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent, h } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useState, useEffect } from 'preact/hooks';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { Table, Checkbox, Picker, Price, Button, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/quote-management/components/ProductListTable/ProductListTable.css';\n\nexport interface ProductListTableItem {\n uid: string;\n product: {\n name: string;\n sku: string;\n };\n prices: {\n originalItemPrice: {\n value: number;\n currency: string;\n };\n rowTotal: {\n value: number;\n currency: string;\n };\n };\n quantity: number;\n catalogDiscount?: {\n amountOff: number;\n percentOff: number;\n };\n configurableOptions?: Array<{\n optionLabel: string;\n valueLabel: string;\n }>;\n bundleOptions?: Array<{\n label: string;\n values: Array<{\n label: string;\n quantity: number;\n originalPrice: {\n value: number;\n currency: string;\n };\n }>;\n }>;\n}\n\nexport interface ProductListTableProps extends HTMLAttributes<HTMLDivElement | HTMLFormElement> {\n items: ProductListTableItem[];\n canEdit: boolean;\n readOnly?: boolean;\n onItemCheckboxChange?: (\n item: ProductListTableItem,\n isSelected: boolean\n ) => void;\n onItemDropdownChange?: (\n item: ProductListTableItem,\n action: string\n ) => void;\n onQuantityChange?: (\n item: ProductListTableItem,\n newQuantity: number\n ) => void;\n onUpdate?: (e: SubmitEvent) => void;\n dropdownSelections?: Record<string, string | undefined>;\n}\n\nexport const ProductListTable: FunctionComponent<ProductListTableProps> = ({\n className,\n items,\n canEdit,\n readOnly = false,\n onItemCheckboxChange,\n onItemDropdownChange,\n onQuantityChange,\n onUpdate,\n dropdownSelections,\n ...props\n}) => {\n // Track original quantities to detect changes\n const [originalQuantities, setOriginalQuantities] = useState<\n Record<string, number>\n >({});\n const [currentQuantities, setCurrentQuantities] = useState<\n Record<string, number>\n >({});\n\n // Initialize quantities when items change\n useEffect(() => {\n const quantities: Record<string, number> = {};\n items.forEach((item) => {\n quantities[item.uid] = item.quantity;\n });\n setOriginalQuantities(quantities);\n setCurrentQuantities(quantities);\n }, [items]);\n\n // Check if any quantities have changed\n const hasQuantityChanges = Object.keys(currentQuantities).some(\n (uid) => currentQuantities[uid] !== originalQuantities[uid]\n );\n\n const dictionary = useText({\n updateButton: 'NegotiableQuote.Manage.productListTable.submitButton',\n productNameHeader:\n 'NegotiableQuote.Manage.productListTable.headers.productName',\n skuHeader: 'NegotiableQuote.Manage.productListTable.headers.sku',\n priceHeader: 'NegotiableQuote.Manage.productListTable.headers.price',\n quantityHeader: 'NegotiableQuote.Manage.productListTable.headers.quantity',\n discountHeader: 'NegotiableQuote.Manage.productListTable.headers.discount',\n subtotalHeader: 'NegotiableQuote.Manage.productListTable.headers.subtotal',\n actionsHeader: 'NegotiableQuote.Manage.productListTable.headers.actions',\n editNoteToSeller:\n 'NegotiableQuote.Manage.productListTable.actions.editNoteToSeller',\n remove: 'NegotiableQuote.Manage.productListTable.actions.remove',\n });\n\n const columns = [\n {\n label: dictionary.productNameHeader,\n key: 'productName',\n },\n {\n label: dictionary.skuHeader,\n key: 'sku',\n },\n {\n label: dictionary.priceHeader,\n key: 'price',\n },\n {\n label: dictionary.quantityHeader,\n key: 'quantity',\n },\n {\n label: dictionary.discountHeader,\n key: 'discount',\n },\n {\n label: dictionary.subtotalHeader,\n key: 'subtotal',\n },\n ];\n\n if (canEdit && !readOnly) {\n columns.unshift({\n label: '',\n key: 'checkbox',\n });\n columns.push({\n label: dictionary.actionsHeader,\n key: 'actions',\n });\n }\n\n const handleItemCheckboxChange = (\n event: Event,\n item: ProductListTableItem\n ) => {\n const isSelected = (event.target as HTMLInputElement).checked;\n onItemCheckboxChange?.(item, isSelected);\n };\n\n const handleItemDropdownChange = (\n event: Event,\n item: ProductListTableItem\n ) => {\n const action = (event.target as HTMLSelectElement).value;\n onItemDropdownChange?.(item, action);\n };\n\n const handleQuantityChange = (\n event: Event,\n item: ProductListTableItem\n ) => {\n const newQuantity = parseInt((event.target as HTMLInputElement).value, 10);\n if (!isNaN(newQuantity) && newQuantity > 0) {\n setCurrentQuantities((prev) => ({\n ...prev,\n [item.uid]: newQuantity,\n }));\n onQuantityChange?.(item, newQuantity);\n }\n };\n\n const handleUpdate = (event: SubmitEvent) => {\n event.preventDefault();\n onUpdate?.(event);\n };\n\n const discountElement = (amountOff: number, percentOff: number) => {\n return amountOff > 0 ? (\n <div className=\"quote-management-product-list-table__discount-container\">\n <span className=\"quote-management-product-list-table__discount-percent\">\n {percentOff}%\n </span>\n <span className=\"quote-management-product-list-table__discount-price\">\n (<Price amount={amountOff} />)\n </span>\n </div>\n ) : undefined;\n };\n\n const getProductNameContent = (item: ProductListTableItem) => {\n const configurableOptions = item.configurableOptions?.map((option) => (\n <div\n key={option.optionLabel}\n className=\"quote-management-product-list-table__configurable-option\"\n >\n <span className=\"quote-management-product-list-table__configurable-option-label\">\n {option.optionLabel}:\n </span>\n <span className=\"quote-management-product-list-table__configurable-option-value\">\n {option.valueLabel}\n </span>\n </div>\n ));\n\n const bundleOptions = item.bundleOptions?.map((option) => (\n <div\n key={option.label}\n className=\"quote-management-product-list-table__bundle-option\"\n >\n <span className=\"quote-management-product-list-table__bundle-option-label\">\n {option.label}\n </span>\n <div className=\"quote-management-product-list-table__bundle-option-values\">\n {option.values.map((value) => (\n <span\n key={value.label}\n className=\"quote-management-product-list-table__bundle-option-value\"\n >\n <span className=\"quote-management-product-list-table__bundle-option-value-quantity\">\n {value.quantity} x\n </span>\n <span className=\"quote-management-product-list-table__bundle-option-value-label\">\n {value.label}\n </span>\n <Price\n className=\"quote-management-product-list-table__bundle-option-value-original-price\"\n amount={value.originalPrice.value}\n currency={value.originalPrice.currency}\n weight=\"normal\"\n />\n </span>\n ))}\n </div>\n </div>\n ));\n\n return (\n <div className=\"quote-management-product-list-table__product-name-container\">\n <span className=\"quote-management-product-list-table__product-name\">\n {item.product.name}\n </span>\n {configurableOptions}\n {bundleOptions}\n </div>\n );\n };\n\n const rowData = items.map((item) => {\n const quantityElement = canEdit ? (\n <Input\n className=\"quote-management-product-list-table__quantity-input\"\n type=\"number\"\n min=\"1\"\n value={\n currentQuantities[item.uid]?.toString() || item.quantity.toString()\n }\n onChange={(e) => handleQuantityChange(e, item)}\n disabled={readOnly || !canEdit}\n data-testid={`quantity-input-${item.product.sku}`}\n />\n ) : (\n <span className=\"quote-management-product-list-table__quantity\">\n {item.quantity}\n </span>\n );\n\n return {\n checkbox: (\n <Checkbox\n className=\"quote-management-product-list-table__checkbox\"\n name=\"itemSelected\"\n data-testid={`item-checkbox-${item.product.sku}`}\n onChange={(e) => handleItemCheckboxChange(e, item)}\n value={item.product.sku}\n />\n ),\n productName: getProductNameContent(item),\n sku: (\n <span className=\"quote-management-product-list-table__sku\">\n {item.product.sku}\n </span>\n ),\n price: (\n <Price\n className=\"quote-management-product-list-table__price\"\n amount={item.prices.originalItemPrice.value}\n currency={item.prices.originalItemPrice.currency}\n />\n ),\n quantity: quantityElement,\n discount: item.catalogDiscount ? discountElement(\n item.catalogDiscount.amountOff,\n item.catalogDiscount.percentOff\n ) : undefined,\n subtotal: (\n <Price\n className=\"quote-management-product-list-table__subtotal\"\n amount={item.prices.rowTotal.value}\n currency={item.prices.rowTotal.currency}\n />\n ),\n actions: (\n <Picker\n className=\"quote-management-product-list-table__actions\"\n data-testid={`item-dropdown-${item.product.sku}`}\n name={`item-dropdown-${item.product.sku}`}\n handleSelect={(e) => handleItemDropdownChange(e, item)}\n placeholder=\"Select\"\n value={dropdownSelections?.[item.uid] ?? ''}\n options={[\n { text: dictionary.editNoteToSeller, value: 'edit' },\n { text: dictionary.remove, value: 'remove' },\n ]}\n />\n ),\n };\n });\n\n const table = (\n <Table\n columns={columns}\n rowData={rowData}\n data-testid=\"product-list-table\"\n mobileLayout=\"stacked\"\n />\n );\n\n // if can edit, the wrapper node should use the form element, else use the div element\n const wrapperNode = canEdit ? h('form', {}) : h('div', {});\n const wrapperProps = canEdit\n ? {\n onSubmit: handleUpdate,\n ...props,\n }\n : props;\n\n const submitButton = (\n <Button\n type=\"submit\"\n disabled={readOnly || !canEdit || !hasQuantityChanges}\n data-testid=\"product-list-table-submit-button\"\n >\n {dictionary.updateButton}\n </Button>\n );\n\n return (\n <VComponent\n node={wrapperNode}\n className={classes([\n 'quote-management-product-list-table-container',\n className,\n ])}\n data-testid=\"product-list-table-container\"\n {...wrapperProps}\n >\n {table}\n <div className=\"quote-management-product-list-table-container__submit-container\">\n {submitButton}\n </div>\n </VComponent>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n \nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport '@/quote-management/components/QuotePricesSummary/QuotePricesSummary.css';\nimport { Accordion, AccordionSection } from '@adobe-commerce/elsie/components';\n\ninterface Entry {\n label: string;\n id: string;\n value: VNode;\n strong?: boolean;\n children?: Entry[];\n}\n\nexport interface QuotePricesSummaryProps extends HTMLAttributes<HTMLDivElement> {\n entries?: Entry[];\n}\n\nexport const QuotePricesSummary: FunctionComponent<QuotePricesSummaryProps> = ({\n className,\n entries,\n ...props\n}) => {\n const createEntry = (entry: Entry) => {\n const children = entry.children?.map(createEntry);\n return (\n <div key={entry.id} className=\"quote-management-quote-prices-summary__entry\" data-testid={`quote-prices-summary-entry-${entry.id}`}>\n {children ? <Accordion\n className=\"quote-management-quote-prices-summary__accordion\"\n data-testid={`quote-prices-summary-entry-accordion-${entry.id}`}\n >\n <AccordionSection className=\"quote-management-quote-prices-summary__accordion-section\" title={entry.label} ariaLabelTitle={entry.label} secondaryText={entry.value}>\n {children}\n </AccordionSection>\n </Accordion>\n :\n <>\n <span className={classes(['quote-management-quote-prices-summary__label', ['quote-management-quote-prices-summary__label--strong', entry.strong]])} data-testid={`quote-prices-summary-entry-label-${entry.id}`}>{entry.label}</span>\n <span className=\"quote-management-quote-prices-summary__value\" data-testid={`quote-prices-summary-entry-value-${entry.id}`}>{entry.value}</span>\n </>\n }\n </div>\n );\n };\n\n return (\n <div className={classes(['quote-management-quote-prices-summary', className])} data-testid=\"quote-prices-summary\" {...props}>\n {entries?.map(createEntry)}\n </div>\n );\n};\n"],"names":["ItemsQuoted","className","loading","table","pricesSummary","props","ItemsQuotedSkeleton","jsxs","classes","jsx","VComponent","Skeleton","SkeletonRow","ProductListTable","items","canEdit","readOnly","onItemCheckboxChange","onItemDropdownChange","onQuantityChange","onUpdate","dropdownSelections","originalQuantities","setOriginalQuantities","useState","currentQuantities","setCurrentQuantities","useEffect","quantities","item","hasQuantityChanges","uid","dictionary","useText","columns","handleItemCheckboxChange","event","isSelected","handleItemDropdownChange","action","handleQuantityChange","newQuantity","prev","handleUpdate","discountElement","amountOff","percentOff","Price","getProductNameContent","configurableOptions","_a","option","bundleOptions","_b","value","rowData","quantityElement","Input","e","Checkbox","Picker","Table","wrapperNode","h","wrapperProps","submitButton","Button","QuotePricesSummary","entries","createEntry","entry","children","Accordion","AccordionSection","Fragment"],"mappings":"0hBAqBO,MAAMA,GAAmD,CAAC,CAC/D,UAAAC,EACA,QAAAC,EACA,MAAAC,EACA,cAAAC,EACA,GAAGC,CACL,IACMH,IACMI,GAAA,EAAoB,EAI5BC,EAAC,MAAA,CAAI,UAAWC,EAAQ,CAAC,gCAAiCP,CAAS,CAAC,EAAI,GAAGI,EACxE,SAAA,CAAAF,GACCM,EAACC,EAAA,CACC,KAAMP,EACN,UAAWK,EAAQ,CAAC,sCAAsC,CAAC,EAC3D,cAAY,sCAAA,CAAA,EAGfJ,GACCK,EAACC,EAAA,CACC,KAAMN,EACN,UAAWI,EAAQ,CAAC,+CAA+C,CAAC,EACpE,cAAY,+CAAA,CAAA,CACd,EAEJ,EAISF,GAAyC,MAEjDK,EAAA,CAAS,cAAY,wBACpB,SAAAF,EAACG,GAAY,QAAQ,MAAM,UAAW,GAAM,KAAK,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,CAAI,UAAU,kEACZ,SAAAwD,CAAA,CACH,CAAA,CAAA,CAAA,CAGN,ECtWaE,GAAiE,CAAC,CAC7E,UAAAlE,EACA,QAAAmE,EACA,GAAG/D,CACL,IAAM,CACJ,MAAMgE,EAAeC,GAAiB,OACpC,MAAMC,GAAWrB,EAAAoB,EAAM,WAAN,YAAApB,EAAgB,IAAImB,GACrC,OACE5D,EAAC,OAAmB,UAAU,+CAA+C,cAAa,8BAA8B6D,EAAM,EAAE,GAC7H,SAAAC,EAAW9D,EAAC+D,EAAA,CACX,UAAU,mDACV,cAAa,wCAAwCF,EAAM,EAAE,GAE7D,SAAA7D,EAACgE,EAAA,CAAiB,UAAU,2DAA2D,MAAOH,EAAM,MAAO,eAAgBA,EAAM,MAAO,cAAeA,EAAM,MAC1J,SAAAC,CAAA,CACH,CAAA,CAAA,EAGFhE,EAAAmE,EAAA,CACE,SAAA,CAAAjE,EAAC,QAAK,UAAWD,EAAQ,CAAC,+CAAgD,CAAC,uDAAwD8D,EAAM,MAAM,CAAC,CAAC,EAAG,cAAa,oCAAoCA,EAAM,EAAE,GAAK,WAAM,MAAM,EAC9N7D,EAAC,OAAA,CAAK,UAAU,+CAA+C,cAAa,oCAAoC6D,EAAM,EAAE,GAAK,SAAAA,EAAM,KAAA,CAAM,CAAA,EAC3I,CAAA,EAbQA,EAAM,EAehB,CAEJ,EAEA,SACG,MAAA,CAAI,UAAW9D,EAAQ,CAAC,wCAAyCP,CAAS,CAAC,EAAG,cAAY,uBAAwB,GAAGI,EACnH,SAAA+D,GAAA,YAAAA,EAAS,IAAIC,GAChB,CAEJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as o,jsxs as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as f,useEffect as p}from"@dropins/tools/preact-compat.js";import{Q as d}from"./QuoteCommentsList.js";import{events as l}from"@dropins/tools/event-bus.js";import{f as c}from"./dateUtils.js";const C=({templateData:a,...s})=>{var r;const[e,m]=f(a);if(p(()=>{const t=l.on("quote-management/quote-template-data",u=>{m(u.quoteTemplate)},{eager:!0});return()=>t==null?void 0:t.off()},[]),!e)return null;const n=(r=e==null?void 0:e.comments)==null?void 0:r.map(t=>({uid:t.uid,createdAt:o("span",{children:c(t.createdAt,"long")}),author:i("span",{children:[t.author.firstname," ",t.author.lastname]}),text:o("p",{children:t.text})}));return o(d,{"data-testid":"quote-template-comments-list-container",...s,comments:n||[]})};export{C as Q};
|
|
4
|
+
//# sourceMappingURL=QuoteTemplateCommentsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuoteTemplateCommentsList.js","sources":["/@dropins/storefront-quote-management/src/containers/QuoteTemplateCommentsList/QuoteTemplateCommentsList.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { QuoteCommentsList as QuoteCommentsListComponent } from '@/quote-management/components/QuoteCommentsList';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { events } from '@adobe-commerce/event-bus';\nimport { formattedDate } from '@/quote-management/utils/dateUtils';\n\nexport interface QuoteTemplateCommentsListProps extends HTMLAttributes<HTMLUListElement> {\n templateData?: NegotiableQuoteTemplateModel;\n}\n\nexport const QuoteTemplateCommentsList: Container<QuoteTemplateCommentsListProps> = ({\n templateData: initialData,\n ...props\n}) => {\n const [templateData, setTemplateData] = useState<NegotiableQuoteTemplateModel | undefined>(initialData);\n\n useEffect(() => {\n const templateDataEvent = events.on('quote-management/quote-template-data', (data: { quoteTemplate: NegotiableQuoteTemplateModel }) => {\n setTemplateData(data.quoteTemplate);\n }, { eager: true });\n return () => templateDataEvent?.off();\n }, []);\n\n if (!templateData) {\n return null;\n }\n\n // Format comments data\n const formattedComments = templateData?.comments?.map((comment) => ({\n uid: comment.uid,\n createdAt: <span>{formattedDate(comment.createdAt, 'long')}</span>,\n author: (\n <span>\n {comment.author.firstname} {comment.author.lastname}\n </span>\n ),\n text: <p>{comment.text}</p>,\n }));\n\n return (\n <QuoteCommentsListComponent\n data-testid=\"quote-template-comments-list-container\"\n {...props}\n comments={formattedComments || []}\n />\n );\n};\n"],"names":["QuoteTemplateCommentsList","initialData","props","templateData","setTemplateData","useState","useEffect","templateDataEvent","events","data","formattedComments","_a","comment","jsx","QuoteCommentsListComponent"],"mappings":"kRAoBO,MAAMA,EAAuE,CAAC,CACnF,aAAcC,EACd,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAmDJ,CAAW,EAStG,GAPAK,EAAU,IAAM,CACd,MAAMC,EAAoBC,EAAO,GAAG,uCAAyCC,GAA0D,CACrIL,EAAgBK,EAAK,aAAa,CACpC,EAAG,CAAE,MAAO,GAAM,EAClB,MAAO,IAAMF,GAAA,YAAAA,EAAmB,KAClC,EAAG,CAAA,CAAE,EAED,CAACJ,EACH,OAAO,KAIT,MAAMO,GAAoBC,EAAAR,GAAA,YAAAA,EAAc,WAAd,YAAAQ,EAAwB,IAAKC,IAAa,CAClE,IAAKA,EAAQ,IACb,UAAWC,EAAC,OAAA,CAAM,WAAcD,EAAQ,UAAW,MAAM,EAAE,EAC3D,SACG,OAAA,CACE,SAAA,CAAAA,EAAQ,OAAO,UAAU,IAAEA,EAAQ,OAAO,QAAA,EAC7C,EAEF,KAAMC,EAAC,IAAA,CAAG,SAAAD,EAAQ,IAAA,CAAK,CAAA,IAGzB,OACEC,EAACC,EAAA,CACC,cAAY,yCACX,GAAGZ,EACJ,SAAUQ,GAAqB,CAAA,CAAC,CAAA,CAGtC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{useState as u,useEffect as i}from"@dropins/tools/preact-compat.js";import{events as p}from"@dropins/tools/event-bus.js";import{Q as n}from"./QuoteHistoryLog.js";const g=({templateData:r,...a})=>{const[e,s]=u(r);return i(()=>{const t=p.on("quote-management/quote-template-data",m=>{s(m.quoteTemplate)},{eager:!0});return()=>t==null?void 0:t.off()},[]),e?o("div",{...a,children:o(n,{history:e.history,items:e.items,buyer:e.buyer,salesRepName:e.salesRepName})}):null};export{g as Q};
|
|
4
|
+
//# sourceMappingURL=QuoteTemplateHistoryLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuoteTemplateHistoryLog.js","sources":["/@dropins/storefront-quote-management/src/containers/QuoteTemplateHistoryLog/QuoteTemplateHistoryLog.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { events } from '@adobe-commerce/event-bus';\nimport { QuoteHistoryLog as QuoteHistoryLogComponent } from '@/quote-management/components/QuoteHistoryLog';\n\nexport interface QuoteTemplateHistoryLogProps extends HTMLAttributes<HTMLDivElement> {\n templateData?: NegotiableQuoteTemplateModel;\n}\n\nexport const QuoteTemplateHistoryLog: Container<QuoteTemplateHistoryLogProps> = ({\n templateData: initialData,\n ...props\n}) => {\n const [templateData, setTemplateData] = useState<NegotiableQuoteTemplateModel | undefined>(initialData);\n\n useEffect(() => {\n const templateDataEvent = events.on('quote-management/quote-template-data', (payload) => {\n setTemplateData(payload.quoteTemplate);\n }, { eager: true });\n\n return () => templateDataEvent?.off();\n }, []);\n\n if (!templateData) {\n return null;\n }\n\n return (\n <div {...props}>\n <QuoteHistoryLogComponent \n history={templateData.history}\n items={templateData.items}\n buyer={templateData.buyer}\n salesRepName={templateData.salesRepName}\n />\n </div>\n );\n};\n"],"names":["QuoteTemplateHistoryLog","initialData","props","templateData","setTemplateData","useState","useEffect","templateDataEvent","events","payload","jsx","QuoteHistoryLogComponent"],"mappings":"mOAmBO,MAAMA,EAAmE,CAAC,CAC/E,aAAcC,EACd,GAAGC,CACL,IAAM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAmDJ,CAAW,EAUtG,OARAK,EAAU,IAAM,CACd,MAAMC,EAAoBC,EAAO,GAAG,uCAAyCC,GAAY,CACvFL,EAAgBK,EAAQ,aAAa,CACvC,EAAG,CAAE,MAAO,GAAM,EAElB,MAAO,IAAMF,GAAA,YAAAA,EAAmB,KAClC,EAAG,CAAA,CAAE,EAEAJ,EAKHO,EAAC,MAAA,CAAK,GAAGR,EACP,SAAAQ,EAACC,EAAA,CACC,QAASR,EAAa,QACtB,MAAOA,EAAa,MACpB,MAAOA,EAAa,MACpB,aAAcA,EAAa,YAAA,CAAA,EAE/B,EAXO,IAaX"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsxs as u,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import{useState as v,useMemo as _}from"@dropins/tools/preact-compat.js";import{classes as n,VComponent as p}from"@dropins/tools/lib.js";/* empty css */const q=({className:s,tabs:a,tabsContent:c,defaultActiveTab:r,...i})=>{const[o,b]=v(r||Array.from(a.keys())[0]),d=e=>{b(e)},m=_(()=>c.get(o),[o,c]);return u("div",{...i,className:n(["quote-management-tabbed-content",s]),children:[a&&t("div",{"data-testid":"tabbed-content-tabs",className:n(["quote-management-tabbed-content__tabs"]),children:Array.from(a.entries()).map(([e,l])=>t("button",{className:n(["quote-management-tabbed-content__tab",["quote-management-tabbed-content__tab--active",e===o]]),onClick:()=>d(e),children:l},e))}),m&&t("div",{className:n(["quote-management-tabbed-content__active-tab-content"]),children:t(p,{node:m})})]})};export{q as T};
|
|
4
|
+
//# sourceMappingURL=TabbedContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabbedContent.js","sources":["/@dropins/storefront-quote-management/src/components/TabbedContent/TabbedContent.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useMemo, useState } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/quote-management/components/TabbedContent/TabbedContent.css';\n\nexport interface TabbedContentProps extends HTMLAttributes<HTMLDivElement> {\n tabs: Map<string, string>;\n tabsContent: Map<string, VNode>;\n defaultActiveTab?: string;\n}\n\nexport const TabbedContent: FunctionComponent<TabbedContentProps> = ({\n className,\n tabs,\n tabsContent,\n defaultActiveTab,\n ...props\n}) => {\n const [activeTabId, setActiveTabId] = useState<string>(\n defaultActiveTab || Array.from(tabs.keys())[0]\n );\n\n const handleTabClick = (tabId: string) => {\n setActiveTabId(tabId);\n };\n\n const activeTabContent = useMemo(() => {\n return tabsContent.get(activeTabId);\n }, [activeTabId, tabsContent]);\n\n return (\n <div {...props} className={classes(['quote-management-tabbed-content', className])}>\n {tabs &&\n <div data-testid=\"tabbed-content-tabs\" className={classes(['quote-management-tabbed-content__tabs'])}>\n {Array.from(tabs.entries()).map(([tabId, tabLabel]) => (\n <button\n className={\n classes([\n 'quote-management-tabbed-content__tab',\n ['quote-management-tabbed-content__tab--active', tabId === activeTabId]\n ])}\n key={tabId}\n onClick={() => handleTabClick(tabId)}\n >\n {tabLabel}\n </button>\n ))}\n </div>\n }\n {\n activeTabContent &&\n <div className={classes(['quote-management-tabbed-content__active-tab-content'])}>\n <VComponent\n node={activeTabContent as VNode}\n />\n </div>\n }\n </div>\n );\n};\n"],"names":["TabbedContent","className","tabs","tabsContent","defaultActiveTab","props","activeTabId","setActiveTabId","useState","handleTabClick","tabId","activeTabContent","useMemo","jsxs","classes","jsx","tabLabel","VComponent"],"mappings":"wPAoBO,MAAMA,EAAuD,CAAC,CACnE,UAAAC,EACA,KAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,GAAGC,CACL,IAAM,CACJ,KAAM,CAACC,EAAaC,CAAc,EAAIC,EACpCJ,GAAoB,MAAM,KAAKF,EAAK,KAAA,CAAM,EAAE,CAAC,CAAA,EAGzCO,EAAkBC,GAAkB,CACxCH,EAAeG,CAAK,CACtB,EAEMC,EAAmBC,EAAQ,IACxBT,EAAY,IAAIG,CAAW,EACjC,CAACA,EAAaH,CAAW,CAAC,EAE7B,OACEU,EAAC,MAAA,CAAK,GAAGR,EAAO,UAAWS,EAAQ,CAAC,kCAAmCb,CAAS,CAAC,EAC9E,SAAA,CAAAC,GACCa,EAAC,OAAI,cAAY,sBAAsB,UAAWD,EAAQ,CAAC,uCAAuC,CAAC,EAChG,eAAM,KAAKZ,EAAK,SAAS,EAAE,IAAI,CAAC,CAACQ,EAAOM,CAAQ,IAC/CD,EAAC,SAAA,CACC,UACED,EAAQ,CACN,uCACA,CAAC,+CAAgDJ,IAAUJ,CAAW,CAAA,CACvE,EAEH,QAAS,IAAMG,EAAeC,CAAK,EAElC,SAAAM,CAAA,EAHIN,CAAA,CAKR,EACH,EAGAC,KACC,MAAA,CAAI,UAAWG,EAAQ,CAAC,qDAAqD,CAAC,EAC7E,SAAAC,EAACE,EAAA,CACC,KAAMN,CAAA,CAAA,CACR,CACF,CAAA,EAEJ,CAEJ"}
|
package/chunks/dateUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
function
|
|
3
|
+
import{getGlobalLocale as r}from"@dropins/tools/lib.js";function o(e){const t=new Date(e);return!isNaN(t.getTime())}function a(e,t="short"){if(!o(e))return"–";const n=r()||"en-US";return t==="short"?new Date(e).toLocaleDateString(n,{year:"numeric",month:"numeric",day:"numeric"}):new Date(e).toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0})}export{a as f};
|
|
4
4
|
//# sourceMappingURL=dateUtils.js.map
|
package/chunks/dateUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.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\n/**\n * Gets the user's timezone with fallback to UTC if detection fails\n * @returns The user's timezone string (e.g., 'America/New_York') or 'UTC' as fallback\n */\
|
|
1
|
+
{"version":3,"file":"dateUtils.js","sources":["/@dropins/storefront-quote-management/src/utils/dateUtils.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\nimport { getGlobalLocale } from \"@adobe-commerce/elsie/lib\";\n\n/**\n * Gets the user's timezone with fallback to UTC if detection fails\n * @returns The user's timezone string (e.g., 'America/New_York') or 'UTC' as fallback\n */\nexport function getUserTimezone(): string {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch (error) {\n console.warn('Failed to detect user timezone, falling back to UTC:', error);\n return 'UTC';\n }\n}\n\n/**\n * Checks if a date string is a valid date\n * @param dateString - The date string to check\n * @returns True if the date string is a valid date, false otherwise\n */\nexport function isValidDate(dateString: string): boolean {\n const date = new Date(dateString);\n return !isNaN(date.getTime());\n}\n\n/**\n * Formats a date string to locale date string, returning \"–\" for invalid dates\n * @param dateString - The date string to format\n * @returns Formatted date string or \"–\" for invalid dates\n */\nexport function formattedDate(dateString: string, type: 'short' | 'long' = 'short'): string {\n if (!isValidDate(dateString)) {\n return '–';\n }\n\n const locale = getGlobalLocale() || 'en-US';\n\n if (type === 'short') {\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n });\n }\n\n return new Date(dateString).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n });\n}\n"],"names":["isValidDate","dateString","date","formattedDate","type","locale","getGlobalLocale"],"mappings":"wDA6BO,SAASA,EAAYC,EAA6B,CACvD,MAAMC,EAAO,IAAI,KAAKD,CAAU,EAChC,MAAO,CAAC,MAAMC,EAAK,SAAS,CAC9B,CAOO,SAASC,EAAcF,EAAoBG,EAAyB,QAAiB,CAC1F,GAAI,CAACJ,EAAYC,CAAU,EACzB,MAAO,IAGT,MAAMI,EAASC,KAAqB,QAEpC,OAAIF,IAAS,QACJ,IAAI,KAAKH,CAAU,EAAE,mBAAmBI,EAAQ,CACrD,KAAM,UACN,MAAO,UACP,IAAK,SAAA,CACN,EAGI,IAAI,KAAKJ,CAAU,EAAE,mBAAmBI,EAAQ,CACrD,KAAM,UACN,MAAO,OACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OAAQ,EAAA,CACT,CACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as y}from"@dropins/tools/event-bus.js";import{
|
|
3
|
+
import{events as y}from"@dropins/tools/event-bus.js";import{t as b,f as E}from"./transform-quote.js";import{s as f}from"./state.js";function P(e){var i,n,o,a,l;return e?{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:e.status,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},comments:(i=e.comments)==null?void 0:i.map(r=>{var c;return{uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text,attachments:(c=r.attachments)==null?void 0:c.map(s=>({name:s.name,url:s.url}))}}),prices:e.prices&&{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},appliedTaxes:(n=e.prices.applied_taxes)==null?void 0:n.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}},history:(o=e.history)==null?void 0:o.map(r=>({uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},changeType:r.change_type,changes:r.changes})),items:((a=e.items)==null?void 0:a.map(r=>{var c,s,_,d,g,p;return{uid:r.uid,product:{uid:r.product.uid,sku:r.product.sku,name:r.product.name},quantity:r.quantity,prices:{originalItemPrice:{value:r.prices.original_item_price.value,currency:r.prices.original_item_price.currency},rowTotal:{value:r.prices.row_total.value,currency:r.prices.row_total.currency}},catalogDiscount:r.prices.catalog_discount&&{amountOff:r.prices.catalog_discount.amount_off,percentOff:r.prices.catalog_discount.percent_off},discounts:(s=(c=r.prices)==null?void 0:c.discounts)==null?void 0:s.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})),noteFromBuyer:(_=r.note_from_buyer)==null?void 0:_.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_template_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(d=r.note_from_seller)==null?void 0:d.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_template_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(g=r.configurable_options)==null?void 0:g.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(p=r.bundle_options)==null?void 0:p.map(t=>({label:t.label,values:t.values.map(u=>({label:u.label,quantity:u.quantity,originalPrice:{value:u.original_price.value,currency:u.original_price.currency},price:{value:u.priceV2.value,currency:u.priceV2.currency}}))}))}}))||[],shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(r=>({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,region:r.region?{code:r.region.code,label:r.region.label,regionId:r.region.region_id}:void 0})),canAccept:["SUBMITTED","PENDING","IN_REVIEW"].includes(e.status),canDelete:["CLOSED","INACTIVE"].includes(e.status),canReopen:e.status==="CLOSED",canCancel:["ACTIVE","IN_REVIEW","SUBMITTED"].includes(e.status),canGenerateQuote:e.status==="ACTIVE"}:null}function T(e){var o;if(!e)return null;const i={items:((o=e.items)==null?void 0:o.map(a=>({id:a.template_id,uid:"TBD",name:a.name,createdAt:"0000-00-00 00:00:00",updatedAt:"0000-00-00 00:00:00",status:a.status,state:a.state,prices:{grandTotal:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:a.min_negotiated_grand_total,currency:"USD"}},lastSharedAt:a.last_shared_at,lastOrderedAt:"0000-00-00 00:00:00",expirationDate:"0000-00-00 00:00:00",ordersPlaced:a.orders_placed})))||[],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=b(i);return{...i,paginationInfo:n||void 0}}const I=`
|
|
4
4
|
query QUOTE_TEMPLATES_QUERY(
|
|
5
5
|
$filter: NegotiableQuoteTemplateFilterInput
|
|
6
6
|
$pageSize: Int
|
|
@@ -46,5 +46,5 @@ import{events as y}from"@dropins/tools/event-bus.js";import{s as f}from"./state.
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
`;var v=(e=>(e.ACTIVE="ACTIVE",e.IN_REVIEW="IN_REVIEW",e.INACTIVE="INACTIVE",e))(v||{}),A=(e=>(e.NAME="NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(A||{}),
|
|
49
|
+
`;var v=(e=>(e.ACTIVE="ACTIVE",e.IN_REVIEW="IN_REVIEW",e.INACTIVE="INACTIVE",e))(v||{}),A=(e=>(e.NAME="NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(A||{}),m=(e=>(e.ASC="ASC",e.DESC="DESC",e))(m||{});const S=async(e={})=>{var i;if(!f.authenticated)throw new Error("Unauthorized");try{const n=await E(I,{variables:{filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null}});if(!((i=n==null?void 0:n.data)!=null&&i.negotiableQuoteTemplates))throw new Error("No quote templates data received");const o=T(n.data.negotiableQuoteTemplates);if(!o)throw new Error("Failed to transform quote templates data");return y.emit("quote-management/quote-templates-data",{quoteTemplates:o,permissions:f.permissions}),o}catch(n){return Promise.reject(n)}};export{v as Q,m as S,A as a,S as g,P as t};
|
|
50
50
|
//# sourceMappingURL=getQuoteTemplates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuoteTemplates.js","sources":["/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/graphql/getQuoteTemplates.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/getQuoteTemplates.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\nimport {\n NegotiableQuoteTemplateModel,\n NegotiableQuoteTemplatesListModel,\n} from '../models/negotiable-quote-template-model';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\n uid: templateData.uid,\n name: templateData.name,\n createdAt: templateData.created_at,\n updatedAt: templateData.updated_at,\n expirationDate: templateData.expiration_date,\n status: templateData.status,\n salesRepName: templateData.sales_rep_name,\n buyer: {\n firstname: templateData.buyer.firstname,\n lastname: templateData.buyer.lastname,\n },\n comments: templateData.comments?.map((comment: 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 attachments: comment.attachments?.map((a: any) => ({\n name: a.name,\n url: a.url,\n })),\n })),\n prices: templateData.prices && {\n subtotalExcludingTax: templateData.prices.subtotal_excluding_tax && {\n value: templateData.prices.subtotal_excluding_tax.value,\n currency: templateData.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: templateData.prices.subtotal_including_tax && {\n value: templateData.prices.subtotal_including_tax.value,\n currency: templateData.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: templateData.prices\n .subtotal_with_discount_excluding_tax && {\n value: templateData.prices.subtotal_with_discount_excluding_tax.value,\n currency:\n templateData.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: templateData.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: templateData.prices.grand_total && {\n value: templateData.prices.grand_total.value,\n currency: templateData.prices.grand_total.currency,\n },\n },\n history: templateData.history?.map((h: any) => ({\n uid: h.uid,\n createdAt: h.created_at,\n author: {\n firstname: h.author.firstname,\n lastname: h.author.lastname,\n },\n changeType: h.change_type,\n changes: h.changes,\n })),\n items: templateData.items?.map((item: any) => ({\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\n quantity: item.quantity,\n prices: {\n originalItemPrice: {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n },\n rowTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n },\n catalogDiscount: item.prices.catalog_discount && {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts: 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 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_template_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_template_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 })) || [],\n shippingAddresses: templateData.shipping_addresses?.map((address: any) => ({\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 region: address.region ? {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n } : undefined,\n })),\n // Calculate permissions based on status\n canAccept: ['SUBMITTED', 'PENDING', 'IN_REVIEW'].includes(templateData.status),\n canDelete: ['CLOSED', 'INACTIVE'].includes(templateData.status),\n canReopen: templateData.status === 'CLOSED',\n canCancel: ['ACTIVE', 'IN_REVIEW', 'SUBMITTED'].includes(templateData.status),\n canGenerateQuote: templateData.status === 'ACTIVE',\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n return {\n items: templatesData.items?.map((template: any) => ({\n id: template.template_id,\n uid: 'TBD',\n name: template.name,\n createdAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n updatedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n status: template.status,\n state: template.state,\n prices: {\n grandTotal: {\n value: 0, // TODO: missing from GraphQL API\n currency: 'USD', // TODO: missing from GraphQL API\n },\n minNegotiatedGrandTotal: {\n value: template.min_negotiated_grand_total,\n currency: 'USD', // TODO: use the same from grand total when available\n },\n },\n lastSharedAt: template.last_shared_at,\n lastOrderedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n expirationDate: '0000-00-00 00:00:00', // TODO: broken in GraphQL API\n ordersPlaced: template.orders_placed,\n })) || [],\n pageInfo: {\n currentPage: templatesData.page_info.current_page,\n pageSize: templatesData.page_info.page_size,\n totalPages: templatesData.page_info.total_pages,\n },\n totalCount: templatesData.total_count,\n sortFields: templatesData.sort_fields ? {\n default: templatesData.sort_fields.default,\n options: templatesData.sort_fields.options,\n } : undefined,\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\nexport const QUOTE_TEMPLATES_QUERY = /* GraphQL */ `\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n # uid\n template_id\n name\n # created_at\n # updated_at\n # last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n # expiration_date\n orders_placed\n # grand_total {\n # currency\n # value\n # }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\n }\n }\n }\n }\n`;\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 { fetchGraphQl } from '@/quote-management/api';\nimport { QUOTE_TEMPLATES_QUERY } from './graphql/getQuoteTemplates';\nimport { transformQuoteTemplatesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplatesListModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QuoteTemplateFilterStatus {\n ACTIVE = 'ACTIVE',\n IN_REVIEW = 'IN_REVIEW',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface QuoteTemplateFilterInput {\n status?: QuoteTemplateFilterStatus[];\n name?: {\n match?: string;\n };\n}\n\nexport enum QuoteTemplateSortField {\n NAME = 'NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface QuoteTemplateSortInput {\n sortField: QuoteTemplateSortField;\n sortDirection: SortDirection;\n}\n\nexport interface GetQuoteTemplatesParams {\n filter?: QuoteTemplateFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: QuoteTemplateSortInput;\n}\n\nexport const getQuoteTemplates = async (\n params: GetQuoteTemplatesParams = {}\n): Promise<NegotiableQuoteTemplatesListModel> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_TEMPLATES_QUERY, {\n variables: {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n },\n });\n\n if (!results?.data?.negotiableQuoteTemplates) {\n throw new Error('No quote templates data received');\n }\n\n const transformedData = transformQuoteTemplatesList(results.data.negotiableQuoteTemplates);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote templates data');\n }\n\n events.emit('quote-management/quote-templates-data', {\n quoteTemplates: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};"],"names":["transformQuoteTemplate","templateData","_a","comment","a","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","transformQuoteTemplatesList","templatesData","template","QUOTE_TEMPLATES_QUERY","QuoteTemplateFilterStatus","QuoteTemplateSortField","SortDirection","getQuoteTemplates","params","state","results","fetchGraphQl","transformedData","events","error"],"mappings":"2HAcO,SAASA,EACZC,EACmC,eACnC,OAAKA,EAIE,CACH,IAAKA,EAAa,IAClB,KAAMA,EAAa,KACnB,UAAWA,EAAa,WACxB,UAAWA,EAAa,WACxB,eAAgBA,EAAa,gBAC7B,OAAQA,EAAa,OACrB,aAAcA,EAAa,eAC3B,MAAO,CACH,UAAWA,EAAa,MAAM,UAC9B,SAAUA,EAAa,MAAM,QAAA,EAEjC,UAAUC,EAAAD,EAAa,WAAb,YAAAC,EAAuB,IAAKC,GAAA,OAAkB,OACpD,IAAKA,EAAQ,IACb,UAAWA,EAAQ,WACnB,OAAQ,CACJ,UAAWA,EAAQ,OAAO,UAC1B,SAAUA,EAAQ,OAAO,QAAA,EAE7B,KAAMA,EAAQ,KACd,aAAaD,EAAAC,EAAQ,c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AASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
1
|
+
{"version":3,"file":"getQuoteTemplates.js","sources":["/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/graphql/getQuoteTemplates.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/getQuoteTemplates.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\nimport {\n NegotiableQuoteTemplateModel,\n NegotiableQuoteTemplatesListModel,\n} from '../models/negotiable-quote-template-model';\nimport { transformPaginationInfo } from './transform-quote';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\n uid: templateData.uid,\n name: templateData.name,\n createdAt: templateData.created_at,\n updatedAt: templateData.updated_at,\n expirationDate: templateData.expiration_date,\n status: templateData.status,\n salesRepName: templateData.sales_rep_name,\n buyer: {\n firstname: templateData.buyer.firstname,\n lastname: templateData.buyer.lastname,\n },\n comments: templateData.comments?.map((comment: 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 attachments: comment.attachments?.map((a: any) => ({\n name: a.name,\n url: a.url,\n })),\n })),\n prices: templateData.prices && {\n subtotalExcludingTax: templateData.prices.subtotal_excluding_tax && {\n value: templateData.prices.subtotal_excluding_tax.value,\n currency: templateData.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: templateData.prices.subtotal_including_tax && {\n value: templateData.prices.subtotal_including_tax.value,\n currency: templateData.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: templateData.prices\n .subtotal_with_discount_excluding_tax && {\n value: templateData.prices.subtotal_with_discount_excluding_tax.value,\n currency:\n templateData.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: templateData.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: templateData.prices.grand_total && {\n value: templateData.prices.grand_total.value,\n currency: templateData.prices.grand_total.currency,\n },\n },\n history: templateData.history?.map((h: any) => ({\n uid: h.uid,\n createdAt: h.created_at,\n author: {\n firstname: h.author.firstname,\n lastname: h.author.lastname,\n },\n changeType: h.change_type,\n changes: h.changes,\n })),\n items: templateData.items?.map((item: any) => ({\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\n quantity: item.quantity,\n prices: {\n originalItemPrice: {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n },\n rowTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n },\n catalogDiscount: item.prices.catalog_discount && {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts: 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 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_template_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_template_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 })) || [],\n shippingAddresses: templateData.shipping_addresses?.map((address: any) => ({\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 region: address.region ? {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n } : undefined,\n })),\n // Calculate permissions based on status\n canAccept: ['SUBMITTED', 'PENDING', 'IN_REVIEW'].includes(templateData.status),\n canDelete: ['CLOSED', 'INACTIVE'].includes(templateData.status),\n canReopen: templateData.status === 'CLOSED',\n canCancel: ['ACTIVE', 'IN_REVIEW', 'SUBMITTED'].includes(templateData.status),\n canGenerateQuote: templateData.status === 'ACTIVE',\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n const transformedModel = {\n items: templatesData.items?.map((template: any) => ({\n id: template.template_id,\n uid: 'TBD',\n name: template.name,\n createdAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n updatedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n status: template.status,\n state: template.state,\n prices: {\n grandTotal: {\n value: 0, // TODO: missing from GraphQL API\n currency: 'USD', // TODO: missing from GraphQL API\n },\n minNegotiatedGrandTotal: {\n value: template.min_negotiated_grand_total,\n currency: 'USD', // TODO: use the same from grand total when available\n },\n },\n lastSharedAt: template.last_shared_at,\n lastOrderedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n expirationDate: '0000-00-00 00:00:00', // TODO: broken in GraphQL API\n ordersPlaced: template.orders_placed,\n })) || [],\n pageInfo: {\n currentPage: templatesData.page_info.current_page,\n pageSize: templatesData.page_info.page_size,\n totalPages: templatesData.page_info.total_pages,\n },\n totalCount: templatesData.total_count,\n sortFields: templatesData.sort_fields ? {\n default: templatesData.sort_fields.default,\n options: templatesData.sort_fields.options,\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 * 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 const QUOTE_TEMPLATES_QUERY = /* GraphQL */ `\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n # uid\n template_id\n name\n # created_at\n # updated_at\n # last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n # expiration_date\n orders_placed\n # grand_total {\n # currency\n # value\n # }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\n }\n }\n }\n }\n`;\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 { fetchGraphQl } from '@/quote-management/api';\nimport { QUOTE_TEMPLATES_QUERY } from './graphql/getQuoteTemplates';\nimport { transformQuoteTemplatesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplatesListModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QuoteTemplateFilterStatus {\n ACTIVE = 'ACTIVE',\n IN_REVIEW = 'IN_REVIEW',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface QuoteTemplateFilterInput {\n status?: QuoteTemplateFilterStatus[];\n name?: {\n match?: string;\n };\n}\n\nexport enum QuoteTemplateSortField {\n NAME = 'NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface QuoteTemplateSortInput {\n sortField: QuoteTemplateSortField;\n sortDirection: SortDirection;\n}\n\nexport interface GetQuoteTemplatesParams {\n filter?: QuoteTemplateFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: QuoteTemplateSortInput;\n}\n\nexport const getQuoteTemplates = async (\n params: GetQuoteTemplatesParams = {}\n): Promise<NegotiableQuoteTemplatesListModel> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_TEMPLATES_QUERY, {\n variables: {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n },\n });\n\n if (!results?.data?.negotiableQuoteTemplates) {\n throw new Error('No quote templates data received');\n }\n\n const transformedData = transformQuoteTemplatesList(results.data.negotiableQuoteTemplates);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote templates data');\n }\n\n events.emit('quote-management/quote-templates-data', {\n quoteTemplates: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};"],"names":["transformQuoteTemplate","templateData","_a","comment","a","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","transformQuoteTemplatesList","templatesData","transformedModel","template","paginationInfo","transformPaginationInfo","QUOTE_TEMPLATES_QUERY","QuoteTemplateFilterStatus","QuoteTemplateSortField","SortDirection","getQuoteTemplates","params","state","results","fetchGraphQl","transformedData","events","error"],"mappings":"oIAeO,SAASA,EACZC,EACmC,eACnC,OAAKA,EAIE,CACH,IAAKA,EAAa,IAClB,KAAMA,EAAa,KACnB,UAAWA,EAAa,WACxB,UAAWA,EAAa,WACx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MAAMC,EAAe,MAAMC,EAAaR,EAAuB,CAC7D,UAAW,CACT,OAAQK,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,CACvB,CACD,EAED,GAAI,GAAC3B,EAAA6B,GAAA,YAAAA,EAAS,OAAT,MAAA7B,EAAe,0BAClB,MAAM,IAAI,MAAM,kCAAkC,EAGpD,MAAM+B,EAAkBf,EAA4Ba,EAAQ,KAAK,wBAAwB,EAEzF,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0CAA0C,EAG5D,OAAAC,EAAO,KAAK,wCAAyC,CACnD,eAAgBD,EAChB,YAAaH,EAAM,WAAA,CACpB,EAEMG,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import"@dropins/tools/event-bus.js";import{f as n,
|
|
3
|
+
import"@dropins/tools/event-bus.js";import{f as n,b as s}from"./transform-quote.js";import{s as i}from"./state.js";const u=`
|
|
4
4
|
fragment NegotiableQuoteListFragment on NegotiableQuote {
|
|
5
5
|
uid
|
|
6
6
|
name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negotiableQuotes.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/NegotiableQuoteListFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SearchResultPageInfoFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SortFieldsFragment.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/graphql/NegotiableQuotesQuery.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/negotiableQuotes.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 const NEGOTIABLE_QUOTE_LIST_FRAGMENT = /* GraphQL */ `\n fragment NegotiableQuoteListFragment on NegotiableQuote {\n uid\n name\n created_at\n updated_at\n status\n buyer {\n firstname\n lastname\n }\n template_name\n prices {\n grand_total {\n value\n currency\n }\n }\n history {\n change_type\n changes {\n statuses {\n changes {\n new_status\n old_status\n }\n }\n }\n }\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\nexport const SEARCH_RESULT_PAGE_INFO_FRAGMENT = /* GraphQL */ `\n fragment SearchResultPageInfoFragment on SearchResultPageInfo {\n current_page\n page_size\n total_pages\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\nexport const SORT_FIELDS_FRAGMENT = /* GraphQL */ `\n fragment SortFieldsFragment on SortFields {\n default\n options {\n label\n value\n }\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 { NEGOTIABLE_QUOTE_LIST_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteListFragment';\nimport { SEARCH_RESULT_PAGE_INFO_FRAGMENT } from '@/quote-management/api/graphql/SearchResultPageInfoFragment';\nimport { SORT_FIELDS_FRAGMENT } from '@/quote-management/api/graphql/SortFieldsFragment';\n\nexport const NEGOTIABLE_QUOTES_QUERY = /* GraphQL */ `\n query negotiableQuotes(\n $filter: NegotiableQuoteFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteSortInput\n ) {\n negotiableQuotes(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n ...NegotiableQuoteListFragment\n }\n page_info {\n ...SearchResultPageInfoFragment\n }\n sort_fields {\n ...SortFieldsFragment\n }\n total_count\n }\n }\n\n ${NEGOTIABLE_QUOTE_LIST_FRAGMENT}\n ${SEARCH_RESULT_PAGE_INFO_FRAGMENT}\n ${SORT_FIELDS_FRAGMENT}\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 { fetchGraphQl } from '@/quote-management/api';\nimport { NEGOTIABLE_QUOTES_QUERY } from './graphql/NegotiableQuotesQuery';\nimport { transformNegotiableQuotesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuotesListModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\nexport enum FilterMatchTypeEnum {\n FULL = 'FULL',\n PARTIAL = 'PARTIAL',\n}\n\nexport interface FilterEqualTypeInput {\n eq?: string;\n in?: string[];\n}\n\nexport interface FilterMatchTypeInput {\n match?: string;\n match_type?: FilterMatchTypeEnum;\n}\n\nexport interface NegotiableQuoteFilterInput {\n ids?: FilterEqualTypeInput;\n name?: FilterMatchTypeInput;\n}\n\nexport enum SortEnum {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport enum NegotiableQuoteSortableField {\n QUOTE_NAME = 'QUOTE_NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport interface NegotiableQuoteSortInput {\n sort_direction: SortEnum;\n sort_field: NegotiableQuoteSortableField;\n}\n\nexport interface NegotiableQuotesParams {\n filter?: NegotiableQuoteFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: NegotiableQuoteSortInput;\n}\n\nexport const negotiableQuotes = async (\n params: NegotiableQuotesParams = {}\n): Promise<NegotiableQuotesListModel> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const variables = {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n };\n\n try {\n const results: any = await fetchGraphQl(NEGOTIABLE_QUOTES_QUERY, {\n variables,\n });\n\n if (!results?.data?.negotiableQuotes) {\n throw new Error('No quotes data received');\n }\n\n const transformedData = transformNegotiableQuotesList(\n results.data.negotiableQuotes\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quotes data');\n }\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["NEGOTIABLE_QUOTE_LIST_FRAGMENT","SEARCH_RESULT_PAGE_INFO_FRAGMENT","SORT_FIELDS_FRAGMENT","NEGOTIABLE_QUOTES_QUERY","FilterMatchTypeEnum","SortEnum","NegotiableQuoteSortableField","negotiableQuotes","params","state","variables","results","fetchGraphQl","_a","transformedData","transformNegotiableQuotesList","error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"negotiableQuotes.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/NegotiableQuoteListFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SearchResultPageInfoFragment.ts","/@dropins/storefront-quote-management/src/api/graphql/SortFieldsFragment.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/graphql/NegotiableQuotesQuery.ts","/@dropins/storefront-quote-management/src/api/negotiableQuotes/negotiableQuotes.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 const NEGOTIABLE_QUOTE_LIST_FRAGMENT = /* GraphQL */ `\n fragment NegotiableQuoteListFragment on NegotiableQuote {\n uid\n name\n created_at\n updated_at\n status\n buyer {\n firstname\n lastname\n }\n template_name\n prices {\n grand_total {\n value\n currency\n }\n }\n history {\n change_type\n changes {\n statuses {\n changes {\n new_status\n old_status\n }\n }\n }\n }\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\nexport const SEARCH_RESULT_PAGE_INFO_FRAGMENT = /* GraphQL */ `\n fragment SearchResultPageInfoFragment on SearchResultPageInfo {\n current_page\n page_size\n total_pages\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\nexport const SORT_FIELDS_FRAGMENT = /* GraphQL */ `\n fragment SortFieldsFragment on SortFields {\n default\n options {\n label\n value\n }\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 { NEGOTIABLE_QUOTE_LIST_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteListFragment';\nimport { SEARCH_RESULT_PAGE_INFO_FRAGMENT } from '@/quote-management/api/graphql/SearchResultPageInfoFragment';\nimport { SORT_FIELDS_FRAGMENT } from '@/quote-management/api/graphql/SortFieldsFragment';\n\nexport const NEGOTIABLE_QUOTES_QUERY = /* GraphQL */ `\n query negotiableQuotes(\n $filter: NegotiableQuoteFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteSortInput\n ) {\n negotiableQuotes(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n ...NegotiableQuoteListFragment\n }\n page_info {\n ...SearchResultPageInfoFragment\n }\n sort_fields {\n ...SortFieldsFragment\n }\n total_count\n }\n }\n\n ${NEGOTIABLE_QUOTE_LIST_FRAGMENT}\n ${SEARCH_RESULT_PAGE_INFO_FRAGMENT}\n ${SORT_FIELDS_FRAGMENT}\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 { fetchGraphQl } from '@/quote-management/api';\nimport { NEGOTIABLE_QUOTES_QUERY } from './graphql/NegotiableQuotesQuery';\nimport { transformNegotiableQuotesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuotesListModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\nexport enum FilterMatchTypeEnum {\n FULL = 'FULL',\n PARTIAL = 'PARTIAL',\n}\n\nexport interface FilterEqualTypeInput {\n eq?: string;\n in?: string[];\n}\n\nexport interface FilterMatchTypeInput {\n match?: string;\n match_type?: FilterMatchTypeEnum;\n}\n\nexport interface NegotiableQuoteFilterInput {\n ids?: FilterEqualTypeInput;\n name?: FilterMatchTypeInput;\n}\n\nexport enum SortEnum {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport enum NegotiableQuoteSortableField {\n QUOTE_NAME = 'QUOTE_NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport interface NegotiableQuoteSortInput {\n sort_direction: SortEnum;\n sort_field: NegotiableQuoteSortableField;\n}\n\nexport interface NegotiableQuotesParams {\n filter?: NegotiableQuoteFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: NegotiableQuoteSortInput;\n}\n\nexport const negotiableQuotes = async (\n params: NegotiableQuotesParams = {}\n): Promise<NegotiableQuotesListModel> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const variables = {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n };\n\n try {\n const results: any = await fetchGraphQl(NEGOTIABLE_QUOTES_QUERY, {\n variables,\n });\n\n if (!results?.data?.negotiableQuotes) {\n throw new Error('No quotes data received');\n }\n\n const transformedData = transformNegotiableQuotesList(\n results.data.negotiableQuotes\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quotes data');\n }\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["NEGOTIABLE_QUOTE_LIST_FRAGMENT","SEARCH_RESULT_PAGE_INFO_FRAGMENT","SORT_FIELDS_FRAGMENT","NEGOTIABLE_QUOTES_QUERY","FilterMatchTypeEnum","SortEnum","NegotiableQuoteSortableField","negotiableQuotes","params","state","variables","results","fetchGraphQl","_a","transformedData","transformNegotiableQuotesList","error"],"mappings":"mHASO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECA/CC,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECAjDC,EAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECIrCC,EAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA0BjDH,CAA8B;AAAA,IAC9BC,CAAgC;AAAA,IAChCC,CAAoB;AAAA,EC1BjB,IAAKE,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UAFAA,IAAAA,GAAA,CAAA,CAAA,EAoBAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAkBL,MAAMC,EAAmB,MAC9BC,EAAiC,KACM,OACvC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,MAAMC,EAAY,CAChB,OAAQF,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,EAGvB,GAAI,CACF,MAAMG,EAAe,MAAMC,EAAaT,EAAyB,CAC/D,UAAAO,CAAA,CACD,EAED,GAAI,GAACG,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,kBAClB,MAAM,IAAI,MAAM,yBAAyB,EAG3C,MAAMC,EAAkBC,EACtBJ,EAAQ,KAAK,gBAAA,EAGf,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as q}from"@dropins/tools/event-bus.js";import{f as d,
|
|
3
|
+
import{events as q}from"@dropins/tools/event-bus.js";import{f as d,a as I}from"./transform-quote.js";import{s as E}from"./state.js";import{N as U}from"./NegotiableQuoteFragment.js";const T=`
|
|
4
4
|
mutation UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION(
|
|
5
5
|
$quoteUid: ID!
|
|
6
6
|
$items: [NegotiableQuoteItemQuantityInput!]!
|
|
@@ -17,7 +17,7 @@ import{events as q}from"@dropins/tools/event-bus.js";import{f as d,t as I}from".
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
${U}
|
|
20
|
-
`,Q=async
|
|
20
|
+
`,Q=async u=>{if(!E.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUid:r,items:e}=u;if(!r)throw new Error("Quote UID is required");if(!e||!Array.isArray(e)||e.length===0)throw new Error("Items array is required and must not be empty");for(const t of e){if(!t.quoteItemUid)throw new Error("Each item must have a quoteItemUid");if(typeof t.quantity!="number"||t.quantity<=0)throw new Error(`Invalid quantity for item ${t.quoteItemUid}: quantity must be a positive number`);if(!Number.isInteger(t.quantity))throw new Error(`Invalid quantity for item ${t.quoteItemUid}: quantity must be an integer`)}const s=e.map(t=>({quote_item_uid:t.quoteItemUid,quantity:t.quantity}));return d(T,{variables:{quoteUid:r,items:s}}).then(t=>{var a,n;const{errors:i}=t;if(i){const m=i.map(f=>f.message).join("; ");throw new Error(`Failed to update quote quantities: ${m}`)}const o=I((n=(a=t.data)==null?void 0:a.updateNegotiableQuoteQuantities)==null?void 0:n.quote);if(!o)throw new Error("Failed to transform quote data: Invalid response structure");return q.emit("quote-management/quantities-updated",{quote:o,input:{quoteUid:r,items:e}}),o})},c=`
|
|
21
21
|
mutation REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION(
|
|
22
22
|
$quoteUid: ID!
|
|
23
23
|
$quoteItemUids: [ID!]!
|
|
@@ -34,5 +34,5 @@ import{events as q}from"@dropins/tools/event-bus.js";import{f as d,t as I}from".
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
${U}
|
|
37
|
-
`,g=async
|
|
37
|
+
`,g=async u=>{var a;if(!E.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUid:r,quoteItemUids:e}=u;if(!r)throw new Error("Quote UID is required");if(!Array.isArray(e)||e.length===0)throw new Error("At least one quote item UID is required");const s=await d(c,{variables:{quoteUid:r,quoteItemUids:e}}),{errors:t,data:i}=s;if(t!=null&&t.length){const n=t.map(m=>m.message).join("; ");throw new Error(`Failed to remove negotiable quote items: ${n}`)}const o=I((a=i==null?void 0:i.removeNegotiableQuoteItems)==null?void 0:a.quote);if(!o)throw new Error("Failed to transform quote data: Invalid response structure");return q.emit("quote-management/quote-items-removed",{quote:o,removedItemUids:e,input:u}),o};export{g as r,Q as u};
|
|
38
38
|
//# sourceMappingURL=removeNegotiableQuoteItems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeNegotiableQuoteItems.js","sources":["/@dropins/storefront-quote-management/src/api/updateQuantities/graphql/UpdateNegotiableQuoteQuantitiesMutation.ts","/@dropins/storefront-quote-management/src/api/updateQuantities/updateQuantities.ts","/@dropins/storefront-quote-management/src/api/removeNegotiableQuoteItems/graphql/RemoveNegotiableQuoteItemsMutation.ts","/@dropins/storefront-quote-management/src/api/removeNegotiableQuoteItems/removeNegotiableQuoteItems.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\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION = `\n mutation UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION(\n $quoteUid: ID!\n $items: [NegotiableQuoteItemQuantityInput!]!\n ) {\n updateNegotiableQuoteQuantities(\n input: {\n quote_uid: $quoteUid\n items: $items\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/quote-management/lib/state';\nimport { UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION } from './graphql/UpdateNegotiableQuoteQuantitiesMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface QuantityItem {\n /** The unique ID of the quote item */\n quoteItemUid: string;\n /** The new quantity for the item (must be greater than 0) */\n quantity: number;\n}\n\nexport interface UpdateQuantitiesInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** Array of items with their new quantities */\n items: QuantityItem[];\n}\n\n/**\n * Updates the quantities of items in a negotiable quote.\n *\n * @param input - The input parameters for updating quantities\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.items - Array of items with their new quantities\n * @returns Promise that resolves to the updated quote model\n * @throws Error if validation fails or GraphQL operation fails\n *\n * @example\n * ```ts\n * const quote = await updateQuantities({\n * quoteUid: 'quote-123',\n * items: [\n * { quoteItemUid: 'item-1', quantity: 5 },\n * { quoteItemUid: 'item-2', quantity: 3 }\n * ]\n * });\n * ```\n */\nexport const updateQuantities = async (\n input: UpdateQuantitiesInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUid, items } = input;\n\n // Validate quoteUid\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate items array\n if (!items || !Array.isArray(items) || items.length === 0) {\n throw new Error('Items array is required and must not be empty');\n }\n\n // Validate each item\n for (const item of items) {\n if (!item.quoteItemUid) {\n throw new Error('Each item must have a quoteItemUid');\n }\n if (typeof item.quantity !== 'number' || item.quantity <= 0) {\n throw new Error(\n `Invalid quantity for item ${item.quoteItemUid}: quantity must be a positive number`\n );\n }\n // Ensure quantity is an integer\n if (!Number.isInteger(item.quantity)) {\n throw new Error(\n `Invalid quantity for item ${item.quoteItemUid}: quantity must be an integer`\n );\n }\n }\n\n // Transform items to snake_case for GraphQL\n const transformedItems = items.map((item) => ({\n quote_item_uid: item.quoteItemUid,\n quantity: item.quantity,\n }));\n\n return fetchGraphQl(UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION, {\n variables: {\n quoteUid,\n items: transformedItems,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to update quote quantities: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.updateNegotiableQuoteQuantities?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/quantities-updated', {\n quote: quoteData,\n input: { quoteUid, items },\n });\n\n return quoteData;\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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION = `\n mutation REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION(\n $quoteUid: ID!\n $quoteItemUids: [ID!]!\n ) {\n removeNegotiableQuoteItems(\n input: {\n quote_uid: $quoteUid\n quote_item_uids: $quoteItemUids\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/quote-management/lib/state';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION } from './graphql/RemoveNegotiableQuoteItemsMutation';\n\nexport interface RemoveNegotiableQuoteItemsInput {\n quoteUid: string;\n quoteItemUids: string[];\n}\n\nexport const removeNegotiableQuoteItems = async (\n input: RemoveNegotiableQuoteItemsInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUid, quoteItemUids } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!Array.isArray(quoteItemUids) || quoteItemUids.length === 0) {\n throw new Error('At least one quote item UID is required');\n }\n\n const response = await fetchGraphQl(REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION, {\n variables: {\n quoteUid,\n quoteItemUids,\n },\n });\n\n const { errors, data } = response;\n\n if (errors?.length) {\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(\n `Failed to remove negotiable quote items: ${errorMessages}`\n );\n }\n\n const quote = transformQuote(data?.removeNegotiableQuoteItems?.quote);\n\n if (!quote) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n events.emit('quote-management/quote-items-removed', {\n quote,\n removedItemUids: quoteItemUids,\n input,\n });\n\n return quote;\n};\n"],"names":["UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","updateQuantities","input","state","quoteUid","items","item","transformedItems","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","_b","_a","events","REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION","removeNegotiableQuoteItems","quoteItemUids","data","quote"],"mappings":"mLAWO,MAAMA,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBvDC,CAAyB;AAAA,ECuBhBC,EAAmB,MAC9BC,GACyC,CACzC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,KAAM,CAAE,SAAAC,EAAU,MAAAC,CAAA,EAAUH,EAG5B,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,uBAAuB,E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AO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,KAAM,CAAE,SAAAC,EAAU,cAAAgB,CAAA,EAAkBlB,EAEpC,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,uBAAuB,EAGzC,GAAI,CAAC,MAAM,QAAQgB,CAAa,GAAKA,EAAc,SAAW,EAC5D,MAAM,IAAI,MAAM,yCAAyC,EAG3D,MAAMX,EAAW,MAAMD,EAAaU,EAAwC,CAC1E,UAAW,CACT,SAAAd,EACA,cAAAgB,CAAA,CACF,CACD,EAEK,CAAE,OAAAV,EAAQ,KAAAW,CAAA,EAASZ,EAEzB,GAAIC,GAAA,MAAAA,EAAQ,OAAQ,CAClB,MAAMC,EAAgBD,EAAO,IAAKE,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MACR,4CAA4CD,CAAa,EAAA,CAE7D,CAEA,MAAMW,EAAQR,GAAeE,EAAAK,GAAA,YAAAA,EAAM,6BAAN,YAAAL,EAAkC,KAAK,EAEpE,GAAI,CAACM,EACH,MAAM,IAAI,MACR,4DAAA,EAIJ,OAAAL,EAAO,KAAK,uCAAwC,CAClD,MAAAK,EACA,gBAAiBF,EACjB,MAAAlB,CAAA,CACD,EAEMoB,CACT"}
|
|
1
|
+
{"version":3,"file":"removeNegotiableQuoteItems.js","sources":["/@dropins/storefront-quote-management/src/api/updateQuantities/graphql/UpdateNegotiableQuoteQuantitiesMutation.ts","/@dropins/storefront-quote-management/src/api/updateQuantities/updateQuantities.ts","/@dropins/storefront-quote-management/src/api/removeNegotiableQuoteItems/graphql/RemoveNegotiableQuoteItemsMutation.ts","/@dropins/storefront-quote-management/src/api/removeNegotiableQuoteItems/removeNegotiableQuoteItems.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\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION = `\n mutation UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION(\n $quoteUid: ID!\n $items: [NegotiableQuoteItemQuantityInput!]!\n ) {\n updateNegotiableQuoteQuantities(\n input: {\n quote_uid: $quoteUid\n items: $items\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/quote-management/lib/state';\nimport { UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION } from './graphql/UpdateNegotiableQuoteQuantitiesMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface QuantityItem {\n /** The unique ID of the quote item */\n quoteItemUid: string;\n /** The new quantity for the item (must be greater than 0) */\n quantity: number;\n}\n\nexport interface UpdateQuantitiesInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** Array of items with their new quantities */\n items: QuantityItem[];\n}\n\n/**\n * Updates the quantities of items in a negotiable quote.\n *\n * @param input - The input parameters for updating quantities\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.items - Array of items with their new quantities\n * @returns Promise that resolves to the updated quote model\n * @throws Error if validation fails or GraphQL operation fails\n *\n * @example\n * ```ts\n * const quote = await updateQuantities({\n * quoteUid: 'quote-123',\n * items: [\n * { quoteItemUid: 'item-1', quantity: 5 },\n * { quoteItemUid: 'item-2', quantity: 3 }\n * ]\n * });\n * ```\n */\nexport const updateQuantities = async (\n input: UpdateQuantitiesInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUid, items } = input;\n\n // Validate quoteUid\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate items array\n if (!items || !Array.isArray(items) || items.length === 0) {\n throw new Error('Items array is required and must not be empty');\n }\n\n // Validate each item\n for (const item of items) {\n if (!item.quoteItemUid) {\n throw new Error('Each item must have a quoteItemUid');\n }\n if (typeof item.quantity !== 'number' || item.quantity <= 0) {\n throw new Error(\n `Invalid quantity for item ${item.quoteItemUid}: quantity must be a positive number`\n );\n }\n // Ensure quantity is an integer\n if (!Number.isInteger(item.quantity)) {\n throw new Error(\n `Invalid quantity for item ${item.quoteItemUid}: quantity must be an integer`\n );\n }\n }\n\n // Transform items to snake_case for GraphQL\n const transformedItems = items.map((item) => ({\n quote_item_uid: item.quoteItemUid,\n quantity: item.quantity,\n }));\n\n return fetchGraphQl(UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION, {\n variables: {\n quoteUid,\n items: transformedItems,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to update quote quantities: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.updateNegotiableQuoteQuantities?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/quantities-updated', {\n quote: quoteData,\n input: { quoteUid, items },\n });\n\n return quoteData;\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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION = `\n mutation REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION(\n $quoteUid: ID!\n $quoteItemUids: [ID!]!\n ) {\n removeNegotiableQuoteItems(\n input: {\n quote_uid: $quoteUid\n quote_item_uids: $quoteItemUids\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/quote-management/lib/state';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION } from './graphql/RemoveNegotiableQuoteItemsMutation';\n\nexport interface RemoveNegotiableQuoteItemsInput {\n quoteUid: string;\n quoteItemUids: string[];\n}\n\nexport const removeNegotiableQuoteItems = async (\n input: RemoveNegotiableQuoteItemsInput\n): Promise<NegotiableQuoteModel | null> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUid, quoteItemUids } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!Array.isArray(quoteItemUids) || quoteItemUids.length === 0) {\n throw new Error('At least one quote item UID is required');\n }\n\n const response = await fetchGraphQl(REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION, {\n variables: {\n quoteUid,\n quoteItemUids,\n },\n });\n\n const { errors, data } = response;\n\n if (errors?.length) {\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(\n `Failed to remove negotiable quote items: ${errorMessages}`\n );\n }\n\n const quote = transformQuote(data?.removeNegotiableQuoteItems?.quote);\n\n if (!quote) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n events.emit('quote-management/quote-items-removed', {\n quote,\n removedItemUids: quoteItemUids,\n input,\n });\n\n return quote;\n};\n"],"names":["UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","updateQuantities","input","state","quoteUid","items","item","transformedItems","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","_b","_a","events","REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION","removeNegotiableQuoteItems","quoteItemUids","data","quote"],"mappings":"qLAWO,MAAMA,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBvDC,CAAyB;AAAA,ECuBhBC,EAAmB,MAC9BC,GACyC,CACzC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,KAAM,CAAE,SAAAC,EAAU,MAAAC,CAAA,EAAUH,EAG5B,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,uBAAuB,EAIzC,GAAI,CAACC,GAAS,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,SAAW,EACtD,MAAM,IAAI,MAAM,+CAA+C,EAIjE,UAAWC,KAAQD,EAAO,CACxB,GAAI,CAACC,EAAK,aACR,MAAM,IAAI,MAAM,oCAAoC,EAEtD,GAAI,OAAOA,EAAK,UAAa,UAAYA,EAAK,UAAY,EACxD,MAAM,IAAI,MACR,6BAA6BA,EAAK,YAAY,sCAAA,EAIlD,GAAI,CAAC,OAAO,UAAUA,EAAK,QAAQ,EACjC,MAAM,IAAI,MACR,6BAA6BA,EAAK,YAAY,+BAAA,CAGpD,CAGA,MAAMC,EAAmBF,EAAM,IAAKC,IAAU,CAC5C,eAAgBA,EAAK,aACrB,SAAUA,EAAK,QAAA,EACf,EAEF,O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IAAI,EACpE,MAAM,IAAI,MACR,4CAA4CD,CAAa,EAAA,CAE7D,CAEA,MAAMW,EAAQR,GAAeE,EAAAK,GAAA,YAAAA,EAAM,6BAAN,YAAAL,EAAkC,KAAK,EAEpE,GAAI,CAACM,EACH,MAAM,IAAI,MACR,4DAAA,EAIJ,OAAAL,EAAO,KAAK,uCAAwC,CAClD,MAAAK,EACA,gBAAiBF,EACjB,MAAAlB,CAAA,CACD,EAEMoB,CACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as _}from"@dropins/tools/event-bus.js";import{f as g,
|
|
3
|
+
import{events as _}from"@dropins/tools/event-bus.js";import{f as g,a as q}from"./transform-quote.js";import{N as E}from"./NegotiableQuoteFragment.js";import{s as p}from"./state.js";const Q=`
|
|
4
4
|
query QUOTE_DATA_QUERY(
|
|
5
5
|
$quoteId: ID!
|
|
6
6
|
) {
|