@medusajs/draft-order 2.11.0-snapshot-20250828185926 → 2.11.0-snapshot-20251014110210

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.
@@ -352,7 +352,7 @@ const DataTableAction = ({
352
352
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { ...buttonProps, onClick: props.onClick, children: label });
353
353
  };
354
354
  const sdk = new Medusa__default.default({
355
- baseUrl: "/",
355
+ baseUrl: __BACKEND_URL__ || "/",
356
356
  auth: {
357
357
  type: "session"
358
358
  }
@@ -7573,12 +7573,12 @@ const addressSchema = objectType({
7573
7573
  first_name: stringType().min(1),
7574
7574
  last_name: stringType().min(1),
7575
7575
  address_1: stringType().min(1),
7576
- address_2: stringType().optional(),
7577
- company: stringType().optional(),
7576
+ address_2: stringType().nullish(),
7577
+ company: stringType().nullish(),
7578
7578
  city: stringType().min(1),
7579
- province: stringType().optional(),
7579
+ province: stringType().nullish(),
7580
7580
  postal_code: stringType().min(1),
7581
- phone: stringType().optional()
7581
+ phone: stringType().nullish()
7582
7582
  });
7583
7583
  const Create = () => {
7584
7584
  return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: /* @__PURE__ */ jsxRuntime.jsx(CreateForm, {}) });
@@ -8328,7 +8328,7 @@ const ActivitySection = ({ order, changes }) => {
8328
8328
  () => getActivityItems(order, changes),
8329
8329
  [order, changes]
8330
8330
  );
8331
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0 overflow-hidden", children: [
8331
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "overflow-hidden p-0", children: [
8332
8332
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Activity" }) }),
8333
8333
  /* @__PURE__ */ jsxRuntime.jsx(ActivityItemList, { items: activityItems })
8334
8334
  ] });
@@ -8359,8 +8359,8 @@ const CollapsibleActivityItemList = ({
8359
8359
  const [open, setOpen] = React.useState(false);
8360
8360
  return /* @__PURE__ */ jsxRuntime.jsxs(radixUi.Collapsible.Root, { open, onOpenChange: setOpen, children: [
8361
8361
  !open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
8362
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y bg-clip-content" }) }),
8363
- /* @__PURE__ */ jsxRuntime.jsx(radixUi.Collapsible.Trigger, { className: "text-left p-0 m-0 pb-4 text-ui-fg-muted hover:text-ui-fg-base focus:text-ui-fg-base outline-none transition-colors", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", weight: "plus", children: `Show ${items.length} more ${items.length === 1 ? "activity" : "activities"}` }) })
8362
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-clip-content bg-right bg-repeat-y" }) }),
8363
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Collapsible.Trigger, { className: "text-ui-fg-muted hover:text-ui-fg-base focus:text-ui-fg-base m-0 p-0 pb-4 text-left outline-none transition-colors", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", weight: "plus", children: `Show ${items.length} more ${items.length === 1 ? "activity" : "activities"}` }) })
8364
8364
  ] }),
8365
8365
  /* @__PURE__ */ jsxRuntime.jsx(radixUi.Collapsible.Content, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-0.5", children: items.map((item, idx) => {
8366
8366
  return /* @__PURE__ */ jsxRuntime.jsx(ActivityItem, { item }, idx);
@@ -8378,14 +8378,14 @@ const ActivityItem = ({ item, isFirst = false }) => {
8378
8378
  return /* @__PURE__ */ jsxRuntime.jsxs(
8379
8379
  "div",
8380
8380
  {
8381
- className: ui.clx("grid grid-cols-[20px_1fr] items-start gap-x-2 w-full"),
8381
+ className: ui.clx("grid w-full grid-cols-[20px_1fr] items-start gap-x-2"),
8382
8382
  children: [
8383
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-0.5 h-full", children: [
8384
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-5 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-2.5 rounded-full shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-1.5 rounded-full bg-ui-tag-neutral-icon" }) }) }),
8385
- !isFirst && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-px bg-ui-border-base" }) })
8383
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col items-center gap-0.5", children: [
8384
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shadow-borders-base flex size-2.5 items-center justify-center rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-neutral-icon size-1.5 rounded-full" }) }) }),
8385
+ !isFirst && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-border-base h-full w-px" }) })
8386
8386
  ] }),
8387
8387
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.clx("flex flex-col", !isFirst && "pb-4"), children: [
8388
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-between", children: [
8388
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
8389
8389
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.label }),
8390
8390
  /* @__PURE__ */ jsxRuntime.jsx(
8391
8391
  ui.Tooltip,
@@ -8396,7 +8396,7 @@ const ActivityItem = ({ item, isFirst = false }) => {
8396
8396
  )
8397
8397
  ] }),
8398
8398
  item.content && renderContent(item.content),
8399
- item.userId && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2 text-ui-fg-muted", children: isUserLoaded ? /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { to: `/settings/users/${user.id}`, className: "w-fit", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1.5 w-fit", children: [
8399
+ item.userId && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-muted pt-2", children: isUserLoaded ? /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { to: `/settings/users/${user.id}`, className: "w-fit", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-fit items-center gap-x-1.5", children: [
8400
8400
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: "By" }),
8401
8401
  /* @__PURE__ */ jsxRuntime.jsx(
8402
8402
  ui.Avatar,
@@ -8412,8 +8412,8 @@ const ActivityItem = ({ item, isFirst = false }) => {
8412
8412
  ] })
8413
8413
  ] }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1.5", children: [
8414
8414
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: "By" }),
8415
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "rounded-full w-5 h-5" }),
8416
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "w-[75px] h-4" })
8415
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-5 w-5 rounded-full" }),
8416
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-4 w-[75px]" })
8417
8417
  ] }) })
