@medusajs/draft-order 2.11.2-preview-20251027000324 → 2.11.2-preview-20251027032612
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 +374 -374
- package/.medusa/server/src/admin/index.mjs +374 -374
- package/package.json +16 -16
|
@@ -9565,10 +9565,31 @@ const ID = () => {
|
|
|
9565
9565
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9566
9566
|
] });
|
|
9567
9567
|
};
|
|
9568
|
-
const
|
|
9568
|
+
const CustomItems = () => {
|
|
9569
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9570
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9571
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9572
|
+
] });
|
|
9573
|
+
};
|
|
9574
|
+
const CustomItemsForm = () => {
|
|
9575
|
+
const form = useForm({
|
|
9576
|
+
resolver: zodResolver(schema$5)
|
|
9577
|
+
});
|
|
9578
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9579
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9580
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9582
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9583
|
+
] }) })
|
|
9584
|
+
] }) });
|
|
9585
|
+
};
|
|
9586
|
+
const schema$5 = objectType({
|
|
9587
|
+
email: stringType().email()
|
|
9588
|
+
});
|
|
9589
|
+
const Email = () => {
|
|
9569
9590
|
const { id } = useParams();
|
|
9570
9591
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9571
|
-
fields: "+
|
|
9592
|
+
fields: "+email"
|
|
9572
9593
|
});
|
|
9573
9594
|
if (isError) {
|
|
9574
9595
|
throw error;
|
|
@@ -9576,34 +9597,24 @@ const BillingAddress = () => {
|
|
|
9576
9597
|
const isReady = !isPending && !!order;
|
|
9577
9598
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9578
9599
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9579
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
9580
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
9600
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9601
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9581
9602
|
] }),
|
|
9582
|
-
isReady && /* @__PURE__ */ jsx(
|
|
9603
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9583
9604
|
] });
|
|
9584
9605
|
};
|
|
9585
|
-
const
|
|
9586
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9606
|
+
const EmailForm = ({ order }) => {
|
|
9587
9607
|
const form = useForm({
|
|
9588
9608
|
defaultValues: {
|
|
9589
|
-
|
|
9590
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9591
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9592
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9593
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9594
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9595
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9596
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9597
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9598
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9609
|
+
email: order.email ?? ""
|
|
9599
9610
|
},
|
|
9600
|
-
resolver: zodResolver(schema$
|
|
9611
|
+
resolver: zodResolver(schema$4)
|
|
9601
9612
|
});
|
|
9602
9613
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
9614
|
const { handleSuccess } = useRouteModal();
|
|
9604
9615
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9605
9616
|
await mutateAsync(
|
|
9606
|
-
{
|
|
9617
|
+
{ email: data.email },
|
|
9607
9618
|
{
|
|
9608
9619
|
onSuccess: () => {
|
|
9609
9620
|
handleSuccess();
|
|
@@ -9620,132 +9631,18 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9620
9631
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9621
9632
|
onSubmit,
|
|
9622
9633
|
children: [
|
|
9623
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
),
|
|
9636
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9637
|
-
/* @__PURE__ */ jsx(
|
|
9638
|
-
Form$2.Field,
|
|
9639
|
-
{
|
|
9640
|
-
control: form.control,
|
|
9641
|
-
name: "first_name",
|
|
9642
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9643
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9644
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9645
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9646
|
-
] })
|
|
9647
|
-
}
|
|
9648
|
-
),
|
|
9649
|
-
/* @__PURE__ */ jsx(
|
|
9650
|
-
Form$2.Field,
|
|
9651
|
-
{
|
|
9652
|
-
control: form.control,
|
|
9653
|
-
name: "last_name",
|
|
9654
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9655
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9656
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9657
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9658
|
-
] })
|
|
9659
|
-
}
|
|
9660
|
-
)
|
|
9661
|
-
] }),
|
|
9662
|
-
/* @__PURE__ */ jsx(
|
|
9663
|
-
Form$2.Field,
|
|
9664
|
-
{
|
|
9665
|
-
control: form.control,
|
|
9666
|
-
name: "company",
|
|
9667
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9668
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9669
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9670
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9671
|
-
] })
|
|
9672
|
-
}
|
|
9673
|
-
),
|
|
9674
|
-
/* @__PURE__ */ jsx(
|
|
9675
|
-
Form$2.Field,
|
|
9676
|
-
{
|
|
9677
|
-
control: form.control,
|
|
9678
|
-
name: "address_1",
|
|
9679
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9680
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9681
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9682
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9683
|
-
] })
|
|
9684
|
-
}
|
|
9685
|
-
),
|
|
9686
|
-
/* @__PURE__ */ jsx(
|
|
9687
|
-
Form$2.Field,
|
|
9688
|
-
{
|
|
9689
|
-
control: form.control,
|
|
9690
|
-
name: "address_2",
|
|
9691
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9692
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9693
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9694
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9695
|
-
] })
|
|
9696
|
-
}
|
|
9697
|
-
),
|
|
9698
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9699
|
-
/* @__PURE__ */ jsx(
|
|
9700
|
-
Form$2.Field,
|
|
9701
|
-
{
|
|
9702
|
-
control: form.control,
|
|
9703
|
-
name: "postal_code",
|
|
9704
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9705
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9706
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9707
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9708
|
-
] })
|
|
9709
|
-
}
|
|
9710
|
-
),
|
|
9711
|
-
/* @__PURE__ */ jsx(
|
|
9712
|
-
Form$2.Field,
|
|
9713
|
-
{
|
|
9714
|
-
control: form.control,
|
|
9715
|
-
name: "city",
|
|
9716
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9717
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9718
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9719
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9720
|
-
] })
|
|
9721
|
-
}
|
|
9722
|
-
)
|
|
9723
|
-
] }),
|
|
9724
|
-
/* @__PURE__ */ jsx(
|
|
9725
|
-
Form$2.Field,
|
|
9726
|
-
{
|
|
9727
|
-
control: form.control,
|
|
9728
|
-
name: "province",
|
|
9729
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9730
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9731
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9732
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9733
|
-
] })
|
|
9734
|
-
}
|
|
9735
|
-
),
|
|
9736
|
-
/* @__PURE__ */ jsx(
|
|
9737
|
-
Form$2.Field,
|
|
9738
|
-
{
|
|
9739
|
-
control: form.control,
|
|
9740
|
-
name: "phone",
|
|
9741
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9742
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9743
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9744
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9745
|
-
] })
|
|
9746
|
-
}
|
|
9747
|
-
)
|
|
9748
|
-
] }) }),
|
|
9634
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9635
|
+
Form$2.Field,
|
|
9636
|
+
{
|
|
9637
|
+
control: form.control,
|
|
9638
|
+
name: "email",
|
|
9639
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9640
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9641
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9642
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9643
|
+
] })
|
|
9644
|
+
}
|
|
9645
|
+
) }),
|
|
9749
9646
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9750
9647
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9751
9648
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9754,7 +9651,9 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9754
9651
|
}
|
|
9755
9652
|
) });
|
|
9756
9653
|
};
|
|
9757
|
-
const schema$
|
|
9654
|
+
const schema$4 = objectType({
|
|
9655
|
+
email: stringType().email()
|
|
9656
|
+
});
|
|
9758
9657
|
const NumberInput = forwardRef(
|
|
9759
9658
|
({
|
|
9760
9659
|
value,
|
|
@@ -11356,74 +11255,180 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11356
11255
|
}
|
|
11357
11256
|
return Array.from(promotionIds);
|
|
11358
11257
|
}
|
|
11359
|
-
const
|
|
11360
|
-
const Shipping = () => {
|
|
11361
|
-
var _a;
|
|
11258
|
+
const SalesChannel = () => {
|
|
11362
11259
|
const { id } = useParams();
|
|
11363
|
-
const {
|
|
11364
|
-
|
|
11365
|
-
});
|
|
11366
|
-
const {
|
|
11367
|
-
order: preview,
|
|
11368
|
-
isPending: isPreviewPending,
|
|
11369
|
-
isError: isPreviewError,
|
|
11370
|
-
error: previewError
|
|
11371
|
-
} = useOrderPreview(id);
|
|
11372
|
-
useInitiateOrderEdit({ preview });
|
|
11373
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11374
|
-
if (isError) {
|
|
11375
|
-
throw error;
|
|
11376
|
-
}
|
|
11377
|
-
if (isPreviewError) {
|
|
11378
|
-
throw previewError;
|
|
11379
|
-
}
|
|
11380
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11381
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11382
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11383
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11384
|
-
/* @__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: [
|
|
11385
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11386
|
-
/* @__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." }) })
|
|
11387
|
-
] }) }) }),
|
|
11388
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11389
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11390
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11391
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11392
|
-
] }) });
|
|
11393
|
-
};
|
|
11394
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11395
|
-
var _a;
|
|
11396
|
-
const { setIsOpen } = useStackedModal();
|
|
11397
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11398
|
-
const [data, setData] = useState(null);
|
|
11399
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11400
|
-
const { shipping_options } = useShippingOptions(
|
|
11260
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11261
|
+
id,
|
|
11401
11262
|
{
|
|
11402
|
-
|
|
11403
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11263
|
+
fields: "+sales_channel_id"
|
|
11404
11264
|
},
|
|
11405
11265
|
{
|
|
11406
|
-
enabled:
|
|
11266
|
+
enabled: !!id
|
|
11407
11267
|
}
|
|
11408
11268
|
);
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
const
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11269
|
+
if (isError) {
|
|
11270
|
+
throw error;
|
|
11271
|
+
}
|
|
11272
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11273
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11274
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11275
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11276
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11277
|
+
] }),
|
|
11278
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11279
|
+
] });
|
|
11280
|
+
};
|
|
11281
|
+
const SalesChannelForm = ({ order }) => {
|
|
11282
|
+
const form = useForm({
|
|
11283
|
+
defaultValues: {
|
|
11284
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11285
|
+
},
|
|
11286
|
+
resolver: zodResolver(schema$3)
|
|
11287
|
+
});
|
|
11288
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11289
|
+
const { handleSuccess } = useRouteModal();
|
|
11290
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11291
|
+
await mutateAsync(
|
|
11292
|
+
{
|
|
11293
|
+
sales_channel_id: data.sales_channel_id
|
|
11294
|
+
},
|
|
11295
|
+
{
|
|
11296
|
+
onSuccess: () => {
|
|
11297
|
+
toast.success("Sales channel updated");
|
|
11298
|
+
handleSuccess();
|
|
11299
|
+
},
|
|
11300
|
+
onError: (error) => {
|
|
11301
|
+
toast.error(error.message);
|
|
11302
|
+
}
|
|
11303
|
+
}
|
|
11304
|
+
);
|
|
11305
|
+
});
|
|
11306
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11307
|
+
KeyboundForm,
|
|
11308
|
+
{
|
|
11309
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11310
|
+
onSubmit,
|
|
11311
|
+
children: [
|
|
11312
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11313
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11314
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11315
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11316
|
+
] }) })
|
|
11317
|
+
]
|
|
11318
|
+
}
|
|
11319
|
+
) });
|
|
11320
|
+
};
|
|
11321
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11322
|
+
const salesChannels = useComboboxData({
|
|
11323
|
+
queryFn: async (params) => {
|
|
11324
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11325
|
+
},
|
|
11326
|
+
queryKey: ["sales-channels"],
|
|
11327
|
+
getOptions: (data) => {
|
|
11328
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11329
|
+
label: salesChannel.name,
|
|
11330
|
+
value: salesChannel.id
|
|
11331
|
+
}));
|
|
11332
|
+
},
|
|
11333
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11334
|
+
});
|
|
11335
|
+
return /* @__PURE__ */ jsx(
|
|
11336
|
+
Form$2.Field,
|
|
11337
|
+
{
|
|
11338
|
+
control,
|
|
11339
|
+
name: "sales_channel_id",
|
|
11340
|
+
render: ({ field }) => {
|
|
11341
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11342
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11343
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11344
|
+
Combobox,
|
|
11345
|
+
{
|
|
11346
|
+
options: salesChannels.options,
|
|
11347
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11348
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11349
|
+
searchValue: salesChannels.searchValue,
|
|
11350
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11351
|
+
placeholder: "Select sales channel",
|
|
11352
|
+
...field
|
|
11353
|
+
}
|
|
11354
|
+
) }),
|
|
11355
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11356
|
+
] });
|
|
11357
|
+
}
|
|
11358
|
+
}
|
|
11359
|
+
);
|
|
11360
|
+
};
|
|
11361
|
+
const schema$3 = objectType({
|
|
11362
|
+
sales_channel_id: stringType().min(1)
|
|
11363
|
+
});
|
|
11364
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11365
|
+
const Shipping = () => {
|
|
11366
|
+
var _a;
|
|
11367
|
+
const { id } = useParams();
|
|
11368
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11369
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11370
|
+
});
|
|
11371
|
+
const {
|
|
11372
|
+
order: preview,
|
|
11373
|
+
isPending: isPreviewPending,
|
|
11374
|
+
isError: isPreviewError,
|
|
11375
|
+
error: previewError
|
|
11376
|
+
} = useOrderPreview(id);
|
|
11377
|
+
useInitiateOrderEdit({ preview });
|
|
11378
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11379
|
+
if (isError) {
|
|
11380
|
+
throw error;
|
|
11381
|
+
}
|
|
11382
|
+
if (isPreviewError) {
|
|
11383
|
+
throw previewError;
|
|
11384
|
+
}
|
|
11385
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11386
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11387
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11388
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11389
|
+
/* @__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: [
|
|
11390
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11391
|
+
/* @__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." }) })
|
|
11392
|
+
] }) }) }),
|
|
11393
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11394
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11395
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11396
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11397
|
+
] }) });
|
|
11398
|
+
};
|
|
11399
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11400
|
+
var _a;
|
|
11401
|
+
const { setIsOpen } = useStackedModal();
|
|
11402
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11403
|
+
const [data, setData] = useState(null);
|
|
11404
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11405
|
+
const { shipping_options } = useShippingOptions(
|
|
11406
|
+
{
|
|
11407
|
+
id: appliedShippingOptionIds,
|
|
11408
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11409
|
+
},
|
|
11410
|
+
{
|
|
11411
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11412
|
+
}
|
|
11413
|
+
);
|
|
11414
|
+
const uniqueShippingProfiles = useMemo(() => {
|
|
11415
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11416
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11417
|
+
profiles.set(profile.id, profile);
|
|
11418
|
+
});
|
|
11419
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11420
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11421
|
+
});
|
|
11422
|
+
return Array.from(profiles.values());
|
|
11423
|
+
}, [order.items, shipping_options]);
|
|
11424
|
+
const { handleSuccess } = useRouteModal();
|
|
11425
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11426
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11427
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11428
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11429
|
+
const onSubmit = async () => {
|
|
11430
|
+
setIsSubmitting(true);
|
|
11431
|
+
let requestSucceeded = false;
|
|
11427
11432
|
await requestOrderEdit(void 0, {
|
|
11428
11433
|
onError: (e) => {
|
|
11429
11434
|
toast.error(`Failed to request order edit: ${e.message}`);
|
|
@@ -12163,112 +12168,6 @@ const CustomAmountField = ({
|
|
|
12163
12168
|
}
|
|
12164
12169
|
);
|
|
12165
12170
|
};
|
|
12166
|
-
const SalesChannel = () => {
|
|
12167
|
-
const { id } = useParams();
|
|
12168
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12169
|
-
id,
|
|
12170
|
-
{
|
|
12171
|
-
fields: "+sales_channel_id"
|
|
12172
|
-
},
|
|
12173
|
-
{
|
|
12174
|
-
enabled: !!id
|
|
12175
|
-
}
|
|
12176
|
-
);
|
|
12177
|
-
if (isError) {
|
|
12178
|
-
throw error;
|
|
12179
|
-
}
|
|
12180
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12181
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12182
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12183
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12184
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12185
|
-
] }),
|
|
12186
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12187
|
-
] });
|
|
12188
|
-
};
|
|
12189
|
-
const SalesChannelForm = ({ order }) => {
|
|
12190
|
-
const form = useForm({
|
|
12191
|
-
defaultValues: {
|
|
12192
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12193
|
-
},
|
|
12194
|
-
resolver: zodResolver(schema$4)
|
|
12195
|
-
});
|
|
12196
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12197
|
-
const { handleSuccess } = useRouteModal();
|
|
12198
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12199
|
-
await mutateAsync(
|
|
12200
|
-
{
|
|
12201
|
-
sales_channel_id: data.sales_channel_id
|
|
12202
|
-
},
|
|
12203
|
-
{
|
|
12204
|
-
onSuccess: () => {
|
|
12205
|
-
toast.success("Sales channel updated");
|
|
12206
|
-
handleSuccess();
|
|
12207
|
-
},
|
|
12208
|
-
onError: (error) => {
|
|
12209
|
-
toast.error(error.message);
|
|
12210
|
-
}
|
|
12211
|
-
}
|
|
12212
|
-
);
|
|
12213
|
-
});
|
|
12214
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12215
|
-
KeyboundForm,
|
|
12216
|
-
{
|
|
12217
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12218
|
-
onSubmit,
|
|
12219
|
-
children: [
|
|
12220
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12221
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12222
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12223
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12224
|
-
] }) })
|
|
12225
|
-
]
|
|
12226
|
-
}
|
|
12227
|
-
) });
|
|
12228
|
-
};
|
|
12229
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12230
|
-
const salesChannels = useComboboxData({
|
|
12231
|
-
queryFn: async (params) => {
|
|
12232
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12233
|
-
},
|
|
12234
|
-
queryKey: ["sales-channels"],
|
|
12235
|
-
getOptions: (data) => {
|
|
12236
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12237
|
-
label: salesChannel.name,
|
|
12238
|
-
value: salesChannel.id
|
|
12239
|
-
}));
|
|
12240
|
-
},
|
|
12241
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12242
|
-
});
|
|
12243
|
-
return /* @__PURE__ */ jsx(
|
|
12244
|
-
Form$2.Field,
|
|
12245
|
-
{
|
|
12246
|
-
control,
|
|
12247
|
-
name: "sales_channel_id",
|
|
12248
|
-
render: ({ field }) => {
|
|
12249
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12250
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12251
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12252
|
-
Combobox,
|
|
12253
|
-
{
|
|
12254
|
-
options: salesChannels.options,
|
|
12255
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12256
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12257
|
-
searchValue: salesChannels.searchValue,
|
|
12258
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12259
|
-
placeholder: "Select sales channel",
|
|
12260
|
-
...field
|
|
12261
|
-
}
|
|
12262
|
-
) }),
|
|
12263
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12264
|
-
] });
|
|
12265
|
-
}
|
|
12266
|
-
}
|
|
12267
|
-
);
|
|
12268
|
-
};
|
|
12269
|
-
const schema$4 = objectType({
|
|
12270
|
-
sales_channel_id: stringType().min(1)
|
|
12271
|
-
});
|
|
12272
12171
|
const ShippingAddress = () => {
|
|
12273
12172
|
const { id } = useParams();
|
|
12274
12173
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12301,7 +12200,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12301
12200
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12302
12201
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12303
12202
|
},
|
|
12304
|
-
resolver: zodResolver(schema$
|
|
12203
|
+
resolver: zodResolver(schema$2)
|
|
12305
12204
|
});
|
|
12306
12205
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12307
12206
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12471,7 +12370,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12471
12370
|
}
|
|
12472
12371
|
) });
|
|
12473
12372
|
};
|
|
12474
|
-
const schema$
|
|
12373
|
+
const schema$2 = addressSchema;
|
|
12475
12374
|
const TransferOwnership = () => {
|
|
12476
12375
|
const { id } = useParams();
|
|
12477
12376
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12495,7 +12394,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12495
12394
|
defaultValues: {
|
|
12496
12395
|
customer_id: order.customer_id || ""
|
|
12497
12396
|
},
|
|
12498
|
-
resolver: zodResolver(schema$
|
|
12397
|
+
resolver: zodResolver(schema$1)
|
|
12499
12398
|
});
|
|
12500
12399
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12501
12400
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12945,34 +12844,13 @@ const Illustration = () => {
|
|
|
12945
12844
|
}
|
|
12946
12845
|
);
|
|
12947
12846
|
};
|
|
12948
|
-
const schema$2 = objectType({
|
|
12949
|
-
customer_id: stringType().min(1)
|
|
12950
|
-
});
|
|
12951
|
-
const CustomItems = () => {
|
|
12952
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12953
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
12954
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
12955
|
-
] });
|
|
12956
|
-
};
|
|
12957
|
-
const CustomItemsForm = () => {
|
|
12958
|
-
const form = useForm({
|
|
12959
|
-
resolver: zodResolver(schema$1)
|
|
12960
|
-
});
|
|
12961
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12962
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
12963
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12964
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12965
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
12966
|
-
] }) })
|
|
12967
|
-
] }) });
|
|
12968
|
-
};
|
|
12969
12847
|
const schema$1 = objectType({
|
|
12970
|
-
|
|
12848
|
+
customer_id: stringType().min(1)
|
|
12971
12849
|
});
|
|
12972
|
-
const
|
|
12850
|
+
const BillingAddress = () => {
|
|
12973
12851
|
const { id } = useParams();
|
|
12974
12852
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12975
|
-
fields: "+
|
|
12853
|
+
fields: "+billing_address"
|
|
12976
12854
|
});
|
|
12977
12855
|
if (isError) {
|
|
12978
12856
|
throw error;
|
|
@@ -12980,16 +12858,26 @@ const Email = () => {
|
|
|
12980
12858
|
const isReady = !isPending && !!order;
|
|
12981
12859
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12982
12860
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12983
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12984
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
12861
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12862
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12985
12863
|
] }),
|
|
12986
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12864
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12987
12865
|
] });
|
|
12988
12866
|
};
|
|
12989
|
-
const
|
|
12867
|
+
const BillingAddressForm = ({ order }) => {
|
|
12868
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12990
12869
|
const form = useForm({
|
|
12991
12870
|
defaultValues: {
|
|
12992
|
-
|
|
12871
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12872
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12873
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12874
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12875
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12876
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12877
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12878
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12879
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12880
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12993
12881
|
},
|
|
12994
12882
|
resolver: zodResolver(schema)
|
|
12995
12883
|
});
|
|
@@ -12997,7 +12885,7 @@ const EmailForm = ({ order }) => {
|
|
|
12997
12885
|
const { handleSuccess } = useRouteModal();
|
|
12998
12886
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12999
12887
|
await mutateAsync(
|
|
13000
|
-
{
|
|
12888
|
+
{ billing_address: data },
|
|
13001
12889
|
{
|
|
13002
12890
|
onSuccess: () => {
|
|
13003
12891
|
handleSuccess();
|
|
@@ -13014,18 +12902,132 @@ const EmailForm = ({ order }) => {
|
|
|
13014
12902
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
13015
12903
|
onSubmit,
|
|
13016
12904
|
children: [
|
|
13017
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
/* @__PURE__ */
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
12905
|
+
/* @__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: [
|
|
12906
|
+
/* @__PURE__ */ jsx(
|
|
12907
|
+
Form$2.Field,
|
|
12908
|
+
{
|
|
12909
|
+
control: form.control,
|
|
12910
|
+
name: "country_code",
|
|
12911
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12912
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12913
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12915
|
+
] })
|
|
12916
|
+
}
|
|
12917
|
+
),
|
|
12918
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12919
|
+
/* @__PURE__ */ jsx(
|
|
12920
|
+
Form$2.Field,
|
|
12921
|
+
{
|
|
12922
|
+
control: form.control,
|
|
12923
|
+
name: "first_name",
|
|
12924
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12925
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12926
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12928
|
+
] })
|
|
12929
|
+
}
|
|
12930
|
+
),
|
|
12931
|
+
/* @__PURE__ */ jsx(
|
|
12932
|
+
Form$2.Field,
|
|
12933
|
+
{
|
|
12934
|
+
control: form.control,
|
|
12935
|
+
name: "last_name",
|
|
12936
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12937
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12938
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12940
|
+
] })
|
|
12941
|
+
}
|
|
12942
|
+
)
|
|
12943
|
+
] }),
|
|
12944
|
+
/* @__PURE__ */ jsx(
|
|
12945
|
+
Form$2.Field,
|
|
12946
|
+
{
|
|
12947
|
+
control: form.control,
|
|
12948
|
+
name: "company",
|
|
12949
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12950
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12951
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12953
|
+
] })
|
|
12954
|
+
}
|
|
12955
|
+
),
|
|
12956
|
+
/* @__PURE__ */ jsx(
|
|
12957
|
+
Form$2.Field,
|
|
12958
|
+
{
|
|
12959
|
+
control: form.control,
|
|
12960
|
+
name: "address_1",
|
|
12961
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12962
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12963
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12965
|
+
] })
|
|
12966
|
+
}
|
|
12967
|
+
),
|
|
12968
|
+
/* @__PURE__ */ jsx(
|
|
12969
|
+
Form$2.Field,
|
|
12970
|
+
{
|
|
12971
|
+
control: form.control,
|
|
12972
|
+
name: "address_2",
|
|
12973
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12974
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12975
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12977
|
+
] })
|
|
12978
|
+
}
|
|
12979
|
+
),
|
|
12980
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12981
|
+
/* @__PURE__ */ jsx(
|
|
12982
|
+
Form$2.Field,
|
|
12983
|
+
{
|
|
12984
|
+
control: form.control,
|
|
12985
|
+
name: "postal_code",
|
|
12986
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12987
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12988
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12990
|
+
] })
|
|
12991
|
+
}
|
|
12992
|
+
),
|
|
12993
|
+
/* @__PURE__ */ jsx(
|
|
12994
|
+
Form$2.Field,
|
|
12995
|
+
{
|
|
12996
|
+
control: form.control,
|
|
12997
|
+
name: "city",
|
|
12998
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12999
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13000
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13002
|
+
] })
|
|
13003
|
+
}
|
|
13004
|
+
)
|
|
13005
|
+
] }),
|
|
13006
|
+
/* @__PURE__ */ jsx(
|
|
13007
|
+
Form$2.Field,
|
|
13008
|
+
{
|
|
13009
|
+
control: form.control,
|
|
13010
|
+
name: "province",
|
|
13011
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13012
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13013
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13015
|
+
] })
|
|
13016
|
+
}
|
|
13017
|
+
),
|
|
13018
|
+
/* @__PURE__ */ jsx(
|
|
13019
|
+
Form$2.Field,
|
|
13020
|
+
{
|
|
13021
|
+
control: form.control,
|
|
13022
|
+
name: "phone",
|
|
13023
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13024
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13025
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13027
|
+
] })
|
|
13028
|
+
}
|
|
13029
|
+
)
|
|
13030
|
+
] }) }),
|
|
13029
13031
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13030
13032
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13031
13033
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -13034,9 +13036,7 @@ const EmailForm = ({ order }) => {
|
|
|
13034
13036
|
}
|
|
13035
13037
|
) });
|
|
13036
13038
|
};
|
|
13037
|
-
const schema =
|
|
13038
|
-
email: stringType().email()
|
|
13039
|
-
});
|
|
13039
|
+
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13058,8 +13058,12 @@ const routeModule = {
|
|
|
13058
13058
|
loader,
|
|
13059
13059
|
children: [
|
|
13060
13060
|
{
|
|
13061
|
-
Component:
|
|
13062
|
-
path: "/draft-orders/:id/
|
|
13061
|
+
Component: CustomItems,
|
|
13062
|
+
path: "/draft-orders/:id/custom-items"
|
|
13063
|
+
},
|
|
13064
|
+
{
|
|
13065
|
+
Component: Email,
|
|
13066
|
+
path: "/draft-orders/:id/email"
|
|
13063
13067
|
},
|
|
13064
13068
|
{
|
|
13065
13069
|
Component: Items,
|
|
@@ -13073,14 +13077,14 @@ const routeModule = {
|
|
|
13073
13077
|
Component: Promotions,
|
|
13074
13078
|
path: "/draft-orders/:id/promotions"
|
|
13075
13079
|
},
|
|
13076
|
-
{
|
|
13077
|
-
Component: Shipping,
|
|
13078
|
-
path: "/draft-orders/:id/shipping"
|
|
13079
|
-
},
|
|
13080
13080
|
{
|
|
13081
13081
|
Component: SalesChannel,
|
|
13082
13082
|
path: "/draft-orders/:id/sales-channel"
|
|
13083
13083
|
},
|
|
13084
|
+
{
|
|
13085
|
+
Component: Shipping,
|
|
13086
|
+
path: "/draft-orders/:id/shipping"
|
|
13087
|
+
},
|
|
13084
13088
|
{
|
|
13085
13089
|
Component: ShippingAddress,
|
|
13086
13090
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13090,12 +13094,8 @@ const routeModule = {
|
|
|
13090
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13091
13095
|
},
|
|
13092
13096
|
{
|
|
13093
|
-
Component:
|
|
13094
|
-
path: "/draft-orders/:id/
|
|
13095
|
-
},
|
|
13096
|
-
{
|
|
13097
|
-
Component: Email,
|
|
13098
|
-
path: "/draft-orders/:id/email"
|
|
13097
|
+
Component: BillingAddress,
|
|
13098
|
+
path: "/draft-orders/:id/billing-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|