@medusajs/draft-order 2.11.0-snapshot-20250829134337 → 2.11.0-snapshot-20251016104801
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 +270 -257
- package/.medusa/server/src/admin/index.mjs +270 -257
- package/package.json +16 -30
|
@@ -346,7 +346,7 @@ const DataTableAction = ({
|
|
|
346
346
|
return /* @__PURE__ */ jsx(Button, { ...buttonProps, onClick: props.onClick, children: label });
|
|
347
347
|
};
|
|
348
348
|
const sdk = new Medusa({
|
|
349
|
-
baseUrl: "/",
|
|
349
|
+
baseUrl: __BACKEND_URL__ || "/",
|
|
350
350
|
auth: {
|
|
351
351
|
type: "session"
|
|
352
352
|
}
|
|
@@ -7567,12 +7567,12 @@ const addressSchema = objectType({
|
|
|
7567
7567
|
first_name: stringType().min(1),
|
|
7568
7568
|
last_name: stringType().min(1),
|
|
7569
7569
|
address_1: stringType().min(1),
|
|
7570
|
-
address_2: stringType().
|
|
7571
|
-
company: stringType().
|
|
7570
|
+
address_2: stringType().nullish(),
|
|
7571
|
+
company: stringType().nullish(),
|
|
7572
7572
|
city: stringType().min(1),
|
|
7573
|
-
province: stringType().
|
|
7573
|
+
province: stringType().nullish(),
|
|
7574
7574
|
postal_code: stringType().min(1),
|
|
7575
|
-
phone: stringType().
|
|
7575
|
+
phone: stringType().nullish()
|
|
7576
7576
|
});
|
|
7577
7577
|
const Create = () => {
|
|
7578
7578
|
return /* @__PURE__ */ jsx(RouteFocusModal, { children: /* @__PURE__ */ jsx(CreateForm, {}) });
|
|
@@ -8322,7 +8322,7 @@ const ActivitySection = ({ order, changes }) => {
|
|
|
8322
8322
|
() => getActivityItems(order, changes),
|
|
8323
8323
|
[order, changes]
|
|
8324
8324
|
);
|
|
8325
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0
|
|
8325
|
+
return /* @__PURE__ */ jsxs(Container, { className: "overflow-hidden p-0", children: [
|
|
8326
8326
|
/* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(Heading, { children: "Activity" }) }),
|
|
8327
8327
|
/* @__PURE__ */ jsx(ActivityItemList, { items: activityItems })
|
|
8328
8328
|
] });
|
|
@@ -8353,8 +8353,8 @@ const CollapsibleActivityItemList = ({
|
|
|
8353
8353
|
const [open, setOpen] = useState(false);
|
|
8354
8354
|
return /* @__PURE__ */ jsxs(Collapsible.Root, { open, onOpenChange: setOpen, children: [
|
|
8355
8355
|
!open && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
|
|
8356
|
-
/* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y
|
|
8357
|
-
/* @__PURE__ */ jsx(Collapsible.Trigger, { className: "text-
|
|
8356
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-clip-content bg-right bg-repeat-y" }) }),
|
|
8357
|
+
/* @__PURE__ */ jsx(Collapsible.Trigger, { className: "text-ui-fg-muted hover:text-ui-fg-base focus:text-ui-fg-base m-0 p-0 pb-4 text-left outline-none transition-colors", children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: `Show ${items.length} more ${items.length === 1 ? "activity" : "activities"}` }) })
|
|
8358
8358
|
] }),
|
|
8359
8359
|
/* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-0.5", children: items.map((item, idx) => {
|
|
8360
8360
|
return /* @__PURE__ */ jsx(ActivityItem, { item }, idx);
|
|
@@ -8372,14 +8372,14 @@ const ActivityItem = ({ item, isFirst = false }) => {
|
|
|
8372
8372
|
return /* @__PURE__ */ jsxs(
|
|
8373
8373
|
"div",
|
|
8374
8374
|
{
|
|
8375
|
-
className: clx("grid grid-cols-[20px_1fr] items-start gap-x-2
|
|
8375
|
+
className: clx("grid w-full grid-cols-[20px_1fr] items-start gap-x-2"),
|
|
8376
8376
|
children: [
|
|
8377
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-0.5
|
|
8378
|
-
/* @__PURE__ */ jsx("div", { className: "size-5
|
|
8379
|
-
!isFirst && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "h-full w-px
|
|
8377
|
+
/* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col items-center gap-0.5", children: [
|
|
8378
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-5 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "shadow-borders-base flex size-2.5 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-tag-neutral-icon size-1.5 rounded-full" }) }) }),
|
|
8379
|
+
!isFirst && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-border-base h-full w-px" }) })
|
|
8380
8380
|
] }),
|
|
8381
8381
|
/* @__PURE__ */ jsxs("div", { className: clx("flex flex-col", !isFirst && "pb-4"), children: [
|
|
8382
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2
|
|
8382
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
8383
8383
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.label }),
|
|
8384
8384
|
/* @__PURE__ */ jsx(
|
|
8385
8385
|
Tooltip,
|
|
@@ -8390,7 +8390,7 @@ const ActivityItem = ({ item, isFirst = false }) => {
|
|
|
8390
8390
|
)
|
|
8391
8391
|
] }),
|
|
8392
8392
|
item.content && renderContent(item.content),
|
|
8393
|
-
item.userId && /* @__PURE__ */ jsx("div", { className: "
|
|
8393
|
+
item.userId && /* @__PURE__ */ jsx("div", { className: "text-ui-fg-muted pt-2", children: isUserLoaded ? /* @__PURE__ */ jsx(Link, { to: `/settings/users/${user.id}`, className: "w-fit", children: /* @__PURE__ */ jsxs("div", { className: "flex w-fit items-center gap-x-1.5", children: [
|
|
8394
8394
|
/* @__PURE__ */ jsx(Text, { size: "small", children: "By" }),
|
|
8395
8395
|
/* @__PURE__ */ jsx(
|
|
8396
8396
|
Avatar,
|
|
@@ -8406,8 +8406,8 @@ const ActivityItem = ({ item, isFirst = false }) => {
|
|
|
8406
8406
|
] })
|
|
8407
8407
|
] }) }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1.5", children: [
|
|
8408
8408
|
/* @__PURE__ */ jsx(Text, { size: "small", children: "By" }),
|
|
8409
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "
|
|
8410
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "w-[75px]
|
|
8409
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-5 rounded-full" }),
|
|
8410
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-[75px]" })
|
|
8411
8411
|
] }) })
|
|
8412
8412
|
] })
|
|
8413
8413
|
]
|
|
@@ -8430,7 +8430,12 @@ function getEditActivityItems(change) {
|
|
|
8430
8430
|
promotionsAdded: 0,
|
|
8431
8431
|
promotionsRemoved: 0
|
|
8432
8432
|
};
|
|
8433
|
-
|
|
8433
|
+
const orderedActions = change.actions.sort((a, b) => {
|
|
8434
|
+
return a.ordering - b.ordering;
|
|
8435
|
+
});
|
|
8436
|
+
const addedPromotionMap = /* @__PURE__ */ new Map();
|
|
8437
|
+
const removedPromotionMap = /* @__PURE__ */ new Map();
|
|
8438
|
+
for (const action of orderedActions) {
|
|
8434
8439
|
if (!action.details) {
|
|
8435
8440
|
continue;
|
|
8436
8441
|
}
|
|
@@ -8448,13 +8453,21 @@ function getEditActivityItems(change) {
|
|
|
8448
8453
|
case "SHIPPING_REMOVE":
|
|
8449
8454
|
counts.shippingMethodsRemoved += 1;
|
|
8450
8455
|
break;
|
|
8451
|
-
case "PROMOTION_ADD":
|
|
8452
|
-
|
|
8456
|
+
case "PROMOTION_ADD": {
|
|
8457
|
+
addedPromotionMap.set(action.reference_id, true);
|
|
8453
8458
|
break;
|
|
8454
|
-
|
|
8455
|
-
|
|
8459
|
+
}
|
|
8460
|
+
case "PROMOTION_REMOVE": {
|
|
8461
|
+
if (addedPromotionMap.has(action.reference_id)) {
|
|
8462
|
+
addedPromotionMap.delete(action.reference_id);
|
|
8463
|
+
} else {
|
|
8464
|
+
removedPromotionMap.set(action.reference_id, true);
|
|
8465
|
+
}
|
|
8456
8466
|
break;
|
|
8467
|
+
}
|
|
8457
8468
|
}
|
|
8469
|
+
counts.promotionsAdded = addedPromotionMap.size;
|
|
8470
|
+
counts.promotionsRemoved = removedPromotionMap.size;
|
|
8458
8471
|
}
|
|
8459
8472
|
const createActivityItem = (type, added, removed) => {
|
|
8460
8473
|
if (added === 0 && removed === 0) return;
|
|
@@ -9554,196 +9567,6 @@ const ID = () => {
|
|
|
9554
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9555
9568
|
] });
|
|
9556
9569
|
};
|
|
9557
|
-
const BillingAddress = () => {
|
|
9558
|
-
const { id } = useParams();
|
|
9559
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9560
|
-
fields: "+billing_address"
|
|
9561
|
-
});
|
|
9562
|
-
if (isError) {
|
|
9563
|
-
throw error;
|
|
9564
|
-
}
|
|
9565
|
-
const isReady = !isPending && !!order;
|
|
9566
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9567
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9568
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9569
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9570
|
-
] }),
|
|
9571
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9572
|
-
] });
|
|
9573
|
-
};
|
|
9574
|
-
const BillingAddressForm = ({ order }) => {
|
|
9575
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9576
|
-
const form = useForm({
|
|
9577
|
-
defaultValues: {
|
|
9578
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9579
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9580
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9581
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9582
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9583
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9584
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9585
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9586
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9587
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9588
|
-
},
|
|
9589
|
-
resolver: zodResolver(schema$5)
|
|
9590
|
-
});
|
|
9591
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9592
|
-
const { handleSuccess } = useRouteModal();
|
|
9593
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9594
|
-
await mutateAsync(
|
|
9595
|
-
{ billing_address: data },
|
|
9596
|
-
{
|
|
9597
|
-
onSuccess: () => {
|
|
9598
|
-
handleSuccess();
|
|
9599
|
-
},
|
|
9600
|
-
onError: (error) => {
|
|
9601
|
-
toast.error(error.message);
|
|
9602
|
-
}
|
|
9603
|
-
}
|
|
9604
|
-
);
|
|
9605
|
-
});
|
|
9606
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9607
|
-
KeyboundForm,
|
|
9608
|
-
{
|
|
9609
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9610
|
-
onSubmit,
|
|
9611
|
-
children: [
|
|
9612
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9613
|
-
/* @__PURE__ */ jsx(
|
|
9614
|
-
Form$2.Field,
|
|
9615
|
-
{
|
|
9616
|
-
control: form.control,
|
|
9617
|
-
name: "country_code",
|
|
9618
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9619
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9620
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9621
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9622
|
-
] })
|
|
9623
|
-
}
|
|
9624
|
-
),
|
|
9625
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9626
|
-
/* @__PURE__ */ jsx(
|
|
9627
|
-
Form$2.Field,
|
|
9628
|
-
{
|
|
9629
|
-
control: form.control,
|
|
9630
|
-
name: "first_name",
|
|
9631
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9633
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9634
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9635
|
-
] })
|
|
9636
|
-
}
|
|
9637
|
-
),
|
|
9638
|
-
/* @__PURE__ */ jsx(
|
|
9639
|
-
Form$2.Field,
|
|
9640
|
-
{
|
|
9641
|
-
control: form.control,
|
|
9642
|
-
name: "last_name",
|
|
9643
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9644
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9645
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9646
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9647
|
-
] })
|
|
9648
|
-
}
|
|
9649
|
-
)
|
|
9650
|
-
] }),
|
|
9651
|
-
/* @__PURE__ */ jsx(
|
|
9652
|
-
Form$2.Field,
|
|
9653
|
-
{
|
|
9654
|
-
control: form.control,
|
|
9655
|
-
name: "company",
|
|
9656
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9658
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
-
] })
|
|
9661
|
-
}
|
|
9662
|
-
),
|
|
9663
|
-
/* @__PURE__ */ jsx(
|
|
9664
|
-
Form$2.Field,
|
|
9665
|
-
{
|
|
9666
|
-
control: form.control,
|
|
9667
|
-
name: "address_1",
|
|
9668
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9669
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9670
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9671
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9672
|
-
] })
|
|
9673
|
-
}
|
|
9674
|
-
),
|
|
9675
|
-
/* @__PURE__ */ jsx(
|
|
9676
|
-
Form$2.Field,
|
|
9677
|
-
{
|
|
9678
|
-
control: form.control,
|
|
9679
|
-
name: "address_2",
|
|
9680
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9681
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9682
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9683
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9684
|
-
] })
|
|
9685
|
-
}
|
|
9686
|
-
),
|
|
9687
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9688
|
-
/* @__PURE__ */ jsx(
|
|
9689
|
-
Form$2.Field,
|
|
9690
|
-
{
|
|
9691
|
-
control: form.control,
|
|
9692
|
-
name: "postal_code",
|
|
9693
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9695
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
-
] })
|
|
9698
|
-
}
|
|
9699
|
-
),
|
|
9700
|
-
/* @__PURE__ */ jsx(
|
|
9701
|
-
Form$2.Field,
|
|
9702
|
-
{
|
|
9703
|
-
control: form.control,
|
|
9704
|
-
name: "city",
|
|
9705
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9706
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9707
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9708
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9709
|
-
] })
|
|
9710
|
-
}
|
|
9711
|
-
)
|
|
9712
|
-
] }),
|
|
9713
|
-
/* @__PURE__ */ jsx(
|
|
9714
|
-
Form$2.Field,
|
|
9715
|
-
{
|
|
9716
|
-
control: form.control,
|
|
9717
|
-
name: "province",
|
|
9718
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9720
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
-
] })
|
|
9723
|
-
}
|
|
9724
|
-
),
|
|
9725
|
-
/* @__PURE__ */ jsx(
|
|
9726
|
-
Form$2.Field,
|
|
9727
|
-
{
|
|
9728
|
-
control: form.control,
|
|
9729
|
-
name: "phone",
|
|
9730
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9731
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9732
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9733
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9734
|
-
] })
|
|
9735
|
-
}
|
|
9736
|
-
)
|
|
9737
|
-
] }) }),
|
|
9738
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9739
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9740
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9741
|
-
] }) })
|
|
9742
|
-
]
|
|
9743
|
-
}
|
|
9744
|
-
) });
|
|
9745
|
-
};
|
|
9746
|
-
const schema$5 = addressSchema;
|
|
9747
9570
|
const CustomItems = () => {
|
|
9748
9571
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9749
9572
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9752,7 +9575,7 @@ const CustomItems = () => {
|
|
|
9752
9575
|
};
|
|
9753
9576
|
const CustomItemsForm = () => {
|
|
9754
9577
|
const form = useForm({
|
|
9755
|
-
resolver: zodResolver(schema$
|
|
9578
|
+
resolver: zodResolver(schema$5)
|
|
9756
9579
|
});
|
|
9757
9580
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9758
9581
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9762,7 +9585,7 @@ const CustomItemsForm = () => {
|
|
|
9762
9585
|
] }) })
|
|
9763
9586
|
] }) });
|
|
9764
9587
|
};
|
|
9765
|
-
const schema$
|
|
9588
|
+
const schema$5 = objectType({
|
|
9766
9589
|
email: stringType().email()
|
|
9767
9590
|
});
|
|
9768
9591
|
const Email = () => {
|
|
@@ -9787,7 +9610,7 @@ const EmailForm = ({ order }) => {
|
|
|
9787
9610
|
defaultValues: {
|
|
9788
9611
|
email: order.email ?? ""
|
|
9789
9612
|
},
|
|
9790
|
-
resolver: zodResolver(schema$
|
|
9613
|
+
resolver: zodResolver(schema$4)
|
|
9791
9614
|
});
|
|
9792
9615
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9793
9616
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9830,7 +9653,7 @@ const EmailForm = ({ order }) => {
|
|
|
9830
9653
|
}
|
|
9831
9654
|
) });
|
|
9832
9655
|
};
|
|
9833
|
-
const schema$
|
|
9656
|
+
const schema$4 = objectType({
|
|
9834
9657
|
email: stringType().email()
|
|
9835
9658
|
});
|
|
9836
9659
|
const NumberInput = forwardRef(
|
|
@@ -10116,7 +9939,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
|
|
|
10116
9939
|
/* @__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: [
|
|
10117
9940
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
10118
9941
|
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Items" }) }),
|
|
10119
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order
|
|
9942
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order" }) })
|
|
10120
9943
|
] }),
|
|
10121
9944
|
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10122
9945
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
@@ -10157,13 +9980,13 @@ const ItemsForm = ({ preview, currencyCode }) => {
|
|
|
10157
9980
|
] })
|
|
10158
9981
|
] }),
|
|
10159
9982
|
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
10160
|
-
/* @__PURE__ */ jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[
|
|
9983
|
+
/* @__PURE__ */ jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-muted grid grid-cols-[2fr_1fr_2fr_28px] gap-3 px-4 py-2", children: [
|
|
10161
9984
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
10162
9985
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) }),
|
|
10163
9986
|
/* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Price" }) }),
|
|
10164
9987
|
/* @__PURE__ */ jsx("div", {})
|
|
10165
9988
|
] }) }),
|
|
10166
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3
|
|
9989
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__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: [
|
|
10167
9990
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "There are no items in this order" }),
|
|
10168
9991
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add items to the order to get started." })
|
|
10169
9992
|
] }) : matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsx(
|
|
@@ -10174,7 +9997,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
|
|
|
10174
9997
|
currencyCode
|
|
10175
9998
|
},
|
|
10176
9999
|
item.id
|
|
10177
|
-
)) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3
|
|
10000
|
+
)) : /* @__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: [
|
|
10178
10001
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
10179
10002
|
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
10180
10003
|
'No items found for "',
|
|
@@ -10213,7 +10036,7 @@ const ItemsForm = ({ preview, currencyCode }) => {
|
|
|
10213
10036
|
]
|
|
10214
10037
|
}
|
|
10215
10038
|
) }),
|
|
10216
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2
|
|
10039
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10217
10040
|
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10218
10041
|
/* @__PURE__ */ jsx(
|
|
10219
10042
|
Button,
|
|
@@ -10289,8 +10112,8 @@ const VariantItem = ({ item, preview, currencyCode }) => {
|
|
|
10289
10112
|
}
|
|
10290
10113
|
);
|
|
10291
10114
|
});
|
|
10292
|
-
return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[minmax(0,
|
|
10293
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3
|
|
10115
|
+
return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
|
|
10116
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-x-3", children: [
|
|
10294
10117
|
/* @__PURE__ */ jsx(
|
|
10295
10118
|
Thumbnail,
|
|
10296
10119
|
{
|
|
@@ -10326,7 +10149,7 @@ const VariantItem = ({ item, preview, currencyCode }) => {
|
|
|
10326
10149
|
)
|
|
10327
10150
|
] })
|
|
10328
10151
|
] }),
|
|
10329
|
-
editing ? /* @__PURE__ */ jsx("div", { className: "flex-1
|
|
10152
|
+
editing ? /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(
|
|
10330
10153
|
Form$2.Field,
|
|
10331
10154
|
{
|
|
10332
10155
|
control: form.control,
|
|
@@ -10335,8 +10158,8 @@ const VariantItem = ({ item, preview, currencyCode }) => {
|
|
|
10335
10158
|
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(NumberInput, { ...field }) }) });
|
|
10336
10159
|
}
|
|
10337
10160
|
}
|
|
10338
|
-
) }) : /* @__PURE__ */ jsx("div", { className: "flex-1
|
|
10339
|
-
editing ? /* @__PURE__ */ jsx("div", { className: "flex-1
|
|
10161
|
+
) }) : /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: item.quantity }) }),
|
|
10162
|
+
editing ? /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(
|
|
10340
10163
|
Form$2.Field,
|
|
10341
10164
|
{
|
|
10342
10165
|
control: form.control,
|
|
@@ -10353,7 +10176,7 @@ const VariantItem = ({ item, preview, currencyCode }) => {
|
|
|
10353
10176
|
) }) });
|
|
10354
10177
|
}
|
|
10355
10178
|
}
|
|
10356
|
-
) }) : /* @__PURE__ */ jsx("div", { className: "flex-
|
|
10179
|
+
) }) : /* @__PURE__ */ jsx("div", { className: "flex w-full flex-1 items-center justify-end", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
10357
10180
|
/* @__PURE__ */ jsx(
|
|
10358
10181
|
IconButton,
|
|
10359
10182
|
{
|
|
@@ -10448,7 +10271,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
|
|
|
10448
10271
|
}
|
|
10449
10272
|
);
|
|
10450
10273
|
});
|
|
10451
|
-
return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[minmax(0,
|
|
10274
|
+
return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit, children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
|
|
10452
10275
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
10453
10276
|
/* @__PURE__ */ jsx(
|
|
10454
10277
|
Thumbnail,
|
|
@@ -10495,7 +10318,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
|
|
|
10495
10318
|
) }) });
|
|
10496
10319
|
}
|
|
10497
10320
|
}
|
|
10498
|
-
) : /* @__PURE__ */ jsx("div", { className: "flex-1
|
|
10321
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-end", children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
10499
10322
|
/* @__PURE__ */ jsx(
|
|
10500
10323
|
IconButton,
|
|
10501
10324
|
{
|
|
@@ -10620,7 +10443,7 @@ const ExistingItemsForm = ({ orderId, items }) => {
|
|
|
10620
10443
|
autoFocusSearch: true
|
|
10621
10444
|
}
|
|
10622
10445
|
) }),
|
|
10623
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2
|
|
10446
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10624
10447
|
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10625
10448
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Update items" })
|
|
10626
10449
|
] }) })
|
|
@@ -10788,15 +10611,15 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
|
10788
10611
|
/* @__PURE__ */ jsx(Form$2.Label, { children: "Quantity" }),
|
|
10789
10612
|
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
10790
10613
|
] }),
|
|
10791
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1
|
|
10792
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "flex-1
|
|
10614
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full flex-1", children: [
|
|
10615
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
10793
10616
|
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10794
10617
|
] })
|
|
10795
10618
|
] }) })
|
|
10796
10619
|
}
|
|
10797
10620
|
)
|
|
10798
10621
|
] }) }) }),
|
|
10799
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2
|
|
10622
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10800
10623
|
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10801
10624
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
10802
10625
|
] }) })
|
|
@@ -11201,22 +11024,22 @@ const PromotionForm = ({ preview }) => {
|
|
|
11201
11024
|
const [comboboxValue, setComboboxValue] = useState("");
|
|
11202
11025
|
const { handleSuccess } = useRouteModal();
|
|
11203
11026
|
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11204
|
-
const
|
|
11027
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11205
11028
|
const { promotions, isPending, isError, error } = usePromotions(
|
|
11206
11029
|
{
|
|
11207
|
-
|
|
11030
|
+
id: promoIds
|
|
11208
11031
|
},
|
|
11209
11032
|
{
|
|
11210
|
-
enabled: !!
|
|
11033
|
+
enabled: !!promoIds.length
|
|
11211
11034
|
}
|
|
11212
11035
|
);
|
|
11213
11036
|
const comboboxData = useComboboxData({
|
|
11214
|
-
queryKey: ["promotions", "combobox",
|
|
11037
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
11215
11038
|
queryFn: async (params) => {
|
|
11216
11039
|
return await sdk.admin.promotion.list({
|
|
11217
11040
|
...params,
|
|
11218
|
-
|
|
11219
|
-
$nin:
|
|
11041
|
+
id: {
|
|
11042
|
+
$nin: promoIds
|
|
11220
11043
|
}
|
|
11221
11044
|
});
|
|
11222
11045
|
},
|
|
@@ -11352,7 +11175,7 @@ const PromotionItem = ({
|
|
|
11352
11175
|
"div",
|
|
11353
11176
|
{
|
|
11354
11177
|
className: clx(
|
|
11355
|
-
"
|
|
11178
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11356
11179
|
{
|
|
11357
11180
|
"animate-pulse": isLoading
|
|
11358
11181
|
}
|
|
@@ -11360,7 +11183,7 @@ const PromotionItem = ({
|
|
|
11360
11183
|
children: [
|
|
11361
11184
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
11362
11185
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11363
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5
|
|
11186
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11364
11187
|
displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11365
11188
|
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11366
11189
|
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
|
|
@@ -11412,13 +11235,13 @@ const formatPercentage = (value, isPercentageValue = false) => {
|
|
|
11412
11235
|
}
|
|
11413
11236
|
return formatter.format(val);
|
|
11414
11237
|
};
|
|
11415
|
-
function
|
|
11416
|
-
const
|
|
11238
|
+
function getPromotionIds(items, shippingMethods) {
|
|
11239
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
11417
11240
|
for (const item of items) {
|
|
11418
11241
|
if (item.adjustments) {
|
|
11419
11242
|
for (const adjustment of item.adjustments) {
|
|
11420
|
-
if (adjustment.
|
|
11421
|
-
|
|
11243
|
+
if (adjustment.promotion_id) {
|
|
11244
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11422
11245
|
}
|
|
11423
11246
|
}
|
|
11424
11247
|
}
|
|
@@ -11426,13 +11249,13 @@ function getPromotionCodes(items, shippingMethods) {
|
|
|
11426
11249
|
for (const shippingMethod of shippingMethods) {
|
|
11427
11250
|
if (shippingMethod.adjustments) {
|
|
11428
11251
|
for (const adjustment of shippingMethod.adjustments) {
|
|
11429
|
-
if (adjustment.
|
|
11430
|
-
|
|
11252
|
+
if (adjustment.promotion_id) {
|
|
11253
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11431
11254
|
}
|
|
11432
11255
|
}
|
|
11433
11256
|
}
|
|
11434
11257
|
}
|
|
11435
|
-
return Array.from(
|
|
11258
|
+
return Array.from(promotionIds);
|
|
11436
11259
|
}
|
|
11437
11260
|
const SalesChannel = () => {
|
|
11438
11261
|
const { id } = useParams();
|
|
@@ -11462,7 +11285,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11462
11285
|
defaultValues: {
|
|
11463
11286
|
sales_channel_id: order.sales_channel_id || ""
|
|
11464
11287
|
},
|
|
11465
|
-
resolver: zodResolver(schema$
|
|
11288
|
+
resolver: zodResolver(schema$3)
|
|
11466
11289
|
});
|
|
11467
11290
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11468
11291
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11537,7 +11360,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11537
11360
|
}
|
|
11538
11361
|
);
|
|
11539
11362
|
};
|
|
11540
|
-
const schema$
|
|
11363
|
+
const schema$3 = objectType({
|
|
11541
11364
|
sales_channel_id: stringType().min(1)
|
|
11542
11365
|
});
|
|
11543
11366
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -12379,7 +12202,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12379
12202
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12380
12203
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12381
12204
|
},
|
|
12382
|
-
resolver: zodResolver(schema$
|
|
12205
|
+
resolver: zodResolver(schema$2)
|
|
12383
12206
|
});
|
|
12384
12207
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12385
12208
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12549,7 +12372,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12549
12372
|
}
|
|
12550
12373
|
) });
|
|
12551
12374
|
};
|
|
12552
|
-
const schema$
|
|
12375
|
+
const schema$2 = addressSchema;
|
|
12553
12376
|
const TransferOwnership = () => {
|
|
12554
12377
|
const { id } = useParams();
|
|
12555
12378
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12573,7 +12396,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12573
12396
|
defaultValues: {
|
|
12574
12397
|
customer_id: order.customer_id || ""
|
|
12575
12398
|
},
|
|
12576
|
-
resolver: zodResolver(schema)
|
|
12399
|
+
resolver: zodResolver(schema$1)
|
|
12577
12400
|
});
|
|
12578
12401
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12579
12402
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13023,9 +12846,199 @@ const Illustration = () => {
|
|
|
13023
12846
|
}
|
|
13024
12847
|
);
|
|
13025
12848
|
};
|
|
13026
|
-
const schema = objectType({
|
|
12849
|
+
const schema$1 = objectType({
|
|
13027
12850
|
customer_id: stringType().min(1)
|
|
13028
12851
|
});
|
|
12852
|
+
const BillingAddress = () => {
|
|
12853
|
+
const { id } = useParams();
|
|
12854
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12855
|
+
fields: "+billing_address"
|
|
12856
|
+
});
|
|
12857
|
+
if (isError) {
|
|
12858
|
+
throw error;
|
|
12859
|
+
}
|
|
12860
|
+
const isReady = !isPending && !!order;
|
|
12861
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12862
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12863
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12864
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12865
|
+
] }),
|
|
12866
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12867
|
+
] });
|
|
12868
|
+
};
|
|
12869
|
+
const BillingAddressForm = ({ order }) => {
|
|
12870
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12871
|
+
const form = useForm({
|
|
12872
|
+
defaultValues: {
|
|
12873
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12874
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12875
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12876
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12877
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12878
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12879
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12880
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12881
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12882
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12883
|
+
},
|
|
12884
|
+
resolver: zodResolver(schema)
|
|
12885
|
+
});
|
|
12886
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12887
|
+
const { handleSuccess } = useRouteModal();
|
|
12888
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12889
|
+
await mutateAsync(
|
|
12890
|
+
{ billing_address: data },
|
|
12891
|
+
{
|
|
12892
|
+
onSuccess: () => {
|
|
12893
|
+
handleSuccess();
|
|
12894
|
+
},
|
|
12895
|
+
onError: (error) => {
|
|
12896
|
+
toast.error(error.message);
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
);
|
|
12900
|
+
});
|
|
12901
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12902
|
+
KeyboundForm,
|
|
12903
|
+
{
|
|
12904
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12905
|
+
onSubmit,
|
|
12906
|
+
children: [
|
|
12907
|
+
/* @__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: [
|
|
12908
|
+
/* @__PURE__ */ jsx(
|
|
12909
|
+
Form$2.Field,
|
|
12910
|
+
{
|
|
12911
|
+
control: form.control,
|
|
12912
|
+
name: "country_code",
|
|
12913
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12915
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12916
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12917
|
+
] })
|
|
12918
|
+
}
|
|
12919
|
+
),
|
|
12920
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12921
|
+
/* @__PURE__ */ jsx(
|
|
12922
|
+
Form$2.Field,
|
|
12923
|
+
{
|
|
12924
|
+
control: form.control,
|
|
12925
|
+
name: "first_name",
|
|
12926
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12928
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12929
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12930
|
+
] })
|
|
12931
|
+
}
|
|
12932
|
+
),
|
|
12933
|
+
/* @__PURE__ */ jsx(
|
|
12934
|
+
Form$2.Field,
|
|
12935
|
+
{
|
|
12936
|
+
control: form.control,
|
|
12937
|
+
name: "last_name",
|
|
12938
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12940
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12941
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12942
|
+
] })
|
|
12943
|
+
}
|
|
12944
|
+
)
|
|
12945
|
+
] }),
|
|
12946
|
+
/* @__PURE__ */ jsx(
|
|
12947
|
+
Form$2.Field,
|
|
12948
|
+
{
|
|
12949
|
+
control: form.control,
|
|
12950
|
+
name: "company",
|
|
12951
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12953
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12955
|
+
] })
|
|
12956
|
+
}
|
|
12957
|
+
),
|
|
12958
|
+
/* @__PURE__ */ jsx(
|
|
12959
|
+
Form$2.Field,
|
|
12960
|
+
{
|
|
12961
|
+
control: form.control,
|
|
12962
|
+
name: "address_1",
|
|
12963
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12965
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12966
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12967
|
+
] })
|
|
12968
|
+
}
|
|
12969
|
+
),
|
|
12970
|
+
/* @__PURE__ */ jsx(
|
|
12971
|
+
Form$2.Field,
|
|
12972
|
+
{
|
|
12973
|
+
control: form.control,
|
|
12974
|
+
name: "address_2",
|
|
12975
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12977
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12978
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12979
|
+
] })
|
|
12980
|
+
}
|
|
12981
|
+
),
|
|
12982
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12983
|
+
/* @__PURE__ */ jsx(
|
|
12984
|
+
Form$2.Field,
|
|
12985
|
+
{
|
|
12986
|
+
control: form.control,
|
|
12987
|
+
name: "postal_code",
|
|
12988
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12990
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12992
|
+
] })
|
|
12993
|
+
}
|
|
12994
|
+
),
|
|
12995
|
+
/* @__PURE__ */ jsx(
|
|
12996
|
+
Form$2.Field,
|
|
12997
|
+
{
|
|
12998
|
+
control: form.control,
|
|
12999
|
+
name: "city",
|
|
13000
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13002
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13003
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13004
|
+
] })
|
|
13005
|
+
}
|
|
13006
|
+
)
|
|
13007
|
+
] }),
|
|
13008
|
+
/* @__PURE__ */ jsx(
|
|
13009
|
+
Form$2.Field,
|
|
13010
|
+
{
|
|
13011
|
+
control: form.control,
|
|
13012
|
+
name: "province",
|
|
13013
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13015
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13016
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13017
|
+
] })
|
|
13018
|
+
}
|
|
13019
|
+
),
|
|
13020
|
+
/* @__PURE__ */ jsx(
|
|
13021
|
+
Form$2.Field,
|
|
13022
|
+
{
|
|
13023
|
+
control: form.control,
|
|
13024
|
+
name: "phone",
|
|
13025
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13027
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13028
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13029
|
+
] })
|
|
13030
|
+
}
|
|
13031
|
+
)
|
|
13032
|
+
] }) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13034
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13035
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13036
|
+
] }) })
|
|
13037
|
+
]
|
|
13038
|
+
}
|
|
13039
|
+
) });
|
|
13040
|
+
};
|
|
13041
|
+
const schema = addressSchema;
|
|
13029
13042
|
const widgetModule = { widgets: [] };
|
|
13030
13043
|
const routeModule = {
|
|
13031
13044
|
routes: [
|
|
@@ -13046,10 +13059,6 @@ const routeModule = {
|
|
|
13046
13059
|
handle,
|
|
13047
13060
|
loader,
|
|
13048
13061
|
children: [
|
|
13049
|
-
{
|
|
13050
|
-
Component: BillingAddress,
|
|
13051
|
-
path: "/draft-orders/:id/billing-address"
|
|
13052
|
-
},
|
|
13053
13062
|
{
|
|
13054
13063
|
Component: CustomItems,
|
|
13055
13064
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13085,6 +13094,10 @@ const routeModule = {
|
|
|
13085
13094
|
{
|
|
13086
13095
|
Component: TransferOwnership,
|
|
13087
13096
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
|
+
},
|
|
13098
|
+
{
|
|
13099
|
+
Component: BillingAddress,
|
|
13100
|
+
path: "/draft-orders/:id/billing-address"
|
|
13088
13101
|
}
|
|
13089
13102
|
]
|
|
13090
13103
|
}
|