@dropins/storefront-quote-management 0.0.1-alpha17 → 0.0.1-alpha18
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/deleteQuote/deleteQuote.d.ts +28 -0
- package/api/deleteQuote/graphql/DeleteQuoteMutation.d.ts +10 -0
- package/api/deleteQuote/index.d.ts +10 -0
- package/api/graphql/NegotiableQuoteAddressFragment.d.ts +10 -0
- package/api/graphql/NegotiableQuoteFragment.d.ts +1 -1
- package/api/graphql/ShippingMethodFragment.d.ts +10 -0
- package/api/index.d.ts +1 -0
- package/api.js +3 -3
- package/api.js.map +1 -1
- package/chunks/NegotiableQuoteFragment.js +74 -26
- package/chunks/NegotiableQuoteFragment.js.map +1 -1
- package/chunks/OrderSummaryLine.js +4 -0
- package/chunks/OrderSummaryLine.js.map +1 -0
- package/chunks/WarningFilled.js +1 -1
- package/chunks/WarningFilled.js.map +1 -1
- package/chunks/fetch-graphql.js +1 -1
- package/chunks/fetch-graphql.js.map +1 -1
- package/chunks/negotiableQuotes.js +2 -2
- package/chunks/negotiableQuotes.js.map +1 -1
- package/chunks/sendForReview.js +35 -3
- package/chunks/sendForReview.js.map +1 -1
- package/chunks/state.js +4 -0
- package/chunks/state.js.map +1 -0
- package/chunks/uploadFile.js +3 -3
- package/chunks/uploadFile.js.map +1 -1
- package/components/ConfirmationModal/ConfirmationModal.d.ts +16 -0
- package/components/ConfirmationModal/index.d.ts +11 -0
- package/components/OrderSummary/OrderSummary.d.ts +7 -26
- package/components/index.d.ts +1 -0
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/OrderSummary/OrderSummary.d.ts +11 -0
- package/containers/OrderSummary/index.d.ts +11 -0
- package/containers/OrderSummary.d.ts +3 -0
- package/containers/OrderSummary.js +4 -0
- package/containers/OrderSummary.js.map +1 -0
- package/containers/OrderSummaryLine/OrderSummaryLine.d.ts +14 -0
- package/containers/OrderSummaryLine/index.d.ts +11 -0
- package/containers/OrderSummaryLine.d.ts +3 -0
- package/containers/OrderSummaryLine.js +4 -0
- package/containers/OrderSummaryLine.js.map +1 -0
- 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 +14 -4
- package/data/models/index.d.ts +9 -0
- package/data/models/negotiable-quote-model.d.ts +30 -5
- package/data/models/store-config-model.d.ts +24 -0
- package/data/transforms/__fixtures__/negotiableQuoteData.d.ts +55 -0
- package/data/transforms/transform-quote.d.ts +8 -0
- package/i18n/en_US.json.d.ts +28 -0
- package/lib/state.d.ts +2 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/render.js.map +1 -1
- package/types/state.types.d.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-graphql.js","sources":["/@dropins/storefront-quote-management/src/lib/state.ts","/@dropins/storefront-quote-management/src/data/models/negotiable-quote-model.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote.ts","/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.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 { State } from '../types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n}\n\n// Proxy state to make it reactive\nexport const state = new Proxy(_state, {\n get: (target, key) => {\n return target[key as keyof State];\n },\n set: (target, key, value) => {\n target[key as keyof State] = value;\n return true;\n }\n})","export interface ShippingAddress {\n /**\n * The unique string identifier of the address\n */\n uid?: string;\n firstname: string;\n lastname: string;\n company?: string;\n street: string[];\n city: string;\n region?: {\n code: string;\n label: string;\n regionId: number;\n };\n postcode: string;\n country: {\n code: string;\n label: string;\n };\n telephone: string;\n}\n\nexport interface NegotiableQuoteModel {\n uid: string;\n name: string;\n createdAt: string;\n salesRepName: string;\n expirationDate: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName?: string;\n comments?: {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n }[];\n history?: NegotiableQuoteHistoryEntry[];\n prices: {\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n grandTotal?: Currency;\n appliedTaxes?: {\n amount: Currency;\n label: string;\n }[];\n };\n items: NegotiableQuoteCartItem[];\n shippingAddresses?: ShippingAddress[];\n canCheckout: boolean;\n canSendForReview: boolean;\n}\n\nexport interface NegotiableQuoteCartItem {\n product: {\n uid: string;\n sku: string;\n name: string;\n templateId?: string;\n templateName?: string;\n priceRange: {\n maximumPrice: {\n regularPrice: {\n value: number;\n };\n };\n };\n };\n catalogDiscount: {\n amountOff: number;\n percentOff: number;\n };\n discounts: {\n label: string;\n value: string;\n amount: Currency;\n }[];\n stockStatus: string;\n quantity: number;\n prices: {\n originalItemPrice: Currency;\n rowTotal: Currency;\n };\n configurableOptions?: {\n optionLabel: string;\n valueLabel: string;\n }[];\n bundleOptions?: {\n label: string;\n values: {\n label: string;\n quantity: number;\n originalPrice: Currency;\n price: Currency;\n }[];\n }[];\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n}\n\nexport interface ItemNote {\n createdAt: string;\n creatorId: number;\n creatorType: number;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n}\n\nexport interface Currency {\n value: number;\n currency: string;\n}\n\nexport interface NegotiableQuoteListEntry {\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName: string;\n prices: {\n grandTotal: Currency;\n };\n}\nexport interface NegotiableQuotesListModel {\n items: NegotiableQuoteListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteHistoryEntry {\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: NegotiableQuoteHistoryEntryChangeType;\n changes: {\n commentAdded?: {\n comment: string;\n };\n customChanges?: {\n new_value: string;\n old_value: string;\n title: string;\n };\n expiration?: {\n newExpiration: string;\n oldExpiration: string;\n };\n productsRemoved?: {\n productsRemovedFromCatalog: string[];\n productsRemovedFromQuote?: {\n uid: string;\n name: string;\n sku: string;\n quantity: number;\n }[];\n };\n statuses?: {\n changes: {\n newStatus: string;\n oldStatus: string;\n }[];\n };\n total?: {\n newPrice: Currency;\n oldPrice: Currency;\n };\n };\n createdAt: string;\n uid: string;\n}\n\nexport enum NegotiableQuoteHistoryEntryChangeType {\n CREATED = 'CREATED',\n UPDATED = 'UPDATED',\n CLOSED = 'CLOSED',\n UPDATED_BY_SYSTEM = 'UPDATED_BY_SYSTEM',\n}\n\n// See: https://experienceleague.adobe.com/en/docs/commerce-admin/b2b/quotes/quotes#quote-status\nexport enum NegotiableQuoteStatus {\n NEW = 'NEW', // Currently not returned by the API, but is used to indicate a new quote\n SUBMITTED = 'SUBMITTED',\n PENDING = 'PENDING',\n UPDATED = 'UPDATED',\n OPEN = 'OPEN',\n ORDERED = 'ORDERED',\n CLOSED = 'CLOSED',\n DECLINED = 'DECLINED',\n EXPIRED = 'EXPIRED',\n DRAFT = 'DRAFT',\n}\n\nexport interface PaginationInfo {\n currentPage: number;\n totalCount: number;\n pageSize: number;\n startItem: number;\n endItem: number;\n totalPages: number;\n pageSizeOptions?: number[];\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport {\n NegotiableQuoteListEntry,\n NegotiableQuoteModel,\n NegotiableQuotesListModel,\n NegotiableQuoteStatus,\n PaginationInfo,\n ShippingAddress,\n} from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n expirationDate: quote.expiration_date,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n salesRepName: quote.sales_rep_name,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n comments: quote.comments?.map((comment: any) => {\n const baseComment: any = {\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n text: comment.text,\n };\n\n if (\n Array.isArray(comment.attachments) &&\n comment.attachments.length > 0\n ) {\n baseComment.attachments = comment.attachments.map((a: any) => ({\n name: a.name,\n url: a.url,\n }));\n }\n\n return baseComment;\n }),\n prices: quote.prices && {\n subtotalExcludingTax: quote.prices.subtotal_excluding_tax && {\n value: quote.prices.subtotal_excluding_tax.value,\n currency: quote.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: quote.prices.subtotal_including_tax && {\n value: quote.prices.subtotal_including_tax.value,\n currency: quote.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: quote.prices\n .subtotal_with_discount_excluding_tax && {\n value: quote.prices.subtotal_with_discount_excluding_tax.value,\n currency: quote.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: quote.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: quote.prices.grand_total && {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n },\n history: quote.history?.map((history: any) => ({\n uid: history.uid,\n createdAt: history.created_at,\n author: {\n firstname: history.author.firstname,\n lastname: history.author.lastname,\n },\n changeType: history.change_type,\n changes: {\n commentAdded: history.changes?.comment_added && {\n comment: history.changes.comment_added.comment,\n },\n customChanges: history.changes?.custom_changes && {\n new_value: history.changes.custom_changes.new_value,\n old_value: history.changes.custom_changes.old_value,\n title: history.changes.custom_changes.title,\n },\n expiration: history.changes?.expiration && {\n newExpiration: history.changes.expiration.new_expiration,\n oldExpiration: history.changes.expiration.old_expiration,\n },\n productsRemoved: history.changes?.products_removed && {\n productsRemovedFromCatalog:\n history.changes.products_removed.products_removed_from_catalog ||\n [],\n productsRemovedFromQuote:\n history.changes.products_removed.products_removed_from_quote || [],\n },\n statuses: history.changes?.statuses && {\n changes:\n history.changes.statuses.changes?.map((change: any) => ({\n newStatus: change.new_status,\n oldStatus: change.old_status,\n })) || [],\n },\n total: history.changes?.total &&\n history.changes.total.new_price &&\n history.changes.total.old_price && {\n newPrice: {\n value: history.changes.total.new_price.value,\n currency: history.changes.total.new_price.currency,\n },\n oldPrice: {\n value: history.changes.total.old_price.value,\n currency: history.changes.total.old_price.currency,\n },\n },\n },\n })),\n items:\n quote.items?.map((item: any) => ({\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\n catalogDiscount: {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts:\n item.prices?.discounts?.map((discount: any) => ({\n label: discount.label,\n value: discount.value,\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })) ?? [],\n stockStatus: item.product.stock_status,\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 noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n })) || [],\n shippingAddresses: quote.shipping_addresses?.map((address: any) => {\n const shippingAddress: ShippingAddress = {\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n };\n\n if (address.region) {\n shippingAddress.region = {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n };\n }\n\n return shippingAddress;\n }),\n canCheckout:\n ['UPDATED', 'DECLINED'].includes(quote.status) &&\n state.permissions.checkoutQuote &&\n quote.shipping_addresses?.length > 0,\n canSendForReview:\n (isQuoteNew ||\n ['DRAFT', 'UPDATED', 'DECLINED', 'EXPIRED', 'NEW'].includes(\n quote.status\n )) &&\n state.permissions.editQuote,\n };\n}\n\nexport function transformQuote(quoteData: any): NegotiableQuoteModel | null {\n if (!quoteData) {\n return null;\n }\n\n return transformSingleQuote(quoteData);\n}\n\n// quote is new if it has a status of SUBMITTED and there is no history entry that\n// has a change_type of UPDATED with a non-empty array of status changes\nfunction isNewQuote(quote: any): boolean {\n return (\n quote.status === 'SUBMITTED' &&\n !(quote.history ?? []).some(\n (history: any) =>\n history.change_type === 'UPDATED' &&\n (history.changes?.statuses?.changes ?? []).length > 0\n )\n );\n}\n\nfunction transformNegotiableQuoteListEntry(\n quote: any\n): NegotiableQuoteListEntry {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n prices: {\n grandTotal: {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n },\n };\n}\n\nexport function transformNegotiableQuotesList(\n quotesData: any\n): NegotiableQuotesListModel | null {\n if (!quotesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n quotesData.items\n ?.filter((quote: any) => quote?.uid)\n .map(transformNegotiableQuoteListEntry) || [],\n pageInfo: {\n currentPage: quotesData.page_info.current_page,\n pageSize: quotesData.page_info.page_size,\n totalPages: quotesData.page_info.total_pages,\n },\n totalCount: quotesData.total_count,\n sortFields: quotesData.sort_fields\n ? {\n default: quotesData.sort_fields.default,\n options: quotesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n\nexport function transformPaginationInfo(\n quotesData: NegotiableQuotesListModel | null\n): PaginationInfo | null {\n if (!quotesData?.pageInfo || !quotesData.totalCount) {\n return null;\n }\n\n const { currentPage, pageSize, totalPages } = quotesData.pageInfo;\n const { totalCount } = quotesData;\n\n const startItem = totalCount > 0 ? (currentPage - 1) * pageSize + 1 : 0;\n const endItem = Math.min(currentPage * pageSize, totalCount);\n\n const pageSizeOptions = [20, 30, 50, 100, 200]; // Default page size options\n\n return {\n currentPage,\n totalCount,\n pageSize,\n startItem,\n endItem,\n totalPages,\n pageSizeOptions,\n };\n}\n\n// TODO: Check if admin has this configuration\nexport const getDefaultPageSizeOptions = () => [20, 30, 50, 100, 200];\n","import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n"],"names":["DEFAULT_PERMISSIONS","_state","state","target","key","value","NegotiableQuoteStatus","transformSingleQuote","quote","isQuoteNew","isNewQuote","_a","comment","baseComment","a","_b","tax","_c","history","_d","_e","_f","change","_g","item","discount","note","option","address","shippingAddress","transformQuote","quoteData","transformNegotiableQuoteListEntry","transformNegotiableQuotesList","quotesData","transformedModel","paginationInfo","transformPaginationInfo","currentPage","pageSize","totalPages","totalCount","startItem","endItem","getDefaultPageSizeOptions","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL"],"mappings":"+DAWO,MAAMA,EAAsB,CAC/B,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,EACnB,EAEMC,EAAgB,CAClB,cAAe,GACf,YAAaD,CACjB,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACnC,IAAK,CAACE,EAAQC,IACHD,EAAOC,CAAkB,EAEpC,IAAK,CAACD,EAAQC,EAAKC,KACfF,EAAOC,CAAkB,EAAIC,EACtB,GAEf,CAAC,ECmLM,IAAKC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,QAA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A,CAEtC,CAEO,SAASC,EACdH,EACuB,CACvB,GAAI,EAACA,GAAA,MAAAA,EAAY,WAAY,CAACA,EAAW,WACvC,OAAO,KAGT,KAAM,CAAE,YAAAI,EAAa,SAAAC,EAAU,WAAAC,CAAA,EAAeN,EAAW,SACnD,CAAE,WAAAO,GAAeP,EAEjBQ,EAAYD,EAAa,GAAKH,EAAc,GAAKC,EAAW,EAAI,EAChEI,EAAU,KAAK,IAAIL,EAAcC,EAAUE,CAAU,EAI3D,MAAO,CACL,YAAAH,EACA,WAAAG,EACA,SAAAF,EACA,UAAAG,EACA,QAAAC,EACA,WAAAH,EACA,gBATsB,CAAC,GAAI,GAAI,GAAI,IAAK,GAAG,CAS3C,CAEJ,CAGO,MAAMI,EAA4B,IAAM,CAAC,GAAI,GAAI,GAAI,IAAK,GAAG,EC7VvD,CACX,YAAAC,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA"}
|
|
1
|
+
{"version":3,"file":"fetch-graphql.js","sources":["/@dropins/storefront-quote-management/src/data/models/negotiable-quote-model.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote.ts","/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport interface ShippingAddress {\n /**\n * The unique string identifier of the address\n */\n uid?: string;\n firstname: string;\n lastname: string;\n company?: string;\n street: string[];\n city: string;\n region?: {\n code: string;\n label: string;\n regionId: number;\n };\n postcode: string;\n country: {\n code: string;\n label: string;\n };\n telephone: string;\n}\n\nexport interface NegotiableQuoteModel {\n uid: string;\n name: string;\n createdAt: string;\n salesRepName: string;\n expirationDate: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n isVirtual: boolean;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName?: string;\n comments?: {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n }[];\n history?: NegotiableQuoteHistoryEntry[];\n prices: {\n appliedDiscounts?: Discount[];\n appliedTaxes?: Tax[];\n discount?: Currency;\n grandTotal?: Currency;\n grandTotalExcludingTax?: Currency;\n shippingExcludingTax?: Currency;\n shippingIncludingTax?: Currency;\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n totalTax?: Currency;\n };\n items: NegotiableQuoteCartItem[];\n shippingAddresses?: ShippingAddress[];\n canCheckout: boolean;\n canSendForReview: boolean;\n canDelete: boolean;\n}\n\nexport interface NegotiableQuoteCartItem {\n product: {\n uid: string;\n sku: string;\n name: string;\n templateId?: string;\n templateName?: string;\n priceRange: {\n maximumPrice: {\n regularPrice: {\n value: number;\n };\n };\n };\n };\n catalogDiscount: {\n amountOff: number;\n percentOff: number;\n };\n discounts: {\n label: string;\n value: string;\n amount: Currency;\n }[];\n stockStatus: string;\n quantity: number;\n prices: {\n originalItemPrice: Currency;\n rowTotal: Currency;\n };\n configurableOptions?: {\n optionLabel: string;\n valueLabel: string;\n }[];\n bundleOptions?: {\n label: string;\n values: {\n label: string;\n quantity: number;\n originalPrice: Currency;\n price: Currency;\n }[];\n }[];\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n}\n\nexport interface ItemNote {\n createdAt: string;\n creatorId: number;\n creatorType: number;\n negotiableQuoteItemUid: string;\n note: string;\n noteUid: string;\n}\n\nexport interface Currency {\n value: number;\n currency: string;\n}\n\nexport interface Tax {\n amount: Currency;\n label: string;\n}\n\nexport interface Discount {\n amount: Currency;\n label: string;\n coupon?: Coupon;\n}\n\nexport interface Coupon {\n code: string;\n}\n\nexport interface NegotiableQuoteListEntry {\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteStatus;\n buyer: {\n firstname: string;\n lastname: string;\n };\n templateName: string;\n prices: {\n grandTotal: Currency;\n };\n}\nexport interface NegotiableQuotesListModel {\n items: NegotiableQuoteListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteHistoryEntry {\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: NegotiableQuoteHistoryEntryChangeType;\n changes: {\n commentAdded?: {\n comment: string;\n };\n customChanges?: {\n new_value: string;\n old_value: string;\n title: string;\n };\n expiration?: {\n newExpiration: string;\n oldExpiration: string;\n };\n productsRemoved?: {\n productsRemovedFromCatalog: string[];\n productsRemovedFromQuote?: {\n uid: string;\n name: string;\n sku: string;\n quantity: number;\n }[];\n };\n statuses?: {\n changes: {\n newStatus: string;\n oldStatus: string;\n }[];\n };\n total?: {\n newPrice: Currency;\n oldPrice: Currency;\n };\n };\n createdAt: string;\n uid: string;\n}\n\nexport enum NegotiableQuoteHistoryEntryChangeType {\n CREATED = 'CREATED',\n UPDATED = 'UPDATED',\n CLOSED = 'CLOSED',\n UPDATED_BY_SYSTEM = 'UPDATED_BY_SYSTEM',\n}\n\n// See: https://experienceleague.adobe.com/en/docs/commerce-admin/b2b/quotes/quotes#quote-status\nexport enum NegotiableQuoteStatus {\n NEW = 'NEW', // Currently not returned by the API, but is used to indicate a new quote\n SUBMITTED = 'SUBMITTED',\n PENDING = 'PENDING',\n UPDATED = 'UPDATED',\n OPEN = 'OPEN',\n ORDERED = 'ORDERED',\n CLOSED = 'CLOSED',\n DECLINED = 'DECLINED',\n EXPIRED = 'EXPIRED',\n DRAFT = 'DRAFT',\n}\n\nexport interface PaginationInfo {\n currentPage: number;\n totalCount: number;\n pageSize: number;\n startItem: number;\n endItem: number;\n totalPages: number;\n pageSizeOptions?: number[];\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport {\n NegotiableQuoteListEntry,\n NegotiableQuoteModel,\n NegotiableQuotesListModel,\n NegotiableQuoteStatus,\n PaginationInfo,\n ShippingAddress,\n} from '@/quote-management/data/models/negotiable-quote-model';\nimport { state } from '@/quote-management/lib/state';\n\n// Base helper that transforms a single quote object directly\nfunction transformSingleQuote(quote: any): NegotiableQuoteModel {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n expirationDate: quote.expiration_date,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n isVirtual: Boolean(quote.is_virtual),\n salesRepName: quote.sales_rep_name,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n comments: quote.comments?.map((comment: any) => {\n const baseComment: any = {\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n text: comment.text,\n };\n\n if (\n Array.isArray(comment.attachments) &&\n comment.attachments.length > 0\n ) {\n baseComment.attachments = comment.attachments.map((a: any) => ({\n name: a.name,\n url: a.url,\n }));\n }\n\n return baseComment;\n }),\n prices: quote.prices && {\n appliedDiscounts: quote.prices.discounts?.map((discount: any) => ({\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n label: discount.label,\n coupon: discount.coupon,\n })),\n appliedTaxes: quote.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n discount:\n quote.prices.discounts &&\n quote.prices.grand_total &&\n calculateTotal(\n quote.prices.discounts,\n quote.prices.grand_total.currency\n ),\n grandTotal: quote.prices.grand_total && {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n grandTotalExcludingTax: quote.prices.grand_total_excluding_tax && {\n value: quote.prices.grand_total_excluding_tax.value,\n currency: quote.prices.grand_total_excluding_tax.currency,\n },\n subtotalExcludingTax: quote.prices.subtotal_excluding_tax && {\n value: quote.prices.subtotal_excluding_tax.value,\n currency: quote.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: quote.prices.subtotal_including_tax && {\n value: quote.prices.subtotal_including_tax.value,\n currency: quote.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: quote.prices\n .subtotal_with_discount_excluding_tax && {\n value: quote.prices.subtotal_with_discount_excluding_tax.value,\n currency: quote.prices.subtotal_with_discount_excluding_tax.currency,\n },\n ...transformShippingPrices(quote),\n totalTax:\n quote.prices.applied_taxes &&\n quote.prices.grand_total &&\n calculateTotal(\n quote.prices.applied_taxes,\n quote.prices.grand_total.currency\n ),\n },\n history: quote.history?.map((history: any) => ({\n uid: history.uid,\n createdAt: history.created_at,\n author: {\n firstname: history.author.firstname,\n lastname: history.author.lastname,\n },\n changeType: history.change_type,\n changes: {\n commentAdded: history.changes?.comment_added && {\n comment: history.changes.comment_added.comment,\n },\n customChanges: history.changes?.custom_changes && {\n new_value: history.changes.custom_changes.new_value,\n old_value: history.changes.custom_changes.old_value,\n title: history.changes.custom_changes.title,\n },\n expiration: history.changes?.expiration && {\n newExpiration: history.changes.expiration.new_expiration,\n oldExpiration: history.changes.expiration.old_expiration,\n },\n productsRemoved: history.changes?.products_removed && {\n productsRemovedFromCatalog:\n history.changes.products_removed.products_removed_from_catalog ||\n [],\n productsRemovedFromQuote:\n history.changes.products_removed.products_removed_from_quote || [],\n },\n statuses: history.changes?.statuses && {\n changes:\n history.changes.statuses.changes?.map((change: any) => ({\n newStatus: change.new_status,\n oldStatus: change.old_status,\n })) || [],\n },\n total: history.changes?.total &&\n history.changes.total.new_price &&\n history.changes.total.old_price && {\n newPrice: {\n value: history.changes.total.new_price.value,\n currency: history.changes.total.new_price.currency,\n },\n oldPrice: {\n value: history.changes.total.old_price.value,\n currency: history.changes.total.old_price.currency,\n },\n },\n },\n })),\n items:\n quote.items?.map((item: any) => ({\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\n catalogDiscount: {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts:\n item.prices?.discounts?.map((discount: any) => ({\n label: discount.label,\n value: discount.value,\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })) ?? [],\n stockStatus: item.product.stock_status,\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 noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n })) || [],\n shippingAddresses: quote.shipping_addresses?.map((address: any) => {\n const shippingAddress: ShippingAddress = {\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n };\n\n if (address.region) {\n shippingAddress.region = {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n };\n }\n\n return shippingAddress;\n }),\n canCheckout:\n ['UPDATED', 'DECLINED'].includes(quote.status) &&\n state.permissions.checkoutQuote &&\n quote.shipping_addresses?.length > 0,\n canSendForReview:\n (isQuoteNew ||\n ['DRAFT', 'UPDATED', 'DECLINED', 'EXPIRED', 'NEW'].includes(\n quote.status\n )) &&\n state.permissions.editQuote,\n canDelete:\n !['PENDING', 'SUBMITTED', 'ORDERED'].includes(quote.status) &&\n state.permissions.deleteQuote,\n };\n}\n\nexport function transformQuote(quoteData: any): NegotiableQuoteModel | null {\n if (!quoteData) {\n return null;\n }\n\n return transformSingleQuote(quoteData);\n}\n\n// quote is new if it has a status of SUBMITTED and there is no history entry that\n// has a change_type of UPDATED with a non-empty array of status changes\nfunction isNewQuote(quote: any): boolean {\n return (\n quote.status === 'SUBMITTED' &&\n !(quote.history ?? []).some(\n (history: any) =>\n history.change_type === 'UPDATED' &&\n (history.changes?.statuses?.changes ?? []).length > 0\n )\n );\n}\n\nfunction transformNegotiableQuoteListEntry(\n quote: any\n): NegotiableQuoteListEntry {\n const isQuoteNew = isNewQuote(quote);\n return {\n uid: quote.uid,\n name: quote.name,\n createdAt: quote.created_at,\n updatedAt: quote.updated_at,\n status: isQuoteNew ? NegotiableQuoteStatus.NEW : quote.status,\n buyer: {\n firstname: quote.buyer.firstname,\n lastname: quote.buyer.lastname,\n },\n templateName: quote.template_name,\n prices: {\n grandTotal: {\n value: quote.prices.grand_total.value,\n currency: quote.prices.grand_total.currency,\n },\n },\n };\n}\n\nexport function transformNegotiableQuotesList(\n quotesData: any\n): NegotiableQuotesListModel | null {\n if (!quotesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n quotesData.items\n ?.filter((quote: any) => quote?.uid)\n .map(transformNegotiableQuoteListEntry) || [],\n pageInfo: {\n currentPage: quotesData.page_info.current_page,\n pageSize: quotesData.page_info.page_size,\n totalPages: quotesData.page_info.total_pages,\n },\n totalCount: quotesData.total_count,\n sortFields: quotesData.sort_fields\n ? {\n default: quotesData.sort_fields.default,\n options: quotesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n\nexport function transformPaginationInfo(\n quotesData: NegotiableQuotesListModel | null\n): PaginationInfo | null {\n if (!quotesData?.pageInfo || !quotesData.totalCount) {\n return null;\n }\n\n const { currentPage, pageSize, totalPages } = quotesData.pageInfo;\n const { totalCount } = quotesData;\n\n const startItem = totalCount > 0 ? (currentPage - 1) * pageSize + 1 : 0;\n const endItem = Math.min(currentPage * pageSize, totalCount);\n\n const pageSizeOptions = [20, 30, 50, 100, 200]; // Default page size options\n\n return {\n currentPage,\n totalCount,\n pageSize,\n startItem,\n endItem,\n totalPages,\n pageSizeOptions,\n };\n}\n\n// TODO: Check if admin has this configuration\nexport const getDefaultPageSizeOptions = () => [20, 30, 50, 100, 200];\n\nexport function calculateTotal(data: any[], currency: string) {\n if (!data?.length)\n return {\n value: 0,\n currency,\n };\n\n return data.reduce(\n (acc: any, item: any) => {\n return {\n value: acc.value + item.amount.value,\n currency: item.amount.currency,\n };\n },\n { value: 0, currency }\n );\n}\n\nexport function transformShippingPrices(quote: any) {\n if (!quote || !quote.shipping_addresses?.length) {\n return {};\n }\n\n const shippingAddress = quote.shipping_addresses[0];\n const selectedShippingMethod = shippingAddress.selected_shipping_method;\n\n if (!selectedShippingMethod) {\n return {};\n }\n\n return {\n shippingIncludingTax: selectedShippingMethod.price_incl_tax && {\n value: selectedShippingMethod.price_incl_tax.value,\n currency: selectedShippingMethod.price_incl_tax.currency,\n },\n shippingExcludingTax: selectedShippingMethod.price_excl_tax && {\n value: selectedShippingMethod.price_excl_tax.value,\n currency: selectedShippingMethod.price_excl_tax.currency,\n },\n };\n}\n","import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n"],"names":["NegotiableQuoteStatus","transformSingleQuote","quote","isQuoteNew","isNewQuote","_a","comment","baseComment","a","_b","discount","_c","tax","calculateTotal","transformShippingPrices","_d","history","_e","_f","change","_g","item","note","option","value","address","shippingAddress","state","transformQuote","quoteData","transformNegotiableQuoteListEntry","transformNegotiableQuotesList","quotesData","transformedModel","paginationInfo","transformPaginationInfo","currentPage","pageSize","totalPages","totalCount","startItem","endItem","getDefaultPageSizeOptions","data","currency","acc","selectedShippingMethod","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL"],"mappings":"8FAgPO,IAAKA,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAVEA,IAAAA,GAAA,CAAA,CAAA,ECrNZ,SAASC,EAAqBC,EAAkC,mBAC9D,MAAMC,EAAaC,EAAWF,CAAK,EACnC,MAAO,CACL,IAAKA,EAAM,IACX,KAAMA,EAAM,KACZ,UAAWA,EAAM,WACjB,UAAWA,EAAM,WACjB,eAAgBA,EAAM,gBACtB,OAAQC,EAAaH,EAAsB,IAAME,EAAM,OACvD,UAAW,EAAQA,EAAM,WACzB,aAAcA,EAAM,eACpB,MAAO,CACL,UA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,EAAuB,eAAe,MAC7C,SAAUA,EAAuB,eAAe,QAAA,EAElD,qBAAsBA,EAAuB,gBAAkB,CAC7D,MAAOA,EAAuB,eAAe,MAC7C,SAAUA,EAAuB,eAAe,QAAA,CAClD,EAXO,CAAA,CAaX,CCtaO,KAAM,CACX,YAAAC,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{f as n,a as s}from"./fetch-graphql.js";import{s as i}from"./state.js";import"@dropins/tools/event-bus.js";const u=`
|
|
4
4
|
fragment NegotiableQuoteListFragment on NegotiableQuote {
|
|
5
5
|
uid
|
|
6
6
|
name
|
|
@@ -73,5 +73,5 @@ import{s as n,f as s,a as i}from"./fetch-graphql.js";import"@dropins/tools/event
|
|
|
73
73
|
${u}
|
|
74
74
|
${g}
|
|
75
75
|
${l}
|
|
76
|
-
`;var _=(e=>(e.FULL="FULL",e.PARTIAL="PARTIAL",e))(_||{}),E=(e=>(e.ASC="ASC",e.DESC="DESC",e))(E||{}),f=(e=>(e.QUOTE_NAME="QUOTE_NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(f||{});const S=async(e={})=>{var
|
|
76
|
+
`;var _=(e=>(e.FULL="FULL",e.PARTIAL="PARTIAL",e))(_||{}),E=(e=>(e.ASC="ASC",e.DESC="DESC",e))(E||{}),f=(e=>(e.QUOTE_NAME="QUOTE_NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(f||{});const S=async(e={})=>{var r;if(!i.authenticated)return Promise.reject(new Error("Unauthorized"));const o={filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null};try{const t=await n(c,{variables:o});if(!((r=t==null?void 0:t.data)!=null&&r.negotiableQuotes))throw new Error("No quotes data received");const a=s(t.data.negotiableQuotes);if(!a)throw new Error("Failed to transform quotes data");return a}catch(t){return Promise.reject(t)}};export{_ as F,f as N,E as S,S as n};
|
|
77
77
|
//# sourceMappingURL=negotiableQuotes.js.map
|
|
@@ -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":"iHASO,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;A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,38 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{s as p}from"./state.js";import{events as c}from"@dropins/tools/event-bus.js";import{f as l,t as E}from"./fetch-graphql.js";import{N as g}from"./NegotiableQuoteFragment.js";const q=`
|
|
4
|
+
mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {
|
|
5
|
+
deleteNegotiableQuotes(
|
|
6
|
+
input: {
|
|
7
|
+
quote_uids: $quoteUids
|
|
8
|
+
}
|
|
9
|
+
) {
|
|
10
|
+
result_status
|
|
11
|
+
operation_results {
|
|
12
|
+
__typename
|
|
13
|
+
... on NegotiableQuoteUidOperationSuccess {
|
|
14
|
+
quote_uid
|
|
15
|
+
}
|
|
16
|
+
... on DeleteNegotiableQuoteOperationFailure {
|
|
17
|
+
quote_uid
|
|
18
|
+
errors {
|
|
19
|
+
__typename
|
|
20
|
+
... on ErrorInterface {
|
|
21
|
+
message
|
|
22
|
+
}
|
|
23
|
+
... on NoSuchEntityUidError {
|
|
24
|
+
uid
|
|
25
|
+
message
|
|
26
|
+
}
|
|
27
|
+
... on NegotiableQuoteInvalidStateError {
|
|
28
|
+
message
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`,w=async m=>{var r;if(!p.authenticated)return Promise.reject(new Error("Unauthorized"));const n=Array.isArray(m)?m:[m];try{const t=await l(q,{variables:{quoteUids:n}}),{errors:i}=t||{};if(i&&i.length){const e=i.map(u=>u==null?void 0:u.message).filter(Boolean).join("; ");throw new Error(e||"Failed to delete negotiable quotes")}const s=(r=t==null?void 0:t.data)==null?void 0:r.deleteNegotiableQuotes;if(!s)throw new Error("No delete result returned");const a={resultStatus:s.result_status,operationResults:(s.operation_results||[]).map(e=>(e==null?void 0:e.__typename)==="NegotiableQuoteUidOperationSuccess"?{__typename:"NegotiableQuoteUidOperationSuccess",quoteUid:e==null?void 0:e.quote_uid}:{__typename:"DeleteNegotiableQuoteOperationFailure",quoteUid:e==null?void 0:e.quote_uid,errors:((e==null?void 0:e.errors)||[]).map(o=>({__typename:o==null?void 0:o.__typename,message:o==null?void 0:o.message,uid:o==null?void 0:o.uid}))})},d=a.operationResults.filter(e=>e.__typename==="NegotiableQuoteUidOperationSuccess").map(e=>e.quoteUid);return d.length>0&&c.emit("quote-management/negotiable-quote-deleted",{deletedQuoteUids:d,resultStatus:a.resultStatus}),a}catch(t){return c.emit("quote-management/negotiable-quote-delete-error",{error:t instanceof Error?t:new Error(String(t)),attemptedQuoteUids:n}),Promise.reject(t)}},U=`
|
|
4
36
|
mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(
|
|
5
37
|
$quoteUid: ID!
|
|
6
38
|
$comment: NegotiableQuoteCommentInput
|
|
@@ -16,6 +48,6 @@ import{f as E,t as c}from"./fetch-graphql.js";import{events as d}from"@dropins/t
|
|
|
16
48
|
}
|
|
17
49
|
}
|
|
18
50
|
}
|
|
19
|
-
${
|
|
20
|
-
`,
|
|
51
|
+
${g}
|
|
52
|
+
`,T=async m=>{const{quoteUid:n,comment:r}=m;if(!n)throw new Error("Quote UID is required");return l(U,{variables:{quoteUid:n,comment:r?{comment:r}:null}}).then(i=>{var d,e;const{errors:s}=i;if(s){const u=s.map(_=>_.message).join("; ");throw new Error(`Failed to send quote for review: ${u}`)}const a=E((e=(d=i.data)==null?void 0:d.sendNegotiableQuoteForReview)==null?void 0:e.quote);if(!a)throw new Error("Failed to transform quote data: Invalid response structure");return c.emit("quote-management/quote-sent-for-review",{quote:a,input:{quoteUid:n,comment:r}}),a})};export{w as d,T as s};
|
|
21
53
|
//# sourceMappingURL=sendForReview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendForReview.js","sources":["/@dropins/storefront-quote-management/src/api/sendForReview/graphql/SendNegotiableQuoteForReviewMutation.ts","/@dropins/storefront-quote-management/src/api/sendForReview/sendForReview.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION = `\n mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(\n $quoteUid: ID!\n $comment: NegotiableQuoteCommentInput\n ) {\n sendNegotiableQuoteForReview(\n input: {\n quote_uid: $quoteUid\n comment: $comment\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { events } from '@adobe-commerce/event-bus';\nimport { SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION } from './graphql/SendNegotiableQuoteForReviewMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface SendForReviewInput {\n quoteUid: string;\n comment?: string;\n}\n\nexport const sendForReview = async (\n input: SendForReviewInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, comment } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Build the comment object only if a comment is provided\n const commentInput = comment ? { comment } : null;\n\n return fetchGraphQl(SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION, {\n variables: {\n quoteUid,\n comment: commentInput,\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 send quote for review: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.sendNegotiableQuoteForReview?.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/quote-sent-for-review', {\n quote: quoteData,\n input: { quoteUid, comment },\n });\n\n return quoteData;\n });\n};\n\n"],"names":["SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","sendForReview","input","quoteUid","comment","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","_b","_a","events"],"mappings":"oJAmBO,MAAMA,EAA4C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBrDC,CAAyB;AAAA,ECfhBC,EAAgB,MAC3BC,GACyC,CACzC,KAAM,CAAE,SAAAC,EAAU,QAAAC,CAAA,EAAYF,EAE9B,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,uBAAuB,EAMzC,OAAOE,EAAaN,EAA2C,CAC7D,UAAW,CACT,SAAAI,EACA,QALiBC,EAAU,CAAE,QAAAA,CAAA,EAAY,IAKhC,CACX,CACD,EAAE,KAAME,GAAa,SACpB,KAAM,CAAE,OAAAC,GAAWD,EAEnB,GAAIC,EAAQ,CAEV,MAAMC,EAAgBD,EAAO,IAAKE,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MAAM,oCAAoCD,CAAa,EAAE,CACrE,CAGA,MAAME,EAAYC,GAChBC,GAAAC,EAAAP,EAAS,OAAT,YAAAO,EAAe,+BAAf,YAAAD,EAA6C,KAAA,EAG/C,GAAI,CAACF,EACH,MAAM,IAAI,MACR,4DAAA,EAKJ,OAAAI,EAAO,KAAK,yCAA0C,CACpD,MAAOJ,EACP,MAAO,CAAE,SAAAP,EAAU,QAAAC,CAAA,CAAQ,CAC5B,EAEMM,CACT,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"sendForReview.js","sources":["/@dropins/storefront-quote-management/src/api/deleteQuote/graphql/DeleteQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/deleteQuote/deleteQuote.ts","/@dropins/storefront-quote-management/src/api/sendForReview/graphql/SendNegotiableQuoteForReviewMutation.ts","/@dropins/storefront-quote-management/src/api/sendForReview/sendForReview.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 DELETE_QUOTE_MUTATION = `\n mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {\n deleteNegotiableQuotes(\n input: {\n quote_uids: $quoteUids\n }\n ) {\n result_status\n operation_results {\n __typename\n ... on NegotiableQuoteUidOperationSuccess {\n quote_uid\n }\n ... on DeleteNegotiableQuoteOperationFailure {\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n message\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\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 \nimport { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { DELETE_QUOTE_MUTATION } from '@/quote-management/api/deleteQuote/graphql/DeleteQuoteMutation';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface DeleteQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface DeleteQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface DeleteQuoteFailureResult {\n __typename: 'DeleteNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: DeleteQuoteFailureError[];\n}\n\nexport interface DeleteQuoteOutput {\n resultStatus: string;\n operationResults: Array<DeleteQuoteSuccessResult | DeleteQuoteFailureResult>;\n}\n\nexport const deleteQuote = async ( quoteUids: string[] | string ): Promise<DeleteQuoteOutput> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const quoteUidsArray = Array.isArray(quoteUids) ? quoteUids : [quoteUids];\n\n try {\n const response: any = await fetchGraphQl(DELETE_QUOTE_MUTATION, {\n variables: {\n quoteUids: quoteUidsArray,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors.map((e: any) => e?.message).filter(Boolean).join('; ');\n throw new Error(errorMessages || 'Failed to delete negotiable quotes');\n }\n\n const raw = response?.data?.deleteNegotiableQuotes;\n if (!raw) {\n throw new Error('No delete result returned');\n }\n\n const transformed: DeleteQuoteOutput = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: DeleteQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: DeleteQuoteFailureResult = {\n __typename: 'DeleteNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Emit event with successfully deleted quote UIDs\n const deletedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as DeleteQuoteSuccessResult).quoteUid);\n\n if (deletedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-deleted', {\n deletedQuoteUids: deletedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-delete-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUidsArray,\n });\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION = `\n mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(\n $quoteUid: ID!\n $comment: NegotiableQuoteCommentInput\n ) {\n sendNegotiableQuoteForReview(\n input: {\n quote_uid: $quoteUid\n comment: $comment\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { events } from '@adobe-commerce/event-bus';\nimport { SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION } from './graphql/SendNegotiableQuoteForReviewMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface SendForReviewInput {\n quoteUid: string;\n comment?: string;\n}\n\nexport const sendForReview = async (\n input: SendForReviewInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, comment } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Build the comment object only if a comment is provided\n const commentInput = comment ? { comment } : null;\n\n return fetchGraphQl(SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION, {\n variables: {\n quoteUid,\n comment: commentInput,\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 send quote for review: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.sendNegotiableQuoteForReview?.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/quote-sent-for-review', {\n quote: quoteData,\n input: { quoteUid, comment },\n });\n\n return quoteData;\n });\n};\n\n"],"names":["DELETE_QUOTE_MUTATION","deleteQuote","quoteUids","state","quoteUidsArray","response","fetchGraphQl","errors","errorMessages","e","raw","_a","transformed","result","err","deletedUids","res","events","error","SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","sendForReview","input","quoteUid","comment","quoteData","transformQuote","_b"],"mappings":"mLASO,MAAMA,EAAwB;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;AAAA;AAAA,EC2BxBC,EAAc,MAAQC,GAA8D,OAC/F,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MA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Quote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1},r={quoteDisplaySettings:{zeroTax:!1,subtotal:t.TAX_INCLUDED,price:t.TAX_INCLUDED,shipping:t.TAX_INCLUDED,fullSummary:!1,grandTotal:!0}},a={authenticated:!1,permissions:E,config:r},_=new Proxy(a,{get:(e,D)=>e[D],set:(e,D,s)=>(e[D]=s,!0)});export{E as D,t as Q,_ as s};
|
|
4
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sources":["/@dropins/storefront-quote-management/src/data/models/store-config-model.ts","/@dropins/storefront-quote-management/src/lib/state.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 enum QuoteDisplayAmount {\n TAX_INCLUDED = 1,\n TAX_EXCLUDED = 2,\n TAX_INCLUDED_AND_EXCLUDED = 3,\n}\n\nexport interface StoreConfigModel {\n quoteDisplaySettings: {\n zeroTax: boolean;\n subtotal: QuoteDisplayAmount;\n price: QuoteDisplayAmount;\n shipping: QuoteDisplayAmount;\n fullSummary: boolean;\n grandTotal: boolean;\n };\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { State } from '@/quote-management/types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n};\n\nexport const DEFAULT_CONFIG: StoreConfigModel = {\n quoteDisplaySettings: {\n zeroTax: false,\n subtotal: QuoteDisplayAmount.TAX_INCLUDED,\n price: QuoteDisplayAmount.TAX_INCLUDED,\n shipping: QuoteDisplayAmount.TAX_INCLUDED,\n fullSummary: false,\n grandTotal: true,\n },\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n config: DEFAULT_CONFIG,\n};\n\n// Proxy state to make it reactive\nexport const state = new Proxy(_state, {\n get: (target, key) => {\n return target[key as keyof State];\n },\n set: (target, key, value) => {\n target[key as keyof State] = value;\n return true;\n },\n});\n"],"names":["QuoteDisplayAmount","DEFAULT_PERMISSIONS","DEFAULT_CONFIG","_state","state","target","key","value"],"mappings":"AASO,IAAKA,GAAAA,IACVA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,0BAA4B,CAAA,EAA5B,4BAHUA,IAAAA,GAAA,CAAA,CAAA,ECML,MAAMC,EAAsB,CACjC,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,EACjB,EAEaC,EAAmC,CAC9C,qBAAsB,CACpB,QAAS,GACT,SAAUF,EAAmB,aAC7B,MAAOA,EAAmB,aAC1B,SAAUA,EAAmB,aAC7B,YAAa,GACb,WAAY,EAAA,CAEhB,EAEMG,EAAgB,CACpB,cAAe,GACf,YAAaF,EACb,OAAQC,CACV,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAK,CAACE,EAAQC,IACLD,EAAOC,CAAkB,EAElC,IAAK,CAACD,EAAQC,EAAKC,KACjBF,EAAOC,CAAkB,EAAIC,EACtB,GAEX,CAAC"}
|
package/chunks/uploadFile.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{f as l,t as w}from"./fetch-graphql.js";import{events as E}from"@dropins/tools/event-bus.js";import{N as f}from"./NegotiableQuoteFragment.js";const N=`
|
|
3
|
+
import{f as l,t as w}from"./fetch-graphql.js";import"./state.js";import{events as E}from"@dropins/tools/event-bus.js";import{N as f}from"./NegotiableQuoteFragment.js";const N=`
|
|
4
4
|
mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(
|
|
5
5
|
$cartId: ID!
|
|
6
6
|
$quoteName: String!
|
|
@@ -21,7 +21,7 @@ import{f as l,t as w}from"./fetch-graphql.js";import{events as E}from"@dropins/t
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
${f}
|
|
24
|
-
|
|
24
|
+
`,$=async t=>{const{cartId:n,quoteName:e,comment:o,attachments:r,isDraft:i}=t;if(!n)throw new Error("Cart ID is required");if(!e)throw new Error("Quote name is required");if(!o)throw new Error("Comment is required");return l(N,{variables:{cartId:n,quoteName:e,comment:r!=null&&r.length?{comment:o,attachments:r}:{comment:o},isDraft:i}}).then(m=>{var s,u;const{errors:d}=m;if(d){const c=d.map(p=>p.message).join("; ");throw new Error(`Failed to request negotiable quote: ${c}`)}const a=w((u=(s=m.data)==null?void 0:s.requestNegotiableQuote)==null?void 0:u.quote);if(!a)throw new Error("Failed to transform quote data: Invalid response structure");return E.emit("quote-management/negotiable-quote-requested",{quote:a,input:{cartId:n,quoteName:e,comment:o,attachments:r,isDraft:i}}),a})},h=`
|
|
25
25
|
mutation INITIATE_UPLOAD_MUTATION($input: initiateUploadInput!) {
|
|
26
26
|
initiateUpload(input: $input) {
|
|
27
27
|
upload_url
|
|
@@ -37,5 +37,5 @@ import{f as l,t as w}from"./fetch-graphql.js";import{events as E}from"@dropins/t
|
|
|
37
37
|
message
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
`,Q=async t=>{const n="NEGOTIABLE_QUOTE_ATTACHMENT";try{const e=t==null?void 0:t.name;if(!t||!e)throw new Error("Invalid file");const o=I=>I.map(_=>_.message).join("; "),{data:r,errors:i}=await l(h,{variables:{input:{key:e,media_resource_type:n}}});if(i&&i.length)throw new Error(o(i));const{upload_url:m,key:d}=(r==null?void 0:r.initiateUpload)||{};if(!m||!d)throw new Error("Failed to initiate upload");const a=await fetch(m,{method:"PUT",body:t});if(!a.ok)throw new Error(`Upload failed: ${a.status} ${a.statusText}`);const{data:s,errors:u}=await l(U,{variables:{input:{key:d,media_resource_type:n}}});if(u&&u.length)throw new Error(o(u));const{success:c,key:p,message:T}=(s==null?void 0:s.finishUpload)||{};if(!c||!p)throw new Error(T||"Failed to finish upload");return{key:p}}catch(e){throw E.emit("quote-management/file-upload-error",{error:(e==null?void 0:e.message)||"File upload failed",fileName:t==null?void 0:t.name}),e instanceof Error?e:new Error("File upload failed")}};export{$ as r,Q as u};
|
|
41
41
|
//# sourceMappingURL=uploadFile.js.map
|
package/chunks/uploadFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.js","sources":["/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/graphql/RequestNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/requestNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/uploadFile/graphql/InitiateUploadMutation.ts","/@dropins/storefront-quote-management/src/api/uploadFile/graphql/FinishUploadMutation.ts","/@dropins/storefront-quote-management/src/api/uploadFile/uploadFile.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const REQUEST_NEGOTIABLE_QUOTE_MUTATION = `\n mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(\n $cartId: ID!\n $quoteName: String!\n $comment: NegotiableQuoteCommentInput!\n $isDraft: Boolean\n ) {\n requestNegotiableQuote(\n input: {\n cart_id: $cartId\n quote_name: $quoteName\n comment: $comment\n is_draft: $isDraft\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 { REQUEST_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RequestNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RequestNegotiableQuoteInput {\n cartId: string;\n quoteName: string;\n comment: string;\n isDraft?: boolean;\n attachments?: { key: string }[];\n}\n\nexport const requestNegotiableQuote = async (\n input: RequestNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { cartId, quoteName, comment, attachments, isDraft } = input;\n\n if (!cartId) {\n throw new Error('Cart ID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n if (!comment) {\n throw new Error('Comment is required');\n }\n\n return fetchGraphQl(REQUEST_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n cartId,\n quoteName,\n comment: attachments?.length ? { comment, attachments } : { comment },\n isDraft,\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 request negotiable quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(response.data?.requestNegotiableQuote?.quote);\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/negotiable-quote-requested', {\n quote: quoteData,\n input: { cartId, quoteName, comment, attachments, isDraft },\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\nexport const INITIATE_UPLOAD_MUTATION = `\n mutation INITIATE_UPLOAD_MUTATION($input: initiateUploadInput!) {\n initiateUpload(input: $input) {\n upload_url\n key\n expires_at\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 FINISH_UPLOAD_MUTATION = `\n mutation FINISH_UPLOAD_MUTATION($input: finishUploadInput!) {\n finishUpload(input: $input) {\n success\n key\n message\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 { events } from '@adobe-commerce/event-bus';\nimport { INITIATE_UPLOAD_MUTATION } from '@/quote-management/api/uploadFile/graphql/InitiateUploadMutation';\nimport { FINISH_UPLOAD_MUTATION } from '@/quote-management/api/uploadFile/graphql/FinishUploadMutation';\n\ntype GraphQLError = { message: string };\ntype InitiateUploadData = {\n initiateUpload?: {\n upload_url: string;\n key: string;\n expires_at: string;\n };\n};\ntype FinishUploadData = {\n finishUpload?: {\n success: boolean;\n key: string;\n message?: string;\n };\n};\ntype GraphQLResponse<T> = {\n data?: T;\n errors?: GraphQLError[];\n};\n\nexport const uploadFile = async (file: File): Promise<{ key: string }> => {\n const mediaResourceType = 'NEGOTIABLE_QUOTE_ATTACHMENT';\n\n try {\n const filename = file?.name;\n if (!file || !filename) throw new Error('Invalid file');\n\n const formatGraphQLErrors = (errors: GraphQLError[]): string =>\n errors.map((e) => e.message).join('; ');\n\n const { data: initialData, errors: initialErrors } = (await fetchGraphQl(\n INITIATE_UPLOAD_MUTATION,\n { \n variables: { input: { key: filename, media_resource_type: mediaResourceType } } \n }\n )) as GraphQLResponse<InitiateUploadData>;\n if (initialErrors && initialErrors.length) throw new Error(formatGraphQLErrors(initialErrors));\n\n const { upload_url, key } = initialData?.initiateUpload || {};\n if (!upload_url || !key) throw new Error('Failed to initiate upload');\n\n const put = await fetch(upload_url, { method: 'PUT', body: file });\n if (!put.ok) throw new Error(`Upload failed: ${put.status} ${put.statusText}`);\n\n const { data: finishData, errors: finishErrors } = (await fetchGraphQl(\n FINISH_UPLOAD_MUTATION,\n { \n variables: { input: { key, media_resource_type: mediaResourceType } } \n }\n )) as GraphQLResponse<FinishUploadData>;\n if (finishErrors && finishErrors.length) throw new Error(formatGraphQLErrors(finishErrors));\n\n const { success, key: finalizedKey, message } = finishData?.finishUpload || {};\n if (!success || !finalizedKey) throw new Error(message || 'Failed to finish upload');\n\n return { key: finalizedKey };\n \n } catch (err: any) {\n events.emit('quote-management/file-upload-error', {\n error: err?.message || 'File upload failed',\n fileName: file?.name,\n });\n throw err instanceof Error ? err : new Error('File upload failed');\n }\n};\n"],"names":["REQUEST_NEGOTIABLE_QUOTE_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","requestNegotiableQuote","input","cartId","quoteName","comment","attachments","isDraft","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","_b","_a","events","INITIATE_UPLOAD_MUTATION","FINISH_UPLOAD_MUTATION","uploadFile","file","mediaResourceType","filename","formatGraphQLErrors","e","initialData","initialErrors","upload_url","key","put","finishData","finishErrors","success","finalizedKey","message","err"],"mappings":"oJAmBO,MAAMA,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoB7CC,CAAyB;AAAA,EChBhBC,EAAyB,M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|
|
1
|
+
{"version":3,"file":"uploadFile.js","sources":["/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/graphql/RequestNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/requestNegotiableQuote/requestNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/uploadFile/graphql/InitiateUploadMutation.ts","/@dropins/storefront-quote-management/src/api/uploadFile/graphql/FinishUploadMutation.ts","/@dropins/storefront-quote-management/src/api/uploadFile/uploadFile.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const REQUEST_NEGOTIABLE_QUOTE_MUTATION = `\n mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(\n $cartId: ID!\n $quoteName: String!\n $comment: NegotiableQuoteCommentInput!\n $isDraft: Boolean\n ) {\n requestNegotiableQuote(\n input: {\n cart_id: $cartId\n quote_name: $quoteName\n comment: $comment\n is_draft: $isDraft\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 { REQUEST_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RequestNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RequestNegotiableQuoteInput {\n cartId: string;\n quoteName: string;\n comment: string;\n isDraft?: boolean;\n attachments?: { key: string }[];\n}\n\nexport const requestNegotiableQuote = async (\n input: RequestNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { cartId, quoteName, comment, attachments, isDraft } = input;\n\n if (!cartId) {\n throw new Error('Cart ID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n if (!comment) {\n throw new Error('Comment is required');\n }\n\n return fetchGraphQl(REQUEST_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n cartId,\n quoteName,\n comment: attachments?.length ? { comment, attachments } : { comment },\n isDraft,\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 request negotiable quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(response.data?.requestNegotiableQuote?.quote);\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/negotiable-quote-requested', {\n quote: quoteData,\n input: { cartId, quoteName, comment, attachments, isDraft },\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\nexport const INITIATE_UPLOAD_MUTATION = `\n mutation INITIATE_UPLOAD_MUTATION($input: initiateUploadInput!) {\n initiateUpload(input: $input) {\n upload_url\n key\n expires_at\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 FINISH_UPLOAD_MUTATION = `\n mutation FINISH_UPLOAD_MUTATION($input: finishUploadInput!) {\n finishUpload(input: $input) {\n success\n key\n message\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 { events } from '@adobe-commerce/event-bus';\nimport { INITIATE_UPLOAD_MUTATION } from '@/quote-management/api/uploadFile/graphql/InitiateUploadMutation';\nimport { FINISH_UPLOAD_MUTATION } from '@/quote-management/api/uploadFile/graphql/FinishUploadMutation';\n\ntype GraphQLError = { message: string };\ntype InitiateUploadData = {\n initiateUpload?: {\n upload_url: string;\n key: string;\n expires_at: string;\n };\n};\ntype FinishUploadData = {\n finishUpload?: {\n success: boolean;\n key: string;\n message?: string;\n };\n};\ntype GraphQLResponse<T> = {\n data?: T;\n errors?: GraphQLError[];\n};\n\nexport const uploadFile = async (file: File): Promise<{ key: string }> => {\n const mediaResourceType = 'NEGOTIABLE_QUOTE_ATTACHMENT';\n\n try {\n const filename = file?.name;\n if (!file || !filename) throw new Error('Invalid file');\n\n const formatGraphQLErrors = (errors: GraphQLError[]): string =>\n errors.map((e) => e.message).join('; ');\n\n const { data: initialData, errors: initialErrors } = (await fetchGraphQl(\n INITIATE_UPLOAD_MUTATION,\n { \n variables: { input: { key: filename, media_resource_type: mediaResourceType } } \n }\n )) as GraphQLResponse<InitiateUploadData>;\n if (initialErrors && initialErrors.length) throw new Error(formatGraphQLErrors(initialErrors));\n\n const { upload_url, key } = initialData?.initiateUpload || {};\n if (!upload_url || !key) throw new Error('Failed to initiate upload');\n\n const put = await fetch(upload_url, { method: 'PUT', body: file });\n if (!put.ok) throw new Error(`Upload failed: ${put.status} ${put.statusText}`);\n\n const { data: finishData, errors: finishErrors } = (await fetchGraphQl(\n FINISH_UPLOAD_MUTATION,\n { \n variables: { input: { key, media_resource_type: mediaResourceType } } \n }\n )) as GraphQLResponse<FinishUploadData>;\n if (finishErrors && finishErrors.length) throw new Error(formatGraphQLErrors(finishErrors));\n\n const { success, key: finalizedKey, message } = finishData?.finishUpload || {};\n if (!success || !finalizedKey) throw new Error(message || 'Failed to finish upload');\n\n return { key: finalizedKey };\n \n } catch (err: any) {\n events.emit('quote-management/file-upload-error', {\n error: err?.message || 'File upload failed',\n fileName: file?.name,\n });\n throw err instanceof Error ? err : new Error('File upload failed');\n }\n};\n"],"names":["REQUEST_NEGOTIABLE_QUOTE_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","requestNegotiableQuote","input","cartId","quoteName","comment","attachments","isDraft","fetchGraphQl","response","errors","errorMessages","error","quoteData","transformQuote","_b","_a","events","INITIATE_UPLOAD_MUTATION","FINISH_UPLOAD_MUTATION","uploadFile","file","mediaResourceType","filename","formatGraphQLErrors","e","initialData","initialErrors","upload_url","key","put","finishData","finishErrors","success","finalizedKey","message","err"],"mappings":"uKAmBO,MAAMA,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoB7CC,CAAyB;AAAA,EChBhBC,EAAyB,MACpCC,GACyC,CACzC,KAAM,CAAE,OAAAC,EAAQ,UAAAC,EAAW,QAAAC,EAAS,YAAAC,EAAa,QAAAC,GAAYL,EAE7D,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,qBAAqB,EAGvC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,wBAAwB,EAG1C,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,qBAAqB,EAGvC,OAAOG,EAAaT,EAAmC,CACrD,UAAW,CACT,OAAAI,EACA,UAAAC,EACA,QAASE,GAAA,MAAAA,EAAa,OAAS,CAAE,QAAAD,EAAS,YAAAC,CAAA,EAAgB,CAAE,QAAAD,CAAA,EAC5D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AACC,EAAK,MAAM,IAAI,MAAM,2BAA2B,EAEpE,MAAMC,EAAM,MAAM,MAAMF,EAAY,CAAE,OAAQ,MAAO,KAAMP,EAAM,EACjE,GAAI,CAACS,EAAI,GAAI,MAAM,IAAI,MAAM,kBAAkBA,EAAI,MAAM,IAAIA,EAAI,UAAU,EAAE,EAE7E,KAAM,CAAE,KAAMC,EAAY,OAAQC,CAAA,EAAkB,MAAMxB,EACxDW,EACA,CACE,UAAW,CAAE,MAAO,CAAE,IAAAU,EAAK,oBAAqBP,EAAkB,CAAE,CACtE,EAEF,GAAIU,GAAgBA,EAAa,OAAQ,MAAM,IAAI,MAAMR,EAAoBQ,CAAY,CAAC,EAE1F,KAAM,CAAE,QAAAC,EAAS,IAAKC,EAAc,QAAAC,IAAYJ,GAAA,YAAAA,EAAY,eAAgB,CAAA,EAC5E,GAAI,CAACE,GAAW,CAACC,QAAoB,IAAI,MAAMC,GAAW,yBAAyB,EAEnF,MAAO,CAAE,IAAKD,CAAA,CAEhB,OAASE,EAAU,CACjB,MAAAnB,EAAO,KAAK,qCAAsC,CAChD,OAAOmB,GAAA,YAAAA,EAAK,UAAW,qBACvB,SAAUf,GAAA,YAAAA,EAAM,IAAA,CACjB,EACKe,aAAe,MAAQA,EAAM,IAAI,MAAM,oBAAoB,CACnE,CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionComponent, VNode } from 'preact';
|
|
2
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
+
|
|
4
|
+
export interface ConfirmationModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
title?: VNode | string;
|
|
7
|
+
message?: VNode | string;
|
|
8
|
+
cancelLabel?: VNode | string;
|
|
9
|
+
confirmLabel?: VNode | string;
|
|
10
|
+
onCancel?: () => void;
|
|
11
|
+
onConfirm?: () => void;
|
|
12
|
+
showCloseButton?: boolean;
|
|
13
|
+
confirmationBanner?: VNode | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const ConfirmationModal: FunctionComponent<ConfirmationModalProps>;
|
|
16
|
+
//# sourceMappingURL=ConfirmationModal.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* Copyright 2025 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
+
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
+
* accompanying it.
|
|
8
|
+
*******************************************************************/
|
|
9
|
+
export * from './ConfirmationModal';
|
|
10
|
+
export { ConfirmationModal as default } from './ConfirmationModal';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -9,18 +9,21 @@ export interface OrderSummaryLineItem {
|
|
|
9
9
|
sortOrder: number;
|
|
10
10
|
content: string | JSXInternal.Element | VNode<HTMLAttributes<HTMLDivElement>> | OrderSummaryLineItem[] | undefined;
|
|
11
11
|
}
|
|
12
|
-
export interface OrderSummaryProps extends
|
|
12
|
+
export interface OrderSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
13
13
|
variant?: 'primary' | 'secondary';
|
|
14
14
|
heading?: VNode<HTMLAttributes<HTMLDivElement>>;
|
|
15
|
-
loading?: boolean;
|
|
16
15
|
subTotal?: {
|
|
17
16
|
price: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
18
17
|
priceExcludingTax?: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
19
18
|
taxIncluded?: boolean;
|
|
20
19
|
taxExcluded?: boolean;
|
|
21
|
-
zeroTaxSubtotal?: boolean;
|
|
22
20
|
};
|
|
23
|
-
shipping?:
|
|
21
|
+
shipping?: {
|
|
22
|
+
price: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
23
|
+
priceExcludingTax?: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
24
|
+
taxIncluded?: boolean;
|
|
25
|
+
taxExcluded?: boolean;
|
|
26
|
+
};
|
|
24
27
|
discounts?: {
|
|
25
28
|
label: string;
|
|
26
29
|
price: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
@@ -38,28 +41,6 @@ export interface OrderSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
38
41
|
price: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
39
42
|
priceWithoutTax?: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
40
43
|
};
|
|
41
|
-
printedCard?: {
|
|
42
|
-
renderContent: boolean;
|
|
43
|
-
taxIncluded: boolean;
|
|
44
|
-
taxInclAndExcl: boolean;
|
|
45
|
-
priceExclTax: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
46
|
-
priceInclTax: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
47
|
-
};
|
|
48
|
-
itemsGiftWrapping?: {
|
|
49
|
-
renderContent: boolean;
|
|
50
|
-
taxIncluded: boolean;
|
|
51
|
-
taxInclAndExcl: boolean;
|
|
52
|
-
priceExclTax: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
53
|
-
priceInclTax: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
54
|
-
};
|
|
55
|
-
orderGiftWrapping?: {
|
|
56
|
-
renderContent: boolean;
|
|
57
|
-
taxIncluded: boolean;
|
|
58
|
-
taxInclAndExcl: boolean;
|
|
59
|
-
priceExclTax: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
60
|
-
priceInclTax: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
61
|
-
};
|
|
62
|
-
primaryAction?: VNode<HTMLAttributes<HTMLButtonElement>>;
|
|
63
44
|
totalSaved?: VNode<HTMLAttributes<HTMLSpanElement>>;
|
|
64
45
|
updateLineItems?: (lineItems: Array<OrderSummaryLineItem>) => Array<OrderSummaryLineItem>;
|
|
65
46
|
}
|
package/components/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './ProductListTable';
|
|
|
15
15
|
export * from './QuotePricesSummary';
|
|
16
16
|
export * from './QuoteSummaryList';
|
|
17
17
|
export * from './QuotesListTable';
|
|
18
|
+
export * from './ConfirmationModal';
|
|
18
19
|
export * from './QuoteHistoryLog';
|
|
19
20
|
export * from './ShippingAddressDisplay';
|
|
20
21
|
export * from './RequestNegotiableQuoteForm';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as t,jsxs as p}from"@dropins/tools/preact-jsx-runtime.js";import{useState as x,useMemo as b,useEffect as M,useCallback as F}from"@dropins/tools/preact-compat.js";import{classes as d,VComponent as c,Slot as u,getGlobalLocale as D}from"@dropins/tools/lib.js";/* empty css */import{Picker as J,Skeleton as K,SkeletonRow as Q,InLineAlert as Y,Button as C,TextArea as Z}from"@dropins/tools/components.js";import{events as y}from"@dropins/tools/event-bus.js";/* empty css */import"@dropins/tools/preact.js";/* empty css *//* empty css *//* empty css */import{S as O}from"../chunks/ShippingAddressDisplay.js";import{Q as k}from"../chunks/QuoteHistoryLog.js";import"../chunks/fetch-graphql.js";import{s as B}from"../chunks/sendForReview.js";import{I as A}from"../chunks/ItemsQuoted.js";import{Q as ee}from"../chunks/QuoteCommentsList.js";import{S as ae}from"../chunks/WarningFilled.js";import{useText as te}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";const ne=({className:q,dropdownPlaceholder:e,dropdownOptions:n,handleDropdownChange:s,buttons:g,...a})=>{const f=n&&n.length>0,h=g&&g.length>0,l=(n==null?void 0:n.map(m=>({text:m.label,value:m.value})))||[];return l.unshift({text:e||"",value:""}),t("div",{className:"quote-management-actions-bar__container","data-testid":"actions-bar-container",children:p("div",{className:d(["quote-management-actions-bar",q]),"data-testid":"actions-bar",...a,children:[f&&t(J,{name:"dropdown",id:"dropdown",onInput:s,className:"quote-management-actions-bar__dropdown","data-testid":"dropdown",options:l}),h&&t("div",{className:"quote-management-actions-bar__buttons","data-testid":"buttons-container",children:g==null?void 0:g.map((m,_)=>t(c,{node:m,className:d(["quote-management-actions-bar__button"])},_))})]})})},re=({className:q,loading:e,quoteName:n,quoteStatus:s,banner:g,details:a,actionBar:f,quoteContent:h,shippingInformationTitle:l,shippingInformation:m,quoteCommentsTitle:_,quoteComments:v,footer:T,...r})=>e?t(ie,{}):p("div",{...r,className:d(["quote-management-manage-negotiable-quote",q]),children:[p("div",{className:d(["quote-management-manage-negotiable-quote__header"]),children:[n&&t(c,{node:n,className:d(["quote-management-manage-negotiable-quote__quote-name"])}),s&&t(c,{node:s,className:d(["quote-management-manage-negotiable-quote__quote-status"])})]}),g&&t(c,{node:g,className:d(["quote-management-manage-negotiable-quote__banner"])}),a&&t(c,{node:a,className:d(["quote-management-manage-negotiable-quote__details"])}),f&&t(c,{node:f,className:d(["quote-management-manage-negotiable-quote__action-bar"])}),h&&t(c,{node:h,className:d(["quote-management-manage-negotiable-quote__quote-content"])}),p("div",{"data-testid":"quote-shipping-information-container",className:d(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[l&&t(c,{node:l,className:d(["quote-management-manage-negotiable-quote__shipping-information-title"])}),m&&t(c,{node:m,className:d(["quote-management-manage-negotiable-quote__shipping-information"])})]}),p("div",{"data-testid":"quote-comments-container",className:d(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[_&&t(c,{node:_,className:d(["quote-management-manage-negotiable-quote__quote-comments-title"])}),v&&t(c,{node:v,className:d(["quote-management-manage-negotiable-quote__quote-comments"])})]}),t(c,{node:T,className:d(["quote-management-manage-negotiable-quote__footer"])})]}),ie=()=>p(K,{"data-testid":"manage-negotiable-quote-skeleton",children:[t(Q,{variant:"heading",fullWidth:!0,size:"large"}),t(Q,{variant:"row",fullWidth:!1,size:"small"}),t(Q,{variant:"row",fullWidth:!1,size:"small"}),t(Q,{variant:"row",fullWidth:!0}),t(Q,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),t(Q,{variant:"row",fullWidth:!1,size:"small"})]}),me=({className:q,tabs:e,tabsContent:n,defaultActiveTab:s,...g})=>{const[a,f]=x(s||Array.from(e.keys())[0]),h=m=>{f(m)},l=b(()=>n.get(a),[a,n]);return p("div",{...g,className:d(["quote-management-tabbed-content",q]),children:[e&&t("div",{"data-testid":"tabbed-content-tabs",className:d(["quote-management-tabbed-content__tabs"]),children:Array.from(e.entries()).map(([m,_])=>t("button",{className:d(["quote-management-tabbed-content__tab",["quote-management-tabbed-content__tab--active",m===a]]),onClick:()=>h(m),children:_},m))}),l&&t("div",{className:d(["quote-management-tabbed-content__active-tab-content"]),children:t(c,{node:l})})]})},we=({onActionsDropdownChange:q,slots:e,onActionsButtonClick:n,onSendForReview:s,...g})=>{const[a,f]=x(void 0),[h,l]=x(!0),[m,_]=x(""),[v,T]=x(!1),r=te({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired"});M(()=>{const o=y.on("quote-management/quote-data",N=>{const{quote:i}=N;i&&(f(i),l(!1))},{eager:!0});return()=>o==null?void 0:o.off()},[]),M(()=>{const o=y.on("quote-management/shipping-address-set",N=>{const{quote:i}=N;i&&f(i)},{eager:!0});return()=>o==null?void 0:o.off()},[]),M(()=>{const o=y.on("quote-management/quote-sent-for-review",N=>{const{quote:i}=N;f(i),_(""),T(!1)},{eager:!0});return()=>o==null?void 0:o.off()},[]);const P=b(()=>t(u,{name:"QuoteName",slot:e==null?void 0:e.QuoteName,context:{quoteName:a==null?void 0:a.name,quoteData:a},children:t("h1",{"data-testid":"quote-name",children:a==null?void 0:a.name})}),[e==null?void 0:e.QuoteName,a]),R=b(()=>t(u,{name:"QuoteStatus",slot:e==null?void 0:e.QuoteStatus,context:{quoteStatus:a==null?void 0:a.status,quoteData:a},children:t("div",{"data-testid":"quote-status",children:a==null?void 0:a.status})}),[e==null?void 0:e.QuoteStatus,a]),S=F(o=>{switch(o){case"SUBMITTED":return r.statusSubmitted;case"PENDING":return r.statusPending;case"EXPIRED":return r.statusExpired;default:return null}},[r])(a==null?void 0:a.status),I=S&&t(Y,{type:"warning",variant:"secondary",icon:t(ae,{}),heading:r.bannerTitle,description:S}),W=I&&t(u,{name:"Banner","data-testid":"banner",slot:e==null?void 0:e.Banner,context:{quoteData:a},children:I}),z=b(()=>{if(!a)return null;const o=D()||"en-US",N=new Intl.DateTimeFormat(o,{year:"numeric",month:"long",day:"numeric"});let i;try{i=N.format(new Date(a.expirationDate))}catch{i=a.expirationDate}return p(u,{name:"Details",slot:e==null?void 0:e.Details,context:{quoteData:a},children:[p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:r.createdLabel}),p("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[N.format(new Date(a.createdAt))," (",a.buyer.firstname," ",a.buyer.lastname,")"]})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:r.salesRepLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:a.salesRepName})]}),p("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:r.expiresLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:i})]})]})},[e==null?void 0:e.Details,r,a]),L=b(()=>[{label:r.close,value:"close"},{label:r.delete,value:"delete"},{label:r.print,value:"print"},{label:r.createTemplate,value:"createTemplate"},{label:r.createCopy,value:"createCopy"}],[r]),H=b(()=>{const o=i=>{q==null||q(i)},N=i=>{switch(i){case"close":n==null||n(i);break;case"delete":n==null||n(i);break;case"print":n==null||n(i);break;case"createTemplate":n==null||n(i);break;case"createCopy":n==null||n(i);break}};return t(u,{name:"ActionBar",slot:e==null?void 0:e.ActionBar,context:{quoteData:a},children:t(ne,{dropdownPlaceholder:r.actionsLabel,dropdownOptions:[{label:r.remove,value:"remove"}],handleDropdownChange:o,buttons:L.map(i=>t(C,{variant:"tertiary",onClick:()=>N(i.value),"data-testid":`actions-bar-${i.value}-button`,"data-action":i.value,disabled:i.disabled,children:i.label},i.value))})})},[L,r,e==null?void 0:e.ActionBar,a,q,n]),E=b(()=>t(u,{name:"QuoteContent",slot:e==null?void 0:e.QuoteContent,context:{quoteData:a},children:t(me,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",t(u,{name:"ItemsQuotedTab",slot:e==null?void 0:e.ItemsQuotedTab,context:{quoteData:a},children:t(A,{quoteData:a})},"items-quoted")],["comments",t(u,{name:"CommentsTab",slot:e==null?void 0:e.CommentsTab,context:{quoteData:a},children:t(ee,{quoteData:a})},"comments")],["history-log",t(u,{name:"HistoryLogTab",slot:e==null?void 0:e.HistoryLogTab,context:{quoteData:a},children:t(k,{quoteData:a})},"history-log")]])})}),[e==null?void 0:e.QuoteContent,e==null?void 0:e.HistoryLogTab,e==null?void 0:e.CommentsTab,e==null?void 0:e.ItemsQuotedTab,a]),U=b(()=>t(u,{name:"ShippingInformationTitle",slot:e==null?void 0:e.ShippingInformationTitle,context:{quoteData:a},children:t("h2",{children:r.shippingInformationTitle})}),[e==null?void 0:e.ShippingInformationTitle,a,r]),j=b(()=>t(u,{name:"ShippingInformation",slot:e==null?void 0:e.ShippingInformation,context:{quoteData:a,loading:h,setLoading:l},children:t(O,{quoteData:a,loading:h,"data-testid":"manage-quote-shipping-address"})}),[e==null?void 0:e.ShippingInformation,a,h,l]),G=b(()=>t(u,{name:"QuoteCommentsTitle",slot:e==null?void 0:e.QuoteCommentsTitle,context:{quoteData:a},children:t("h2",{children:r.quoteCommentsTitle})}),[e==null?void 0:e.QuoteCommentsTitle,r,a]),$=b(()=>t(u,{name:"QuoteComments",slot:e==null?void 0:e.QuoteComments,context:{quoteData:a},children:t(Z,{name:"quoteComments",placeholder:r.quoteCommentsPlaceholder,rows:3,value:m,onInput:o=>{_(o.target.value)},disabled:v})}),[e==null?void 0:e.QuoteComments,r,a,m,v]),w=F(async()=>{if(s){s({quoteData:a,comment:m.trim()||void 0});return}T(!0);try{await B({quoteUid:a.uid,comment:m.trim()||void 0})}catch(o){console.error("Failed to send quote for review:",o),T(!1)}},[a,s,m]),V=b(()=>t(u,{name:"Footer",slot:e==null?void 0:e.Footer,context:{quoteData:a,comment:m,isSubmitting:v},children:t(C,{variant:"primary",onClick:w,"data-testid":"send-for-review-button",disabled:!(a!=null&&a.canSendForReview)||v||!a,children:r.sendForReview})}),[e==null?void 0:e.Footer,r,a,m,v,w]),X={...g,loading:h,quoteName:P,quoteStatus:R,banner:W||void 0,details:z,actionBar:H,quoteContent:E,shippingInformationTitle:U,shippingInformation:j,quoteCommentsTitle:G,quoteComments:$,footer:V};return t(re,{...X})};export{we as ManageNegotiableQuote,we as default};
|
|
3
|
+
import{jsx as t,jsxs as u,Fragment as me}from"@dropins/tools/preact-jsx-runtime.js";import{useState as v,useMemo as _,useEffect as F,useCallback as T,createPortal as ce}from"@dropins/tools/preact-compat.js";import{classes as m,VComponent as f,Slot as s,getGlobalLocale as le}from"@dropins/tools/lib.js";/* empty css */import{Picker as de,Skeleton as ue,SkeletonRow as S,Modal as ge,Button as C,InLineAlert as E,TextArea as se}from"@dropins/tools/components.js";import{events as H}from"@dropins/tools/event-bus.js";/* empty css */import"@dropins/tools/preact.js";import{useText as G}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{S as be}from"../chunks/ShippingAddressDisplay.js";import{Q as fe}from"../chunks/QuoteHistoryLog.js";import{I as pe}from"../chunks/ItemsQuoted.js";import"../chunks/state.js";import{s as he,d as Ne}from"../chunks/sendForReview.js";import{Q as Me}from"../chunks/QuoteCommentsList.js";import{a as k,S as _e}from"../chunks/WarningFilled.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/NegotiableQuoteFragment.js";const qe=({className:p,dropdownPlaceholder:e,dropdownOptions:o,handleDropdownChange:h,buttons:g,...a})=>{const N=o&&o.length>0,b=g&&g.length>0,l=(o==null?void 0:o.map(c=>({text:c.label,value:c.value})))||[];return l.unshift({text:e||"",value:""}),t("div",{className:"quote-management-actions-bar__container","data-testid":"actions-bar-container",children:u("div",{className:m(["quote-management-actions-bar",p]),"data-testid":"actions-bar",...a,children:[N&&t(de,{name:"dropdown",id:"dropdown",onInput:h,className:"quote-management-actions-bar__dropdown","data-testid":"dropdown",options:l}),b&&t("div",{className:"quote-management-actions-bar__buttons","data-testid":"buttons-container",children:g==null?void 0:g.map((c,M)=>t(f,{node:c,className:m(["quote-management-actions-bar__button"])},M))})]})})},ve=({className:p,loading:e,quoteName:o,quoteStatus:h,banner:g,details:a,actionBar:N,quoteContent:b,shippingInformationTitle:l,shippingInformation:c,quoteCommentsTitle:M,quoteComments:Q,footer:q,...I})=>e?t(Qe,{}):u("div",{...I,className:m(["quote-management-manage-negotiable-quote",p]),children:[u("div",{className:m(["quote-management-manage-negotiable-quote__header"]),children:[o&&t(f,{node:o,className:m(["quote-management-manage-negotiable-quote__quote-name"])}),h&&t(f,{node:h,className:m(["quote-management-manage-negotiable-quote__quote-status"])})]}),g&&t(f,{node:g,className:m(["quote-management-manage-negotiable-quote__banner"])}),a&&t(f,{node:a,className:m(["quote-management-manage-negotiable-quote__details"])}),N&&t(f,{node:N,className:m(["quote-management-manage-negotiable-quote__action-bar"])}),b&&t(f,{node:b,className:m(["quote-management-manage-negotiable-quote__quote-content"])}),u("div",{"data-testid":"quote-shipping-information-container",className:m(["quote-management-manage-negotiable-quote__shipping-information-container"]),children:[l&&t(f,{node:l,className:m(["quote-management-manage-negotiable-quote__shipping-information-title"])}),c&&t(f,{node:c,className:m(["quote-management-manage-negotiable-quote__shipping-information"])})]}),u("div",{"data-testid":"quote-comments-container",className:m(["quote-management-manage-negotiable-quote__quote-comments-container"]),children:[M&&t(f,{node:M,className:m(["quote-management-manage-negotiable-quote__quote-comments-title"])}),Q&&t(f,{node:Q,className:m(["quote-management-manage-negotiable-quote__quote-comments"])})]}),t(f,{node:q,className:m(["quote-management-manage-negotiable-quote__footer"])})]}),Qe=()=>u(ue,{"data-testid":"manage-negotiable-quote-skeleton",children:[t(S,{variant:"heading",fullWidth:!0,size:"large"}),t(S,{variant:"row",fullWidth:!1,size:"small"}),t(S,{variant:"row",fullWidth:!1,size:"small"}),t(S,{variant:"row",fullWidth:!0}),t(S,{variant:"row",fullWidth:!0,size:"xlarge",lines:2}),t(S,{variant:"row",fullWidth:!1,size:"small"})]}),ye=({open:p=!1,title:e,message:o,cancelLabel:h,confirmLabel:g,onCancel:a,onConfirm:N,showCloseButton:b,confirmationBanner:l,...c})=>{const M=G({cancel:"ConfirmationModal.cancel",confirm:"ConfirmationModal.confirm"});if(!p)return null;const{className:Q,...q}=c;return t(ge,{...q,size:"medium",onClose:a,clickToDismiss:!0,escapeToDismiss:!0,showCloseButton:b,"data-testid":"confirmation-modal",className:Q,children:u("div",{className:"confirmation-modal__content",children:[l&&t("div",{className:"confirmation-modal__banner","data-testid":"confirmation-modal-banner",children:l}),e&&t("div",{className:"confirmation-modal__title","data-testid":"confirmation-modal-title",children:e}),o&&t("div",{className:"confirmation-modal__message","data-testid":"confirmation-modal-message",children:o}),u("div",{className:"confirmation-modal__actions","data-testid":"confirmation-modal-actions",children:[t(C,{variant:"secondary",onClick:a,"data-testid":"confirmation-modal-cancel",children:h??M.cancel}),t(C,{variant:"primary",onClick:N,"data-testid":"confirmation-modal-confirm",children:g??M.confirm})]})]})})},Te=({className:p,tabs:e,tabsContent:o,defaultActiveTab:h,...g})=>{const[a,N]=v(h||Array.from(e.keys())[0]),b=c=>{N(c)},l=_(()=>o.get(a),[a,o]);return u("div",{...g,className:m(["quote-management-tabbed-content",p]),children:[e&&t("div",{"data-testid":"tabbed-content-tabs",className:m(["quote-management-tabbed-content__tabs"]),children:Array.from(e.entries()).map(([c,M])=>t("button",{className:m(["quote-management-tabbed-content__tab",["quote-management-tabbed-content__tab--active",c===a]]),onClick:()=>b(c),children:M},c))}),l&&t("div",{className:m(["quote-management-tabbed-content__active-tab-content"]),children:t(f,{node:l})})]})},Oe=({onActionsDropdownChange:p,slots:e,onActionsButtonClick:o,onSendForReview:h,...g})=>{const[a,N]=v(void 0),[b,l]=v(!0),[c,M]=v(!1),[Q,q]=v(null),[I,D]=v(!1),[y,P]=v(""),[x,L]=v(!1),n=G({createdLabel:"NegotiableQuote.Manage.createdLabel",salesRepLabel:"NegotiableQuote.Manage.salesRepLabel",expiresLabel:"NegotiableQuote.Manage.expiresLabel",actionsLabel:"NegotiableQuote.Manage.actionsLabel",remove:"NegotiableQuote.Manage.actions.remove",close:"NegotiableQuote.Manage.actionButtons.close",delete:"NegotiableQuote.Manage.actionButtons.delete",print:"NegotiableQuote.Manage.actionButtons.print",createTemplate:"NegotiableQuote.Manage.actionButtons.createTemplate",createCopy:"NegotiableQuote.Manage.actionButtons.createCopy",shippingInformationTitle:"NegotiableQuote.Manage.shippingInformation.title",quoteCommentsTitle:"NegotiableQuote.Manage.quoteComments.title",quoteCommentsPlaceholder:"NegotiableQuote.Manage.quoteComments.placeholder",sendForReview:"NegotiableQuote.Manage.actionButtons.sendForReview",bannerTitle:"NegotiableQuote.Manage.bannerTitle",statusSubmitted:"NegotiableQuote.Manage.bannerStatusMessages.submitted",statusPending:"NegotiableQuote.Manage.bannerStatusMessages.pending",statusExpired:"NegotiableQuote.Manage.bannerStatusMessages.expired",confirmationModalCancel:"NegotiableQuote.Manage.confirmationModal.cancel",confirmationModalDeleteTitle:"NegotiableQuote.Manage.confirmationModal.delete.title",confirmationModalDeleteMessage:"NegotiableQuote.Manage.confirmationModal.delete.message",confirmationModalDeleteConfirm:"NegotiableQuote.Manage.confirmationModal.delete.confirm",confirmationModalDeleteErrorHeading:"NegotiableQuote.Manage.confirmationModal.delete.errorHeading",confirmationModalDeleteErrorFallback:"NegotiableQuote.Manage.confirmationModal.delete.errorFallback",confirmationModalDeleteSuccessHeading:"NegotiableQuote.Manage.confirmationModal.delete.successHeading",confirmationModalDeleteSuccessDescription:"NegotiableQuote.Manage.confirmationModal.delete.successDescription"});F(()=>{const i=H.on("quote-management/quote-data",d=>{const{quote:r}=d;r&&(N(r),l(!1))},{eager:!0});return()=>i==null?void 0:i.off()},[]),F(()=>{const i=H.on("quote-management/shipping-address-set",d=>{const{quote:r}=d;r&&N(r)},{eager:!0});return()=>i==null?void 0:i.off()},[]),F(()=>{const i=H.on("quote-management/quote-sent-for-review",d=>{const{quote:r}=d;N(r),P(""),L(!1)},{eager:!0});return()=>i==null?void 0:i.off()},[]);const $=_(()=>t(s,{name:"QuoteName",slot:e==null?void 0:e.QuoteName,context:{quoteName:a==null?void 0:a.name,quoteData:a},children:t("h1",{"data-testid":"quote-name",children:a==null?void 0:a.name})}),[e==null?void 0:e.QuoteName,a]),V=_(()=>t(s,{name:"QuoteStatus",slot:e==null?void 0:e.QuoteStatus,context:{quoteStatus:a==null?void 0:a.status,quoteData:a},children:t("div",{"data-testid":"quote-status",children:a==null?void 0:a.status})}),[e==null?void 0:e.QuoteStatus,a]),R=T(i=>{switch(i){case"SUBMITTED":return n.statusSubmitted;case"PENDING":return n.statusPending;case"EXPIRED":return n.statusExpired;default:return null}},[n])(a==null?void 0:a.status),W=R&&t(E,{type:"warning",variant:"secondary",icon:t(k,{}),heading:n.bannerTitle,description:R}),X=W&&t(s,{name:"Banner","data-testid":"banner",slot:e==null?void 0:e.Banner,context:{quoteData:a},children:W}),J=_(()=>{if(!a)return null;const i=le()||"en-US",d=new Intl.DateTimeFormat(i,{year:"numeric",month:"long",day:"numeric"});let r;try{r=d.format(new Date(a.expirationDate))}catch{r=a.expirationDate}return u(s,{name:"Details",slot:e==null?void 0:e.Details,context:{quoteData:a},children:[u("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"created-label",children:n.createdLabel}),u("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"created-value",children:[d.format(new Date(a.createdAt))," (",a.buyer.firstname," ",a.buyer.lastname,")"]})]}),u("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"sales-rep-label",children:n.salesRepLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"sales-rep-value",children:a.salesRepName})]}),u("div",{className:"quote-management-manage-negotiable-quote__detail",children:[t("span",{className:"quote-management-manage-negotiable-quote__detail-title","data-testid":"expires-label",children:n.expiresLabel}),t("span",{className:"quote-management-manage-negotiable-quote__detail-content","data-testid":"expires-value",children:r})]})]})},[e==null?void 0:e.Details,n,a]),z=_(()=>[{label:n.close,value:"close"},{label:n.delete,value:"delete",disabled:!(a!=null&&a.canDelete)},{label:n.print,value:"print"},{label:n.createTemplate,value:"createTemplate"},{label:n.createCopy,value:"createCopy"}],[n,a==null?void 0:a.canDelete]),K=_(()=>{const i=r=>{p==null||p(r)},d=r=>{switch(r){case"close":o==null||o(r);break;case"delete":M(!0),o==null||o(r);break;case"print":o==null||o(r);break;case"createTemplate":o==null||o(r);break;case"createCopy":o==null||o(r);break}};return t(s,{name:"ActionBar",slot:e==null?void 0:e.ActionBar,context:{quoteData:a},children:t(qe,{dropdownPlaceholder:n.actionsLabel,dropdownOptions:[{label:n.remove,value:"remove"}],handleDropdownChange:i,buttons:z.map(r=>t(C,{variant:"tertiary",onClick:()=>d(r.value),"data-testid":`actions-bar-${r.value}-button`,"data-action":r.value,disabled:r.disabled,children:r.label},r.value))})})},[z,n,e==null?void 0:e.ActionBar,a,p,o]),Y=_(()=>t(s,{name:"QuoteContent",slot:e==null?void 0:e.QuoteContent,context:{quoteData:a},children:t(Te,{tabs:new Map([["items-quoted","Items Quoted"],["comments","Comments"],["history-log","History Log"]]),tabsContent:new Map([["items-quoted",t(s,{name:"ItemsQuotedTab",slot:e==null?void 0:e.ItemsQuotedTab,context:{quoteData:a},children:t(pe,{quoteData:a})},"items-quoted")],["comments",t(s,{name:"CommentsTab",slot:e==null?void 0:e.CommentsTab,context:{quoteData:a},children:t(Me,{quoteData:a})},"comments")],["history-log",t(s,{name:"HistoryLogTab",slot:e==null?void 0:e.HistoryLogTab,context:{quoteData:a},children:t(fe,{quoteData:a})},"history-log")]])})}),[e==null?void 0:e.QuoteContent,e==null?void 0:e.HistoryLogTab,e==null?void 0:e.CommentsTab,e==null?void 0:e.ItemsQuotedTab,a]),Z=_(()=>t(s,{name:"ShippingInformationTitle",slot:e==null?void 0:e.ShippingInformationTitle,context:{quoteData:a},children:t("h2",{children:n.shippingInformationTitle})}),[e==null?void 0:e.ShippingInformationTitle,a,n]),O=_(()=>t(s,{name:"ShippingInformation",slot:e==null?void 0:e.ShippingInformation,context:{quoteData:a,loading:b,setLoading:l},children:t(be,{quoteData:a,loading:b,"data-testid":"manage-quote-shipping-address"})}),[e==null?void 0:e.ShippingInformation,a,b,l]),B=_(()=>t(s,{name:"QuoteCommentsTitle",slot:e==null?void 0:e.QuoteCommentsTitle,context:{quoteData:a},children:t("h2",{children:n.quoteCommentsTitle})}),[e==null?void 0:e.QuoteCommentsTitle,n,a]),A=_(()=>t(s,{name:"QuoteComments",slot:e==null?void 0:e.QuoteComments,context:{quoteData:a},children:t(se,{name:"quoteComments",placeholder:n.quoteCommentsPlaceholder,rows:3,value:y,onInput:i=>{P(i.target.value)},disabled:x})}),[e==null?void 0:e.QuoteComments,n,a,y,x]),U=T(async()=>{if(h){h({quoteData:a,comment:y.trim()||void 0});return}L(!0);try{await he({quoteUid:a.uid,comment:y.trim()||void 0})}catch(i){console.error("Failed to send quote for review:",i),L(!1)}},[a,h,y]),ee=_(()=>t(s,{name:"Footer",slot:e==null?void 0:e.Footer,context:{quoteData:a,comment:y,isSubmitting:x},children:t(C,{variant:"primary",onClick:U,"data-testid":"send-for-review-button",disabled:!(a!=null&&a.canSendForReview)||x||!a,children:n.sendForReview})}),[e==null?void 0:e.Footer,n,a,y,x,U]),w=T(i=>i.errors&&Array.isArray(i.errors)&&i.errors.length>0?i.errors[0].message||n.confirmationModalDeleteErrorFallback:(i==null?void 0:i.message)||n.confirmationModalDeleteErrorFallback,[n.confirmationModalDeleteErrorFallback]),ae=T(()=>{M(!1),q(null),D(!1)},[]),te=T(async()=>{if(a!=null&&a.uid){q(null),D(!1);try{const{operationResults:i}=await Ne(a.uid),d=i.find(r=>r.__typename==="DeleteNegotiableQuoteOperationFailure");if(d){const r=w(d);q(r);return}D(!0)}catch(i){const d=w(i);q(d)}}},[a,w]),ne=T(()=>{q(null)},[]),ie=T(()=>{D(!1)},[]),oe=Q?t(E,{type:"error",variant:"primary",icon:t(k,{}),heading:n.confirmationModalDeleteErrorHeading,description:Q,onDismiss:ne,"data-testid":"confirmation-modal-error-banner"}):null,j=(I?t(E,{type:"success",variant:"primary",icon:t(_e,{}),heading:n.confirmationModalDeleteSuccessHeading,description:n.confirmationModalDeleteSuccessDescription,onDismiss:ie,"data-testid":"confirmation-modal-success-banner"}):null)||oe,re={...g,loading:b,quoteName:$,quoteStatus:V,banner:X||void 0,details:J,actionBar:K,quoteContent:Y,shippingInformationTitle:Z,shippingInformation:O,quoteCommentsTitle:B,quoteComments:A,footer:ee};return u(me,{children:[t(ve,{...re}),c&&ce(t(ye,{open:c,title:n.confirmationModalDeleteTitle,message:n.confirmationModalDeleteMessage,cancelLabel:n.confirmationModalCancel,confirmLabel:n.confirmationModalDeleteConfirm,onCancel:ae,onConfirm:te,showCloseButton:!j,confirmationBanner:j}),document.body)]})};export{Oe as ManageNegotiableQuote,Oe as default};
|
|
4
4
|
//# sourceMappingURL=ManageNegotiableQuote.js.map
|