@dropins/storefront-purchase-order 1.0.0-beta2 → 1.0.0-beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +59 -60
- package/api.js +5 -5
- package/api.js.map +1 -1
- package/chunks/addPurchaseOrderComment.js +2 -2
- package/chunks/addPurchaseOrderComment.js.map +1 -1
- package/chunks/currencyInfo.js +5 -5
- package/chunks/currencyInfo.js.map +1 -1
- package/chunks/fetch-graphql.js +1 -1
- package/chunks/fetch-graphql.js.map +1 -1
- package/chunks/getPurchaseOrderApprovalRule.js +2 -2
- package/chunks/getPurchaseOrderApprovalRule.js.map +1 -1
- package/chunks/getPurchaseOrderApprovalRules.js +3 -3
- package/chunks/getPurchaseOrderApprovalRules.js.map +1 -1
- package/chunks/getPurchaseOrders.js +3 -3
- package/chunks/getPurchaseOrders.js.map +1 -1
- package/chunks/placeOrderForPurchaseOrder.js +3 -3
- package/chunks/placeOrderForPurchaseOrder.js.map +1 -1
- package/chunks/rejectPurchaseOrders.js +4 -4
- package/chunks/rejectPurchaseOrders.js.map +1 -1
- package/containers/ApprovalRuleForm.js +1 -1
- package/containers/ApprovalRuleForm.js.map +1 -1
- package/containers/ApprovalRulesList.js +1 -1
- package/containers/ApprovalRulesList.js.map +1 -1
- package/containers/CompanyPurchaseOrders.js +1 -1
- package/containers/CompanyPurchaseOrders.js.map +1 -1
- package/containers/CustomerPurchaseOrders.js +1 -1
- package/containers/CustomerPurchaseOrders.js.map +1 -1
- package/containers/PurchaseOrderCommentForm.js +1 -1
- package/containers/PurchaseOrderCommentForm.js.map +1 -1
- package/containers/PurchaseOrderStatus.js +1 -1
- package/containers/PurchaseOrderStatus.js.map +1 -1
- package/containers/RequireApprovalPurchaseOrders.js +1 -1
- package/containers/RequireApprovalPurchaseOrders.js.map +1 -1
- package/package.json +1 -1
- package/render.js +1 -1
- package/chunks/fetch-error.js +0 -4
- package/chunks/fetch-error.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rejectPurchaseOrders.js","sources":["/@dropins/storefront-purchase-order/src/api/graphql/PurchaseOrderQuoteFragment.ts","/@dropins/storefront-purchase-order/src/api/graphql/PurchaseOrdersFragment.graphql.ts","/@dropins/storefront-purchase-order/src/data/transforms/transform-purchase-order.ts","/@dropins/storefront-purchase-order/src/api/approvePurchaseOrders/graphql/approvePurchaseOrders.graphql.ts","/@dropins/storefront-purchase-order/src/api/approvePurchaseOrders/approvePurchaseOrders.ts","/@dropins/storefront-purchase-order/src/api/rejectPurchaseOrders/graphql/rejectPurchaseOrders.graphql.ts","/@dropins/storefront-purchase-order/src/api/rejectPurchaseOrders/rejectPurchaseOrders.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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\n/**\n * Limited Quote fragment for Purchase Order context\n * Some fields from full Cart type may not be available in purchase_order.quote\n */\nexport const PURCHASE_ORDER_QUOTE_FRAGMENT = /* GraphQL */ `\n fragment PURCHASE_ORDER_QUOTE_FRAGMENT on Cart {\n __typename\n id\n email\n is_virtual\n total_quantity\n applied_coupons {\n code\n }\n applied_gift_cards {\n code\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n expiration_date\n }\n applied_reward_points {\n money {\n value\n currency\n }\n points\n }\n applied_store_credit {\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n }\n available_gift_wrappings {\n uid\n design\n price {\n value\n currency\n }\n image {\n url\n label\n }\n }\n gift_message {\n from\n to\n message\n }\n gift_receipt_included\n gift_wrapping {\n uid\n design\n price {\n value\n currency\n }\n image {\n url\n label\n }\n }\n printed_card_included\n available_payment_methods {\n code\n title\n is_deferred\n }\n selected_payment_method {\n code\n title\n }\n billing_address {\n city\n company\n country {\n code\n label\n }\n firstname\n lastname\n postcode\n region {\n code\n label\n }\n street\n telephone\n custom_attributes {\n code\n }\n fax\n id\n middlename\n prefix\n suffix\n uid\n vat_id\n }\n shipping_addresses {\n city\n company\n country {\n code\n label\n }\n firstname\n lastname\n postcode\n region {\n code\n label\n }\n street\n telephone\n custom_attributes {\n code\n }\n fax\n id\n middlename\n prefix\n suffix\n uid\n vat_id\n available_shipping_methods {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n }\n rules {\n uid\n }\n itemsV2(pageSize: 100, currentPage: 1) {\n items {\n uid\n quantity\n product {\n __typename\n uid\n name\n sku\n url_key\n canonical_url\n stock_status\n only_x_left_in_stock\n image {\n url\n label\n }\n small_image {\n url\n label\n }\n thumbnail {\n url\n label\n }\n price_range {\n maximum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n }\n }\n }\n prices {\n price {\n value\n currency\n }\n price_including_tax {\n value\n currency\n }\n original_item_price {\n value\n currency\n }\n original_row_total {\n value\n currency\n }\n row_total {\n value\n currency\n }\n row_total_including_tax {\n value\n currency\n }\n total_item_discount {\n value\n currency\n }\n discounts {\n label\n amount {\n value\n currency\n }\n }\n fixed_product_taxes {\n label\n amount {\n value\n currency\n }\n }\n }\n ... on SimpleCartItem {\n customizable_options {\n label\n values {\n label\n value\n }\n }\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n value_label\n }\n }\n ... on BundleCartItem {\n bundle_options {\n uid\n label\n type\n values {\n uid\n label\n quantity\n }\n }\n }\n ... on DownloadableCartItem {\n links {\n uid\n title\n }\n }\n ... on GiftCardCartItem {\n sender_name\n sender_email\n recipient_name\n recipient_email\n message\n amount {\n value\n currency\n }\n }\n errors {\n code\n message\n }\n is_available\n max_qty\n min_qty\n not_available_message\n note_from_buyer {\n note_uid\n note\n created_at\n }\n note_from_seller {\n note_uid\n note\n created_at\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n }\n prices {\n grand_total {\n value\n currency\n }\n grand_total_excluding_tax {\n value\n currency\n }\n subtotal_excluding_tax {\n value\n currency\n }\n subtotal_including_tax {\n value\n currency\n }\n subtotal_with_discount_excluding_tax {\n value\n currency\n }\n applied_taxes {\n label\n amount {\n value\n currency\n }\n }\n discounts {\n label\n amount {\n value\n currency\n }\n }\n gift_options {\n gift_wrapping_for_items {\n value\n currency\n }\n gift_wrapping_for_items_incl_tax {\n value\n currency\n }\n gift_wrapping_for_order {\n value\n currency\n }\n gift_wrapping_for_order_incl_tax {\n value\n currency\n }\n printed_card {\n value\n currency\n }\n printed_card_incl_tax {\n value\n currency\n }\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PURCHASE_ORDER_QUOTE_FRAGMENT } from './PurchaseOrderQuoteFragment';\n\nexport const PURCHASE_ORDERS_FRAGMENT = /* GraphQL */ `\n fragment PURCHASE_ORDERS_FRAGMENT on PurchaseOrder {\n __typename\n uid\n number\n status\n available_actions\n approval_flow {\n events {\n name\n role\n message\n status\n updated_at\n }\n rule_name\n }\n comments {\n created_at\n author {\n firstname\n lastname\n email\n }\n text\n }\n created_at\n updated_at\n created_by {\n firstname\n lastname\n email\n }\n history_log {\n message\n created_at\n activity\n __typename\n uid\n }\n order {\n number\n }\n quote {\n ...PURCHASE_ORDER_QUOTE_FRAGMENT\n }\n }\n ${PURCHASE_ORDER_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PurchaseOrderModel } from '@/b2b-purchase-order/data/models';\n\nexport const transformPurchaseOrder = (\n purchaseOrder: any\n): PurchaseOrderModel => {\n const order = {\n typename: purchaseOrder?.__typename ?? '',\n uid: purchaseOrder?.uid ?? '',\n number: purchaseOrder?.number ?? '',\n status: purchaseOrder?.status ?? '',\n availableActions: purchaseOrder?.available_actions ?? [],\n approvalFlow: purchaseOrder?.approval_flow?.length\n ? purchaseOrder.approval_flow.map((flow: any) => ({\n ruleName: flow?.rule_name ?? '',\n events:\n flow?.events?.map((event: any) => ({\n message: event?.message ?? '',\n name: event?.name ?? '',\n role: event?.role ?? '',\n status: event?.status ?? '',\n updatedAt: event?.updated_at ?? '',\n })) ?? [],\n }))\n : [],\n comments:\n purchaseOrder?.comments?.map((comment: any) => ({\n uid: comment?.uid ?? '',\n createdAt: comment?.created_at ?? '',\n author: {\n firstname: comment?.author?.firstname ?? '',\n lastname: comment?.author?.lastname ?? '',\n email: comment?.author?.email ?? '',\n },\n text: comment?.text ?? '',\n })) ?? [],\n createdAt: purchaseOrder?.created_at ?? '',\n updatedAt: purchaseOrder?.updated_at ?? '',\n createdBy: {\n firstname: purchaseOrder?.created_by?.firstname ?? '',\n lastname: purchaseOrder?.created_by?.lastname ?? '',\n email: purchaseOrder?.created_by?.email ?? '',\n },\n historyLog:\n purchaseOrder?.history_log?.map((log: any) => ({\n activity: log?.activity ?? '',\n createdAt: log?.created_at ?? '',\n message: log?.message ?? '',\n uid: log?.uid ?? '',\n })) ?? [],\n quote: transformQuoteToOrder(purchaseOrder?.quote),\n order: {\n id: purchaseOrder?.order?.id ?? '',\n orderNumber: purchaseOrder?.order?.number ?? '',\n },\n };\n\n return order;\n};\n\nfunction transformQuoteToOrder(quote: any) {\n if (!quote) return null;\n\n // Helper functions\n const parseNumber = (value: number | undefined | null) => {\n return value || 0;\n };\n\n const transformUserInformation = (user: any) => {\n return {\n firstName: user?.firstname ?? '',\n lastName: user?.lastname ?? '',\n middleName: user?.middlename ?? '',\n };\n };\n\n const transformAddress = (address: any) => {\n const { firstName, lastName, middleName } =\n transformUserInformation(address);\n\n return {\n firstName,\n lastName,\n middleName,\n city: address?.city ?? '',\n company: address?.company ?? '',\n country: address?.country?.label ?? '',\n countryCode: address?.country?.code ?? '',\n fax: address?.fax ?? '',\n postCode: address?.postcode ?? '',\n prefix: address?.prefix ?? '',\n region: address?.region?.label ?? '',\n regionId: address?.region?.code ?? '',\n street: address?.street ?? [],\n suffix: address?.suffix ?? '',\n telephone: address?.telephone ?? '',\n vatId: address?.vat_id ?? '',\n customAttributes: address?.custom_attributes ?? [],\n };\n };\n\n const transformProduct = (product: any) => {\n return {\n __typename: product?.__typename || '',\n uid: product?.uid || '',\n onlyXLeftInStock: product?.only_x_left_in_stock ?? 0,\n stockStatus: product?.stock_status ?? '',\n priceRange: {\n maximumPrice: {\n regularPrice: {\n currency:\n product?.price_range?.maximum_price?.regular_price?.currency ??\n '',\n value:\n product?.price_range?.maximum_price?.regular_price?.value ?? 0,\n },\n },\n },\n canonicalUrl: product?.canonical_url ?? '',\n urlKey: product?.url_key || '',\n id: product?.uid ?? '',\n name: product?.name || '',\n sku: product?.sku || '',\n image: product?.image?.url || '',\n imageAlt: product?.image?.label || '',\n productType: product?.__typename || '',\n thumbnail: {\n label: product?.thumbnail?.label || '',\n url: product?.thumbnail?.url || '',\n },\n };\n };\n\n const transformConfigurableOptions = (item: any) => {\n if (!item) return;\n\n // GraphQL returns configurable_options (not selected_options)\n if (!('configurable_options' in item)) return;\n\n const configurableOptions: Record<string, string> = {};\n\n for (const option of item.configurable_options!) {\n // GraphQL fields: option_label and value_label\n configurableOptions[option!.option_label] = option!.value_label;\n }\n\n return configurableOptions;\n };\n const transformBundleOptions = (data: any) => {\n const bundle = data?.map((option: any) => ({\n uid: option.uid,\n label: option.label,\n values: option.values.map((value: any) => value.product_name).join(', '),\n }));\n\n const bundleOptions: { [key: string]: any } = {};\n\n bundle?.forEach((option: any) => {\n bundleOptions[option.label] = option.values;\n });\n\n return Object.keys(bundleOptions).length > 0 ? bundleOptions : null;\n };\n\n const transformLinks = (links: { title: string }[]) => {\n return links?.length > 0\n ? {\n count: links.length,\n result: links.map((link: any) => link.title).join(', '),\n }\n : null;\n };\n\n const transformGiftCard = (item: any) => {\n return {\n senderName: item?.gift_card?.sender_name || '',\n senderEmail: item?.gift_card?.sender_email || '',\n recipientEmail: item?.gift_card?.recipient_email || '',\n recipientName: item?.gift_card?.recipient_name || '',\n message: item?.gift_card?.message || '',\n };\n };\n\n const transformGiftMessage = (data: any) => {\n return {\n senderName: data?.gift_message?.from ?? '',\n recipientName: data?.gift_message?.to ?? '',\n message: data?.gift_message?.message ?? '',\n };\n };\n\n const transformGiftWrapping = (data: any) => {\n return {\n design: data?.gift_wrapping?.design ?? '',\n uid: data?.gift_wrapping?.uid ?? '',\n selected: Boolean(data?.gift_wrapping?.uid),\n image: {\n url: data?.gift_wrapping?.image?.url ?? '',\n label: data?.gift_wrapping?.image?.label ?? '',\n },\n price: {\n currency: data?.gift_wrapping?.price?.currency ?? 'USD',\n value: data?.gift_wrapping?.price?.value ?? 0,\n },\n };\n };\n\n const transformWrappingPrice = (data: any) => {\n return {\n currency: data?.currency ?? 'USD',\n value: data?.value ?? 0,\n };\n };\n\n const transformTaxCalculations = (\n itemPrices: any,\n productPrice: { value: number; currency: string }\n ) => {\n const price = itemPrices?.price;\n const priceIncludingTax = itemPrices?.priceIncludingTax;\n const originalPrice = itemPrices?.originalPrice;\n\n // For quote, discounted is always false since there are no discounts yet\n const discounted = false;\n const baseOriginalPriceValue = discounted\n ? originalPrice?.value\n : priceIncludingTax?.value;\n\n const includeAndExcludeTax = {\n originalPrice,\n baseOriginalPrice: {\n value: baseOriginalPriceValue,\n currency: originalPrice?.currency,\n },\n baseDiscountedPrice: {\n value: priceIncludingTax?.value,\n currency: priceIncludingTax?.currency,\n },\n baseExcludingTax: {\n value: price?.value,\n currency: price?.currency,\n },\n };\n\n const excludeTax = {\n originalPrice,\n baseOriginalPrice: {\n value: originalPrice?.value,\n currency: priceIncludingTax?.currency,\n },\n baseDiscountedPrice: {\n value: productPrice?.value,\n currency: price?.currency,\n },\n baseExcludingTax: {\n value: price?.value,\n currency: price?.currency,\n },\n };\n\n const includeTax = {\n singleItemPrice: {\n value: discounted ? originalPrice.value : priceIncludingTax.value,\n currency: priceIncludingTax.currency,\n },\n baseOriginalPrice: {\n value: baseOriginalPriceValue,\n currency: priceIncludingTax.currency,\n },\n baseDiscountedPrice: {\n value: priceIncludingTax.value,\n currency: priceIncludingTax.currency,\n },\n };\n\n return {\n includeAndExcludeTax,\n excludeTax,\n includeTax,\n };\n };\n\n const transformQuoteItem = (item: any) => {\n const product = item?.product;\n const prices = item?.prices;\n const quantity = parseNumber(item?.quantity);\n\n const itemPrices = {\n price: prices?.price ?? { value: 0, currency: 'USD' },\n priceIncludingTax: prices?.price_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n originalPrice: prices?.original_item_price ?? {\n value: 0,\n currency: 'USD',\n },\n originalPriceIncludingTax: prices?.original_item_price ?? {\n value: 0,\n currency: 'USD',\n },\n discounts: prices?.discounts ?? [],\n };\n\n const discounted =\n (prices?.original_item_price?.value ?? 0) > (prices?.price?.value ?? 0);\n\n const price = prices?.price ?? { value: 0, currency: 'USD' };\n\n return {\n giftMessage: transformGiftMessage(item),\n giftWrappingPrice: transformWrappingPrice(item?.gift_wrapping?.price),\n productGiftWrapping: [transformGiftWrapping(item)],\n taxCalculations: transformTaxCalculations(itemPrices, price),\n productSalePrice: price,\n status: item?.is_available ? 'available' : 'unavailable',\n currentReturnOrderQuantity: 0,\n eligibleForReturn: false,\n productSku: product?.sku ?? '',\n type: product?.__typename ?? '',\n discounted,\n id: item?.uid ?? '',\n productName: product?.name ?? '',\n productUrlKey: product?.url_key ?? '',\n regularPrice: {\n value: product?.price_range?.maximum_price?.regular_price?.value ?? 0,\n currency:\n product?.price_range?.maximum_price?.regular_price?.currency ?? 'USD',\n },\n price,\n product: transformProduct(product),\n selectedOptions: item?.customizable_options ?? [],\n thumbnail: {\n label: product?.thumbnail?.label || '',\n url: product?.thumbnail?.url || '',\n },\n downloadableLinks:\n product?.__typename === 'DownloadableProduct' &&\n item?.downloadable_links\n ? transformLinks(item.downloadable_links)\n : null,\n prices: itemPrices,\n itemPrices,\n bundleOptions:\n product?.__typename === 'BundleProduct' && item?.bundle_options\n ? transformBundleOptions(item.bundle_options)\n : null,\n totalInclTax: prices?.row_total_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n priceInclTax: prices?.price_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n total: prices?.row_total ?? { value: 0, currency: 'USD' },\n configurableOptions:\n product?.__typename === 'ConfigurableProduct'\n ? transformConfigurableOptions(item)\n : undefined,\n giftCard:\n product?.__typename === 'GiftCardProduct'\n ? transformGiftCard(item)\n : undefined,\n quantityCanceled: 0,\n quantityInvoiced: 0,\n quantityOrdered: quantity,\n quantityRefunded: 0,\n quantityReturned: 0,\n quantityShipped: 0,\n requestQuantity: 0,\n totalQuantity: quantity,\n returnableQuantity: 0,\n quantityReturnRequested: 0,\n };\n };\n\n const transformGiftOptions = (giftOptions: any) => {\n return {\n giftWrappingForItems: giftOptions?.gift_wrapping_for_items ?? {\n value: 0,\n currency: 'USD',\n },\n giftWrappingForItemsInclTax:\n giftOptions?.gift_wrapping_for_items_incl_tax ?? {\n value: 0,\n currency: 'USD',\n },\n giftWrappingForOrder: giftOptions?.gift_wrapping_for_order ?? {\n value: 0,\n currency: 'USD',\n },\n giftWrappingForOrderInclTax:\n giftOptions?.gift_wrapping_for_order_incl_tax ?? {\n value: 0,\n currency: 'USD',\n },\n printedCard: giftOptions?.printed_card ?? {\n value: 0,\n currency: 'USD',\n },\n printedCardInclTax: giftOptions?.printed_card_incl_tax ?? {\n value: 0,\n currency: 'USD',\n },\n };\n };\n\n const transformAppliedGiftCards = (appliedGiftCards: any[] = []) => {\n if (!appliedGiftCards || appliedGiftCards.length === 0) return [];\n\n return appliedGiftCards.map((giftCard: any) => ({\n code: giftCard?.code ?? '',\n appliedBalance: {\n value: giftCard?.applied_balance?.value ?? 0,\n currency: giftCard?.applied_balance?.currency ?? 'USD',\n },\n }));\n };\n\n const transformTaxes = (appliedTaxes: any[] = []) => {\n if (!appliedTaxes || appliedTaxes.length === 0) return [];\n\n return appliedTaxes.map((tax: any) => ({\n amount: {\n value: tax?.amount?.value ?? 0,\n currency: tax?.amount?.currency ?? 'USD',\n },\n rate: tax?.rate ?? 0,\n title: tax?.title ?? tax?.label ?? '',\n }));\n };\n\n // Get shipping address (first one if multiple)\n const shippingAddressData = quote?.shipping_addresses?.[0];\n const billingAddressData = quote?.billing_address;\n const selectedShippingMethod = shippingAddressData?.selected_shipping_method;\n const selectedPaymentMethod = quote?.selected_payment_method;\n const prices = quote?.prices;\n\n // Transform items from quote\n const items = quote?.itemsV2?.items?.map(transformQuoteItem) ?? [];\n\n // Calculate total quantity\n const totalQuantity = items.reduce(\n (accum: number, item: any) => accum + item.totalQuantity,\n 0\n );\n\n // Build OrderDataModel structure from quote\n // Build shipping method string like in order: \"carrier_title - method_title\"\n const shippingMethodString = selectedShippingMethod\n ? `${selectedShippingMethod.carrier_title ?? ''} - ${\n selectedShippingMethod.method_title ?? ''\n }`.trim()\n : '';\n\n const appliedGiftCards = transformAppliedGiftCards(quote?.applied_gift_cards);\n\n return {\n giftReceiptIncluded: quote?.gift_receipt_included ?? false,\n printedCardIncluded: quote?.printed_card_included ?? false,\n giftWrappingOrder: {\n price: {\n value: quote?.gift_wrapping?.price?.value ?? 0,\n currency: quote?.gift_wrapping?.price?.currency ?? 'USD',\n },\n uid: quote?.gift_wrapping?.uid ?? '',\n },\n placeholderImage: '',\n returnNumber: undefined,\n id: quote?.id ?? '',\n orderStatusChangeDate: undefined,\n number: '', // Quotes don't have order numbers yet\n email: quote?.email ?? '',\n token: undefined,\n status: 'pending', // Quote status\n isVirtual: quote?.is_virtual ?? false,\n totalQuantity,\n shippingMethod: shippingMethodString,\n carrier: selectedShippingMethod?.carrier_code ?? '',\n orderDate: '', // Quotes don't have order date yet\n returns: [],\n discounts: prices?.discounts ?? [],\n coupons: quote?.applied_coupons ?? [],\n payments: [\n {\n code: selectedPaymentMethod?.code ?? '',\n name: selectedPaymentMethod?.title ?? '',\n },\n ],\n shipping: {\n code: shippingMethodString,\n amount: selectedShippingMethod?.amount?.value ?? 0,\n currency: selectedShippingMethod?.amount?.currency ?? 'USD',\n },\n shipments: [],\n items,\n totalGiftCard: appliedGiftCards.length\n ? appliedGiftCards.reduce(\n (acc, gc) => ({\n value: acc.value + (gc?.appliedBalance?.value ?? 0),\n currency: gc?.appliedBalance?.currency ?? acc.currency,\n }),\n {\n value: 0,\n currency: appliedGiftCards[0]?.appliedBalance?.currency ?? 'USD',\n }\n )\n : { value: 0, currency: 'USD' },\n grandTotal: prices?.grand_total ?? { value: 0, currency: 'USD' },\n grandTotalExclTax: prices?.grand_total_excluding_tax ?? {\n value: 0,\n currency: 'USD',\n },\n totalShipping: selectedShippingMethod?.amount ?? {\n value: 0,\n currency: 'USD',\n },\n subtotalExclTax: prices?.subtotal_excluding_tax ?? {\n value: 0,\n currency: 'USD',\n },\n subtotalInclTax: prices?.subtotal_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n totalTax: {\n value:\n (prices?.grand_total?.value ?? 0) -\n (prices?.grand_total_excluding_tax?.value ?? 0),\n currency: prices?.grand_total?.currency ?? 'USD',\n },\n shippingAddress: shippingAddressData\n ? transformAddress(shippingAddressData)\n : null,\n totalGiftOptions: transformGiftOptions(prices?.gift_options),\n billingAddress: billingAddressData\n ? transformAddress(billingAddressData)\n : null,\n availableActions: [],\n taxes: transformTaxes(prices?.applied_taxes),\n appliedGiftCards,\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PURCHASE_ORDERS_FRAGMENT } from '@/b2b-purchase-order/api/graphql/PurchaseOrdersFragment.graphql';\n\nexport const APPROVE_PURCHASE_ORDERS = /* GraphQL */ `\n mutation APPROVE_PURCHASE_ORDERS($input: PurchaseOrdersActionInput!) {\n approvePurchaseOrders(input: $input) {\n purchase_orders {\n ...PURCHASE_ORDERS_FRAGMENT\n }\n errors {\n message\n type\n }\n }\n }\n ${PURCHASE_ORDERS_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { fetchGraphQl } from '@/b2b-purchase-order/api/fetch-graphql';\nimport { handleNetworkError } from '@/b2b-purchase-order/lib/network-error';\nimport { handleFetchError } from '@/b2b-purchase-order/lib/fetch-error';\nimport { APPROVE_PURCHASE_ORDERS } from '@/b2b-purchase-order/api/approvePurchaseOrders/graphql/approvePurchaseOrders.graphql';\nimport { transformPurchaseOrder } from '@/b2b-purchase-order/data/transforms/transform-purchase-order';\nimport { PurchaseOrderModel } from '@/b2b-purchase-order/data/models';\n\nexport const approvePurchaseOrders = async (\n uids: string | string[]\n): Promise<{\n errors: { message: string; type: string }[];\n purchaseOrders: PurchaseOrderModel[];\n}> => {\n const uidArray = Array.isArray(uids) ? uids : [uids];\n\n if (!uidArray || uidArray.length === 0) {\n throw new Error('Purchase Order UID(s) are required');\n }\n\n if (uidArray.some((uid) => !uid || uid.trim() === '')) {\n throw new Error('All Purchase Order UIDs must be valid');\n }\n\n const input = {\n purchase_order_uids: uidArray,\n };\n\n return fetchGraphQl(APPROVE_PURCHASE_ORDERS, {\n variables: { input },\n })\n .then((response: any) => {\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n const data = response.data?.approvePurchaseOrders;\n if (!data) {\n throw new Error('Failed to approve purchase orders');\n }\n\n return {\n errors: (data?.errors ?? []).map((error: any) => ({\n message: error?.message ?? '',\n type: error?.type ?? '',\n })),\n purchaseOrders:\n data?.purchase_orders?.map((order: any) =>\n transformPurchaseOrder(order)\n ) ?? [],\n };\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PURCHASE_ORDERS_FRAGMENT } from '@/b2b-purchase-order/api/graphql/PurchaseOrdersFragment.graphql';\n\nexport const REJECT_PURCHASE_ORDERS = /* GraphQL */ `\n mutation REJECT_PURCHASE_ORDERS($input: PurchaseOrdersActionInput!) {\n rejectPurchaseOrders(input: $input) {\n purchase_orders {\n ...PURCHASE_ORDERS_FRAGMENT\n }\n errors {\n message\n type\n }\n }\n }\n ${PURCHASE_ORDERS_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { fetchGraphQl } from '@/b2b-purchase-order/api/fetch-graphql';\nimport { handleNetworkError } from '@/b2b-purchase-order/lib/network-error';\nimport { handleFetchError } from '@/b2b-purchase-order/lib/fetch-error';\nimport { REJECT_PURCHASE_ORDERS } from '@/b2b-purchase-order/api/rejectPurchaseOrders/graphql/rejectPurchaseOrders.graphql';\nimport { transformPurchaseOrder } from '@/b2b-purchase-order/data/transforms/transform-purchase-order';\nimport { PurchaseOrderModel } from '@/b2b-purchase-order/data/models';\n\nexport const rejectPurchaseOrders = async (\n uids: string | string[]\n): Promise<{\n errors: { message: string; type: string }[];\n purchaseOrders: PurchaseOrderModel[];\n}> => {\n const uidArray = Array.isArray(uids) ? uids : [uids];\n\n if (!uidArray || uidArray.length === 0) {\n throw new Error('Purchase Order UID(s) are required');\n }\n\n if (uidArray.some((uid) => !uid || uid.trim() === '')) {\n throw new Error('All Purchase Order UIDs must be valid');\n }\n\n const input = {\n purchase_order_uids: uidArray,\n };\n\n return fetchGraphQl(REJECT_PURCHASE_ORDERS, {\n variables: { input },\n })\n .then((response: any) => {\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n const data = response.data?.rejectPurchaseOrders;\n\n return {\n errors: (data?.errors ?? []).map((error: any) => ({\n message: error?.message ?? '',\n type: error?.type ?? '',\n })),\n purchaseOrders: (data?.purchase_orders ?? []).map(\n transformPurchaseOrder\n ),\n };\n })\n .catch(handleNetworkError);\n};\n"],"names":["PURCHASE_ORDER_QUOTE_FRAGMENT","PURCHASE_ORDERS_FRAGMENT","transformPurchaseOrder","purchaseOrder","_a","flow","event","_b","comment","_c","_d","_e","_f","log","transformQuoteToOrder","_g","_h","quote","parseNumber","value","transformUserInformation","user","transformAddress","address","firstName","lastName","middleName","transformProduct","product","_i","_j","transformConfigurableOptions","item","configurableOptions","option","transformBundleOptions","data","bundle","bundleOptions","transformLinks","links","link","transformGiftCard","transformGiftMessage","transformGiftWrapping","_k","transformWrappingPrice","transformTaxCalculations","itemPrices","productPrice","price","priceIncludingTax","originalPrice","discounted","baseOriginalPriceValue","includeAndExcludeTax","excludeTax","includeTax","transformQuoteItem","prices","quantity","transformGiftOptions","giftOptions","transformAppliedGiftCards","appliedGiftCards","giftCard","transformTaxes","appliedTaxes","tax","shippingAddressData","billingAddressData","selectedShippingMethod","selectedPaymentMethod","items","totalQuantity","accum","shippingMethodString","acc","gc","_l","_m","_n","_o","APPROVE_PURCHASE_ORDERS","approvePurchaseOrders","uids","uidArray","uid","fetchGraphQl","response","handleFetchError","error","order","handleNetworkError","REJECT_PURCHASE_ORDERS","rejectPurchaseOrders"],"mappings":"sFAqBO,MAAMA,GAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,OAAOC,GAAaM,GAAwB,CAC1C,UAAW,CAAE,MALD,CACZ,oBAAqBR,CAAA,CAIR,CAAM,CACpB,EACE,KAAMG,GAAkB,UACnBrF,EAAAqF,EAAS,SAAT,MAAArF,EAAiB,QACnBsF,GAAiBD,EAAS,MAAM,EAGlC,MAAMrD,GAAO7B,EAAAkF,EAAS,OAAT,YAAAlF,EAAe,qBAE5B,MAAO,CACL,SAAS6B,GAAA,YAAAA,EAAM,SAAU,CAAA,GAAI,IAAKuD,IAAgB,CAChD,SAASA,GAAA,YAAAA,EAAO,UAAW,GAC3B,MAAMA,GAAA,YAAAA,EAAO,OAAQ,EAAA,EACrB,EACF,iBAAiBvD,GAAA,YAAAA,EAAM,kBAAmB,CAAA,GAAI,IAC5ClC,EAAA,CACF,CAEJ,CAAC,EACA,MAAM2F,EAAkB,CAC7B"}
|
|
1
|
+
{"version":3,"file":"rejectPurchaseOrders.js","sources":["/@dropins/storefront-purchase-order/src/api/graphql/PurchaseOrderQuoteFragment.ts","/@dropins/storefront-purchase-order/src/api/graphql/PurchaseOrdersFragment.graphql.ts","/@dropins/storefront-purchase-order/src/data/transforms/transform-purchase-order.ts","/@dropins/storefront-purchase-order/src/api/approvePurchaseOrders/graphql/approvePurchaseOrders.graphql.ts","/@dropins/storefront-purchase-order/src/api/approvePurchaseOrders/approvePurchaseOrders.ts","/@dropins/storefront-purchase-order/src/api/rejectPurchaseOrders/graphql/rejectPurchaseOrders.graphql.ts","/@dropins/storefront-purchase-order/src/api/rejectPurchaseOrders/rejectPurchaseOrders.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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\n/**\n * Limited Quote fragment for Purchase Order context\n * Some fields from full Cart type may not be available in purchase_order.quote\n */\nexport const PURCHASE_ORDER_QUOTE_FRAGMENT = /* GraphQL */ `\n fragment PURCHASE_ORDER_QUOTE_FRAGMENT on Cart {\n __typename\n id\n email\n is_virtual\n total_quantity\n applied_coupons {\n code\n }\n applied_gift_cards {\n code\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n expiration_date\n }\n applied_reward_points {\n money {\n value\n currency\n }\n points\n }\n applied_store_credit {\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n }\n available_gift_wrappings {\n uid\n design\n price {\n value\n currency\n }\n image {\n url\n label\n }\n }\n gift_message {\n from\n to\n message\n }\n gift_receipt_included\n gift_wrapping {\n uid\n design\n price {\n value\n currency\n }\n image {\n url\n label\n }\n }\n printed_card_included\n available_payment_methods {\n code\n title\n is_deferred\n }\n selected_payment_method {\n code\n title\n }\n billing_address {\n city\n company\n country {\n code\n label\n }\n firstname\n lastname\n postcode\n region {\n code\n label\n }\n street\n telephone\n custom_attributes {\n code\n }\n fax\n id\n middlename\n prefix\n suffix\n uid\n vat_id\n }\n shipping_addresses {\n city\n company\n country {\n code\n label\n }\n firstname\n lastname\n postcode\n region {\n code\n label\n }\n street\n telephone\n custom_attributes {\n code\n }\n fax\n id\n middlename\n prefix\n suffix\n uid\n vat_id\n available_shipping_methods {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n }\n rules {\n uid\n }\n itemsV2(pageSize: 100, currentPage: 1) {\n items {\n uid\n quantity\n product {\n __typename\n uid\n name\n sku\n url_key\n canonical_url\n stock_status\n only_x_left_in_stock\n image {\n url\n label\n }\n small_image {\n url\n label\n }\n thumbnail {\n url\n label\n }\n price_range {\n maximum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n }\n }\n }\n prices {\n price {\n value\n currency\n }\n price_including_tax {\n value\n currency\n }\n original_item_price {\n value\n currency\n }\n original_row_total {\n value\n currency\n }\n row_total {\n value\n currency\n }\n row_total_including_tax {\n value\n currency\n }\n total_item_discount {\n value\n currency\n }\n discounts {\n label\n amount {\n value\n currency\n }\n }\n fixed_product_taxes {\n label\n amount {\n value\n currency\n }\n }\n }\n ... on SimpleCartItem {\n customizable_options {\n label\n values {\n label\n value\n }\n }\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n value_label\n }\n }\n ... on BundleCartItem {\n bundle_options {\n uid\n label\n type\n values {\n uid\n label\n quantity\n }\n }\n }\n ... on DownloadableCartItem {\n links {\n uid\n title\n }\n }\n ... on GiftCardCartItem {\n sender_name\n sender_email\n recipient_name\n recipient_email\n message\n amount {\n value\n currency\n }\n }\n errors {\n code\n message\n }\n is_available\n max_qty\n min_qty\n not_available_message\n note_from_buyer {\n note_uid\n note\n created_at\n }\n note_from_seller {\n note_uid\n note\n created_at\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n }\n prices {\n grand_total {\n value\n currency\n }\n grand_total_excluding_tax {\n value\n currency\n }\n subtotal_excluding_tax {\n value\n currency\n }\n subtotal_including_tax {\n value\n currency\n }\n subtotal_with_discount_excluding_tax {\n value\n currency\n }\n applied_taxes {\n label\n amount {\n value\n currency\n }\n }\n discounts {\n label\n amount {\n value\n currency\n }\n }\n gift_options {\n gift_wrapping_for_items {\n value\n currency\n }\n gift_wrapping_for_items_incl_tax {\n value\n currency\n }\n gift_wrapping_for_order {\n value\n currency\n }\n gift_wrapping_for_order_incl_tax {\n value\n currency\n }\n printed_card {\n value\n currency\n }\n printed_card_incl_tax {\n value\n currency\n }\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PURCHASE_ORDER_QUOTE_FRAGMENT } from './PurchaseOrderQuoteFragment';\n\nexport const PURCHASE_ORDERS_FRAGMENT = /* GraphQL */ `\n fragment PURCHASE_ORDERS_FRAGMENT on PurchaseOrder {\n __typename\n uid\n number\n status\n available_actions\n approval_flow {\n events {\n name\n role\n message\n status\n updated_at\n }\n rule_name\n }\n comments {\n created_at\n author {\n firstname\n lastname\n email\n }\n text\n }\n created_at\n updated_at\n created_by {\n firstname\n lastname\n email\n }\n history_log {\n message\n created_at\n activity\n __typename\n uid\n }\n order {\n number\n }\n quote {\n ...PURCHASE_ORDER_QUOTE_FRAGMENT\n }\n }\n ${PURCHASE_ORDER_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PurchaseOrderModel } from '@/b2b-purchase-order/data/models';\n\nexport const transformPurchaseOrder = (\n purchaseOrder: any\n): PurchaseOrderModel => {\n const order = {\n typename: purchaseOrder?.__typename ?? '',\n uid: purchaseOrder?.uid ?? '',\n number: purchaseOrder?.number ?? '',\n status: purchaseOrder?.status ?? '',\n availableActions: purchaseOrder?.available_actions ?? [],\n approvalFlow: purchaseOrder?.approval_flow?.length\n ? purchaseOrder.approval_flow.map((flow: any) => ({\n ruleName: flow?.rule_name ?? '',\n events:\n flow?.events?.map((event: any) => ({\n message: event?.message ?? '',\n name: event?.name ?? '',\n role: event?.role ?? '',\n status: event?.status ?? '',\n updatedAt: event?.updated_at ?? '',\n })) ?? [],\n }))\n : [],\n comments:\n purchaseOrder?.comments?.map((comment: any) => ({\n uid: comment?.uid ?? '',\n createdAt: comment?.created_at ?? '',\n author: {\n firstname: comment?.author?.firstname ?? '',\n lastname: comment?.author?.lastname ?? '',\n email: comment?.author?.email ?? '',\n },\n text: comment?.text ?? '',\n })) ?? [],\n createdAt: purchaseOrder?.created_at ?? '',\n updatedAt: purchaseOrder?.updated_at ?? '',\n createdBy: {\n firstname: purchaseOrder?.created_by?.firstname ?? '',\n lastname: purchaseOrder?.created_by?.lastname ?? '',\n email: purchaseOrder?.created_by?.email ?? '',\n },\n historyLog:\n purchaseOrder?.history_log?.map((log: any) => ({\n activity: log?.activity ?? '',\n createdAt: log?.created_at ?? '',\n message: log?.message ?? '',\n uid: log?.uid ?? '',\n })) ?? [],\n quote: transformQuoteToOrder(purchaseOrder?.quote),\n order: {\n id: purchaseOrder?.order?.id ?? '',\n orderNumber: purchaseOrder?.order?.number ?? '',\n },\n };\n\n return order;\n};\n\nfunction transformQuoteToOrder(quote: any) {\n if (!quote) return null;\n\n // Helper functions\n const parseNumber = (value: number | undefined | null) => {\n return value || 0;\n };\n\n const transformUserInformation = (user: any) => {\n return {\n firstName: user?.firstname ?? '',\n lastName: user?.lastname ?? '',\n middleName: user?.middlename ?? '',\n };\n };\n\n const transformAddress = (address: any) => {\n const { firstName, lastName, middleName } =\n transformUserInformation(address);\n\n return {\n firstName,\n lastName,\n middleName,\n city: address?.city ?? '',\n company: address?.company ?? '',\n country: address?.country?.label ?? '',\n countryCode: address?.country?.code ?? '',\n fax: address?.fax ?? '',\n postCode: address?.postcode ?? '',\n prefix: address?.prefix ?? '',\n region: address?.region?.label ?? '',\n regionId: address?.region?.code ?? '',\n street: address?.street ?? [],\n suffix: address?.suffix ?? '',\n telephone: address?.telephone ?? '',\n vatId: address?.vat_id ?? '',\n customAttributes: address?.custom_attributes ?? [],\n };\n };\n\n const transformProduct = (product: any) => {\n return {\n __typename: product?.__typename || '',\n uid: product?.uid || '',\n onlyXLeftInStock: product?.only_x_left_in_stock ?? 0,\n stockStatus: product?.stock_status ?? '',\n priceRange: {\n maximumPrice: {\n regularPrice: {\n currency:\n product?.price_range?.maximum_price?.regular_price?.currency ??\n '',\n value:\n product?.price_range?.maximum_price?.regular_price?.value ?? 0,\n },\n },\n },\n canonicalUrl: product?.canonical_url ?? '',\n urlKey: product?.url_key || '',\n id: product?.uid ?? '',\n name: product?.name || '',\n sku: product?.sku || '',\n image: product?.image?.url || '',\n imageAlt: product?.image?.label || '',\n productType: product?.__typename || '',\n thumbnail: {\n label: product?.thumbnail?.label || '',\n url: product?.thumbnail?.url || '',\n },\n };\n };\n\n const transformConfigurableOptions = (item: any) => {\n if (!item) return;\n\n // GraphQL returns configurable_options (not selected_options)\n if (!('configurable_options' in item)) return;\n\n const configurableOptions: Record<string, string> = {};\n\n for (const option of item.configurable_options!) {\n // GraphQL fields: option_label and value_label\n configurableOptions[option!.option_label] = option!.value_label;\n }\n\n return configurableOptions;\n };\n const transformBundleOptions = (data: any) => {\n const bundle = data?.map((option: any) => ({\n uid: option.uid,\n label: option.label,\n values: option.values.map((value: any) => value.product_name).join(', '),\n }));\n\n const bundleOptions: { [key: string]: any } = {};\n\n bundle?.forEach((option: any) => {\n bundleOptions[option.label] = option.values;\n });\n\n return Object.keys(bundleOptions).length > 0 ? bundleOptions : null;\n };\n\n const transformLinks = (links: { title: string }[]) => {\n return links?.length > 0\n ? {\n count: links.length,\n result: links.map((link: any) => link.title).join(', '),\n }\n : null;\n };\n\n const transformGiftCard = (item: any) => {\n return {\n senderName: item?.gift_card?.sender_name || '',\n senderEmail: item?.gift_card?.sender_email || '',\n recipientEmail: item?.gift_card?.recipient_email || '',\n recipientName: item?.gift_card?.recipient_name || '',\n message: item?.gift_card?.message || '',\n };\n };\n\n const transformGiftMessage = (data: any) => {\n return {\n senderName: data?.gift_message?.from ?? '',\n recipientName: data?.gift_message?.to ?? '',\n message: data?.gift_message?.message ?? '',\n };\n };\n\n const transformGiftWrapping = (data: any) => {\n return {\n design: data?.gift_wrapping?.design ?? '',\n uid: data?.gift_wrapping?.uid ?? '',\n selected: Boolean(data?.gift_wrapping?.uid),\n image: {\n url: data?.gift_wrapping?.image?.url ?? '',\n label: data?.gift_wrapping?.image?.label ?? '',\n },\n price: {\n currency: data?.gift_wrapping?.price?.currency ?? 'USD',\n value: data?.gift_wrapping?.price?.value ?? 0,\n },\n };\n };\n\n const transformWrappingPrice = (data: any) => {\n return {\n currency: data?.currency ?? 'USD',\n value: data?.value ?? 0,\n };\n };\n\n const transformTaxCalculations = (\n itemPrices: any,\n productPrice: { value: number; currency: string }\n ) => {\n const price = itemPrices?.price;\n const priceIncludingTax = itemPrices?.priceIncludingTax;\n const originalPrice = itemPrices?.originalPrice;\n\n // For quote, discounted is always false since there are no discounts yet\n const discounted = false;\n const baseOriginalPriceValue = discounted\n ? originalPrice?.value\n : priceIncludingTax?.value;\n\n const includeAndExcludeTax = {\n originalPrice,\n baseOriginalPrice: {\n value: baseOriginalPriceValue,\n currency: originalPrice?.currency,\n },\n baseDiscountedPrice: {\n value: priceIncludingTax?.value,\n currency: priceIncludingTax?.currency,\n },\n baseExcludingTax: {\n value: price?.value,\n currency: price?.currency,\n },\n };\n\n const excludeTax = {\n originalPrice,\n baseOriginalPrice: {\n value: originalPrice?.value,\n currency: priceIncludingTax?.currency,\n },\n baseDiscountedPrice: {\n value: productPrice?.value,\n currency: price?.currency,\n },\n baseExcludingTax: {\n value: price?.value,\n currency: price?.currency,\n },\n };\n\n const includeTax = {\n singleItemPrice: {\n value: discounted ? originalPrice.value : priceIncludingTax.value,\n currency: priceIncludingTax.currency,\n },\n baseOriginalPrice: {\n value: baseOriginalPriceValue,\n currency: priceIncludingTax.currency,\n },\n baseDiscountedPrice: {\n value: priceIncludingTax.value,\n currency: priceIncludingTax.currency,\n },\n };\n\n return {\n includeAndExcludeTax,\n excludeTax,\n includeTax,\n };\n };\n\n const transformQuoteItem = (item: any) => {\n const product = item?.product;\n const prices = item?.prices;\n const quantity = parseNumber(item?.quantity);\n\n const itemPrices = {\n price: prices?.price ?? { value: 0, currency: 'USD' },\n priceIncludingTax: prices?.price_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n originalPrice: prices?.original_item_price ?? {\n value: 0,\n currency: 'USD',\n },\n originalPriceIncludingTax: prices?.original_item_price ?? {\n value: 0,\n currency: 'USD',\n },\n discounts: prices?.discounts ?? [],\n };\n\n const discounted =\n (prices?.original_item_price?.value ?? 0) > (prices?.price?.value ?? 0);\n\n const price = prices?.price ?? { value: 0, currency: 'USD' };\n\n return {\n giftMessage: transformGiftMessage(item),\n giftWrappingPrice: transformWrappingPrice(item?.gift_wrapping?.price),\n productGiftWrapping: [transformGiftWrapping(item)],\n taxCalculations: transformTaxCalculations(itemPrices, price),\n productSalePrice: price,\n status: item?.is_available ? 'available' : 'unavailable',\n currentReturnOrderQuantity: 0,\n eligibleForReturn: false,\n productSku: product?.sku ?? '',\n type: product?.__typename ?? '',\n discounted,\n id: item?.uid ?? '',\n productName: product?.name ?? '',\n productUrlKey: product?.url_key ?? '',\n regularPrice: {\n value: product?.price_range?.maximum_price?.regular_price?.value ?? 0,\n currency:\n product?.price_range?.maximum_price?.regular_price?.currency ?? 'USD',\n },\n price,\n product: transformProduct(product),\n selectedOptions: item?.customizable_options ?? [],\n thumbnail: {\n label: product?.thumbnail?.label || '',\n url: product?.thumbnail?.url || '',\n },\n downloadableLinks:\n product?.__typename === 'DownloadableProduct' &&\n item?.downloadable_links\n ? transformLinks(item.downloadable_links)\n : null,\n prices: itemPrices,\n itemPrices,\n bundleOptions:\n product?.__typename === 'BundleProduct' && item?.bundle_options\n ? transformBundleOptions(item.bundle_options)\n : null,\n totalInclTax: prices?.row_total_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n priceInclTax: prices?.price_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n total: prices?.row_total ?? { value: 0, currency: 'USD' },\n configurableOptions:\n product?.__typename === 'ConfigurableProduct'\n ? transformConfigurableOptions(item)\n : undefined,\n giftCard:\n product?.__typename === 'GiftCardProduct'\n ? transformGiftCard(item)\n : undefined,\n quantityCanceled: 0,\n quantityInvoiced: 0,\n quantityOrdered: quantity,\n quantityRefunded: 0,\n quantityReturned: 0,\n quantityShipped: 0,\n requestQuantity: 0,\n totalQuantity: quantity,\n returnableQuantity: 0,\n quantityReturnRequested: 0,\n };\n };\n\n const transformGiftOptions = (giftOptions: any) => {\n return {\n giftWrappingForItems: giftOptions?.gift_wrapping_for_items ?? {\n value: 0,\n currency: 'USD',\n },\n giftWrappingForItemsInclTax:\n giftOptions?.gift_wrapping_for_items_incl_tax ?? {\n value: 0,\n currency: 'USD',\n },\n giftWrappingForOrder: giftOptions?.gift_wrapping_for_order ?? {\n value: 0,\n currency: 'USD',\n },\n giftWrappingForOrderInclTax:\n giftOptions?.gift_wrapping_for_order_incl_tax ?? {\n value: 0,\n currency: 'USD',\n },\n printedCard: giftOptions?.printed_card ?? {\n value: 0,\n currency: 'USD',\n },\n printedCardInclTax: giftOptions?.printed_card_incl_tax ?? {\n value: 0,\n currency: 'USD',\n },\n };\n };\n\n const transformAppliedGiftCards = (appliedGiftCards: any[] = []) => {\n if (!appliedGiftCards || appliedGiftCards.length === 0) return [];\n\n return appliedGiftCards.map((giftCard: any) => ({\n code: giftCard?.code ?? '',\n appliedBalance: {\n value: giftCard?.applied_balance?.value ?? 0,\n currency: giftCard?.applied_balance?.currency ?? 'USD',\n },\n }));\n };\n\n const transformTaxes = (appliedTaxes: any[] = []) => {\n if (!appliedTaxes || appliedTaxes.length === 0) return [];\n\n return appliedTaxes.map((tax: any) => ({\n amount: {\n value: tax?.amount?.value ?? 0,\n currency: tax?.amount?.currency ?? 'USD',\n },\n rate: tax?.rate ?? 0,\n title: tax?.title ?? tax?.label ?? '',\n }));\n };\n\n // Get shipping address (first one if multiple)\n const shippingAddressData = quote?.shipping_addresses?.[0];\n const billingAddressData = quote?.billing_address;\n const selectedShippingMethod = shippingAddressData?.selected_shipping_method;\n const selectedPaymentMethod = quote?.selected_payment_method;\n const prices = quote?.prices;\n\n // Transform items from quote\n const items = quote?.itemsV2?.items?.map(transformQuoteItem) ?? [];\n\n // Calculate total quantity\n const totalQuantity = items.reduce(\n (accum: number, item: any) => accum + item.totalQuantity,\n 0\n );\n\n // Build OrderDataModel structure from quote\n // Build shipping method string like in order: \"carrier_title - method_title\"\n const shippingMethodString = selectedShippingMethod\n ? `${selectedShippingMethod.carrier_title ?? ''} - ${\n selectedShippingMethod.method_title ?? ''\n }`.trim()\n : '';\n\n const appliedGiftCards = transformAppliedGiftCards(quote?.applied_gift_cards);\n\n return {\n giftReceiptIncluded: quote?.gift_receipt_included ?? false,\n printedCardIncluded: quote?.printed_card_included ?? false,\n giftWrappingOrder: {\n price: {\n value: quote?.gift_wrapping?.price?.value ?? 0,\n currency: quote?.gift_wrapping?.price?.currency ?? 'USD',\n },\n uid: quote?.gift_wrapping?.uid ?? '',\n },\n placeholderImage: '',\n returnNumber: undefined,\n id: quote?.id ?? '',\n orderStatusChangeDate: undefined,\n number: '', // Quotes don't have order numbers yet\n email: quote?.email ?? '',\n token: undefined,\n status: 'pending', // Quote status\n isVirtual: quote?.is_virtual ?? false,\n totalQuantity,\n shippingMethod: shippingMethodString,\n carrier: selectedShippingMethod?.carrier_code ?? '',\n orderDate: '', // Quotes don't have order date yet\n returns: [],\n discounts: prices?.discounts ?? [],\n coupons: quote?.applied_coupons ?? [],\n payments: [\n {\n code: selectedPaymentMethod?.code ?? '',\n name: selectedPaymentMethod?.title ?? '',\n },\n ],\n shipping: {\n code: shippingMethodString,\n amount: selectedShippingMethod?.amount?.value ?? 0,\n currency: selectedShippingMethod?.amount?.currency ?? 'USD',\n },\n shipments: [],\n items,\n totalGiftCard: appliedGiftCards.length\n ? appliedGiftCards.reduce(\n (acc, gc) => ({\n value: acc.value + (gc?.appliedBalance?.value ?? 0),\n currency: gc?.appliedBalance?.currency ?? acc.currency,\n }),\n {\n value: 0,\n currency: appliedGiftCards[0]?.appliedBalance?.currency ?? 'USD',\n }\n )\n : { value: 0, currency: 'USD' },\n grandTotal: prices?.grand_total ?? { value: 0, currency: 'USD' },\n grandTotalExclTax: prices?.grand_total_excluding_tax ?? {\n value: 0,\n currency: 'USD',\n },\n totalShipping: selectedShippingMethod?.amount ?? {\n value: 0,\n currency: 'USD',\n },\n subtotalExclTax: prices?.subtotal_excluding_tax ?? {\n value: 0,\n currency: 'USD',\n },\n subtotalInclTax: prices?.subtotal_including_tax ?? {\n value: 0,\n currency: 'USD',\n },\n totalTax: {\n value:\n (prices?.grand_total?.value ?? 0) -\n (prices?.grand_total_excluding_tax?.value ?? 0),\n currency: prices?.grand_total?.currency ?? 'USD',\n },\n shippingAddress: shippingAddressData\n ? transformAddress(shippingAddressData)\n : null,\n totalGiftOptions: transformGiftOptions(prices?.gift_options),\n billingAddress: billingAddressData\n ? transformAddress(billingAddressData)\n : null,\n availableActions: [],\n taxes: transformTaxes(prices?.applied_taxes),\n appliedGiftCards,\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PURCHASE_ORDERS_FRAGMENT } from '@/b2b-purchase-order/api/graphql/PurchaseOrdersFragment.graphql';\n\nexport const APPROVE_PURCHASE_ORDERS = /* GraphQL */ `\n mutation APPROVE_PURCHASE_ORDERS($input: PurchaseOrdersActionInput!) {\n approvePurchaseOrders(input: $input) {\n purchase_orders {\n ...PURCHASE_ORDERS_FRAGMENT\n }\n errors {\n message\n type\n }\n }\n }\n ${PURCHASE_ORDERS_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { fetchGraphQl } from '@/b2b-purchase-order/api/fetch-graphql';\nimport { handleNetworkError } from '@/b2b-purchase-order/lib/network-error';\nimport { handleFetchError } from '@/b2b-purchase-order/lib/fetch-error';\nimport { APPROVE_PURCHASE_ORDERS } from '@/b2b-purchase-order/api/approvePurchaseOrders/graphql/approvePurchaseOrders.graphql';\nimport { transformPurchaseOrder } from '@/b2b-purchase-order/data/transforms/transform-purchase-order';\nimport { PurchaseOrderModel } from '@/b2b-purchase-order/data/models';\n\nexport const approvePurchaseOrders = async (\n uids: string | string[]\n): Promise<{\n errors: { message: string; type: string }[];\n purchaseOrders: PurchaseOrderModel[];\n}> => {\n const uidArray = Array.isArray(uids) ? uids : [uids];\n\n if (!uidArray || uidArray.length === 0) {\n throw new Error('Purchase Order UID(s) are required');\n }\n\n if (uidArray.some((uid) => !uid || uid.trim() === '')) {\n throw new Error('All Purchase Order UIDs must be valid');\n }\n\n const input = {\n purchase_order_uids: uidArray,\n };\n\n return fetchGraphQl(APPROVE_PURCHASE_ORDERS, {\n variables: { input },\n })\n .then((response: any) => {\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n const data = response.data?.approvePurchaseOrders;\n if (!data) {\n throw new Error('Failed to approve purchase orders');\n }\n\n return {\n errors: (data?.errors ?? []).map((error: any) => ({\n message: error?.message ?? '',\n type: error?.type ?? '',\n })),\n purchaseOrders:\n data?.purchase_orders?.map((order: any) =>\n transformPurchaseOrder(order)\n ) ?? [],\n };\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { PURCHASE_ORDERS_FRAGMENT } from '@/b2b-purchase-order/api/graphql/PurchaseOrdersFragment.graphql';\n\nexport const REJECT_PURCHASE_ORDERS = /* GraphQL */ `\n mutation REJECT_PURCHASE_ORDERS($input: PurchaseOrdersActionInput!) {\n rejectPurchaseOrders(input: $input) {\n purchase_orders {\n ...PURCHASE_ORDERS_FRAGMENT\n }\n errors {\n message\n type\n }\n }\n }\n ${PURCHASE_ORDERS_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { fetchGraphQl } from '@/b2b-purchase-order/api/fetch-graphql';\nimport { handleNetworkError } from '@/b2b-purchase-order/lib/network-error';\nimport { handleFetchError } from '@/b2b-purchase-order/lib/fetch-error';\nimport { REJECT_PURCHASE_ORDERS } from '@/b2b-purchase-order/api/rejectPurchaseOrders/graphql/rejectPurchaseOrders.graphql';\nimport { transformPurchaseOrder } from '@/b2b-purchase-order/data/transforms/transform-purchase-order';\nimport { PurchaseOrderModel } from '@/b2b-purchase-order/data/models';\n\nexport const rejectPurchaseOrders = async (\n uids: string | string[]\n): Promise<{\n errors: { message: string; type: string }[];\n purchaseOrders: PurchaseOrderModel[];\n}> => {\n const uidArray = Array.isArray(uids) ? uids : [uids];\n\n if (!uidArray || uidArray.length === 0) {\n throw new Error('Purchase Order UID(s) are required');\n }\n\n if (uidArray.some((uid) => !uid || uid.trim() === '')) {\n throw new Error('All Purchase Order UIDs must be valid');\n }\n\n const input = {\n purchase_order_uids: uidArray,\n };\n\n return fetchGraphQl(REJECT_PURCHASE_ORDERS, {\n variables: { input },\n })\n .then((response: any) => {\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n const data = response.data?.rejectPurchaseOrders;\n\n return {\n errors: (data?.errors ?? []).map((error: any) => ({\n message: error?.message ?? '',\n type: error?.type ?? '',\n })),\n purchaseOrders: (data?.purchase_orders ?? []).map(\n transformPurchaseOrder\n ),\n };\n })\n .catch(handleNetworkError);\n};\n"],"names":["PURCHASE_ORDER_QUOTE_FRAGMENT","PURCHASE_ORDERS_FRAGMENT","transformPurchaseOrder","purchaseOrder","_a","flow","event","_b","comment","_c","_d","_e","_f","log","transformQuoteToOrder","_g","_h","quote","parseNumber","value","transformUserInformation","user","transformAddress","address","firstName","lastName","middleName","transformProduct","product","_i","_j","transformConfigurableOptions","item","configurableOptions","option","transformBundleOptions","data","bundle","bundleOptions","transformLinks","links","link","transformGiftCard","transformGiftMessage","transformGiftWrapping","_k","transformWrappingPrice","transformTaxCalculations","itemPrices","productPrice","price","priceIncludingTax","originalPrice","discounted","baseOriginalPriceValue","includeAndExcludeTax","excludeTax","includeTax","transformQuoteItem","prices","quantity","transformGiftOptions","giftOptions","transformAppliedGiftCards","appliedGiftCards","giftCard","transformTaxes","appliedTaxes","tax","shippingAddressData","billingAddressData","selectedShippingMethod","selectedPaymentMethod","items","totalQuantity","accum","shippingMethodString","acc","gc","_l","_m","_n","_o","APPROVE_PURCHASE_ORDERS","approvePurchaseOrders","uids","uidArray","uid","fetchGraphQl","response","handleF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,GAAA,YAAAA,EAAM,kBAAN,YAAA3B,EAAuB,IAAKmF,GAC1B1F,GAAuB0F,CAAK,KACzB,CAAA,CAAC,CAEZ,CAAC,EACA,MAAMC,EAAkB,CAC7B,ECjDaC,GAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYhD7F,EAAwB;AAAA,ECRf8F,GAAuB,MAClCV,GAII,CACJ,MAAMC,EAAW,MAAM,QAAQD,CAAI,EAAIA,EAAO,CAACA,CAAI,EAEnD,GAAI,CAACC,GAAYA,EAAS,SAAW,EACnC,MAAM,IAAI,MAAM,oCAAoC,EAGtD,GAAIA,EAAS,KAAMC,GAAQ,CAACA,GAAOA,EAAI,SAAW,EAAE,EAClD,MAAM,IAAI,MAAM,uCAAuC,EAOzD,OAAOC,GAAaM,GAAwB,CAC1C,UAAW,CAAE,MALD,CACZ,oBAAqBR,CAAA,CAIR,CAAM,CACpB,EACE,KAAMG,GAAkB,UACnBrF,EAAAqF,EAAS,SAAT,MAAArF,EAAiB,QACnBsF,GAAiBD,EAAS,MAAM,EAGlC,MAAMrD,GAAO7B,EAAAkF,EAAS,OAAT,YAAAlF,EAAe,qBAE5B,MAAO,CACL,SAAS6B,GAAA,YAAAA,EAAM,SAAU,CAAA,GAAI,IAAKuD,IAAgB,CAChD,SAASA,GAAA,YAAAA,EAAO,UAAW,GAC3B,MAAMA,GAAA,YAAAA,EAAO,OAAQ,EAAA,EACrB,EACF,iBAAiBvD,GAAA,YAAAA,EAAM,kBAAmB,CAAA,GAAI,IAC5ClC,EAAA,CACF,CAEJ,CAAC,EACA,MAAM2F,EAAkB,CAC7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as u,jsxs as E,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as F}from"@dropins/tools/lib.js";import{Checkbox as Q,Input as k,TextArea as K,RadioButton as j,MultiSelect as B,Picker as U,Button as x,Card as Y,InLineAlert as X}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/PurchaseOrderHistoryLogContent.js";import{useReducer as $,useMemo as y,useEffect as z,useCallback as g}from"@dropins/tools/preact-hooks.js";import{u as J}from"../chunks/useCustomerRolePermissions.js";import{c as W,g as Z,u as ee,a as re}from"../chunks/currencyInfo.js";import{t as ae}from"../chunks/case-converter.js";import{g as oe}from"../chunks/getPurchaseOrderApprovalRule.js";import{Text as le,useText as te}from"@dropins/tools/i18n.js";import{P as ie}from"../chunks/PurchaseOrdersHeader.js";import{F as se}from"../chunks/FormLoader.js";import"@dropins/tools/preact.js";import"../chunks/permissions.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/fetch-error.js";import"../chunks/transform-purchase-order-approval-rule.js";const ne=(e,a,l)=>{const r={...e};switch(a){case"status":r.status=l?"ENABLED":"DISABLED";break;case"name":r.name=l;break;case"description":r.description=l;break;case"ruleType":r.condition.attribute=l;break;case"ruleCondition":r.condition.operator=l;break;case"ruleValue":{let t=typeof l=="string"?l.replace(/[^\d]/g,""):String(l);t===""?r.condition.attribute==="NUMBER_OF_SKUS"?r.condition.quantity="":r.condition.amount.value="":r.condition.attribute==="NUMBER_OF_SKUS"?r.condition.quantity=+t:r.condition.amount.value=+t;break}case"ruleConditionCurrency":r.condition.amount.currency=l;break;case"approvers":r.approvers=l;break;case"roleType":r.roleType=l;break;case"appliesTo":r.appliesTo=l;break}return r},L=e=>{const a={};return(!e.name||e.name.trim()==="")&&(a.name="PurchaseOrders.approvalRuleForm.errorsMessages.required"),e.roleType==="specific_roles"&&(!e.appliesTo||e.appliesTo.length===0)&&(a.appliesTo="PurchaseOrders.approvalRuleForm.errorsMessages.approvers"),e.condition.attribute==="NUMBER_OF_SKUS"?e.condition.quantity===""&&(a.ruleValue="PurchaseOrders.approvalRuleForm.errorsMessages.required"):e.condition.amount.value===""&&(a.ruleValue="PurchaseOrders.approvalRuleForm.errorsMessages.required"),(!e.approvers||e.approvers.length===0)&&(a.approvers="PurchaseOrders.approvalRuleForm.errorsMessages.approvers"),a},C=(e,a,l)=>{const r={...a};return Object.keys(e).forEach(t=>{l[t]&&(r[t]=e[t])}),Object.keys(r).forEach(t=>{l[t]&&!e[t]&&delete r[t]}),r},N={GRAND_TOTAL:"ruleTypeGrandTotal",SHIPPING_INCL_TAX:"ruleTypeShippingInclTax",NUMBER_OF_SKUS:"ruleTypeNumberOfSkus"},A={MORE_THAN:"conditionOperatorMoreThan",LESS_THAN:"conditionOperatorLessThan",MORE_THAN_OR_EQUAL_TO:"conditionOperatorMoreThanOrEqualTo",LESS_THAN_OR_EQUAL_TO:"conditionOperatorLessThanOrEqualTo"},q={ALL_USERS:"appliesToAllUsers",SPECIFIC_ROLES:"appliesToSpecificRoles"},pe={status:"ENABLED",name:"",description:"",roleType:"all_users",appliesTo:[],condition:{quantity:"",amount:{currency:"USD",value:""},attribute:"GRAND_TOTAL",operator:"MORE_THAN"},approvers:[]},ue={formValues:pe,isLoading:!1,submitError:null,availableAppliesTo:[],availableRequiresApprovalFrom:[],errors:{},touched:{},currencyCodesList:[{text:"USD",value:"USD"}]},ce={name:!0,appliesTo:!0,ruleValue:!0,approvers:!0},D={REQUIRED:"PurchaseOrders.approvalRuleForm.errorsMessages.required",APPROVERS:"PurchaseOrders.approvalRuleForm.errorsMessages.approvers",FAILED_TO_LOAD:"Failed to load metadata. Please try again.",FAILED_TO_CREATE:"Failed to create approval rule. Please try again."},de=e=>[{text:e[N.GRAND_TOTAL],value:"GRAND_TOTAL"},{text:e[N.SHIPPING_INCL_TAX],value:"SHIPPING_INCL_TAX"},{text:e[N.NUMBER_OF_SKUS],value:"NUMBER_OF_SKUS"}],Te=e=>[{text:e[A.MORE_THAN],value:"MORE_THAN"},{text:e[A.LESS_THAN],value:"LESS_THAN"},{text:e[A.MORE_THAN_OR_EQUAL_TO],value:"MORE_THAN_OR_EQUAL_TO"},{text:e[A.LESS_THAN_OR_EQUAL_TO],value:"LESS_THAN_OR_EQUAL_TO"}],me=e=>[{text:e[q.ALL_USERS],value:"all_users"},{text:e[q.SPECIFIC_ROLES],value:"specific_roles"}],_e="ENABLED",Ee="GRAND_TOTAL",Oe="MORE_THAN",ve="USD",be=0,Re=0,he=e=>Object.keys(N).includes(e),fe=e=>Object.keys(A).includes(e),Ae=e=>{var a,l,r,t,c,s,i,o,O,v;return{status:e.status||_e,name:e.name||"",description:e.description||"",roleType:((a=e.appliesToRoles)==null?void 0:a.length)>0?"specific_roles":"all_users",appliesTo:((l=e.appliesToRoles)==null?void 0:l.map(_=>_.id))||[],condition:{quantity:((r=e.condition)==null?void 0:r.quantity)??be,amount:{currency:((c=(t=e.condition)==null?void 0:t.amount)==null?void 0:c.currency)||ve,value:((i=(s=e.condition)==null?void 0:s.amount)==null?void 0:i.value)??Re},attribute:he((o=e.condition)==null?void 0:o.attribute)?e.condition.attribute:Ee,operator:fe((O=e.condition)==null?void 0:O.operator)?e.condition.operator:Oe},approvers:((v=e.approverRoles)==null?void 0:v.map(_=>_.id))||[]}},V=e=>e!=null&&e!==""&&e!==0;function ye(e){const{roleType:a,appliesTo:l,condition:r,...t}=e,c=a==="all_users"?{appliesTo:[]}:{appliesTo:l};let s={};if(r){const{amount:o,quantity:O,...v}=r,_={...v};V(o==null?void 0:o.value)&&(_.amount=o),V(O)&&(_.quantity=O),s=_}return ae({...t,...c,condition:s})}function Se(e,a){switch(a.type){case"SET_LOADING":return{...e,isLoading:a.payload};case"SET_SUBMIT_ERROR":return{...e,submitError:a.payload};case"SET_FORM_VALUES":return{...e,formValues:a.payload};case"SET_AVAILABLE_APPLIES_TO":return{...e,availableAppliesTo:a.payload};case"SET_AVAILABLE_APPROVERS":return{...e,availableRequiresApprovalFrom:a.payload};case"SET_ERRORS":return{...e,errors:a.payload};case"SET_TOUCHED":return{...e,touched:a.payload};case"SET_CURRENCIES":return{...e,currencyCodesList:a.payload};case"UPDATE_FIELD":{const{key:l,value:r}=a.payload,t=ne(e.formValues,l,r),c={...e.touched,[l]:!0};l==="roleType"&&r==="specific_roles"&&(c.appliesTo=!0);const s=L(t),i=C(s,e.errors,c);return{...e,formValues:t,touched:c,errors:i}}case"TOUCH_FIELD":{const l=a.payload,r={...e.touched,[l]:!0},t=L(e.formValues),c=C(t,e.errors,r);return{...e,touched:r,errors:c}}case"MARK_FIELDS_TOUCHED":{const l={...e.touched,...a.payload},r=L(e.formValues),t=C(r,e.errors,l);return{...e,touched:l,errors:t}}default:return e}}const Le=({t:e,approvalRuleID:a,routeApprovalRulesList:l,onSubmit:r,onChange:t,permissions:c,loadingPermissions:s})=>{const[i,o]=$(Se,ue),O=y(()=>de(e),[e]),v=y(()=>Te(e),[e]),_=y(()=>me(e),[e]);z(()=>{o({type:"SET_LOADING",payload:!0}),W().then(n=>{o({type:"SET_CURRENCIES",payload:n.availableCurrencyCodes})}).catch(n=>{console.error("Failed to fetch currencies:",n)}),Z().then(n=>{const{availableAppliesTo:b,availableRequiresApprovalFrom:R}=n;return o({type:"SET_AVAILABLE_APPLIES_TO",payload:b}),o({type:"SET_AVAILABLE_APPROVERS",payload:R}),a?oe(a):null}).then(n=>{n&&o({type:"SET_FORM_VALUES",payload:Ae(n)}),o({type:"SET_SUBMIT_ERROR",payload:null})}).catch(n=>{console.error("Failed to fetch data:",n),o({type:"SET_SUBMIT_ERROR",payload:D.FAILED_TO_LOAD})}).finally(()=>{o({type:"SET_LOADING",payload:!1})})},[a]);const h=g((n,b)=>{o({type:"UPDATE_FIELD",payload:{key:n,value:b}}),t&&t({...i.formValues,[n]:b})},[t,i.formValues]),m=g(n=>{o({type:"TOUCH_FIELD",payload:n}),t&&t(i.formValues)},[t,i.formValues]),f=g(async()=>{o({type:"SET_LOADING",payload:!0}),o({type:"SET_SUBMIT_ERROR",payload:null}),o({type:"MARK_FIELDS_TOUCHED",payload:ce});const n=L(i.formValues);if(Object.keys(n).length>0){o({type:"SET_ERRORS",payload:n}),o({type:"SET_LOADING",payload:!1});return}const b=ye(i.formValues);try{let R;if(a?R=await ee({uid:a,...b}):R=await re(b),!R.uid){o({type:"SET_SUBMIT_ERROR",payload:D.FAILED_TO_CREATE}),o({type:"SET_LOADING",payload:!1});return}r&&r(i.formValues),l?window.location.href=l():o({type:"SET_LOADING",payload:!1})}catch(R){console.error("Failed to save approval rule:",R),o({type:"SET_SUBMIT_ERROR",payload:D.FAILED_TO_CREATE}),o({type:"SET_LOADING",payload:!1})}},[i.formValues,l,a,r]),T=y(()=>!!(i.isLoading||s||!(c!=null&&c.permissions.viewApprovalRules)&&!(c!=null&&c.permissions.manageApprovalRules)),[i.isLoading,s,c]);return{availableAppliesTo:i.availableAppliesTo,availableRequiresApprovalFrom:i.availableRequiresApprovalFrom,formValues:i.formValues,ruleTypeOptions:O,conditionOperators:v,currencies:i.currencyCodesList,appliesToOptions:_,handleSetFormValues:h,handleSubmit:f,handleFieldTouch:m,errors:i.errors,touched:i.touched,isLoading:i.isLoading,formLoading:T,submitError:i.submitError}},S=({touched:e=!1,error:a,className:l="error-message"})=>!e||!a?null:u("span",{className:l,children:u(le,{id:a})}),Ne=({availableRequiresApprovalFrom:e,conditionOperators:a,availableAppliesTo:l,appliesToOptions:r,ruleTypeOptions:t,currencies:c,formValues:s,errors:i,touched:o,isLoading:O,permissions:v,handleSubmit:_,handleFieldTouch:h,handleSetFormValues:m,routeApprovalRulesList:f,t:T})=>{var b,R;const n=O||!((b=v==null?void 0:v.permissions)!=null&&b.viewApprovalRules);return E("form",{"data-testid":"approval-rule-form",children:[u(Q,{"data-testid":"status-toggle",className:"b2b-purchase-order-approval-rule-form__toggle",disabled:n,name:"status",label:T.formEnabled,checked:s.status==="ENABLED",onChange:p=>{const d=p.target.checked;m("status",d)}}),E("div",{"data-testid":"name-input-container",children:[u(k,{"data-testid":"name-input",className:"b2b-purchase-order-approval-rule-form__name-input",disabled:n,name:"name",floatingLabel:T.inputRuleNameFloatingLabel,placeholder:T.inputRuleNamePlaceholder,value:s.name,error:!!(o.name&&i.name),onChange:p=>{const d=p.target.value;m("name",d)},onBlur:()=>h("name")}),u(S,{touched:o.name,error:i.name})]}),u(K,{"data-testid":"description-textarea",className:"b2b-purchase-order-approval-rule-form__description",disabled:n,name:"description",label:T.textAreaDescriptionLabel,value:s.description,onChange:p=>{const d=p.target.value;m("description",d)}}),E("div",{"data-testid":"applies-to-section",className:"b2b-purchase-order-approval-rule-form__applies-to",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__applies-to-title",children:T.titleAppliesTo}),r.map((p,d)=>u(j,{"data-testid":`applies-to-radio-${d}`,disabled:n,name:"radio-group",value:p.value,label:p.text,checked:s.roleType===p.value,onChange:P=>{const I=P.target.value;m("roleType",I)}},p.value)),s.roleType==="specific_roles"?E("div",{"data-testid":"applies-to-multiselect-container",className:"b2b-purchase-order-approval-rule-form__applies-to-multiselect",children:[u(B,{"data-testid":"applies-to-multiselect",disabled:n,name:"appliesTo",value:[...s.appliesTo],options:l.map(p=>({value:p.id,label:p.name})),error:!!(o.appliesTo&&i.appliesTo),onChange:p=>{m("appliesTo",p),o.appliesTo||h("appliesTo")}}),u(S,{touched:o.appliesTo,error:i.appliesTo})]}):null]}),E("div",{"data-testid":"rule-type-section",className:"b2b-purchase-order-approval-rule-form__rule-type",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__rule-type-title",children:T.titleRuleType}),u(U,{"data-testid":"rule-type-picker",className:"b2b-purchase-order-approval-rule-form__rule-type-picker",disabled:n,name:"ruleType",value:s.condition.attribute,options:t,handleSelect:p=>{const d=p.target.value;m("ruleType",d)}})]}),E("div",{"data-testid":"rule-condition-section",className:"b2b-purchase-order-approval-rule-form__rule-condition",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__rule-condition-title",children:(R=t.find(p=>p.value===s.condition.attribute))==null?void 0:R.text}),E("div",{className:F(["b2b-purchase-order-approval-rule-form__rule-condition-container",["b2b-purchase-order-approval-rule-form__rule-condition-container--error",!!i.ruleValue&&o.ruleValue]]),children:[u(U,{"data-testid":"rule-condition-picker",className:"b2b-purchase-order-approval-rule-form__rule-condition-picker",disabled:n,name:"ruleCondition",value:s.condition.operator,options:a,handleSelect:p=>{const d=p.target.value;m("ruleCondition",d)}}),E("div",{"data-testid":"rule-value-container",children:[u(k,{"data-testid":"rule-value-input",className:"b2b-purchase-order-approval-rule-form__rule-value-input",disabled:n,name:"ruleValue",floatingLabel:s.condition.attribute==="NUMBER_OF_SKUS"?T.inputQuantityFloatingLabel:T.inputAmountFloatingLabel,placeholder:s.condition.attribute==="NUMBER_OF_SKUS"?T.inputQuantityPlaceholder:T.inputAmountPlaceholder,value:s.condition.attribute==="NUMBER_OF_SKUS"?s.condition.quantity:s.condition.amount.value,error:!!(o.ruleValue&&i.ruleValue),onChange:p=>{const d=p.target.value;m("ruleValue",d)},onBlur:()=>h("ruleValue")}),u(S,{touched:o.ruleValue,error:i.ruleValue})]}),s.condition.attribute!=="NUMBER_OF_SKUS"?u(U,{"data-testid":"rule-condition-currency-picker",className:"b2b-purchase-order-approval-rule-form__rule-condition-currency-picker",disabled:n,name:"ruleConditionCurrency",value:s.condition.amount.currency,options:c,handleSelect:p=>{const d=p.target.value;m("ruleConditionCurrency",d)}}):null]})]}),E("div",{"data-testid":"approval-role-section",className:"b2b-purchase-order-approval-rule-form__approval-role",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__approval-role-title",children:T.titleRequiresApprovalRole}),E("div",{className:"b2b-purchase-order-approval-rule-form__approval-role-multiselect",children:[u(B,{"data-testid":"approvers-multiselect",disabled:n,name:"approvers",value:[...s.approvers],options:e.map(p=>({value:p.id,label:p.name})),error:!!(o.approvers&&i.approvers),onChange:p=>{m("approvers",p),o.approvers||h("approvers")}}),u(S,{touched:o.approvers,error:i.approvers})]})]}),E("div",{"data-testid":"form-buttons",className:"b2b-purchase-order-approval-rule-form__buttons",children:[u(x,{"data-testid":"save-button",type:"button",disabled:n,onClick:_,children:T.buttonSave}),u(x,{"data-testid":"cancel-button",disabled:O,variant:"secondary",type:"button",onClick:()=>{window.location.href=(f==null?void 0:f())??""},children:T.buttonCancel})]})]})},Fe=({className:e,approvalRuleID:a,withHeader:l,withWrapper:r,routeApprovalRulesList:t,onSubmit:c,onChange:s})=>{const i=te({headerText:"PurchaseOrders.approvalRuleForm.headerText",titleAppliesTo:"PurchaseOrders.approvalRuleForm.titleAppliesTo",titleRuleType:"PurchaseOrders.approvalRuleForm.titleRuleType",titleRequiresApprovalRole:"PurchaseOrders.approvalRuleForm.titleRequiresApprovalRole",formEnabled:"PurchaseOrders.approvalRuleForm.fields.enabled",formDisabled:"PurchaseOrders.approvalRuleForm.fields.disabled",inputRuleNameFloatingLabel:"PurchaseOrders.approvalRuleForm.fields.inputRuleName.floatingLabel",inputRuleNamePlaceholder:"PurchaseOrders.approvalRuleForm.fields.inputRuleName.placeholder",textAreaDescriptionLabel:"PurchaseOrders.approvalRuleForm.fields.textAreaDescription.label",appliesToAllUsers:"PurchaseOrders.approvalRuleForm.fields.appliesTo.allUsers",appliesToSpecificRoles:"PurchaseOrders.approvalRuleForm.fields.appliesTo.specificRoles",ruleTypeGrandTotal:"PurchaseOrders.approvalRuleForm.fields.ruleTypeOptions.grandTotal",ruleTypeShippingInclTax:"PurchaseOrders.approvalRuleForm.fields.ruleTypeOptions.shippingInclTax",ruleTypeNumberOfSkus:"PurchaseOrders.approvalRuleForm.fields.ruleTypeOptions.numberOfSkus",conditionOperatorMoreThan:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.moreThan",conditionOperatorLessThan:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.lessThan",conditionOperatorMoreThanOrEqualTo:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.moreThanOrEqualTo",conditionOperatorLessThanOrEqualTo:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.lessThanOrEqualTo",inputQuantityFloatingLabel:"PurchaseOrders.approvalRuleForm.fields.inputQuantity.floatingLabel",inputQuantityPlaceholder:"PurchaseOrders.approvalRuleForm.fields.inputQuantity.placeholder",inputAmountFloatingLabel:"PurchaseOrders.approvalRuleForm.fields.inputAmount.floatingLabel",inputAmountPlaceholder:"PurchaseOrders.approvalRuleForm.fields.inputAmount.placeholder",buttonCancel:"PurchaseOrders.approvalRuleForm.fields.buttons.cancel",buttonSave:"PurchaseOrders.approvalRuleForm.fields.buttons.save"}),{permissions:o,loadingPermissions:O}=J(),{availableRequiresApprovalFrom:v,conditionOperators:_,availableAppliesTo:h,appliesToOptions:m,ruleTypeOptions:f,currencies:T,formValues:n,errors:b,touched:R,isLoading:p,submitError:d,formLoading:P,handleSubmit:I,handleFieldTouch:H,handleSetFormValues:G}=Le({t:i,approvalRuleID:a,loadingPermissions:O,permissions:o,routeApprovalRulesList:t,onSubmit:c,onChange:s});if(P)return u(se,{testId:"b2b-purchase-order-approval-rule-form",className:F(["b2b-purchase-order-approval-rule-form",e])});const M=E(w,{children:[!!d&&u(X,{heading:"",description:d}),u(Ne,{availableRequiresApprovalFrom:v,conditionOperators:_,availableAppliesTo:h,appliesToOptions:m,ruleTypeOptions:f,currencies:T,formValues:n,errors:b,touched:R,isLoading:p,handleSubmit:I,handleFieldTouch:H,handleSetFormValues:G,permissions:o,routeApprovalRulesList:t,t:i})]});return E("div",{"data-testid":"b2b-purchase-order-approval-rule-form",className:F(["b2b-purchase-order-approval-rule-form",e]),children:[l?u(ie,{headerText:i.headerText}):null,r?u(Y,{variant:"secondary",children:M}):M]})},Xe=({withHeader:e=!0,withWrapper:a=!0,className:l,approvalRuleID:r,routeApprovalRulesList:t,onSubmit:c,onChange:s})=>u("div",{"data-testid":"b2b-purchase-order-approval-rule-form-container",className:F(["b2b-purchase-order-approval-rule-form-container",l]),children:u(Fe,{withWrapper:a,withHeader:e,approvalRuleID:r,routeApprovalRulesList:t,onSubmit:c,onChange:s})});export{Xe as ApprovalRuleForm,Xe as default};
|
|
3
|
+
import{jsx as u,jsxs as O,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as F}from"@dropins/tools/lib.js";import{Checkbox as Q,Input as k,TextArea as K,RadioButton as j,MultiSelect as B,Picker as U,Button as x,Card as Y,InLineAlert as X}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/PurchaseOrderHistoryLogContent.js";import{useReducer as $,useMemo as y,useEffect as z,useCallback as g}from"@dropins/tools/preact-hooks.js";import{u as J}from"../chunks/useCustomerRolePermissions.js";import{c as W,g as Z,u as ee,a as re}from"../chunks/currencyInfo.js";import{t as ae}from"../chunks/case-converter.js";import{g as oe}from"../chunks/getPurchaseOrderApprovalRule.js";import{Text as le,useText as te}from"@dropins/tools/i18n.js";import{P as ie}from"../chunks/PurchaseOrdersHeader.js";import{F as se}from"../chunks/FormLoader.js";import"@dropins/tools/preact.js";import"../chunks/permissions.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-purchase-order-approval-rule.js";const ne=(e,a,l)=>{const r={...e};switch(a){case"status":r.status=l?"ENABLED":"DISABLED";break;case"name":r.name=l;break;case"description":r.description=l;break;case"ruleType":r.condition.attribute=l;break;case"ruleCondition":r.condition.operator=l;break;case"ruleValue":{let t=typeof l=="string"?l.replace(/[^\d]/g,""):String(l);t===""?r.condition.attribute==="NUMBER_OF_SKUS"?r.condition.quantity="":r.condition.amount.value="":r.condition.attribute==="NUMBER_OF_SKUS"?r.condition.quantity=+t:r.condition.amount.value=+t;break}case"ruleConditionCurrency":r.condition.amount.currency=l;break;case"approvers":r.approvers=l;break;case"roleType":r.roleType=l;break;case"appliesTo":r.appliesTo=l;break}return r},L=e=>{const a={};return(!e.name||e.name.trim()==="")&&(a.name="PurchaseOrders.approvalRuleForm.errorsMessages.required"),e.roleType==="specific_roles"&&(!e.appliesTo||e.appliesTo.length===0)&&(a.appliesTo="PurchaseOrders.approvalRuleForm.errorsMessages.approvers"),e.condition.attribute==="NUMBER_OF_SKUS"?e.condition.quantity===""&&(a.ruleValue="PurchaseOrders.approvalRuleForm.errorsMessages.required"):e.condition.amount.value===""&&(a.ruleValue="PurchaseOrders.approvalRuleForm.errorsMessages.required"),(!e.approvers||e.approvers.length===0)&&(a.approvers="PurchaseOrders.approvalRuleForm.errorsMessages.approvers"),a},C=(e,a,l)=>{const r={...a};return Object.keys(e).forEach(t=>{l[t]&&(r[t]=e[t])}),Object.keys(r).forEach(t=>{l[t]&&!e[t]&&delete r[t]}),r},N={GRAND_TOTAL:"ruleTypeGrandTotal",SHIPPING_INCL_TAX:"ruleTypeShippingInclTax",NUMBER_OF_SKUS:"ruleTypeNumberOfSkus"},A={MORE_THAN:"conditionOperatorMoreThan",LESS_THAN:"conditionOperatorLessThan",MORE_THAN_OR_EQUAL_TO:"conditionOperatorMoreThanOrEqualTo",LESS_THAN_OR_EQUAL_TO:"conditionOperatorLessThanOrEqualTo"},q={ALL_USERS:"appliesToAllUsers",SPECIFIC_ROLES:"appliesToSpecificRoles"},pe={status:"ENABLED",name:"",description:"",roleType:"all_users",appliesTo:[],condition:{quantity:"",amount:{currency:"USD",value:""},attribute:"GRAND_TOTAL",operator:"MORE_THAN"},approvers:[]},ue={formValues:pe,isLoading:!1,submitError:null,availableAppliesTo:[],availableRequiresApprovalFrom:[],errors:{},touched:{},currencyCodesList:[{text:"USD",value:"USD"}]},ce={name:!0,appliesTo:!0,ruleValue:!0,approvers:!0},D={REQUIRED:"PurchaseOrders.approvalRuleForm.errorsMessages.required",APPROVERS:"PurchaseOrders.approvalRuleForm.errorsMessages.approvers",FAILED_TO_LOAD:"Failed to load metadata. Please try again.",FAILED_TO_CREATE:"Failed to create approval rule. Please try again."},de=e=>[{text:e[N.GRAND_TOTAL],value:"GRAND_TOTAL"},{text:e[N.SHIPPING_INCL_TAX],value:"SHIPPING_INCL_TAX"},{text:e[N.NUMBER_OF_SKUS],value:"NUMBER_OF_SKUS"}],Te=e=>[{text:e[A.MORE_THAN],value:"MORE_THAN"},{text:e[A.LESS_THAN],value:"LESS_THAN"},{text:e[A.MORE_THAN_OR_EQUAL_TO],value:"MORE_THAN_OR_EQUAL_TO"},{text:e[A.LESS_THAN_OR_EQUAL_TO],value:"LESS_THAN_OR_EQUAL_TO"}],me=e=>[{text:e[q.ALL_USERS],value:"all_users"},{text:e[q.SPECIFIC_ROLES],value:"specific_roles"}],_e="ENABLED",Ee="GRAND_TOTAL",Oe="MORE_THAN",ve="USD",be=0,Re=0,he=e=>Object.keys(N).includes(e),fe=e=>Object.keys(A).includes(e),Ae=e=>{var a,l,r,t,c,n,i,o,v,b;return{status:e.status||_e,name:e.name||"",description:e.description||"",roleType:((a=e.appliesToRoles)==null?void 0:a.length)>0?"specific_roles":"all_users",appliesTo:((l=e.appliesToRoles)==null?void 0:l.map(E=>E.id))||[],condition:{quantity:((r=e.condition)==null?void 0:r.quantity)??be,amount:{currency:((c=(t=e.condition)==null?void 0:t.amount)==null?void 0:c.currency)||ve,value:((i=(n=e.condition)==null?void 0:n.amount)==null?void 0:i.value)??Re},attribute:he((o=e.condition)==null?void 0:o.attribute)?e.condition.attribute:Ee,operator:fe((v=e.condition)==null?void 0:v.operator)?e.condition.operator:Oe},approvers:((b=e.approverRoles)==null?void 0:b.map(E=>E.id))||[]}},V=e=>e!=null&&e!==""&&e!==0;function ye(e){const{roleType:a,appliesTo:l,condition:r,...t}=e,c=a==="all_users"?{appliesTo:[]}:{appliesTo:l};let n={};if(r){const{amount:o,quantity:v,...b}=r,E={...b};V(o==null?void 0:o.value)&&(E.amount=o),V(v)&&(E.quantity=v),n=E}return ae({...t,...c,condition:n})}function Se(e,a){switch(a.type){case"SET_LOADING":return{...e,isLoading:a.payload};case"SET_SUBMIT_ERROR":return{...e,submitError:a.payload};case"SET_FORM_VALUES":return{...e,formValues:a.payload};case"SET_AVAILABLE_APPLIES_TO":return{...e,availableAppliesTo:a.payload};case"SET_AVAILABLE_APPROVERS":return{...e,availableRequiresApprovalFrom:a.payload};case"SET_ERRORS":return{...e,errors:a.payload};case"SET_TOUCHED":return{...e,touched:a.payload};case"SET_CURRENCIES":return{...e,currencyCodesList:a.payload};case"UPDATE_FIELD":{const{key:l,value:r}=a.payload,t=ne(e.formValues,l,r),c={...e.touched,[l]:!0};l==="roleType"&&r==="specific_roles"&&(c.appliesTo=!0);const n=L(t),i=C(n,e.errors,c);return{...e,formValues:t,touched:c,errors:i}}case"TOUCH_FIELD":{const l=a.payload,r={...e.touched,[l]:!0},t=L(e.formValues),c=C(t,e.errors,r);return{...e,touched:r,errors:c}}case"MARK_FIELDS_TOUCHED":{const l={...e.touched,...a.payload},r=L(e.formValues),t=C(r,e.errors,l);return{...e,touched:l,errors:t}}default:return e}}const Le=({t:e,approvalRuleID:a,routeApprovalRulesList:l,onSubmit:r,onChange:t,permissions:c,loadingPermissions:n})=>{const[i,o]=$(Se,ue),v=y(()=>de(e),[e]),b=y(()=>Te(e),[e]),E=y(()=>me(e),[e]);z(()=>{o({type:"SET_LOADING",payload:!0}),W().then(s=>{o({type:"SET_CURRENCIES",payload:s.availableCurrencyCodes})}).catch(s=>{console.error("Failed to fetch currencies:",s)}),Z().then(s=>{const{availableAppliesTo:R,availableRequiresApprovalFrom:m}=s;return o({type:"SET_AVAILABLE_APPLIES_TO",payload:R}),o({type:"SET_AVAILABLE_APPROVERS",payload:m}),a?oe(a):null}).then(s=>{s&&o({type:"SET_FORM_VALUES",payload:Ae(s)}),o({type:"SET_SUBMIT_ERROR",payload:null})}).catch(s=>{console.error("Failed to fetch data:",s),o({type:"SET_SUBMIT_ERROR",payload:(s==null?void 0:s.message)||D.FAILED_TO_LOAD})}).finally(()=>{o({type:"SET_LOADING",payload:!1})})},[a]);const h=g((s,R)=>{o({type:"UPDATE_FIELD",payload:{key:s,value:R}}),t&&t({...i.formValues,[s]:R})},[t,i.formValues]),_=g(s=>{o({type:"TOUCH_FIELD",payload:s}),t&&t(i.formValues)},[t,i.formValues]),f=g(async()=>{o({type:"SET_LOADING",payload:!0}),o({type:"SET_SUBMIT_ERROR",payload:null}),o({type:"MARK_FIELDS_TOUCHED",payload:ce});const s=L(i.formValues);if(Object.keys(s).length>0){o({type:"SET_ERRORS",payload:s}),o({type:"SET_LOADING",payload:!1});return}const R=ye(i.formValues);try{let m;if(a?m=await ee({uid:a,...R}):m=await re(R),!m.uid){o({type:"SET_SUBMIT_ERROR",payload:D.FAILED_TO_CREATE}),o({type:"SET_LOADING",payload:!1});return}r&&r(i.formValues),l?window.location.href=l():o({type:"SET_LOADING",payload:!1})}catch(m){console.error("Failed to save approval rule:",m),o({type:"SET_SUBMIT_ERROR",payload:(m==null?void 0:m.message)||D.FAILED_TO_CREATE}),o({type:"SET_LOADING",payload:!1})}},[i.formValues,l,a,r]),T=y(()=>!!(i.isLoading||n||!(c!=null&&c.permissions.viewApprovalRules)&&!(c!=null&&c.permissions.manageApprovalRules)),[i.isLoading,n,c]);return{availableAppliesTo:i.availableAppliesTo,availableRequiresApprovalFrom:i.availableRequiresApprovalFrom,formValues:i.formValues,ruleTypeOptions:v,conditionOperators:b,currencies:i.currencyCodesList,appliesToOptions:E,handleSetFormValues:h,handleSubmit:f,handleFieldTouch:_,errors:i.errors,touched:i.touched,isLoading:i.isLoading,formLoading:T,submitError:i.submitError}},S=({touched:e=!1,error:a,className:l="error-message"})=>!e||!a?null:u("span",{className:l,children:u(le,{id:a})}),Ne=({availableRequiresApprovalFrom:e,conditionOperators:a,availableAppliesTo:l,appliesToOptions:r,ruleTypeOptions:t,currencies:c,formValues:n,errors:i,touched:o,isLoading:v,permissions:b,handleSubmit:E,handleFieldTouch:h,handleSetFormValues:_,routeApprovalRulesList:f,t:T})=>{var R,m;const s=v||!((R=b==null?void 0:b.permissions)!=null&&R.viewApprovalRules);return O("form",{"data-testid":"approval-rule-form",children:[u(Q,{"data-testid":"status-toggle",className:"b2b-purchase-order-approval-rule-form__toggle",disabled:s,name:"status",label:T.formEnabled,checked:n.status==="ENABLED",onChange:p=>{const d=p.target.checked;_("status",d)}}),O("div",{"data-testid":"name-input-container",children:[u(k,{"data-testid":"name-input",className:"b2b-purchase-order-approval-rule-form__name-input",disabled:s,name:"name",floatingLabel:T.inputRuleNameFloatingLabel,placeholder:T.inputRuleNamePlaceholder,value:n.name,error:!!(o.name&&i.name),onChange:p=>{const d=p.target.value;_("name",d)},onBlur:()=>h("name")}),u(S,{touched:o.name,error:i.name})]}),u(K,{"data-testid":"description-textarea",className:"b2b-purchase-order-approval-rule-form__description",disabled:s,name:"description",label:T.textAreaDescriptionLabel,value:n.description,onChange:p=>{const d=p.target.value;_("description",d)}}),O("div",{"data-testid":"applies-to-section",className:"b2b-purchase-order-approval-rule-form__applies-to",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__applies-to-title",children:T.titleAppliesTo}),r.map((p,d)=>u(j,{"data-testid":`applies-to-radio-${d}`,disabled:s,name:"radio-group",value:p.value,label:p.text,checked:n.roleType===p.value,onChange:P=>{const I=P.target.value;_("roleType",I)}},p.value)),n.roleType==="specific_roles"?O("div",{"data-testid":"applies-to-multiselect-container",className:"b2b-purchase-order-approval-rule-form__applies-to-multiselect",children:[u(B,{"data-testid":"applies-to-multiselect",disabled:s,name:"appliesTo",value:[...n.appliesTo],options:l.map(p=>({value:p.id,label:p.name})),error:!!(o.appliesTo&&i.appliesTo),onChange:p=>{_("appliesTo",p),o.appliesTo||h("appliesTo")}}),u(S,{touched:o.appliesTo,error:i.appliesTo})]}):null]}),O("div",{"data-testid":"rule-type-section",className:"b2b-purchase-order-approval-rule-form__rule-type",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__rule-type-title",children:T.titleRuleType}),u(U,{"data-testid":"rule-type-picker",className:"b2b-purchase-order-approval-rule-form__rule-type-picker",disabled:s,name:"ruleType",value:n.condition.attribute,options:t,handleSelect:p=>{const d=p.target.value;_("ruleType",d)}})]}),O("div",{"data-testid":"rule-condition-section",className:"b2b-purchase-order-approval-rule-form__rule-condition",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__rule-condition-title",children:(m=t.find(p=>p.value===n.condition.attribute))==null?void 0:m.text}),O("div",{className:F(["b2b-purchase-order-approval-rule-form__rule-condition-container",["b2b-purchase-order-approval-rule-form__rule-condition-container--error",!!i.ruleValue&&o.ruleValue]]),children:[u(U,{"data-testid":"rule-condition-picker",className:"b2b-purchase-order-approval-rule-form__rule-condition-picker",disabled:s,name:"ruleCondition",value:n.condition.operator,options:a,handleSelect:p=>{const d=p.target.value;_("ruleCondition",d)}}),O("div",{"data-testid":"rule-value-container",children:[u(k,{"data-testid":"rule-value-input",className:"b2b-purchase-order-approval-rule-form__rule-value-input",disabled:s,name:"ruleValue",floatingLabel:n.condition.attribute==="NUMBER_OF_SKUS"?T.inputQuantityFloatingLabel:T.inputAmountFloatingLabel,placeholder:n.condition.attribute==="NUMBER_OF_SKUS"?T.inputQuantityPlaceholder:T.inputAmountPlaceholder,value:n.condition.attribute==="NUMBER_OF_SKUS"?n.condition.quantity:n.condition.amount.value,error:!!(o.ruleValue&&i.ruleValue),onChange:p=>{const d=p.target.value;_("ruleValue",d)},onBlur:()=>h("ruleValue")}),u(S,{touched:o.ruleValue,error:i.ruleValue})]}),n.condition.attribute!=="NUMBER_OF_SKUS"?u(U,{"data-testid":"rule-condition-currency-picker",className:"b2b-purchase-order-approval-rule-form__rule-condition-currency-picker",disabled:s,name:"ruleConditionCurrency",value:n.condition.amount.currency,options:c,handleSelect:p=>{const d=p.target.value;_("ruleConditionCurrency",d)}}):null]})]}),O("div",{"data-testid":"approval-role-section",className:"b2b-purchase-order-approval-rule-form__approval-role",children:[u("span",{className:"b2b-purchase-order-approval-rule-form__approval-role-title",children:T.titleRequiresApprovalRole}),O("div",{className:"b2b-purchase-order-approval-rule-form__approval-role-multiselect",children:[u(B,{"data-testid":"approvers-multiselect",disabled:s,name:"approvers",value:[...n.approvers],options:e.map(p=>({value:p.id,label:p.name})),error:!!(o.approvers&&i.approvers),onChange:p=>{_("approvers",p),o.approvers||h("approvers")}}),u(S,{touched:o.approvers,error:i.approvers})]})]}),O("div",{"data-testid":"form-buttons",className:"b2b-purchase-order-approval-rule-form__buttons",children:[u(x,{"data-testid":"save-button",type:"button",disabled:s,onClick:E,children:T.buttonSave}),u(x,{"data-testid":"cancel-button",disabled:v,variant:"secondary",type:"button",onClick:()=>{window.location.href=(f==null?void 0:f())??""},children:T.buttonCancel})]})]})},Fe=({className:e,approvalRuleID:a,withHeader:l,withWrapper:r,routeApprovalRulesList:t,onSubmit:c,onChange:n})=>{const i=te({headerText:"PurchaseOrders.approvalRuleForm.headerText",titleAppliesTo:"PurchaseOrders.approvalRuleForm.titleAppliesTo",titleRuleType:"PurchaseOrders.approvalRuleForm.titleRuleType",titleRequiresApprovalRole:"PurchaseOrders.approvalRuleForm.titleRequiresApprovalRole",formEnabled:"PurchaseOrders.approvalRuleForm.fields.enabled",formDisabled:"PurchaseOrders.approvalRuleForm.fields.disabled",inputRuleNameFloatingLabel:"PurchaseOrders.approvalRuleForm.fields.inputRuleName.floatingLabel",inputRuleNamePlaceholder:"PurchaseOrders.approvalRuleForm.fields.inputRuleName.placeholder",textAreaDescriptionLabel:"PurchaseOrders.approvalRuleForm.fields.textAreaDescription.label",appliesToAllUsers:"PurchaseOrders.approvalRuleForm.fields.appliesTo.allUsers",appliesToSpecificRoles:"PurchaseOrders.approvalRuleForm.fields.appliesTo.specificRoles",ruleTypeGrandTotal:"PurchaseOrders.approvalRuleForm.fields.ruleTypeOptions.grandTotal",ruleTypeShippingInclTax:"PurchaseOrders.approvalRuleForm.fields.ruleTypeOptions.shippingInclTax",ruleTypeNumberOfSkus:"PurchaseOrders.approvalRuleForm.fields.ruleTypeOptions.numberOfSkus",conditionOperatorMoreThan:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.moreThan",conditionOperatorLessThan:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.lessThan",conditionOperatorMoreThanOrEqualTo:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.moreThanOrEqualTo",conditionOperatorLessThanOrEqualTo:"PurchaseOrders.approvalRuleForm.fields.conditionOperators.lessThanOrEqualTo",inputQuantityFloatingLabel:"PurchaseOrders.approvalRuleForm.fields.inputQuantity.floatingLabel",inputQuantityPlaceholder:"PurchaseOrders.approvalRuleForm.fields.inputQuantity.placeholder",inputAmountFloatingLabel:"PurchaseOrders.approvalRuleForm.fields.inputAmount.floatingLabel",inputAmountPlaceholder:"PurchaseOrders.approvalRuleForm.fields.inputAmount.placeholder",buttonCancel:"PurchaseOrders.approvalRuleForm.fields.buttons.cancel",buttonSave:"PurchaseOrders.approvalRuleForm.fields.buttons.save"}),{permissions:o,loadingPermissions:v}=J(),{availableRequiresApprovalFrom:b,conditionOperators:E,availableAppliesTo:h,appliesToOptions:_,ruleTypeOptions:f,currencies:T,formValues:s,errors:R,touched:m,isLoading:p,submitError:d,formLoading:P,handleSubmit:I,handleFieldTouch:H,handleSetFormValues:G}=Le({t:i,approvalRuleID:a,loadingPermissions:v,permissions:o,routeApprovalRulesList:t,onSubmit:c,onChange:n});if(P)return u(se,{testId:"b2b-purchase-order-approval-rule-form",className:F(["b2b-purchase-order-approval-rule-form",e])});const M=O(w,{children:[!!d&&u(X,{heading:"",description:d}),u(Ne,{availableRequiresApprovalFrom:b,conditionOperators:E,availableAppliesTo:h,appliesToOptions:_,ruleTypeOptions:f,currencies:T,formValues:s,errors:R,touched:m,isLoading:p,handleSubmit:I,handleFieldTouch:H,handleSetFormValues:G,permissions:o,routeApprovalRulesList:t,t:i})]});return O("div",{"data-testid":"b2b-purchase-order-approval-rule-form",className:F(["b2b-purchase-order-approval-rule-form",e]),children:[l?u(ie,{headerText:i.headerText}):null,r?u(Y,{variant:"secondary",children:M}):M]})},Ye=({withHeader:e=!0,withWrapper:a=!0,className:l,approvalRuleID:r,routeApprovalRulesList:t,onSubmit:c,onChange:n})=>u("div",{"data-testid":"b2b-purchase-order-approval-rule-form-container",className:F(["b2b-purchase-order-approval-rule-form-container",l]),children:u(Fe,{withWrapper:a,withHeader:e,approvalRuleID:r,routeApprovalRulesList:t,onSubmit:c,onChange:n})});export{Ye as ApprovalRuleForm,Ye as default};
|
|
4
4
|
//# sourceMappingURL=ApprovalRuleForm.js.map
|