@medusajs/dashboard 2.20.1 → 2.20.2-preview-20260904113944

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.
Files changed (42) hide show
  1. package/dist/app.js +33 -11
  2. package/dist/app.mjs +1 -1
  3. package/dist/{categories-metadata-N5FBZ3DP.mjs → categories-metadata-SNBLFGOW.mjs} +1 -1
  4. package/dist/{chunk-3DAFXBA2.mjs → chunk-6J7PJX4H.mjs} +30 -29
  5. package/dist/{chunk-SRB46YCA.mjs → chunk-7MZ3KZEC.mjs} +1 -1
  6. package/dist/{chunk-UEZBIZRM.mjs → chunk-ENCSRL5P.mjs} +25 -6
  7. package/dist/{collection-metadata-4BNXPME7.mjs → collection-metadata-EVKCVN6U.mjs} +1 -1
  8. package/dist/{customer-group-metadata-JSWYYQ7X.mjs → customer-group-metadata-HUFRLIEO.mjs} +1 -1
  9. package/dist/{customer-metadata-U2LOGIOG.mjs → customer-metadata-XMR3RYGI.mjs} +1 -1
  10. package/dist/index.d.mts +1 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/{inventory-metadata-IDXP72WU.mjs → inventory-metadata-D3BK2JTS.mjs} +1 -1
  13. package/dist/{location-metadata-76SDPEA7.mjs → location-metadata-HY2NQ5AN.mjs} +1 -1
  14. package/dist/{order-metadata-2ZJ46QVX.mjs → order-metadata-IDKLPDRT.mjs} +1 -1
  15. package/dist/{price-list-metadata-ITQPDESX.mjs → price-list-metadata-MGU3NIJY.mjs} +1 -1
  16. package/dist/{product-attributes-YUSO34D3.mjs → product-attributes-WDS4CQ4B.mjs} +1 -1
  17. package/dist/{product-create-FUALPWTH.mjs → product-create-ZU4BHZZP.mjs} +2 -2
  18. package/dist/{product-detail-UYEOEAB6.mjs → product-detail-QZMY7BTK.mjs} +2 -2
  19. package/dist/{product-edit-SZJ6T2FD.mjs → product-edit-WNCHRKJI.mjs} +1 -1
  20. package/dist/{product-metadata-JFSXRSIJ.mjs → product-metadata-DBPI3K6A.mjs} +1 -1
  21. package/dist/{product-option-metadata-U6EBWHGU.mjs → product-option-metadata-MPONY6D6.mjs} +1 -1
  22. package/dist/{product-option-value-metadata-V4S44CAG.mjs → product-option-value-metadata-KNMU4PHP.mjs} +1 -1
  23. package/dist/{product-options-manage-ZFTSUEY6.mjs → product-options-manage-L7KNCJRY.mjs} +2 -2
  24. package/dist/{product-organization-MPPG6MUE.mjs → product-organization-SPHCBRY7.mjs} +1 -1
  25. package/dist/{product-tag-list-WKDS5YFZ.mjs → product-tag-list-6RCS2J2L.mjs} +4 -2
  26. package/dist/{product-tag-metadata-BBA7EKMY.mjs → product-tag-metadata-KD475YDG.mjs} +1 -1
  27. package/dist/{product-type-metadata-TY2QMFYM.mjs → product-type-metadata-JTXNXUUG.mjs} +1 -1
  28. package/dist/{product-variant-metadata-EFVUKD4Z.mjs → product-variant-metadata-2QS6TS6H.mjs} +1 -1
  29. package/dist/{region-metadata-TL7FPABQ.mjs → region-metadata-GBZ6EJ6S.mjs} +1 -1
  30. package/dist/{reservation-metadata-6HKDMEUJ.mjs → reservation-metadata-FEJR67UX.mjs} +1 -1
  31. package/dist/{sales-channel-metadata-MDI7BZYK.mjs → sales-channel-metadata-ANOPRPGB.mjs} +1 -1
  32. package/dist/{shipping-profile-metadata-BMEE45UH.mjs → shipping-profile-metadata-WQIWJI7U.mjs} +1 -1
  33. package/dist/{store-metadata-5BSUD7BG.mjs → store-metadata-R5GNVTKR.mjs} +1 -1
  34. package/dist/{user-metadata-7FTXFRN3.mjs → user-metadata-MJ33QWBH.mjs} +1 -1
  35. package/package.json +9 -9
  36. package/src/components/forms/metadata-form/metadata-form.tsx +31 -13
  37. package/src/i18n/translations/$schema.json +9 -1
  38. package/src/i18n/translations/en.json +2 -1
  39. package/src/routes/product-tags/product-tag-list/__tests__/loader.spec.ts +59 -0
  40. package/src/routes/product-tags/product-tag-list/loader.ts +8 -2
  41. package/src/routes/products/product-create/components/product-create-inventory-kit-form/components/product-create-inventory-kit-section/product-create-inventory-kit-section.spec.tsx +115 -0
  42. package/src/routes/products/product-create/components/product-create-inventory-kit-form/components/product-create-inventory-kit-section/product-create-inventory-kit-section.tsx +3 -2