8418
8418
  ] })
8419
8419
  ]
@@ -8436,7 +8436,12 @@ function getEditActivityItems(change) {
8436
8436
  promotionsAdded: 0,
8437
8437
  promotionsRemoved: 0
8438
8438
  };
8439
- for (const action of change.actions) {
8439
+ const orderedActions = change.actions.sort((a, b) => {
8440
+ return a.ordering - b.ordering;
8441
+ });
8442
+ const addedPromotionMap = /* @__PURE__ */ new Map();
8443
+ const removedPromotionMap = /* @__PURE__ */ new Map();
8444
+ for (const action of orderedActions) {
8440
8445
  if (!action.details) {
8441
8446
  continue;
8442
8447
  }
@@ -8454,13 +8459,21 @@ function getEditActivityItems(change) {
8454
8459
  case "SHIPPING_REMOVE":
8455
8460
  counts.shippingMethodsRemoved += 1;
8456
8461
  break;
8457
- case "PROMOTION_ADD":
8458
- counts.promotionsAdded += 1;
8462
+ case "PROMOTION_ADD": {
8463
+ addedPromotionMap.set(action.reference_id, true);
8459
8464
  break;
8460
- case "PROMOTION_REMOVE":
8461
- counts.promotionsRemoved += 1;
8465
+ }
8466
+ case "PROMOTION_REMOVE": {
8467
+ if (addedPromotionMap.has(action.reference_id)) {
8468
+ addedPromotionMap.delete(action.reference_id);
8469
+ } else {
8470
+ removedPromotionMap.set(action.reference_id, true);
8471
+ }
8462
8472
  break;
8473
+ }
8463
8474
  }
8475
+ counts.promotionsAdded = addedPromotionMap.size;
8476
+ counts.promotionsRemoved = removedPromotionMap.size;
8464
8477
  }
8465
8478
  const createActivityItem = (type, added, removed) => {
8466
8479
  if (added === 0 && removed === 0) return;
@@ -10122,7 +10135,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
10122
10135
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
10123
10136
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10124
10137
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Items" }) }),
10125
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order." }) })
10138
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order" }) })
10126
10139
  ] }),
10127
10140
  /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10128
10141
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
@@ -10163,13 +10176,13 @@ const ItemsForm = ({ preview, currencyCode }) => {
10163
10176
  ] })
10164
10177
  ] }),
10165
10178
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
10166
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_1fr_1fr_28px] gap-3 px-4 py-2 text-ui-fg-muted", children: [
10179
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-muted grid grid-cols-[2fr_1fr_2fr_28px] gap-3 px-4 py-2", children: [
10167
10180
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
10168
10181
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) }),
10169
10182
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Price" }) }),
10170
10183
  /* @__PURE__ */ jsxRuntime.jsx("div", {})
10171
10184
  ] }) }),
10172
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
10185
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
10173
10186
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "There are no items in this order" }),
10174
10187
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add items to the order to get started." })
10175
10188
  ] }) : matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -10180,7 +10193,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
10180
10193
  currencyCode
10181
10194
  },
10182
10195
  item.id
10183
- )) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
10196
+ )) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
10184
10197
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
10185
10198
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
10186
10199
  'No items found for "',
@@ -10219,7 +10232,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
10219
10232
  ]
10220
10233
  }
10221
10234
  ) }),
10222
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10235
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10223
10236
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10224
10237
  /* @__PURE__ */ jsxRuntime.jsx(
10225
10238
  ui.Button,
@@ -10295,8 +10308,8 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10295
10308
  }
