@medusajs/draft-order 2.10.4-preview-20250922120207 → 2.10.4-preview-20250922150158
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 +425 -425
- package/.medusa/server/src/admin/index.mjs +425 -425
- package/package.json +16 -16
|
@@ -9567,6 +9567,27 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
+
const CustomItems = () => {
|
|
9571
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9572
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9573
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9574
|
+
] });
|
|
9575
|
+
};
|
|
9576
|
+
const CustomItemsForm = () => {
|
|
9577
|
+
const form = useForm({
|
|
9578
|
+
resolver: zodResolver(schema$5)
|
|
9579
|
+
});
|
|
9580
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9582
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9583
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9584
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9585
|
+
] }) })
|
|
9586
|
+
] }) });
|
|
9587
|
+
};
|
|
9588
|
+
const schema$5 = objectType({
|
|
9589
|
+
email: stringType().email()
|
|
9590
|
+
});
|
|
9570
9591
|
const Email = () => {
|
|
9571
9592
|
const { id } = useParams();
|
|
9572
9593
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9589,7 +9610,7 @@ const EmailForm = ({ order }) => {
|
|
|
9589
9610
|
defaultValues: {
|
|
9590
9611
|
email: order.email ?? ""
|
|
9591
9612
|
},
|
|
9592
|
-
resolver: zodResolver(schema$
|
|
9613
|
+
resolver: zodResolver(schema$4)
|
|
9593
9614
|
});
|
|
9594
9615
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9595
9616
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9632,27 +9653,6 @@ const EmailForm = ({ order }) => {
|
|
|
9632
9653
|
}
|
|
9633
9654
|
) });
|
|
9634
9655
|
};
|
|
9635
|
-
const schema$5 = objectType({
|
|
9636
|
-
email: stringType().email()
|
|
9637
|
-
});
|
|
9638
|
-
const CustomItems = () => {
|
|
9639
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9640
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9641
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9642
|
-
] });
|
|
9643
|
-
};
|
|
9644
|
-
const CustomItemsForm = () => {
|
|
9645
|
-
const form = useForm({
|
|
9646
|
-
resolver: zodResolver(schema$4)
|
|
9647
|
-
});
|
|
9648
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9649
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9650
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9651
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9652
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9653
|
-
] }) })
|
|
9654
|
-
] }) });
|
|
9655
|
-
};
|
|
9656
9656
|
const schema$4 = objectType({
|
|
9657
9657
|
email: stringType().email()
|
|
9658
9658
|
});
|
|
@@ -11257,386 +11257,77 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11257
11257
|
}
|
|
11258
11258
|
return Array.from(promotionIds);
|
|
11259
11259
|
}
|
|
11260
|
-
const
|
|
11260
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11261
|
+
const Shipping = () => {
|
|
11262
|
+
var _a;
|
|
11261
11263
|
const { id } = useParams();
|
|
11262
|
-
const {
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
);
|
|
11264
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11265
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11266
|
+
});
|
|
11267
|
+
const {
|
|
11268
|
+
order: preview,
|
|
11269
|
+
isPending: isPreviewPending,
|
|
11270
|
+
isError: isPreviewError,
|
|
11271
|
+
error: previewError
|
|
11272
|
+
} = useOrderPreview(id);
|
|
11273
|
+
useInitiateOrderEdit({ preview });
|
|
11274
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11271
11275
|
if (isError) {
|
|
11272
11276
|
throw error;
|
|
11273
11277
|
}
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11278
|
+
if (isPreviewError) {
|
|
11279
|
+
throw previewError;
|
|
11280
|
+
}
|
|
11281
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11282
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11283
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11284
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11285
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__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 py-16 px-6", children: [
|
|
11286
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11287
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11288
|
+
] }) }) }),
|
|
11289
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11290
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11291
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11292
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11293
|
+
] }) });
|
|
11282
11294
|
};
|
|
11283
|
-
const
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
}
|
|
11290
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11291
|
-
const { handleSuccess } = useRouteModal();
|
|
11292
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11293
|
-
await mutateAsync(
|
|
11294
|
-
{
|
|
11295
|
-
sales_channel_id: data.sales_channel_id
|
|
11296
|
-
},
|
|
11297
|
-
{
|
|
11298
|
-
onSuccess: () => {
|
|
11299
|
-
toast.success("Sales channel updated");
|
|
11300
|
-
handleSuccess();
|
|
11301
|
-
},
|
|
11302
|
-
onError: (error) => {
|
|
11303
|
-
toast.error(error.message);
|
|
11304
|
-
}
|
|
11305
|
-
}
|
|
11306
|
-
);
|
|
11307
|
-
});
|
|
11308
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11309
|
-
KeyboundForm,
|
|
11295
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11296
|
+
var _a;
|
|
11297
|
+
const { setIsOpen } = useStackedModal();
|
|
11298
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11299
|
+
const [data, setData] = useState(null);
|
|
11300
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11301
|
+
const { shipping_options } = useShippingOptions(
|
|
11310
11302
|
{
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
children: [
|
|
11314
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11315
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11316
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11317
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11318
|
-
] }) })
|
|
11319
|
-
]
|
|
11320
|
-
}
|
|
11321
|
-
) });
|
|
11322
|
-
};
|
|
11323
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11324
|
-
const salesChannels = useComboboxData({
|
|
11325
|
-
queryFn: async (params) => {
|
|
11326
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11327
|
-
},
|
|
11328
|
-
queryKey: ["sales-channels"],
|
|
11329
|
-
getOptions: (data) => {
|
|
11330
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11331
|
-
label: salesChannel.name,
|
|
11332
|
-
value: salesChannel.id
|
|
11333
|
-
}));
|
|
11303
|
+
id: appliedShippingOptionIds,
|
|
11304
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11334
11305
|
},
|
|
11335
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11336
|
-
});
|
|
11337
|
-
return /* @__PURE__ */ jsx(
|
|
11338
|
-
Form$2.Field,
|
|
11339
11306
|
{
|
|
11340
|
-
|
|
11341
|
-
name: "sales_channel_id",
|
|
11342
|
-
render: ({ field }) => {
|
|
11343
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11344
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11345
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11346
|
-
Combobox,
|
|
11347
|
-
{
|
|
11348
|
-
options: salesChannels.options,
|
|
11349
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11350
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11351
|
-
searchValue: salesChannels.searchValue,
|
|
11352
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11353
|
-
placeholder: "Select sales channel",
|
|
11354
|
-
...field
|
|
11355
|
-
}
|
|
11356
|
-
) }),
|
|
11357
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11358
|
-
] });
|
|
11359
|
-
}
|
|
11307
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11360
11308
|
}
|
|
11361
11309
|
);
|
|
11362
|
-
|
|
11363
|
-
const
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
throw error;
|
|
11373
|
-
}
|
|
11374
|
-
const isReady = !isPending && !!order;
|
|
11375
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11376
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11377
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
11378
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11379
|
-
] }),
|
|
11380
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
11381
|
-
] });
|
|
11382
|
-
};
|
|
11383
|
-
const ShippingAddressForm = ({ order }) => {
|
|
11384
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11385
|
-
const form = useForm({
|
|
11386
|
-
defaultValues: {
|
|
11387
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11388
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11389
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11390
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11391
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11392
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11393
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11394
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11395
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11396
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11397
|
-
},
|
|
11398
|
-
resolver: zodResolver(schema$2)
|
|
11399
|
-
});
|
|
11400
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11310
|
+
const uniqueShippingProfiles = useMemo(() => {
|
|
11311
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11312
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11313
|
+
profiles.set(profile.id, profile);
|
|
11314
|
+
});
|
|
11315
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11316
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11317
|
+
});
|
|
11318
|
+
return Array.from(profiles.values());
|
|
11319
|
+
}, [order.items, shipping_options]);
|
|
11401
11320
|
const { handleSuccess } = useRouteModal();
|
|
11402
|
-
const
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
province: data.province,
|
|
11413
|
-
country_code: data.country_code,
|
|
11414
|
-
postal_code: data.postal_code,
|
|
11415
|
-
phone: data.phone
|
|
11416
|
-
}
|
|
11417
|
-
},
|
|
11418
|
-
{
|
|
11419
|
-
onSuccess: () => {
|
|
11420
|
-
handleSuccess();
|
|
11421
|
-
},
|
|
11422
|
-
onError: (error) => {
|
|
11423
|
-
toast.error(error.message);
|
|
11424
|
-
}
|
|
11425
|
-
}
|
|
11426
|
-
);
|
|
11427
|
-
});
|
|
11428
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11429
|
-
KeyboundForm,
|
|
11430
|
-
{
|
|
11431
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11432
|
-
onSubmit,
|
|
11433
|
-
children: [
|
|
11434
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
11435
|
-
/* @__PURE__ */ jsx(
|
|
11436
|
-
Form$2.Field,
|
|
11437
|
-
{
|
|
11438
|
-
control: form.control,
|
|
11439
|
-
name: "country_code",
|
|
11440
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11441
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11442
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11443
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11444
|
-
] })
|
|
11445
|
-
}
|
|
11446
|
-
),
|
|
11447
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11448
|
-
/* @__PURE__ */ jsx(
|
|
11449
|
-
Form$2.Field,
|
|
11450
|
-
{
|
|
11451
|
-
control: form.control,
|
|
11452
|
-
name: "first_name",
|
|
11453
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11454
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11455
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11456
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11457
|
-
] })
|
|
11458
|
-
}
|
|
11459
|
-
),
|
|
11460
|
-
/* @__PURE__ */ jsx(
|
|
11461
|
-
Form$2.Field,
|
|
11462
|
-
{
|
|
11463
|
-
control: form.control,
|
|
11464
|
-
name: "last_name",
|
|
11465
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11466
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11467
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11468
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11469
|
-
] })
|
|
11470
|
-
}
|
|
11471
|
-
)
|
|
11472
|
-
] }),
|
|
11473
|
-
/* @__PURE__ */ jsx(
|
|
11474
|
-
Form$2.Field,
|
|
11475
|
-
{
|
|
11476
|
-
control: form.control,
|
|
11477
|
-
name: "company",
|
|
11478
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11479
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11480
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11481
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11482
|
-
] })
|
|
11483
|
-
}
|
|
11484
|
-
),
|
|
11485
|
-
/* @__PURE__ */ jsx(
|
|
11486
|
-
Form$2.Field,
|
|
11487
|
-
{
|
|
11488
|
-
control: form.control,
|
|
11489
|
-
name: "address_1",
|
|
11490
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11491
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11492
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11493
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11494
|
-
] })
|
|
11495
|
-
}
|
|
11496
|
-
),
|
|
11497
|
-
/* @__PURE__ */ jsx(
|
|
11498
|
-
Form$2.Field,
|
|
11499
|
-
{
|
|
11500
|
-
control: form.control,
|
|
11501
|
-
name: "address_2",
|
|
11502
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11503
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11504
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11505
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11506
|
-
] })
|
|
11507
|
-
}
|
|
11508
|
-
),
|
|
11509
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11510
|
-
/* @__PURE__ */ jsx(
|
|
11511
|
-
Form$2.Field,
|
|
11512
|
-
{
|
|
11513
|
-
control: form.control,
|
|
11514
|
-
name: "postal_code",
|
|
11515
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11516
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11517
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11518
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11519
|
-
] })
|
|
11520
|
-
}
|
|
11521
|
-
),
|
|
11522
|
-
/* @__PURE__ */ jsx(
|
|
11523
|
-
Form$2.Field,
|
|
11524
|
-
{
|
|
11525
|
-
control: form.control,
|
|
11526
|
-
name: "city",
|
|
11527
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11528
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11529
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11530
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11531
|
-
] })
|
|
11532
|
-
}
|
|
11533
|
-
)
|
|
11534
|
-
] }),
|
|
11535
|
-
/* @__PURE__ */ jsx(
|
|
11536
|
-
Form$2.Field,
|
|
11537
|
-
{
|
|
11538
|
-
control: form.control,
|
|
11539
|
-
name: "province",
|
|
11540
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11541
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11542
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11543
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11544
|
-
] })
|
|
11545
|
-
}
|
|
11546
|
-
),
|
|
11547
|
-
/* @__PURE__ */ jsx(
|
|
11548
|
-
Form$2.Field,
|
|
11549
|
-
{
|
|
11550
|
-
control: form.control,
|
|
11551
|
-
name: "phone",
|
|
11552
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11553
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11554
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11555
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11556
|
-
] })
|
|
11557
|
-
}
|
|
11558
|
-
)
|
|
11559
|
-
] }) }),
|
|
11560
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11561
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11562
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11563
|
-
] }) })
|
|
11564
|
-
]
|
|
11565
|
-
}
|
|
11566
|
-
) });
|
|
11567
|
-
};
|
|
11568
|
-
const schema$2 = addressSchema;
|
|
11569
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11570
|
-
const Shipping = () => {
|
|
11571
|
-
var _a;
|
|
11572
|
-
const { id } = useParams();
|
|
11573
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11574
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11575
|
-
});
|
|
11576
|
-
const {
|
|
11577
|
-
order: preview,
|
|
11578
|
-
isPending: isPreviewPending,
|
|
11579
|
-
isError: isPreviewError,
|
|
11580
|
-
error: previewError
|
|
11581
|
-
} = useOrderPreview(id);
|
|
11582
|
-
useInitiateOrderEdit({ preview });
|
|
11583
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11584
|
-
if (isError) {
|
|
11585
|
-
throw error;
|
|
11586
|
-
}
|
|
11587
|
-
if (isPreviewError) {
|
|
11588
|
-
throw previewError;
|
|
11589
|
-
}
|
|
11590
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11591
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11592
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11593
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11594
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__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 py-16 px-6", children: [
|
|
11595
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11596
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11597
|
-
] }) }) }),
|
|
11598
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11599
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11600
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11601
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11602
|
-
] }) });
|
|
11603
|
-
};
|
|
11604
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11605
|
-
var _a;
|
|
11606
|
-
const { setIsOpen } = useStackedModal();
|
|
11607
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11608
|
-
const [data, setData] = useState(null);
|
|
11609
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11610
|
-
const { shipping_options } = useShippingOptions(
|
|
11611
|
-
{
|
|
11612
|
-
id: appliedShippingOptionIds,
|
|
11613
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11614
|
-
},
|
|
11615
|
-
{
|
|
11616
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
11617
|
-
}
|
|
11618
|
-
);
|
|
11619
|
-
const uniqueShippingProfiles = useMemo(() => {
|
|
11620
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
11621
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11622
|
-
profiles.set(profile.id, profile);
|
|
11623
|
-
});
|
|
11624
|
-
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11625
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11626
|
-
});
|
|
11627
|
-
return Array.from(profiles.values());
|
|
11628
|
-
}, [order.items, shipping_options]);
|
|
11629
|
-
const { handleSuccess } = useRouteModal();
|
|
11630
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11631
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11632
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11633
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11634
|
-
const onSubmit = async () => {
|
|
11635
|
-
setIsSubmitting(true);
|
|
11636
|
-
let requestSucceeded = false;
|
|
11637
|
-
await requestOrderEdit(void 0, {
|
|
11638
|
-
onError: (e) => {
|
|
11639
|
-
toast.error(`Failed to request order edit: ${e.message}`);
|
|
11321
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11322
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11323
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11324
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11325
|
+
const onSubmit = async () => {
|
|
11326
|
+
setIsSubmitting(true);
|
|
11327
|
+
let requestSucceeded = false;
|
|
11328
|
+
await requestOrderEdit(void 0, {
|
|
11329
|
+
onError: (e) => {
|
|
11330
|
+
toast.error(`Failed to request order edit: ${e.message}`);
|
|
11640
11331
|
},
|
|
11641
11332
|
onSuccess: () => {
|
|
11642
11333
|
requestSucceeded = true;
|
|
@@ -12373,46 +12064,249 @@ const CustomAmountField = ({
|
|
|
12373
12064
|
}
|
|
12374
12065
|
);
|
|
12375
12066
|
};
|
|
12376
|
-
const
|
|
12067
|
+
const ShippingAddress = () => {
|
|
12377
12068
|
const { id } = useParams();
|
|
12378
|
-
const {
|
|
12379
|
-
fields: "
|
|
12069
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12070
|
+
fields: "+shipping_address"
|
|
12380
12071
|
});
|
|
12381
12072
|
if (isError) {
|
|
12382
12073
|
throw error;
|
|
12383
12074
|
}
|
|
12384
|
-
const isReady = !isPending && !!
|
|
12075
|
+
const isReady = !isPending && !!order;
|
|
12385
12076
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12386
12077
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12387
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12388
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12078
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12079
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12389
12080
|
] }),
|
|
12390
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12081
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12391
12082
|
] });
|
|
12392
12083
|
};
|
|
12393
|
-
const
|
|
12394
|
-
var _a, _b;
|
|
12084
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12085
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12395
12086
|
const form = useForm({
|
|
12396
12087
|
defaultValues: {
|
|
12397
|
-
|
|
12088
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12089
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12090
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12091
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12092
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12093
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12094
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12095
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12096
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12097
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12398
12098
|
},
|
|
12399
|
-
resolver: zodResolver(schema$
|
|
12099
|
+
resolver: zodResolver(schema$3)
|
|
12400
12100
|
});
|
|
12401
12101
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12402
12102
|
const { handleSuccess } = useRouteModal();
|
|
12403
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12404
|
-
const currentCustomer = order.customer ? {
|
|
12405
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12406
|
-
value: order.customer.id
|
|
12407
|
-
} : null;
|
|
12408
12103
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12409
12104
|
await mutateAsync(
|
|
12410
|
-
{ customer_id: data.customer_id },
|
|
12411
12105
|
{
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12106
|
+
shipping_address: {
|
|
12107
|
+
first_name: data.first_name,
|
|
12108
|
+
last_name: data.last_name,
|
|
12109
|
+
company: data.company,
|
|
12110
|
+
address_1: data.address_1,
|
|
12111
|
+
address_2: data.address_2,
|
|
12112
|
+
city: data.city,
|
|
12113
|
+
province: data.province,
|
|
12114
|
+
country_code: data.country_code,
|
|
12115
|
+
postal_code: data.postal_code,
|
|
12116
|
+
phone: data.phone
|
|
12117
|
+
}
|
|
12118
|
+
},
|
|
12119
|
+
{
|
|
12120
|
+
onSuccess: () => {
|
|
12121
|
+
handleSuccess();
|
|
12122
|
+
},
|
|
12123
|
+
onError: (error) => {
|
|
12124
|
+
toast.error(error.message);
|
|
12125
|
+
}
|
|
12126
|
+
}
|
|
12127
|
+
);
|
|
12128
|
+
});
|
|
12129
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12130
|
+
KeyboundForm,
|
|
12131
|
+
{
|
|
12132
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12133
|
+
onSubmit,
|
|
12134
|
+
children: [
|
|
12135
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12136
|
+
/* @__PURE__ */ jsx(
|
|
12137
|
+
Form$2.Field,
|
|
12138
|
+
{
|
|
12139
|
+
control: form.control,
|
|
12140
|
+
name: "country_code",
|
|
12141
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12142
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12143
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12144
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12145
|
+
] })
|
|
12146
|
+
}
|
|
12147
|
+
),
|
|
12148
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12149
|
+
/* @__PURE__ */ jsx(
|
|
12150
|
+
Form$2.Field,
|
|
12151
|
+
{
|
|
12152
|
+
control: form.control,
|
|
12153
|
+
name: "first_name",
|
|
12154
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12155
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12156
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12157
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12158
|
+
] })
|
|
12159
|
+
}
|
|
12160
|
+
),
|
|
12161
|
+
/* @__PURE__ */ jsx(
|
|
12162
|
+
Form$2.Field,
|
|
12163
|
+
{
|
|
12164
|
+
control: form.control,
|
|
12165
|
+
name: "last_name",
|
|
12166
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12167
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12168
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12169
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12170
|
+
] })
|
|
12171
|
+
}
|
|
12172
|
+
)
|
|
12173
|
+
] }),
|
|
12174
|
+
/* @__PURE__ */ jsx(
|
|
12175
|
+
Form$2.Field,
|
|
12176
|
+
{
|
|
12177
|
+
control: form.control,
|
|
12178
|
+
name: "company",
|
|
12179
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12180
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12181
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12182
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12183
|
+
] })
|
|
12184
|
+
}
|
|
12185
|
+
),
|
|
12186
|
+
/* @__PURE__ */ jsx(
|
|
12187
|
+
Form$2.Field,
|
|
12188
|
+
{
|
|
12189
|
+
control: form.control,
|
|
12190
|
+
name: "address_1",
|
|
12191
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12192
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12193
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12194
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12195
|
+
] })
|
|
12196
|
+
}
|
|
12197
|
+
),
|
|
12198
|
+
/* @__PURE__ */ jsx(
|
|
12199
|
+
Form$2.Field,
|
|
12200
|
+
{
|
|
12201
|
+
control: form.control,
|
|
12202
|
+
name: "address_2",
|
|
12203
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12204
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12205
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12206
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12207
|
+
] })
|
|
12208
|
+
}
|
|
12209
|
+
),
|
|
12210
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12211
|
+
/* @__PURE__ */ jsx(
|
|
12212
|
+
Form$2.Field,
|
|
12213
|
+
{
|
|
12214
|
+
control: form.control,
|
|
12215
|
+
name: "postal_code",
|
|
12216
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12217
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12218
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12219
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12220
|
+
] })
|
|
12221
|
+
}
|
|
12222
|
+
),
|
|
12223
|
+
/* @__PURE__ */ jsx(
|
|
12224
|
+
Form$2.Field,
|
|
12225
|
+
{
|
|
12226
|
+
control: form.control,
|
|
12227
|
+
name: "city",
|
|
12228
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12229
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12230
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12231
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12232
|
+
] })
|
|
12233
|
+
}
|
|
12234
|
+
)
|
|
12235
|
+
] }),
|
|
12236
|
+
/* @__PURE__ */ jsx(
|
|
12237
|
+
Form$2.Field,
|
|
12238
|
+
{
|
|
12239
|
+
control: form.control,
|
|
12240
|
+
name: "province",
|
|
12241
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12242
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12243
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12244
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12245
|
+
] })
|
|
12246
|
+
}
|
|
12247
|
+
),
|
|
12248
|
+
/* @__PURE__ */ jsx(
|
|
12249
|
+
Form$2.Field,
|
|
12250
|
+
{
|
|
12251
|
+
control: form.control,
|
|
12252
|
+
name: "phone",
|
|
12253
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12254
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12255
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12256
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12257
|
+
] })
|
|
12258
|
+
}
|
|
12259
|
+
)
|
|
12260
|
+
] }) }),
|
|
12261
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12262
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12263
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12264
|
+
] }) })
|
|
12265
|
+
]
|
|
12266
|
+
}
|
|
12267
|
+
) });
|
|
12268
|
+
};
|
|
12269
|
+
const schema$3 = addressSchema;
|
|
12270
|
+
const TransferOwnership = () => {
|
|
12271
|
+
const { id } = useParams();
|
|
12272
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12273
|
+
fields: "id,customer_id,customer.*"
|
|
12274
|
+
});
|
|
12275
|
+
if (isError) {
|
|
12276
|
+
throw error;
|
|
12277
|
+
}
|
|
12278
|
+
const isReady = !isPending && !!draft_order;
|
|
12279
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12280
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12281
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12282
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12283
|
+
] }),
|
|
12284
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12285
|
+
] });
|
|
12286
|
+
};
|
|
12287
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12288
|
+
var _a, _b;
|
|
12289
|
+
const form = useForm({
|
|
12290
|
+
defaultValues: {
|
|
12291
|
+
customer_id: order.customer_id || ""
|
|
12292
|
+
},
|
|
12293
|
+
resolver: zodResolver(schema$2)
|
|
12294
|
+
});
|
|
12295
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12296
|
+
const { handleSuccess } = useRouteModal();
|
|
12297
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12298
|
+
const currentCustomer = order.customer ? {
|
|
12299
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12300
|
+
value: order.customer.id
|
|
12301
|
+
} : null;
|
|
12302
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12303
|
+
await mutateAsync(
|
|
12304
|
+
{ customer_id: data.customer_id },
|
|
12305
|
+
{
|
|
12306
|
+
onSuccess: () => {
|
|
12307
|
+
toast.success("Customer updated");
|
|
12308
|
+
handleSuccess();
|
|
12309
|
+
},
|
|
12416
12310
|
onError: (error) => {
|
|
12417
12311
|
toast.error(error.message);
|
|
12418
12312
|
}
|
|
@@ -12846,7 +12740,7 @@ const Illustration = () => {
|
|
|
12846
12740
|
}
|
|
12847
12741
|
);
|
|
12848
12742
|
};
|
|
12849
|
-
const schema$
|
|
12743
|
+
const schema$2 = objectType({
|
|
12850
12744
|
customer_id: stringType().min(1)
|
|
12851
12745
|
});
|
|
12852
12746
|
const BillingAddress = () => {
|
|
@@ -12881,7 +12775,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
12881
12775
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12882
12776
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12883
12777
|
},
|
|
12884
|
-
resolver: zodResolver(schema)
|
|
12778
|
+
resolver: zodResolver(schema$1)
|
|
12885
12779
|
});
|
|
12886
12780
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12887
12781
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13038,7 +12932,113 @@ const BillingAddressForm = ({ order }) => {
|
|
|
13038
12932
|
}
|
|
13039
12933
|
) });
|
|
13040
12934
|
};
|
|
13041
|
-
const schema = addressSchema;
|
|
12935
|
+
const schema$1 = addressSchema;
|
|
12936
|
+
const SalesChannel = () => {
|
|
12937
|
+
const { id } = useParams();
|
|
12938
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12939
|
+
id,
|
|
12940
|
+
{
|
|
12941
|
+
fields: "+sales_channel_id"
|
|
12942
|
+
},
|
|
12943
|
+
{
|
|
12944
|
+
enabled: !!id
|
|
12945
|
+
}
|
|
12946
|
+
);
|
|
12947
|
+
if (isError) {
|
|
12948
|
+
throw error;
|
|
12949
|
+
}
|
|
12950
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12951
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12953
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12955
|
+
] }),
|
|
12956
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12957
|
+
] });
|
|
12958
|
+
};
|
|
12959
|
+
const SalesChannelForm = ({ order }) => {
|
|
12960
|
+
const form = useForm({
|
|
12961
|
+
defaultValues: {
|
|
12962
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12963
|
+
},
|
|
12964
|
+
resolver: zodResolver(schema)
|
|
12965
|
+
});
|
|
12966
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12967
|
+
const { handleSuccess } = useRouteModal();
|
|
12968
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12969
|
+
await mutateAsync(
|
|
12970
|
+
{
|
|
12971
|
+
sales_channel_id: data.sales_channel_id
|
|
12972
|
+
},
|
|
12973
|
+
{
|
|
12974
|
+
onSuccess: () => {
|
|
12975
|
+
toast.success("Sales channel updated");
|
|
12976
|
+
handleSuccess();
|
|
12977
|
+
},
|
|
12978
|
+
onError: (error) => {
|
|
12979
|
+
toast.error(error.message);
|
|
12980
|
+
}
|
|
12981
|
+
}
|
|
12982
|
+
);
|
|
12983
|
+
});
|
|
12984
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12985
|
+
KeyboundForm,
|
|
12986
|
+
{
|
|
12987
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12988
|
+
onSubmit,
|
|
12989
|
+
children: [
|
|
12990
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12992
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12993
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12994
|
+
] }) })
|
|
12995
|
+
]
|
|
12996
|
+
}
|
|
12997
|
+
) });
|
|
12998
|
+
};
|
|
12999
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13000
|
+
const salesChannels = useComboboxData({
|
|
13001
|
+
queryFn: async (params) => {
|
|
13002
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13003
|
+
},
|
|
13004
|
+
queryKey: ["sales-channels"],
|
|
13005
|
+
getOptions: (data) => {
|
|
13006
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13007
|
+
label: salesChannel.name,
|
|
13008
|
+
value: salesChannel.id
|
|
13009
|
+
}));
|
|
13010
|
+
},
|
|
13011
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13012
|
+
});
|
|
13013
|
+
return /* @__PURE__ */ jsx(
|
|
13014
|
+
Form$2.Field,
|
|
13015
|
+
{
|
|
13016
|
+
control,
|
|
13017
|
+
name: "sales_channel_id",
|
|
13018
|
+
render: ({ field }) => {
|
|
13019
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13020
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13021
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13022
|
+
Combobox,
|
|
13023
|
+
{
|
|
13024
|
+
options: salesChannels.options,
|
|
13025
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13026
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13027
|
+
searchValue: salesChannels.searchValue,
|
|
13028
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13029
|
+
placeholder: "Select sales channel",
|
|
13030
|
+
...field
|
|
13031
|
+
}
|
|
13032
|
+
) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13034
|
+
] });
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
);
|
|
13038
|
+
};
|
|
13039
|
+
const schema = objectType({
|
|
13040
|
+
sales_channel_id: stringType().min(1)
|
|
13041
|
+
});
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -13059,14 +13059,14 @@ const routeModule = {
|
|
|
13059
13059
|
handle,
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
|
-
{
|
|
13063
|
-
Component: Email,
|
|
13064
|
-
path: "/draft-orders/:id/email"
|
|
13065
|
-
},
|
|
13066
13062
|
{
|
|
13067
13063
|
Component: CustomItems,
|
|
13068
13064
|
path: "/draft-orders/:id/custom-items"
|
|
13069
13065
|
},
|
|
13066
|
+
{
|
|
13067
|
+
Component: Email,
|
|
13068
|
+
path: "/draft-orders/:id/email"
|
|
13069
|
+
},
|
|
13070
13070
|
{
|
|
13071
13071
|
Component: Items,
|
|
13072
13072
|
path: "/draft-orders/:id/items"
|
|
@@ -13080,17 +13080,13 @@ const routeModule = {
|
|
|
13080
13080
|
path: "/draft-orders/:id/promotions"
|
|
13081
13081
|
},
|
|
13082
13082
|
{
|
|
13083
|
-
Component:
|
|
13084
|
-
path: "/draft-orders/:id/
|
|
13083
|
+
Component: Shipping,
|
|
13084
|
+
path: "/draft-orders/:id/shipping"
|
|
13085
13085
|
},
|
|
13086
13086
|
{
|
|
13087
13087
|
Component: ShippingAddress,
|
|
13088
13088
|
path: "/draft-orders/:id/shipping-address"
|
|
13089
13089
|
},
|
|
13090
|
-
{
|
|
13091
|
-
Component: Shipping,
|
|
13092
|
-
path: "/draft-orders/:id/shipping"
|
|
13093
|
-
},
|
|
13094
13090
|
{
|
|
13095
13091
|
Component: TransferOwnership,
|
|
13096
13092
|
path: "/draft-orders/:id/transfer-ownership"
|
|
@@ -13098,6 +13094,10 @@ const routeModule = {
|
|
|
13098
13094
|
{
|
|
13099
13095
|
Component: BillingAddress,
|
|
13100
13096
|
path: "/draft-orders/:id/billing-address"
|
|
13097
|
+
},
|
|
13098
|
+
{
|
|
13099
|
+
Component: SalesChannel,
|
|
13100
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|