package/dist/app.js CHANGED
@@ -9485,7 +9485,8 @@ var init_en = __esm({
9485
9485
  actions: {
9486
9486
  insertRowAbove: "Insert row above",
9487
9487
  insertRowBelow: "Insert row below",
9488
- deleteRow: "Delete row"
9488
+ deleteRow: "Delete row",
9489
+ addRow: "Add row"
9489
9490
  },
9490
9491
  labels: {
9491
9492
  key: "Key",
@@ -128440,7 +128441,7 @@ var init_product_create_inventory_kit_section = __esm({
128440
128441
  });
128441
128442
  return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { id: "organize", className: "flex flex-col gap-y-8", children: [
128442
128443
  /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_ui70.Heading, { children: t5("products.create.inventory.heading") }),
128443
- variants.fields.filter((v) => v.inventory_kit).map((variant, variantIndex) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
128444
+ variants.fields.map((variant, variantIndex) => ({ variant, variantIndex })).filter(({ variant }) => variant.inventory_kit).map(({ variant, variantIndex }) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
128444
128445
  VariantSection,
128445
128446
  {
128446
128447
  form,
@@ -141682,6 +141683,13 @@ var init_metadata_form = __esm({
141682
141683
  disabled: false
141683
141684
  });
141684
141685
  }
141686
+ function addRow() {
141687
+ insert(fields.length, {
141688
+ key: "",
141689
+ value: "",
141690
+ disabled: false
141691
+ });
141692
+ }
141685
141693
  return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RouteDrawer.Form, { form, children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(
141686
141694
  KeyboundForm,
141687
141695
  {
@@ -141823,18 +141831,30 @@ var init_metadata_form = __esm({
141823
141831
  }
141824
141832
  )
141825
141833
  ] }),
141826
- /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "flex items-center justify-end gap-x-2", children: [
141827
- /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
141834
+ /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "flex items-center justify-between", children: [
141835
+ /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
141828
141836
  import_ui132.Button,
141829
141837
  {
141830
141838
  size: "small",
141831
141839
  variant: "secondary",
141832
141840
  type: "button",
141833
- disabled: isMutating,
141834
- children: t5("actions.cancel")
141841
+ onClick: addRow,
141842
+ children: t5("metadata.edit.actions.addRow")
141835
141843
  }
141836
- ) }),
141837
- /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_ui132.Button, { size: "small", type: "submit", isLoading: isMutating, children: t5("actions.save") })
141844
+ ),
141845
+ /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "flex items-center gap-x-2", children: [
141846
+ /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
141847
+ import_ui132.Button,
141848
+ {
141849
+ size: "small",
141850
+ variant: "secondary",
141851
+ type: "button",
141852
+ disabled: isMutating,
141853
+ children: t5("actions.cancel")
141854
+ }
141855
+ ) }),
141856
+ /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_ui132.Button, { size: "small", type: "submit", isLoading: isMutating, children: t5("actions.save") })
141857
+ ] })
141838
141858
  ] }) })
141839
141859
  ]
141840
141860
  }
@@ -204817,13 +204837,14 @@ var init_location_service_zone_shipping_option_pricing2 = __esm({
204817
204837
  });
204818
204838
 
204819
204839
  // src/routes/product-tags/product-tag-list/loader.ts