10296
10309
  );
10297
10310
  });
10298
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
10299
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full", children: [
10311
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
10312
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-x-3", children: [
10300
10313
  /* @__PURE__ */ jsxRuntime.jsx(
10301
10314
  Thumbnail,
10302
10315
  {
@@ -10332,7 +10345,7 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10332
10345
  )
10333
10346
  ] })
10334
10347
  ] }),
10335
- editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
10348
+ editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
10336
10349
  Form$2.Field,
10337
10350
  {
10338
10351
  control: form.control,
@@ -10341,8 +10354,8 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10341
10354
  return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
10342
10355
  }
10343
10356
  }
10344
- ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }) }),
10345
- editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
10357
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }) }),
10358
+ editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
10346
10359
  Form$2.Field,
10347
10360
  {
10348
10361
  control: form.control,
@@ -10359,7 +10372,7 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10359
10372
  ) }) });
10360
10373
  }
10361
10374
  }
10362
- ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-end w-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10375
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-1 items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10363
10376
  /* @__PURE__ */ jsxRuntime.jsx(
10364
10377
  ui.IconButton,
10365
10378
  {
@@ -10454,7 +10467,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
10454
10467
  }
10455
10468
  );
10456
10469
  });
10457
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
10470
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
10458
10471
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
10459
10472
  /* @__PURE__ */ jsxRuntime.jsx(
10460
10473
  Thumbnail,
@@ -10501,7 +10514,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
10501
10514
  ) }) });
10502
10515
  }
10503
10516
  }
10504
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10517
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10505
10518
  /* @__PURE__ */ jsxRuntime.jsx(
10506
10519
  ui.IconButton,
10507
10520
  {
@@ -10626,7 +10639,7 @@ const ExistingItemsForm = ({ orderId, items }) => {
10626
10639
  autoFocusSearch: true
10627
10640
  }
10628
10641
  ) }),
10629
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10642
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10630
10643
  /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10631
10644
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Update items" })
10632
10645
  ] }) })
@@ -10794,15 +10807,15 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10794
10807
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
10795
10808
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10796
10809
  ] }),
10797
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 w-full", children: [
10798
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10810
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
10811
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10799
10812
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10800
10813
  ] })
10801
10814
  ] }) })
10802
10815
  }
10803
10816
  )
10804
10817
  ] }) }) }),
10805
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10818
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10806
10819
  /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10807
10820
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10808
10821
  ] }) })
