@medusajs/draft-order 2.10.2-preview-20250903090152 → 2.10.2-preview-20250903120201
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 +450 -450
- package/.medusa/server/src/admin/index.mjs +450 -450
- package/package.json +16 -16
|
@@ -9554,6 +9554,196 @@ const ID = () => {
|
|
|
9554
9554
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9555
9555
|
] });
|
|
9556
9556
|
};
|
|
9557
|
+
const BillingAddress = () => {
|
|
9558
|
+
const { id } = useParams();
|
|
9559
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9560
|
+
fields: "+billing_address"
|
|
9561
|
+
});
|
|
9562
|
+
if (isError) {
|
|
9563
|
+
throw error;
|
|
9564
|
+
}
|
|
9565
|
+
const isReady = !isPending && !!order;
|
|
9566
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9567
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9568
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9569
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9570
|
+
] }),
|
|
9571
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9572
|
+
] });
|
|
9573
|
+
};
|
|
9574
|
+
const BillingAddressForm = ({ order }) => {
|
|
9575
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9576
|
+
const form = useForm({
|
|
9577
|
+
defaultValues: {
|
|
9578
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9579
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9580
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9581
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9582
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9583
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9584
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9585
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9586
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9587
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9588
|
+
},
|
|
9589
|
+
resolver: zodResolver(schema$5)
|
|
9590
|
+
});
|
|
9591
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9592
|
+
const { handleSuccess } = useRouteModal();
|
|
9593
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9594
|
+
await mutateAsync(
|
|
9595
|
+
{ billing_address: data },
|
|
9596
|
+
{
|
|
9597
|
+
onSuccess: () => {
|
|
9598
|
+
handleSuccess();
|
|
9599
|
+
},
|
|
9600
|
+
onError: (error) => {
|
|
9601
|
+
toast.error(error.message);
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
);
|
|
9605
|
+
});
|
|
9606
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9607
|
+
KeyboundForm,
|
|
9608
|
+
{
|
|
9609
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9610
|
+
onSubmit,
|
|
9611
|
+
children: [
|
|
9612
|
+
/* @__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: [
|
|
9613
|
+
/* @__PURE__ */ jsx(
|
|
9614
|
+
Form$2.Field,
|
|
9615
|
+
{
|
|
9616
|
+
control: form.control,
|
|
9617
|
+
name: "country_code",
|
|
9618
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9619
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9620
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9621
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9622
|
+
] })
|
|
9623
|
+
}
|
|
9624
|
+
),
|
|
9625
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9626
|
+
/* @__PURE__ */ jsx(
|
|
9627
|
+
Form$2.Field,
|
|
9628
|
+
{
|
|
9629
|
+
control: form.control,
|
|
9630
|
+
name: "first_name",
|
|
9631
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9633
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9634
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9635
|
+
] })
|
|
9636
|
+
}
|
|
9637
|
+
),
|
|
9638
|
+
/* @__PURE__ */ jsx(
|
|
9639
|
+
Form$2.Field,
|
|
9640
|
+
{
|
|
9641
|
+
control: form.control,
|
|
9642
|
+
name: "last_name",
|
|
9643
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9644
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9645
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9646
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9647
|
+
] })
|
|
9648
|
+
}
|
|
9649
|
+
)
|
|
9650
|
+
] }),
|
|
9651
|
+
/* @__PURE__ */ jsx(
|
|
9652
|
+
Form$2.Field,
|
|
9653
|
+
{
|
|
9654
|
+
control: form.control,
|
|
9655
|
+
name: "company",
|
|
9656
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9658
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
+
] })
|
|
9661
|
+
}
|
|
9662
|
+
),
|
|
9663
|
+
/* @__PURE__ */ jsx(
|
|
9664
|
+
Form$2.Field,
|
|
9665
|
+
{
|
|
9666
|
+
control: form.control,
|
|
9667
|
+
name: "address_1",
|
|
9668
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9669
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9670
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9671
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9672
|
+
] })
|
|
9673
|
+
}
|
|
9674
|
+
),
|
|
9675
|
+
/* @__PURE__ */ jsx(
|
|
9676
|
+
Form$2.Field,
|
|
9677
|
+
{
|
|
9678
|
+
control: form.control,
|
|
9679
|
+
name: "address_2",
|
|
9680
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9681
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9682
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9683
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9684
|
+
] })
|
|
9685
|
+
}
|
|
9686
|
+
),
|
|
9687
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9688
|
+
/* @__PURE__ */ jsx(
|
|
9689
|
+
Form$2.Field,
|
|
9690
|
+
{
|
|
9691
|
+
control: form.control,
|
|
9692
|
+
name: "postal_code",
|
|
9693
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9695
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
+
] })
|
|
9698
|
+
}
|
|
9699
|
+
),
|
|
9700
|
+
/* @__PURE__ */ jsx(
|
|
9701
|
+
Form$2.Field,
|
|
9702
|
+
{
|
|
9703
|
+
control: form.control,
|
|
9704
|
+
name: "city",
|
|
9705
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9706
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9707
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9708
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9709
|
+
] })
|
|
9710
|
+
}
|
|
9711
|
+
)
|
|
9712
|
+
] }),
|
|
9713
|
+
/* @__PURE__ */ jsx(
|
|
9714
|
+
Form$2.Field,
|
|
9715
|
+
{
|
|
9716
|
+
control: form.control,
|
|
9717
|
+
name: "province",
|
|
9718
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9720
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
+
] })
|
|
9723
|
+
}
|
|
9724
|
+
),
|
|
9725
|
+
/* @__PURE__ */ jsx(
|
|
9726
|
+
Form$2.Field,
|
|
9727
|
+
{
|
|
9728
|
+
control: form.control,
|
|
9729
|
+
name: "phone",
|
|
9730
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9731
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9732
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9733
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9734
|
+
] })
|
|
9735
|
+
}
|
|
9736
|
+
)
|
|
9737
|
+
] }) }),
|
|
9738
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9739
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9740
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9741
|
+
] }) })
|
|
9742
|
+
]
|
|
9743
|
+
}
|
|
9744
|
+
) });
|
|
9745
|
+
};
|
|
9746
|
+
const schema$5 = addressSchema;
|
|
9557
9747
|
const CustomItems = () => {
|
|
9558
9748
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9559
9749
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9562,7 +9752,7 @@ const CustomItems = () => {
|
|
|
9562
9752
|
};
|
|
9563
9753
|
const CustomItemsForm = () => {
|
|
9564
9754
|
const form = useForm({
|
|
9565
|
-
resolver: zodResolver(schema$
|
|
9755
|
+
resolver: zodResolver(schema$4)
|
|
9566
9756
|
});
|
|
9567
9757
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9568
9758
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9572,7 +9762,7 @@ const CustomItemsForm = () => {
|
|
|
9572
9762
|
] }) })
|
|
9573
9763
|
] }) });
|
|
9574
9764
|
};
|
|
9575
|
-
const schema$
|
|
9765
|
+
const schema$4 = objectType({
|
|
9576
9766
|
email: stringType().email()
|
|
9577
9767
|
});
|
|
9578
9768
|
const Email = () => {
|
|
@@ -9597,7 +9787,7 @@ const EmailForm = ({ order }) => {
|
|
|
9597
9787
|
defaultValues: {
|
|
9598
9788
|
email: order.email ?? ""
|
|
9599
9789
|
},
|
|
9600
|
-
resolver: zodResolver(schema$
|
|
9790
|
+
resolver: zodResolver(schema$3)
|
|
9601
9791
|
});
|
|
9602
9792
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
9793
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9640,7 +9830,7 @@ const EmailForm = ({ order }) => {
|
|
|
9640
9830
|
}
|
|
9641
9831
|
) });
|
|
9642
9832
|
};
|
|
9643
|
-
const schema$
|
|
9833
|
+
const schema$3 = objectType({
|
|
9644
9834
|
email: stringType().email()
|
|
9645
9835
|
});
|
|
9646
9836
|
const NumberInput = forwardRef(
|
|
@@ -11244,67 +11434,173 @@ function getPromotionCodes(items, shippingMethods) {
|
|
|
11244
11434
|
}
|
|
11245
11435
|
return Array.from(codes);
|
|
11246
11436
|
}
|
|
11247
|
-
const
|
|
11248
|
-
const Shipping = () => {
|
|
11249
|
-
var _a;
|
|
11437
|
+
const SalesChannel = () => {
|
|
11250
11438
|
const { id } = useParams();
|
|
11251
|
-
const {
|
|
11252
|
-
|
|
11253
|
-
});
|
|
11254
|
-
const {
|
|
11255
|
-
order: preview,
|
|
11256
|
-
isPending: isPreviewPending,
|
|
11257
|
-
isError: isPreviewError,
|
|
11258
|
-
error: previewError
|
|
11259
|
-
} = useOrderPreview(id);
|
|
11260
|
-
useInitiateOrderEdit({ preview });
|
|
11261
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11262
|
-
if (isError) {
|
|
11263
|
-
throw error;
|
|
11264
|
-
}
|
|
11265
|
-
if (isPreviewError) {
|
|
11266
|
-
throw previewError;
|
|
11267
|
-
}
|
|
11268
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11269
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11270
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11271
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11272
|
-
/* @__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: [
|
|
11273
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11274
|
-
/* @__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." }) })
|
|
11275
|
-
] }) }) }),
|
|
11276
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11277
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11278
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11279
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11280
|
-
] }) });
|
|
11281
|
-
};
|
|
11282
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11283
|
-
var _a;
|
|
11284
|
-
const { setIsOpen } = useStackedModal();
|
|
11285
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11286
|
-
const [data, setData] = useState(null);
|
|
11287
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11288
|
-
const { shipping_options } = useShippingOptions(
|
|
11439
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11440
|
+
id,
|
|
11289
11441
|
{
|
|
11290
|
-
|
|
11291
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11442
|
+
fields: "+sales_channel_id"
|
|
11292
11443
|
},
|
|
11293
11444
|
{
|
|
11294
|
-
enabled:
|
|
11445
|
+
enabled: !!id
|
|
11295
11446
|
}
|
|
11296
11447
|
);
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11448
|
+
if (isError) {
|
|
11449
|
+
throw error;
|
|
11450
|
+
}
|
|
11451
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11452
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11453
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11454
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11455
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11456
|
+
] }),
|
|
11457
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11458
|
+
] });
|
|
11459
|
+
};
|
|
11460
|
+
const SalesChannelForm = ({ order }) => {
|
|
11461
|
+
const form = useForm({
|
|
11462
|
+
defaultValues: {
|
|
11463
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11464
|
+
},
|
|
11465
|
+
resolver: zodResolver(schema$2)
|
|
11466
|
+
});
|
|
11467
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11468
|
+
const { handleSuccess } = useRouteModal();
|
|
11469
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11470
|
+
await mutateAsync(
|
|
11471
|
+
{
|
|
11472
|
+
sales_channel_id: data.sales_channel_id
|
|
11473
|
+
},
|
|
11474
|
+
{
|
|
11475
|
+
onSuccess: () => {
|
|
11476
|
+
toast.success("Sales channel updated");
|
|
11477
|
+
handleSuccess();
|
|
11478
|
+
},
|
|
11479
|
+
onError: (error) => {
|
|
11480
|
+
toast.error(error.message);
|
|
11481
|
+
}
|
|
11482
|
+
}
|
|
11483
|
+
);
|
|
11484
|
+
});
|
|
11485
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11486
|
+
KeyboundForm,
|
|
11487
|
+
{
|
|
11488
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11489
|
+
onSubmit,
|
|
11490
|
+
children: [
|
|
11491
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11492
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11493
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11494
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11495
|
+
] }) })
|
|
11496
|
+
]
|
|
11497
|
+
}
|
|
11498
|
+
) });
|
|
11499
|
+
};
|
|
11500
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11501
|
+
const salesChannels = useComboboxData({
|
|
11502
|
+
queryFn: async (params) => {
|
|
11503
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11504
|
+
},
|
|
11505
|
+
queryKey: ["sales-channels"],
|
|
11506
|
+
getOptions: (data) => {
|
|
11507
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11508
|
+
label: salesChannel.name,
|
|
11509
|
+
value: salesChannel.id
|
|
11510
|
+
}));
|
|
11511
|
+
},
|
|
11512
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11513
|
+
});
|
|
11514
|
+
return /* @__PURE__ */ jsx(
|
|
11515
|
+
Form$2.Field,
|
|
11516
|
+
{
|
|
11517
|
+
control,
|
|
11518
|
+
name: "sales_channel_id",
|
|
11519
|
+
render: ({ field }) => {
|
|
11520
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11521
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11522
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11523
|
+
Combobox,
|
|
11524
|
+
{
|
|
11525
|
+
options: salesChannels.options,
|
|
11526
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11527
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11528
|
+
searchValue: salesChannels.searchValue,
|
|
11529
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11530
|
+
placeholder: "Select sales channel",
|
|
11531
|
+
...field
|
|
11532
|
+
}
|
|
11533
|
+
) }),
|
|
11534
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11535
|
+
] });
|
|
11536
|
+
}
|
|
11537
|
+
}
|
|
11538
|
+
);
|
|
11539
|
+
};
|
|
11540
|
+
const schema$2 = objectType({
|
|
11541
|
+
sales_channel_id: stringType().min(1)
|
|
11542
|
+
});
|
|
11543
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11544
|
+
const Shipping = () => {
|
|
11545
|
+
var _a;
|
|
11546
|
+
const { id } = useParams();
|
|
11547
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11548
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11549
|
+
});
|
|
11550
|
+
const {
|
|
11551
|
+
order: preview,
|
|
11552
|
+
isPending: isPreviewPending,
|
|
11553
|
+
isError: isPreviewError,
|
|
11554
|
+
error: previewError
|
|
11555
|
+
} = useOrderPreview(id);
|
|
11556
|
+
useInitiateOrderEdit({ preview });
|
|
11557
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11558
|
+
if (isError) {
|
|
11559
|
+
throw error;
|
|
11560
|
+
}
|
|
11561
|
+
if (isPreviewError) {
|
|
11562
|
+
throw previewError;
|
|
11563
|
+
}
|
|
11564
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11565
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11566
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11567
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11568
|
+
/* @__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: [
|
|
11569
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11570
|
+
/* @__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." }) })
|
|
11571
|
+
] }) }) }),
|
|
11572
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11573
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11574
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11575
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11576
|
+
] }) });
|
|
11577
|
+
};
|
|
11578
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11579
|
+
var _a;
|
|
11580
|
+
const { setIsOpen } = useStackedModal();
|
|
11581
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11582
|
+
const [data, setData] = useState(null);
|
|
11583
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11584
|
+
const { shipping_options } = useShippingOptions(
|
|
11585
|
+
{
|
|
11586
|
+
id: appliedShippingOptionIds,
|
|
11587
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11588
|
+
},
|
|
11589
|
+
{
|
|
11590
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11591
|
+
}
|
|
11592
|
+
);
|
|
11593
|
+
const uniqueShippingProfiles = useMemo(() => {
|
|
11594
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11595
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11596
|
+
profiles.set(profile.id, profile);
|
|
11597
|
+
});
|
|
11598
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11599
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11600
|
+
});
|
|
11601
|
+
return Array.from(profiles.values());
|
|
11602
|
+
}, [order.items, shipping_options]);
|
|
11603
|
+
const { handleSuccess } = useRouteModal();
|
|
11308
11604
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11309
11605
|
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11310
11606
|
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
@@ -12051,46 +12347,44 @@ const CustomAmountField = ({
|
|
|
12051
12347
|
}
|
|
12052
12348
|
);
|
|
12053
12349
|
};
|
|
12054
|
-
const
|
|
12350
|
+
const TransferOwnership = () => {
|
|
12055
12351
|
const { id } = useParams();
|
|
12056
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12057
|
-
id,
|
|
12058
|
-
|
|
12059
|
-
fields: "+sales_channel_id"
|
|
12060
|
-
},
|
|
12061
|
-
{
|
|
12062
|
-
enabled: !!id
|
|
12063
|
-
}
|
|
12064
|
-
);
|
|
12352
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12353
|
+
fields: "id,customer_id,customer.*"
|
|
12354
|
+
});
|
|
12065
12355
|
if (isError) {
|
|
12066
12356
|
throw error;
|
|
12067
12357
|
}
|
|
12068
|
-
const
|
|
12358
|
+
const isReady = !isPending && !!draft_order;
|
|
12069
12359
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12070
12360
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12071
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12072
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12361
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12362
|
+
/* @__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" }) })
|
|
12073
12363
|
] }),
|
|
12074
|
-
|
|
12364
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12075
12365
|
] });
|
|
12076
12366
|
};
|
|
12077
|
-
const
|
|
12367
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12368
|
+
var _a, _b;
|
|
12078
12369
|
const form = useForm({
|
|
12079
12370
|
defaultValues: {
|
|
12080
|
-
|
|
12371
|
+
customer_id: order.customer_id || ""
|
|
12081
12372
|
},
|
|
12082
|
-
resolver: zodResolver(schema$
|
|
12373
|
+
resolver: zodResolver(schema$1)
|
|
12083
12374
|
});
|
|
12084
12375
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12085
12376
|
const { handleSuccess } = useRouteModal();
|
|
12377
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12378
|
+
const currentCustomer = order.customer ? {
|
|
12379
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12380
|
+
value: order.customer.id
|
|
12381
|
+
} : null;
|
|
12086
12382
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12087
12383
|
await mutateAsync(
|
|
12088
|
-
{
|
|
12089
|
-
sales_channel_id: data.sales_channel_id
|
|
12090
|
-
},
|
|
12384
|
+
{ customer_id: data.customer_id },
|
|
12091
12385
|
{
|
|
12092
12386
|
onSuccess: () => {
|
|
12093
|
-
toast.success("
|
|
12387
|
+
toast.success("Customer updated");
|
|
12094
12388
|
handleSuccess();
|
|
12095
12389
|
},
|
|
12096
12390
|
onError: (error) => {
|
|
@@ -12105,364 +12399,57 @@ const SalesChannelForm = ({ order }) => {
|
|
|
12105
12399
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12106
12400
|
onSubmit,
|
|
12107
12401
|
children: [
|
|
12108
|
-
/* @__PURE__ */
|
|
12109
|
-
|
|
12110
|
-
|
|
12402
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12403
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12404
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12405
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12406
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12407
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12408
|
+
] }),
|
|
12409
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12410
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12411
|
+
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12412
|
+
] })
|
|
12413
|
+
] }),
|
|
12414
|
+
/* @__PURE__ */ jsx(
|
|
12415
|
+
CustomerField,
|
|
12416
|
+
{
|
|
12417
|
+
control: form.control,
|
|
12418
|
+
currentCustomerId: order.customer_id
|
|
12419
|
+
}
|
|
12420
|
+
)
|
|
12421
|
+
] }),
|
|
12422
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12423
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12111
12424
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12112
12425
|
] }) })
|
|
12113
12426
|
]
|
|
12114
12427
|
}
|
|
12115
12428
|
) });
|
|
12116
12429
|
};
|
|
12117
|
-
const
|
|
12118
|
-
const
|
|
12430
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12431
|
+
const customers = useComboboxData({
|
|
12119
12432
|
queryFn: async (params) => {
|
|
12120
|
-
return await sdk.admin.
|
|
12433
|
+
return await sdk.admin.customer.list({
|
|
12434
|
+
...params,
|
|
12435
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12436
|
+
});
|
|
12121
12437
|
},
|
|
12122
|
-
queryKey: ["
|
|
12438
|
+
queryKey: ["customers"],
|
|
12123
12439
|
getOptions: (data) => {
|
|
12124
|
-
return data.
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12440
|
+
return data.customers.map((customer) => {
|
|
12441
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12442
|
+
return {
|
|
12443
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12444
|
+
value: customer.id
|
|
12445
|
+
};
|
|
12446
|
+
});
|
|
12447
|
+
}
|
|
12130
12448
|
});
|
|
12131
12449
|
return /* @__PURE__ */ jsx(
|
|
12132
12450
|
Form$2.Field,
|
|
12133
12451
|
{
|
|
12134
|
-
|
|
12135
|
-
name: "sales_channel_id",
|
|
12136
|
-
render: ({ field }) => {
|
|
12137
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12138
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12139
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12140
|
-
Combobox,
|
|
12141
|
-
{
|
|
12142
|
-
options: salesChannels.options,
|
|
12143
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12144
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12145
|
-
searchValue: salesChannels.searchValue,
|
|
12146
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12147
|
-
placeholder: "Select sales channel",
|
|
12148
|
-
...field
|
|
12149
|
-
}
|
|
12150
|
-
) }),
|
|
12151
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12152
|
-
] });
|
|
12153
|
-
}
|
|
12154
|
-
}
|
|
12155
|
-
);
|
|
12156
|
-
};
|
|
12157
|
-
const schema$3 = objectType({
|
|
12158
|
-
sales_channel_id: stringType().min(1)
|
|
12159
|
-
});
|
|
12160
|
-
const ShippingAddress = () => {
|
|
12161
|
-
const { id } = useParams();
|
|
12162
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12163
|
-
fields: "+shipping_address"
|
|
12164
|
-
});
|
|
12165
|
-
if (isError) {
|
|
12166
|
-
throw error;
|
|
12167
|
-
}
|
|
12168
|
-
const isReady = !isPending && !!order;
|
|
12169
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12170
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12171
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12172
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12173
|
-
] }),
|
|
12174
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12175
|
-
] });
|
|
12176
|
-
};
|
|
12177
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12178
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12179
|
-
const form = useForm({
|
|
12180
|
-
defaultValues: {
|
|
12181
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12182
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12183
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12184
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12185
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12186
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12187
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12188
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12189
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12190
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12191
|
-
},
|
|
12192
|
-
resolver: zodResolver(schema$2)
|
|
12193
|
-
});
|
|
12194
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12195
|
-
const { handleSuccess } = useRouteModal();
|
|
12196
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12197
|
-
await mutateAsync(
|
|
12198
|
-
{
|
|
12199
|
-
shipping_address: {
|
|
12200
|
-
first_name: data.first_name,
|
|
12201
|
-
last_name: data.last_name,
|
|
12202
|
-
company: data.company,
|
|
12203
|
-
address_1: data.address_1,
|
|
12204
|
-
address_2: data.address_2,
|
|
12205
|
-
city: data.city,
|
|
12206
|
-
province: data.province,
|
|
12207
|
-
country_code: data.country_code,
|
|
12208
|
-
postal_code: data.postal_code,
|
|
12209
|
-
phone: data.phone
|
|
12210
|
-
}
|
|
12211
|
-
},
|
|
12212
|
-
{
|
|
12213
|
-
onSuccess: () => {
|
|
12214
|
-
handleSuccess();
|
|
12215
|
-
},
|
|
12216
|
-
onError: (error) => {
|
|
12217
|
-
toast.error(error.message);
|
|
12218
|
-
}
|
|
12219
|
-
}
|
|
12220
|
-
);
|
|
12221
|
-
});
|
|
12222
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12223
|
-
KeyboundForm,
|
|
12224
|
-
{
|
|
12225
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12226
|
-
onSubmit,
|
|
12227
|
-
children: [
|
|
12228
|
-
/* @__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: [
|
|
12229
|
-
/* @__PURE__ */ jsx(
|
|
12230
|
-
Form$2.Field,
|
|
12231
|
-
{
|
|
12232
|
-
control: form.control,
|
|
12233
|
-
name: "country_code",
|
|
12234
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12235
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12236
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12237
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12238
|
-
] })
|
|
12239
|
-
}
|
|
12240
|
-
),
|
|
12241
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12242
|
-
/* @__PURE__ */ jsx(
|
|
12243
|
-
Form$2.Field,
|
|
12244
|
-
{
|
|
12245
|
-
control: form.control,
|
|
12246
|
-
name: "first_name",
|
|
12247
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12248
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12249
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12250
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12251
|
-
] })
|
|
12252
|
-
}
|
|
12253
|
-
),
|
|
12254
|
-
/* @__PURE__ */ jsx(
|
|
12255
|
-
Form$2.Field,
|
|
12256
|
-
{
|
|
12257
|
-
control: form.control,
|
|
12258
|
-
name: "last_name",
|
|
12259
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12260
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12261
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12262
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12263
|
-
] })
|
|
12264
|
-
}
|
|
12265
|
-
)
|
|
12266
|
-
] }),
|
|
12267
|
-
/* @__PURE__ */ jsx(
|
|
12268
|
-
Form$2.Field,
|
|
12269
|
-
{
|
|
12270
|
-
control: form.control,
|
|
12271
|
-
name: "company",
|
|
12272
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12273
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12274
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12275
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12276
|
-
] })
|
|
12277
|
-
}
|
|
12278
|
-
),
|
|
12279
|
-
/* @__PURE__ */ jsx(
|
|
12280
|
-
Form$2.Field,
|
|
12281
|
-
{
|
|
12282
|
-
control: form.control,
|
|
12283
|
-
name: "address_1",
|
|
12284
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12285
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12286
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12287
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12288
|
-
] })
|
|
12289
|
-
}
|
|
12290
|
-
),
|
|
12291
|
-
/* @__PURE__ */ jsx(
|
|
12292
|
-
Form$2.Field,
|
|
12293
|
-
{
|
|
12294
|
-
control: form.control,
|
|
12295
|
-
name: "address_2",
|
|
12296
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12297
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12298
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12299
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12300
|
-
] })
|
|
12301
|
-
}
|
|
12302
|
-
),
|
|
12303
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12304
|
-
/* @__PURE__ */ jsx(
|
|
12305
|
-
Form$2.Field,
|
|
12306
|
-
{
|
|
12307
|
-
control: form.control,
|
|
12308
|
-
name: "postal_code",
|
|
12309
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12310
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12311
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12312
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12313
|
-
] })
|
|
12314
|
-
}
|
|
12315
|
-
),
|
|
12316
|
-
/* @__PURE__ */ jsx(
|
|
12317
|
-
Form$2.Field,
|
|
12318
|
-
{
|
|
12319
|
-
control: form.control,
|
|
12320
|
-
name: "city",
|
|
12321
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12322
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12323
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12324
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12325
|
-
] })
|
|
12326
|
-
}
|
|
12327
|
-
)
|
|
12328
|
-
] }),
|
|
12329
|
-
/* @__PURE__ */ jsx(
|
|
12330
|
-
Form$2.Field,
|
|
12331
|
-
{
|
|
12332
|
-
control: form.control,
|
|
12333
|
-
name: "province",
|
|
12334
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12335
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12336
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12337
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12338
|
-
] })
|
|
12339
|
-
}
|
|
12340
|
-
),
|
|
12341
|
-
/* @__PURE__ */ jsx(
|
|
12342
|
-
Form$2.Field,
|
|
12343
|
-
{
|
|
12344
|
-
control: form.control,
|
|
12345
|
-
name: "phone",
|
|
12346
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12347
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12348
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12349
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12350
|
-
] })
|
|
12351
|
-
}
|
|
12352
|
-
)
|
|
12353
|
-
] }) }),
|
|
12354
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12355
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12356
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12357
|
-
] }) })
|
|
12358
|
-
]
|
|
12359
|
-
}
|
|
12360
|
-
) });
|
|
12361
|
-
};
|
|
12362
|
-
const schema$2 = addressSchema;
|
|
12363
|
-
const TransferOwnership = () => {
|
|
12364
|
-
const { id } = useParams();
|
|
12365
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12366
|
-
fields: "id,customer_id,customer.*"
|
|
12367
|
-
});
|
|
12368
|
-
if (isError) {
|
|
12369
|
-
throw error;
|
|
12370
|
-
}
|
|
12371
|
-
const isReady = !isPending && !!draft_order;
|
|
12372
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12373
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12374
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12375
|
-
/* @__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" }) })
|
|
12376
|
-
] }),
|
|
12377
|
-
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12378
|
-
] });
|
|
12379
|
-
};
|
|
12380
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
12381
|
-
var _a, _b;
|
|
12382
|
-
const form = useForm({
|
|
12383
|
-
defaultValues: {
|
|
12384
|
-
customer_id: order.customer_id || ""
|
|
12385
|
-
},
|
|
12386
|
-
resolver: zodResolver(schema$1)
|
|
12387
|
-
});
|
|
12388
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12389
|
-
const { handleSuccess } = useRouteModal();
|
|
12390
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12391
|
-
const currentCustomer = order.customer ? {
|
|
12392
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12393
|
-
value: order.customer.id
|
|
12394
|
-
} : null;
|
|
12395
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12396
|
-
await mutateAsync(
|
|
12397
|
-
{ customer_id: data.customer_id },
|
|
12398
|
-
{
|
|
12399
|
-
onSuccess: () => {
|
|
12400
|
-
toast.success("Customer updated");
|
|
12401
|
-
handleSuccess();
|
|
12402
|
-
},
|
|
12403
|
-
onError: (error) => {
|
|
12404
|
-
toast.error(error.message);
|
|
12405
|
-
}
|
|
12406
|
-
}
|
|
12407
|
-
);
|
|
12408
|
-
});
|
|
12409
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12410
|
-
KeyboundForm,
|
|
12411
|
-
{
|
|
12412
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12413
|
-
onSubmit,
|
|
12414
|
-
children: [
|
|
12415
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12416
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12417
|
-
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12418
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12419
|
-
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12420
|
-
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12421
|
-
] }),
|
|
12422
|
-
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12423
|
-
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12424
|
-
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12425
|
-
] })
|
|
12426
|
-
] }),
|
|
12427
|
-
/* @__PURE__ */ jsx(
|
|
12428
|
-
CustomerField,
|
|
12429
|
-
{
|
|
12430
|
-
control: form.control,
|
|
12431
|
-
currentCustomerId: order.customer_id
|
|
12432
|
-
}
|
|
12433
|
-
)
|
|
12434
|
-
] }),
|
|
12435
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12436
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12437
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12438
|
-
] }) })
|
|
12439
|
-
]
|
|
12440
|
-
}
|
|
12441
|
-
) });
|
|
12442
|
-
};
|
|
12443
|
-
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12444
|
-
const customers = useComboboxData({
|
|
12445
|
-
queryFn: async (params) => {
|
|
12446
|
-
return await sdk.admin.customer.list({
|
|
12447
|
-
...params,
|
|
12448
|
-
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12449
|
-
});
|
|
12450
|
-
},
|
|
12451
|
-
queryKey: ["customers"],
|
|
12452
|
-
getOptions: (data) => {
|
|
12453
|
-
return data.customers.map((customer) => {
|
|
12454
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12455
|
-
return {
|
|
12456
|
-
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12457
|
-
value: customer.id
|
|
12458
|
-
};
|
|
12459
|
-
});
|
|
12460
|
-
}
|
|
12461
|
-
});
|
|
12462
|
-
return /* @__PURE__ */ jsx(
|
|
12463
|
-
Form$2.Field,
|
|
12464
|
-
{
|
|
12465
|
-
name: "customer_id",
|
|
12452
|
+
name: "customer_id",
|
|
12466
12453
|
control,
|
|
12467
12454
|
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
12468
12455
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
@@ -12836,10 +12823,10 @@ const Illustration = () => {
|
|
|
12836
12823
|
const schema$1 = objectType({
|
|
12837
12824
|
customer_id: stringType().min(1)
|
|
12838
12825
|
});
|
|
12839
|
-
const
|
|
12826
|
+
const ShippingAddress = () => {
|
|
12840
12827
|
const { id } = useParams();
|
|
12841
12828
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12842
|
-
fields: "+
|
|
12829
|
+
fields: "+shipping_address"
|
|
12843
12830
|
});
|
|
12844
12831
|
if (isError) {
|
|
12845
12832
|
throw error;
|
|
@@ -12847,26 +12834,26 @@ const BillingAddress = () => {
|
|
|
12847
12834
|
const isReady = !isPending && !!order;
|
|
12848
12835
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12849
12836
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12850
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12851
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
12837
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12838
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12852
12839
|
] }),
|
|
12853
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12840
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12854
12841
|
] });
|
|
12855
12842
|
};
|
|
12856
|
-
const
|
|
12843
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12857
12844
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12858
12845
|
const form = useForm({
|
|
12859
12846
|
defaultValues: {
|
|
12860
|
-
first_name: ((_a = order.
|
|
12861
|
-
last_name: ((_b = order.
|
|
12862
|
-
company: ((_c = order.
|
|
12863
|
-
address_1: ((_d = order.
|
|
12864
|
-
address_2: ((_e = order.
|
|
12865
|
-
city: ((_f = order.
|
|
12866
|
-
province: ((_g = order.
|
|
12867
|
-
country_code: ((_h = order.
|
|
12868
|
-
postal_code: ((_i = order.
|
|
12869
|
-
phone: ((_j = order.
|
|
12847
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12848
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12849
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12850
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12851
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12852
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12853
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12854
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12855
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12856
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12870
12857
|
},
|
|
12871
12858
|
resolver: zodResolver(schema)
|
|
12872
12859
|
});
|
|
@@ -12874,7 +12861,20 @@ const BillingAddressForm = ({ order }) => {
|
|
|
12874
12861
|
const { handleSuccess } = useRouteModal();
|
|
12875
12862
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12876
12863
|
await mutateAsync(
|
|
12877
|
-
{
|
|
12864
|
+
{
|
|
12865
|
+
shipping_address: {
|
|
12866
|
+
first_name: data.first_name,
|
|
12867
|
+
last_name: data.last_name,
|
|
12868
|
+
company: data.company,
|
|
12869
|
+
address_1: data.address_1,
|
|
12870
|
+
address_2: data.address_2,
|
|
12871
|
+
city: data.city,
|
|
12872
|
+
province: data.province,
|
|
12873
|
+
country_code: data.country_code,
|
|
12874
|
+
postal_code: data.postal_code,
|
|
12875
|
+
phone: data.phone
|
|
12876
|
+
}
|
|
12877
|
+
},
|
|
12878
12878
|
{
|
|
12879
12879
|
onSuccess: () => {
|
|
12880
12880
|
handleSuccess();
|
|
@@ -13046,6 +13046,10 @@ const routeModule = {
|
|
|
13046
13046
|
handle,
|
|
13047
13047
|
loader,
|
|
13048
13048
|
children: [
|
|
13049
|
+
{
|
|
13050
|
+
Component: BillingAddress,
|
|
13051
|
+
path: "/draft-orders/:id/billing-address"
|
|
13052
|
+
},
|
|
13049
13053
|
{
|
|
13050
13054
|
Component: CustomItems,
|
|
13051
13055
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13066,25 +13070,21 @@ const routeModule = {
|
|
|
13066
13070
|
Component: Promotions,
|
|
13067
13071
|
path: "/draft-orders/:id/promotions"
|
|
13068
13072
|
},
|
|
13069
|
-
{
|
|
13070
|
-
Component: Shipping,
|
|
13071
|
-
path: "/draft-orders/:id/shipping"
|
|
13072
|
-
},
|
|
13073
13073
|
{
|
|
13074
13074
|
Component: SalesChannel,
|
|
13075
13075
|
path: "/draft-orders/:id/sales-channel"
|
|
13076
13076
|
},
|
|
13077
13077
|
{
|
|
13078
|
-
Component:
|
|
13079
|
-
path: "/draft-orders/:id/shipping
|
|
13078
|
+
Component: Shipping,
|
|
13079
|
+
path: "/draft-orders/:id/shipping"
|
|
13080
13080
|
},
|
|
13081
13081
|
{
|
|
13082
13082
|
Component: TransferOwnership,
|
|
13083
13083
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13084
13084
|
},
|
|
13085
13085
|
{
|
|
13086
|
-
Component:
|
|
13087
|
-
path: "/draft-orders/:id/
|
|
13086
|
+
Component: ShippingAddress,
|
|
13087
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13088
13088
|
}
|
|
13089
13089
|
]
|
|
13090
13090
|
}
|