@medusajs/draft-order 2.11.2-preview-20251026120206 → 2.11.2-snapshot-20251026124930
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 +457 -457
- package/.medusa/server/src/admin/index.mjs +457 -457
- package/package.json +16 -16
|
@@ -9565,196 +9565,6 @@ 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;
|
|
9758
9568
|
const Email = () => {
|
|
9759
9569
|
const { id } = useParams();
|
|
9760
9570
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9777,7 +9587,7 @@ const EmailForm = ({ order }) => {
|
|
|
9777
9587
|
defaultValues: {
|
|
9778
9588
|
email: order.email ?? ""
|
|
9779
9589
|
},
|
|
9780
|
-
resolver: zodResolver(schema$
|
|
9590
|
+
resolver: zodResolver(schema$5)
|
|
9781
9591
|
});
|
|
9782
9592
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9783
9593
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9820,7 +9630,7 @@ const EmailForm = ({ order }) => {
|
|
|
9820
9630
|
}
|
|
9821
9631
|
) });
|
|
9822
9632
|
};
|
|
9823
|
-
const schema$
|
|
9633
|
+
const schema$5 = objectType({
|
|
9824
9634
|
email: stringType().email()
|
|
9825
9635
|
});
|
|
9826
9636
|
const NumberInput = forwardRef(
|
|
@@ -11424,6 +11234,27 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11424
11234
|
}
|
|
11425
11235
|
return Array.from(promotionIds);
|
|
11426
11236
|
}
|
|
11237
|
+
const CustomItems = () => {
|
|
11238
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11239
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
11240
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
11241
|
+
] });
|
|
11242
|
+
};
|
|
11243
|
+
const CustomItemsForm = () => {
|
|
11244
|
+
const form = useForm({
|
|
11245
|
+
resolver: zodResolver(schema$4)
|
|
11246
|
+
});
|
|
11247
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
11248
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
11249
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11250
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11251
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
11252
|
+
] }) })
|
|
11253
|
+
] }) });
|
|
11254
|
+
};
|
|
11255
|
+
const schema$4 = objectType({
|
|
11256
|
+
email: stringType().email()
|
|
11257
|
+
});
|
|
11427
11258
|
const SalesChannel = () => {
|
|
11428
11259
|
const { id } = useParams();
|
|
11429
11260
|
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
@@ -12337,244 +12168,41 @@ const CustomAmountField = ({
|
|
|
12337
12168
|
}
|
|
12338
12169
|
);
|
|
12339
12170
|
};
|
|
12340
|
-
const
|
|
12171
|
+
const TransferOwnership = () => {
|
|
12341
12172
|
const { id } = useParams();
|
|
12342
|
-
const {
|
|
12343
|
-
fields: "
|
|
12173
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12174
|
+
fields: "id,customer_id,customer.*"
|
|
12344
12175
|
});
|
|
12345
12176
|
if (isError) {
|
|
12346
12177
|
throw error;
|
|
12347
12178
|
}
|
|
12348
|
-
const isReady = !isPending && !!
|
|
12179
|
+
const isReady = !isPending && !!draft_order;
|
|
12349
12180
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12350
12181
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12351
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12352
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12182
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12183
|
+
/* @__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" }) })
|
|
12353
12184
|
] }),
|
|
12354
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12185
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12355
12186
|
] });
|
|
12356
12187
|
};
|
|
12357
|
-
const
|
|
12358
|
-
var _a, _b
|
|
12188
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12189
|
+
var _a, _b;
|
|
12359
12190
|
const form = useForm({
|
|
12360
12191
|
defaultValues: {
|
|
12361
|
-
|
|
12362
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12363
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12364
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12365
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12366
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12367
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12368
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12369
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12370
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12192
|
+
customer_id: order.customer_id || ""
|
|
12371
12193
|
},
|
|
12372
12194
|
resolver: zodResolver(schema$2)
|
|
12373
12195
|
});
|
|
12374
12196
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12375
12197
|
const { handleSuccess } = useRouteModal();
|
|
12198
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12199
|
+
const currentCustomer = order.customer ? {
|
|
12200
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12201
|
+
value: order.customer.id
|
|
12202
|
+
} : null;
|
|
12376
12203
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12377
12204
|
await mutateAsync(
|
|
12378
|
-
{
|
|
12379
|
-
shipping_address: {
|
|
12380
|
-
first_name: data.first_name,
|
|
12381
|
-
last_name: data.last_name,
|
|
12382
|
-
company: data.company,
|
|
12383
|
-
address_1: data.address_1,
|
|
12384
|
-
address_2: data.address_2,
|
|
12385
|
-
city: data.city,
|
|
12386
|
-
province: data.province,
|
|
12387
|
-
country_code: data.country_code,
|
|
12388
|
-
postal_code: data.postal_code,
|
|
12389
|
-
phone: data.phone
|
|
12390
|
-
}
|
|
12391
|
-
},
|
|
12392
|
-
{
|
|
12393
|
-
onSuccess: () => {
|
|
12394
|
-
handleSuccess();
|
|
12395
|
-
},
|
|
12396
|
-
onError: (error) => {
|
|
12397
|
-
toast.error(error.message);
|
|
12398
|
-
}
|
|
12399
|
-
}
|
|
12400
|
-
);
|
|
12401
|
-
});
|
|
12402
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12403
|
-
KeyboundForm,
|
|
12404
|
-
{
|
|
12405
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12406
|
-
onSubmit,
|
|
12407
|
-
children: [
|
|
12408
|
-
/* @__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: [
|
|
12409
|
-
/* @__PURE__ */ jsx(
|
|
12410
|
-
Form$2.Field,
|
|
12411
|
-
{
|
|
12412
|
-
control: form.control,
|
|
12413
|
-
name: "country_code",
|
|
12414
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12415
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12416
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12417
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12418
|
-
] })
|
|
12419
|
-
}
|
|
12420
|
-
),
|
|
12421
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12422
|
-
/* @__PURE__ */ jsx(
|
|
12423
|
-
Form$2.Field,
|
|
12424
|
-
{
|
|
12425
|
-
control: form.control,
|
|
12426
|
-
name: "first_name",
|
|
12427
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12428
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12429
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12430
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12431
|
-
] })
|
|
12432
|
-
}
|
|
12433
|
-
),
|
|
12434
|
-
/* @__PURE__ */ jsx(
|
|
12435
|
-
Form$2.Field,
|
|
12436
|
-
{
|
|
12437
|
-
control: form.control,
|
|
12438
|
-
name: "last_name",
|
|
12439
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12440
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12441
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12442
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12443
|
-
] })
|
|
12444
|
-
}
|
|
12445
|
-
)
|
|
12446
|
-
] }),
|
|
12447
|
-
/* @__PURE__ */ jsx(
|
|
12448
|
-
Form$2.Field,
|
|
12449
|
-
{
|
|
12450
|
-
control: form.control,
|
|
12451
|
-
name: "company",
|
|
12452
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12453
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12454
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12455
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12456
|
-
] })
|
|
12457
|
-
}
|
|
12458
|
-
),
|
|
12459
|
-
/* @__PURE__ */ jsx(
|
|
12460
|
-
Form$2.Field,
|
|
12461
|
-
{
|
|
12462
|
-
control: form.control,
|
|
12463
|
-
name: "address_1",
|
|
12464
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12465
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12466
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12467
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12468
|
-
] })
|
|
12469
|
-
}
|
|
12470
|
-
),
|
|
12471
|
-
/* @__PURE__ */ jsx(
|
|
12472
|
-
Form$2.Field,
|
|
12473
|
-
{
|
|
12474
|
-
control: form.control,
|
|
12475
|
-
name: "address_2",
|
|
12476
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12477
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12478
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12479
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12480
|
-
] })
|
|
12481
|
-
}
|
|
12482
|
-
),
|
|
12483
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12484
|
-
/* @__PURE__ */ jsx(
|
|
12485
|
-
Form$2.Field,
|
|
12486
|
-
{
|
|
12487
|
-
control: form.control,
|
|
12488
|
-
name: "postal_code",
|
|
12489
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12490
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12491
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12492
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12493
|
-
] })
|
|
12494
|
-
}
|
|
12495
|
-
),
|
|
12496
|
-
/* @__PURE__ */ jsx(
|
|
12497
|
-
Form$2.Field,
|
|
12498
|
-
{
|
|
12499
|
-
control: form.control,
|
|
12500
|
-
name: "city",
|
|
12501
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12502
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12503
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12504
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12505
|
-
] })
|
|
12506
|
-
}
|
|
12507
|
-
)
|
|
12508
|
-
] }),
|
|
12509
|
-
/* @__PURE__ */ jsx(
|
|
12510
|
-
Form$2.Field,
|
|
12511
|
-
{
|
|
12512
|
-
control: form.control,
|
|
12513
|
-
name: "province",
|
|
12514
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12515
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12516
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12517
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12518
|
-
] })
|
|
12519
|
-
}
|
|
12520
|
-
),
|
|
12521
|
-
/* @__PURE__ */ jsx(
|
|
12522
|
-
Form$2.Field,
|
|
12523
|
-
{
|
|
12524
|
-
control: form.control,
|
|
12525
|
-
name: "phone",
|
|
12526
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12527
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12528
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12529
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12530
|
-
] })
|
|
12531
|
-
}
|
|
12532
|
-
)
|
|
12533
|
-
] }) }),
|
|
12534
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12535
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12536
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12537
|
-
] }) })
|
|
12538
|
-
]
|
|
12539
|
-
}
|
|
12540
|
-
) });
|
|
12541
|
-
};
|
|
12542
|
-
const schema$2 = addressSchema;
|
|
12543
|
-
const TransferOwnership = () => {
|
|
12544
|
-
const { id } = useParams();
|
|
12545
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12546
|
-
fields: "id,customer_id,customer.*"
|
|
12547
|
-
});
|
|
12548
|
-
if (isError) {
|
|
12549
|
-
throw error;
|
|
12550
|
-
}
|
|
12551
|
-
const isReady = !isPending && !!draft_order;
|
|
12552
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12553
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12554
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12555
|
-
/* @__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" }) })
|
|
12556
|
-
] }),
|
|
12557
|
-
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12558
|
-
] });
|
|
12559
|
-
};
|
|
12560
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
12561
|
-
var _a, _b;
|
|
12562
|
-
const form = useForm({
|
|
12563
|
-
defaultValues: {
|
|
12564
|
-
customer_id: order.customer_id || ""
|
|
12565
|
-
},
|
|
12566
|
-
resolver: zodResolver(schema$1)
|
|
12567
|
-
});
|
|
12568
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12569
|
-
const { handleSuccess } = useRouteModal();
|
|
12570
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12571
|
-
const currentCustomer = order.customer ? {
|
|
12572
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12573
|
-
value: order.customer.id
|
|
12574
|
-
} : null;
|
|
12575
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12576
|
-
await mutateAsync(
|
|
12577
|
-
{ customer_id: data.customer_id },
|
|
12205
|
+
{ customer_id: data.customer_id },
|
|
12578
12206
|
{
|
|
12579
12207
|
onSuccess: () => {
|
|
12580
12208
|
toast.success("Customer updated");
|
|
@@ -13013,54 +12641,422 @@ const Illustration = () => {
|
|
|
13013
12641
|
}
|
|
13014
12642
|
);
|
|
13015
12643
|
};
|
|
13016
|
-
const schema$
|
|
12644
|
+
const schema$2 = objectType({
|
|
13017
12645
|
customer_id: stringType().min(1)
|
|
13018
12646
|
});
|
|
13019
|
-
const
|
|
12647
|
+
const ShippingAddress = () => {
|
|
12648
|
+
const { id } = useParams();
|
|
12649
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12650
|
+
fields: "+shipping_address"
|
|
12651
|
+
});
|
|
12652
|
+
if (isError) {
|
|
12653
|
+
throw error;
|
|
12654
|
+
}
|
|
12655
|
+
const isReady = !isPending && !!order;
|
|
13020
12656
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
13021
|
-
/* @__PURE__ */
|
|
13022
|
-
|
|
12657
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12658
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12659
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12660
|
+
] }),
|
|
12661
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
13023
12662
|
] });
|
|
13024
12663
|
};
|
|
13025
|
-
const
|
|
12664
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12665
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
13026
12666
|
const form = useForm({
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
email: stringType().email()
|
|
13039
|
-
});
|
|
13040
|
-
const widgetModule = { widgets: [] };
|
|
13041
|
-
const routeModule = {
|
|
13042
|
-
routes: [
|
|
13043
|
-
{
|
|
13044
|
-
Component: List,
|
|
13045
|
-
path: "/draft-orders",
|
|
13046
|
-
handle: handle$1,
|
|
13047
|
-
children: [
|
|
13048
|
-
{
|
|
13049
|
-
Component: Create,
|
|
13050
|
-
path: "/draft-orders/create"
|
|
13051
|
-
}
|
|
13052
|
-
]
|
|
12667
|
+
defaultValues: {
|
|
12668
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12669
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12670
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12671
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12672
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12673
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12674
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12675
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12676
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12677
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
13053
12678
|
},
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
12679
|
+
resolver: zodResolver(schema$1)
|
|
12680
|
+
});
|
|
12681
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12682
|
+
const { handleSuccess } = useRouteModal();
|
|
12683
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12684
|
+
await mutateAsync(
|
|
12685
|
+
{
|
|
12686
|
+
shipping_address: {
|
|
12687
|
+
first_name: data.first_name,
|
|
12688
|
+
last_name: data.last_name,
|
|
12689
|
+
company: data.company,
|
|
12690
|
+
address_1: data.address_1,
|
|
12691
|
+
address_2: data.address_2,
|
|
12692
|
+
city: data.city,
|
|
12693
|
+
province: data.province,
|
|
12694
|
+
country_code: data.country_code,
|
|
12695
|
+
postal_code: data.postal_code,
|
|
12696
|
+
phone: data.phone
|
|
12697
|
+
}
|
|
12698
|
+
},
|
|
12699
|
+
{
|
|
12700
|
+
onSuccess: () => {
|
|
12701
|
+
handleSuccess();
|
|
12702
|
+
},
|
|
12703
|
+
onError: (error) => {
|
|
12704
|
+
toast.error(error.message);
|
|
12705
|
+
}
|
|
12706
|
+
}
|
|
12707
|
+
);
|
|
12708
|
+
});
|
|
12709
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12710
|
+
KeyboundForm,
|
|
12711
|
+
{
|
|
12712
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12713
|
+
onSubmit,
|
|
12714
|
+
children: [
|
|
12715
|
+
/* @__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: [
|
|
12716
|
+
/* @__PURE__ */ jsx(
|
|
12717
|
+
Form$2.Field,
|
|
12718
|
+
{
|
|
12719
|
+
control: form.control,
|
|
12720
|
+
name: "country_code",
|
|
12721
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12722
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12723
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12724
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12725
|
+
] })
|
|
12726
|
+
}
|
|
12727
|
+
),
|
|
12728
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12729
|
+
/* @__PURE__ */ jsx(
|
|
12730
|
+
Form$2.Field,
|
|
12731
|
+
{
|
|
12732
|
+
control: form.control,
|
|
12733
|
+
name: "first_name",
|
|
12734
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12735
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12736
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12737
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12738
|
+
] })
|
|
12739
|
+
}
|
|
12740
|
+
),
|
|
12741
|
+
/* @__PURE__ */ jsx(
|
|
12742
|
+
Form$2.Field,
|
|
12743
|
+
{
|
|
12744
|
+
control: form.control,
|
|
12745
|
+
name: "last_name",
|
|
12746
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12747
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12748
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12749
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12750
|
+
] })
|
|
12751
|
+
}
|
|
12752
|
+
)
|
|
12753
|
+
] }),
|
|
12754
|
+
/* @__PURE__ */ jsx(
|
|
12755
|
+
Form$2.Field,
|
|
12756
|
+
{
|
|
12757
|
+
control: form.control,
|
|
12758
|
+
name: "company",
|
|
12759
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12760
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12761
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12762
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12763
|
+
] })
|
|
12764
|
+
}
|
|
12765
|
+
),
|
|
12766
|
+
/* @__PURE__ */ jsx(
|
|
12767
|
+
Form$2.Field,
|
|
12768
|
+
{
|
|
12769
|
+
control: form.control,
|
|
12770
|
+
name: "address_1",
|
|
12771
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12772
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12773
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12774
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12775
|
+
] })
|
|
12776
|
+
}
|
|
12777
|
+
),
|
|
12778
|
+
/* @__PURE__ */ jsx(
|
|
12779
|
+
Form$2.Field,
|
|
12780
|
+
{
|
|
12781
|
+
control: form.control,
|
|
12782
|
+
name: "address_2",
|
|
12783
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12784
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12785
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12786
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12787
|
+
] })
|
|
12788
|
+
}
|
|
12789
|
+
),
|
|
12790
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12791
|
+
/* @__PURE__ */ jsx(
|
|
12792
|
+
Form$2.Field,
|
|
12793
|
+
{
|
|
12794
|
+
control: form.control,
|
|
12795
|
+
name: "postal_code",
|
|
12796
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12797
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12798
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12799
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12800
|
+
] })
|
|
12801
|
+
}
|
|
12802
|
+
),
|
|
12803
|
+
/* @__PURE__ */ jsx(
|
|
12804
|
+
Form$2.Field,
|
|
12805
|
+
{
|
|
12806
|
+
control: form.control,
|
|
12807
|
+
name: "city",
|
|
12808
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12809
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12810
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12811
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12812
|
+
] })
|
|
12813
|
+
}
|
|
12814
|
+
)
|
|
12815
|
+
] }),
|
|
12816
|
+
/* @__PURE__ */ jsx(
|
|
12817
|
+
Form$2.Field,
|
|
12818
|
+
{
|
|
12819
|
+
control: form.control,
|
|
12820
|
+
name: "province",
|
|
12821
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12822
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12823
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12824
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12825
|
+
] })
|
|
12826
|
+
}
|
|
12827
|
+
),
|
|
12828
|
+
/* @__PURE__ */ jsx(
|
|
12829
|
+
Form$2.Field,
|
|
12830
|
+
{
|
|
12831
|
+
control: form.control,
|
|
12832
|
+
name: "phone",
|
|
12833
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12834
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12835
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12836
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12837
|
+
] })
|
|
12838
|
+
}
|
|
12839
|
+
)
|
|
12840
|
+
] }) }),
|
|
12841
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12842
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12843
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12844
|
+
] }) })
|
|
12845
|
+
]
|
|
12846
|
+
}
|
|
12847
|
+
) });
|
|
12848
|
+
};
|
|
12849
|
+
const schema$1 = addressSchema;
|
|
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();
|
|
13063
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
|
+
const widgetModule = { widgets: [] };
|
|
13041
|
+
const routeModule = {
|
|
13042
|
+
routes: [
|
|
13043
|
+
{
|
|
13044
|
+
Component: List,
|
|
13045
|
+
path: "/draft-orders",
|
|
13046
|
+
handle: handle$1,
|
|
13047
|
+
children: [
|
|
13048
|
+
{
|
|
13049
|
+
Component: Create,
|
|
13050
|
+
path: "/draft-orders/create"
|
|
13051
|
+
}
|
|
13052
|
+
]
|
|
13053
|
+
},
|
|
13054
|
+
{
|
|
13055
|
+
Component: ID,
|
|
13056
|
+
path: "/draft-orders/:id",
|
|
13057
|
+
handle,
|
|
13058
|
+
loader,
|
|
13059
|
+
children: [
|
|
13064
13060
|
{
|
|
13065
13061
|
Component: Email,
|
|
13066
13062
|
path: "/draft-orders/:id/email"
|
|
@@ -13077,6 +13073,10 @@ const routeModule = {
|
|
|
13077
13073
|
Component: Promotions,
|
|
13078
13074
|
path: "/draft-orders/:id/promotions"
|
|
13079
13075
|
},
|
|
13076
|
+
{
|
|
13077
|
+
Component: CustomItems,
|
|
13078
|
+
path: "/draft-orders/:id/custom-items"
|
|
13079
|
+
},
|
|
13080
13080
|
{
|
|
13081
13081
|
Component: SalesChannel,
|
|
13082
13082
|
path: "/draft-orders/:id/sales-channel"
|
|
@@ -13085,17 +13085,17 @@ const routeModule = {
|
|
|
13085
13085
|
Component: Shipping,
|
|
13086
13086
|
path: "/draft-orders/:id/shipping"
|
|
13087
13087
|
},
|
|
13088
|
-
{
|
|
13089
|
-
Component: ShippingAddress,
|
|
13090
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
-
},
|
|
13092
13088
|
{
|
|
13093
13089
|
Component: TransferOwnership,
|
|
13094
13090
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
13091
|
},
|
|
13096
13092
|
{
|
|
13097
|
-
Component:
|
|
13098
|
-
path: "/draft-orders/:id/
|
|
13093
|
+
Component: ShippingAddress,
|
|
13094
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13095
|
+
},
|
|
13096
|
+
{
|
|
13097
|
+
Component: BillingAddress,
|
|
13098
|
+
path: "/draft-orders/:id/billing-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|