@@ -11207,22 +11220,22 @@ const PromotionForm = ({ preview }) => {
11207
11220
  const [comboboxValue, setComboboxValue] = React.useState("");
11208
11221
  const { handleSuccess } = useRouteModal();
11209
11222
  const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
11210
- const promoCodes = getPromotionCodes(items, shipping_methods);
11223
+ const promoIds = getPromotionIds(items, shipping_methods);
11211
11224
  const { promotions, isPending, isError, error } = usePromotions(
11212
11225
  {
11213
- code: promoCodes
11226
+ id: promoIds
11214
11227
  },
11215
11228
  {
11216
- enabled: !!promoCodes.length
11229
+ enabled: !!promoIds.length
11217
11230
  }
11218
11231
  );
11219
11232
  const comboboxData = useComboboxData({
11220
- queryKey: ["promotions", "combobox", promoCodes],
11233
+ queryKey: ["promotions", "combobox", promoIds],
11221
11234
  queryFn: async (params) => {
11222
11235
  return await sdk.admin.promotion.list({
11223
11236
  ...params,
11224
- code: {
11225
- $nin: promoCodes
11237
+ id: {
11238
+ $nin: promoIds
11226
11239
  }
11227
11240
  });
11228
11241
  },
@@ -11358,7 +11371,7 @@ const PromotionItem = ({
11358
11371
  "div",
11359
11372
  {
11360
11373
  className: ui.clx(
11361
- "px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
11374
+ "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11362
11375
  {
11363
11376
  "animate-pulse": isLoading
11364
11377
  }
@@ -11366,7 +11379,7 @@ const PromotionItem = ({
11366
11379
  children: [
11367
11380
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11368
11381
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11369
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
11382
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11370
11383
  displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
11371
11384
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
11372
11385
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
@@ -11418,13 +11431,13 @@ const formatPercentage = (value, isPercentageValue = false) => {
11418
11431
  }
11419
11432
  return formatter.format(val);
11420
11433
  };
11421
- function getPromotionCodes(items, shippingMethods) {
11422
- const codes = /* @__PURE__ */ new Set();
11434
+ function getPromotionIds(items, shippingMethods) {
11435
+ const promotionIds = /* @__PURE__ */ new Set();
11423
11436
  for (const item of items) {
11424
11437
  if (item.adjustments) {
11425
11438
  for (const adjustment of item.adjustments) {
11426
- if (adjustment.code) {
11427
- codes.add(adjustment.code);
11439
+ if (adjustment.promotion_id) {
11440
+ promotionIds.add(adjustment.promotion_id);
11428
11441
  }
11429
11442
  }
11430
11443
  }
@@ -11432,13 +11445,13 @@ function getPromotionCodes(items, shippingMethods) {
11432
11445
  for (const shippingMethod of shippingMethods) {
11433
11446
  if (shippingMethod.adjustments) {
11434
11447
  for (const adjustment of shippingMethod.adjustments) {
11435
- if (adjustment.code) {
11436
- codes.add(adjustment.code);
11448
+ if (adjustment.promotion_id) {
11449
+ promotionIds.add(adjustment.promotion_id);
11437
11450
  }
11438
11451
  }
11439
11452
  }
11440
11453
  }
11441
- return Array.from(codes);
11454
+ return Array.from(promotionIds);
11442
11455
  }
11443
11456
  const SalesChannel = () => {
11444
11457
  const { id } = reactRouterDom.useParams();
@@ -346,7 +346,7 @@ const DataTableAction = ({
346
346
  return /* @__PURE__ */ jsx(Button, { ...buttonProps, onClick: props.onClick, children: label });
347
347
  };
348
348
  const sdk = new Medusa({
349
- baseUrl: "/",
349
+ baseUrl: __BACKEND_URL__ || "/",
350
350
  auth: {
351
351
  type: "session"
352
352
  }
@@ -7567,12 +7567,12 @@ const addressSchema = objectType({
7567
7567
  first_name: stringType().min(1),
7568
7568
  last_name: stringType().min(1),
7569
7569
  address_1: stringType().min(1),
7570
- address_2: stringType().optional(),
7571
- company: stringType().optional(),
7570
+ address_2: stringType().nullish(),
7571
+ company: stringType().nullish(),
7572
7572
  city: stringType().min(1),
7573
- province: stringType().optional(),
7573
+ province: stringType().nullish(),
7574
7574
  postal_code: stringType().min(1),
7575
- phone: stringType().optional()
7575
+ phone: stringType().nullish()
7576
7576
  });
7577
7577
  const Create = () => {
7578
7578
  return /* @__PURE__ */ jsx(RouteFocusModal, { children: /* @__PURE__ */ jsx(CreateForm, {}) });
@@ -8322,7 +8322,7 @@ const ActivitySection = ({ order, changes }) => {
8322
8322
  () => getActivityItems(order, changes),
8323
8323
  [order, changes]
8324
8324
  );
8325
- return /* @__PURE__ */ jsxs(Container, { className: "p-0 overflow-hidden", children: [
8325
+ return /* @__PURE__ */ jsxs(Container, { className: "overflow-hidden p-0", children: [
8326
8326
  /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(Heading, { children: "Activity" }) }),
8327
8327
  /* @__PURE__ */ jsx(ActivityItemList, { items: activityItems })
8328
8328
  ] });
@@ -8353,8 +8353,8 @@ const CollapsibleActivityItemList = ({
8353
8353
  const [open, setOpen] = useState(false);
8354
8354
  return /* @__PURE__ */ jsxs(Collapsible.Root, { open, onOpenChange: setOpen, children: [
8355
8355
  !open && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
8356
- /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y bg-clip-content" }) }),
8357
- /* @__PURE__ */ jsx(Collapsible.Trigger, { className: "text-left p-0 m-0 pb-4 text-ui-fg-muted hover:text-ui-fg-base focus:text-ui-fg-base outline-none transition-colors", children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: `Show ${items.length} more ${items.length === 1 ? "activity" : "activities"}` }) })
8356
+ /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-clip-content bg-right bg-repeat-y" }) }),
8357
+ /* @__PURE__ */ jsx(Collapsible.Trigger, { className: "text-ui-fg-muted hover:text-ui-fg-base focus:text-ui-fg-base m-0 p-0 pb-4 text-left outline-none transition-colors", children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: `Show ${items.length} more ${items.length === 1 ? "activity" : "activities"}` }) })
8358
8358
  ] }),
8359
8359
  /* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-0.5", children: items.map((item, idx) => {
8360
8360
  return /* @__PURE__ */ jsx(ActivityItem, { item }, idx);
@@ -8372,14 +8372,14 @@ const ActivityItem = ({ item, isFirst = false }) => {
8372
8372
  return /* @__PURE__ */ jsxs(
8373
8373
  "div",
8374
8374
  {
8375
- className: clx("grid grid-cols-[20px_1fr] items-start gap-x-2 w-full"),
8375
+ className: clx("grid w-full grid-cols-[20px_1fr] items-start gap-x-2"),
8376
8376
  children: [
8377
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-0.5 h-full", children: [
8378
- /* @__PURE__ */ jsx("div", { className: "size-5 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "size-2.5 rounded-full shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "size-1.5 rounded-full bg-ui-tag-neutral-icon" }) }) }),
8379
- !isFirst && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "h-full w-px bg-ui-border-base" }) })
8377
+ /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col items-center gap-0.5", children: [
8378
+ /* @__PURE__ */ jsx("div", { className: "flex size-5 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "shadow-borders-base flex size-2.5 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-tag-neutral-icon size-1.5 rounded-full" }) }) }),
8379
+ !isFirst && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-border-base h-full w-px" }) })
8380
8380
  ] }),
8381
8381
  /* @__PURE__ */ jsxs("div", { className: clx("flex flex-col", !isFirst && "pb-4"), children: [
8382
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-between", children: [
8382
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
8383
8383
  /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.label }),
8384
8384
  /* @__PURE__ */ jsx(
8385
8385
  Tooltip,
@@ -8390,7 +8390,7 @@ const ActivityItem = ({ item, isFirst = false }) => {
8390
8390
  )
8391
8391
  ] }),
8392
8392
  item.content && renderContent(item.content),
8393
- item.userId && /* @__PURE__ */ jsx("div", { className: "pt-2 text-ui-fg-muted", children: isUserLoaded ? /* @__PURE__ */ jsx(Link, { to: `/settings/users/${user.id}`, className: "w-fit", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1.5 w-fit", children: [
8393
+ item.userId && /* @__PURE__ */ jsx("div", { className: "text-ui-fg-muted pt-2", children: isUserLoaded ? /* @__PURE__ */ jsx(Link, { to: `/settings/users/${user.id}`, className: "w-fit", children: /* @__PURE__ */ jsxs("div", { className: "flex w-fit items-center gap-x-1.5", children: [
8394
8394
  /* @__PURE__ */ jsx(Text, { size: "small", children: "By" }),
8395
8395
  /* @__PURE__ */ jsx(
8396
8396
  Avatar,
@@ -8406,8 +8406,8 @@ const ActivityItem = ({ item, isFirst = false }) => {
8406
8406
  ] })
8407
8407
  ] }) }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1.5", children: [
8408
8408
  /* @__PURE__ */ jsx(Text, { size: "small", children: "By" }),
8409
- /* @__PURE__ */ jsx(Skeleton, { className: "rounded-full w-5 h-5" }),
8410
- /* @__PURE__ */ jsx(Skeleton, { className: "w-[75px] h-4" })
8409
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-5 rounded-full" }),
8410
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-[75px]" })
8411
8411
  ] }) })
8412
8412
  ] })
8413
8413
  ]
@@ -8430,7 +8430,12 @@ function getEditActivityItems(change) {
8430
8430
  promotionsAdded: 0,
8431
8431
  promotionsRemoved: 0
8432
8432
  };
8433
- for (const action of change.actions) {
8433
+ const orderedActions = change.actions.sort((a, b) => {
8434
+ return a.ordering - b.ordering;
8435
+ });
8436
+ const addedPromotionMap = /* @__PURE__ */ new Map();
8437
+ const removedPromotionMap = /* @__PURE__ */ new Map();
8438
+ for (const action of orderedActions) {
8434
8439
  if (!action.details) {
8435
8440
  continue;
8436
8441
  }
@@ -8448,13 +8453,21 @@ function getEditActivityItems(change) {
8448
8453
  case "SHIPPING_REMOVE":
8449
8454
  counts.shippingMethodsRemoved += 1;
8450
8455
  break;
8451
- case "PROMOTION_ADD":
8452
- counts.promotionsAdded += 1;
8456
+ case "PROMOTION_ADD": {
8457
+ addedPromotionMap.set(action.reference_id, true);
8453
8458
  break;
8454
- case "PROMOTION_REMOVE":
8455
- counts.promotionsRemoved += 1;
8459
+ }
8460
+ case "PROMOTION_REMOVE": {
8461
+ if (addedPromotionMap.has(action.reference_id)) {
8462
+ addedPromotionMap.delete(action.reference_id);
8463
+ } else {
8464
+ removedPromotionMap.set(action.reference_id, true);
8465
+ }
8456
8466
  break;
8467
+ }
8457
8468
  }
8469
+ counts.promotionsAdded = addedPromotionMap.size;
8470
+ counts.promotionsRemoved = removedPromotionMap.size;
8458
8471
  }
8459
8472
  const createActivityItem = (type, added, removed) => {
8460
8473
  if (added === 0 && removed === 0) return;
@@ -10116,7 +10129,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
10116
10129
  /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
10117
10130
  /* @__PURE__ */ jsxs("div", { children: [
10118
10131
  /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Items" }) }),
10119
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order." }) })
10132
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order" }) })
10120
10133
  ] }),
10121
10134
  /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
10122
10135
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
@@ -10157,13 +10170,13 @@ const ItemsForm = ({ preview, currencyCode }) => {
10157
10170
  ] })
10158
10171
  ] }),
10159
10172
  /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
10160
- /* @__PURE__ */ jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[1fr_1fr_1fr_28px] gap-3 px-4 py-2 text-ui-fg-muted", children: [
10173
+ /* @__PURE__ */ jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-muted grid grid-cols-[2fr_1fr_2fr_28px] gap-3 px-4 py-2", children: [
10161
10174
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
10162
10175
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) }),
10163
10176
  /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Price" }) }),
10164
10177
  /* @__PURE__ */ jsx("div", {})
10165
10178
  ] }) }),
