@dropins/storefront-quote-management 0.0.1-alpha15 → 0.0.1-alpha17

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{D as a,s as n,t as p}from"./chunks/transform-quote.js";import{fetchGraphQl as _}from"@dropins/tools/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";import{f as Q}from"./chunks/uploadFile.js";import{g as H,b as L,r as B,s as V,a as Y,c as K,u as J}from"./chunks/uploadFile.js";import{N as h}from"./chunks/NegotiableQuoteFragment.js";import{F as X,N as Z,S as ee,n as te}from"./chunks/negotiableQuotes.js";import{s as se}from"./chunks/sendForReview.js";import{Initializer as q}from"@dropins/tools/lib.js";const I=`
3
+ import{D as i,s as n,f as l,t as Q}from"./chunks/fetch-graphql.js";import{e as j,r as z,b as H,c as L,d as B}from"./chunks/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";import{r as Y,u as K}from"./chunks/uploadFile.js";import{N as h}from"./chunks/NegotiableQuoteFragment.js";import{F as W,N as X,S as Z,n as ee}from"./chunks/negotiableQuotes.js";import{s as oe}from"./chunks/sendForReview.js";import{Initializer as _}from"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const q=`
4
4
  fragment CUSTOMER_FRAGMENT on Customer {
5
5
  role {
6
6
  permissions {
@@ -17,15 +17,15 @@ import{D as a,s as n,t as p}from"./chunks/transform-quote.js";import{fetchGraphQ
17
17
  }
18
18
  }
19
19
  }
20
- `,T=`
20
+ `,I=`
21
21
  query CUSTOMER_QUERY {
22
22
  customer {
23
23
  ...CUSTOMER_FRAGMENT
24
24
  }
25
25
  }
26
26
 
27
- ${I}
28
- `,S="All/Quotes/View/Request, Edit, Delete",A="All/Quotes/View/Request, Edit, Delete",N="All/Quotes/View/Request, Edit, Delete",U="All/Quotes/View/Checkout with quote",R=o=>{const e=[],t=(s,u=[])=>{for(const i of s){const d=[...u,i.text];i.children&&i.children.length>0?t(i.children,d):e.push(d.join("/"))}};return t(o),e};function D(o){const{role:e}=o;if(!e)return{permissions:{canRequestQuote:a.requestQuote,canEditQuote:a.editQuote,canDeleteQuote:a.deleteQuote,canCheckoutQuote:a.checkoutQuote}};const{permissions:t}=e,s=R(t);return{permissions:{canRequestQuote:s.includes(S),canEditQuote:s.includes(A),canDeleteQuote:s.includes(N),canCheckoutQuote:s.includes(U)}}}const w=async()=>{var o;if(!n.authenticated)return Promise.reject(new Error("Unauthorized"));try{const e=await Q(T);if(!((o=e==null?void 0:e.data)!=null&&o.customer))throw new Error("No customer data received");return D(e.data.customer)}catch(e){return Promise.reject(e)}},C=`
27
+ ${q}
28
+ `,T="All/Quotes/View/Request, Edit, Delete",S="All/Quotes/View/Request, Edit, Delete",A="All/Quotes/View/Request, Edit, Delete",N="All/Quotes/View/Checkout with quote",U=o=>{const e=[],t=(s,u=[])=>{for(const a of s){const d=[...u,a.text];a.children&&a.children.length>0?t(a.children,d):e.push(d.join("/"))}};return t(o),e};function R(o){const{role:e}=o;if(!e)return{permissions:{canRequestQuote:i.requestQuote,canEditQuote:i.editQuote,canDeleteQuote:i.deleteQuote,canCheckoutQuote:i.checkoutQuote}};const{permissions:t}=e,s=U(t);return{permissions:{canRequestQuote:s.includes(T),canEditQuote:s.includes(S),canDeleteQuote:s.includes(A),canCheckoutQuote:s.includes(N)}}}const D=async()=>{var o;if(!n.authenticated)return Promise.reject(new Error("Unauthorized"));try{const e=await l(I);if(!((o=e==null?void 0:e.data)!=null&&o.customer))throw new Error("No customer data received");return R(e.data.customer)}catch(e){return Promise.reject(e)}},w=`
29
29
  query QUOTE_DATA_QUERY(
30
30
  $quoteId: ID!
31
31
  ) {
@@ -37,7 +37,7 @@ import{D as a,s as n,t as p}from"./chunks/transform-quote.js";import{fetchGraphQ
37
37
  }
38
38
 
39
39
  ${h}
40
- `,O=async o=>{var e;if(!n.authenticated)return Promise.reject(new Error("Unauthorized"));if(!n.permissions.editQuote)return Promise.reject(new Error("Unauthorized"));try{const t=await Q(C,{variables:{quoteId:o}}),s=p((e=t==null?void 0:t.data)==null?void 0:e.negotiableQuote);if(!s)throw new Error("Failed to transform quote data");return r.emit("quote-management/quote-data",{quote:s,permissions:n.permissions}),s}catch(t){return Promise.reject(t)}},m=new q({init:async o=>{const e={};m.config.setConfig({...e,...o})},listeners:()=>[r.on("authenticated",async o=>{n.authenticated=!!o,o?w().then(e=>{n.permissions={requestQuote:e.permissions.canRequestQuote,editQuote:e.permissions.canEditQuote,deleteQuote:e.permissions.canDeleteQuote,checkoutQuote:e.permissions.canCheckoutQuote},r.emit("quote-management/permissions",n.permissions)}).catch(e=>{console.error(e),n.permissions=a,r.emit("quote-management/permissions",a)}):(n.permissions=a,r.emit("quote-management/permissions",a))},{eager:!0}),r.on("quote-management/permissions",async o=>{const e=m.config.getConfig().quoteId;e&&o.editQuote&&O(e).then(t=>{r.emit("quote-management/quote-data/initialized",{quote:t,permissions:o},{})}).catch(t=>{r.emit("quote-management/quote-data/error",{error:t})})},{eager:!0})]}),k=m.config,F=`
40
+ `,C=async o=>{var e;if(!n.authenticated)return Promise.reject(new Error("Unauthorized"));if(!n.permissions.editQuote)return Promise.reject(new Error("Unauthorized"));try{const t=await l(w,{variables:{quoteId:o}}),s=Q((e=t==null?void 0:t.data)==null?void 0:e.negotiableQuote);if(!s)throw new Error("Failed to transform quote data");return r.emit("quote-management/quote-data",{quote:s,permissions:n.permissions}),s}catch(t){return Promise.reject(t)}},m=new _({init:async o=>{const e={};m.config.setConfig({...e,...o})},listeners:()=>[r.on("authenticated",async o=>{n.authenticated=!!o,o?D().then(e=>{n.permissions={requestQuote:e.permissions.canRequestQuote,editQuote:e.permissions.canEditQuote,deleteQuote:e.permissions.canDeleteQuote,checkoutQuote:e.permissions.canCheckoutQuote},r.emit("quote-management/permissions",n.permissions)}).catch(e=>{console.error(e),n.permissions=i,r.emit("quote-management/permissions",i)}):(n.permissions=i,r.emit("quote-management/permissions",i))},{eager:!0}),r.on("quote-management/permissions",async o=>{const e=m.config.getConfig().quoteId;e&&o.editQuote&&C(e).then(t=>{r.emit("quote-management/quote-data/initialized",{quote:t,permissions:o},{})}).catch(t=>{r.emit("quote-management/quote-data/error",{error:t})})},{eager:!0})]}),G=m.config,O=`
41
41
  mutation SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION(
42
42
  $quoteUid: ID!
43
43
  $addressId: ID
@@ -58,5 +58,5 @@ import{D as a,s as n,t as p}from"./chunks/transform-quote.js";import{fetchGraphQ
58
58
  }
59
59
  }
60
60
  ${h}
61
- `;function M(o){const{additionalInput:e,...t}=o,s={city:t.city,company:t.company,country_code:t.countryCode,firstname:t.firstname,lastname:t.lastname,postcode:t.postcode,region:t.region,region_id:t.regionId,save_in_address_book:t.saveInAddressBook,street:t.street,telephone:t.telephone};return{...e||{},...s}}const x=async o=>{const{quoteUid:e,addressId:t,addressData:s}=o;if(!e)throw new Error("Quote UID is required");if(t===void 0&&!s)throw new Error("Either addressId or addressData must be provided");if(t!==void 0&&s)throw new Error("Cannot provide both addressId and addressData");const u=s?M(s):null;return _(F,{variables:{quoteUid:e,addressId:t||null,addressData:u}}).then(i=>{var l,E;const{errors:d}=i;if(d){const f=d.map(g=>g.message).join("; ");throw new Error(`Failed to set shipping address: ${f}`)}const c=p((E=(l=i.data)==null?void 0:l.setNegotiableQuoteShippingAddress)==null?void 0:E.quote);if(!c)throw new Error("Failed to transform quote data: Invalid response structure");return r.emit("quote-management/shipping-address-set",{quote:c,input:{quoteUid:e,addressId:t,addressData:s}}),c})};export{X as FilterMatchTypeEnum,Z as NegotiableQuoteSortableField,ee as SortEnum,k as config,Q as fetchGraphQl,H as getConfig,w as getCustomerData,O as getQuoteData,m as initialize,te as negotiableQuotes,L as removeFetchGraphQlHeader,B as requestNegotiableQuote,se as sendForReview,V as setEndpoint,Y as setFetchGraphQlHeader,K as setFetchGraphQlHeaders,x as setShippingAddress,J as uploadFile};
61
+ `;function F(o){const{additionalInput:e,...t}=o,s={city:t.city,company:t.company,country_code:t.countryCode,firstname:t.firstname,lastname:t.lastname,postcode:t.postcode,region:t.region,region_id:t.regionId,save_in_address_book:t.saveInAddressBook,street:t.street,telephone:t.telephone};return{...e||{},...s}}const $=async o=>{const{quoteUid:e,addressId:t,addressData:s}=o;if(!e)throw new Error("Quote UID is required");if(t===void 0&&!s)throw new Error("Either addressId or addressData must be provided");if(t!==void 0&&s)throw new Error("Cannot provide both addressId and addressData");const u=s?F(s):null;return l(O,{variables:{quoteUid:e,addressId:t||null,addressData:u}}).then(a=>{var E,p;const{errors:d}=a;if(d){const f=d.map(g=>g.message).join("; ");throw new Error(`Failed to set shipping address: ${f}`)}const c=Q((p=(E=a.data)==null?void 0:E.setNegotiableQuoteShippingAddress)==null?void 0:p.quote);if(!c)throw new Error("Failed to transform quote data: Invalid response structure");return r.emit("quote-management/shipping-address-set",{quote:c,input:{quoteUid:e,addressId:t,addressData:s}}),c})};export{W as FilterMatchTypeEnum,X as NegotiableQuoteSortableField,Z as SortEnum,G as config,l as fetchGraphQl,j as getConfig,D as getCustomerData,C as getQuoteData,m as initialize,ee as negotiableQuotes,z as removeFetchGraphQlHeader,Y as requestNegotiableQuote,oe as sendForReview,H as setEndpoint,L as setFetchGraphQlHeader,B as setFetchGraphQlHeaders,$ as setShippingAddress,K as uploadFile};
62
62
  //# sourceMappingURL=api.js.map
package/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/CustomerFragment.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/graphql/CustomerQuery.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-customer.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/graphql/QuoteDataQuery.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/getQuoteData.ts","/@dropins/storefront-quote-management/src/api/initialize/initialize.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/graphql/SetNegotiableQuoteShippingAddressMutation.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/setShippingAddress.ts"],"sourcesContent":["export const CUSTOMER_FRAGMENT = /* GraphQL */ `\n fragment CUSTOMER_FRAGMENT on Customer {\n role {\n permissions {\n text\n children {\n text\n children {\n text\n children {\n text\n }\n }\n }\n }\n }\n }\n`","import { CUSTOMER_FRAGMENT } from '@/quote-management/api/graphql/CustomerFragment';\n\nexport const CUSTOMER_QUERY = `\n query CUSTOMER_QUERY {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\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 { DEFAULT_PERMISSIONS } from \"@/quote-management/lib/state\";\nimport { CustomerModel } from \"../models\";\n\ntype PermissionsSchema = {\n text: string;\n children: PermissionsSchema[];\n}\n\nconst CAN_REQUEST_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_EDIT_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_DELETE_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_CHECKOUT_QUOTE_PERMISSION = 'All/Quotes/View/Checkout with quote';\n\n/**\n * Flatten the permissions into a list of strings\n * @param permissions - The permissions to flatten\n * @returns A list of strings representing the flattened permissions\n */\nexport const flattenPermissions = (permissions: PermissionsSchema[]): string[] => {\n const result: string[] = [];\n \n // Recursively traverse the permissions and build the path\n const traverse = (nodes: PermissionsSchema[], path: string[] = []) => {\n for (const node of nodes) {\n const currentPath = [...path, node.text];\n \n if (node.children && node.children.length > 0) {\n traverse(node.children, currentPath);\n } else {\n result.push(currentPath.join('/'));\n }\n }\n };\n \n traverse(permissions);\n return result;\n}\n\nexport function transformCustomer(customerData: any): CustomerModel {\n const { role } = customerData;\n\n if (!role) {\n return {\n permissions: {\n canRequestQuote: DEFAULT_PERMISSIONS.requestQuote,\n canEditQuote: DEFAULT_PERMISSIONS.editQuote,\n canDeleteQuote: DEFAULT_PERMISSIONS.deleteQuote,\n canCheckoutQuote: DEFAULT_PERMISSIONS.checkoutQuote,\n },\n };\n }\n\n const { permissions } = role;\n\n const flattenedPermissions = flattenPermissions(permissions);\n return {\n permissions: {\n canRequestQuote: flattenedPermissions.includes(CAN_REQUEST_QUOTE_PERMISSION),\n canEditQuote: flattenedPermissions.includes(CAN_EDIT_QUOTE_PERMISSION),\n canDeleteQuote: flattenedPermissions.includes(CAN_DELETE_QUOTE_PERMISSION),\n canCheckoutQuote: flattenedPermissions.includes(CAN_CHECKOUT_QUOTE_PERMISSION),\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 { CUSTOMER_QUERY } from './graphql/CustomerQuery';\nimport { transformCustomer } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport const getCustomerData = async () => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(CUSTOMER_QUERY);\n \n if (!results?.data?.customer) {\n throw new Error('No customer data received');\n }\n \n return transformCustomer(results.data.customer);\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const QUOTE_DATA_QUERY = `\n query QUOTE_DATA_QUERY(\n $quoteId: ID!\n ) {\n negotiableQuote(\n uid: $quoteId\n ) {\n ...NegotiableQuoteFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { QUOTE_DATA_QUERY } from './graphql/QuoteDataQuery';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteData = async (quoteId: string) => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n if (!state.permissions.editQuote) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_DATA_QUERY, {\n variables: {\n quoteId\n }\n });\n\n const transformedQuote = transformQuote(results?.data?.negotiableQuote);\n\n if (!transformedQuote) {\n throw new Error('Failed to transform quote data');\n }\n\n events.emit('quote-management/quote-data', {\n quote: transformedQuote,\n permissions: state.permissions,\n });\n \n return transformedQuote;\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state, DEFAULT_PERMISSIONS } from '@/quote-management/lib/state';\nimport { getCustomerData } from '@/quote-management/api/getCustomerData';\nimport { getQuoteData } from '@/quote-management/api/getQuoteData';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n quoteId?: string;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {};\n\n initialize.config.setConfig({ ...defaultConfig, ...config });\n },\n\n listeners: () => [\n events.on('authenticated', async (authenticated) => {\n state.authenticated = !!authenticated;\n\n if (authenticated) {\n getCustomerData().then((customerData) => {\n state.permissions = {\n requestQuote: customerData.permissions.canRequestQuote,\n editQuote: customerData.permissions.canEditQuote,\n deleteQuote: customerData.permissions.canDeleteQuote,\n checkoutQuote: customerData.permissions.canCheckoutQuote,\n };\n events.emit('quote-management/permissions', state.permissions);\n })\n .catch((error) => {\n console.error(error);\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n });\n } else {\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n }\n }, {\n eager: true,\n }),\n events.on('quote-management/permissions', async (permissions) => {\n const quoteId = initialize.config.getConfig().quoteId;\n if (!quoteId) {\n return;\n }\n\n if (permissions.editQuote) {\n getQuoteData(quoteId).then((quoteData) => {\n events.emit('quote-management/quote-data/initialized', {\n quote: quoteData,\n permissions,\n }, {});\n }).catch((error) => {\n events.emit('quote-management/quote-data/error', {\n error,\n });\n });\n }\n }, {\n eager: true,\n }),\n ],\n});\n\nexport const config = initialize.config;\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 SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION = `\n mutation SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION(\n $quoteUid: ID!\n $addressId: ID\n $addressData: NegotiableQuoteAddressInput\n ) {\n setNegotiableQuoteShippingAddress(\n input: {\n quote_uid: $quoteUid\n shipping_addresses: {\n customer_address_uid: $addressId\n address: $addressData\n }\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 '@adobe-commerce/fetch-graphql';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION } from './graphql/SetNegotiableQuoteShippingAddressMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface AddressInput {\n /** City name */\n city: string;\n /** Optional company name */\n company?: string;\n /** Two-letter country code (e.g., 'US') */\n countryCode: string;\n /** First name */\n firstname: string;\n /** Last name */\n lastname: string;\n /** Postal/ZIP code */\n postcode: string;\n /** Optional state/province name */\n region?: string;\n /** Optional state/province ID */\n regionId?: number;\n /** Whether to save this address to the customer's address book */\n saveInAddressBook?: boolean;\n /** Street address lines (array) */\n street: string[];\n /** Phone number */\n telephone: string;\n /** \n * Additional input (optional custom fields for the address).\n * These fields will be merged into the address data sent to GraphQL.\n * Standard fields take precedence over additional fields to prevent\n * accidental override of required address attributes.\n * \n * @example\n * ```ts\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute: 'value',\n * delivery_instructions: 'Leave at door'\n * }\n * ```\n */\n additionalInput?: Record<string, any>;\n}\n\nexport interface SetShippingAddressInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** The ID of a saved customer address (use this OR addressData, not both) */\n addressId?: number;\n /** New address data (use this OR addressId, not both) */\n addressData?: AddressInput;\n}\n\n/**\n * Transform camelCase address data to snake_case for GraphQL mutation.\n * Additional fields from additionalInput are spread into the result, with\n * standard fields taking precedence (defensive flexibility approach).\n */\nfunction transformAddressToSnakeCase(address: AddressInput) {\n const { additionalInput, ...standardFields } = address;\n \n // Build the standard transformed fields\n const transformedStandardFields = {\n city: standardFields.city,\n company: standardFields.company,\n country_code: standardFields.countryCode,\n firstname: standardFields.firstname,\n lastname: standardFields.lastname,\n postcode: standardFields.postcode,\n region: standardFields.region,\n region_id: standardFields.regionId,\n save_in_address_book: standardFields.saveInAddressBook,\n street: standardFields.street,\n telephone: standardFields.telephone,\n };\n \n // Spread additional input first, then standard fields take precedence\n // This provides defensive flexibility: allows custom fields while protecting core fields\n return {\n ...(additionalInput || {}),\n ...transformedStandardFields,\n };\n}\n\n/**\n * Sets or updates the shipping address for a negotiable quote.\n * \n * @param input - The input parameters for setting the shipping address\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.addressId - Optional ID of a saved customer address (use this OR addressData)\n * @param input.addressData - Optional new address data (use this OR addressId)\n * @param input.addressData.additionalInput - Optional additional address fields to pass through to GraphQL\n * @returns Promise that resolves to the updated quote model with shipping addresses including uid field\n * @throws Error if validation fails or GraphQL operation fails\n * \n * @example\n * ```ts\n * // Using a saved address\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressId: 5\n * });\n * \n * // Using new address data\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234'\n * }\n * });\n * \n * // Using address data with additional custom fields\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234',\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute_1: 'value1',\n * delivery_instructions: 'Leave at door'\n * }\n * }\n * });\n * \n * // Access address identifier\n * if (quote?.shippingAddresses?.[0]) {\n * console.log('Address UID:', quote.shippingAddresses[0].uid);\n * }\n * ```\n */\nexport const setShippingAddress = async (\n input: SetShippingAddressInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, addressId, addressData } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate that exactly one of addressId or addressData is provided\n if (addressId === undefined && !addressData) {\n throw new Error('Either addressId or addressData must be provided');\n }\n\n if (addressId !== undefined && addressData) {\n throw new Error('Cannot provide both addressId and addressData');\n }\n\n // Transform addressData to snake_case if provided\n const transformedAddressData = addressData\n ? transformAddressToSnakeCase(addressData)\n : null;\n\n return fetchGraphQl(SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION, {\n variables: {\n quoteUid,\n addressId: addressId || null,\n addressData: transformedAddressData,\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 set shipping address: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.setNegotiableQuoteShippingAddress?.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/shipping-address-set', {\n quote: quoteData,\n input: { quoteUid, addressId, addressData },\n });\n\n return quoteData;\n });\n};\n\n"],"names":["CUSTOMER_FRAGMENT","CUSTOMER_QUERY","CAN_REQUEST_QUOTE_PERMISSION","CAN_EDIT_QUOTE_PERMISSION","CAN_DELETE_QUOTE_PERMISSION","CAN_CHECKOUT_QUOTE_PERMISSION","flattenPermissions","permissions","result","traverse","nodes","path","node","currentPath","transformCustomer","customerData","role","DEFAULT_PERMISSIONS","flattenedPermissions","getCustomerData","state","results","fetchGraphQl","_a","error","QUOTE_DATA_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","getQuoteData","quoteId","transformedQuote","transformQuote","events","initialize","Initializer","config","defaultConfig","authenticated","quoteData","SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION","transformAddressToSnakeCase","address","additionalInput","standardFields","transformedStandardFields","setShippingAddress","input","quoteUid","addressId","addressData","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A,EACvB,GAAGE,CAAA,CAEP,CA4DO,MAAMC,EAAqB,MAChCC,GACyC,CACzC,KAAM,CAAE,SAAAC,EAAU,UAAAC,EAAW,YAAAC,CAAA,EAAgBH,EAE7C,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,uBAAuB,EAIzC,GAAIC,IAAc,QAAa,CAACC,EAC9B,MAAM,IAAI,MAAM,kDAAkD,EAGpE,GAAID,IAAc,QAAaC,EAC7B,MAAM,IAAI,MAAM,+CAA+C,EAIjE,MAAMC,EAAyBD,EAC3BT,EAA4BS,CAAW,EACvC,KAEJ,OAAO1B,EAAagB,EAAgD,CAClE,UAAW,CACT,SAAAQ,EACA,UAAWC,GAAa,KACxB,YAAaE,CAAA,CACf,CACD,EAAE,KAAMC,GAAa,SACpB,KAAM,CAAE,OAAAC,GAAWD,EAEnB,GAAIC,EAAQ,CAEV,MAAMC,EAAgBD,EAAO,IAAK3B,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MAAM,mCAAmC4B,CAAa,EAAE,CACpE,CAGA,MAAMf,EAAYP,GAChBuB,GAAA9B,EAAA2B,EAAS,OAAT,YAAA3B,EAAe,oCAAf,YAAA8B,EAAkD,KAAA,EAGpD,GAAI,CAAChB,EACH,MAAM,IAAI,MACR,4DAAA,EAKJ,OAAAN,EAAO,KAAK,wCAAyC,CACnD,MAAOM,EACP,MAAO,CAAE,SAAAS,EAAU,UAAAC,EAAW,YAAAC,CAAA,CAAY,CAC3C,EAEMX,CACT,CAAC,CACH"}
1
+ {"version":3,"file":"api.js","sources":["/@dropins/storefront-quote-management/src/api/graphql/CustomerFragment.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/graphql/CustomerQuery.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-customer.ts","/@dropins/storefront-quote-management/src/api/getCustomerData/getCustomerData.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/graphql/QuoteDataQuery.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/getQuoteData.ts","/@dropins/storefront-quote-management/src/api/initialize/initialize.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/graphql/SetNegotiableQuoteShippingAddressMutation.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/setShippingAddress.ts"],"sourcesContent":["export const CUSTOMER_FRAGMENT = /* GraphQL */ `\n fragment CUSTOMER_FRAGMENT on Customer {\n role {\n permissions {\n text\n children {\n text\n children {\n text\n children {\n text\n }\n }\n }\n }\n }\n }\n`","import { CUSTOMER_FRAGMENT } from '@/quote-management/api/graphql/CustomerFragment';\n\nexport const CUSTOMER_QUERY = `\n query CUSTOMER_QUERY {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\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 { DEFAULT_PERMISSIONS } from \"@/quote-management/lib/state\";\nimport { CustomerModel } from \"../models\";\n\ntype PermissionsSchema = {\n text: string;\n children: PermissionsSchema[];\n}\n\nconst CAN_REQUEST_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_EDIT_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_DELETE_QUOTE_PERMISSION = 'All/Quotes/View/Request, Edit, Delete';\nconst CAN_CHECKOUT_QUOTE_PERMISSION = 'All/Quotes/View/Checkout with quote';\n\n/**\n * Flatten the permissions into a list of strings\n * @param permissions - The permissions to flatten\n * @returns A list of strings representing the flattened permissions\n */\nexport const flattenPermissions = (permissions: PermissionsSchema[]): string[] => {\n const result: string[] = [];\n \n // Recursively traverse the permissions and build the path\n const traverse = (nodes: PermissionsSchema[], path: string[] = []) => {\n for (const node of nodes) {\n const currentPath = [...path, node.text];\n \n if (node.children && node.children.length > 0) {\n traverse(node.children, currentPath);\n } else {\n result.push(currentPath.join('/'));\n }\n }\n };\n \n traverse(permissions);\n return result;\n}\n\nexport function transformCustomer(customerData: any): CustomerModel {\n const { role } = customerData;\n\n if (!role) {\n return {\n permissions: {\n canRequestQuote: DEFAULT_PERMISSIONS.requestQuote,\n canEditQuote: DEFAULT_PERMISSIONS.editQuote,\n canDeleteQuote: DEFAULT_PERMISSIONS.deleteQuote,\n canCheckoutQuote: DEFAULT_PERMISSIONS.checkoutQuote,\n },\n };\n }\n\n const { permissions } = role;\n\n const flattenedPermissions = flattenPermissions(permissions);\n return {\n permissions: {\n canRequestQuote: flattenedPermissions.includes(CAN_REQUEST_QUOTE_PERMISSION),\n canEditQuote: flattenedPermissions.includes(CAN_EDIT_QUOTE_PERMISSION),\n canDeleteQuote: flattenedPermissions.includes(CAN_DELETE_QUOTE_PERMISSION),\n canCheckoutQuote: flattenedPermissions.includes(CAN_CHECKOUT_QUOTE_PERMISSION),\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 { CUSTOMER_QUERY } from './graphql/CustomerQuery';\nimport { transformCustomer } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport const getCustomerData = async () => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(CUSTOMER_QUERY);\n \n if (!results?.data?.customer) {\n throw new Error('No customer data received');\n }\n \n return transformCustomer(results.data.customer);\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const QUOTE_DATA_QUERY = `\n query QUOTE_DATA_QUERY(\n $quoteId: ID!\n ) {\n negotiableQuote(\n uid: $quoteId\n ) {\n ...NegotiableQuoteFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { QUOTE_DATA_QUERY } from './graphql/QuoteDataQuery';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteData = async (quoteId: string) => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n if (!state.permissions.editQuote) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_DATA_QUERY, {\n variables: {\n quoteId\n }\n });\n\n const transformedQuote = transformQuote(results?.data?.negotiableQuote);\n\n if (!transformedQuote) {\n throw new Error('Failed to transform quote data');\n }\n\n events.emit('quote-management/quote-data', {\n quote: transformedQuote,\n permissions: state.permissions,\n });\n \n return transformedQuote;\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state, DEFAULT_PERMISSIONS } from '@/quote-management/lib/state';\nimport { getCustomerData } from '@/quote-management/api/getCustomerData';\nimport { getQuoteData } from '@/quote-management/api/getQuoteData';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n quoteId?: string;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {};\n\n initialize.config.setConfig({ ...defaultConfig, ...config });\n },\n\n listeners: () => [\n events.on('authenticated', async (authenticated) => {\n state.authenticated = !!authenticated;\n\n if (authenticated) {\n getCustomerData().then((customerData) => {\n state.permissions = {\n requestQuote: customerData.permissions.canRequestQuote,\n editQuote: customerData.permissions.canEditQuote,\n deleteQuote: customerData.permissions.canDeleteQuote,\n checkoutQuote: customerData.permissions.canCheckoutQuote,\n };\n events.emit('quote-management/permissions', state.permissions);\n })\n .catch((error) => {\n console.error(error);\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n });\n } else {\n state.permissions = DEFAULT_PERMISSIONS;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n }\n }, {\n eager: true,\n }),\n events.on('quote-management/permissions', async (permissions) => {\n const quoteId = initialize.config.getConfig().quoteId;\n if (!quoteId) {\n return;\n }\n\n if (permissions.editQuote) {\n getQuoteData(quoteId).then((quoteData) => {\n events.emit('quote-management/quote-data/initialized', {\n quote: quoteData,\n permissions,\n }, {});\n }).catch((error) => {\n events.emit('quote-management/quote-data/error', {\n error,\n });\n });\n }\n }, {\n eager: true,\n }),\n ],\n});\n\nexport const config = initialize.config;\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 SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION = `\n mutation SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION(\n $quoteUid: ID!\n $addressId: ID\n $addressData: NegotiableQuoteAddressInput\n ) {\n setNegotiableQuoteShippingAddress(\n input: {\n quote_uid: $quoteUid\n shipping_addresses: {\n customer_address_uid: $addressId\n address: $addressData\n }\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 { SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION } from './graphql/SetNegotiableQuoteShippingAddressMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface AddressInput {\n /** City name */\n city: string;\n /** Optional company name */\n company?: string;\n /** Two-letter country code (e.g., 'US') */\n countryCode: string;\n /** First name */\n firstname: string;\n /** Last name */\n lastname: string;\n /** Postal/ZIP code */\n postcode: string;\n /** Optional state/province name */\n region?: string;\n /** Optional state/province ID */\n regionId?: number;\n /** Whether to save this address to the customer's address book */\n saveInAddressBook?: boolean;\n /** Street address lines (array) */\n street: string[];\n /** Phone number */\n telephone: string;\n /** \n * Additional input (optional custom fields for the address).\n * These fields will be merged into the address data sent to GraphQL.\n * Standard fields take precedence over additional fields to prevent\n * accidental override of required address attributes.\n * \n * @example\n * ```ts\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute: 'value',\n * delivery_instructions: 'Leave at door'\n * }\n * ```\n */\n additionalInput?: Record<string, any>;\n}\n\nexport interface SetShippingAddressInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** The ID of a saved customer address (use this OR addressData, not both) */\n addressId?: number;\n /** New address data (use this OR addressId, not both) */\n addressData?: AddressInput;\n}\n\n/**\n * Transform camelCase address data to snake_case for GraphQL mutation.\n * Additional fields from additionalInput are spread into the result, with\n * standard fields taking precedence (defensive flexibility approach).\n */\nfunction transformAddressToSnakeCase(address: AddressInput) {\n const { additionalInput, ...standardFields } = address;\n \n // Build the standard transformed fields\n const transformedStandardFields = {\n city: standardFields.city,\n company: standardFields.company,\n country_code: standardFields.countryCode,\n firstname: standardFields.firstname,\n lastname: standardFields.lastname,\n postcode: standardFields.postcode,\n region: standardFields.region,\n region_id: standardFields.regionId,\n save_in_address_book: standardFields.saveInAddressBook,\n street: standardFields.street,\n telephone: standardFields.telephone,\n };\n \n // Spread additional input first, then standard fields take precedence\n // This provides defensive flexibility: allows custom fields while protecting core fields\n return {\n ...(additionalInput || {}),\n ...transformedStandardFields,\n };\n}\n\n/**\n * Sets or updates the shipping address for a negotiable quote.\n * \n * @param input - The input parameters for setting the shipping address\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.addressId - Optional ID of a saved customer address (use this OR addressData)\n * @param input.addressData - Optional new address data (use this OR addressId)\n * @param input.addressData.additionalInput - Optional additional address fields to pass through to GraphQL\n * @returns Promise that resolves to the updated quote model with shipping addresses including uid field\n * @throws Error if validation fails or GraphQL operation fails\n * \n * @example\n * ```ts\n * // Using a saved address\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressId: 5\n * });\n * \n * // Using new address data\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234'\n * }\n * });\n * \n * // Using address data with additional custom fields\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234',\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute_1: 'value1',\n * delivery_instructions: 'Leave at door'\n * }\n * }\n * });\n * \n * // Access address identifier\n * if (quote?.shippingAddresses?.[0]) {\n * console.log('Address UID:', quote.shippingAddresses[0].uid);\n * }\n * ```\n */\nexport const setShippingAddress = async (\n input: SetShippingAddressInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, addressId, addressData } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate that exactly one of addressId or addressData is provided\n if (addressId === undefined && !addressData) {\n throw new Error('Either addressId or addressData must be provided');\n }\n\n if (addressId !== undefined && addressData) {\n throw new Error('Cannot provide both addressId and addressData');\n }\n\n // Transform addressData to snake_case if provided\n const transformedAddressData = addressData\n ? transformAddressToSnakeCase(addressData)\n : null;\n\n return fetchGraphQl(SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION, {\n variables: {\n quoteUid,\n addressId: addressId || null,\n addressData: transformedAddressData,\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 set shipping address: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.setNegotiableQuoteShippingAddress?.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/shipping-address-set', {\n quote: quoteData,\n input: { quoteUid, addressId, addressData },\n });\n\n return quoteData;\n });\n};\n\n"],"names":["CUSTOMER_FRAGMENT","CUSTOMER_QUERY","CAN_REQUEST_QUOTE_PERMISSION","CAN_EDIT_QUOTE_PERMISSION","CAN_DELETE_QUOTE_PERMISSION","CAN_CHECKOUT_QUOTE_PERMISSION","flattenPermissions","permissions","result","traverse","nodes","path","node","currentPath","transformCustomer","customerData","role","DEFAULT_PERMISSIONS","flattenedPermissions","getCustomerData","state","results","fetchGraphQl","_a","error","QUOTE_DATA_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","getQuoteData","quoteId","transformedQuote","transformQuote","events","initialize","Initializer","config","defaultConfig","authenticated","quoteData","SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION","transformAddressToSnakeCase","address","additionalInput","standardFields","transformedStandardFields","setShippingAddress","input","quoteU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GAAmB,CAAA,EACvB,GAAGE,CAAA,CAEP,CA4DO,MAAMC,EAAqB,MAChCC,GACyC,CACzC,KAAM,CAAE,SAAAC,EAAU,UAAAC,EAAW,YAAAC,CAAA,EAAgBH,EAE7C,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,uBAAuB,EAIzC,GAAIC,IAAc,QAAa,CAACC,EAC9B,MAAM,IAAI,MAAM,kDAAkD,EAGpE,GAAID,IAAc,QAAaC,EAC7B,MAAM,IAAI,MAAM,+CAA+C,EAIjE,MAAMC,EAAyBD,EAC3BT,EAA4BS,CAAW,EACvC,KAEJ,OAAO1B,EAAagB,EAAgD,CAClE,UAAW,CACT,SAAAQ,EACA,UAAWC,GAAa,KACxB,YAAaE,CAAA,CACf,CACD,EAAE,KAAMC,GAAa,SACpB,KAAM,CAAE,OAAAC,GAAWD,EAEnB,GAAIC,EAAQ,CAEV,MAAMC,EAAgBD,EAAO,IAAK3B,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MAAM,mCAAmC4B,CAAa,EAAE,CACpE,CAGA,MAAMf,EAAYP,GAChBuB,GAAA9B,EAAA2B,EAAS,OAAT,YAAA3B,EAAe,oCAAf,YAAA8B,EAAkD,KAAA,EAGpD,GAAI,CAAChB,EACH,MAAM,IAAI,MACR,4DAAA,EAKJ,OAAAN,EAAO,KAAK,wCAAyC,CACnD,MAAOM,EACP,MAAO,CAAE,SAAAS,EAAU,UAAAC,EAAW,YAAAC,CAAA,CAAY,CAC3C,EAEMX,CACT,CAAC,CACH"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{FetchGraphQL as b}from"@dropins/tools/fetch-graphql.js";const x={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1},y={authenticated:!1,permissions:x},E=new Proxy(y,{get:(e,t)=>e[t],set:(e,t,r)=>(e[t]=r,!0)});var h=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(h||{});function I(e){var r,s,i,g,m,f;const t=v(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:t?h.NEW:e.status,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,comments:(r=e.comments)==null?void 0:r.map(a=>{const c={uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},text:a.text};return Array.isArray(a.attachments)&&a.attachments.length>0&&(c.attachments=a.attachments.map(o=>({name:o.name,url:o.url}))),c}),prices:e.prices&&{subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(s=e.prices.applied_taxes)==null?void 0:s.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label})),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}},history:(i=e.history)==null?void 0:i.map(a=>{var c,o,u,p,d,_,n;return{uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},changeType:a.change_type,changes:{commentAdded:((c=a.changes)==null?void 0:c.comment_added)&&{comment:a.changes.comment_added.comment},customChanges:((o=a.changes)==null?void 0:o.custom_changes)&&{new_value:a.changes.custom_changes.new_value,old_value:a.changes.custom_changes.old_value,title:a.changes.custom_changes.title},expiration:((u=a.changes)==null?void 0:u.expiration)&&{newExpiration:a.changes.expiration.new_expiration,oldExpiration:a.changes.expiration.old_expiration},productsRemoved:((p=a.changes)==null?void 0:p.products_removed)&&{productsRemovedFromCatalog:a.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:a.changes.products_removed.products_removed_from_quote||[]},statuses:((d=a.changes)==null?void 0:d.statuses)&&{changes:((_=a.changes.statuses.changes)==null?void 0:_.map(l=>({newStatus:l.new_status,oldStatus:l.old_status})))||[]},total:((n=a.changes)==null?void 0:n.total)&&a.changes.total.new_price&&a.changes.total.old_price&&{newPrice:{value:a.changes.total.new_price.value,currency:a.changes.total.new_price.currency},oldPrice:{value:a.changes.total.old_price.value,currency:a.changes.total.old_price.currency}}}}}),items:((g=e.items)==null?void 0:g.map(a=>{var c,o,u,p,d,_;return{product:{uid:a.product.uid,sku:a.product.sku,name:a.product.name},catalogDiscount:{amountOff:a.prices.catalog_discount.amount_off,percentOff:a.prices.catalog_discount.percent_off},discounts:((o=(c=a.prices)==null?void 0:c.discounts)==null?void 0:o.map(n=>({label:n.label,value:n.value,amount:{value:n.amount.value,currency:n.amount.currency}})))??[],stockStatus:a.product.stock_status,quantity:a.quantity,prices:{originalItemPrice:{value:a.prices.original_item_price.value,currency:a.prices.original_item_price.currency},rowTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency}},noteFromBuyer:(u=a.note_from_buyer)==null?void 0:u.map(n=>({createdAt:n.created_at,creatorId:n.creator_id,creatorType:n.creator_type,negotiableQuoteItemUid:n.negotiable_quote_item_uid,note:n.note,noteUid:n.note_uid})),noteFromSeller:(p=a.note_from_seller)==null?void 0:p.map(n=>({createdAt:n.created_at,creatorId:n.creator_id,creatorType:n.creator_type,negotiableQuoteItemUid:n.negotiable_quote_item_uid,note:n.note,noteUid:n.note_uid})),configurableOptions:(d=a.configurable_options)==null?void 0:d.map(n=>({optionLabel:n.option_label,valueLabel:n.value_label})),bundleOptions:(_=a.bundle_options)==null?void 0:_.map(n=>({label:n.label,values:n.values.map(l=>({label:l.label,quantity:l.quantity,originalPrice:{value:l.original_price.value,currency:l.original_price.currency},price:{value:l.priceV2.value,currency:l.priceV2.currency}}))}))}}))||[],shippingAddresses:(m=e.shipping_addresses)==null?void 0:m.map(a=>{const c={uid:a.uid,firstname:a.firstname,lastname:a.lastname,company:a.company,street:a.street,city:a.city,postcode:a.postcode,country:{code:a.country.code,label:a.country.label},telephone:a.telephone};return a.region&&(c.region={code:a.region.code,label:a.region.label,regionId:a.region.region_id}),c}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&E.permissions.checkoutQuote&&((f=e.shipping_addresses)==null?void 0:f.length)>0,canSendForReview:(t||["DRAFT","UPDATED","DECLINED","EXPIRED","NEW"].includes(e.status))&&E.permissions.editQuote}}function w(e){return e?I(e):null}function v(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(t=>{var r,s;return t.change_type==="UPDATED"&&(((s=(r=t.changes)==null?void 0:r.statuses)==null?void 0:s.changes)??[]).length>0})}function D(e){const t=v(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:t?h.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function A(e){var s;if(!e)return null;const t={items:((s=e.items)==null?void 0:s.filter(i=>i==null?void 0:i.uid).map(D))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},r=T(t);return{...t,paginationInfo:r||void 0}}function T(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:t,pageSize:r,totalPages:s}=e.pageInfo,{totalCount:i}=e,g=i>0?(t-1)*r+1:0,m=Math.min(t*r,i);return{currentPage:t,totalCount:i,pageSize:r,startItem:g,endItem:m,totalPages:s,pageSizeOptions:[20,30,50,100,200]}}const R=()=>[20,30,50,100,200],{setEndpoint:N,setFetchGraphQlHeader:C,removeFetchGraphQlHeader:F,setFetchGraphQlHeaders:O,fetchGraphQl:U,getConfig:L}=new b().getMethods();export{x as D,A as a,N as b,C as c,O as d,L as e,U as f,R as g,F as r,E as s,w as t};
4
+ //# sourceMappingURL=fetch-graphql.js.map
@@ -0,0 +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,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAVEA,IAAAA,GAAA,CAAA,CAAA,ECxLZ,SAASC,EAAqBC,EAAkC,iBAC9D,MAAMC,EAAaC,EAAWF,CAAK,EACnC,MAAO,CACL,IAAKA,EAAM,IACX,KAAMA,EAAM,KACZ,UAAWA,EAAM,WACjB,UAAWA,EAAM,WACjB,eAAgBA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AO,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,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{fetchGraphQl as n}from"@dropins/tools/fetch-graphql.js";import{s,a as i}from"./transform-quote.js";const u=`
3
+ import{s as n,f as s,a as i}from"./fetch-graphql.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{fetchGraphQl as n}from"@dropins/tools/fetch-graphql.js";import{s,a as i}f
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 r;if(!s.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=i(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};
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 a;if(!n.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 s(c,{variables:o});if(!((a=t==null?void 0:t.data)!=null&&a.negotiableQuotes))throw new Error("No quotes data received");const r=i(t.data.negotiableQuotes);if(!r)throw new Error("Failed to transform quotes data");return r}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 '@adobe-commerce/fetch-graphql';\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":"0GASO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECA/CC,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECAjDC,EAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECIrCC,EAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA0BjDH,CAA8B;AAAA,IAC9BC,CAAgC;AAAA,IAChCC,CAAoB;AAAA,EC1BjB,IAAKE,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UAFAA,IAAAA,GAAA,CAAA,CAAA,EAoBAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAkBL,MAAMC,EAAmB,MAC9BC,EAAiC,KACM,OACvC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,MAAMC,EAAY,CAChB,OAAQF,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,EAGvB,GAAI,CACF,MAAMG,EAAe,MAAMC,EAAaT,EAAyB,CAC/D,UAAAO,CAAA,CACD,EAED,GAAI,GAACG,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,kBAClB,MAAM,IAAI,MAAM,yBAAyB,EAG3C,MAAMC,EAAkBC,EACtBJ,EAAQ,KAAK,gBAAA,EAGf,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
1
+ {"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":"yFASO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECA/CC,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECAjDC,EAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECIrCC,EAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA0BjDH,CAA8B;AAAA,IAC9BC,CAAgC;AAAA,IAChCC,CAAoB;AAAA,EC1BjB,IAAKE,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UAFAA,IAAAA,GAAA,CAAA,CAAA,EAoBAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAkBL,MAAMC,EAAmB,MAC9BC,EAAiC,KACM,OACvC,GAAI,CAACC,EAAM,cACT,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGjD,MAAMC,EAAY,CAChB,OAAQF,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,EAGvB,GAAI,CACF,MAAMG,EAAe,MAAMC,EAAaT,EAAyB,CAC/D,UAAAO,CAAA,CACD,EAED,GAAI,GAACG,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,kBAClB,MAAM,IAAI,MAAM,yBAAyB,EAG3C,MAAMC,EAAkBC,EACtBJ,EAAQ,KAAK,gBAAA,EAGf,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,OAASE,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{fetchGraphQl as E}from"@dropins/tools/fetch-graphql.js";import{events as c}from"@dropins/tools/event-bus.js";import{N as d}from"./NegotiableQuoteFragment.js";import{t as q}from"./transform-quote.js";const I=`
3
+ import{f as E,t as c}from"./fetch-graphql.js";import{events as d}from"@dropins/tools/event-bus.js";import{N as q}from"./NegotiableQuoteFragment.js";const I=`
4
4
  mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(
5
5
  $quoteUid: ID!
6
6
  $comment: NegotiableQuoteCommentInput
@@ -16,6 +16,6 @@ import{fetchGraphQl as E}from"@dropins/tools/fetch-graphql.js";import{events as
16
16
  }
17
17
  }
18
18
  }
19
- ${d}
20
- `,w=async u=>{const{quoteUid:e,comment:t}=u;if(!e)throw new Error("Quote UID is required");return E(I,{variables:{quoteUid:e,comment:t?{comment:t}:null}}).then(r=>{var m,i;const{errors:n}=r;if(n){const a=n.map(s=>s.message).join("; ");throw new Error(`Failed to send quote for review: ${a}`)}const o=q((i=(m=r.data)==null?void 0:m.sendNegotiableQuoteForReview)==null?void 0:i.quote);if(!o)throw new Error("Failed to transform quote data: Invalid response structure");return c.emit("quote-management/quote-sent-for-review",{quote:o,input:{quoteUid:e,comment:t}}),o})};export{w as s};
19
+ ${q}
20
+ `,p=async a=>{const{quoteUid:e,comment:t}=a;if(!e)throw new Error("Quote UID is required");return E(I,{variables:{quoteUid:e,comment:t?{comment:t}:null}}).then(r=>{var m,u;const{errors:n}=r;if(n){const i=n.map(s=>s.message).join("; ");throw new Error(`Failed to send quote for review: ${i}`)}const o=c((u=(m=r.data)==null?void 0:m.sendNegotiableQuoteForReview)==null?void 0:u.quote);if(!o)throw new Error("Failed to transform quote data: Invalid response structure");return d.emit("quote-management/quote-sent-for-review",{quote:o,input:{quoteUid:e,comment:t}}),o})};export{p as s};
21
21
  //# 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 '@adobe-commerce/fetch-graphql';\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":"8MAmBO,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/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,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{FetchGraphQL as I,fetchGraphQl as w}from"@dropins/tools/fetch-graphql.js";import{events as h}from"@dropins/tools/event-bus.js";import{N as _}from"./NegotiableQuoteFragment.js";import{t as N}from"./transform-quote.js";const{setEndpoint:F,setFetchGraphQlHeader:y,removeFetchGraphQlHeader:G,setFetchGraphQlHeaders:b,fetchGraphQl:l,getConfig:L}=new I().getMethods(),g=`
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=`
4
4
  mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(
5
5
  $cartId: ID!
6
6
  $quoteName: String!
@@ -20,8 +20,8 @@ import{FetchGraphQL as I,fetchGraphQl as w}from"@dropins/tools/fetch-graphql.js"
20
20
  }
21
21
  }
22
22
  }
23
- ${_}
24
- `,M=async t=>{const{cartId:n,quoteName:e,comment:o,attachments:r,isDraft:s}=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 w(g,{variables:{cartId:n,quoteName:e,comment:r!=null&&r.length?{comment:o,attachments:r}:{comment:o},isDraft:s}}).then(m=>{var i,u;const{errors:p}=m;if(p){const d=p.map(c=>c.message).join("; ");throw new Error(`Failed to request negotiable quote: ${d}`)}const a=N((u=(i=m.data)==null?void 0:i.requestNegotiableQuote)==null?void 0:u.quote);if(!a)throw new Error("Failed to transform quote data: Invalid response structure");return h.emit("quote-management/negotiable-quote-requested",{quote:a,input:{cartId:n,quoteName:e,comment:o,attachments:r,isDraft:s}}),a})},U=`
23
+ ${f}
24
+ `,O=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
@@ -29,7 +29,7 @@ import{FetchGraphQL as I,fetchGraphQl as w}from"@dropins/tools/fetch-graphql.js"
29
29
  expires_at
30
30
  }