204820
- var productTagListQuery, productTagListLoader;
204840
+ var QUERY_PREFIX, productTagListQuery, productTagListLoader;
204821
204841
  var init_loader28 = __esm({
204822
204842
  "src/routes/product-tags/product-tag-list/loader.ts"() {
204823
204843
  "use strict";
204824
204844
  init_api();
204825
204845
  init_client2();
204826
204846
  init_query_client();
204847
+ QUERY_PREFIX = "ptag_";
204827
204848
  productTagListQuery = (query) => ({
204828
204849
  queryKey: productTagsQueryKeys.list(query),
204829
204850
  queryFn: async () => sdk.admin.productTag.list(query)
@@ -204832,10 +204853,11 @@ var init_loader28 = __esm({
204832
204853
  const searchParams = new URL(request.url).searchParams;
204833
204854
  const queryObject = {};
204834
204855
  searchParams.forEach((value, key) => {
204856
+ const field = key.startsWith(QUERY_PREFIX) ? key.slice(QUERY_PREFIX.length) : key;
204835
204857
  try {
204836
- queryObject[key] = JSON.parse(value);
204858
+ queryObject[field] = JSON.parse(value);
204837
204859
  } catch (_e) {
204838
- queryObject[key] = value;
204860
+ queryObject[field] = value;
204839
204861
  }
204840
204862
  });
204841
204863
  const query = productTagListQuery(
package/dist/app.mjs CHANGED
@@ -14,7 +14,7 @@ import "./chunk-P3UUX2T6.mjs";
14
14
  import "./chunk-DG7J63J2.mjs";
15
15
  import {
16
16
  DashboardApp
17
- } from "./chunk-3DAFXBA2.mjs";
17
+ } from "./chunk-6J7PJX4H.mjs";
18
18
  import "./chunk-ONB3JEHR.mjs";
19
19
  import "./chunk-JAW6ZD7F.mjs";
20
20
  import "./chunk-TO7QJZLE.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -9055,7 +9055,8 @@ var en_default = {
9055
9055
  actions: {
9056
9056
  insertRowAbove: "Insert row above",
9057
9057
  insertRowBelow: "Insert row below",
9058
- deleteRow: "Delete row"
9058
+ deleteRow: "Delete row",
9059
+ addRow: "Add row"
9059
9060
  },
9060
9061
  labels: {
9061
9062
  key: "Key",
@@ -108288,7 +108289,7 @@ function getRouteMap({
108288
108289
  children: [
108289
108290
  {
108290
108291
  path: "create",
108291
- lazy: () => import("./product-create-FUALPWTH.mjs")
108292
+ lazy: () => import("./product-create-ZU4BHZZP.mjs")
108292
108293
  },
108293
108294
  {
108294
108295
  path: "import",
@@ -108304,7 +108305,7 @@ function getRouteMap({
108304
108305
  path: ":id",
108305
108306
  errorElement: /* @__PURE__ */ jsx21(ErrorBoundary, {}),
108306
108307
  lazy: async () => {
108307
- const { Breadcrumb, loader, seo } = await import("./product-detail-UYEOEAB6.mjs");
108308
+ const { Breadcrumb, loader, seo } = await import("./product-detail-QZMY7BTK.mjs");
108308
108309
  return {
108309
108310
  Component: Outlet5,
108310
108311
  loader,
@@ -108317,11 +108318,11 @@ function getRouteMap({
108317
108318
  children: [
108318
108319
  {
108319
108320
  path: "",
108320
- lazy: () => import("./product-detail-UYEOEAB6.mjs"),
108321
+ lazy: () => import("./product-detail-QZMY7BTK.mjs"),
108321
108322
  children: [
108322
108323
  {
108323
108324
  path: "edit",
108324
- lazy: () => import("./product-edit-SZJ6T2FD.mjs")
108325
+ lazy: () => import("./product-edit-WNCHRKJI.mjs")
108325
108326
  },
108326
108327
  {
108327
108328
  path: "edit-variant",
@@ -108333,11 +108334,11 @@ function getRouteMap({
108333
108334
  },
108334
108335
  {
108335
108336
  path: "attributes",
108336
- lazy: () => import("./product-attributes-YUSO34D3.mjs")
108337
+ lazy: () => import("./product-attributes-WDS4CQ4B.mjs")
108337
108338
  },
108338
108339
  {
108339
108340
  path: "organization",
108340
- lazy: () => import("./product-organization-MPPG6MUE.mjs")
108341
+ lazy: () => import("./product-organization-SPHCBRY7.mjs")
108341
108342
  },
108342
108343
  {
108343
108344
  path: "shipping-profile",
@@ -108365,11 +108366,11 @@ function getRouteMap({
108365
108366
  },
108366
108367
  {
108367
108368
  path: "metadata/edit",
108368
- lazy: () => import("./product-metadata-JFSXRSIJ.mjs")
108369
+ lazy: () => import("./product-metadata-DBPI3K6A.mjs")
108369
108370
  },
108370
108371
  {
108371
108372
  path: "options/manage",
108372
- lazy: () => import("./product-options-manage-ZFTSUEY6.mjs")
108373
+ lazy: () => import("./product-options-manage-L7KNCJRY.mjs")
108373
108374
  }
108374
108375
  ]
108375
108376
  },
@@ -108405,7 +108406,7 @@ function getRouteMap({
108405
108406
  },
108406
108407
  {
108407
108408
  path: "metadata/edit",
108408
- lazy: () => import("./product-variant-metadata-EFVUKD4Z.mjs")
108409
+ lazy: () => import("./product-variant-metadata-2QS6TS6H.mjs")
108409
108410
  }
108410
108411
  ]
108411
108412
  }
@@ -108454,7 +108455,7 @@ function getRouteMap({
108454
108455
  },
108455
108456
  {
108456
108457
  path: "metadata/edit",
108457
- lazy: () => import("./product-option-metadata-U6EBWHGU.mjs")
108458
+ lazy: () => import("./product-option-metadata-MPONY6D6.mjs")
108458
108459
  }
108459
108460
  ]
108460
108461
  },
@@ -108473,7 +108474,7 @@ function getRouteMap({
108473
108474
  children: [
108474
108475
  {
108475
108476
  path: "metadata/edit",
108476
- lazy: () => import("./product-option-value-metadata-V4S44CAG.mjs")
108477
+ lazy: () => import("./product-option-value-metadata-KNMU4PHP.mjs")
108477
108478
  }
108478
108479
  ]
108479
108480
  }
@@ -108530,7 +108531,7 @@ function getRouteMap({
108530
108531
  },
108531
108532
  {
108532
108533
  path: "metadata/edit",
108533
- lazy: () => import("./categories-metadata-N5FBZ3DP.mjs")
108534
+ lazy: () => import("./categories-metadata-SNBLFGOW.mjs")
108534
108535
  }
108535
108536
  ]
108536
108537
  }
@@ -108621,7 +108622,7 @@ function getRouteMap({
108621
108622
  },
108622
108623
  {
108623
108624
  path: "metadata/edit",
108624
- lazy: () => import("./order-metadata-2ZJ46QVX.mjs")
108625
+ lazy: () => import("./order-metadata-IDKLPDRT.mjs")
108625
108626
  }
108626
108627
  ]
108627
108628
  }
@@ -108763,7 +108764,7 @@ function getRouteMap({
108763
108764
  },
108764
108765
  {
108765
108766
  path: "metadata/edit",
108766
- lazy: () => import("./collection-metadata-4BNXPME7.mjs")
108767
+ lazy: () => import("./collection-metadata-EVKCVN6U.mjs")
108767
108768
  }
108768
108769
  ]
108769
108770
  }
@@ -108818,7 +108819,7 @@ function getRouteMap({
108818
108819
  },
108819
108820
  {
108820
108821
  path: "metadata/edit",
108821
- lazy: () => import("./price-list-metadata-ITQPDESX.mjs")
108822
+ lazy: () => import("./price-list-metadata-MGU3NIJY.mjs")
108822
108823
  }
108823
108824
  ]
108824
108825
  }
@@ -108906,7 +108907,7 @@ function getRouteMap({
108906
108907
  children: [
108907
108908
  {
108908
108909
  path: "",
108909
- lazy: () => import("./customer-metadata-U2LOGIOG.mjs")
108910
+ lazy: () => import("./customer-metadata-XMR3RYGI.mjs")
108910
108911
  }
108911
108912
  ]
108912
108913
  }
@@ -108955,7 +108956,7 @@ function getRouteMap({
108955
108956
  },
108956
108957
  {
108957
108958
  path: "metadata/edit",
108958
- lazy: () => import("./customer-group-metadata-JSWYYQ7X.mjs")
108959
+ lazy: () => import("./customer-group-metadata-HUFRLIEO.mjs")
108959
108960
  }
108960
108961
  ]
108961
108962
  }
@@ -108998,7 +108999,7 @@ function getRouteMap({
108998
108999
  },
108999
109000
  {
109000
109001
  path: "metadata/edit",
109001
- lazy: () => import("./reservation-metadata-6HKDMEUJ.mjs")
109002
+ lazy: () => import("./reservation-metadata-FEJR67UX.mjs")
109002
109003
  }
109003
109004
  ]
109004
109005
  }
@@ -109053,7 +109054,7 @@ function getRouteMap({
109053
109054
  },
109054
109055
  {
109055
109056
  path: "metadata/edit",
109056
- lazy: () => import("./inventory-metadata-IDXP72WU.mjs")
109057
+ lazy: () => import("./inventory-metadata-D3BK2JTS.mjs")
109057
109058
  },
109058
109059
  {
109059
109060
  path: "locations",
@@ -109145,7 +109146,7 @@ function getRouteMap({
109145
109146
  },
109146
109147
  {
109147
109148
  path: "metadata/edit",
109148
- lazy: () => import("./region-metadata-TL7FPABQ.mjs")
109149
+ lazy: () => import("./region-metadata-GBZ6EJ6S.mjs")
109149
109150
  }
109150
109151
  ]
109151
109152
  }
@@ -109193,7 +109194,7 @@ function getRouteMap({
109193
109194
  },
109194
109195
  {
109195
109196
  path: "metadata/edit",
109196
- lazy: () => import("./store-metadata-5BSUD7BG.mjs")
109197
+ lazy: () => import("./store-metadata-R5GNVTKR.mjs")
109197
109198
  }
109198
109199
  ]
109199
109200
  },
@@ -109244,7 +109245,7 @@ function getRouteMap({
109244
109245
  },
109245
109246
  {
109246
109247
  path: "metadata/edit",
109247
- lazy: () => import("./user-metadata-7FTXFRN3.mjs")
109248
+ lazy: () => import("./user-metadata-MJ33QWBH.mjs")
109248
109249
  }
109249
109250
  ]
109250
109251
  }
@@ -109430,7 +109431,7 @@ function getRouteMap({
109430
109431
  },
109431
109432
  {
109432
109433
  path: "metadata/edit",
109433
- lazy: () => import("./sales-channel-metadata-MDI7BZYK.mjs")
109434
+ lazy: () => import("./sales-channel-metadata-ANOPRPGB.mjs")
109434
109435
  }
109435
109436
  ]
109436
109437
  }
@@ -109485,7 +109486,7 @@ function getRouteMap({
109485
109486
  children: [
109486
109487
  {
109487
109488
  path: "metadata/edit",
109488
- lazy: () => import("./shipping-profile-metadata-BMEE45UH.mjs")
109489
+ lazy: () => import("./shipping-profile-metadata-WQIWJI7U.mjs")
109489
109490
  }
109490
109491
  ]
109491
109492
  }
@@ -109559,7 +109560,7 @@ function getRouteMap({
109559
109560
  },
109560
109561
  {
109561
109562
  path: "metadata/edit",
109562
- lazy: () => import("./location-metadata-76SDPEA7.mjs")
109563
+ lazy: () => import("./location-metadata-HY2NQ5AN.mjs")
109563
109564
  },
109564
109565
  {
109565
109566
  path: "fulfillment-set/:fset_id",
@@ -109619,7 +109620,7 @@ function getRouteMap({
109619
109620
  children: [
109620
109621
  {
109621
109622
  path: "",
109622
- lazy: () => import("./product-tag-list-WKDS5YFZ.mjs"),
109623
+ lazy: () => import("./product-tag-list-6RCS2J2L.mjs"),
109623
109624
  children: [
109624
109625
  {
109625
109626
  path: "create",
@@ -109647,7 +109648,7 @@ function getRouteMap({
109647
109648
  },
109648
109649
  {
109649
109650
  path: "metadata/edit",
109650
- lazy: () => import("./product-tag-metadata-BBA7EKMY.mjs")
109651
+ lazy: () => import("./product-tag-metadata-KD475YDG.mjs")
109651
109652
  }
109652
109653
  ]
109653
109654
  }
@@ -109727,7 +109728,7 @@ function getRouteMap({
109727
109728
  },
109728
109729
  {
109729
109730
  path: "metadata/edit",
109730
- lazy: () => import("./product-type-metadata-TY2QMFYM.mjs")
109731
+ lazy: () => import("./product-type-metadata-JTXNXUUG.mjs")
109731
109732
  }
109732
109733
  ]
109733
109734
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getLinkedFields
3
- } from "./chunk-3DAFXBA2.mjs";
3
+ } from "./chunk-6J7PJX4H.mjs";
4
4
 
5
5
  // src/routes/products/product-detail/constants.ts
6
6
  var PRODUCT_DETAIL_FIELDS = getLinkedFields(
@@ -116,6 +116,13 @@ var InnerForm = ({
116
116
  disabled: false
117
117
  });
118
118
  }
119
+ function addRow() {
120
+ insert(fields.length, {
121
+ key: "",
122
+ value: "",
123
+ disabled: false
124
+ });
125
+ }
119
126
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
120
127
  KeyboundForm,
121
128
  {
@@ -257,18 +264,30 @@ var InnerForm = ({
257
264
  }
258
265
  )
259
266
  ] }),
260
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
261
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
267
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
268
+ /* @__PURE__ */ jsx(
262
269
  Button,
263
270
  {
264
271
  size: "small",
265
272
  variant: "secondary",
266
273
  type: "button",
267
- disabled: isMutating,
268
- children: t("actions.cancel")
274
+ onClick: addRow,
275
+ children: t("metadata.edit.actions.addRow")
269
276
  }
270
- ) }),
271
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isMutating, children: t("actions.save") })
277
+ ),
278
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
279
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
280
+ Button,
281
+ {
282
+ size: "small",
283
+ variant: "secondary",
284
+ type: "button",
285
+ disabled: isMutating,
286
+ children: t("actions.cancel")
287
+ }
288
+ ) }),
289
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isMutating, children: t("actions.save") })
290
+ ] })
272
291
  ] }) })
273
292
  ]
