@medusajs/draft-order 2.11.3-preview-20251031150158 → 2.11.3-preview-20251031180155
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 +484 -483
- package/.medusa/server/src/admin/index.mjs +482 -482
- package/package.json +54 -23
|
@@ -13,9 +13,9 @@ import { FormProvider, Controller, useFormContext, useFormState, useForm, useWat
|
|
|
13
13
|
import { Slot, Collapsible, Accordion } from "radix-ui";
|
|
14
14
|
import { ComboboxProvider, Combobox as Combobox$1, ComboboxDisclosure, ComboboxPopover, ComboboxItem, ComboboxItemCheck, ComboboxItemValue, Separator } from "@ariakit/react";
|
|
15
15
|
import { matchSorter } from "match-sorter";
|
|
16
|
-
import debounce from "lodash
|
|
16
|
+
import debounce from "lodash.debounce";
|
|
17
17
|
import Primitive from "@uiw/react-json-view";
|
|
18
|
-
import
|
|
18
|
+
import isEqual from "lodash.isequal";
|
|
19
19
|
function useQueryParams(keys, prefix) {
|
|
20
20
|
const [params] = useSearchParams();
|
|
21
21
|
const result = {};
|
|
@@ -9565,6 +9565,196 @@ const ID = () => {
|
|
|
9565
9565
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9566
9566
|
] });
|
|
9567
9567
|
};
|
|
9568
|
+
const BillingAddress = () => {
|
|
9569
|
+
const { id } = useParams();
|
|
9570
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9571
|
+
fields: "+billing_address"
|
|
9572
|
+
});
|
|
9573
|
+
if (isError) {
|
|
9574
|
+
throw error;
|
|
9575
|
+
}
|
|
9576
|
+
const isReady = !isPending && !!order;
|
|
9577
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9578
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9579
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9580
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9581
|
+
] }),
|
|
9582
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9583
|
+
] });
|
|
9584
|
+
};
|
|
9585
|
+
const BillingAddressForm = ({ order }) => {
|
|
9586
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9587
|
+
const form = useForm({
|
|
9588
|
+
defaultValues: {
|
|
9589
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
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) ?? ""
|
|
9599
|
+
},
|
|
9600
|
+
resolver: zodResolver(schema$5)
|
|
9601
|
+
});
|
|
9602
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
|
+
const { handleSuccess } = useRouteModal();
|
|
9604
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9605
|
+
await mutateAsync(
|
|
9606
|
+
{ billing_address: data },
|
|
9607
|
+
{
|
|
9608
|
+
onSuccess: () => {
|
|
9609
|
+
handleSuccess();
|
|
9610
|
+
},
|
|
9611
|
+
onError: (error) => {
|
|
9612
|
+
toast.error(error.message);
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9615
|
+
);
|
|
9616
|
+
});
|
|
9617
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9618
|
+
KeyboundForm,
|
|
9619
|
+
{
|
|
9620
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9621
|
+
onSubmit,
|
|
9622
|
+
children: [
|
|
9623
|
+
/* @__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: [
|
|
9624
|
+
/* @__PURE__ */ jsx(
|
|
9625
|
+
Form$2.Field,
|
|
9626
|
+
{
|
|
9627
|
+
control: form.control,
|
|
9628
|
+
name: "country_code",
|
|
9629
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9630
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9631
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
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
|
+
] }) }),
|
|
9749
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9750
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9751
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9752
|
+
] }) })
|
|
9753
|
+
]
|
|
9754
|
+
}
|
|
9755
|
+
) });
|
|
9756
|
+
};
|
|
9757
|
+
const schema$5 = addressSchema;
|
|
9568
9758
|
const CustomItems = () => {
|
|
9569
9759
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9570
9760
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9573,7 +9763,7 @@ const CustomItems = () => {
|
|
|
9573
9763
|
};
|
|
9574
9764
|
const CustomItemsForm = () => {
|
|
9575
9765
|
const form = useForm({
|
|
9576
|
-
resolver: zodResolver(schema$
|
|
9766
|
+
resolver: zodResolver(schema$4)
|
|
9577
9767
|
});
|
|
9578
9768
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9579
9769
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9583,7 +9773,7 @@ const CustomItemsForm = () => {
|
|
|
9583
9773
|
] }) })
|
|
9584
9774
|
] }) });
|
|
9585
9775
|
};
|
|
9586
|
-
const schema$
|
|
9776
|
+
const schema$4 = objectType({
|
|
9587
9777
|
email: stringType().email()
|
|
9588
9778
|
});
|
|
9589
9779
|
const Email = () => {
|
|
@@ -9608,7 +9798,7 @@ const EmailForm = ({ order }) => {
|
|
|
9608
9798
|
defaultValues: {
|
|
9609
9799
|
email: order.email ?? ""
|
|
9610
9800
|
},
|
|
9611
|
-
resolver: zodResolver(schema$
|
|
9801
|
+
resolver: zodResolver(schema$3)
|
|
9612
9802
|
});
|
|
9613
9803
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9614
9804
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9651,7 +9841,7 @@ const EmailForm = ({ order }) => {
|
|
|
9651
9841
|
}
|
|
9652
9842
|
) });
|
|
9653
9843
|
};
|
|
9654
|
-
const schema$
|
|
9844
|
+
const schema$3 = objectType({
|
|
9655
9845
|
email: stringType().email()
|
|
9656
9846
|
});
|
|
9657
9847
|
const NumberInput = forwardRef(
|
|
@@ -11283,7 +11473,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11283
11473
|
defaultValues: {
|
|
11284
11474
|
sales_channel_id: order.sales_channel_id || ""
|
|
11285
11475
|
},
|
|
11286
|
-
resolver: zodResolver(schema$
|
|
11476
|
+
resolver: zodResolver(schema$2)
|
|
11287
11477
|
});
|
|
11288
11478
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11289
11479
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11358,246 +11548,43 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11358
11548
|
}
|
|
11359
11549
|
);
|
|
11360
11550
|
};
|
|
11361
|
-
const schema$
|
|
11551
|
+
const schema$2 = objectType({
|
|
11362
11552
|
sales_channel_id: stringType().min(1)
|
|
11363
11553
|
});
|
|
11364
|
-
const
|
|
11554
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11555
|
+
const Shipping = () => {
|
|
11556
|
+
var _a;
|
|
11365
11557
|
const { id } = useParams();
|
|
11366
11558
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
11367
|
-
fields: "+
|
|
11559
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11368
11560
|
});
|
|
11561
|
+
const {
|
|
11562
|
+
order: preview,
|
|
11563
|
+
isPending: isPreviewPending,
|
|
11564
|
+
isError: isPreviewError,
|
|
11565
|
+
error: previewError
|
|
11566
|
+
} = useOrderPreview(id);
|
|
11567
|
+
useInitiateOrderEdit({ preview });
|
|
11568
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11369
11569
|
if (isError) {
|
|
11370
11570
|
throw error;
|
|
11371
11571
|
}
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
}
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11389
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11390
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11391
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11392
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11393
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11394
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11395
|
-
},
|
|
11396
|
-
resolver: zodResolver(schema$2)
|
|
11397
|
-
});
|
|
11398
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11399
|
-
const { handleSuccess } = useRouteModal();
|
|
11400
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11401
|
-
await mutateAsync(
|
|
11402
|
-
{
|
|
11403
|
-
shipping_address: {
|
|
11404
|
-
first_name: data.first_name,
|
|
11405
|
-
last_name: data.last_name,
|
|
11406
|
-
company: data.company,
|
|
11407
|
-
address_1: data.address_1,
|
|
11408
|
-
address_2: data.address_2,
|
|
11409
|
-
city: data.city,
|
|
11410
|
-
province: data.province,
|
|
11411
|
-
country_code: data.country_code,
|
|
11412
|
-
postal_code: data.postal_code,
|
|
11413
|
-
phone: data.phone
|
|
11414
|
-
}
|
|
11415
|
-
},
|
|
11416
|
-
{
|
|
11417
|
-
onSuccess: () => {
|
|
11418
|
-
handleSuccess();
|
|
11419
|
-
},
|
|
11420
|
-
onError: (error) => {
|
|
11421
|
-
toast.error(error.message);
|
|
11422
|
-
}
|
|
11423
|
-
}
|
|
11424
|
-
);
|
|
11425
|
-
});
|
|
11426
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11427
|
-
KeyboundForm,
|
|
11428
|
-
{
|
|
11429
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11430
|
-
onSubmit,
|
|
11431
|
-
children: [
|
|
11432
|
-
/* @__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: [
|
|
11433
|
-
/* @__PURE__ */ jsx(
|
|
11434
|
-
Form$2.Field,
|
|
11435
|
-
{
|
|
11436
|
-
control: form.control,
|
|
11437
|
-
name: "country_code",
|
|
11438
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11439
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11440
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11441
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11442
|
-
] })
|
|
11443
|
-
}
|
|
11444
|
-
),
|
|
11445
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11446
|
-
/* @__PURE__ */ jsx(
|
|
11447
|
-
Form$2.Field,
|
|
11448
|
-
{
|
|
11449
|
-
control: form.control,
|
|
11450
|
-
name: "first_name",
|
|
11451
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11452
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11453
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11454
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11455
|
-
] })
|
|
11456
|
-
}
|
|
11457
|
-
),
|
|
11458
|
-
/* @__PURE__ */ jsx(
|
|
11459
|
-
Form$2.Field,
|
|
11460
|
-
{
|
|
11461
|
-
control: form.control,
|
|
11462
|
-
name: "last_name",
|
|
11463
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11464
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11465
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11466
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11467
|
-
] })
|
|
11468
|
-
}
|
|
11469
|
-
)
|
|
11470
|
-
] }),
|
|
11471
|
-
/* @__PURE__ */ jsx(
|
|
11472
|
-
Form$2.Field,
|
|
11473
|
-
{
|
|
11474
|
-
control: form.control,
|
|
11475
|
-
name: "company",
|
|
11476
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11477
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11478
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11479
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11480
|
-
] })
|
|
11481
|
-
}
|
|
11482
|
-
),
|
|
11483
|
-
/* @__PURE__ */ jsx(
|
|
11484
|
-
Form$2.Field,
|
|
11485
|
-
{
|
|
11486
|
-
control: form.control,
|
|
11487
|
-
name: "address_1",
|
|
11488
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11489
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11490
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11491
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11492
|
-
] })
|
|
11493
|
-
}
|
|
11494
|
-
),
|
|
11495
|
-
/* @__PURE__ */ jsx(
|
|
11496
|
-
Form$2.Field,
|
|
11497
|
-
{
|
|
11498
|
-
control: form.control,
|
|
11499
|
-
name: "address_2",
|
|
11500
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11501
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11502
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11503
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11504
|
-
] })
|
|
11505
|
-
}
|
|
11506
|
-
),
|
|
11507
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11508
|
-
/* @__PURE__ */ jsx(
|
|
11509
|
-
Form$2.Field,
|
|
11510
|
-
{
|
|
11511
|
-
control: form.control,
|
|
11512
|
-
name: "postal_code",
|
|
11513
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11514
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11515
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11516
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11517
|
-
] })
|
|
11518
|
-
}
|
|
11519
|
-
),
|
|
11520
|
-
/* @__PURE__ */ jsx(
|
|
11521
|
-
Form$2.Field,
|
|
11522
|
-
{
|
|
11523
|
-
control: form.control,
|
|
11524
|
-
name: "city",
|
|
11525
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11526
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11527
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11528
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11529
|
-
] })
|
|
11530
|
-
}
|
|
11531
|
-
)
|
|
11532
|
-
] }),
|
|
11533
|
-
/* @__PURE__ */ jsx(
|
|
11534
|
-
Form$2.Field,
|
|
11535
|
-
{
|
|
11536
|
-
control: form.control,
|
|
11537
|
-
name: "province",
|
|
11538
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11539
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11540
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11541
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11542
|
-
] })
|
|
11543
|
-
}
|
|
11544
|
-
),
|
|
11545
|
-
/* @__PURE__ */ jsx(
|
|
11546
|
-
Form$2.Field,
|
|
11547
|
-
{
|
|
11548
|
-
control: form.control,
|
|
11549
|
-
name: "phone",
|
|
11550
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11551
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11552
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11553
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11554
|
-
] })
|
|
11555
|
-
}
|
|
11556
|
-
)
|
|
11557
|
-
] }) }),
|
|
11558
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11559
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11560
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11561
|
-
] }) })
|
|
11562
|
-
]
|
|
11563
|
-
}
|
|
11564
|
-
) });
|
|
11565
|
-
};
|
|
11566
|
-
const schema$2 = addressSchema;
|
|
11567
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11568
|
-
const Shipping = () => {
|
|
11569
|
-
var _a;
|
|
11570
|
-
const { id } = useParams();
|
|
11571
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11572
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11573
|
-
});
|
|
11574
|
-
const {
|
|
11575
|
-
order: preview,
|
|
11576
|
-
isPending: isPreviewPending,
|
|
11577
|
-
isError: isPreviewError,
|
|
11578
|
-
error: previewError
|
|
11579
|
-
} = useOrderPreview(id);
|
|
11580
|
-
useInitiateOrderEdit({ preview });
|
|
11581
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11582
|
-
if (isError) {
|
|
11583
|
-
throw error;
|
|
11584
|
-
}
|
|
11585
|
-
if (isPreviewError) {
|
|
11586
|
-
throw previewError;
|
|
11587
|
-
}
|
|
11588
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11589
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11590
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11591
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11592
|
-
/* @__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: [
|
|
11593
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11594
|
-
/* @__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." }) })
|
|
11595
|
-
] }) }) }),
|
|
11596
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11597
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11598
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11599
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11600
|
-
] }) });
|
|
11572
|
+
if (isPreviewError) {
|
|
11573
|
+
throw previewError;
|
|
11574
|
+
}
|
|
11575
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11576
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11577
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11578
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11579
|
+
/* @__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 px-6 py-16", children: [
|
|
11580
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11581
|
+
/* @__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." }) })
|
|
11582
|
+
] }) }) }),
|
|
11583
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11584
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11585
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11586
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11587
|
+
] }) });
|
|
11601
11588
|
};
|
|
11602
11589
|
const ShippingForm = ({ preview, order }) => {
|
|
11603
11590
|
var _a;
|
|
@@ -11676,14 +11663,14 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11676
11663
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11677
11664
|
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11678
11665
|
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11679
|
-
/* @__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
|
|
11666
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11680
11667
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
11681
11668
|
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11682
11669
|
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11683
11670
|
] }),
|
|
11684
11671
|
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
11685
|
-
/* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle
|
|
11686
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
11672
|
+
/* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11673
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
11687
11674
|
/* @__PURE__ */ jsx(
|
|
11688
11675
|
Text,
|
|
11689
11676
|
{
|
|
@@ -11725,8 +11712,8 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11725
11712
|
value: profile.id,
|
|
11726
11713
|
className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
|
|
11727
11714
|
children: [
|
|
11728
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
11729
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3
|
|
11715
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
|
|
11716
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-x-3 overflow-hidden", children: [
|
|
11730
11717
|
/* @__PURE__ */ jsx(Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
11731
11718
|
IconButton,
|
|
11732
11719
|
{
|
|
@@ -11734,12 +11721,12 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11734
11721
|
variant: "transparent",
|
|
11735
11722
|
className: "group/trigger",
|
|
11736
11723
|
disabled: !hasItems,
|
|
11737
|
-
children: /* @__PURE__ */ jsx(TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90
|
|
11724
|
+
children: /* @__PURE__ */ jsx(TriangleRightMini, { className: "transition-transform group-data-[state=open]/trigger:rotate-90" })
|
|
11738
11725
|
}
|
|
11739
11726
|
) }),
|
|
11740
11727
|
!shippingOption ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
11741
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
11742
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-
|
|
11728
|
+
/* @__PURE__ */ jsx("div", { className: "shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-component-hover flex size-6 items-center justify-center rounded", children: /* @__PURE__ */ jsx(Shopping, { className: "text-ui-fg-subtle" }) }) }),
|
|
11729
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
|
|
11743
11730
|
/* @__PURE__ */ jsx(
|
|
11744
11731
|
Text,
|
|
11745
11732
|
{
|
|
@@ -11763,7 +11750,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11763
11750
|
}
|
|
11764
11751
|
)
|
|
11765
11752
|
] })
|
|
11766
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start
|
|
11753
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-1 items-center gap-[5px] overflow-hidden max-sm:flex-col max-sm:items-start", children: [
|
|
11767
11754
|
/* @__PURE__ */ jsx(
|
|
11768
11755
|
Tooltip,
|
|
11769
11756
|
{
|
|
@@ -11780,7 +11767,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11780
11767
|
children: /* @__PURE__ */ jsxs(
|
|
11781
11768
|
Badge,
|
|
11782
11769
|
{
|
|
11783
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11770
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
11784
11771
|
size: "xsmall",
|
|
11785
11772
|
children: [
|
|
11786
11773
|
/* @__PURE__ */ jsx(Shopping, { className: "shrink-0" }),
|
|
@@ -11805,7 +11792,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11805
11792
|
children: /* @__PURE__ */ jsxs(
|
|
11806
11793
|
Badge,
|
|
11807
11794
|
{
|
|
11808
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11795
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
11809
11796
|
size: "xsmall",
|
|
11810
11797
|
children: [
|
|
11811
11798
|
/* @__PURE__ */ jsx(Buildings, { className: "shrink-0" }),
|
|
@@ -11818,7 +11805,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11818
11805
|
/* @__PURE__ */ jsx(Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxs(
|
|
11819
11806
|
Badge,
|
|
11820
11807
|
{
|
|
11821
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11808
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
11822
11809
|
size: "xsmall",
|
|
11823
11810
|
children: [
|
|
11824
11811
|
/* @__PURE__ */ jsx(TruckFast, { className: "shrink-0" }),
|
|
@@ -11889,17 +11876,17 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11889
11876
|
/* @__PURE__ */ jsxs(
|
|
11890
11877
|
"div",
|
|
11891
11878
|
{
|
|
11892
|
-
className: "
|
|
11879
|
+
className: "flex items-center gap-x-3 px-3",
|
|
11893
11880
|
children: [
|
|
11894
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
11881
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-[56px] w-5 flex-col items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
11895
11882
|
Divider,
|
|
11896
11883
|
{
|
|
11897
11884
|
variant: "dashed",
|
|
11898
11885
|
orientation: "vertical"
|
|
11899
11886
|
}
|
|
11900
11887
|
) }),
|
|
11901
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
11902
|
-
/* @__PURE__ */ jsx("div", { className: "size-7
|
|
11888
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3 py-2", children: [
|
|
11889
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-7 items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxs(
|
|
11903
11890
|
Text,
|
|
11904
11891
|
{
|
|
11905
11892
|
size: "small",
|
|
@@ -12080,7 +12067,7 @@ const ShippingProfileForm = ({
|
|
|
12080
12067
|
onSubmit,
|
|
12081
12068
|
children: [
|
|
12082
12069
|
/* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
|
|
12083
|
-
/* @__PURE__ */ jsx(StackedFocusModal.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
|
|
12070
|
+
/* @__PURE__ */ jsx(StackedFocusModal.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 px-6 py-16", children: [
|
|
12084
12071
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
12085
12072
|
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
12086
12073
|
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
@@ -12153,14 +12140,14 @@ const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
|
12153
12140
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12154
12141
|
] }) }),
|
|
12155
12142
|
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12156
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2
|
|
12143
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
|
|
12157
12144
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12158
12145
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12159
12146
|
] }),
|
|
12160
12147
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
|
|
12161
12148
|
"div",
|
|
12162
12149
|
{
|
|
12163
|
-
className: "
|
|
12150
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
12164
12151
|
children: [
|
|
12165
12152
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12166
12153
|
/* @__PURE__ */ jsx(
|
|
@@ -12213,7 +12200,7 @@ const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
|
12213
12200
|
]
|
|
12214
12201
|
},
|
|
12215
12202
|
item.id
|
|
12216
|
-
)) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3
|
|
12203
|
+
)) : /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
12217
12204
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12218
12205
|
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12219
12206
|
'No items found for "',
|
|
@@ -12371,44 +12358,60 @@ const CustomAmountField = ({
|
|
|
12371
12358
|
}
|
|
12372
12359
|
);
|
|
12373
12360
|
};
|
|
12374
|
-
const
|
|
12361
|
+
const ShippingAddress = () => {
|
|
12375
12362
|
const { id } = useParams();
|
|
12376
|
-
const {
|
|
12377
|
-
fields: "
|
|
12363
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12364
|
+
fields: "+shipping_address"
|
|
12378
12365
|
});
|
|
12379
12366
|
if (isError) {
|
|
12380
12367
|
throw error;
|
|
12381
12368
|
}
|
|
12382
|
-
const isReady = !isPending && !!
|
|
12369
|
+
const isReady = !isPending && !!order;
|
|
12383
12370
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12384
12371
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12385
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12386
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12372
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12373
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12387
12374
|
] }),
|
|
12388
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12375
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12389
12376
|
] });
|
|
12390
12377
|
};
|
|
12391
|
-
const
|
|
12392
|
-
var _a, _b;
|
|
12378
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12379
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12393
12380
|
const form = useForm({
|
|
12394
12381
|
defaultValues: {
|
|
12395
|
-
|
|
12382
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12383
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12384
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12385
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12386
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12387
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12388
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12389
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12390
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12391
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12396
12392
|
},
|
|
12397
12393
|
resolver: zodResolver(schema$1)
|
|
12398
12394
|
});
|
|
12399
12395
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12400
12396
|
const { handleSuccess } = useRouteModal();
|
|
12401
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12402
|
-
const currentCustomer = order.customer ? {
|
|
12403
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12404
|
-
value: order.customer.id
|
|
12405
|
-
} : null;
|
|
12406
12397
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12407
12398
|
await mutateAsync(
|
|
12408
|
-
{
|
|
12399
|
+
{
|
|
12400
|
+
shipping_address: {
|
|
12401
|
+
first_name: data.first_name,
|
|
12402
|
+
last_name: data.last_name,
|
|
12403
|
+
company: data.company,
|
|
12404
|
+
address_1: data.address_1,
|
|
12405
|
+
address_2: data.address_2,
|
|
12406
|
+
city: data.city,
|
|
12407
|
+
province: data.province,
|
|
12408
|
+
country_code: data.country_code,
|
|
12409
|
+
postal_code: data.postal_code,
|
|
12410
|
+
phone: data.phone
|
|
12411
|
+
}
|
|
12412
|
+
},
|
|
12409
12413
|
{
|
|
12410
12414
|
onSuccess: () => {
|
|
12411
|
-
toast.success("Customer updated");
|
|
12412
12415
|
handleSuccess();
|
|
12413
12416
|
},
|
|
12414
12417
|
onError: (error) => {
|
|
@@ -12423,13 +12426,200 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12423
12426
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12424
12427
|
onSubmit,
|
|
12425
12428
|
children: [
|
|
12426
|
-
/* @__PURE__ */
|
|
12427
|
-
/* @__PURE__ */ jsx(
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12429
|
+
/* @__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: [
|
|
12430
|
+
/* @__PURE__ */ jsx(
|
|
12431
|
+
Form$2.Field,
|
|
12432
|
+
{
|
|
12433
|
+
control: form.control,
|
|
12434
|
+
name: "country_code",
|
|
12435
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12436
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12437
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12438
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12439
|
+
] })
|
|
12440
|
+
}
|
|
12441
|
+
),
|
|
12442
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12443
|
+
/* @__PURE__ */ jsx(
|
|
12444
|
+
Form$2.Field,
|
|
12445
|
+
{
|
|
12446
|
+
control: form.control,
|
|
12447
|
+
name: "first_name",
|
|
12448
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12449
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12450
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12451
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12452
|
+
] })
|
|
12453
|
+
}
|
|
12454
|
+
),
|
|
12455
|
+
/* @__PURE__ */ jsx(
|
|
12456
|
+
Form$2.Field,
|
|
12457
|
+
{
|
|
12458
|
+
control: form.control,
|
|
12459
|
+
name: "last_name",
|
|
12460
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12461
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12462
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12463
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12464
|
+
] })
|
|
12465
|
+
}
|
|
12466
|
+
)
|
|
12467
|
+
] }),
|
|
12468
|
+
/* @__PURE__ */ jsx(
|
|
12469
|
+
Form$2.Field,
|
|
12470
|
+
{
|
|
12471
|
+
control: form.control,
|
|
12472
|
+
name: "company",
|
|
12473
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12474
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12475
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12476
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12477
|
+
] })
|
|
12478
|
+
}
|
|
12479
|
+
),
|
|
12480
|
+
/* @__PURE__ */ jsx(
|
|
12481
|
+
Form$2.Field,
|
|
12482
|
+
{
|
|
12483
|
+
control: form.control,
|
|
12484
|
+
name: "address_1",
|
|
12485
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12486
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12487
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12488
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12489
|
+
] })
|
|
12490
|
+
}
|
|
12491
|
+
),
|
|
12492
|
+
/* @__PURE__ */ jsx(
|
|
12493
|
+
Form$2.Field,
|
|
12494
|
+
{
|
|
12495
|
+
control: form.control,
|
|
12496
|
+
name: "address_2",
|
|
12497
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12498
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12499
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12500
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12501
|
+
] })
|
|
12502
|
+
}
|
|
12503
|
+
),
|
|
12504
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12505
|
+
/* @__PURE__ */ jsx(
|
|
12506
|
+
Form$2.Field,
|
|
12507
|
+
{
|
|
12508
|
+
control: form.control,
|
|
12509
|
+
name: "postal_code",
|
|
12510
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12511
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12512
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12513
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12514
|
+
] })
|
|
12515
|
+
}
|
|
12516
|
+
),
|
|
12517
|
+
/* @__PURE__ */ jsx(
|
|
12518
|
+
Form$2.Field,
|
|
12519
|
+
{
|
|
12520
|
+
control: form.control,
|
|
12521
|
+
name: "city",
|
|
12522
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12523
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12524
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12525
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12526
|
+
] })
|
|
12527
|
+
}
|
|
12528
|
+
)
|
|
12529
|
+
] }),
|
|
12530
|
+
/* @__PURE__ */ jsx(
|
|
12531
|
+
Form$2.Field,
|
|
12532
|
+
{
|
|
12533
|
+
control: form.control,
|
|
12534
|
+
name: "province",
|
|
12535
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12536
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12537
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12538
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12539
|
+
] })
|
|
12540
|
+
}
|
|
12541
|
+
),
|
|
12542
|
+
/* @__PURE__ */ jsx(
|
|
12543
|
+
Form$2.Field,
|
|
12544
|
+
{
|
|
12545
|
+
control: form.control,
|
|
12546
|
+
name: "phone",
|
|
12547
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12548
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12549
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12550
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12551
|
+
] })
|
|
12552
|
+
}
|
|
12553
|
+
)
|
|
12554
|
+
] }) }),
|
|
12555
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12556
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12557
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12558
|
+
] }) })
|
|
12559
|
+
]
|
|
12560
|
+
}
|
|
12561
|
+
) });
|
|
12562
|
+
};
|
|
12563
|
+
const schema$1 = addressSchema;
|
|
12564
|
+
const TransferOwnership = () => {
|
|
12565
|
+
const { id } = useParams();
|
|
12566
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12567
|
+
fields: "id,customer_id,customer.*"
|
|
12568
|
+
});
|
|
12569
|
+
if (isError) {
|
|
12570
|
+
throw error;
|
|
12571
|
+
}
|
|
12572
|
+
const isReady = !isPending && !!draft_order;
|
|
12573
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12574
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12575
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12576
|
+
/* @__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" }) })
|
|
12577
|
+
] }),
|
|
12578
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12579
|
+
] });
|
|
12580
|
+
};
|
|
12581
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12582
|
+
var _a, _b;
|
|
12583
|
+
const form = useForm({
|
|
12584
|
+
defaultValues: {
|
|
12585
|
+
customer_id: order.customer_id || ""
|
|
12586
|
+
},
|
|
12587
|
+
resolver: zodResolver(schema)
|
|
12588
|
+
});
|
|
12589
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12590
|
+
const { handleSuccess } = useRouteModal();
|
|
12591
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12592
|
+
const currentCustomer = order.customer ? {
|
|
12593
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12594
|
+
value: order.customer.id
|
|
12595
|
+
} : null;
|
|
12596
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12597
|
+
await mutateAsync(
|
|
12598
|
+
{ customer_id: data.customer_id },
|
|
12599
|
+
{
|
|
12600
|
+
onSuccess: () => {
|
|
12601
|
+
toast.success("Customer updated");
|
|
12602
|
+
handleSuccess();
|
|
12603
|
+
},
|
|
12604
|
+
onError: (error) => {
|
|
12605
|
+
toast.error(error.message);
|
|
12606
|
+
}
|
|
12607
|
+
}
|
|
12608
|
+
);
|
|
12609
|
+
});
|
|
12610
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12611
|
+
KeyboundForm,
|
|
12612
|
+
{
|
|
12613
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12614
|
+
onSubmit,
|
|
12615
|
+
children: [
|
|
12616
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12617
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12618
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12619
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12620
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12621
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12622
|
+
] }),
|
|
12433
12623
|
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12434
12624
|
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12435
12625
|
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
@@ -12844,199 +13034,9 @@ const Illustration = () => {
|
|
|
12844
13034
|
}
|
|
12845
13035
|
);
|
|
12846
13036
|
};
|
|
12847
|
-
const schema
|
|
13037
|
+
const schema = objectType({
|
|
12848
13038
|
customer_id: stringType().min(1)
|
|
12849
13039
|
});
|
|
12850
|
-
const BillingAddress = () => {
|
|
12851
|
-
const { id } = useParams();
|
|
12852
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12853
|
-
fields: "+billing_address"
|
|
12854
|
-
});
|
|
12855
|
-
if (isError) {
|
|
12856
|
-
throw error;
|
|
12857
|
-
}
|
|
12858
|
-
const isReady = !isPending && !!order;
|
|
12859
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12860
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
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" }) })
|
|
12863
|
-
] }),
|
|
12864
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12865
|
-
] });
|
|
12866
|
-
};
|
|
12867
|
-
const BillingAddressForm = ({ order }) => {
|
|
12868
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12869
|
-
const form = useForm({
|
|
12870
|
-
defaultValues: {
|
|
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) ?? ""
|
|
12881
|
-
},
|
|
12882
|
-
resolver: zodResolver(schema)
|
|
12883
|
-
});
|
|
12884
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12885
|
-
const { handleSuccess } = useRouteModal();
|
|
12886
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12887
|
-
await mutateAsync(
|
|
12888
|
-
{ billing_address: data },
|
|
12889
|
-
{
|
|
12890
|
-
onSuccess: () => {
|
|
12891
|
-
handleSuccess();
|
|
12892
|
-
},
|
|
12893
|
-
onError: (error) => {
|
|
12894
|
-
toast.error(error.message);
|
|
12895
|
-
}
|
|
12896
|
-
}
|
|
12897
|
-
);
|
|
12898
|
-
});
|
|
12899
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12900
|
-
KeyboundForm,
|
|
12901
|
-
{
|
|
12902
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12903
|
-
onSubmit,
|
|
12904
|
-
children: [
|
|
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
|
-
] }) }),
|
|
13031
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13032
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13033
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13034
|
-
] }) })
|
|
13035
|
-
]
|
|
13036
|
-
}
|
|
13037
|
-
) });
|
|
13038
|
-
};
|
|
13039
|
-
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13057,6 +13057,10 @@ const routeModule = {
|
|
|
13057
13057
|
handle,
|
|
13058
13058
|
loader,
|
|
13059
13059
|
children: [
|
|
13060
|
+
{
|
|
13061
|
+
Component: BillingAddress,
|
|
13062
|
+
path: "/draft-orders/:id/billing-address"
|
|
13063
|
+
},
|
|
13060
13064
|
{
|
|
13061
13065
|
Component: CustomItems,
|
|
13062
13066
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13081,21 +13085,17 @@ const routeModule = {
|
|
|
13081
13085
|
Component: SalesChannel,
|
|
13082
13086
|
path: "/draft-orders/:id/sales-channel"
|
|
13083
13087
|
},
|
|
13084
|
-
{
|
|
13085
|
-
Component: ShippingAddress,
|
|
13086
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13087
|
-
},
|
|
13088
13088
|
{
|
|
13089
13089
|
Component: Shipping,
|
|
13090
13090
|
path: "/draft-orders/:id/shipping"
|
|
13091
13091
|
},
|
|
13092
13092
|
{
|
|
13093
|
-
Component:
|
|
13094
|
-
path: "/draft-orders/:id/
|
|
13093
|
+
Component: ShippingAddress,
|
|
13094
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13095
13095
|
},
|
|
13096
13096
|
{
|
|
13097
|
-
Component:
|
|
13098
|
-
path: "/draft-orders/:id/
|
|
13097
|
+
Component: TransferOwnership,
|
|
13098
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|