10166
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
10179
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
10167
10180
  /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "There are no items in this order" }),
10168
10181
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add items to the order to get started." })
10169
10182
  ] }) : matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsx(
@@ -10174,7 +10187,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
10174
10187
  currencyCode
10175
10188
  },
10176
10189
  item.id
10177
- )) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
10190
+ )) : /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
10178
10191
  /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
10179
10192
  /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
10180
10193
  'No items found for "',
@@ -10213,7 +10226,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
10213
10226
  ]
10214
10227
  }
10215
10228
  ) }),
10216
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10229
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10217
10230
  /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10218
10231
  /* @__PURE__ */ jsx(
10219
10232
  Button,
@@ -10289,8 +10302,8 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10289
10302
  }
10290
10303
  );
10291
10304
  });
10292
- return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
10293
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3 w-full", children: [
10305
+ return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
10306
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-x-3", children: [
10294
10307
  /* @__PURE__ */ jsx(
10295
10308
  Thumbnail,
10296
10309
  {
@@ -10326,7 +10339,7 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10326
10339
  )
10327
10340
  ] })
10328
10341
  ] }),
10329
- editing ? /* @__PURE__ */ jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsx(
10342
+ editing ? /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(
10330
10343
  Form$2.Field,
10331
10344
  {
10332
10345
  control: form.control,
@@ -10335,8 +10348,8 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10335
10348
  return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(NumberInput, { ...field }) }) });