274
293
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
package/dist/index.d.mts CHANGED
@@ -180,6 +180,7 @@ declare const resources: {
180
180
  insertRowAbove: string;
181
181
  insertRowBelow: string;
182
182
  deleteRow: string;
183
+ addRow: string;
183
184
  };
184
185
  labels: {
185
186
  key: string;
package/dist/index.d.ts CHANGED
@@ -180,6 +180,7 @@ declare const resources: {
180
180
  insertRowAbove: string;
181
181
  insertRowBelow: string;
182
182
  deleteRow: string;
183
+ addRow: string;
183
184
  };
184
185
  labels: {
185
186
  key: string;
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  FormExtensionZone,
13
13
  useExtendableForm
14
- } from "./chunk-3DAFXBA2.mjs";
14
+ } from "./chunk-6J7PJX4H.mjs";
15
15
  import "./chunk-ONB3JEHR.mjs";
16
16
  import "./chunk-JAW6ZD7F.mjs";
17
17
  import "./chunk-TO7QJZLE.mjs";
@@ -52,7 +52,7 @@ import {
52
52
  import {
53
53
  FormExtensionZone,
54
54
  useExtendableForm
55
- } from "./chunk-3DAFXBA2.mjs";
55
+ } from "./chunk-6J7PJX4H.mjs";
56
56
  import "./chunk-ONB3JEHR.mjs";