31
31
  }
32
- `,q=`
32
+ `,U=`
33
33
  mutation FINISH_UPLOAD_MUTATION($input: finishUploadInput!) {
34
34
  finishUpload(input: $input) {
35
35
  success
@@ -37,5 +37,5 @@ import{FetchGraphQL as I,fetchGraphQl as w}from"@dropins/tools/fetch-graphql.js"
37
37
  message
38
38
  }
39
39
  }
40
- `,D=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=T=>T.map(f=>f.message).join("; "),{data:r,errors:s}=await l(U,{variables:{input:{key:e,media_resource_type:n}}});if(s&&s.length)throw new Error(o(s));const{upload_url:m,key:p}=(r==null?void 0:r.initiateUpload)||{};if(!m||!p)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:i,errors:u}=await l(q,{variables:{input:{key:p,media_resource_type:n}}});if(u&&u.length)throw new Error(o(u));const{success:d,key:c,message:E}=(i==null?void 0:i.finishUpload)||{};if(!d||!c)throw new Error(E||"Failed to finish upload");return{key:c}}catch(e){throw h.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{y as a,G as b,b as c,l as f,L as g,M as r,F as s,D as u};
40
+ `,$=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{O as r,$ as u};
41
41
  //# sourceMappingURL=uploadFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadFile.js","sources":["/@dropins/storefront-quote-management/src/api/fetch-graphql/fetch-graphql.ts","/@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":["import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * 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 '@adobe-commerce/fetch-graphql';\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":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","REQUEST_NEGOTIABLE_QUOTE_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","requestNegotiableQuote","input","cartId","quoteName","comment","attachments","isDraft","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":"gOAEO,KAAM,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECUVC,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,OAAOT,EAAaG,EAAmC,CACrD,UAAW,CACT,OAAAI,EACA,UAAAC,EACA,QAASE,GAAA,MAAAA,EAAa,OAAS,CAAE,QAAAD,EAAS,YAAAC,CAAA,EAAgB,CAAE,QAAAD,CAAA,EAC5D,QAAAE,CAAA,CACF,CACD,EAAE,KAAMC,GAAa,SACpB,KAAM,CAAE,OAAAC,GAAWD,EAEnB,GAAIC,EAAQ,CAEV,MAAMC,EAAgBD,EAAO,IAAKE,GAAUA,EAAM,OAAO,EAAE,KAAK,IAAI,EACpE,MAAM,IAAI,MAAM,uCAAuCD,CAAa,EAAE,CACxE,CAGA,MAAME,EAAYC,GAAeC,GAAAC,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AkB,MAAMnC,EACxDsB,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"}
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;A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D,OAAOmB,GAAA,YAAAA,EAAK,UAAW,qBACvB,SAAUf,GAAA,YAAAA,EAAM,IAAA,CACjB,EACKe,aAAe,MAAQA,EAAM,IAAI,MAAM,oBAAoB,CACnE,CACF"}
@@ -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/transform-quote.js";import"@dropins/tools/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"../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 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};
4
4
  //# sourceMappingURL=ManageNegotiableQuote.js.map