@medusajs/draft-order 2.11.4-snapshot-20251107205323 → 2.11.4-snapshot-20251107211311
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +575 -574
- package/.medusa/server/src/admin/index.mjs +575 -574
- package/package.json +16 -16
|
@@ -9572,6 +9572,27 @@ const ID = () => {
|
|
|
9572
9572
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9573
9573
|
] });
|
|
9574
9574
|
};
|
|
9575
|
+
const CustomItems = () => {
|
|
9576
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9577
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9578
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9579
|
+
] });
|
|
9580
|
+
};
|
|
9581
|
+
const CustomItemsForm = () => {
|
|
9582
|
+
const form = reactHookForm.useForm({
|
|
9583
|
+
resolver: zod.zodResolver(schema$5)
|
|
9584
|
+
});
|
|
9585
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9586
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9588
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9589
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9590
|
+
] }) })
|
|
9591
|
+
] }) });
|
|
9592
|
+
};
|
|
9593
|
+
const schema$5 = objectType({
|
|
9594
|
+
email: stringType().email()
|
|
9595
|
+
});
|
|
9575
9596
|
const BillingAddress = () => {
|
|
9576
9597
|
const { id } = reactRouterDom.useParams();
|
|
9577
9598
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9604,7 +9625,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9604
9625
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9605
9626
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9606
9627
|
},
|
|
9607
|
-
resolver: zod.zodResolver(schema$
|
|
9628
|
+
resolver: zod.zodResolver(schema$4)
|
|
9608
9629
|
});
|
|
9609
9630
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9610
9631
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9761,28 +9782,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9761
9782
|
}
|
|
9762
9783
|
) });
|
|
9763
9784
|
};
|
|
9764
|
-
const schema$
|
|
9765
|
-
const CustomItems = () => {
|
|
9766
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9767
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9768
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9769
|
-
] });
|
|
9770
|
-
};
|
|
9771
|
-
const CustomItemsForm = () => {
|
|
9772
|
-
const form = reactHookForm.useForm({
|
|
9773
|
-
resolver: zod.zodResolver(schema$4)
|
|
9774
|
-
});
|
|
9775
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9776
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9777
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9778
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9779
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9780
|
-
] }) })
|
|
9781
|
-
] }) });
|
|
9782
|
-
};
|
|
9783
|
-
const schema$4 = objectType({
|
|
9784
|
-
email: stringType().email()
|
|
9785
|
-
});
|
|
9785
|
+
const schema$4 = addressSchema;
|
|
9786
9786
|
const Email = () => {
|
|
9787
9787
|
const { id } = reactRouterDom.useParams();
|
|
9788
9788
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -11175,190 +11175,467 @@ function getHasUneditableRows(metadata) {
|
|
|
11175
11175
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11176
11176
|
);
|
|
11177
11177
|
}
|
|
11178
|
-
const
|
|
11179
|
-
|
|
11180
|
-
|
|
11178
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
11179
|
+
const promotionsQueryKeys = {
|
|
11180
|
+
list: (query2) => [
|
|
11181
|
+
PROMOTION_QUERY_KEY,
|
|
11182
|
+
query2 ? query2 : void 0
|
|
11183
|
+
],
|
|
11184
|
+
detail: (id, query2) => [
|
|
11185
|
+
PROMOTION_QUERY_KEY,
|
|
11181
11186
|
id,
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
},
|
|
11185
|
-
{
|
|
11186
|
-
enabled: !!id
|
|
11187
|
-
}
|
|
11188
|
-
);
|
|
11189
|
-
if (isError) {
|
|
11190
|
-
throw error;
|
|
11191
|
-
}
|
|
11192
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11193
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11194
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11195
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11196
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11197
|
-
] }),
|
|
11198
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11199
|
-
] });
|
|
11200
|
-
};
|
|
11201
|
-
const SalesChannelForm = ({ order }) => {
|
|
11202
|
-
const form = reactHookForm.useForm({
|
|
11203
|
-
defaultValues: {
|
|
11204
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11205
|
-
},
|
|
11206
|
-
resolver: zod.zodResolver(schema$2)
|
|
11207
|
-
});
|
|
11208
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11209
|
-
const { handleSuccess } = useRouteModal();
|
|
11210
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11211
|
-
await mutateAsync(
|
|
11212
|
-
{
|
|
11213
|
-
sales_channel_id: data.sales_channel_id
|
|
11214
|
-
},
|
|
11215
|
-
{
|
|
11216
|
-
onSuccess: () => {
|
|
11217
|
-
ui.toast.success("Sales channel updated");
|
|
11218
|
-
handleSuccess();
|
|
11219
|
-
},
|
|
11220
|
-
onError: (error) => {
|
|
11221
|
-
ui.toast.error(error.message);
|
|
11222
|
-
}
|
|
11223
|
-
}
|
|
11224
|
-
);
|
|
11225
|
-
});
|
|
11226
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11227
|
-
KeyboundForm,
|
|
11228
|
-
{
|
|
11229
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11230
|
-
onSubmit,
|
|
11231
|
-
children: [
|
|
11232
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11233
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11234
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11235
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11236
|
-
] }) })
|
|
11237
|
-
]
|
|
11238
|
-
}
|
|
11239
|
-
) });
|
|
11187
|
+
query2 ? query2 : void 0
|
|
11188
|
+
]
|
|
11240
11189
|
};
|
|
11241
|
-
const
|
|
11242
|
-
const
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
queryKey: ["sales-channels"],
|
|
11247
|
-
getOptions: (data) => {
|
|
11248
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11249
|
-
label: salesChannel.name,
|
|
11250
|
-
value: salesChannel.id
|
|
11251
|
-
}));
|
|
11252
|
-
},
|
|
11253
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11190
|
+
const usePromotions = (query2, options) => {
|
|
11191
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
11192
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
11193
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11194
|
+
...options
|
|
11254
11195
|
});
|
|
11255
|
-
return
|
|
11256
|
-
Form$2.Field,
|
|
11257
|
-
{
|
|
11258
|
-
control,
|
|
11259
|
-
name: "sales_channel_id",
|
|
11260
|
-
render: ({ field }) => {
|
|
11261
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11262
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11263
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11264
|
-
Combobox,
|
|
11265
|
-
{
|
|
11266
|
-
options: salesChannels.options,
|
|
11267
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11268
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11269
|
-
searchValue: salesChannels.searchValue,
|
|
11270
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11271
|
-
placeholder: "Select sales channel",
|
|
11272
|
-
...field
|
|
11273
|
-
}
|
|
11274
|
-
) }),
|
|
11275
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11276
|
-
] });
|
|
11277
|
-
}
|
|
11278
|
-
}
|
|
11279
|
-
);
|
|
11196
|
+
return { ...data, ...rest };
|
|
11280
11197
|
};
|
|
11281
|
-
const
|
|
11282
|
-
sales_channel_id: stringType().min(1)
|
|
11283
|
-
});
|
|
11284
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11285
|
-
const Shipping = () => {
|
|
11286
|
-
var _a;
|
|
11198
|
+
const Promotions = () => {
|
|
11287
11199
|
const { id } = reactRouterDom.useParams();
|
|
11288
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11289
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11290
|
-
});
|
|
11291
11200
|
const {
|
|
11292
11201
|
order: preview,
|
|
11293
|
-
isPending: isPreviewPending,
|
|
11294
11202
|
isError: isPreviewError,
|
|
11295
11203
|
error: previewError
|
|
11296
|
-
} = useOrderPreview(id);
|
|
11204
|
+
} = useOrderPreview(id, void 0);
|
|
11297
11205
|
useInitiateOrderEdit({ preview });
|
|
11298
11206
|
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11299
|
-
if (isError) {
|
|
11300
|
-
throw error;
|
|
11301
|
-
}
|
|
11302
11207
|
if (isPreviewError) {
|
|
11303
11208
|
throw previewError;
|
|
11304
11209
|
}
|
|
11305
|
-
const
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11309
|
-
|
|
11310
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11311
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11312
|
-
] }) }) }),
|
|
11313
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11314
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11315
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11316
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11317
|
-
] }) });
|
|
11210
|
+
const isReady = !!preview;
|
|
11211
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11212
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
11213
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11214
|
+
] });
|
|
11318
11215
|
};
|
|
11319
|
-
const
|
|
11320
|
-
|
|
11321
|
-
const { setIsOpen } = useStackedModal();
|
|
11216
|
+
const PromotionForm = ({ preview }) => {
|
|
11217
|
+
const { items, shipping_methods } = preview;
|
|
11322
11218
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11323
|
-
const [
|
|
11324
|
-
const
|
|
11325
|
-
const {
|
|
11219
|
+
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
11220
|
+
const { handleSuccess } = useRouteModal();
|
|
11221
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11222
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11223
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
11326
11224
|
{
|
|
11327
|
-
id:
|
|
11328
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11225
|
+
id: promoIds
|
|
11329
11226
|
},
|
|
11330
11227
|
{
|
|
11331
|
-
enabled:
|
|
11228
|
+
enabled: !!promoIds.length
|
|
11332
11229
|
}
|
|
11333
11230
|
);
|
|
11334
|
-
const
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
}
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11231
|
+
const comboboxData = useComboboxData({
|
|
11232
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
11233
|
+
queryFn: async (params) => {
|
|
11234
|
+
return await sdk.admin.promotion.list({
|
|
11235
|
+
...params,
|
|
11236
|
+
id: {
|
|
11237
|
+
$nin: promoIds
|
|
11238
|
+
}
|
|
11239
|
+
});
|
|
11240
|
+
},
|
|
11241
|
+
getOptions: (data) => {
|
|
11242
|
+
return data.promotions.map((promotion) => ({
|
|
11243
|
+
label: promotion.code,
|
|
11244
|
+
value: promotion.code
|
|
11245
|
+
}));
|
|
11246
|
+
}
|
|
11247
|
+
});
|
|
11248
|
+
const add = async (value) => {
|
|
11249
|
+
if (!value) {
|
|
11250
|
+
return;
|
|
11251
|
+
}
|
|
11252
|
+
addPromotions(
|
|
11253
|
+
{
|
|
11254
|
+
promo_codes: [value]
|
|
11255
|
+
},
|
|
11256
|
+
{
|
|
11257
|
+
onError: (e) => {
|
|
11258
|
+
ui.toast.error(e.message);
|
|
11259
|
+
comboboxData.onSearchValueChange("");
|
|
11260
|
+
setComboboxValue("");
|
|
11261
|
+
},
|
|
11262
|
+
onSuccess: () => {
|
|
11263
|
+
comboboxData.onSearchValueChange("");
|
|
11264
|
+
setComboboxValue("");
|
|
11265
|
+
}
|
|
11266
|
+
}
|
|
11267
|
+
);
|
|
11268
|
+
};
|
|
11269
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11270
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
11271
|
+
const onSubmit = async () => {
|
|
11272
|
+
setIsSubmitting(true);
|
|
11273
|
+
let requestSucceeded = false;
|
|
11274
|
+
await requestOrderEdit(void 0, {
|
|
11275
|
+
onError: (e) => {
|
|
11276
|
+
ui.toast.error(e.message);
|
|
11277
|
+
},
|
|
11278
|
+
onSuccess: () => {
|
|
11279
|
+
requestSucceeded = true;
|
|
11280
|
+
}
|
|
11281
|
+
});
|
|
11282
|
+
if (!requestSucceeded) {
|
|
11283
|
+
setIsSubmitting(false);
|
|
11284
|
+
return;
|
|
11285
|
+
}
|
|
11286
|
+
await confirmOrderEdit(void 0, {
|
|
11287
|
+
onError: (e) => {
|
|
11288
|
+
ui.toast.error(e.message);
|
|
11289
|
+
},
|
|
11290
|
+
onSuccess: () => {
|
|
11291
|
+
handleSuccess();
|
|
11292
|
+
},
|
|
11293
|
+
onSettled: () => {
|
|
11294
|
+
setIsSubmitting(false);
|
|
11295
|
+
}
|
|
11296
|
+
});
|
|
11297
|
+
};
|
|
11298
|
+
if (isError) {
|
|
11299
|
+
throw error;
|
|
11300
|
+
}
|
|
11301
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11302
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11303
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11304
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11305
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11306
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11307
|
+
] }),
|
|
11308
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11309
|
+
Combobox,
|
|
11310
|
+
{
|
|
11311
|
+
id: "promotion-combobox",
|
|
11312
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
11313
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11314
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
11315
|
+
options: comboboxData.options,
|
|
11316
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11317
|
+
searchValue: comboboxData.searchValue,
|
|
11318
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11319
|
+
onChange: add,
|
|
11320
|
+
value: comboboxValue
|
|
11321
|
+
}
|
|
11322
|
+
)
|
|
11323
|
+
] }),
|
|
11324
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11325
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11326
|
+
PromotionItem,
|
|
11327
|
+
{
|
|
11328
|
+
promotion,
|
|
11329
|
+
orderId: preview.id,
|
|
11330
|
+
isLoading: isPending
|
|
11331
|
+
},
|
|
11332
|
+
promotion.id
|
|
11333
|
+
)) })
|
|
11334
|
+
] }) }),
|
|
11335
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11336
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11337
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11338
|
+
ui.Button,
|
|
11339
|
+
{
|
|
11340
|
+
size: "small",
|
|
11341
|
+
type: "submit",
|
|
11342
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
11343
|
+
children: "Save"
|
|
11344
|
+
}
|
|
11345
|
+
)
|
|
11346
|
+
] }) })
|
|
11347
|
+
] });
|
|
11348
|
+
};
|
|
11349
|
+
const PromotionItem = ({
|
|
11350
|
+
promotion,
|
|
11351
|
+
orderId,
|
|
11352
|
+
isLoading
|
|
11353
|
+
}) => {
|
|
11354
|
+
var _a;
|
|
11355
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11356
|
+
const onRemove = async () => {
|
|
11357
|
+
removePromotions(
|
|
11358
|
+
{
|
|
11359
|
+
promo_codes: [promotion.code]
|
|
11360
|
+
},
|
|
11361
|
+
{
|
|
11362
|
+
onError: (e) => {
|
|
11363
|
+
ui.toast.error(e.message);
|
|
11364
|
+
}
|
|
11365
|
+
}
|
|
11366
|
+
);
|
|
11367
|
+
};
|
|
11368
|
+
const displayValue = getDisplayValue(promotion);
|
|
11369
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11370
|
+
"div",
|
|
11371
|
+
{
|
|
11372
|
+
className: ui.clx(
|
|
11373
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11374
|
+
{
|
|
11375
|
+
"animate-pulse": isLoading
|
|
11376
|
+
}
|
|
11377
|
+
),
|
|
11378
|
+
children: [
|
|
11379
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11380
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11381
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11382
|
+
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11383
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11384
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
11385
|
+
] }),
|
|
11386
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11387
|
+
] })
|
|
11388
|
+
] }),
|
|
11389
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11390
|
+
ui.IconButton,
|
|
11391
|
+
{
|
|
11392
|
+
size: "small",
|
|
11393
|
+
type: "button",
|
|
11394
|
+
variant: "transparent",
|
|
11395
|
+
onClick: onRemove,
|
|
11396
|
+
isLoading: isPending || isLoading,
|
|
11397
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11398
|
+
}
|
|
11399
|
+
)
|
|
11400
|
+
]
|
|
11401
|
+
},
|
|
11402
|
+
promotion.id
|
|
11403
|
+
);
|
|
11404
|
+
};
|
|
11405
|
+
function getDisplayValue(promotion) {
|
|
11406
|
+
var _a, _b, _c, _d;
|
|
11407
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11408
|
+
if (!value) {
|
|
11409
|
+
return null;
|
|
11410
|
+
}
|
|
11411
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11412
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11413
|
+
if (!currency) {
|
|
11414
|
+
return null;
|
|
11415
|
+
}
|
|
11416
|
+
return getLocaleAmount(value, currency);
|
|
11417
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11418
|
+
return formatPercentage(value);
|
|
11419
|
+
}
|
|
11420
|
+
return null;
|
|
11421
|
+
}
|
|
11422
|
+
const formatter = new Intl.NumberFormat([], {
|
|
11423
|
+
style: "percent",
|
|
11424
|
+
minimumFractionDigits: 2
|
|
11425
|
+
});
|
|
11426
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11427
|
+
let val = value || 0;
|
|
11428
|
+
if (!isPercentageValue) {
|
|
11429
|
+
val = val / 100;
|
|
11430
|
+
}
|
|
11431
|
+
return formatter.format(val);
|
|
11432
|
+
};
|
|
11433
|
+
function getPromotionIds(items, shippingMethods) {
|
|
11434
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
11435
|
+
for (const item of items) {
|
|
11436
|
+
if (item.adjustments) {
|
|
11437
|
+
for (const adjustment of item.adjustments) {
|
|
11438
|
+
if (adjustment.promotion_id) {
|
|
11439
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
}
|
|
11443
|
+
}
|
|
11444
|
+
for (const shippingMethod of shippingMethods) {
|
|
11445
|
+
if (shippingMethod.adjustments) {
|
|
11446
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11447
|
+
if (adjustment.promotion_id) {
|
|
11448
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11449
|
+
}
|
|
11450
|
+
}
|
|
11451
|
+
}
|
|
11452
|
+
}
|
|
11453
|
+
return Array.from(promotionIds);
|
|
11454
|
+
}
|
|
11455
|
+
const SalesChannel = () => {
|
|
11456
|
+
const { id } = reactRouterDom.useParams();
|
|
11457
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11458
|
+
id,
|
|
11459
|
+
{
|
|
11460
|
+
fields: "+sales_channel_id"
|
|
11461
|
+
},
|
|
11462
|
+
{
|
|
11463
|
+
enabled: !!id
|
|
11464
|
+
}
|
|
11465
|
+
);
|
|
11466
|
+
if (isError) {
|
|
11467
|
+
throw error;
|
|
11468
|
+
}
|
|
11469
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11470
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11471
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11472
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11473
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11474
|
+
] }),
|
|
11475
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11476
|
+
] });
|
|
11477
|
+
};
|
|
11478
|
+
const SalesChannelForm = ({ order }) => {
|
|
11479
|
+
const form = reactHookForm.useForm({
|
|
11480
|
+
defaultValues: {
|
|
11481
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11482
|
+
},
|
|
11483
|
+
resolver: zod.zodResolver(schema$2)
|
|
11484
|
+
});
|
|
11485
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11486
|
+
const { handleSuccess } = useRouteModal();
|
|
11487
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11488
|
+
await mutateAsync(
|
|
11489
|
+
{
|
|
11490
|
+
sales_channel_id: data.sales_channel_id
|
|
11491
|
+
},
|
|
11492
|
+
{
|
|
11493
|
+
onSuccess: () => {
|
|
11494
|
+
ui.toast.success("Sales channel updated");
|
|
11495
|
+
handleSuccess();
|
|
11496
|
+
},
|
|
11497
|
+
onError: (error) => {
|
|
11498
|
+
ui.toast.error(error.message);
|
|
11499
|
+
}
|
|
11500
|
+
}
|
|
11501
|
+
);
|
|
11502
|
+
});
|
|
11503
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11504
|
+
KeyboundForm,
|
|
11505
|
+
{
|
|
11506
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11507
|
+
onSubmit,
|
|
11508
|
+
children: [
|
|
11509
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11510
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11511
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11512
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11513
|
+
] }) })
|
|
11514
|
+
]
|
|
11515
|
+
}
|
|
11516
|
+
) });
|
|
11517
|
+
};
|
|
11518
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11519
|
+
const salesChannels = useComboboxData({
|
|
11520
|
+
queryFn: async (params) => {
|
|
11521
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11522
|
+
},
|
|
11523
|
+
queryKey: ["sales-channels"],
|
|
11524
|
+
getOptions: (data) => {
|
|
11525
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11526
|
+
label: salesChannel.name,
|
|
11527
|
+
value: salesChannel.id
|
|
11528
|
+
}));
|
|
11529
|
+
},
|
|
11530
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11531
|
+
});
|
|
11532
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11533
|
+
Form$2.Field,
|
|
11534
|
+
{
|
|
11535
|
+
control,
|
|
11536
|
+
name: "sales_channel_id",
|
|
11537
|
+
render: ({ field }) => {
|
|
11538
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11540
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11541
|
+
Combobox,
|
|
11542
|
+
{
|
|
11543
|
+
options: salesChannels.options,
|
|
11544
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11545
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11546
|
+
searchValue: salesChannels.searchValue,
|
|
11547
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11548
|
+
placeholder: "Select sales channel",
|
|
11549
|
+
...field
|
|
11550
|
+
}
|
|
11551
|
+
) }),
|
|
11552
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11553
|
+
] });
|
|
11554
|
+
}
|
|
11555
|
+
}
|
|
11556
|
+
);
|
|
11557
|
+
};
|
|
11558
|
+
const schema$2 = objectType({
|
|
11559
|
+
sales_channel_id: stringType().min(1)
|
|
11560
|
+
});
|
|
11561
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11562
|
+
const Shipping = () => {
|
|
11563
|
+
var _a;
|
|
11564
|
+
const { id } = reactRouterDom.useParams();
|
|
11565
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11566
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11567
|
+
});
|
|
11568
|
+
const {
|
|
11569
|
+
order: preview,
|
|
11570
|
+
isPending: isPreviewPending,
|
|
11571
|
+
isError: isPreviewError,
|
|
11572
|
+
error: previewError
|
|
11573
|
+
} = useOrderPreview(id);
|
|
11574
|
+
useInitiateOrderEdit({ preview });
|
|
11575
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11576
|
+
if (isError) {
|
|
11577
|
+
throw error;
|
|
11578
|
+
}
|
|
11579
|
+
if (isPreviewError) {
|
|
11580
|
+
throw previewError;
|
|
11581
|
+
}
|
|
11582
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11583
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11584
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11585
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11586
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__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: [
|
|
11587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11588
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11589
|
+
] }) }) }),
|
|
11590
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11591
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11592
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11593
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11594
|
+
] }) });
|
|
11595
|
+
};
|
|
11596
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11597
|
+
var _a;
|
|
11598
|
+
const { setIsOpen } = useStackedModal();
|
|
11599
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11600
|
+
const [data, setData] = React.useState(null);
|
|
11601
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11602
|
+
const { shipping_options } = useShippingOptions(
|
|
11603
|
+
{
|
|
11604
|
+
id: appliedShippingOptionIds,
|
|
11605
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11606
|
+
},
|
|
11607
|
+
{
|
|
11608
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11609
|
+
}
|
|
11610
|
+
);
|
|
11611
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11612
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11613
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11614
|
+
profiles.set(profile.id, profile);
|
|
11615
|
+
});
|
|
11616
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11617
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11618
|
+
});
|
|
11619
|
+
return Array.from(profiles.values());
|
|
11620
|
+
}, [order.items, shipping_options]);
|
|
11621
|
+
const { handleSuccess } = useRouteModal();
|
|
11622
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11623
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11624
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11625
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11626
|
+
const onSubmit = async () => {
|
|
11627
|
+
setIsSubmitting(true);
|
|
11628
|
+
let requestSucceeded = false;
|
|
11629
|
+
await requestOrderEdit(void 0, {
|
|
11630
|
+
onError: (e) => {
|
|
11631
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11632
|
+
},
|
|
11633
|
+
onSuccess: () => {
|
|
11634
|
+
requestSucceeded = true;
|
|
11635
|
+
}
|
|
11636
|
+
});
|
|
11637
|
+
if (!requestSucceeded) {
|
|
11638
|
+
setIsSubmitting(false);
|
|
11362
11639
|
return;
|
|
11363
11640
|
}
|
|
11364
11641
|
await confirmOrderEdit(void 0, {
|
|
@@ -12657,393 +12934,116 @@ const Illustration = () => {
|
|
|
12657
12934
|
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12658
12935
|
"path",
|
|
12659
12936
|
{
|
|
12660
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12661
|
-
stroke: "#A1A1AA",
|
|
12662
|
-
strokeWidth: "1.5",
|
|
12663
|
-
strokeLinecap: "round",
|
|
12664
|
-
strokeLinejoin: "round"
|
|
12665
|
-
}
|
|
12666
|
-
) }),
|
|
12667
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12668
|
-
"path",
|
|
12669
|
-
{
|
|
12670
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12671
|
-
stroke: "#A1A1AA",
|
|
12672
|
-
strokeWidth: "1.5",
|
|
12673
|
-
strokeLinecap: "round",
|
|
12674
|
-
strokeLinejoin: "round"
|
|
12675
|
-
}
|
|
12676
|
-
) }),
|
|
12677
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12678
|
-
"path",
|
|
12679
|
-
{
|
|
12680
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12681
|
-
stroke: "#A1A1AA",
|
|
12682
|
-
strokeWidth: "1.5",
|
|
12683
|
-
strokeLinecap: "round",
|
|
12684
|
-
strokeLinejoin: "round"
|
|
12685
|
-
}
|
|
12686
|
-
) }),
|
|
12687
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12688
|
-
"path",
|
|
12689
|
-
{
|
|
12690
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12691
|
-
stroke: "#A1A1AA",
|
|
12692
|
-
strokeWidth: "1.5",
|
|
12693
|
-
strokeLinecap: "round",
|
|
12694
|
-
strokeLinejoin: "round"
|
|
12695
|
-
}
|
|
12696
|
-
) }),
|
|
12697
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12698
|
-
"path",
|
|
12699
|
-
{
|
|
12700
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12701
|
-
stroke: "#A1A1AA",
|
|
12702
|
-
strokeWidth: "1.5",
|
|
12703
|
-
strokeLinecap: "round",
|
|
12704
|
-
strokeLinejoin: "round"
|
|
12705
|
-
}
|
|
12706
|
-
) }),
|
|
12707
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12708
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12709
|
-
"rect",
|
|
12710
|
-
{
|
|
12711
|
-
width: "12",
|
|
12712
|
-
height: "12",
|
|
12713
|
-
fill: "white",
|
|
12714
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12715
|
-
}
|
|
12716
|
-
) }),
|
|
12717
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12718
|
-
"rect",
|
|
12719
|
-
{
|
|
12720
|
-
width: "12",
|
|
12721
|
-
height: "12",
|
|
12722
|
-
fill: "white",
|
|
12723
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12724
|
-
}
|
|
12725
|
-
) }),
|
|
12726
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12727
|
-
"rect",
|
|
12728
|
-
{
|
|
12729
|
-
width: "12",
|
|
12730
|
-
height: "12",
|
|
12731
|
-
fill: "white",
|
|
12732
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12733
|
-
}
|
|
12734
|
-
) }),
|
|
12735
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12736
|
-
"rect",
|
|
12737
|
-
{
|
|
12738
|
-
width: "12",
|
|
12739
|
-
height: "12",
|
|
12740
|
-
fill: "white",
|
|
12741
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12742
|
-
}
|
|
12743
|
-
) }),
|
|
12744
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12745
|
-
"rect",
|
|
12746
|
-
{
|
|
12747
|
-
width: "12",
|
|
12748
|
-
height: "12",
|
|
12749
|
-
fill: "white",
|
|
12750
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12751
|
-
}
|
|
12752
|
-
) }),
|
|
12753
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12754
|
-
"rect",
|
|
12755
|
-
{
|
|
12756
|
-
width: "12",
|
|
12757
|
-
height: "12",
|
|
12758
|
-
fill: "white",
|
|
12759
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12760
|
-
}
|
|
12761
|
-
) })
|
|
12762
|
-
] })
|
|
12763
|
-
]
|
|
12764
|
-
}
|
|
12765
|
-
);
|
|
12766
|
-
};
|
|
12767
|
-
const schema = objectType({
|
|
12768
|
-
customer_id: stringType().min(1)
|
|
12769
|
-
});
|
|
12770
|
-
const PROMOTION_QUERY_KEY = "promotions";
|
|
12771
|
-
const promotionsQueryKeys = {
|
|
12772
|
-
list: (query2) => [
|
|
12773
|
-
PROMOTION_QUERY_KEY,
|
|
12774
|
-
query2 ? query2 : void 0
|
|
12775
|
-
],
|
|
12776
|
-
detail: (id, query2) => [
|
|
12777
|
-
PROMOTION_QUERY_KEY,
|
|
12778
|
-
id,
|
|
12779
|
-
query2 ? query2 : void 0
|
|
12780
|
-
]
|
|
12781
|
-
};
|
|
12782
|
-
const usePromotions = (query2, options) => {
|
|
12783
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
12784
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
12785
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
12786
|
-
...options
|
|
12787
|
-
});
|
|
12788
|
-
return { ...data, ...rest };
|
|
12789
|
-
};
|
|
12790
|
-
const Promotions = () => {
|
|
12791
|
-
const { id } = reactRouterDom.useParams();
|
|
12792
|
-
const {
|
|
12793
|
-
order: preview,
|
|
12794
|
-
isError: isPreviewError,
|
|
12795
|
-
error: previewError
|
|
12796
|
-
} = useOrderPreview(id, void 0);
|
|
12797
|
-
useInitiateOrderEdit({ preview });
|
|
12798
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
12799
|
-
if (isPreviewError) {
|
|
12800
|
-
throw previewError;
|
|
12801
|
-
}
|
|
12802
|
-
const isReady = !!preview;
|
|
12803
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
12804
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
12805
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
12806
|
-
] });
|
|
12807
|
-
};
|
|
12808
|
-
const PromotionForm = ({ preview }) => {
|
|
12809
|
-
const { items, shipping_methods } = preview;
|
|
12810
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
12811
|
-
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
12812
|
-
const { handleSuccess } = useRouteModal();
|
|
12813
|
-
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
12814
|
-
const promoIds = getPromotionIds(items, shipping_methods);
|
|
12815
|
-
const { promotions, isPending, isError, error } = usePromotions(
|
|
12816
|
-
{
|
|
12817
|
-
id: promoIds
|
|
12818
|
-
},
|
|
12819
|
-
{
|
|
12820
|
-
enabled: !!promoIds.length
|
|
12821
|
-
}
|
|
12822
|
-
);
|
|
12823
|
-
const comboboxData = useComboboxData({
|
|
12824
|
-
queryKey: ["promotions", "combobox", promoIds],
|
|
12825
|
-
queryFn: async (params) => {
|
|
12826
|
-
return await sdk.admin.promotion.list({
|
|
12827
|
-
...params,
|
|
12828
|
-
id: {
|
|
12829
|
-
$nin: promoIds
|
|
12830
|
-
}
|
|
12831
|
-
});
|
|
12832
|
-
},
|
|
12833
|
-
getOptions: (data) => {
|
|
12834
|
-
return data.promotions.map((promotion) => ({
|
|
12835
|
-
label: promotion.code,
|
|
12836
|
-
value: promotion.code
|
|
12837
|
-
}));
|
|
12838
|
-
}
|
|
12839
|
-
});
|
|
12840
|
-
const add = async (value) => {
|
|
12841
|
-
if (!value) {
|
|
12842
|
-
return;
|
|
12843
|
-
}
|
|
12844
|
-
addPromotions(
|
|
12845
|
-
{
|
|
12846
|
-
promo_codes: [value]
|
|
12847
|
-
},
|
|
12848
|
-
{
|
|
12849
|
-
onError: (e) => {
|
|
12850
|
-
ui.toast.error(e.message);
|
|
12851
|
-
comboboxData.onSearchValueChange("");
|
|
12852
|
-
setComboboxValue("");
|
|
12853
|
-
},
|
|
12854
|
-
onSuccess: () => {
|
|
12855
|
-
comboboxData.onSearchValueChange("");
|
|
12856
|
-
setComboboxValue("");
|
|
12857
|
-
}
|
|
12858
|
-
}
|
|
12859
|
-
);
|
|
12860
|
-
};
|
|
12861
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
12862
|
-
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
12863
|
-
const onSubmit = async () => {
|
|
12864
|
-
setIsSubmitting(true);
|
|
12865
|
-
let requestSucceeded = false;
|
|
12866
|
-
await requestOrderEdit(void 0, {
|
|
12867
|
-
onError: (e) => {
|
|
12868
|
-
ui.toast.error(e.message);
|
|
12869
|
-
},
|
|
12870
|
-
onSuccess: () => {
|
|
12871
|
-
requestSucceeded = true;
|
|
12872
|
-
}
|
|
12873
|
-
});
|
|
12874
|
-
if (!requestSucceeded) {
|
|
12875
|
-
setIsSubmitting(false);
|
|
12876
|
-
return;
|
|
12877
|
-
}
|
|
12878
|
-
await confirmOrderEdit(void 0, {
|
|
12879
|
-
onError: (e) => {
|
|
12880
|
-
ui.toast.error(e.message);
|
|
12881
|
-
},
|
|
12882
|
-
onSuccess: () => {
|
|
12883
|
-
handleSuccess();
|
|
12884
|
-
},
|
|
12885
|
-
onSettled: () => {
|
|
12886
|
-
setIsSubmitting(false);
|
|
12887
|
-
}
|
|
12888
|
-
});
|
|
12889
|
-
};
|
|
12890
|
-
if (isError) {
|
|
12891
|
-
throw error;
|
|
12892
|
-
}
|
|
12893
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
12894
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
12895
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
12896
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12897
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
12898
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
12899
|
-
] }),
|
|
12900
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12901
|
-
Combobox,
|
|
12902
|
-
{
|
|
12903
|
-
id: "promotion-combobox",
|
|
12904
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
12905
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
12906
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
12907
|
-
options: comboboxData.options,
|
|
12908
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
12909
|
-
searchValue: comboboxData.searchValue,
|
|
12910
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
12911
|
-
onChange: add,
|
|
12912
|
-
value: comboboxValue
|
|
12937
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12938
|
+
stroke: "#A1A1AA",
|
|
12939
|
+
strokeWidth: "1.5",
|
|
12940
|
+
strokeLinecap: "round",
|
|
12941
|
+
strokeLinejoin: "round"
|
|
12913
12942
|
}
|
|
12914
|
-
)
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12918
|
-
PromotionItem,
|
|
12919
|
-
{
|
|
12920
|
-
promotion,
|
|
12921
|
-
orderId: preview.id,
|
|
12922
|
-
isLoading: isPending
|
|
12923
|
-
},
|
|
12924
|
-
promotion.id
|
|
12925
|
-
)) })
|
|
12926
|
-
] }) }),
|
|
12927
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12928
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12929
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12930
|
-
ui.Button,
|
|
12931
|
-
{
|
|
12932
|
-
size: "small",
|
|
12933
|
-
type: "submit",
|
|
12934
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
12935
|
-
children: "Save"
|
|
12936
|
-
}
|
|
12937
|
-
)
|
|
12938
|
-
] }) })
|
|
12939
|
-
] });
|
|
12940
|
-
};
|
|
12941
|
-
const PromotionItem = ({
|
|
12942
|
-
promotion,
|
|
12943
|
-
orderId,
|
|
12944
|
-
isLoading
|
|
12945
|
-
}) => {
|
|
12946
|
-
var _a;
|
|
12947
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
12948
|
-
const onRemove = async () => {
|
|
12949
|
-
removePromotions(
|
|
12950
|
-
{
|
|
12951
|
-
promo_codes: [promotion.code]
|
|
12952
|
-
},
|
|
12953
|
-
{
|
|
12954
|
-
onError: (e) => {
|
|
12955
|
-
ui.toast.error(e.message);
|
|
12956
|
-
}
|
|
12957
|
-
}
|
|
12958
|
-
);
|
|
12959
|
-
};
|
|
12960
|
-
const displayValue = getDisplayValue(promotion);
|
|
12961
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12962
|
-
"div",
|
|
12963
|
-
{
|
|
12964
|
-
className: ui.clx(
|
|
12965
|
-
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
12966
|
-
{
|
|
12967
|
-
"animate-pulse": isLoading
|
|
12968
|
-
}
|
|
12969
|
-
),
|
|
12970
|
-
children: [
|
|
12971
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12972
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
12973
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
12974
|
-
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
12975
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
12976
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
12977
|
-
] }),
|
|
12978
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
12979
|
-
] })
|
|
12980
|
-
] }),
|
|
12981
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12982
|
-
ui.IconButton,
|
|
12943
|
+
) }),
|
|
12944
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12945
|
+
"path",
|
|
12983
12946
|
{
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
12947
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12948
|
+
stroke: "#A1A1AA",
|
|
12949
|
+
strokeWidth: "1.5",
|
|
12950
|
+
strokeLinecap: "round",
|
|
12951
|
+
strokeLinejoin: "round"
|
|
12990
12952
|
}
|
|
12991
|
-
)
|
|
12953
|
+
) }),
|
|
12954
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12955
|
+
"path",
|
|
12956
|
+
{
|
|
12957
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12958
|
+
stroke: "#A1A1AA",
|
|
12959
|
+
strokeWidth: "1.5",
|
|
12960
|
+
strokeLinecap: "round",
|
|
12961
|
+
strokeLinejoin: "round"
|
|
12962
|
+
}
|
|
12963
|
+
) }),
|
|
12964
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12965
|
+
"path",
|
|
12966
|
+
{
|
|
12967
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12968
|
+
stroke: "#A1A1AA",
|
|
12969
|
+
strokeWidth: "1.5",
|
|
12970
|
+
strokeLinecap: "round",
|
|
12971
|
+
strokeLinejoin: "round"
|
|
12972
|
+
}
|
|
12973
|
+
) }),
|
|
12974
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12975
|
+
"path",
|
|
12976
|
+
{
|
|
12977
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12978
|
+
stroke: "#A1A1AA",
|
|
12979
|
+
strokeWidth: "1.5",
|
|
12980
|
+
strokeLinecap: "round",
|
|
12981
|
+
strokeLinejoin: "round"
|
|
12982
|
+
}
|
|
12983
|
+
) }),
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12985
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12986
|
+
"rect",
|
|
12987
|
+
{
|
|
12988
|
+
width: "12",
|
|
12989
|
+
height: "12",
|
|
12990
|
+
fill: "white",
|
|
12991
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12992
|
+
}
|
|
12993
|
+
) }),
|
|
12994
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12995
|
+
"rect",
|
|
12996
|
+
{
|
|
12997
|
+
width: "12",
|
|
12998
|
+
height: "12",
|
|
12999
|
+
fill: "white",
|
|
13000
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
13001
|
+
}
|
|
13002
|
+
) }),
|
|
13003
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13004
|
+
"rect",
|
|
13005
|
+
{
|
|
13006
|
+
width: "12",
|
|
13007
|
+
height: "12",
|
|
13008
|
+
fill: "white",
|
|
13009
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
13010
|
+
}
|
|
13011
|
+
) }),
|
|
13012
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
+
"rect",
|
|
13014
|
+
{
|
|
13015
|
+
width: "12",
|
|
13016
|
+
height: "12",
|
|
13017
|
+
fill: "white",
|
|
13018
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
13019
|
+
}
|
|
13020
|
+
) }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
+
"rect",
|
|
13023
|
+
{
|
|
13024
|
+
width: "12",
|
|
13025
|
+
height: "12",
|
|
13026
|
+
fill: "white",
|
|
13027
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13028
|
+
}
|
|
13029
|
+
) }),
|
|
13030
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13031
|
+
"rect",
|
|
13032
|
+
{
|
|
13033
|
+
width: "12",
|
|
13034
|
+
height: "12",
|
|
13035
|
+
fill: "white",
|
|
13036
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13037
|
+
}
|
|
13038
|
+
) })
|
|
13039
|
+
] })
|
|
12992
13040
|
]
|
|
12993
|
-
}
|
|
12994
|
-
promotion.id
|
|
13041
|
+
}
|
|
12995
13042
|
);
|
|
12996
13043
|
};
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
13000
|
-
if (!value) {
|
|
13001
|
-
return null;
|
|
13002
|
-
}
|
|
13003
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
13004
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
13005
|
-
if (!currency) {
|
|
13006
|
-
return null;
|
|
13007
|
-
}
|
|
13008
|
-
return getLocaleAmount(value, currency);
|
|
13009
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
13010
|
-
return formatPercentage(value);
|
|
13011
|
-
}
|
|
13012
|
-
return null;
|
|
13013
|
-
}
|
|
13014
|
-
const formatter = new Intl.NumberFormat([], {
|
|
13015
|
-
style: "percent",
|
|
13016
|
-
minimumFractionDigits: 2
|
|
13044
|
+
const schema = objectType({
|
|
13045
|
+
customer_id: stringType().min(1)
|
|
13017
13046
|
});
|
|
13018
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
13019
|
-
let val = value || 0;
|
|
13020
|
-
if (!isPercentageValue) {
|
|
13021
|
-
val = val / 100;
|
|
13022
|
-
}
|
|
13023
|
-
return formatter.format(val);
|
|
13024
|
-
};
|
|
13025
|
-
function getPromotionIds(items, shippingMethods) {
|
|
13026
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
13027
|
-
for (const item of items) {
|
|
13028
|
-
if (item.adjustments) {
|
|
13029
|
-
for (const adjustment of item.adjustments) {
|
|
13030
|
-
if (adjustment.promotion_id) {
|
|
13031
|
-
promotionIds.add(adjustment.promotion_id);
|
|
13032
|
-
}
|
|
13033
|
-
}
|
|
13034
|
-
}
|
|
13035
|
-
}
|
|
13036
|
-
for (const shippingMethod of shippingMethods) {
|
|
13037
|
-
if (shippingMethod.adjustments) {
|
|
13038
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
13039
|
-
if (adjustment.promotion_id) {
|
|
13040
|
-
promotionIds.add(adjustment.promotion_id);
|
|
13041
|
-
}
|
|
13042
|
-
}
|
|
13043
|
-
}
|
|
13044
|
-
}
|
|
13045
|
-
return Array.from(promotionIds);
|
|
13046
|
-
}
|
|
13047
13047
|
const widgetModule = { widgets: [] };
|
|
13048
13048
|
const routeModule = {
|
|
13049
13049
|
routes: [
|
|
@@ -13064,14 +13064,14 @@ const routeModule = {
|
|
|
13064
13064
|
handle,
|
|
13065
13065
|
loader,
|
|
13066
13066
|
children: [
|
|
13067
|
-
{
|
|
13068
|
-
Component: BillingAddress,
|
|
13069
|
-
path: "/draft-orders/:id/billing-address"
|
|
13070
|
-
},
|
|
13071
13067
|
{
|
|
13072
13068
|
Component: CustomItems,
|
|
13073
13069
|
path: "/draft-orders/:id/custom-items"
|
|
13074
13070
|
},
|
|
13071
|
+
{
|
|
13072
|
+
Component: BillingAddress,
|
|
13073
|
+
path: "/draft-orders/:id/billing-address"
|
|
13074
|
+
},
|
|
13075
13075
|
{
|
|
13076
13076
|
Component: Email,
|
|
13077
13077
|
path: "/draft-orders/:id/email"
|
|
@@ -13084,6 +13084,10 @@ const routeModule = {
|
|
|
13084
13084
|
Component: Metadata,
|
|
13085
13085
|
path: "/draft-orders/:id/metadata"
|
|
13086
13086
|
},
|
|
13087
|
+
{
|
|
13088
|
+
Component: Promotions,
|
|
13089
|
+
path: "/draft-orders/:id/promotions"
|
|
13090
|
+
},
|
|
13087
13091
|
{
|
|
13088
13092
|
Component: SalesChannel,
|
|
13089
13093
|
path: "/draft-orders/:id/sales-channel"
|
|
@@ -13099,10 +13103,6 @@ const routeModule = {
|
|
|
13099
13103
|
{
|
|
13100
13104
|
Component: TransferOwnership,
|
|
13101
13105
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13102
|
-
},
|
|
13103
|
-
{
|
|
13104
|
-
Component: Promotions,
|
|
13105
|
-
path: "/draft-orders/:id/promotions"
|
|
13106
13106
|
}
|
|
13107
13107
|
]
|
|
13108
13108
|
}
|
|
@@ -13115,6 +13115,7 @@ const menuItemModule = {
|
|
|
13115
13115
|
icon: void 0,
|
|
13116
13116
|
path: "/draft-orders",
|
|
13117
13117
|
nested: "/orders",
|
|
13118
|
+
rank: void 0,
|
|
13118
13119
|
translationNs: void 0
|
|
13119
13120
|
}
|
|
13120
13121
|
]
|