@dropins/storefront-requisition-list 1.1.0 → 1.2.1-alpha1

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.
@@ -1,32 +1,6 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{events as c}from"@dropins/tools/event-bus.js";import{FetchGraphQL as p}from"@dropins/tools/fetch-graphql.js";const d=e=>{const i=e.map(o=>o.message).join(" ");throw Error(i)},{setEndpoint:E,setFetchGraphQlHeader:v,removeFetchGraphQlHeader:y,setFetchGraphQlHeaders:h,fetchGraphQl:l,getConfig:N}=new p().getMethods(),f=`
4
- query REFINE_PRODUCT(
5
- $optionIds: [String!]!,
6
- $sku: String!
7
- ) {
8
- refineProduct(
9
- optionIds: $optionIds
10
- sku: $sku
11
- ) {
12
- sku
13
- name
14
- images {
15
- url
16
- }
17
- ... on SimpleProductView {
18
- price {
19
- final {
20
- amount {
21
- value
22
- currency
23
- }
24
- }
25
- }
26
- }
27
- }
28
- }
29
- `,I=e=>e.configurable_options.map(i=>btoa(`configurable/${atob(i.configurable_product_option_uid)}/${atob(i.configurable_product_option_value_uid)}`)),g=async e=>Promise.all(e.map(async i=>{if(!i.product||!i.configurable_options||i.configurable_options.length===0)return i;const o=I(i),{errors:s,data:n}=await l(f,{variables:{optionIds:o,sku:i.product.sku}});return s?(console.error("Failed to refine product:",s),i):n!=null&&n.refineProduct?{...i,configured_product:n.refineProduct}:i})),m=`
3
+ import{events as p}from"@dropins/tools/event-bus.js";import{FetchGraphQL as d}from"@dropins/tools/fetch-graphql.js";const I=t=>{const e=t.map(o=>o.message).join(" ");throw Error(e)},{setEndpoint:S,setFetchGraphQlHeader:E,removeFetchGraphQlHeader:v,setFetchGraphQlHeaders:N,fetchGraphQl:m,getConfig:h}=new d().getMethods(),g=`
30
4
  fragment REQUISITION_LIST_FRAGMENT on RequisitionList {
31
5
  uid
32
6
  name
@@ -34,7 +8,7 @@ fragment REQUISITION_LIST_FRAGMENT on RequisitionList {
34
8
  items_count
35
9
  updated_at
36
10
  }
37
- `;function b(e){var i,o;return e?{uid:e.uid,name:e.name,description:e.description,updated_at:e.updated_at,items_count:e.items_count,items:T((i=e.items)==null?void 0:i.items),page_info:(o=e.items)==null?void 0:o.page_info}:null}function T(e){return e!=null&&e.length?e.map(i=>{var s,n,a,r;const o={uid:i.uid,sku:(s=i.product)==null?void 0:s.sku,quantity:i.quantity,stock_status:((n=i.product)==null?void 0:n.stock_status)||"IN_STOCK",only_x_left_in_stock:((a=i.product)==null?void 0:a.only_x_left_in_stock)??null,customizable_options:i.customizable_options?i.customizable_options.map(t=>({uid:t.customizable_option_uid,is_required:t.is_required,label:t.label,sort_order:t.sort_order,type:t.type,values:t.values.map(u=>({uid:u.customizable_option_value_uid,label:u.label,price:u.price,value:u.value}))})):[],bundle_options:i.bundle_options||[],configurable_options:i.configurable_options?i.configurable_options.map(t=>({option_uid:t.configurable_product_option_uid,option_label:t.option_label,value_uid:t.configurable_product_option_value_uid,value_label:t.value_label})):[],samples:i.samples?i.samples.map(t=>({url:t.sample_url,sort_order:t.sort_order,title:t.title})):[],gift_card_options:i.gift_card_options||{}};return(r=i.configured_product)!=null&&r.name?{...o,configured_product:i.configured_product}:o}):[]}const R=`
11
+ `;function f(t){var e,o;return t?{uid:t.uid,name:t.name,description:t.description,updated_at:t.updated_at,items_count:t.items_count,items:b((e=t.items)==null?void 0:e.items),page_info:(o=t.items)==null?void 0:o.page_info}:null}function b(t){return t!=null&&t.length?t.map(e=>{var a,_,n,u;const o={uid:e.uid,sku:(a=e.product)==null?void 0:a.sku,quantity:e.quantity,stock_status:((_=e.product)==null?void 0:_.stock_status)||"IN_STOCK",only_x_left_in_stock:((n=e.product)==null?void 0:n.only_x_left_in_stock)??null,customizable_options:e.customizable_options?e.customizable_options.map(i=>({uid:i.customizable_option_uid,is_required:i.is_required,label:i.label,sort_order:i.sort_order,type:i.type,values:i.values.map(r=>({uid:r.customizable_option_value_uid,label:r.label,price:r.price,value:r.value}))})):[],bundle_options:e.bundle_options||[],configurable_options:e.configurable_options?e.configurable_options.map(i=>({option_uid:i.configurable_product_option_uid,option_label:i.option_label,value_uid:i.configurable_product_option_value_uid,value_label:i.value_label})):[],samples:e.samples?e.samples.map(i=>({url:i.sample_url,sort_order:i.sort_order,title:i.title})):[],gift_card_options:e.gift_card_options||{}};return(u=e.configured_product)!=null&&u.name?{...o,configured_product:e.configured_product}:o}):[]}const T=`
38
12
  fragment REQUISITION_LIST_ITEMS_FRAGMENT on RequistionListItems {
39
13
  items {
40
14
  uid
@@ -127,7 +101,7 @@ fragment REQUISITION_LIST_ITEMS_FRAGMENT on RequistionListItems {
127
101
  total_pages
128
102
  }
129
103
  }
130
- `,q=`
104
+ `,R=`
131
105
  mutation UPDATE_REQUISITION_LIST_MUTATION(
132
106
  $requisitionListUid: ID!,
133
107
  $name: String!,
@@ -150,7 +124,7 @@ fragment REQUISITION_LIST_ITEMS_FRAGMENT on RequistionListItems {
150
124
  }
151
125
  }
152
126
  }
153
- ${m}
154
- ${R}
155
- `,U=async(e,i,o,s,n)=>l(q,{variables:{requisitionListUid:e,name:i,description:o,pageSize:s,currentPage:n}}).then(async({errors:a,data:r})=>{var u,_;if(a)return d(a);if(!((u=r==null?void 0:r.updateRequisitionList)!=null&&u.requisition_list))return null;(_=r.updateRequisitionList.requisition_list.items)!=null&&_.items&&(r.updateRequisitionList.requisition_list.items.items=await g(r.updateRequisitionList.requisition_list.items.items));const t=b(r.updateRequisitionList.requisition_list);return c.emit("requisitionList/data",t),t});export{m as R,v as a,h as b,R as c,g as e,l as f,N as g,d as h,y as r,E as s,b as t,U as u};
127
+ ${g}
128
+ ${T}
129
+ `,y=async(t,e,o,a,_,n)=>{var l,c;const{errors:u,data:i}=await m(R,{variables:{requisitionListUid:t,name:e,description:o,pageSize:a,currentPage:_}});if(u)return I(u);if(!((l=i==null?void 0:i.updateRequisitionList)!=null&&l.requisition_list))return null;const r=i.updateRequisitionList.requisition_list;let s=f(r);return(c=s==null?void 0:s.items)!=null&&c.length&&n&&(s={...s,items:await n(s.items)}),p.emit("requisitionList/data",s),s};export{g as R,E as a,N as b,T as c,m as f,h as g,I as h,v as r,S as s,f as t,y as u};
156
130
  //# sourceMappingURL=updateRequisitionList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateRequisitionList.js","sources":["/@dropins/storefront-requisition-list/src/lib/fetch-error.ts","/@dropins/storefront-requisition-list/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-requisition-list/src/api/refineProduct/graphql/refineProduct.ts","/@dropins/storefront-requisition-list/src/api/refineProduct/enrichConfigurableProducts.ts","/@dropins/storefront-requisition-list/src/api/fragments/RequisitionListFragment.graphql.ts","/@dropins/storefront-requisition-list/src/data/transforms/transform-requisition-list.ts","/@dropins/storefront-requisition-list/src/api/fragments/RequisitionListItemsFragment.graphql.ts","/@dropins/storefront-requisition-list/src/api/updateRequisitionList/graphql/updateRequisitionList.ts","/@dropins/storefront-requisition-list/src/api/updateRequisitionList/updateRequisitionList.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/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\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 { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 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\nexport const REFINE_PRODUCT = `\n query REFINE_PRODUCT(\n $optionIds: [String!]!,\n $sku: String!\n ) {\n refineProduct(\n optionIds: $optionIds\n sku: $sku\n ) {\n sku\n name\n images {\n url\n }\n ... on SimpleProductView {\n price {\n final {\n amount {\n value\n currency\n }\n }\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 { fetchGraphQl } from '@/requisitionList/api';\nimport { Item, ConfigurableOption } from '@/requisitionList/data/models/item';\nimport { REFINE_PRODUCT } from '@/requisitionList/api/refineProduct/graphql/refineProduct';\n\n/**\n * Encodes option UID string into base64 string for refineProduct query\n * Example: 'configurable/93/13' -> 'Y29uZmlndXJhYmxlLzkzLzEz'\n */\nconst encodeOptionUids = (item: Item): string[] => {\n return item.configurable_options.map((option: ConfigurableOption) => {\n return btoa(\n `configurable/${atob(option.configurable_product_option_uid)}/${atob(\n option.configurable_product_option_value_uid\n )}`\n );\n });\n};\n\n/**\n * Enriches configurable products with variant data by calling the refineProduct query\n *\n * @param items - Array of requisition list items\n * @returns Promise resolving to array of items with configured_product populated for configurable items\n */\nexport const enrichConfigurableProducts = async (\n items: Item[]\n): Promise<Item[]> => {\n return Promise.all(\n items.map(async (item: Item) => {\n // Skip non-configurable items or items with no options selected\n if (\n !item.product ||\n !item.configurable_options ||\n item.configurable_options.length === 0\n ) {\n return item;\n }\n\n const optionIds = encodeOptionUids(item);\n\n const { errors, data: refineData } = await fetchGraphQl(REFINE_PRODUCT, {\n variables: {\n optionIds,\n sku: item.product.sku,\n },\n });\n\n if (errors) {\n console.error('Failed to refine product:', errors);\n return item;\n }\n\n if (!refineData?.refineProduct) {\n return item;\n }\n\n return {\n ...item,\n configured_product: refineData.refineProduct,\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\nexport const REQUISITION_LIST_FRAGMENT = `\nfragment REQUISITION_LIST_FRAGMENT on RequisitionList {\n uid\n name\n description\n items_count\n updated_at\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 *******************************************************************/\nimport { RequisitionList } from '../models/requisitionList';\nimport {\n Item,\n ConfiguredProduct,\n Link,\n Sample,\n BundleOption,\n ConfigurableOption,\n RawCustomizableOption,\n GiftCardOption,\n} from '@/requisitionList/data/models/item';\n\n// Interface for raw API response data for a requisition list\nexport interface RawRequisitionListData {\n name: string;\n description: string;\n uid: string;\n updated_at: string;\n items_count: number;\n items: {\n items: RawItemData[];\n page_info: {\n total_pages: number;\n current_page: number;\n page_size: number;\n };\n };\n}\n\nexport function transformRequisitionList(\n data: RawRequisitionListData\n): RequisitionList | null {\n if (!data) {\n return null;\n }\n\n return {\n uid: data.uid,\n name: data.name,\n description: data.description,\n updated_at: data.updated_at,\n items_count: data.items_count,\n items: transformItems(data.items?.items),\n page_info: data.items?.page_info,\n };\n}\n\n// Interface for raw item data\ninterface RawItemData {\n uid: string;\n product: {\n sku: string;\n stock_status?: string;\n only_x_left_in_stock?: number | null;\n };\n quantity: number;\n customizable_options?: RawCustomizableOption[];\n bundle_options?: BundleOption[];\n configurable_options?: ConfigurableOption[];\n configured_product?: ConfiguredProduct;\n links?: Link[];\n samples?: Sample[];\n gift_card_options?: GiftCardOption;\n}\n\nfunction transformItems(items: RawItemData[]): Item[] {\n if (!items?.length) return [];\n\n return items.map((item: RawItemData) => {\n const transformedItem = {\n uid: item.uid,\n sku: item.product?.sku,\n quantity: item.quantity,\n stock_status: (item.product?.stock_status || 'IN_STOCK') as\n | 'IN_STOCK'\n | 'OUT_OF_STOCK',\n only_x_left_in_stock: item.product?.only_x_left_in_stock ?? null,\n customizable_options: item.customizable_options\n ? item.customizable_options.map((option) => ({\n uid: option.customizable_option_uid,\n is_required: option.is_required,\n label: option.label,\n sort_order: option.sort_order,\n type: option.type,\n values: option.values.map(\n (value: RawCustomizableOption['values'][number]) => ({\n uid: value.customizable_option_value_uid,\n label: value.label,\n price: value.price,\n value: value.value,\n })\n ),\n }))\n : [],\n bundle_options: item.bundle_options || [],\n configurable_options: item.configurable_options\n ? item.configurable_options.map((option) => ({\n option_uid: option.configurable_product_option_uid,\n option_label: option.option_label,\n value_uid: option.configurable_product_option_value_uid,\n value_label: option.value_label,\n }))\n : [],\n samples: item.samples\n ? item.samples.map((sample) => ({\n url: sample.sample_url,\n sort_order: sample.sort_order,\n title: sample.title,\n }))\n : [],\n gift_card_options: item.gift_card_options || {},\n };\n\n if (item.configured_product?.name) {\n return {\n ...transformedItem,\n configured_product: item.configured_product,\n };\n }\n return transformedItem;\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\nexport const REQUISITION_LIST_ITEMS_FRAGMENT = `\nfragment REQUISITION_LIST_ITEMS_FRAGMENT on RequistionListItems {\n items {\n uid\n quantity\n product {\n sku\n stock_status\n only_x_left_in_stock\n }\n customizable_options {\n customizable_option_uid\n is_required\n label\n sort_order\n type\n values {\n customizable_option_value_uid\n label\n value\n price {\n type\n units\n value\n }\n }\n }\n ... on ConfigurableRequisitionListItem {\n configurable_options {\n configurable_product_option_uid\n configurable_product_option_value_uid\n option_label\n value_label\n }\n }\n ... on DownloadableRequisitionListItem {\n links {\n price\n sample_url\n sort_order\n title\n uid\n }\n samples {\n sample_url\n sort_order\n title\n }\n }\n ... on BundleRequisitionListItem {\n bundle_options {\n uid\n type\n label\n values {\n uid\n label\n quantity\n priceV2 {\n value\n currency\n }\n original_price {\n value\n currency\n }\n }\n }\n }\n ... on GiftCardRequisitionListItem {\n gift_card_options {\n amount {\n currency\n value\n }\n custom_giftcard_amount {\n currency\n value\n }\n message\n recipient_email\n recipient_name\n sender_name\n sender_email\n }\n }\n }\n page_info {\n page_size\n current_page\n total_pages\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 *******************************************************************/\nimport { REQUISITION_LIST_FRAGMENT } from '@/requisitionList/api/fragments/RequisitionListFragment.graphql';\nimport { REQUISITION_LIST_ITEMS_FRAGMENT } from '@/requisitionList/api/fragments/RequisitionListItemsFragment.graphql';\n\nexport const UPDATE_REQUISITION_LIST_MUTATION = `\n mutation UPDATE_REQUISITION_LIST_MUTATION(\n $requisitionListUid: ID!,\n $name: String!,\n $description: String,\n $pageSize: Int,\n $currentPage: Int\n ) {\n updateRequisitionList(\n requisitionListUid: $requisitionListUid\n input: {\n name: $name\n description: $description\n }\n ) {\n requisition_list {\n ...REQUISITION_LIST_FRAGMENT\n items(pageSize: $pageSize, currentPage: $currentPage) {\n ...REQUISITION_LIST_ITEMS_FRAGMENT\n }\n }\n }\n }\n${REQUISITION_LIST_FRAGMENT}\n${REQUISITION_LIST_ITEMS_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 { transformRequisitionList } from '@/requisitionList/data/transforms';\nimport { fetchGraphQl } from '@/requisitionList/api';\nimport { enrichConfigurableProducts } from '@/requisitionList/api/refineProduct';\nimport { handleFetchError } from '@/requisitionList/lib/fetch-error';\nimport { RequisitionList } from '@/requisitionList/data/models/requisitionList';\nimport { UPDATE_REQUISITION_LIST_MUTATION } from '@/requisitionList/api/updateRequisitionList/graphql/updateRequisitionList';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const updateRequisitionList = async (\n requisitionListUid: string,\n name: string,\n description?: string,\n pageSize?: number,\n currentPage?: number\n): Promise<RequisitionList | null> => {\n return fetchGraphQl(UPDATE_REQUISITION_LIST_MUTATION, {\n variables: {\n requisitionListUid,\n name,\n description,\n pageSize,\n currentPage,\n },\n }).then(async ({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.updateRequisitionList?.requisition_list) {\n return null;\n }\n\n // Enrich configurable products with variant data if items are present\n if (data.updateRequisitionList.requisition_list.items?.items) {\n data.updateRequisitionList.requisition_list.items.items =\n await enrichConfigurableProducts(\n data.updateRequisitionList.requisition_list.items.items\n );\n }\n\n const payload = transformRequisitionList(\n data.updateRequisitionList.requisition_list\n );\n\n events.emit('requisitionList/data', payload);\n\n return payload;\n });\n};\n"],"names":["handleFetchError","errors","errorMessage","e","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","REFINE_PRODUCT","encodeOptionUids","item","option","enrichConfigurableProducts","items","optionIds","refineData","REQUISITION_LIST_FRAGMENT","transformRequisitionList","data","transformItems","_a","_b","transformedItem","_c","value","sample","_d","REQUISITION_LIST_ITEMS_FRAGMENT","UPDATE_REQUISITION_LIST_MUTATION","updateRequisitionList","requisitionListUid","name","description","pageSize","currentPage","payload","events"],"mappings":"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"}
1
+ {"version":3,"file":"updateRequisitionList.js","sources":["/@dropins/storefront-requisition-list/src/lib/fetch-error.ts","/@dropins/storefront-requisition-list/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-requisition-list/src/api/fragments/RequisitionListFragment.graphql.ts","/@dropins/storefront-requisition-list/src/data/transforms/transform-requisition-list.ts","/@dropins/storefront-requisition-list/src/api/fragments/RequisitionListItemsFragment.graphql.ts","/@dropins/storefront-requisition-list/src/api/updateRequisitionList/graphql/updateRequisitionList.ts","/@dropins/storefront-requisition-list/src/api/updateRequisitionList/updateRequisitionList.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/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\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 { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 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\nexport const REQUISITION_LIST_FRAGMENT = `\nfragment REQUISITION_LIST_FRAGMENT on RequisitionList {\n uid\n name\n description\n items_count\n updated_at\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 *******************************************************************/\nimport { RequisitionList } from '../models/requisitionList';\nimport {\n Item,\n ConfiguredProduct,\n Link,\n Sample,\n BundleOption,\n ConfigurableOption,\n RawCustomizableOption,\n GiftCardOption,\n} from '@/requisitionList/data/models/item';\n\n// Interface for raw API response data for a requisition list\nexport interface RawRequisitionListData {\n name: string;\n description: string;\n uid: string;\n updated_at: string;\n items_count: number;\n items: {\n items: RawItemData[];\n page_info: {\n total_pages: number;\n current_page: number;\n page_size: number;\n };\n };\n}\n\nexport function transformRequisitionList(\n data: RawRequisitionListData\n): RequisitionList | null {\n if (!data) {\n return null;\n }\n\n return {\n uid: data.uid,\n name: data.name,\n description: data.description,\n updated_at: data.updated_at,\n items_count: data.items_count,\n items: transformItems(data.items?.items),\n page_info: data.items?.page_info,\n };\n}\n\n// Interface for raw item data\ninterface RawItemData {\n uid: string;\n product: {\n sku: string;\n stock_status?: string;\n only_x_left_in_stock?: number | null;\n };\n quantity: number;\n customizable_options?: RawCustomizableOption[];\n bundle_options?: BundleOption[];\n configurable_options?: ConfigurableOption[];\n configured_product?: ConfiguredProduct;\n links?: Link[];\n samples?: Sample[];\n gift_card_options?: GiftCardOption;\n}\n\nfunction transformItems(items: RawItemData[]): Item[] {\n if (!items?.length) return [];\n\n return items.map((item: RawItemData) => {\n const transformedItem = {\n uid: item.uid,\n sku: item.product?.sku,\n quantity: item.quantity,\n stock_status: (item.product?.stock_status || 'IN_STOCK') as\n | 'IN_STOCK'\n | 'OUT_OF_STOCK',\n only_x_left_in_stock: item.product?.only_x_left_in_stock ?? null,\n customizable_options: item.customizable_options\n ? item.customizable_options.map((option) => ({\n uid: option.customizable_option_uid,\n is_required: option.is_required,\n label: option.label,\n sort_order: option.sort_order,\n type: option.type,\n values: option.values.map(\n (value: RawCustomizableOption['values'][number]) => ({\n uid: value.customizable_option_value_uid,\n label: value.label,\n price: value.price,\n value: value.value,\n })\n ),\n }))\n : [],\n bundle_options: item.bundle_options || [],\n configurable_options: item.configurable_options\n ? item.configurable_options.map((option) => ({\n option_uid: option.configurable_product_option_uid,\n option_label: option.option_label,\n value_uid: option.configurable_product_option_value_uid,\n value_label: option.value_label,\n }))\n : [],\n samples: item.samples\n ? item.samples.map((sample) => ({\n url: sample.sample_url,\n sort_order: sample.sort_order,\n title: sample.title,\n }))\n : [],\n gift_card_options: item.gift_card_options || {},\n };\n\n if (item.configured_product?.name) {\n return {\n ...transformedItem,\n configured_product: item.configured_product,\n };\n }\n return transformedItem;\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\nexport const REQUISITION_LIST_ITEMS_FRAGMENT = `\nfragment REQUISITION_LIST_ITEMS_FRAGMENT on RequistionListItems {\n items {\n uid\n quantity\n product {\n sku\n stock_status\n only_x_left_in_stock\n }\n customizable_options {\n customizable_option_uid\n is_required\n label\n sort_order\n type\n values {\n customizable_option_value_uid\n label\n value\n price {\n type\n units\n value\n }\n }\n }\n ... on ConfigurableRequisitionListItem {\n configurable_options {\n configurable_product_option_uid\n configurable_product_option_value_uid\n option_label\n value_label\n }\n }\n ... on DownloadableRequisitionListItem {\n links {\n price\n sample_url\n sort_order\n title\n uid\n }\n samples {\n sample_url\n sort_order\n title\n }\n }\n ... on BundleRequisitionListItem {\n bundle_options {\n uid\n type\n label\n values {\n uid\n label\n quantity\n priceV2 {\n value\n currency\n }\n original_price {\n value\n currency\n }\n }\n }\n }\n ... on GiftCardRequisitionListItem {\n gift_card_options {\n amount {\n currency\n value\n }\n custom_giftcard_amount {\n currency\n value\n }\n message\n recipient_email\n recipient_name\n sender_name\n sender_email\n }\n }\n }\n page_info {\n page_size\n current_page\n total_pages\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 *******************************************************************/\nimport { REQUISITION_LIST_FRAGMENT } from '@/requisitionList/api/fragments/RequisitionListFragment.graphql';\nimport { REQUISITION_LIST_ITEMS_FRAGMENT } from '@/requisitionList/api/fragments/RequisitionListItemsFragment.graphql';\n\nexport const UPDATE_REQUISITION_LIST_MUTATION = `\n mutation UPDATE_REQUISITION_LIST_MUTATION(\n $requisitionListUid: ID!,\n $name: String!,\n $description: String,\n $pageSize: Int,\n $currentPage: Int\n ) {\n updateRequisitionList(\n requisitionListUid: $requisitionListUid\n input: {\n name: $name\n description: $description\n }\n ) {\n requisition_list {\n ...REQUISITION_LIST_FRAGMENT\n items(pageSize: $pageSize, currentPage: $currentPage) {\n ...REQUISITION_LIST_ITEMS_FRAGMENT\n }\n }\n }\n }\n${REQUISITION_LIST_FRAGMENT}\n${REQUISITION_LIST_ITEMS_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 { transformRequisitionList } from '@/requisitionList/data/transforms';\nimport { fetchGraphQl } from '@/requisitionList/api';\nimport { handleFetchError } from '@/requisitionList/lib/fetch-error';\nimport { RequisitionList } from '@/requisitionList/data/models/requisitionList';\nimport { Item } from '@/requisitionList/data/models/item';\nimport { UPDATE_REQUISITION_LIST_MUTATION } from '@/requisitionList/api/updateRequisitionList/graphql/updateRequisitionList';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const updateRequisitionList = async (\n requisitionListUid: string,\n name: string,\n description?: string,\n pageSize?: number,\n currentPage?: number,\n enrichConfigurableProducts?: (items: Item[]) => Promise<Item[]>\n): Promise<RequisitionList | null> => {\n const { errors, data } = await fetchGraphQl(UPDATE_REQUISITION_LIST_MUTATION, {\n variables: {\n requisitionListUid,\n name,\n description,\n pageSize,\n currentPage,\n },\n });\n\n if (errors) return handleFetchError(errors);\n\n if (!data?.updateRequisitionList?.requisition_list) {\n return null;\n }\n\n const rawList = data.updateRequisitionList.requisition_list;\n let payload = transformRequisitionList(rawList);\n if (payload?.items?.length && enrichConfigurableProducts) {\n payload = {\n ...payload,\n items: await enrichConfigurableProducts(payload.items),\n };\n }\n events.emit('requisitionList/data', payload);\n return payload;\n};\n"],"names":["handleFetchError","errors","errorMessage","e","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","REQUISITION_LIST_FRAGMENT","transformRequisitionList","data","transformItems","_a","_b","items","item","transformedItem","_c","option","value","sample","_d","REQUISITION_LIST_ITEMS_FRAGMENT","UPDATE_REQUISITION_LIST_MUTATION","updateRequisitionList","requisitionListUid","name","description","pageSize","currentPage","enrichConfigurableProducts","rawList","payload","events"],"mappings":"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"}
@@ -1,5 +1,6 @@
1
1
  import { Container } from '@dropins/tools/types/elsie/src/lib';
2
2
  import { RequisitionList } from '../../data/models/requisitionList';
3
+ import { Item } from '../../data/models/item';
3
4
 
4
5
  export interface RequisitionListHeaderProps {
5
6
  requisitionList: RequisitionList;
@@ -10,6 +11,7 @@ export interface RequisitionListHeaderProps {
10
11
  type: string;
11
12
  context: string;
12
13
  }) => void;
14
+ enrichConfigurableProducts?: (items: Item[]) => Promise<Item[]>;
13
15
  }