10336
10349
  }
10337
10350
  }
10338
- ) }) : /* @__PURE__ */ jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: item.quantity }) }),
10339
- editing ? /* @__PURE__ */ jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsx(
10351
+ ) }) : /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: item.quantity }) }),
10352
+ editing ? /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(
10340
10353
  Form$2.Field,
10341
10354
  {
10342
10355
  control: form.control,
@@ -10353,7 +10366,7 @@ const VariantItem = ({ item, preview, currencyCode }) => {
10353
10366
  ) }) });
10354
10367
  }
10355
10368
  }
10356
- ) }) : /* @__PURE__ */ jsx("div", { className: "flex-1 flex items-center justify-end w-full", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10369
+ ) }) : /* @__PURE__ */ jsx("div", { className: "flex w-full flex-1 items-center justify-end", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10357
10370
  /* @__PURE__ */ jsx(
10358
10371
  IconButton,
10359
10372
  {
@@ -10448,7 +10461,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
10448
10461
  }
10449
10462
  );
10450
10463
  });
10451
- return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
10464
+ return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
10452
10465
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
10453
10466
  /* @__PURE__ */ jsx(
10454
10467
  Thumbnail,
@@ -10495,7 +10508,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
10495
10508
  ) }) });
10496
10509
  }
10497
10510
  }
10498
- ) : /* @__PURE__ */ jsx("div", { className: "flex-1 flex items-center justify-end", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10511
+ ) : /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-end", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
10499
10512
  /* @__PURE__ */ jsx(
10500
10513
  IconButton,
10501
10514
  {
@@ -10620,7 +10633,7 @@ const ExistingItemsForm = ({ orderId, items }) => {
10620
10633
  autoFocusSearch: true
10621
10634
  }
10622
10635
  ) }),
10623
- /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10636
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10624
10637
  /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10625
10638
  /* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Update items" })
10626
10639
  ] }) })
@@ -10788,15 +10801,15 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10788
10801
  /* @__PURE__ */ jsx(Form$2.Label, { children: "Quantity" }),