57
57
  import "./chunk-JAW6ZD7F.mjs";
58
58
  import "./chunk-TO7QJZLE.mjs";
@@ -1304,7 +1304,7 @@ var ProductCreateInventoryKitSection = ({
1304
1304
  });
1305
1305
  return /* @__PURE__ */ jsxs5("div", { id: "organize", className: "flex flex-col gap-y-8", children: [
1306
1306
  /* @__PURE__ */ jsx5(Heading3, { children: t("products.create.inventory.heading") }),
1307
- variants.fields.filter((v) => v.inventory_kit).map((variant, variantIndex) => /* @__PURE__ */ jsx5(
1307
+ variants.fields.map((variant, variantIndex) => ({ variant, variantIndex })).filter(({ variant }) => variant.inventory_kit).map(({ variant, variantIndex }) => /* @__PURE__ */ jsx5(
1308
1308
  VariantSection,
1309
1309
  {
1310
1310
  form,
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-AM2BU2RH.mjs";
14
14
  import {
15
15
  PRODUCT_DETAIL_FIELDS
16
- } from "./chunk-SRB46YCA.mjs";
16
+ } from "./chunk-7MZ3KZEC.mjs";
17
17
  import "./chunk-YOYOJU5D.mjs";
18
18
  import {
19
19
  SectionRow
@@ -22,7 +22,7 @@ import "./chunk-DG7J63J2.mjs";
22
22
  import {
23
23
  useDataTableDateFilters
24
24
  } from "./chunk-V2OKIIO7.mjs";
25
- import "./chunk-3DAFXBA2.mjs";
25
+ import "./chunk-6J7PJX4H.mjs";
26
26
  import "./chunk-ONB3JEHR.mjs";
27
27
  import "./chunk-JAW6ZD7F.mjs";
28
28
  import "./chunk-TO7QJZLE.mjs";
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  FormExtensionZone,
14
14
  useExtendableForm
15
- } from "./chunk-3DAFXBA2.mjs";
15
+ } from "./chunk-6J7PJX4H.mjs";
16
16
  import "./chunk-ONB3JEHR.mjs";
17
17
  import "./chunk-JAW6ZD7F.mjs";
18
18
  import "./chunk-TO7QJZLE.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PRODUCT_DETAIL_FIELDS
3
- } from "./chunk-SRB46YCA.mjs";
3
+ } from "./chunk-7MZ3KZEC.mjs";
4
4
  import {
5
5
  useComboboxData
6
6
  } from "./chunk-3TZOFKX2.mjs";
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-6HTZNHPT.mjs";
14
14
  import {
15
15
  useExtendableForm
16
- } from "./chunk-3DAFXBA2.mjs";
16
+ } from "./chunk-6J7PJX4H.mjs";
17
17
  import "./chunk-ONB3JEHR.mjs";
18
18
  import "./chunk-JAW6ZD7F.mjs";
19
19
  import "./chunk-TO7QJZLE.mjs";
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  FormExtensionZone,
16
16
  useExtendableForm
17
- } from "./chunk-3DAFXBA2.mjs";
17
+ } from "./chunk-6J7PJX4H.mjs";
18
18
  import "./chunk-ONB3JEHR.mjs";
19
19
  import "./chunk-JAW6ZD7F.mjs";
20
20
  import "./chunk-TO7QJZLE.mjs";
@@ -128,6 +128,7 @@ import {
128
128
  import "./chunk-QZ7TP4HQ.mjs";
129
129
 
130
130
  // src/routes/product-tags/product-tag-list/loader.ts
131
+ var QUERY_PREFIX = "ptag_";
131
132
  var productTagListQuery = (query) => ({
132
133
  queryKey: productTagsQueryKeys.list(query),
133
134
  queryFn: async () => sdk.admin.productTag.list(query)
@@ -136,10 +137,11 @@ var productTagListLoader = async ({ request }) => {
136
137
  const searchParams = new URL(request.url).searchParams;
137
138
  const queryObject = {};
138
139
  searchParams.forEach((value, key) => {
140
+ const field = key.startsWith(QUERY_PREFIX) ? key.slice(QUERY_PREFIX.length) : key;
139
141
  try {
140
- queryObject[key] = JSON.parse(value);
142
+ queryObject[field] = JSON.parse(value);
141
143
  } catch (_e) {
142
- queryObject[key] = value;
144
+ queryObject[field] = value;
143
145
  }
144
146
  });
145
147
  const query = productTagListQuery(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MetadataForm
3
- } from "./chunk-UEZBIZRM.mjs";
3
+ } from "./chunk-ENCSRL5P.mjs";
4
4
  import "./chunk-IUCDCPJU.mjs";
5
5
  import "./chunk-6HTZNHPT.mjs";
6
6
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
@@ -1,7 +1,7 @@
1
1
  import "./chunk-XRTVFYCW.mjs";
2
2
  import {
3
3
  MetadataForm
4
- } from "./chunk-UEZBIZRM.mjs";
4
+ } from "./chunk-ENCSRL5P.mjs";
5
5
  import "./chunk-IUCDCPJU.mjs";
6
6
  import "./chunk-6HTZNHPT.mjs";
7
7
  import "./chunk-LPEUYMRK.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/dashboard",
3
- "version": "2.20.1",
3
+ "version": "2.20.2-preview-20260904113944",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "scripts": {
6
6
  "typecheck": "tsgo --noEmit -p tsconfig.typecheck.json",
@@ -67,10 +67,10 @@
67
67
  "@dnd-kit/utilities": "^3.2.2",
68
68
  "@hookform/error-message": "^2.0.1",
69
69
  "@hookform/resolvers": "5.5.7",
70
- "@medusajs/admin-shared": "2.20.1",
71
- "@medusajs/icons": "2.20.1",
72
- "@medusajs/js-sdk": "2.20.1",
73
- "@medusajs/ui": "4.2.3",
70
+ "@medusajs/admin-shared": "2.20.2-preview-20260904113944",
71
+ "@medusajs/icons": "2.20.2-preview-20260904113944",
72
+ "@medusajs/js-sdk": "2.20.2-preview-20260904113944",
73
+ "@medusajs/ui": "4.2.4-preview-20260904113944",
74
74
  "@radix-ui/react-dialog": "1.1.4",
75
75
  "@radix-ui/react-dismissable-layer": "1.1.4",
76
76
  "@tanstack/react-query": "5.64.2",
@@ -102,10 +102,10 @@
102
102
  "zod": "4.2.0"
103
103
  },
104
104
  "devDependencies": {
105
- "@medusajs/admin-shared": "2.20.1",
106
- "@medusajs/admin-vite-plugin": "2.20.1",
107
- "@medusajs/types": "2.20.1",
108
- "@medusajs/ui-preset": "2.20.1",
105
+ "@medusajs/admin-shared": "2.20.2-preview-20260904113944",
106
+ "@medusajs/admin-vite-plugin": "2.20.2-preview-20260904113944",
107
+ "@medusajs/types": "2.20.2-preview-20260904113944",
108
+ "@medusajs/ui-preset": "2.20.2-preview-20260904113944",
109
109
  "@types/qrcode": "^1.5.5",
110
110
  "@typescript/native-preview": "^7.0.0-dev.20260423.1",
111
111
  "eslint": "8",
@@ -133,6 +133,14 @@ const InnerForm = <TRes,>({
133
133
  })
134
134
  }
135
135
 
136
+ function addRow() {
137
+ insert(fields.length, {
138
+ key: "",
139
+ value: "",
140
+ disabled: false,
141
+ })
142
+ }
143
+
136
144
  return (
137
145
  <RouteDrawer.Form form={form}>
138
146
  <KeyboundForm
@@ -271,20 +279,30 @@ const InnerForm = <TRes,>({
271
279
  )}
272
280
  </RouteDrawer.Body>
273
281
  <RouteDrawer.Footer>
274
- <div className="flex items-center justify-end gap-x-2">
275
- <RouteDrawer.Close asChild>
276
- <Button
277
- size="small"
278
- variant="secondary"
279
- type="button"
280
- disabled={isMutating}
281
- >
282
- {t("actions.cancel")}
283
- </Button>
284
- </RouteDrawer.Close>
285
- <Button size="small" type="submit" isLoading={isMutating}>
286
- {t("actions.save")}
282
+ <div className="flex items-center justify-between">
283
+ <Button
284
+ size="small"
285
+ variant="secondary"
286
+ type="button"
287
+ onClick={addRow}
288
+ >
289
+ {t("metadata.edit.actions.addRow")}
287
290
  </Button>
291
+ <div className="flex items-center gap-x-2">
292
+ <RouteDrawer.Close asChild>
293
+ <Button
294
+ size="small"
295
+ variant="secondary"
296
+ type="button"
297
+ disabled={isMutating}
298
+ >
299
+ {t("actions.cancel")}
300
+ </Button>
301
+ </RouteDrawer.Close>
302
+ <Button size="small" type="submit" isLoading={isMutating}>
303
+ {t("actions.save")}
304
+ </Button>
305
+ </div>
288
306
  </div>
289
307
  </RouteDrawer.Footer>
290
308
  </KeyboundForm>
@@ -408,9 +408,17 @@
408
408
  },
409
409
  "deleteRow": {
410
410
  "type": "string"
411
+ },
412
+ "addRow": {
413
+ "type": "string"
411
414
  }
412
415
  },
413
- "required": ["insertRowAbove", "insertRowBelow", "deleteRow"],
416
+ "required": [
417
+ "insertRowAbove",
418
+ "insertRowBelow",
419
+ "deleteRow",
420
+ "addRow"
421
+ ],
414
422
  "additionalProperties": false
415
423
  },
416
424
  "labels": {
@@ -91,7 +91,8 @@
91
91
  "actions": {
92
92
  "insertRowAbove": "Insert row above",
93
93
  "insertRowBelow": "Insert row below",
94
- "deleteRow": "Delete row"
94
+ "deleteRow": "Delete row",
95
+ "addRow": "Add row"
95
96
  },
96
97
  "labels": {
97
98
  "key": "Key",
@@ -0,0 +1,59 @@
1
+ import { LoaderFunctionArgs } from "react-router-dom"
2
+ import { beforeEach, describe, expect, it, vi } from "vitest"
3
+
4
+ import { productTagListLoader } from "../loader"
5
+
6
+ const { list } = vi.hoisted(() => ({ list: vi.fn() }))
7
+
8
+ vi.mock("../../../../hooks/api", () => ({
9
+ productTagsQueryKeys: {
10
+ list: (query?: object) => ["product_tags", "list", query],
11
+ },
12
+ }))
13
+
14
+ vi.mock("../../../../lib/client", () => ({
15
+ sdk: { admin: { productTag: { list } } },
16
+ }))
17
+
18
+ vi.mock("../../../../lib/query-client", () => ({
19
+ queryClient: {
20
+ getQueryData: () => undefined,
21
+ fetchQuery: ({ queryFn }: { queryFn: () => unknown }) => queryFn(),
22
+ },
23
+ }))
24
+
25
+ const loadProductTags = (url: string) =>
26
+ productTagListLoader({ request: new Request(url) } as LoaderFunctionArgs)
27
+
28
+ describe("productTagListLoader", () => {
29
+ beforeEach(() => {
30
+ list.mockReset()
31
+ list.mockResolvedValue({ product_tags: [], count: 0 })
32
+ })
33
+
34
+ it("strips the table's query prefix from the search params", async () => {
35
+ await loadProductTags(
36
+ "http://localhost/settings/product-tags?ptag_order=created_at"
37
+ )
38
+
39
+ expect(list).toHaveBeenCalledWith({ order: "created_at" })
40
+ })
41
+
42
+ it("parses prefixed filter values", async () => {
43
+ const created_at = { $gte: "2026-01-01" }
44
+
45
+ await loadProductTags(
46
+ `http://localhost/settings/product-tags?ptag_created_at=${encodeURIComponent(
47
+ JSON.stringify(created_at)
48
+ )}`
49
+ )
50
+
51
+ expect(list).toHaveBeenCalledWith({ created_at })
52
+ })
53
+
54
+ it("leaves unprefixed search params untouched", async () => {
55
+ await loadProductTags("http://localhost/settings/product-tags?order=value")
56
+
57
+ expect(list).toHaveBeenCalledWith({ order: "value" })
58
+ })
59
+ })
@@ -5,6 +5,8 @@ import { productTagsQueryKeys } from "../../../hooks/api"
5
5
  import { sdk } from "../../../lib/client"
6
6
  import { queryClient } from "../../../lib/query-client"
7
7
 
8
+ const QUERY_PREFIX = "ptag_"
9
+
8
10
  const productTagListQuery = (query?: HttpTypes.AdminProductTagListParams) => ({
9
11
  queryKey: productTagsQueryKeys.list(query),
10
12
  queryFn: async () => sdk.admin.productTag.list(query),
@@ -16,10 +18,14 @@ export const productTagListLoader = async ({ request }: LoaderFunctionArgs) => {
16
18
  const queryObject: Record<string, string> = {}
17
19
 
18
20
  searchParams.forEach((value, key) => {
21
+ const field = key.startsWith(QUERY_PREFIX)
22
+ ? key.slice(QUERY_PREFIX.length)
23
+ : key
24
+
19
25
  try {
20
- queryObject[key] = JSON.parse(value)
26
+ queryObject[field] = JSON.parse(value)
21
27
  } catch (_e) {
22
- queryObject[key] = value
28
+ queryObject[field] = value
23
29
  }
24
30
  })
25
31
 
@@ -0,0 +1,115 @@
1
+ // @vitest-environment jsdom
2
+ import React from "react"
3
+ import { fireEvent, render, screen } from "@testing-library/react"
4
+ import { useForm, UseFormReturn } from "react-hook-form"
5
+ import { describe, expect, it, vi } from "vitest"
6
+
7
+ import { ProductCreateSchemaType } from "../../../../types"
8
+ import { ProductCreateInventoryKitSection } from "./product-create-inventory-kit-section"
9
+
10
+ vi.mock("react-i18next", () => ({
11
+ useTranslation: () => ({
12
+ t: (key: string) => key,
13
+ }),
14
+ }))
15
+
16
+ vi.mock("@medusajs/icons", () => ({
17
+ XMarkMini: () => <svg />,
18
+ }))
19
+
20
+ vi.mock("@medusajs/ui", () => ({
21
+ Button: ({ children, ...props }: React.ComponentProps<"button">) => (
22
+ <button {...props}>{children}</button>
23
+ ),
24
+ Heading: ({ children }: { children: React.ReactNode }) => <h2>{children}</h2>,
25
+ IconButton: ({ children, ...props }: React.ComponentProps<"button">) => (
26
+ <button {...props}>{children}</button>
27
+ ),
28
+ Input: (props: React.ComponentProps<"input">) => <input {...props} />,
29
+ Label: ({ children }: { children: React.ReactNode }) => (
30
+ <label>{children}</label>
31
+ ),
32
+ }))
33
+
34
+ vi.mock("../../../../../../../components/common/form", () => ({
35
+ Form: {
36
+ Label: ({ children }: { children: React.ReactNode }) => (
37
+ <label>{children}</label>
38
+ ),
39
+ Hint: ({ children }: { children: React.ReactNode }) => (
40
+ <span>{children}</span>
41
+ ),
42
+ Field: ({
43
+ render,
44
+ }: {
45
+ render: (props: { field: object }) => React.ReactNode
46
+ }) => <>{render({ field: {} })}</>,
47
+ Item: ({ children }: { children: React.ReactNode }) => (
48
+ <div>{children}</div>
49
+ ),
50
+ Control: ({ children }: { children: React.ReactNode }) => <>{children}</>,
51
+ ErrorMessage: () => null,
52
+ },
53
+ }))
54
+
55
+ vi.mock("../../../../../../../components/inputs/combobox", () => ({
56
+ Combobox: () => <div />,
57
+ }))
58
+
59
+ vi.mock("../../../../../../../hooks/use-combobox-data", () => ({
60
+ useComboboxData: () => ({
61
+ options: [],
62
+ searchValue: "",
63
+ onSearchValueChange: vi.fn(),
64
+ fetchNextPage: vi.fn(),
65
+ }),
66
+ }))
67
+
68
+ vi.mock("../../../../../../../lib/client", () => ({
69
+ sdk: {
70
+ admin: {
71
+ inventoryItem: {
72
+ list: vi.fn(),
73
+ },
74
+ },
75
+ },
76
+ }))
77
+
78
+ describe("ProductCreateInventoryKitSection", () => {
79
+ it("adds inventory to the original variant when earlier variants are filtered out", () => {
80
+ let form: UseFormReturn<ProductCreateSchemaType>
81
+
82
+ function TestComponent() {
83
+ form = useForm<ProductCreateSchemaType>({
84
+ defaultValues: {
85
+ variants: [
86
+ {
87
+ title: "Regular variant",
88
+ inventory_kit: false,
89
+ inventory: [],
90
+ },
91
+ {
92
+ title: "Inventory kit variant",
93
+ inventory_kit: true,
94
+ inventory: [],
95
+ },
96
+ ],
97
+ },
98
+ })
99
+
100
+ return <ProductCreateInventoryKitSection form={form} />
101
+ }
102
+
103
+ render(<TestComponent />)
104
+
105
+ fireEvent.click(screen.getByRole("button", { name: "actions.add" }))
106
+
107
+ expect(form!.getValues("variants.0.inventory")).toEqual([])
108
+ expect(form!.getValues("variants.1.inventory")).toEqual([
109
+ {
110
+ inventory_item_id: "",
111
+ required_quantity: "",
112
+ },
113
+ ])
114
+ })
115
+ })
@@ -236,8 +236,9 @@ export const ProductCreateInventoryKitSection = ({
236
236
  <Heading>{t("products.create.inventory.heading")}</Heading>
237
237
 
238
238
  {variants.fields
239
- .filter((v) => v.inventory_kit)
240
- .map((variant, variantIndex) => (
239
+ .map((variant, variantIndex) => ({ variant, variantIndex }))
240
+ .filter(({ variant }) => variant.inventory_kit)
241
+ .map(({ variant, variantIndex }) => (
241
242
  <VariantSection
242
243
  key={variant.id}
243
244
  form={form}