14
16
  export declare const RequisitionListHeader: Container<RequisitionListHeaderProps>;
15
17
  //# sourceMappingURL=RequisitionListHeader.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { HTMLAttributes } from 'preact/compat';
2
2
  import { Container } from '@dropins/tools/types/elsie/src/lib';
3
+ import { Item, Product } from '../../data/models/item';
3
4
 
4
5
  export interface RequisitionListViewProps extends HTMLAttributes<HTMLDivElement> {
5
6
  /**
@@ -29,6 +30,8 @@ export interface RequisitionListViewProps extends HTMLAttributes<HTMLDivElement>
29
30
  * Defaults to '/customer/account'
30
31
  */
31
32
  fallbackRoute?: string;
33
+ getProductData: (skus: string[]) => Promise<Product[] | null>;
34
+ enrichConfigurableProducts: (items: Item[]) => Promise<Item[]>;
32
35
  }
33
36
  export declare const RequisitionListView: Container<RequisitionListViewProps>;
34
37
  //# sourceMappingURL=RequisitionListView.d.ts.map
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as w,jsx as e,Fragment as bt}from"@dropins/tools/preact-jsx-runtime.js";import*as p from"@dropins/tools/preact-compat.js";import{useState as S,useEffect as lt,useCallback as M}from"@dropins/tools/preact-compat.js";import{g as kt,a as yt,d as vt,u as Ct,b as ct,i as Rt}from"../chunks/addRequisitionListItemsToCart.js";import{Button as pt,Icon as tt,Price as Lt,Field as St,Input as It,Image as At,Checkbox as Nt,Table as Pt,ProgressSpinner as Tt,InLineAlert as Et,Pagination as xt}from"@dropins/tools/components.js";import{events as O}from"@dropins/tools/event-bus.js";import{useState as et,useCallback as ut}from"@dropins/tools/preact-hooks.js";import{VComponent as Vt,classes as Mt}from"@dropins/tools/lib.js";import{D as dt}from"../chunks/RequisitionListForm.js";import{a as Dt,u as Ht,E as $t}from"../chunks/RequisitionListView.js";import{h as Ft}from"@dropins/tools/preact.js";import{useText as gt}from"@dropins/tools/i18n.js";import{R as Bt}from"../chunks/RequisitionListHeader.js";import"../chunks/state.js";import{R as zt}from"../chunks/RequisitionListModal.js";import{N as qt,P as Ot,a as Wt}from"../chunks/PaginationItemsCounter.js";import"../chunks/updateRequisitionList.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/deleteRequisitionList.js";const Qt=l=>p.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},p.createElement("g",{clipPath:"url(#clip0_102_196)"},p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),p.createElement("defs",null,p.createElement("clipPath",{id:"clip0_102_196"},p.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),jt=l=>p.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},p.createElement("path",{d:"M17.3332 11.75H6.6665",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",fill:"none",stroke:"currentColor"})),wt=l=>p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",...l},p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1 5H23",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.87402 8.58057L9.39348 17.682",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.6673 8.58057L14.146 17.682",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}));function Zt(){const[l,P]=et(null),[k,g]=et(new Set),D=ut((y,L)=>{g(f=>{const m=new Set(f);return L?m.add(y):m.delete(y),m})},[]),I=ut(()=>{var L;const y=(L=l==null?void 0:l.items)==null?void 0:L.map(f=>f.uid);g(new Set(y))},[l]),A=ut(()=>{g(new Set)},[]);return{currentRequisitionList:l,setCurrentRequisitionList:P,selectedItems:k,setSelectedItems:g,handleItemSelection:D,handleSelectAll:I,handleSelectNone:A}}const Kt=({className:l,items:P,selectedItems:k,currentPage:g,pageSize:D,canEdit:I=!0,handleItemSelection:A,handleUpdateQuantity:y,onAddToCart:L,onDeleteItem:f,...m})=>{const[N,F]=et({}),[it,W]=et({}),h=gt({productNameHeader:"RequisitionList.RequisitionListView.productListTable.headers.productName",skuHeader:"RequisitionList.RequisitionListView.productListTable.headers.sku",priceHeader:"RequisitionList.RequisitionListView.productListTable.headers.price",quantityHeader:"RequisitionList.RequisitionListView.productListTable.headers.quantity",subtotalHeader:"RequisitionList.RequisitionListView.productListTable.headers.subtotal",actionsHeader:"RequisitionList.RequisitionListView.productListTable.headers.actions",actionAddToCart:"RequisitionList.RequisitionListView.actionAddToCart",actionDelete:"RequisitionList.RequisitionListView.actionDelete",actionSelect:"RequisitionList.RequisitionListView.actionSelect",itemQuantity:"RequisitionList.RequisitionListView.productListTable.itemQuantity",outOfStock:"RequisitionList.RequisitionListView.productListTable.outOfStock",onlyXLeftInStock:"RequisitionList.RequisitionListView.productListTable.onlyXLeftInStock"}),T=[{label:"#",key:"index"},{label:"item",key:"item"},{label:h.priceHeader,key:"price"},{label:h.quantityHeader,key:"quantity"},{label:h.subtotalHeader,key:"subtotal"}];I&&(T.unshift({label:h.actionSelect,key:"selector"}),T.push({label:h.actionsHeader,key:"actions"}));const E=(t,s)=>{const r=t.target.checked;A(s.uid,r)},X=t=>(g-1)*D+t+1,nt=t=>{var s,r;return((s=t.configured_product)==null?void 0:s.name)||((r=t.product)==null?void 0:r.name)||t.sku},Q=t=>{var s,r,a,R,c,v;return(r=(s=t.configured_product)==null?void 0:s.images)!=null&&r.length?((a=t.configured_product.images[0])==null?void 0:a.url)||"":(c=(R=t.product)==null?void 0:R.images)!=null&&c.length&&((v=t.product.images[0])==null?void 0:v.url)||""},x=t=>{var s;return((s=t.product)==null?void 0:s.name)||t.sku},j=t=>{var s;return(s=t.configured_product)==null?void 0:s.name},B=t=>t.bundle_options?t.bundle_options.map((r,a)=>w("span",{className:"requisition-list-view-product-list-table__product-configurable-name",children:[r.values[0].label," x ",r.values[0].quantity]},r.values[0].label||a)):void 0,Z=t=>{var s;return((s=t.configured_product)==null?void 0:s.sku)||t.sku},n=t=>{var s,r,a,R,c,v,V,H;return Array.isArray(t.bundle_options)&&t.bundle_options.length>0?t.bundle_options.reduce((rt,Y)=>{var G,U,K;return rt+(((U=(G=Y.values[0])==null?void 0:G.priceV2)==null?void 0:U.value)||0)*(((K=Y.values[0])==null?void 0:K.quantity)||0)},0):((R=(a=(r=(s=t.configured_product)==null?void 0:s.price)==null?void 0:r.final)==null?void 0:a.amount)==null?void 0:R.value)||((H=(V=(v=(c=t.product)==null?void 0:c.price)==null?void 0:v.final)==null?void 0:V.amount)==null?void 0:H.value)||0},d=t=>{var s,r,a,R,c,v,V,H;return((R=(a=(r=(s=t.configured_product)==null?void 0:s.price)==null?void 0:r.final)==null?void 0:a.amount)==null?void 0:R.currency)||((H=(V=(v=(c=t.product)==null?void 0:c.price)==null?void 0:v.final)==null?void 0:V.amount)==null?void 0:H.currency)},z=t=>n(t)*t.quantity,J=(t,s)=>{const r=+t.target.value;r>0&&!Number.isNaN(t.target.value)&&W(a=>({...a,[s.uid]:r}))},st=async(t,s)=>{let r=+t.target.value;if(!(r>0&&r!==s.quantity)){W(a=>({...a,[s.uid]:s.quantity}));return}F(a=>({...a,[s.uid]:!0}));try{await y(s.uid,r)}finally{F(a=>({...a,[s.uid]:!1}))}},ot=P.map((t,s)=>({selector:e("label",{id:`item-selector-${t.sku}-label`,children:e(Nt,{className:"requisition-list-view-product-list-table__checkbox",name:`item-selector-${t.sku}`,"aria-label":`${h.actionSelect} ${x(t)}`,"data-testid":`item-checkbox-${t.sku}`,onChange:r=>E(r,t),value:t.sku,checked:k.has(t.uid)})}),index:e("div",{className:"requisition-list-view-product-list-table__index-container",children:X(s)}),item:w("div",{className:"requisition-list-view-product-list-table__item-container",children:[e(At,{className:"requisition-list-view-product-list-table__thumbnail",alt:nt(t),src:Q(t)}),w("div",{className:"requisition-list-view-product-list-table__item-details",children:[e("div",{className:"requisition-list-view-product-list-table__product-name",children:x(t)}),t.stock_status==="OUT_OF_STOCK"&&e("div",{className:"requisition-list-view-product-list-table__out-of-stock",children:h.outOfStock}),t.stock_status!=="OUT_OF_STOCK"&&t.only_x_left_in_stock!==null&&t.only_x_left_in_stock<t.quantity&&e("div",{className:"requisition-list-view-product-list-table__low-stock",children:h.onlyXLeftInStock.replace("{count}",String(t.only_x_left_in_stock))}),e("span",{className:"requisition-list-view-product-list-table__product-configurable-name",children:j(t)}),e("div",{className:"requisition-list-view-product-list-table__sku",children:Z(t)}),B(t)]})]}),price:e(Lt,{className:"requisition-list-view-product-list-table__price",amount:n(t),currency:d(t)}),quantity:e("span",{className:"requisition-list-view-product-list-table__quantity",children:e(St,{disabled:!!N[t.uid],children:e(It,{id:`requisition-list-item-quantity-${t.sku}`,"data-testid":`requisition-list-item-quantity-${t.sku}`,name:"quantity",type:"text","aria-label":`${h.itemQuantity} - ${x(t)}`,value:it[t.uid]??t.quantity,onChange:r=>J(r,t),onBlur:r=>st(r,t)})})}),subtotal:e(Lt,{className:"requisition-list-view-product-list-table__price",amount:z(t),currency:d(t)}),actions:w("div",{className:"requisition-list-view__bulk-actions",children:[e(pt,{type:"button",onClick:()=>L([t.uid]),icon:e(tt,{source:Qt}),"aria-label":`${h.actionAddToCart} - ${x(t)}`,"data-testid":"product-list-table-add-to-cart-button"}),e(pt,{type:"button",variant:"secondary",icon:e(tt,{source:wt}),onClick:()=>f([t.uid]),"aria-label":`${h.actionDelete} - ${x(t)}`,"data-testid":"product-list-table-delete-button"})]})})),at=e(Pt,{columns:T,rowData:ot,"data-testid":"product-list-table",mobileLayout:"stacked"});return e(Vt,{node:Ft("div",{}),className:Mt(["requisition-list-view-product-list-table-container",l]),"data-testid":"product-list-table-container",...m,children:at})},Xt=({selectedItems:l,deletingItemId:P,addingToCartItemId:k,bulkAddingToCart:g,updatingQuantityItemId:D,onSelectAll:I,onSelectNone:A,onBulkAddToCart:y,onBulkDelete:L})=>{const f=gt({statusDeleting:"RequisitionList.RequisitionListView.statusDeleting",actionSelectAll:"RequisitionList.RequisitionListView.actionSelectAll",actionSelectNone:"RequisitionList.RequisitionListView.actionSelectNone",actionAddToCart:"RequisitionList.RequisitionListView.actionAddToCart",actionDeleteSelectedItems:"RequisitionList.RequisitionListView.actionDeleteSelectedItems",statusBulkAddingToCart:"RequisitionList.RequisitionListView.statusBulkAddingToCart"}),m=P!==null||k!==null||g||D!==null,N=l.size>0;return w("div",{className:"requisition-list-view__batch-actions",children:[w("div",{className:"requisition-list-view__batch-actions-left",children:[e("button",{"data-testid":"bulk-actions-select-toggle-btn",type:"button",className:`requisition-list-view__batch-actions-select-toggle ${N?"requisition-list-view__batch-actions-select-toggle--active":""}`,onClick:N?A:I,disabled:m,"aria-label":N?f.actionSelectNone:f.actionSelectAll,children:e(tt,{source:jt})}),e("button",{type:"button",className:"requisition-list-view__batch-actions-select-label",onClick:N?A:I,disabled:m,children:f.actionSelectAll})]}),N&&w("div",{className:"requisition-list-view__batch-actions-buttons",children:[e("span",{className:"requisition-list-view__batch-actions-count-badge","aria-label":`${l.size} items selected`,children:l.size}),e(pt,{"data-testid":"bulk-actions-add-to-cart-btn",type:"button",variant:"secondary",onClick:y,disabled:m,children:g?f.statusBulkAddingToCart:f.actionAddToCart}),e("button",{"data-testid":"bulk-actions-delete-btn",type:"button",className:"requisition-list-view__batch-actions-delete-icon",onClick:L,disabled:m,"aria-label":f.actionDeleteSelectedItems,children:e(tt,{source:wt})})]})]})},fe=({requisitionListUid:l,skipProductLoading:P=!1,pageSize:k=dt,routeRequisitionListGrid:g,fallbackRoute:D="/customer/account"})=>{var K,ft,mt,ht,_t;const[I,A]=S(!1),[y,L]=S(null),[f,m]=S(null),[N,F]=S(!1),[it,W]=S(null),[h,T]=S(!1),[E,X]=S(k),[nt,Q]=S(!0),[x,j]=S(!1),[B,Z]=S([]),{currentRequisitionList:n,setCurrentRequisitionList:d,selectedItems:z,setSelectedItems:J,handleItemSelection:st,handleSelectAll:ot,handleSelectNone:at}=Zt(),t=gt({emptyRequisitionList:"RequisitionList.RequisitionListView.emptyRequisitionList",errorLoadingProducts:"RequisitionList.RequisitionListView.errorLoadingProducts",errorLoadPage:"RequisitionList.RequisitionListView.errorLoadPage",notFoundTitle:"RequisitionList.RequisitionListView.notFoundTitle",notFoundMessage:"RequisitionList.RequisitionListView.notFoundMessage",notFoundActionLabel:"RequisitionList.RequisitionListView.notFoundActionLabel",notEnabledTitle:"RequisitionList.RequisitionListsNotEnabled.title",notEnabledMessage:"RequisitionList.RequisitionListsNotEnabled.message",partialMoveSuccess:"RequisitionList.RequisitionListAlert.partialMoveSuccess",notEnabledActionLabel:"RequisitionList.RequisitionListsNotEnabled.actionLabel",show:"RequisitionList.PageSizePicker.show",deleteItemsTitle:"RequisitionList.RequisitionListView.deleteItemsTitle",deleteItemsMessage:"RequisitionList.RequisitionListView.deleteItemsMessage",confirmAction:"RequisitionList.RequisitionListView.confirmAction",cancelAction:"RequisitionList.RequisitionListView.cancelAction"}),{alert:s,setAlert:r,handleRequisitionListAlert:a}=Dt(),{isEnabled:R}=Ht();lt(()=>{const i=O.on("requisitionList/data",u=>{(u==null?void 0:u.uid)===l&&(d(u),J(new Set))}),o=O.on("requisitionList/alert",a);return()=>{i==null||i.off(),o==null||o.off()}},[a,l,d,J]),lt(()=>{X(k)},[k]);const c=M(async i=>{var u,C;const o=((u=i.items)==null?void 0:u.map(q=>q.sku))||[];if(o.length===0)return i;A(!0);try{const q=await kt(o);if(q){const _=new Map;return q.forEach(b=>{_.set(b.sku,b)}),{...i,items:(C=i.items)==null?void 0:C.map(b=>{const $=_.get(b.sku);return{...b,product:$||b.product,stock_status:b.stock_status||($==null?void 0:$.stock_status)||"IN_STOCK",only_x_left_in_stock:b.only_x_left_in_stock??($==null?void 0:$.only_x_left_in_stock)??null}})}}return console.warn("No products found"),i}catch(q){return console.warn(q instanceof Error?q.message:t.errorLoadingProducts),i}finally{A(!1)}},[t.errorLoadingProducts]);lt(()=>{if(!l){Q(!1);return}if(n&&n.uid===l)return;Q(!0),(async()=>{try{const o=await ct(l,1,k);if(o)if(P)d(o);else{const u=await c(o);d(u)}}catch(o){console.error("Failed to initialize requisition list from UID:",o)}finally{Q(!1)}})()},[l,k,P,c,d,n]);const v=M(async i=>{i&&i.length===1?(F(!1),m(i)):(F(!0),m(null));try{const o=await yt(n.uid,i),u=(i==null?void 0:i.length)||0,C=(o==null?void 0:o.length)||0,q=u-C;if(o&&o.length>0&&q>0){const _={action:"move",type:"error",context:"product",message:[t.partialMoveSuccess.replace("{successCount}",String(q)).replace("{failedCount}",String(C))]};a(_),O.emit("requisitionList/alert",_)}else if(o&&o.length>0){const _={action:"move",type:"error",context:"product",message:o.map(b=>b.message)};a(_),O.emit("requisitionList/alert",_)}else{const _={action:"move",type:"success",context:"product"};a(_),O.emit("requisitionList/alert",_)}}catch{const u={action:"move",type:"error",context:"product"};a(u),O.emit("requisitionList/alert",u)}finally{m(null),F(!1)}},[n,a,t]),V=M(i=>{i&&i.length>0&&(Z(i),j(!0))},[]),H=M(async()=>{B.length===1?L(B[0]):L("bulk");try{const i=await vt(n.uid,B,E,n.page_info.current_page);if(i){const o=await c(i);d(o),a({action:"delete",type:"success",context:"product"})}else a({action:"delete",type:"error",context:"product"})}catch{a({action:"delete",type:"error",context:"product"})}finally{L(null),j(!1),Z([])}},[B,n,E,c,d,a]),rt=M(async(i,o)=>{var u;W(i);try{const C=(u=n.items)==null?void 0:u.find(b=>b.uid===i);if(!C){a({action:"update",type:"error",context:"product"});return}const q={item_id:C.uid,entered_options:C.entered_options,selected_options:C.selected_options,quantity:o},_=await Ct(n.uid,[q],E,n.page_info.current_page);if(_){const b=await c(_);d(b),a({action:"update",type:"success",context:"product"})}else a({action:"update",type:"error",context:"product"})}catch{a({action:"update",type:"error",context:"product"})}finally{W(null)}},[n,c,d,E,a]),Y=M(async i=>{T(!0);try{const o=await ct(n.uid,i,E);if(o){const u=await c(o);d(u)}else console.warn(t.errorLoadPage)}catch(o){console.warn(o instanceof Error?o.message:t.errorLoadPage)}finally{T(!1)}},[n==null?void 0:n.uid,c,E,t,d]),G=M(async i=>{X(i),T(!0);try{const o=await ct(n.uid,1,i);if(o){const u=await c(o);d(u)}else console.warn(t.errorLoadPage)}catch{console.warn(t.errorLoadPage)}finally{T(!1)}},[n==null?void 0:n.uid,c,t,d]),U=M(async i=>{const o=await c(i);d(o)},[d,c]);return w("div",{className:"requisition-list-view__container",children:[nt?e("div",{className:"requisition-list-view__loading",children:e(Tt,{stroke:"4",size:"large"})}):R===!1?e(qt,{title:t.notEnabledTitle,message:t.notEnabledMessage,actionLabel:t.notEnabledActionLabel,onAction:()=>{window.location.href=D}}):!n||!Rt(n==null?void 0:n.uid)?e(qt,{title:t.notFoundTitle,message:t.notFoundMessage,actionLabel:g?t.notFoundActionLabel:void 0,onAction:g?()=>{const i=g();i&&typeof i=="string"&&(window.location.href=i)}:void 0}):w(bt,{children:[e(Bt,{requisitionList:n,routeRequisitionListGrid:g,onUpdate:U,onAlert:a}),s&&e("div",{className:"requisition-list__alert-wrapper",children:e(Et,{heading:s.description,type:s.type,variant:"primary",onDismiss:()=>r(null)})}),n.items_count===0?e($t,{textContent:`${n.name} ${t.emptyRequisitionList}`}):w(bt,{children:[e(Xt,{selectedItems:z,deletingItemId:y,addingToCartItemId:f,bulkAddingToCart:N,updatingQuantityItemId:it,onSelectAll:ot,onSelectNone:at,onBulkAddToCart:()=>v(Array.from(z)),onBulkDelete:()=>V(Array.from(z))}),e(Kt,{items:n.items,selectedItems:z,currentPage:((K=n.page_info)==null?void 0:K.current_page)||1,pageSize:((ft=n.page_info)==null?void 0:ft.page_size)||dt,handleItemSelection:st,handleUpdateQuantity:rt,onAddToCart:v,onDeleteItem:V}),n.page_info&&w("div",{className:"requisition-list-view__pagination",children:[e(Ot,{pageInfo:n.page_info,totalCount:n.items_count}),(((mt=n.page_info)==null?void 0:mt.total_pages)||0)>1&&e(xt,{totalPages:n.page_info.total_pages,currentPage:((ht=n.page_info)==null?void 0:ht.current_page)||1,onChange:Y,disabled:h||I}),w("div",{className:"requisition-list-view__pagination-picker",children:[e("span",{children:t.show}),e(Wt,{currentPageSize:((_t=n.page_info)==null?void 0:_t.page_size)||dt,onPageSizeChange:G,disabled:h||I})]})]})]})]}),x&&e(zt,{isOpen:x,isLoading:y!==null,title:t.deleteItemsTitle,modalContent:t.deleteItemsMessage,confirmBtnCaption:t.confirmAction,closeBtnCaption:t.cancelAction,handleModalOnClose:()=>{j(!1),Z([])},handleModalOnConfirm:H})]})};export{fe as RequisitionListView,fe as default};
3
+ import{jsxs as y,jsx as n,Fragment as qt}from"@dropins/tools/preact-jsx-runtime.js";import*as f from"@dropins/tools/preact-compat.js";import{useState as N,useEffect as rt,useCallback as x}from"@dropins/tools/preact-compat.js";import{a as Rt,d as Ct,u as It,g as ct,i as St}from"../chunks/addRequisitionListItemsToCart.js";import{Button as pt,Icon as st,Price as bt,Field as At,Input as Nt,Image as Tt,Checkbox as Et,Table as xt,ProgressSpinner as Vt,InLineAlert as Mt,Pagination as Pt}from"@dropins/tools/components.js";import{events as j}from"@dropins/tools/event-bus.js";import{useState as ot,useCallback as ut}from"@dropins/tools/preact-hooks.js";import{VComponent as Dt,classes as Ht}from"@dropins/tools/lib.js";import{D as dt}from"../chunks/RequisitionListForm.js";import{a as $t,u as Ft,E as Bt}from"../chunks/RequisitionListView.js";import{h as zt}from"@dropins/tools/preact.js";import{useText as gt}from"@dropins/tools/i18n.js";import{R as Wt}from"../chunks/RequisitionListHeader.js";import"../chunks/state.js";import{R as Ot}from"../chunks/RequisitionListModal.js";import{N as wt,P as Qt,a as jt}from"../chunks/PaginationItemsCounter.js";import"../chunks/updateRequisitionList.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/deleteRequisitionList.js";const Zt=c=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},f.createElement("g",{clipPath:"url(#clip0_102_196)"},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),f.createElement("defs",null,f.createElement("clipPath",{id:"clip0_102_196"},f.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),Kt=c=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},f.createElement("path",{d:"M17.3332 11.75H6.6665",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",fill:"none",stroke:"currentColor"})),kt=c=>f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",...c},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1 5H23",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.87402 8.58057L9.39348 17.682",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.6673 8.58057L14.146 17.682",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}));function Xt(){const[c,V]=ot(null),[v,_]=ot(new Set),P=ut((R,C)=>{_(m=>{const L=new Set(m);return C?L.add(R):L.delete(R),L})},[]),T=ut(()=>{var C;const R=(C=c==null?void 0:c.items)==null?void 0:C.map(m=>m.uid);_(new Set(R))},[c]),d=ut(()=>{_(new Set)},[]);return{currentRequisitionList:c,setCurrentRequisitionList:V,selectedItems:v,setSelectedItems:_,handleItemSelection:P,handleSelectAll:T,handleSelectNone:d}}const Jt=({className:c,items:V,selectedItems:v,currentPage:_,pageSize:P,canEdit:T=!0,handleItemSelection:d,handleUpdateQuantity:R,onAddToCart:C,onDeleteItem:m,...L})=>{const[E,F]=ot({}),[at,B]=ot({}),w=gt({productNameHeader:"RequisitionList.RequisitionListView.productListTable.headers.productName",skuHeader:"RequisitionList.RequisitionListView.productListTable.headers.sku",priceHeader:"RequisitionList.RequisitionListView.productListTable.headers.price",quantityHeader:"RequisitionList.RequisitionListView.productListTable.headers.quantity",subtotalHeader:"RequisitionList.RequisitionListView.productListTable.headers.subtotal",actionsHeader:"RequisitionList.RequisitionListView.productListTable.headers.actions",actionAddToCart:"RequisitionList.RequisitionListView.actionAddToCart",actionDelete:"RequisitionList.RequisitionListView.actionDelete",actionSelect:"RequisitionList.RequisitionListView.actionSelect",itemQuantity:"RequisitionList.RequisitionListView.productListTable.itemQuantity",outOfStock:"RequisitionList.RequisitionListView.productListTable.outOfStock",onlyXLeftInStock:"RequisitionList.RequisitionListView.productListTable.onlyXLeftInStock"}),z=[{label:"#",key:"index"},{label:"item",key:"item"},{label:w.priceHeader,key:"price"},{label:w.quantityHeader,key:"quantity"},{label:w.subtotalHeader,key:"subtotal"}];T&&(z.unshift({label:w.actionSelect,key:"selector"}),z.push({label:w.actionsHeader,key:"actions"}));const J=(t,a)=>{const e=t.target.checked;d(a.uid,e)},W=t=>(_-1)*P+t+1,M=t=>{var a,e;return((a=t.configured_product)==null?void 0:a.name)||((e=t.product)==null?void 0:e.name)||t.sku},Y=t=>{var a,e,u,I,l,S;return(e=(a=t.configured_product)==null?void 0:a.images)!=null&&e.length?((u=t.configured_product.images[0])==null?void 0:u.url)||"":(l=(I=t.product)==null?void 0:I.images)!=null&&l.length&&((S=t.product.images[0])==null?void 0:S.url)||""},D=t=>{var a;return((a=t.product)==null?void 0:a.name)||t.sku},Z=t=>{var a;return(a=t.configured_product)==null?void 0:a.name},G=t=>t.bundle_options?t.bundle_options.map((e,u)=>y("span",{className:"requisition-list-view-product-list-table__product-configurable-name",children:[e.values[0].label," x ",e.values[0].quantity]},e.values[0].label||u)):void 0,K=t=>{var a;return((a=t.configured_product)==null?void 0:a.sku)||t.sku},H=t=>{var a,e,u,I,l,S,A,p;return Array.isArray(t.bundle_options)&&t.bundle_options.length>0?t.bundle_options.reduce((tt,X)=>{var et,it,nt;return tt+(((it=(et=X.values[0])==null?void 0:et.priceV2)==null?void 0:it.value)||0)*(((nt=X.values[0])==null?void 0:nt.quantity)||0)},0):((I=(u=(e=(a=t.configured_product)==null?void 0:a.price)==null?void 0:e.final)==null?void 0:u.amount)==null?void 0:I.value)||((p=(A=(S=(l=t.product)==null?void 0:l.price)==null?void 0:S.final)==null?void 0:A.amount)==null?void 0:p.value)||0},O=t=>{var a,e,u,I,l,S,A,p;return((I=(u=(e=(a=t.configured_product)==null?void 0:a.price)==null?void 0:e.final)==null?void 0:u.amount)==null?void 0:I.currency)||((p=(A=(S=(l=t.product)==null?void 0:l.price)==null?void 0:S.final)==null?void 0:A.amount)==null?void 0:p.currency)},o=t=>H(t)*t.quantity,g=(t,a)=>{const e=+t.target.value;e>0&&!Number.isNaN(t.target.value)&&B(u=>({...u,[a.uid]:e}))},Q=async(t,a)=>{let e=+t.target.value;if(!(e>0&&e!==a.quantity)){B(u=>({...u,[a.uid]:a.quantity}));return}F(u=>({...u,[a.uid]:!0}));try{await R(a.uid,e)}finally{F(u=>({...u,[a.uid]:!1}))}},U=V.map((t,a)=>({selector:n("label",{id:`item-selector-${t.sku}-label`,children:n(Et,{className:"requisition-list-view-product-list-table__checkbox",name:`item-selector-${t.sku}`,"aria-label":`${w.actionSelect} ${D(t)}`,"data-testid":`item-checkbox-${t.sku}`,onChange:e=>J(e,t),value:t.sku,checked:v.has(t.uid)})}),index:n("div",{className:"requisition-list-view-product-list-table__index-container",children:W(a)}),item:y("div",{className:"requisition-list-view-product-list-table__item-container",children:[n(Tt,{className:"requisition-list-view-product-list-table__thumbnail",alt:M(t),src:Y(t)}),y("div",{className:"requisition-list-view-product-list-table__item-details",children:[n("div",{className:"requisition-list-view-product-list-table__product-name",children:D(t)}),t.stock_status==="OUT_OF_STOCK"&&n("div",{className:"requisition-list-view-product-list-table__out-of-stock",children:w.outOfStock}),t.stock_status!=="OUT_OF_STOCK"&&t.only_x_left_in_stock!==null&&t.only_x_left_in_stock<t.quantity&&n("div",{className:"requisition-list-view-product-list-table__low-stock",children:w.onlyXLeftInStock.replace("{count}",String(t.only_x_left_in_stock))}),n("span",{className:"requisition-list-view-product-list-table__product-configurable-name",children:Z(t)}),n("div",{className:"requisition-list-view-product-list-table__sku",children:K(t)}),G(t)]})]}),price:n(bt,{className:"requisition-list-view-product-list-table__price",amount:H(t),currency:O(t)}),quantity:n("span",{className:"requisition-list-view-product-list-table__quantity",children:n(At,{disabled:!!E[t.uid],children:n(Nt,{id:`requisition-list-item-quantity-${t.sku}`,"data-testid":`requisition-list-item-quantity-${t.sku}`,name:"quantity",type:"text","aria-label":`${w.itemQuantity} - ${D(t)}`,value:at[t.uid]??t.quantity,onChange:e=>g(e,t),onBlur:e=>Q(e,t)})})}),subtotal:n(bt,{className:"requisition-list-view-product-list-table__price",amount:o(t),currency:O(t)}),actions:y("div",{className:"requisition-list-view__bulk-actions",children:[n(pt,{type:"button",onClick:()=>C([t.uid]),icon:n(st,{source:Zt}),"aria-label":`${w.actionAddToCart} - ${D(t)}`,"data-testid":"product-list-table-add-to-cart-button"}),n(pt,{type:"button",variant:"secondary",icon:n(st,{source:kt}),onClick:()=>m([t.uid]),"aria-label":`${w.actionDelete} - ${D(t)}`,"data-testid":"product-list-table-delete-button"})]})})),lt=n(xt,{columns:z,rowData:U,"data-testid":"product-list-table",mobileLayout:"stacked"});return n(Dt,{node:zt("div",{}),className:Ht(["requisition-list-view-product-list-table-container",c]),"data-testid":"product-list-table-container",...L,children:lt})},Yt=({selectedItems:c,deletingItemId:V,addingToCartItemId:v,bulkAddingToCart:_,updatingQuantityItemId:P,onSelectAll:T,onSelectNone:d,onBulkAddToCart:R,onBulkDelete:C})=>{const m=gt({statusDeleting:"RequisitionList.RequisitionListView.statusDeleting",actionSelectAll:"RequisitionList.RequisitionListView.actionSelectAll",actionSelectNone:"RequisitionList.RequisitionListView.actionSelectNone",actionAddToCart:"RequisitionList.RequisitionListView.actionAddToCart",actionDeleteSelectedItems:"RequisitionList.RequisitionListView.actionDeleteSelectedItems",statusBulkAddingToCart:"RequisitionList.RequisitionListView.statusBulkAddingToCart"}),L=V!==null||v!==null||_||P!==null,E=c.size>0;return y("div",{className:"requisition-list-view__batch-actions",children:[y("div",{className:"requisition-list-view__batch-actions-left",children:[n("button",{"data-testid":"bulk-actions-select-toggle-btn",type:"button",className:`requisition-list-view__batch-actions-select-toggle ${E?"requisition-list-view__batch-actions-select-toggle--active":""}`,onClick:E?d:T,disabled:L,"aria-label":E?m.actionSelectNone:m.actionSelectAll,children:n(st,{source:Kt})}),n("button",{type:"button",className:"requisition-list-view__batch-actions-select-label",onClick:E?d:T,disabled:L,children:m.actionSelectAll})]}),E&&y("div",{className:"requisition-list-view__batch-actions-buttons",children:[n("span",{className:"requisition-list-view__batch-actions-count-badge","aria-label":`${c.size} items selected`,children:c.size}),n(pt,{"data-testid":"bulk-actions-add-to-cart-btn",type:"button",variant:"secondary",onClick:R,disabled:L,children:_?m.statusBulkAddingToCart:m.actionAddToCart}),n("button",{"data-testid":"bulk-actions-delete-btn",type:"button",className:"requisition-list-view__batch-actions-delete-icon",onClick:C,disabled:L,"aria-label":m.actionDeleteSelectedItems,children:n(st,{source:kt})})]})]})},fe=({requisitionListUid:c,skipProductLoading:V=!1,pageSize:v=dt,routeRequisitionListGrid:_,fallbackRoute:P="/customer/account",getProductData:T,enrichConfigurableProducts:d})=>{var mt,ht,ft,_t,Lt;const[R,C]=N(!1),[m,L]=N(null),[E,F]=N(null),[at,B]=N(!1),[w,z]=N(null),[J,W]=N(!1),[M,Y]=N(v),[D,Z]=N(!0),[G,K]=N(!1),[H,O]=N([]),{currentRequisitionList:o,setCurrentRequisitionList:g,selectedItems:Q,setSelectedItems:U,handleItemSelection:lt,handleSelectAll:t,handleSelectNone:a}=Xt(),e=gt({emptyRequisitionList:"RequisitionList.RequisitionListView.emptyRequisitionList",errorLoadingProducts:"RequisitionList.RequisitionListView.errorLoadingProducts",errorLoadPage:"RequisitionList.RequisitionListView.errorLoadPage",notFoundTitle:"RequisitionList.RequisitionListView.notFoundTitle",notFoundMessage:"RequisitionList.RequisitionListView.notFoundMessage",notFoundActionLabel:"RequisitionList.RequisitionListView.notFoundActionLabel",notEnabledTitle:"RequisitionList.RequisitionListsNotEnabled.title",notEnabledMessage:"RequisitionList.RequisitionListsNotEnabled.message",partialMoveSuccess:"RequisitionList.RequisitionListAlert.partialMoveSuccess",notEnabledActionLabel:"RequisitionList.RequisitionListsNotEnabled.actionLabel",show:"RequisitionList.PageSizePicker.show",deleteItemsTitle:"RequisitionList.RequisitionListView.deleteItemsTitle",deleteItemsMessage:"RequisitionList.RequisitionListView.deleteItemsMessage",confirmAction:"RequisitionList.RequisitionListView.confirmAction",cancelAction:"RequisitionList.RequisitionListView.cancelAction"}),{alert:u,setAlert:I,handleRequisitionListAlert:l}=$t(),{isEnabled:S}=Ft();rt(()=>{const i=j.on("requisitionList/data",r=>{(r==null?void 0:r.uid)===c&&(g(r),U(new Set))}),s=j.on("requisitionList/alert",l);return()=>{i==null||i.off(),s==null||s.off()}},[l,c,g,U]),rt(()=>{Y(v)},[v]);const A=x(async i=>{var r;if(!((r=i.items)!=null&&r.length))return i;const s=await d(i.items);return{...i,items:s}},[d]),p=x(async i=>{var r,h;const s=((r=i.items)==null?void 0:r.map(k=>k.sku))||[];if(s.length===0)return i;C(!0);try{const k=await T(s);if(k){const q=new Map;return k.forEach(b=>{q.set(b.sku,b)}),{...i,items:(h=i.items)==null?void 0:h.map(b=>{const $=q.get(b.sku);return{...b,product:$||b.product,stock_status:b.stock_status||($==null?void 0:$.stock_status)||"IN_STOCK",only_x_left_in_stock:b.only_x_left_in_stock??($==null?void 0:$.only_x_left_in_stock)??null}})}}return console.warn("No products found"),i}catch(k){return console.warn(k instanceof Error?k.message:e.errorLoadingProducts),i}finally{C(!1)}},[T,e.errorLoadingProducts]);rt(()=>{if(!c){Z(!1);return}if(o&&o.uid===c)return;Z(!0),(async()=>{try{const s=await ct(c,1,v,d);if(s)if(V)g(s);else{const r=await p(s);g(r)}}catch(s){console.error("Failed to initialize requisition list from UID:",s)}finally{Z(!1)}})()},[c,v,V,d,p,g,o]);const tt=x(async i=>{i&&i.length===1?(B(!1),F(i)):(B(!0),F(null));try{const s=await Rt(o.uid,i),r=(i==null?void 0:i.length)||0,h=(s==null?void 0:s.length)||0,k=r-h;if(s&&s.length>0&&k>0){const q={action:"move",type:"error",context:"product",message:[e.partialMoveSuccess.replace("{successCount}",String(k)).replace("{failedCount}",String(h))]};l(q),j.emit("requisitionList/alert",q)}else if(s&&s.length>0){const q={action:"move",type:"error",context:"product",message:s.map(b=>b.message)};l(q),j.emit("requisitionList/alert",q)}else{const q={action:"move",type:"success",context:"product"};l(q),j.emit("requisitionList/alert",q)}}catch{const r={action:"move",type:"error",context:"product"};l(r),j.emit("requisitionList/alert",r)}finally{F(null),B(!1)}},[o,l,e]),X=x(i=>{i&&i.length>0&&(O(i),K(!0))},[]),et=x(async()=>{H.length===1?L(H[0]):L("bulk");try{const i=await Ct(o.uid,H,M,o.page_info.current_page,d);if(i){const s=await A(i),r=await p(s);g(r),l({action:"delete",type:"success",context:"product"})}else l({action:"delete",type:"error",context:"product"})}catch{l({action:"delete",type:"error",context:"product"})}finally{L(null),K(!1),O([])}},[H,o,M,p,g,l,A,d]),it=x(async(i,s)=>{var r;z(i);try{const h=(r=o.items)==null?void 0:r.find(b=>b.uid===i);if(!h){l({action:"update",type:"error",context:"product"});return}const k={item_id:h.uid,entered_options:h.entered_options,selected_options:h.selected_options,quantity:s},q=await It(o.uid,[k],M,o.page_info.current_page,d);if(q){const b=await p(q);g(b),l({action:"update",type:"success",context:"product"})}else l({action:"update",type:"error",context:"product"})}catch{l({action:"update",type:"error",context:"product"})}finally{z(null)}},[o,p,g,M,l,d]),nt=x(async i=>{W(!0);try{const s=await ct(o.uid,i,M,d);if(s){const h=await p(s);g(h)}else console.warn(e.errorLoadPage)}catch(s){console.warn(s instanceof Error?s.message:e.errorLoadPage)}finally{W(!1)}},[o==null?void 0:o.uid,p,M,e,g,d]),yt=x(async i=>{Y(i),W(!0);try{const s=await ct(o.uid,1,i,d);if(s){const h=await p(s);g(h)}else console.warn(e.errorLoadPage)}catch{console.warn(e.errorLoadPage)}finally{W(!1)}},[o==null?void 0:o.uid,p,e,g,d]),vt=x(async i=>{const s=await A(i),r=await p(s);g(r)},[g,p,A]);return y("div",{className:"requisition-list-view__container",children:[D?n("div",{className:"requisition-list-view__loading",children:n(Vt,{stroke:"4",size:"large"})}):S===!1?n(wt,{title:e.notEnabledTitle,message:e.notEnabledMessage,actionLabel:e.notEnabledActionLabel,onAction:()=>{window.location.href=P}}):!o||!St(o==null?void 0:o.uid)?n(wt,{title:e.notFoundTitle,message:e.notFoundMessage,actionLabel:_?e.notFoundActionLabel:void 0,onAction:_?()=>{const i=_();i&&typeof i=="string"&&(window.location.href=i)}:void 0}):y(qt,{children:[n(Wt,{requisitionList:o,routeRequisitionListGrid:_,onUpdate:vt,onAlert:l,enrichConfigurableProducts:d}),u&&n("div",{className:"requisition-list__alert-wrapper",children:n(Mt,{heading:u.description,type:u.type,variant:"primary",onDismiss:()=>I(null)})}),o.items_count===0?n(Bt,{textContent:`${o.name} ${e.emptyRequisitionList}`}):y(qt,{children:[n(Yt,{selectedItems:Q,deletingItemId:m,addingToCartItemId:E,bulkAddingToCart:at,updatingQuantityItemId:w,onSelectAll:t,onSelectNone:a,onBulkAddToCart:()=>tt(Array.from(Q)),onBulkDelete:()=>X(Array.from(Q))}),n(Jt,{items:o.items,selectedItems:Q,currentPage:((mt=o.page_info)==null?void 0:mt.current_page)||1,pageSize:((ht=o.page_info)==null?void 0:ht.page_size)||dt,handleItemSelection:lt,handleUpdateQuantity:it,onAddToCart:tt,onDeleteItem:X}),o.page_info&&y("div",{className:"requisition-list-view__pagination",children:[n(Qt,{pageInfo:o.page_info,totalCount:o.items_count}),(((ft=o.page_info)==null?void 0:ft.total_pages)||0)>1&&n(Pt,{totalPages:o.page_info.total_pages,currentPage:((_t=o.page_info)==null?void 0:_t.current_page)||1,onChange:nt,disabled:J||R}),y("div",{className:"requisition-list-view__pagination-picker",children:[n("span",{children:e.show}),n(jt,{currentPageSize:((Lt=o.page_info)==null?void 0:Lt.page_size)||dt,onPageSizeChange:yt,disabled:J||R})]})]})]})]}),G&&n(Ot,{isOpen:G,isLoading:m!==null,title:e.deleteItemsTitle,modalContent:e.deleteItemsMessage,confirmBtnCaption:e.confirmAction,closeBtnCaption:e.cancelAction,handleModalOnClose:()=>{K(!1),O([])},handleModalOnConfirm:et})]})};export{fe as RequisitionListView,fe as default};
4
4
  //# sourceMappingURL=RequisitionListView.js.map