10789
10802
  /* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10790
10803
  ] }),
10791
- /* @__PURE__ */ jsxs("div", { className: "flex-1 w-full", children: [
10792
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10804
+ /* @__PURE__ */ jsxs("div", { className: "w-full flex-1", children: [
10805
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10793
10806
  /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
10794
10807
  ] })
10795
10808
  ] }) })
10796
10809
  }
10797
10810
  )
10798
10811
  ] }) }) }),
10799
- /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
10812
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10800
10813
  /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10801
10814
  /* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10802
10815
  ] }) })
@@ -11201,22 +11214,22 @@ const PromotionForm = ({ preview }) => {
11201
11214
  const [comboboxValue, setComboboxValue] = useState("");
11202
11215
  const { handleSuccess } = useRouteModal();
11203
11216
  const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
11204
- const promoCodes = getPromotionCodes(items, shipping_methods);
11217
+ const promoIds = getPromotionIds(items, shipping_methods);
11205
11218
  const { promotions, isPending, isError, error } = usePromotions(
11206
11219
  {
11207
- code: promoCodes
11220
+ id: promoIds
11208
11221
  },
11209
11222
  {
11210
- enabled: !!promoCodes.length
11223
+ enabled: !!promoIds.length
11211
11224
  }
11212
11225
  );
11213
11226
  const comboboxData = useComboboxData({
11214
- queryKey: ["promotions", "combobox", promoCodes],
11227
+ queryKey: ["promotions", "combobox", promoIds],
11215
11228
  queryFn: async (params) => {
11216
11229
  return await sdk.admin.promotion.list({
11217
11230
  ...params,
11218
- code: {
11219
- $nin: promoCodes
11231
+ id: {
11232
+ $nin: promoIds
11220
11233
  }
11221
11234
  });
11222
11235
  },
@@ -11352,7 +11365,7 @@ const PromotionItem = ({
11352
11365
  "div",
11353
11366
  {
11354
11367
  className: clx(
11355
- "px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
11368
+ "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
11356
11369
  {
11357
11370
  "animate-pulse": isLoading
11358
11371
  }
@@ -11360,7 +11373,7 @@ const PromotionItem = ({
11360
11373
  children: [
11361
11374
  /* @__PURE__ */ jsxs("div", { children: [
11362
11375
  /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
11363
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
11376
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
11364
11377
  displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
11365
11378
  /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
11366
11379
  /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
@@ -11412,13 +11425,13 @@ const formatPercentage = (value, isPercentageValue = false) => {
11412
11425
  }
11413
11426
  return formatter.format(val);
11414
11427
  };
11415
- function getPromotionCodes(items, shippingMethods) {
11416
- const codes = /* @__PURE__ */ new Set();
11428
+ function getPromotionIds(items, shippingMethods) {
11429
+ const promotionIds = /* @__PURE__ */ new Set();
11417
11430
  for (const item of items) {
11418
11431
  if (item.adjustments) {
11419
11432
  for (const adjustment of item.adjustments) {
11420
- if (adjustment.code) {
11421
- codes.add(adjustment.code);
11433
+ if (adjustment.promotion_id) {
11434
+ promotionIds.add(adjustment.promotion_id);
11422
11435
  }
11423
11436
  }
11424
11437
  }
@@ -11426,13 +11439,13 @@ function getPromotionCodes(items, shippingMethods) {
11426
11439
  for (const shippingMethod of shippingMethods) {
11427
11440
  if (shippingMethod.adjustments) {
11428
11441
  for (const adjustment of shippingMethod.adjustments) {
11429
- if (adjustment.code) {
11430
- codes.add(adjustment.code);
11442
+ if (adjustment.promotion_id) {
11443
+ promotionIds.add(adjustment.promotion_id);
11431
11444
  }
11432
11445
  }
11433
11446
  }
11434
11447
  }
11435
- return Array.from(codes);
11448
+ return Array.from(promotionIds);
11436
11449
  }
11437
11450
  const SalesChannel = () => {
11438
11451
  const { id } = useParams();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.0-snapshot-20250828185926",
3
+ "version": "2.11.0-snapshot-20251014110210",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -27,16 +27,10 @@
27
27
  "medusa-plugin",
28
28
  "medusa-v2"
29
29
  ],
30
- "scripts": {
31
- "build": "medusa plugin:build",
32
- "dev": "medusa plugin:develop",
33
- "prepare": "cross-env NODE_ENV=production yarn run build",
34
- "link:watch": "medusa plugin:publish && medusa plugin:develop"
35
- },
36
30
  "dependencies": {
37
31
  "@ariakit/react": "^0.4.15",
38
32
  "@hookform/resolvers": "3.4.2",
39
- "@medusajs/js-sdk": "2.11.0-snapshot-20250828185926",
33
+ "@medusajs/js-sdk": "2.11.0-snapshot-20251014110210",
40
34
  "@tanstack/react-query": "5.64.2",
41
35
  "@uiw/react-json-view": "^2.0.0-alpha.17",
42
36
  "date-fns": "^3.6.0",
@@ -45,27 +39,20 @@
45
39
  "react-hook-form": "7.49.1"
46
40
  },
47
41
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.11.0-snapshot-20250828185926",
49
- "@medusajs/cli": "2.11.0-snapshot-20250828185926",
50
- "@medusajs/framework": "2.11.0-snapshot-20250828185926",
51
- "@medusajs/icons": "2.11.0-snapshot-20250828185926",
52
- "@medusajs/test-utils": "2.11.0-snapshot-20250828185926",
53
- "@medusajs/types": "2.11.0-snapshot-20250828185926",
54
- "@medusajs/ui": "4.0.21-snapshot-20250828185926",
55
- "@medusajs/ui-preset": "2.11.0-snapshot-20250828185926",
56
- "@mikro-orm/cli": "6.4.3",
57
- "@mikro-orm/core": "6.4.3",
58
- "@mikro-orm/knex": "6.4.3",
59
- "@mikro-orm/migrations": "6.4.3",
60
- "@mikro-orm/postgresql": "6.4.3",
42
+ "@medusajs/admin-sdk": "2.11.0-snapshot-20251014110210",
43
+ "@medusajs/cli": "2.11.0-snapshot-20251014110210",
44
+ "@medusajs/framework": "2.11.0-snapshot-20251014110210",
45
+ "@medusajs/icons": "2.11.0-snapshot-20251014110210",
46
+ "@medusajs/test-utils": "2.11.0-snapshot-20251014110210",
47
+ "@medusajs/types": "2.11.0-snapshot-20251014110210",
48
+ "@medusajs/ui": "4.0.24-snapshot-20251014110210",
49
+ "@medusajs/ui-preset": "2.11.0-snapshot-20251014110210",
61
50
  "@swc/core": "1.5.7",
62
51
  "@types/lodash": "^4.17.15",
63
52
  "@types/node": "^20.0.0",
64
53
  "@types/react": "^18.3.2",
65
54
  "@types/react-dom": "^18.2.25",
66
- "awilix": "^8.0.1",
67
55
  "lodash": "^4.17.21",
68
- "pg": "^8.13.0",
69
56
  "react": "^18.2.0",
70
57
  "react-dom": "^18.2.0",
71
58
  "react-router-dom": "6.20.1",
@@ -76,24 +63,22 @@
76
63
  "yalc": "^1.0.0-pre.53"
77
64
  },
78
65
  "peerDependencies": {
79
- "@medusajs/admin-sdk": "2.11.0-snapshot-20250828185926",
80
- "@medusajs/cli": "2.11.0-snapshot-20250828185926",
81
- "@medusajs/framework": "2.11.0-snapshot-20250828185926",
82
- "@medusajs/icons": "2.11.0-snapshot-20250828185926",
83
- "@medusajs/test-utils": "2.11.0-snapshot-20250828185926",
84
- "@medusajs/ui": "4.0.21-snapshot-20250828185926",
85
- "@mikro-orm/cli": "6.4.3",
86
- "@mikro-orm/core": "6.4.3",
87
- "@mikro-orm/knex": "6.4.3",
88
- "@mikro-orm/migrations": "6.4.3",
89
- "@mikro-orm/postgresql": "6.4.3",
90
- "awilix": "^8.0.1",
66
+ "@medusajs/admin-sdk": "2.11.0-snapshot-20251014110210",
67
+ "@medusajs/cli": "2.11.0-snapshot-20251014110210",
68
+ "@medusajs/framework": "2.11.0-snapshot-20251014110210",
69
+ "@medusajs/icons": "2.11.0-snapshot-20251014110210",
70
+ "@medusajs/test-utils": "2.11.0-snapshot-20251014110210",
71
+ "@medusajs/ui": "4.0.24-snapshot-20251014110210",
91
72
  "lodash": "^4.17.21",
92
- "pg": "^8.13.0",
93
73
  "react-router-dom": "6.20.1"
94
74
  },
95
75
  "engines": {
96
76
  "node": ">=20"
97
77
  },
98
- "packageManager": "yarn@3.2.1"
99
- }
78
+ "packageManager": "yarn@3.2.1",
79
+ "scripts": {
80
+ "build": "medusa plugin:build",
81
+ "dev": "medusa plugin:develop",
82
+ "link:watch": "medusa plugin:publish && medusa plugin:develop"
83
+ }
84
+ }