@medusajs/draft-order 0.0.13-preview.1 → 0.0.13
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 +1435 -1434
- package/.medusa/server/src/admin/index.mjs +1435 -1434
- package/package.json +1 -1
|
@@ -9402,6 +9402,7 @@ const Total = ({
|
|
|
9402
9402
|
itemSubTotal,
|
|
9403
9403
|
itemCount
|
|
9404
9404
|
}) => {
|
|
9405
|
+
var _a;
|
|
9405
9406
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-6 py-4 gap-y-2", children: [
|
|
9406
9407
|
itemCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 items-center justify-between gap-x-4 text-ui-fg-subtle", children: [
|
|
9407
9408
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "Subtotal" }),
|
|
@@ -9423,7 +9424,7 @@ const Total = ({
|
|
|
9423
9424
|
),
|
|
9424
9425
|
children: [
|
|
9425
9426
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "Discount" }),
|
|
9426
|
-
promotions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { to: `/promotions/${promotions[0].id}`, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: promotions.map((p) => p.code).join(", ") }) }) }),
|
|
9427
|
+
(promotions == null ? void 0 : promotions.length) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { to: `/promotions/${(_a = promotions == null ? void 0 : promotions[0]) == null ? void 0 : _a.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: promotions.map((p) => p.code).join(", ") }) }) }),
|
|
9427
9428
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: getLocaleAmount(discountTotal, currencyCode) }) })
|
|
9428
9429
|
]
|
|
9429
9430
|
}
|
|
@@ -9548,95 +9549,6 @@ const ID = () => {
|
|
|
9548
9549
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9549
9550
|
] });
|
|
9550
9551
|
};
|
|
9551
|
-
const CustomItems = () => {
|
|
9552
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9553
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9554
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9555
|
-
] });
|
|
9556
|
-
};
|
|
9557
|
-
const CustomItemsForm = () => {
|
|
9558
|
-
const form = reactHookForm.useForm({
|
|
9559
|
-
resolver: zod.zodResolver(schema$5)
|
|
9560
|
-
});
|
|
9561
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9562
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9563
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9564
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9565
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9566
|
-
] }) })
|
|
9567
|
-
] }) });
|
|
9568
|
-
};
|
|
9569
|
-
const schema$5 = objectType({
|
|
9570
|
-
email: stringType().email()
|
|
9571
|
-
});
|
|
9572
|
-
const Email = () => {
|
|
9573
|
-
const { id } = reactRouterDom.useParams();
|
|
9574
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9575
|
-
fields: "+email"
|
|
9576
|
-
});
|
|
9577
|
-
if (isError) {
|
|
9578
|
-
throw error;
|
|
9579
|
-
}
|
|
9580
|
-
const isReady = !isPending && !!order;
|
|
9581
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9582
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9583
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9584
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9585
|
-
] }),
|
|
9586
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9587
|
-
] });
|
|
9588
|
-
};
|
|
9589
|
-
const EmailForm = ({ order }) => {
|
|
9590
|
-
const form = reactHookForm.useForm({
|
|
9591
|
-
defaultValues: {
|
|
9592
|
-
email: order.email ?? ""
|
|
9593
|
-
},
|
|
9594
|
-
resolver: zod.zodResolver(schema$4)
|
|
9595
|
-
});
|
|
9596
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9597
|
-
const { handleSuccess } = useRouteModal();
|
|
9598
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9599
|
-
await mutateAsync(
|
|
9600
|
-
{ email: data.email },
|
|
9601
|
-
{
|
|
9602
|
-
onSuccess: () => {
|
|
9603
|
-
handleSuccess();
|
|
9604
|
-
},
|
|
9605
|
-
onError: (error) => {
|
|
9606
|
-
ui.toast.error(error.message);
|
|
9607
|
-
}
|
|
9608
|
-
}
|
|
9609
|
-
);
|
|
9610
|
-
});
|
|
9611
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9612
|
-
KeyboundForm,
|
|
9613
|
-
{
|
|
9614
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9615
|
-
onSubmit,
|
|
9616
|
-
children: [
|
|
9617
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9618
|
-
Form$2.Field,
|
|
9619
|
-
{
|
|
9620
|
-
control: form.control,
|
|
9621
|
-
name: "email",
|
|
9622
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9623
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9624
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9625
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9626
|
-
] })
|
|
9627
|
-
}
|
|
9628
|
-
) }),
|
|
9629
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9630
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9631
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9632
|
-
] }) })
|
|
9633
|
-
]
|
|
9634
|
-
}
|
|
9635
|
-
) });
|
|
9636
|
-
};
|
|
9637
|
-
const schema$4 = objectType({
|
|
9638
|
-
email: stringType().email()
|
|
9639
|
-
});
|
|
9640
9552
|
const BillingAddress = () => {
|
|
9641
9553
|
const { id } = reactRouterDom.useParams();
|
|
9642
9554
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9669,7 +9581,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9669
9581
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9670
9582
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9671
9583
|
},
|
|
9672
|
-
resolver: zod.zodResolver(schema$
|
|
9584
|
+
resolver: zod.zodResolver(schema$5)
|
|
9673
9585
|
});
|
|
9674
9586
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9675
9587
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9826,7 +9738,28 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9826
9738
|
}
|
|
9827
9739
|
) });
|
|
9828
9740
|
};
|
|
9829
|
-
const schema$
|
|
9741
|
+
const schema$5 = addressSchema;
|
|
9742
|
+
const CustomItems = () => {
|
|
9743
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9744
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9745
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9746
|
+
] });
|
|
9747
|
+
};
|
|
9748
|
+
const CustomItemsForm = () => {
|
|
9749
|
+
const form = reactHookForm.useForm({
|
|
9750
|
+
resolver: zod.zodResolver(schema$4)
|
|
9751
|
+
});
|
|
9752
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9753
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9754
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9755
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9756
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9757
|
+
] }) })
|
|
9758
|
+
] }) });
|
|
9759
|
+
};
|
|
9760
|
+
const schema$4 = objectType({
|
|
9761
|
+
email: stringType().email()
|
|
9762
|
+
});
|
|
9830
9763
|
const InlineTip = React.forwardRef(
|
|
9831
9764
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
9832
9765
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -10528,7 +10461,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
10528
10461
|
defaultValues: {
|
|
10529
10462
|
sales_channel_id: order.sales_channel_id || ""
|
|
10530
10463
|
},
|
|
10531
|
-
resolver: zod.zodResolver(schema$
|
|
10464
|
+
resolver: zod.zodResolver(schema$3)
|
|
10532
10465
|
});
|
|
10533
10466
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10534
10467
|
const { handleSuccess } = useRouteModal();
|
|
@@ -10603,7 +10536,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
10603
10536
|
}
|
|
10604
10537
|
);
|
|
10605
10538
|
};
|
|
10606
|
-
const schema$
|
|
10539
|
+
const schema$3 = objectType({
|
|
10607
10540
|
sales_channel_id: stringType().min(1)
|
|
10608
10541
|
});
|
|
10609
10542
|
function convertNumber(value) {
|
|
@@ -11448,7 +11381,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11448
11381
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11449
11382
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11450
11383
|
},
|
|
11451
|
-
resolver: zod.zodResolver(schema$
|
|
11384
|
+
resolver: zod.zodResolver(schema$2)
|
|
11452
11385
|
});
|
|
11453
11386
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11454
11387
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11618,1407 +11551,1475 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11618
11551
|
}
|
|
11619
11552
|
) });
|
|
11620
11553
|
};
|
|
11621
|
-
const schema$
|
|
11622
|
-
const
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
};
|
|
11639
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
11640
|
-
var _a, _b;
|
|
11641
|
-
const form = reactHookForm.useForm({
|
|
11642
|
-
defaultValues: {
|
|
11643
|
-
customer_id: order.customer_id || ""
|
|
11644
|
-
},
|
|
11645
|
-
resolver: zod.zodResolver(schema)
|
|
11646
|
-
});
|
|
11647
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11648
|
-
const { handleSuccess } = useRouteModal();
|
|
11649
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
11650
|
-
const currentCustomer = order.customer ? {
|
|
11651
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
11652
|
-
value: order.customer.id
|
|
11653
|
-
} : null;
|
|
11654
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11655
|
-
await mutateAsync(
|
|
11656
|
-
{ customer_id: data.customer_id },
|
|
11657
|
-
{
|
|
11658
|
-
onSuccess: () => {
|
|
11659
|
-
ui.toast.success("Customer updated");
|
|
11660
|
-
handleSuccess();
|
|
11661
|
-
},
|
|
11662
|
-
onError: (error) => {
|
|
11663
|
-
ui.toast.error(error.message);
|
|
11664
|
-
}
|
|
11554
|
+
const schema$2 = addressSchema;
|
|
11555
|
+
const NumberInput = React.forwardRef(
|
|
11556
|
+
({
|
|
11557
|
+
value,
|
|
11558
|
+
onChange,
|
|
11559
|
+
size = "base",
|
|
11560
|
+
min = 0,
|
|
11561
|
+
max = 100,
|
|
11562
|
+
step = 1,
|
|
11563
|
+
className,
|
|
11564
|
+
disabled,
|
|
11565
|
+
...props
|
|
11566
|
+
}, ref) => {
|
|
11567
|
+
const handleChange = (event) => {
|
|
11568
|
+
const newValue = event.target.value === "" ? min : Number(event.target.value);
|
|
11569
|
+
if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
|
|
11570
|
+
onChange(newValue);
|
|
11665
11571
|
}
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11572
|
+
};
|
|
11573
|
+
const handleIncrement = () => {
|
|
11574
|
+
const newValue = value + step;
|
|
11575
|
+
if (max === void 0 || newValue <= max) {
|
|
11576
|
+
onChange(newValue);
|
|
11577
|
+
}
|
|
11578
|
+
};
|
|
11579
|
+
const handleDecrement = () => {
|
|
11580
|
+
const newValue = value - step;
|
|
11581
|
+
if (min === void 0 || newValue >= min) {
|
|
11582
|
+
onChange(newValue);
|
|
11583
|
+
}
|
|
11584
|
+
};
|
|
11585
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11586
|
+
"div",
|
|
11587
|
+
{
|
|
11588
|
+
className: ui.clx(
|
|
11589
|
+
"inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
|
|
11590
|
+
"[&:has(input:focus)]:shadow-borders-interactive-with-active",
|
|
11591
|
+
{
|
|
11592
|
+
"h-7": size === "small",
|
|
11593
|
+
"h-8": size === "base"
|
|
11594
|
+
},
|
|
11595
|
+
className
|
|
11596
|
+
),
|
|
11597
|
+
children: [
|
|
11686
11598
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11687
|
-
|
|
11599
|
+
"input",
|
|
11688
11600
|
{
|
|
11689
|
-
|
|
11690
|
-
|
|
11601
|
+
ref,
|
|
11602
|
+
type: "number",
|
|
11603
|
+
value,
|
|
11604
|
+
onChange: handleChange,
|
|
11605
|
+
min,
|
|
11606
|
+
max,
|
|
11607
|
+
step,
|
|
11608
|
+
className: ui.clx(
|
|
11609
|
+
"flex-1 px-2 py-1 bg-transparent txt-compact-small text-ui-fg-base outline-none [appearance:textfield]",
|
|
11610
|
+
"[&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
|
|
11611
|
+
"placeholder:text-ui-fg-muted"
|
|
11612
|
+
),
|
|
11613
|
+
...props
|
|
11691
11614
|
}
|
|
11692
|
-
)
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11615
|
+
),
|
|
11616
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11617
|
+
"button",
|
|
11618
|
+
{
|
|
11619
|
+
className: ui.clx(
|
|
11620
|
+
"flex items-center justify-center outline-none transition-fg",
|
|
11621
|
+
"disabled:cursor-not-allowed disabled:text-ui-fg-muted",
|
|
11622
|
+
"focus:bg-ui-bg-field-component-hover",
|
|
11623
|
+
"hover:bg-ui-bg-field-component-hover",
|
|
11624
|
+
{
|
|
11625
|
+
"size-7": size === "small",
|
|
11626
|
+
"size-8": size === "base"
|
|
11627
|
+
}
|
|
11628
|
+
),
|
|
11629
|
+
type: "button",
|
|
11630
|
+
onClick: handleDecrement,
|
|
11631
|
+
disabled: min !== void 0 && value <= min || disabled,
|
|
11632
|
+
children: [
|
|
11633
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Minus, {}),
|
|
11634
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: `Decrease by ${step}` })
|
|
11635
|
+
]
|
|
11636
|
+
}
|
|
11637
|
+
),
|
|
11638
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11639
|
+
"button",
|
|
11640
|
+
{
|
|
11641
|
+
className: ui.clx(
|
|
11642
|
+
"flex items-center justify-center outline-none transition-fg",
|
|
11643
|
+
"disabled:cursor-not-allowed disabled:text-ui-fg-muted",
|
|
11644
|
+
"focus:bg-ui-bg-field-hover",
|
|
11645
|
+
"hover:bg-ui-bg-field-hover",
|
|
11646
|
+
{
|
|
11647
|
+
"size-7": size === "small",
|
|
11648
|
+
"size-8": size === "base"
|
|
11649
|
+
}
|
|
11650
|
+
),
|
|
11651
|
+
type: "button",
|
|
11652
|
+
onClick: handleIncrement,
|
|
11653
|
+
disabled: max !== void 0 && value >= max || disabled,
|
|
11654
|
+
children: [
|
|
11655
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
11656
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: `Increase by ${step}` })
|
|
11657
|
+
]
|
|
11658
|
+
}
|
|
11659
|
+
)
|
|
11660
|
+
]
|
|
11661
|
+
}
|
|
11662
|
+
);
|
|
11663
|
+
}
|
|
11664
|
+
);
|
|
11665
|
+
const PRODUCT_VARIANTS_QUERY_KEY = "product-variants";
|
|
11666
|
+
const productVariantsQueryKeys = {
|
|
11667
|
+
list: (query2) => [
|
|
11668
|
+
PRODUCT_VARIANTS_QUERY_KEY,
|
|
11669
|
+
query2 ? query2 : void 0
|
|
11670
|
+
]
|
|
11671
|
+
};
|
|
11672
|
+
const useProductVariants = (query2, options) => {
|
|
11673
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
11674
|
+
queryKey: productVariantsQueryKeys.list(query2),
|
|
11675
|
+
queryFn: async () => await sdk.admin.productVariant.list(query2),
|
|
11676
|
+
...options
|
|
11720
11677
|
});
|
|
11721
|
-
return
|
|
11722
|
-
|
|
11678
|
+
return { ...data, ...rest };
|
|
11679
|
+
};
|
|
11680
|
+
const STACKED_MODAL_ID = "items_stacked_modal";
|
|
11681
|
+
const Items = () => {
|
|
11682
|
+
const { id } = reactRouterDom.useParams();
|
|
11683
|
+
const {
|
|
11684
|
+
order: preview,
|
|
11685
|
+
isPending: isPreviewPending,
|
|
11686
|
+
isError: isPreviewError,
|
|
11687
|
+
error: previewError
|
|
11688
|
+
} = useOrderPreview(id, void 0, {
|
|
11689
|
+
placeholderData: reactQuery.keepPreviousData
|
|
11690
|
+
});
|
|
11691
|
+
useInitiateOrderEdit({ preview });
|
|
11692
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11693
|
+
id,
|
|
11723
11694
|
{
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
11729
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
11730
|
-
] }),
|
|
11731
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11732
|
-
Combobox,
|
|
11733
|
-
{
|
|
11734
|
-
options: customers.options,
|
|
11735
|
-
fetchNextPage: customers.fetchNextPage,
|
|
11736
|
-
isFetchingNextPage: customers.isFetchingNextPage,
|
|
11737
|
-
searchValue: customers.searchValue,
|
|
11738
|
-
onSearchValueChange: customers.onSearchValueChange,
|
|
11739
|
-
placeholder: "Select customer",
|
|
11740
|
-
...field
|
|
11741
|
-
}
|
|
11742
|
-
) }),
|
|
11743
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11744
|
-
] })
|
|
11695
|
+
fields: "currency_code"
|
|
11696
|
+
},
|
|
11697
|
+
{
|
|
11698
|
+
enabled: !!id
|
|
11745
11699
|
}
|
|
11746
11700
|
);
|
|
11701
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11702
|
+
if (isError) {
|
|
11703
|
+
throw error;
|
|
11704
|
+
}
|
|
11705
|
+
if (isPreviewError) {
|
|
11706
|
+
throw previewError;
|
|
11707
|
+
}
|
|
11708
|
+
const ready = !!preview && !isPreviewPending && !!draft_order && !isPending;
|
|
11709
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: ready ? /* @__PURE__ */ jsxRuntime.jsx(ItemsForm, { preview, currencyCode: draft_order.currency_code }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11710
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Items" }) }),
|
|
11711
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11712
|
+
] }) });
|
|
11747
11713
|
};
|
|
11748
|
-
const
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11714
|
+
const ItemsForm = ({ preview, currencyCode }) => {
|
|
11715
|
+
var _a;
|
|
11716
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11717
|
+
const [modalContent, setModalContent] = React.useState(
|
|
11718
|
+
null
|
|
11719
|
+
);
|
|
11720
|
+
const { handleSuccess } = useRouteModal();
|
|
11721
|
+
const { searchValue, onSearchValueChange, query: query2 } = useDebouncedSearch();
|
|
11722
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11723
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11724
|
+
const itemCount = ((_a = preview.items) == null ? void 0 : _a.reduce((acc, item) => acc + item.quantity, 0)) || 0;
|
|
11725
|
+
const matches = React.useMemo(() => {
|
|
11726
|
+
return matchSorter.matchSorter(preview.items, query2, {
|
|
11727
|
+
keys: ["product_title", "variant_title", "variant_sku", "title"]
|
|
11728
|
+
});
|
|
11729
|
+
}, [preview.items, query2]);
|
|
11730
|
+
const onSubmit = async () => {
|
|
11731
|
+
setIsSubmitting(true);
|
|
11732
|
+
let requestSucceeded = false;
|
|
11733
|
+
await requestOrderEdit(void 0, {
|
|
11734
|
+
onError: (e) => {
|
|
11735
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11736
|
+
},
|
|
11737
|
+
onSuccess: () => {
|
|
11738
|
+
requestSucceeded = true;
|
|
11739
|
+
}
|
|
11740
|
+
});
|
|
11741
|
+
if (!requestSucceeded) {
|
|
11742
|
+
setIsSubmitting(false);
|
|
11743
|
+
return;
|
|
11744
|
+
}
|
|
11745
|
+
await confirmOrderEdit(void 0, {
|
|
11746
|
+
onError: (e) => {
|
|
11747
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11748
|
+
},
|
|
11749
|
+
onSuccess: () => {
|
|
11750
|
+
handleSuccess();
|
|
11751
|
+
},
|
|
11752
|
+
onSettled: () => {
|
|
11753
|
+
setIsSubmitting(false);
|
|
11754
|
+
}
|
|
11755
|
+
});
|
|
11756
|
+
};
|
|
11757
|
+
const onKeyDown = React.useCallback(
|
|
11758
|
+
(e) => {
|
|
11759
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11760
|
+
if (modalContent || isSubmitting) {
|
|
11761
|
+
return;
|
|
11762
|
+
}
|
|
11763
|
+
onSubmit();
|
|
11764
|
+
}
|
|
11765
|
+
},
|
|
11766
|
+
[modalContent, isSubmitting, onSubmit]
|
|
11767
|
+
);
|
|
11768
|
+
React.useEffect(() => {
|
|
11769
|
+
document.addEventListener("keydown", onKeyDown);
|
|
11770
|
+
return () => {
|
|
11771
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
11772
|
+
};
|
|
11773
|
+
}, [onKeyDown]);
|
|
11774
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11775
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11776
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11777
|
+
StackedFocusModal,
|
|
11778
|
+
{
|
|
11779
|
+
id: STACKED_MODAL_ID,
|
|
11780
|
+
onOpenChangeCallback: (open) => {
|
|
11781
|
+
if (!open) {
|
|
11782
|
+
setModalContent(null);
|
|
11805
11783
|
}
|
|
11806
|
-
|
|
11807
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11808
|
-
"path",
|
|
11809
|
-
{
|
|
11810
|
-
opacity: "0.75",
|
|
11811
|
-
d: "M180.551 111.93L179.108 111.096",
|
|
11812
|
-
stroke: "#52525B",
|
|
11813
|
-
strokeWidth: "1.5",
|
|
11814
|
-
strokeLinecap: "round",
|
|
11815
|
-
strokeLinejoin: "round"
|
|
11816
|
-
}
|
|
11817
|
-
),
|
|
11818
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11819
|
-
"path",
|
|
11820
|
-
{
|
|
11821
|
-
opacity: "0.63",
|
|
11822
|
-
d: "M176.347 112.897L176.354 111.73",
|
|
11823
|
-
stroke: "#52525B",
|
|
11824
|
-
strokeWidth: "1.5",
|
|
11825
|
-
strokeLinecap: "round",
|
|
11826
|
-
strokeLinejoin: "round"
|
|
11827
|
-
}
|
|
11828
|
-
),
|
|
11829
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11830
|
-
"path",
|
|
11831
|
-
{
|
|
11832
|
-
opacity: "0.5",
|
|
11833
|
-
d: "M172.153 111.881L173.606 111.064",
|
|
11834
|
-
stroke: "#52525B",
|
|
11835
|
-
strokeWidth: "1.5",
|
|
11836
|
-
strokeLinecap: "round",
|
|
11837
|
-
strokeLinejoin: "round"
|
|
11838
|
-
}
|
|
11839
|
-
),
|
|
11840
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11841
|
-
"path",
|
|
11842
|
-
{
|
|
11843
|
-
opacity: "0.38",
|
|
11844
|
-
d: "M170.428 109.478L172.476 109.489",
|
|
11845
|
-
stroke: "#52525B",
|
|
11846
|
-
strokeWidth: "1.5",
|
|
11847
|
-
strokeLinecap: "round",
|
|
11848
|
-
strokeLinejoin: "round"
|
|
11849
|
-
}
|
|
11850
|
-
),
|
|
11851
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11852
|
-
"path",
|
|
11853
|
-
{
|
|
11854
|
-
opacity: "0.25",
|
|
11855
|
-
d: "M172.181 107.094L173.624 107.928",
|
|
11856
|
-
stroke: "#52525B",
|
|
11857
|
-
strokeWidth: "1.5",
|
|
11858
|
-
strokeLinecap: "round",
|
|
11859
|
-
strokeLinejoin: "round"
|
|
11860
|
-
}
|
|
11861
|
-
),
|
|
11862
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11863
|
-
"path",
|
|
11864
|
-
{
|
|
11865
|
-
opacity: "0.13",
|
|
11866
|
-
d: "M176.386 106.126L176.379 107.294",
|
|
11867
|
-
stroke: "#52525B",
|
|
11868
|
-
strokeWidth: "1.5",
|
|
11869
|
-
strokeLinecap: "round",
|
|
11870
|
-
strokeLinejoin: "round"
|
|
11871
|
-
}
|
|
11872
|
-
),
|
|
11873
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11874
|
-
"rect",
|
|
11875
|
-
{
|
|
11876
|
-
width: "12",
|
|
11877
|
-
height: "3",
|
|
11878
|
-
rx: "1.5",
|
|
11879
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
11880
|
-
fill: "#D4D4D8"
|
|
11881
|
-
}
|
|
11882
|
-
),
|
|
11883
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11884
|
-
"rect",
|
|
11885
|
-
{
|
|
11886
|
-
x: "0.00428286",
|
|
11887
|
-
y: "-0.742904",
|
|
11888
|
-
width: "33.5",
|
|
11889
|
-
height: "65.5",
|
|
11890
|
-
rx: "6.75",
|
|
11891
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
11892
|
-
fill: "#D4D4D8",
|
|
11893
|
-
stroke: "#52525B",
|
|
11894
|
-
strokeWidth: "1.5"
|
|
11895
|
-
}
|
|
11896
|
-
),
|
|
11897
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11898
|
-
"rect",
|
|
11899
|
-
{
|
|
11900
|
-
x: "0.00428286",
|
|
11901
|
-
y: "-0.742904",
|
|
11902
|
-
width: "33.5",
|
|
11903
|
-
height: "65.5",
|
|
11904
|
-
rx: "6.75",
|
|
11905
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
11906
|
-
fill: "white",
|
|
11907
|
-
stroke: "#52525B",
|
|
11908
|
-
strokeWidth: "1.5"
|
|
11909
|
-
}
|
|
11910
|
-
),
|
|
11911
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11912
|
-
"rect",
|
|
11913
|
-
{
|
|
11914
|
-
width: "12",
|
|
11915
|
-
height: "3",
|
|
11916
|
-
rx: "1.5",
|
|
11917
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
11918
|
-
fill: "#D4D4D8"
|
|
11919
|
-
}
|
|
11920
|
-
),
|
|
11921
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11922
|
-
"rect",
|
|
11923
|
-
{
|
|
11924
|
-
width: "17",
|
|
11925
|
-
height: "3",
|
|
11926
|
-
rx: "1.5",
|
|
11927
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
11928
|
-
fill: "#D4D4D8"
|
|
11929
|
-
}
|
|
11930
|
-
),
|
|
11931
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11932
|
-
"rect",
|
|
11933
|
-
{
|
|
11934
|
-
width: "12",
|
|
11935
|
-
height: "3",
|
|
11936
|
-
rx: "1.5",
|
|
11937
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
11938
|
-
fill: "#D4D4D8"
|
|
11939
|
-
}
|
|
11940
|
-
),
|
|
11941
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11942
|
-
"path",
|
|
11943
|
-
{
|
|
11944
|
-
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
11945
|
-
fill: "#A1A1AA"
|
|
11946
|
-
}
|
|
11947
|
-
),
|
|
11948
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11949
|
-
"rect",
|
|
11950
|
-
{
|
|
11951
|
-
width: "17",
|
|
11952
|
-
height: "3",
|
|
11953
|
-
rx: "1.5",
|
|
11954
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
11955
|
-
fill: "#A1A1AA"
|
|
11956
|
-
}
|
|
11957
|
-
),
|
|
11958
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11959
|
-
"rect",
|
|
11960
|
-
{
|
|
11961
|
-
width: "12",
|
|
11962
|
-
height: "3",
|
|
11963
|
-
rx: "1.5",
|
|
11964
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
11965
|
-
fill: "#A1A1AA"
|
|
11966
|
-
}
|
|
11967
|
-
),
|
|
11968
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11969
|
-
"path",
|
|
11970
|
-
{
|
|
11971
|
-
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
11972
|
-
fill: "#52525B"
|
|
11973
|
-
}
|
|
11974
|
-
),
|
|
11975
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11976
|
-
"path",
|
|
11977
|
-
{
|
|
11978
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
11979
|
-
stroke: "#A1A1AA",
|
|
11980
|
-
strokeWidth: "1.5",
|
|
11981
|
-
strokeLinecap: "round",
|
|
11982
|
-
strokeLinejoin: "round"
|
|
11983
|
-
}
|
|
11984
|
-
) }),
|
|
11985
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11986
|
-
"path",
|
|
11987
|
-
{
|
|
11988
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
11989
|
-
stroke: "#A1A1AA",
|
|
11990
|
-
strokeWidth: "1.5",
|
|
11991
|
-
strokeLinecap: "round",
|
|
11992
|
-
strokeLinejoin: "round"
|
|
11993
|
-
}
|
|
11994
|
-
) }),
|
|
11995
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11996
|
-
"path",
|
|
11997
|
-
{
|
|
11998
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
11999
|
-
stroke: "#A1A1AA",
|
|
12000
|
-
strokeWidth: "1.5",
|
|
12001
|
-
strokeLinecap: "round",
|
|
12002
|
-
strokeLinejoin: "round"
|
|
12003
|
-
}
|
|
12004
|
-
) }),
|
|
12005
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12006
|
-
"path",
|
|
12007
|
-
{
|
|
12008
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12009
|
-
stroke: "#A1A1AA",
|
|
12010
|
-
strokeWidth: "1.5",
|
|
12011
|
-
strokeLinecap: "round",
|
|
12012
|
-
strokeLinejoin: "round"
|
|
12013
|
-
}
|
|
12014
|
-
) }),
|
|
12015
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12016
|
-
"path",
|
|
12017
|
-
{
|
|
12018
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12019
|
-
stroke: "#A1A1AA",
|
|
12020
|
-
strokeWidth: "1.5",
|
|
12021
|
-
strokeLinecap: "round",
|
|
12022
|
-
strokeLinejoin: "round"
|
|
12023
|
-
}
|
|
12024
|
-
) }),
|
|
12025
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12026
|
-
"path",
|
|
12027
|
-
{
|
|
12028
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12029
|
-
stroke: "#A1A1AA",
|
|
12030
|
-
strokeWidth: "1.5",
|
|
12031
|
-
strokeLinecap: "round",
|
|
12032
|
-
strokeLinejoin: "round"
|
|
12033
|
-
}
|
|
12034
|
-
) }),
|
|
12035
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12036
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12037
|
-
"rect",
|
|
12038
|
-
{
|
|
12039
|
-
width: "12",
|
|
12040
|
-
height: "12",
|
|
12041
|
-
fill: "white",
|
|
12042
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12043
|
-
}
|
|
12044
|
-
) }),
|
|
12045
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12046
|
-
"rect",
|
|
12047
|
-
{
|
|
12048
|
-
width: "12",
|
|
12049
|
-
height: "12",
|
|
12050
|
-
fill: "white",
|
|
12051
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12052
|
-
}
|
|
12053
|
-
) }),
|
|
12054
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12055
|
-
"rect",
|
|
12056
|
-
{
|
|
12057
|
-
width: "12",
|
|
12058
|
-
height: "12",
|
|
12059
|
-
fill: "white",
|
|
12060
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12061
|
-
}
|
|
12062
|
-
) }),
|
|
12063
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12064
|
-
"rect",
|
|
12065
|
-
{
|
|
12066
|
-
width: "12",
|
|
12067
|
-
height: "12",
|
|
12068
|
-
fill: "white",
|
|
12069
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12070
|
-
}
|
|
12071
|
-
) }),
|
|
12072
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12073
|
-
"rect",
|
|
12074
|
-
{
|
|
12075
|
-
width: "12",
|
|
12076
|
-
height: "12",
|
|
12077
|
-
fill: "white",
|
|
12078
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12079
|
-
}
|
|
12080
|
-
) }),
|
|
12081
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12082
|
-
"rect",
|
|
12083
|
-
{
|
|
12084
|
-
width: "12",
|
|
12085
|
-
height: "12",
|
|
12086
|
-
fill: "white",
|
|
12087
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12088
|
-
}
|
|
12089
|
-
) })
|
|
12090
|
-
] })
|
|
12091
|
-
]
|
|
12092
|
-
}
|
|
12093
|
-
);
|
|
12094
|
-
};
|
|
12095
|
-
const schema = objectType({
|
|
12096
|
-
customer_id: stringType().min(1)
|
|
12097
|
-
});
|
|
12098
|
-
const NumberInput = React.forwardRef(
|
|
12099
|
-
({
|
|
12100
|
-
value,
|
|
12101
|
-
onChange,
|
|
12102
|
-
size = "base",
|
|
12103
|
-
min = 0,
|
|
12104
|
-
max = 100,
|
|
12105
|
-
step = 1,
|
|
12106
|
-
className,
|
|
12107
|
-
disabled,
|
|
12108
|
-
...props
|
|
12109
|
-
}, ref) => {
|
|
12110
|
-
const handleChange = (event) => {
|
|
12111
|
-
const newValue = event.target.value === "" ? min : Number(event.target.value);
|
|
12112
|
-
if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
|
|
12113
|
-
onChange(newValue);
|
|
12114
|
-
}
|
|
12115
|
-
};
|
|
12116
|
-
const handleIncrement = () => {
|
|
12117
|
-
const newValue = value + step;
|
|
12118
|
-
if (max === void 0 || newValue <= max) {
|
|
12119
|
-
onChange(newValue);
|
|
12120
|
-
}
|
|
12121
|
-
};
|
|
12122
|
-
const handleDecrement = () => {
|
|
12123
|
-
const newValue = value - step;
|
|
12124
|
-
if (min === void 0 || newValue >= min) {
|
|
12125
|
-
onChange(newValue);
|
|
12126
|
-
}
|
|
12127
|
-
};
|
|
12128
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12129
|
-
"div",
|
|
12130
|
-
{
|
|
12131
|
-
className: ui.clx(
|
|
12132
|
-
"inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
|
|
12133
|
-
"[&:has(input:focus)]:shadow-borders-interactive-with-active",
|
|
12134
|
-
{
|
|
12135
|
-
"h-7": size === "small",
|
|
12136
|
-
"h-8": size === "base"
|
|
12137
|
-
},
|
|
12138
|
-
className
|
|
12139
|
-
),
|
|
11784
|
+
},
|
|
12140
11785
|
children: [
|
|
12141
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12142
|
-
"
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
"
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
11786
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11787
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11788
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Items" }) }),
|
|
11789
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Edit the items in the draft order." }) })
|
|
11790
|
+
] }),
|
|
11791
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11792
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
11793
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 items-center gap-3", children: [
|
|
11794
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11795
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items" }),
|
|
11796
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose items from the product catalog." })
|
|
11797
|
+
] }),
|
|
11798
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
11799
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11800
|
+
ui.Input,
|
|
11801
|
+
{
|
|
11802
|
+
type: "search",
|
|
11803
|
+
placeholder: "Search items",
|
|
11804
|
+
value: searchValue,
|
|
11805
|
+
onChange: (e) => onSearchValueChange(e.target.value)
|
|
11806
|
+
}
|
|
11807
|
+
) }),
|
|
11808
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11809
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}) }) }),
|
|
11810
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11811
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11812
|
+
StackedModalTrigger,
|
|
11813
|
+
{
|
|
11814
|
+
type: "add-items",
|
|
11815
|
+
setModalContent
|
|
11816
|
+
}
|
|
11817
|
+
),
|
|
11818
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11819
|
+
StackedModalTrigger,
|
|
11820
|
+
{
|
|
11821
|
+
type: "add-custom-item",
|
|
11822
|
+
setModalContent
|
|
11823
|
+
}
|
|
11824
|
+
)
|
|
11825
|
+
] })
|
|
11826
|
+
] })
|
|
11827
|
+
] })
|
|
11828
|
+
] }),
|
|
11829
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11830
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_1fr_1fr_28px] gap-3 px-4 py-2 text-ui-fg-muted", children: [
|
|
11831
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
11832
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) }),
|
|
11833
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Price" }) }),
|
|
11834
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {})
|
|
11835
|
+
] }) }),
|
|
11836
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
11837
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "There are no items in this order" }),
|
|
11838
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add items to the order to get started." })
|
|
11839
|
+
] }) : matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11840
|
+
Item,
|
|
11841
|
+
{
|
|
11842
|
+
item,
|
|
11843
|
+
preview,
|
|
11844
|
+
currencyCode
|
|
11845
|
+
},
|
|
11846
|
+
item.id
|
|
11847
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
11848
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
11849
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
11850
|
+
'No items found for "',
|
|
11851
|
+
query2,
|
|
11852
|
+
'".'
|
|
11853
|
+
] })
|
|
11854
|
+
] }) })
|
|
11855
|
+
] })
|
|
11856
|
+
] }),
|
|
11857
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11858
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_0.5fr_0.5fr] gap-3", children: [
|
|
11859
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Subtotal" }) }),
|
|
11860
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11861
|
+
ui.Text,
|
|
12167
11862
|
{
|
|
12168
|
-
|
|
12169
|
-
|
|
11863
|
+
size: "small",
|
|
11864
|
+
leading: "compact",
|
|
11865
|
+
className: "text-ui-fg-subtle",
|
|
11866
|
+
children: [
|
|
11867
|
+
itemCount,
|
|
11868
|
+
" ",
|
|
11869
|
+
itemCount === 1 ? "item" : "items"
|
|
11870
|
+
]
|
|
12170
11871
|
}
|
|
12171
|
-
),
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
11872
|
+
) }),
|
|
11873
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(preview.item_subtotal, currencyCode) }) })
|
|
11874
|
+
] })
|
|
11875
|
+
] }) }),
|
|
11876
|
+
modalContent && (modalContent === "add-items" ? /* @__PURE__ */ jsxRuntime.jsx(ExistingItemsForm, { orderId: preview.id, items: preview.items }) : modalContent === "add-custom-item" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
11877
|
+
CustomItemForm,
|
|
11878
|
+
{
|
|
11879
|
+
orderId: preview.id,
|
|
11880
|
+
currencyCode
|
|
12179
11881
|
}
|
|
12180
|
-
)
|
|
11882
|
+
) : null)
|
|
11883
|
+
]
|
|
11884
|
+
}
|
|
11885
|
+
) }),
|
|
11886
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
|
|
11887
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11888
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11889
|
+
ui.Button,
|
|
11890
|
+
{
|
|
11891
|
+
size: "small",
|
|
11892
|
+
type: "button",
|
|
11893
|
+
onClick: onSubmit,
|
|
11894
|
+
isLoading: isSubmitting,
|
|
11895
|
+
children: "Save"
|
|
11896
|
+
}
|
|
11897
|
+
)
|
|
11898
|
+
] }) })
|
|
11899
|
+
] });
|
|
11900
|
+
};
|
|
11901
|
+
const Item = ({ item, preview, currencyCode }) => {
|
|
11902
|
+
if (item.variant_id) {
|
|
11903
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VariantItem, { item, preview, currencyCode });
|
|
11904
|
+
}
|
|
11905
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CustomItem, { item, preview, currencyCode });
|
|
11906
|
+
};
|
|
11907
|
+
const VariantItem = ({ item, preview, currencyCode }) => {
|
|
11908
|
+
const [editing, setEditing] = React.useState(false);
|
|
11909
|
+
const form = reactHookForm.useForm({
|
|
11910
|
+
defaultValues: {
|
|
11911
|
+
quantity: item.quantity,
|
|
11912
|
+
unit_price: item.unit_price
|
|
11913
|
+
},
|
|
11914
|
+
resolver: zod.zodResolver(variantItemSchema)
|
|
11915
|
+
});
|
|
11916
|
+
const actionId = React.useMemo(() => {
|
|
11917
|
+
var _a, _b;
|
|
11918
|
+
return (_b = (_a = item.actions) == null ? void 0 : _a.find((a) => a.action === "ITEM_ADD")) == null ? void 0 : _b.id;
|
|
11919
|
+
}, [item]);
|
|
11920
|
+
const { mutateAsync: updateActionItem, isPending: isUpdatingActionItem } = useDraftOrderUpdateActionItem(preview.id);
|
|
11921
|
+
const { mutateAsync: updateOriginalItem, isPending: isUpdatingOriginalItem } = useDraftOrderUpdateItem(preview.id);
|
|
11922
|
+
const isPending = isUpdatingActionItem || isUpdatingOriginalItem;
|
|
11923
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11924
|
+
if (convertNumber(data.unit_price) === item.unit_price && data.quantity === item.quantity) {
|
|
11925
|
+
setEditing(false);
|
|
11926
|
+
return;
|
|
11927
|
+
}
|
|
11928
|
+
if (!actionId) {
|
|
11929
|
+
await updateOriginalItem(
|
|
11930
|
+
{
|
|
11931
|
+
item_id: item.id,
|
|
11932
|
+
quantity: data.quantity,
|
|
11933
|
+
unit_price: convertNumber(data.unit_price)
|
|
11934
|
+
},
|
|
11935
|
+
{
|
|
11936
|
+
onSuccess: () => {
|
|
11937
|
+
setEditing(false);
|
|
11938
|
+
},
|
|
11939
|
+
onError: (e) => {
|
|
11940
|
+
ui.toast.error(e.message);
|
|
11941
|
+
}
|
|
11942
|
+
}
|
|
11943
|
+
);
|
|
11944
|
+
return;
|
|
11945
|
+
}
|
|
11946
|
+
await updateActionItem(
|
|
11947
|
+
{
|
|
11948
|
+
action_id: actionId,
|
|
11949
|
+
quantity: data.quantity,
|
|
11950
|
+
unit_price: convertNumber(data.unit_price)
|
|
11951
|
+
},
|
|
11952
|
+
{
|
|
11953
|
+
onSuccess: () => {
|
|
11954
|
+
setEditing(false);
|
|
11955
|
+
},
|
|
11956
|
+
onError: (e) => {
|
|
11957
|
+
ui.toast.error(e.message);
|
|
11958
|
+
}
|
|
11959
|
+
}
|
|
11960
|
+
);
|
|
11961
|
+
});
|
|
11962
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
|
|
11963
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full", children: [
|
|
11964
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11965
|
+
Thumbnail,
|
|
11966
|
+
{
|
|
11967
|
+
thumbnail: item.thumbnail,
|
|
11968
|
+
alt: item.product_title ?? void 0
|
|
11969
|
+
}
|
|
11970
|
+
),
|
|
11971
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11972
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
11973
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12181
11974
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12182
|
-
|
|
11975
|
+
ui.Text,
|
|
12183
11976
|
{
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
"focus:bg-ui-bg-field-hover",
|
|
12188
|
-
"hover:bg-ui-bg-field-hover",
|
|
12189
|
-
{
|
|
12190
|
-
"size-7": size === "small",
|
|
12191
|
-
"size-8": size === "base"
|
|
12192
|
-
}
|
|
12193
|
-
),
|
|
12194
|
-
type: "button",
|
|
12195
|
-
onClick: handleIncrement,
|
|
12196
|
-
disabled: max !== void 0 && value >= max || disabled,
|
|
11977
|
+
size: "small",
|
|
11978
|
+
leading: "compact",
|
|
11979
|
+
className: "text-ui-fg-subtle",
|
|
12197
11980
|
children: [
|
|
12198
|
-
|
|
12199
|
-
|
|
11981
|
+
"(",
|
|
11982
|
+
item.variant_title,
|
|
11983
|
+
")"
|
|
12200
11984
|
]
|
|
12201
11985
|
}
|
|
12202
11986
|
)
|
|
12203
|
-
]
|
|
11987
|
+
] }),
|
|
11988
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11989
|
+
ui.Text,
|
|
11990
|
+
{
|
|
11991
|
+
size: "small",
|
|
11992
|
+
leading: "compact",
|
|
11993
|
+
className: "text-ui-fg-subtle",
|
|
11994
|
+
children: item.variant_sku
|
|
11995
|
+
}
|
|
11996
|
+
)
|
|
11997
|
+
] })
|
|
11998
|
+
] }),
|
|
11999
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12000
|
+
Form$2.Field,
|
|
12001
|
+
{
|
|
12002
|
+
control: form.control,
|
|
12003
|
+
name: "quantity",
|
|
12004
|
+
render: ({ field }) => {
|
|
12005
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
|
|
12006
|
+
}
|
|
12204
12007
|
}
|
|
12205
|
-
)
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12008
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }) }),
|
|
12009
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12010
|
+
Form$2.Field,
|
|
12011
|
+
{
|
|
12012
|
+
control: form.control,
|
|
12013
|
+
name: "unit_price",
|
|
12014
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12015
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12016
|
+
ui.CurrencyInput,
|
|
12017
|
+
{
|
|
12018
|
+
...field,
|
|
12019
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12020
|
+
code: currencyCode,
|
|
12021
|
+
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value)
|
|
12022
|
+
}
|
|
12023
|
+
) }) });
|
|
12024
|
+
}
|
|
12025
|
+
}
|
|
12026
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-end w-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
12027
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12028
|
+
ui.IconButton,
|
|
12029
|
+
{
|
|
12030
|
+
type: "button",
|
|
12031
|
+
size: "small",
|
|
12032
|
+
onClick: editing ? onSubmit : () => {
|
|
12033
|
+
setEditing(true);
|
|
12034
|
+
},
|
|
12035
|
+
disabled: isPending,
|
|
12036
|
+
children: editing ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.PencilSquare, {})
|
|
12037
|
+
}
|
|
12038
|
+
)
|
|
12039
|
+
] }) }) });
|
|
12214
12040
|
};
|
|
12215
|
-
const
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12041
|
+
const variantItemSchema = objectType({
|
|
12042
|
+
quantity: numberType(),
|
|
12043
|
+
unit_price: unionType([numberType(), stringType()])
|
|
12044
|
+
});
|
|
12045
|
+
const CustomItem = ({ item, preview, currencyCode }) => {
|
|
12046
|
+
const [editing, setEditing] = React.useState(false);
|
|
12047
|
+
const { quantity, unit_price, title } = item;
|
|
12048
|
+
const form = reactHookForm.useForm({
|
|
12049
|
+
defaultValues: {
|
|
12050
|
+
title,
|
|
12051
|
+
quantity,
|
|
12052
|
+
unit_price
|
|
12053
|
+
},
|
|
12054
|
+
resolver: zod.zodResolver(customItemSchema)
|
|
12220
12055
|
});
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
}
|
|
12232
|
-
|
|
12056
|
+
React.useEffect(() => {
|
|
12057
|
+
form.reset({
|
|
12058
|
+
title,
|
|
12059
|
+
quantity,
|
|
12060
|
+
unit_price
|
|
12061
|
+
});
|
|
12062
|
+
}, [form, title, quantity, unit_price]);
|
|
12063
|
+
const actionId = React.useMemo(() => {
|
|
12064
|
+
var _a, _b;
|
|
12065
|
+
return (_b = (_a = item.actions) == null ? void 0 : _a.find((a) => a.action === "ITEM_ADD")) == null ? void 0 : _b.id;
|
|
12066
|
+
}, [item]);
|
|
12067
|
+
const { mutateAsync: updateActionItem, isPending: isUpdatingActionItem } = useDraftOrderUpdateActionItem(preview.id);
|
|
12068
|
+
const { mutateAsync: removeActionItem, isPending: isRemovingActionItem } = useDraftOrderRemoveActionItem(preview.id);
|
|
12069
|
+
const { mutateAsync: updateOriginalItem, isPending: isUpdatingOriginalItem } = useDraftOrderUpdateItem(preview.id);
|
|
12070
|
+
const isPending = isUpdatingActionItem || isUpdatingOriginalItem;
|
|
12071
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12072
|
+
if (convertNumber(data.unit_price) === item.unit_price && data.quantity === item.quantity && data.title === item.title) {
|
|
12073
|
+
setEditing(false);
|
|
12074
|
+
return;
|
|
12075
|
+
}
|
|
12076
|
+
if (!actionId) {
|
|
12077
|
+
await updateOriginalItem(
|
|
12078
|
+
{
|
|
12079
|
+
item_id: item.id,
|
|
12080
|
+
quantity: data.quantity,
|
|
12081
|
+
unit_price: convertNumber(data.unit_price)
|
|
12082
|
+
},
|
|
12083
|
+
{
|
|
12084
|
+
onSuccess: () => {
|
|
12085
|
+
setEditing(false);
|
|
12086
|
+
},
|
|
12087
|
+
onError: (e) => {
|
|
12088
|
+
ui.toast.error(e.message);
|
|
12089
|
+
}
|
|
12090
|
+
}
|
|
12091
|
+
);
|
|
12092
|
+
return;
|
|
12093
|
+
}
|
|
12094
|
+
if (data.quantity === 0) {
|
|
12095
|
+
await removeActionItem(actionId, {
|
|
12096
|
+
onSuccess: () => {
|
|
12097
|
+
setEditing(false);
|
|
12098
|
+
},
|
|
12099
|
+
onError: (e) => {
|
|
12100
|
+
ui.toast.error(e.message);
|
|
12101
|
+
}
|
|
12102
|
+
});
|
|
12103
|
+
return;
|
|
12104
|
+
}
|
|
12105
|
+
await updateActionItem(
|
|
12106
|
+
{
|
|
12107
|
+
action_id: actionId,
|
|
12108
|
+
quantity: data.quantity,
|
|
12109
|
+
unit_price: convertNumber(data.unit_price)
|
|
12110
|
+
},
|
|
12111
|
+
{
|
|
12112
|
+
onSuccess: () => {
|
|
12113
|
+
setEditing(false);
|
|
12114
|
+
},
|
|
12115
|
+
onError: (e) => {
|
|
12116
|
+
ui.toast.error(e.message);
|
|
12117
|
+
}
|
|
12118
|
+
}
|
|
12119
|
+
);
|
|
12233
12120
|
});
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12121
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
|
|
12122
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12123
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12124
|
+
Thumbnail,
|
|
12125
|
+
{
|
|
12126
|
+
thumbnail: item.thumbnail,
|
|
12127
|
+
alt: item.title ?? void 0
|
|
12128
|
+
}
|
|
12129
|
+
),
|
|
12130
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12131
|
+
Form$2.Field,
|
|
12132
|
+
{
|
|
12133
|
+
control: form.control,
|
|
12134
|
+
name: "title",
|
|
12135
|
+
render: ({ field }) => {
|
|
12136
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }) });
|
|
12137
|
+
}
|
|
12138
|
+
}
|
|
12139
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.title })
|
|
12140
|
+
] }),
|
|
12141
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12142
|
+
Form$2.Field,
|
|
12143
|
+
{
|
|
12144
|
+
control: form.control,
|
|
12145
|
+
name: "quantity",
|
|
12146
|
+
render: ({ field }) => {
|
|
12147
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
|
|
12148
|
+
}
|
|
12149
|
+
}
|
|
12150
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }),
|
|
12151
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12152
|
+
Form$2.Field,
|
|
12153
|
+
{
|
|
12154
|
+
control: form.control,
|
|
12155
|
+
name: "unit_price",
|
|
12156
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12157
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12158
|
+
ui.CurrencyInput,
|
|
12159
|
+
{
|
|
12160
|
+
...field,
|
|
12161
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12162
|
+
code: currencyCode,
|
|
12163
|
+
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value)
|
|
12164
|
+
}
|
|
12165
|
+
) }) });
|
|
12166
|
+
}
|
|
12167
|
+
}
|
|
12168
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
12169
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12170
|
+
ui.IconButton,
|
|
12171
|
+
{
|
|
12172
|
+
type: "button",
|
|
12173
|
+
size: "small",
|
|
12174
|
+
onClick: editing ? onSubmit : () => {
|
|
12175
|
+
setEditing(true);
|
|
12176
|
+
},
|
|
12177
|
+
disabled: isPending,
|
|
12178
|
+
children: editing ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.PencilSquare, {})
|
|
12179
|
+
}
|
|
12180
|
+
)
|
|
12181
|
+
] }) }) });
|
|
12182
|
+
};
|
|
12183
|
+
const StackedModalTrigger = ({
|
|
12184
|
+
type,
|
|
12185
|
+
setModalContent
|
|
12186
|
+
}) => {
|
|
12187
|
+
const { setIsOpen } = useStackedModal();
|
|
12188
|
+
const onClick = React.useCallback(() => {
|
|
12189
|
+
setModalContent(type);
|
|
12190
|
+
setIsOpen(STACKED_MODAL_ID, true);
|
|
12191
|
+
}, [setModalContent, setIsOpen, type]);
|
|
12192
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Item, { onClick, children: type === "add-items" ? "Add items" : "Add custom item" }) });
|
|
12193
|
+
};
|
|
12194
|
+
const VARIANT_PREFIX = "items";
|
|
12195
|
+
const LIMIT = 50;
|
|
12196
|
+
const ExistingItemsForm = ({ orderId, items }) => {
|
|
12197
|
+
const { setIsOpen } = useStackedModal();
|
|
12198
|
+
const [rowSelection, setRowSelection] = React.useState(
|
|
12199
|
+
items.reduce((acc, item) => {
|
|
12200
|
+
acc[item.variant_id] = true;
|
|
12201
|
+
return acc;
|
|
12202
|
+
}, {})
|
|
12203
|
+
);
|
|
12204
|
+
React.useEffect(() => {
|
|
12205
|
+
setRowSelection(
|
|
12206
|
+
items.reduce((acc, item) => {
|
|
12207
|
+
if (item.variant_id) {
|
|
12208
|
+
acc[item.variant_id] = true;
|
|
12209
|
+
}
|
|
12210
|
+
return acc;
|
|
12211
|
+
}, {})
|
|
12212
|
+
);
|
|
12213
|
+
}, [items]);
|
|
12214
|
+
const { q, order, offset } = useQueryParams(
|
|
12215
|
+
["q", "order", "offset"],
|
|
12216
|
+
VARIANT_PREFIX
|
|
12217
|
+
);
|
|
12218
|
+
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
12237
12219
|
{
|
|
12238
|
-
|
|
12220
|
+
q,
|
|
12221
|
+
order,
|
|
12222
|
+
offset: offset ? parseInt(offset) : void 0,
|
|
12223
|
+
limit: LIMIT
|
|
12239
12224
|
},
|
|
12240
12225
|
{
|
|
12241
|
-
|
|
12226
|
+
placeholderData: reactQuery.keepPreviousData
|
|
12242
12227
|
}
|
|
12243
12228
|
);
|
|
12244
|
-
const
|
|
12245
|
-
|
|
12246
|
-
throw error;
|
|
12247
|
-
}
|
|
12248
|
-
if (isPreviewError) {
|
|
12249
|
-
throw previewError;
|
|
12250
|
-
}
|
|
12251
|
-
const ready = !!preview && !isPreviewPending && !!draft_order && !isPending;
|
|
12252
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: ready ? /* @__PURE__ */ jsxRuntime.jsx(ItemsForm, { preview, currencyCode: draft_order.currency_code }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12253
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Items" }) }),
|
|
12254
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
12255
|
-
] }) });
|
|
12256
|
-
};
|
|
12257
|
-
const ItemsForm = ({ preview, currencyCode }) => {
|
|
12258
|
-
var _a;
|
|
12259
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
12260
|
-
const [modalContent, setModalContent] = React.useState(
|
|
12261
|
-
null
|
|
12262
|
-
);
|
|
12263
|
-
const { handleSuccess } = useRouteModal();
|
|
12264
|
-
const { searchValue, onSearchValueChange, query: query2 } = useDebouncedSearch();
|
|
12265
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
12266
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
12267
|
-
const itemCount = ((_a = preview.items) == null ? void 0 : _a.reduce((acc, item) => acc + item.quantity, 0)) || 0;
|
|
12268
|
-
const matches = React.useMemo(() => {
|
|
12269
|
-
return matchSorter.matchSorter(preview.items, query2, {
|
|
12270
|
-
keys: ["product_title", "variant_title", "variant_sku", "title"]
|
|
12271
|
-
});
|
|
12272
|
-
}, [preview.items, query2]);
|
|
12229
|
+
const columns = useColumns();
|
|
12230
|
+
const { mutateAsync } = useDraftOrderAddItems(orderId);
|
|
12273
12231
|
const onSubmit = async () => {
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
});
|
|
12284
|
-
if (!requestSucceeded) {
|
|
12285
|
-
setIsSubmitting(false);
|
|
12286
|
-
return;
|
|
12287
|
-
}
|
|
12288
|
-
await confirmOrderEdit(void 0, {
|
|
12289
|
-
onError: (e) => {
|
|
12290
|
-
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
12291
|
-
},
|
|
12292
|
-
onSuccess: () => {
|
|
12293
|
-
handleSuccess();
|
|
12232
|
+
const ids = Object.keys(rowSelection).filter(
|
|
12233
|
+
(id) => !items.find((i) => i.variant_id === id)
|
|
12234
|
+
);
|
|
12235
|
+
await mutateAsync(
|
|
12236
|
+
{
|
|
12237
|
+
items: ids.map((id) => ({
|
|
12238
|
+
variant_id: id,
|
|
12239
|
+
quantity: 1
|
|
12240
|
+
}))
|
|
12294
12241
|
},
|
|
12295
|
-
|
|
12296
|
-
|
|
12242
|
+
{
|
|
12243
|
+
onSuccess: () => {
|
|
12244
|
+
setRowSelection({});
|
|
12245
|
+
setIsOpen(STACKED_MODAL_ID, false);
|
|
12246
|
+
},
|
|
12247
|
+
onError: (e) => {
|
|
12248
|
+
ui.toast.error(e.message);
|
|
12249
|
+
}
|
|
12297
12250
|
}
|
|
12298
|
-
|
|
12251
|
+
);
|
|
12299
12252
|
};
|
|
12300
|
-
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12253
|
+
if (isError) {
|
|
12254
|
+
throw error;
|
|
12255
|
+
}
|
|
12256
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12257
|
+
StackedFocusModal.Content,
|
|
12258
|
+
{
|
|
12259
|
+
onOpenAutoFocus: (e) => {
|
|
12260
|
+
e.preventDefault();
|
|
12261
|
+
const searchInput = document.querySelector(
|
|
12262
|
+
"[data-modal-id='modal-search-input']"
|
|
12263
|
+
);
|
|
12264
|
+
if (searchInput) {
|
|
12265
|
+
searchInput.focus();
|
|
12305
12266
|
}
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12267
|
+
},
|
|
12268
|
+
children: [
|
|
12269
|
+
/* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Header, { children: [
|
|
12270
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Product Variants" }) }),
|
|
12271
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Choose product variants to add to the order." }) })
|
|
12272
|
+
] }),
|
|
12273
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12274
|
+
DataTable,
|
|
12275
|
+
{
|
|
12276
|
+
data: variants,
|
|
12277
|
+
columns,
|
|
12278
|
+
isLoading: isPending,
|
|
12279
|
+
getRowId: (row) => row.id,
|
|
12280
|
+
rowCount: count,
|
|
12281
|
+
prefix: VARIANT_PREFIX,
|
|
12282
|
+
layout: "fill",
|
|
12283
|
+
rowSelection: {
|
|
12284
|
+
state: rowSelection,
|
|
12285
|
+
onRowSelectionChange: setRowSelection,
|
|
12286
|
+
enableRowSelection: (row) => {
|
|
12287
|
+
return !items.find((i) => i.variant_id === row.original.id);
|
|
12288
|
+
}
|
|
12289
|
+
},
|
|
12290
|
+
autoFocusSearch: true
|
|
12291
|
+
}
|
|
12292
|
+
) }),
|
|
12293
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
|
|
12294
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12295
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Update items" })
|
|
12296
|
+
] }) })
|
|
12297
|
+
]
|
|
12298
|
+
}
|
|
12310
12299
|
);
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12300
|
+
};
|
|
12301
|
+
const columnHelper = ui.createDataTableColumnHelper();
|
|
12302
|
+
const useColumns = () => {
|
|
12303
|
+
return React.useMemo(() => {
|
|
12304
|
+
return [
|
|
12305
|
+
columnHelper.select(),
|
|
12306
|
+
columnHelper.accessor("product.title", {
|
|
12307
|
+
header: "Product",
|
|
12308
|
+
cell: ({ row }) => {
|
|
12309
|
+
var _a, _b, _c;
|
|
12310
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
12311
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12312
|
+
Thumbnail,
|
|
12313
|
+
{
|
|
12314
|
+
thumbnail: (_a = row.original.product) == null ? void 0 : _a.thumbnail,
|
|
12315
|
+
alt: (_b = row.original.product) == null ? void 0 : _b.title
|
|
12316
|
+
}
|
|
12317
|
+
),
|
|
12318
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: (_c = row.original.product) == null ? void 0 : _c.title })
|
|
12319
|
+
] });
|
|
12320
|
+
},
|
|
12321
|
+
enableSorting: true
|
|
12322
|
+
}),
|
|
12323
|
+
columnHelper.accessor("title", {
|
|
12324
|
+
header: "Variant",
|
|
12325
|
+
enableSorting: true
|
|
12326
|
+
}),
|
|
12327
|
+
columnHelper.accessor("sku", {
|
|
12328
|
+
header: "SKU",
|
|
12329
|
+
cell: ({ getValue }) => {
|
|
12330
|
+
return getValue() ?? "-";
|
|
12331
|
+
},
|
|
12332
|
+
enableSorting: true
|
|
12333
|
+
}),
|
|
12334
|
+
columnHelper.accessor("updated_at", {
|
|
12335
|
+
header: "Updated",
|
|
12336
|
+
cell: ({ getValue }) => {
|
|
12337
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12338
|
+
ui.Tooltip,
|
|
12339
|
+
{
|
|
12340
|
+
content: getFullDate({ date: getValue(), includeTime: true }),
|
|
12341
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
|
|
12342
|
+
}
|
|
12343
|
+
);
|
|
12344
|
+
},
|
|
12345
|
+
enableSorting: true,
|
|
12346
|
+
sortAscLabel: "Oldest first",
|
|
12347
|
+
sortDescLabel: "Newest first"
|
|
12348
|
+
}),
|
|
12349
|
+
columnHelper.accessor("created_at", {
|
|
12350
|
+
header: "Created",
|
|
12351
|
+
cell: ({ getValue }) => {
|
|
12352
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12353
|
+
ui.Tooltip,
|
|
12354
|
+
{
|
|
12355
|
+
content: getFullDate({ date: getValue(), includeTime: true }),
|
|
12356
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
|
|
12357
|
+
}
|
|
12358
|
+
);
|
|
12359
|
+
},
|
|
12360
|
+
enableSorting: true,
|
|
12361
|
+
sortAscLabel: "Oldest first",
|
|
12362
|
+
sortDescLabel: "Newest first"
|
|
12363
|
+
})
|
|
12364
|
+
];
|
|
12365
|
+
}, []);
|
|
12366
|
+
};
|
|
12367
|
+
const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
12368
|
+
const { setIsOpen } = useStackedModal();
|
|
12369
|
+
const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
|
|
12370
|
+
const form = reactHookForm.useForm({
|
|
12371
|
+
defaultValues: {
|
|
12372
|
+
title: "",
|
|
12373
|
+
quantity: 1,
|
|
12374
|
+
unit_price: ""
|
|
12375
|
+
},
|
|
12376
|
+
resolver: zod.zodResolver(customItemSchema)
|
|
12377
|
+
});
|
|
12378
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12379
|
+
await addItems(
|
|
12321
12380
|
{
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12381
|
+
items: [
|
|
12382
|
+
{
|
|
12383
|
+
title: data.title,
|
|
12384
|
+
quantity: data.quantity,
|
|
12385
|
+
unit_price: convertNumber(data.unit_price)
|
|
12326
12386
|
}
|
|
12387
|
+
]
|
|
12388
|
+
},
|
|
12389
|
+
{
|
|
12390
|
+
onSuccess: () => {
|
|
12391
|
+
setIsOpen(STACKED_MODAL_ID, false);
|
|
12327
12392
|
},
|
|
12328
|
-
|
|
12329
|
-
|
|
12393
|
+
onError: (e) => {
|
|
12394
|
+
ui.toast.error(e.message);
|
|
12395
|
+
}
|
|
12396
|
+
}
|
|
12397
|
+
);
|
|
12398
|
+
});
|
|
12399
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Content, { children: [
|
|
12400
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
12401
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
|
|
12402
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12403
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
|
|
12404
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
|
|
12405
|
+
] }),
|
|
12406
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12407
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12408
|
+
Form$2.Field,
|
|
12409
|
+
{
|
|
12410
|
+
control: form.control,
|
|
12411
|
+
name: "title",
|
|
12412
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12330
12413
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12331
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12332
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12414
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
|
|
12415
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
|
|
12333
12416
|
] }),
|
|
12334
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12335
|
-
|
|
12336
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
12352
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}) }) }),
|
|
12353
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
12354
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12355
|
-
StackedModalTrigger,
|
|
12356
|
-
{
|
|
12357
|
-
type: "add-items",
|
|
12358
|
-
setModalContent
|
|
12359
|
-
}
|
|
12360
|
-
),
|
|
12361
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12362
|
-
StackedModalTrigger,
|
|
12363
|
-
{
|
|
12364
|
-
type: "add-custom-item",
|
|
12365
|
-
setModalContent
|
|
12366
|
-
}
|
|
12367
|
-
)
|
|
12368
|
-
] })
|
|
12369
|
-
] })
|
|
12370
|
-
] })
|
|
12371
|
-
] }),
|
|
12372
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12373
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_1fr_1fr_28px] gap-3 px-4 py-2 text-ui-fg-muted", children: [
|
|
12374
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12375
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) }),
|
|
12376
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Price" }) }),
|
|
12377
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", {})
|
|
12378
|
-
] }) }),
|
|
12379
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: itemCount <= 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
12380
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "There are no items in this order" }),
|
|
12381
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add items to the order to get started." })
|
|
12382
|
-
] }) : matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12383
|
-
Item,
|
|
12384
|
-
{
|
|
12385
|
-
item,
|
|
12386
|
-
preview,
|
|
12387
|
-
currencyCode
|
|
12388
|
-
},
|
|
12389
|
-
item.id
|
|
12390
|
-
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
12391
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12392
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12393
|
-
'No items found for "',
|
|
12394
|
-
query2,
|
|
12395
|
-
'".'
|
|
12396
|
-
] })
|
|
12397
|
-
] }) })
|
|
12398
|
-
] })
|
|
12417
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12418
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12419
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12420
|
+
] })
|
|
12421
|
+
] }) })
|
|
12422
|
+
}
|
|
12423
|
+
),
|
|
12424
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12425
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12426
|
+
Form$2.Field,
|
|
12427
|
+
{
|
|
12428
|
+
control: form.control,
|
|
12429
|
+
name: "unit_price",
|
|
12430
|
+
render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12431
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12432
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
|
|
12433
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
|
|
12399
12434
|
] }),
|
|
12400
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12404
|
-
ui.Text,
|
|
12435
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12436
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12437
|
+
ui.CurrencyInput,
|
|
12405
12438
|
{
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
itemCount,
|
|
12411
|
-
" ",
|
|
12412
|
-
itemCount === 1 ? "item" : "items"
|
|
12413
|
-
]
|
|
12439
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12440
|
+
code: currencyCode,
|
|
12441
|
+
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
|
|
12442
|
+
...field
|
|
12414
12443
|
}
|
|
12415
12444
|
) }),
|
|
12416
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12445
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12417
12446
|
] })
|
|
12418
|
-
] }) })
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
orderId: preview.id,
|
|
12423
|
-
currencyCode
|
|
12424
|
-
}
|
|
12425
|
-
) : null)
|
|
12426
|
-
]
|
|
12427
|
-
}
|
|
12428
|
-
) }),
|
|
12429
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
|
|
12430
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12447
|
+
] }) })
|
|
12448
|
+
}
|
|
12449
|
+
),
|
|
12450
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12431
12451
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12432
|
-
|
|
12452
|
+
Form$2.Field,
|
|
12433
12453
|
{
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12454
|
+
control: form.control,
|
|
12455
|
+
name: "quantity",
|
|
12456
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12457
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12458
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
|
|
12459
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
12460
|
+
] }),
|
|
12461
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 w-full", children: [
|
|
12462
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
12463
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12464
|
+
] })
|
|
12465
|
+
] }) })
|
|
12439
12466
|
}
|
|
12440
12467
|
)
|
|
12468
|
+
] }) }) }),
|
|
12469
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
|
|
12470
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12471
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
12441
12472
|
] }) })
|
|
12473
|
+
] }) }) });
|
|
12474
|
+
};
|
|
12475
|
+
const customItemSchema = objectType({
|
|
12476
|
+
title: stringType().min(1),
|
|
12477
|
+
quantity: numberType(),
|
|
12478
|
+
unit_price: unionType([numberType(), stringType()])
|
|
12479
|
+
});
|
|
12480
|
+
const Email = () => {
|
|
12481
|
+
const { id } = reactRouterDom.useParams();
|
|
12482
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12483
|
+
fields: "+email"
|
|
12484
|
+
});
|
|
12485
|
+
if (isError) {
|
|
12486
|
+
throw error;
|
|
12487
|
+
}
|
|
12488
|
+
const isReady = !isPending && !!order;
|
|
12489
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12490
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12491
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
12492
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12493
|
+
] }),
|
|
12494
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
12442
12495
|
] });
|
|
12443
12496
|
};
|
|
12444
|
-
const
|
|
12445
|
-
|
|
12446
|
-
|
|
12497
|
+
const EmailForm = ({ order }) => {
|
|
12498
|
+
const form = reactHookForm.useForm({
|
|
12499
|
+
defaultValues: {
|
|
12500
|
+
email: order.email ?? ""
|
|
12501
|
+
},
|
|
12502
|
+
resolver: zod.zodResolver(schema$1)
|
|
12503
|
+
});
|
|
12504
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12505
|
+
const { handleSuccess } = useRouteModal();
|
|
12506
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12507
|
+
await mutateAsync(
|
|
12508
|
+
{ email: data.email },
|
|
12509
|
+
{
|
|
12510
|
+
onSuccess: () => {
|
|
12511
|
+
handleSuccess();
|
|
12512
|
+
},
|
|
12513
|
+
onError: (error) => {
|
|
12514
|
+
ui.toast.error(error.message);
|
|
12515
|
+
}
|
|
12516
|
+
}
|
|
12517
|
+
);
|
|
12518
|
+
});
|
|
12519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12520
|
+
KeyboundForm,
|
|
12521
|
+
{
|
|
12522
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12523
|
+
onSubmit,
|
|
12524
|
+
children: [
|
|
12525
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12526
|
+
Form$2.Field,
|
|
12527
|
+
{
|
|
12528
|
+
control: form.control,
|
|
12529
|
+
name: "email",
|
|
12530
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12531
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
12532
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12533
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12534
|
+
] })
|
|
12535
|
+
}
|
|
12536
|
+
) }),
|
|
12537
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12538
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12539
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12540
|
+
] }) })
|
|
12541
|
+
]
|
|
12542
|
+
}
|
|
12543
|
+
) });
|
|
12544
|
+
};
|
|
12545
|
+
const schema$1 = objectType({
|
|
12546
|
+
email: stringType().email()
|
|
12547
|
+
});
|
|
12548
|
+
const TransferOwnership = () => {
|
|
12549
|
+
const { id } = reactRouterDom.useParams();
|
|
12550
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12551
|
+
fields: "id,customer_id,customer.*"
|
|
12552
|
+
});
|
|
12553
|
+
if (isError) {
|
|
12554
|
+
throw error;
|
|
12447
12555
|
}
|
|
12448
|
-
|
|
12556
|
+
const isReady = !isPending && !!draft_order;
|
|
12557
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12558
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12559
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
12560
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12561
|
+
] }),
|
|
12562
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
12563
|
+
] });
|
|
12449
12564
|
};
|
|
12450
|
-
const
|
|
12451
|
-
|
|
12565
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12566
|
+
var _a, _b;
|
|
12452
12567
|
const form = reactHookForm.useForm({
|
|
12453
12568
|
defaultValues: {
|
|
12454
|
-
|
|
12455
|
-
unit_price: item.unit_price
|
|
12569
|
+
customer_id: order.customer_id || ""
|
|
12456
12570
|
},
|
|
12457
|
-
resolver: zod.zodResolver(
|
|
12571
|
+
resolver: zod.zodResolver(schema)
|
|
12458
12572
|
});
|
|
12459
|
-
const
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12573
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12574
|
+
const { handleSuccess } = useRouteModal();
|
|
12575
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12576
|
+
const currentCustomer = order.customer ? {
|
|
12577
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12578
|
+
value: order.customer.id
|
|
12579
|
+
} : null;
|
|
12466
12580
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
{
|
|
12474
|
-
item_id: item.id,
|
|
12475
|
-
quantity: data.quantity,
|
|
12476
|
-
unit_price: convertNumber(data.unit_price)
|
|
12581
|
+
await mutateAsync(
|
|
12582
|
+
{ customer_id: data.customer_id },
|
|
12583
|
+
{
|
|
12584
|
+
onSuccess: () => {
|
|
12585
|
+
ui.toast.success("Customer updated");
|
|
12586
|
+
handleSuccess();
|
|
12477
12587
|
},
|
|
12478
|
-
{
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12588
|
+
onError: (error) => {
|
|
12589
|
+
ui.toast.error(error.message);
|
|
12590
|
+
}
|
|
12591
|
+
}
|
|
12592
|
+
);
|
|
12593
|
+
});
|
|
12594
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12595
|
+
KeyboundForm,
|
|
12596
|
+
{
|
|
12597
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12598
|
+
onSubmit,
|
|
12599
|
+
children: [
|
|
12600
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12601
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
12602
|
+
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12603
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12604
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12605
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
12606
|
+
] }),
|
|
12607
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12608
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
12609
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12610
|
+
] })
|
|
12611
|
+
] }),
|
|
12612
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12613
|
+
CustomerField,
|
|
12614
|
+
{
|
|
12615
|
+
control: form.control,
|
|
12616
|
+
currentCustomerId: order.customer_id
|
|
12617
|
+
}
|
|
12618
|
+
)
|
|
12619
|
+
] }),
|
|
12620
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12621
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12622
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12623
|
+
] }) })
|
|
12624
|
+
]
|
|
12625
|
+
}
|
|
12626
|
+
) });
|
|
12627
|
+
};
|
|
12628
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12629
|
+
const customers = useComboboxData({
|
|
12630
|
+
queryFn: async (params) => {
|
|
12631
|
+
return await sdk.admin.customer.list({
|
|
12632
|
+
...params,
|
|
12633
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12634
|
+
});
|
|
12635
|
+
},
|
|
12636
|
+
queryKey: ["customers"],
|
|
12637
|
+
getOptions: (data) => {
|
|
12638
|
+
return data.customers.map((customer) => {
|
|
12639
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12640
|
+
return {
|
|
12641
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12642
|
+
value: customer.id
|
|
12643
|
+
};
|
|
12644
|
+
});
|
|
12645
|
+
}
|
|
12646
|
+
});
|
|
12647
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12648
|
+
Form$2.Field,
|
|
12649
|
+
{
|
|
12650
|
+
name: "customer_id",
|
|
12651
|
+
control,
|
|
12652
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
12653
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12654
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
12655
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
12656
|
+
] }),
|
|
12657
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12658
|
+
Combobox,
|
|
12659
|
+
{
|
|
12660
|
+
options: customers.options,
|
|
12661
|
+
fetchNextPage: customers.fetchNextPage,
|
|
12662
|
+
isFetchingNextPage: customers.isFetchingNextPage,
|
|
12663
|
+
searchValue: customers.searchValue,
|
|
12664
|
+
onSearchValueChange: customers.onSearchValueChange,
|
|
12665
|
+
placeholder: "Select customer",
|
|
12666
|
+
...field
|
|
12667
|
+
}
|
|
12668
|
+
) }),
|
|
12669
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12670
|
+
] })
|
|
12671
|
+
}
|
|
12672
|
+
);
|
|
12673
|
+
};
|
|
12674
|
+
const Illustration = () => {
|
|
12675
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12676
|
+
"svg",
|
|
12677
|
+
{
|
|
12678
|
+
width: "280",
|
|
12679
|
+
height: "180",
|
|
12680
|
+
viewBox: "0 0 280 180",
|
|
12681
|
+
fill: "none",
|
|
12682
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12683
|
+
children: [
|
|
12684
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12685
|
+
"rect",
|
|
12686
|
+
{
|
|
12687
|
+
x: "0.00428286",
|
|
12688
|
+
y: "-0.742904",
|
|
12689
|
+
width: "33.5",
|
|
12690
|
+
height: "65.5",
|
|
12691
|
+
rx: "6.75",
|
|
12692
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
12693
|
+
fill: "#D4D4D8",
|
|
12694
|
+
stroke: "#52525B",
|
|
12695
|
+
strokeWidth: "1.5"
|
|
12696
|
+
}
|
|
12697
|
+
),
|
|
12698
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12699
|
+
"rect",
|
|
12700
|
+
{
|
|
12701
|
+
x: "0.00428286",
|
|
12702
|
+
y: "-0.742904",
|
|
12703
|
+
width: "33.5",
|
|
12704
|
+
height: "65.5",
|
|
12705
|
+
rx: "6.75",
|
|
12706
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
12707
|
+
fill: "white",
|
|
12708
|
+
stroke: "#52525B",
|
|
12709
|
+
strokeWidth: "1.5"
|
|
12710
|
+
}
|
|
12711
|
+
),
|
|
12712
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12713
|
+
"path",
|
|
12714
|
+
{
|
|
12715
|
+
d: "M180.579 107.142L179.126 107.959",
|
|
12716
|
+
stroke: "#52525B",
|
|
12717
|
+
strokeWidth: "1.5",
|
|
12718
|
+
strokeLinecap: "round",
|
|
12719
|
+
strokeLinejoin: "round"
|
|
12720
|
+
}
|
|
12721
|
+
),
|
|
12722
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12723
|
+
"path",
|
|
12724
|
+
{
|
|
12725
|
+
opacity: "0.88",
|
|
12726
|
+
d: "M182.305 109.546L180.257 109.534",
|
|
12727
|
+
stroke: "#52525B",
|
|
12728
|
+
strokeWidth: "1.5",
|
|
12729
|
+
strokeLinecap: "round",
|
|
12730
|
+
strokeLinejoin: "round"
|
|
12731
|
+
}
|
|
12732
|
+
),
|
|
12733
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12734
|
+
"path",
|
|
12735
|
+
{
|
|
12736
|
+
opacity: "0.75",
|
|
12737
|
+
d: "M180.551 111.93L179.108 111.096",
|
|
12738
|
+
stroke: "#52525B",
|
|
12739
|
+
strokeWidth: "1.5",
|
|
12740
|
+
strokeLinecap: "round",
|
|
12741
|
+
strokeLinejoin: "round"
|
|
12742
|
+
}
|
|
12743
|
+
),
|
|
12744
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12745
|
+
"path",
|
|
12746
|
+
{
|
|
12747
|
+
opacity: "0.63",
|
|
12748
|
+
d: "M176.347 112.897L176.354 111.73",
|
|
12749
|
+
stroke: "#52525B",
|
|
12750
|
+
strokeWidth: "1.5",
|
|
12751
|
+
strokeLinecap: "round",
|
|
12752
|
+
strokeLinejoin: "round"
|
|
12753
|
+
}
|
|
12754
|
+
),
|
|
12755
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12756
|
+
"path",
|
|
12757
|
+
{
|
|
12758
|
+
opacity: "0.5",
|
|
12759
|
+
d: "M172.153 111.881L173.606 111.064",
|
|
12760
|
+
stroke: "#52525B",
|
|
12761
|
+
strokeWidth: "1.5",
|
|
12762
|
+
strokeLinecap: "round",
|
|
12763
|
+
strokeLinejoin: "round"
|
|
12764
|
+
}
|
|
12765
|
+
),
|
|
12766
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12767
|
+
"path",
|
|
12768
|
+
{
|
|
12769
|
+
opacity: "0.38",
|
|
12770
|
+
d: "M170.428 109.478L172.476 109.489",
|
|
12771
|
+
stroke: "#52525B",
|
|
12772
|
+
strokeWidth: "1.5",
|
|
12773
|
+
strokeLinecap: "round",
|
|
12774
|
+
strokeLinejoin: "round"
|
|
12775
|
+
}
|
|
12776
|
+
),
|
|
12777
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12778
|
+
"path",
|
|
12779
|
+
{
|
|
12780
|
+
opacity: "0.25",
|
|
12781
|
+
d: "M172.181 107.094L173.624 107.928",
|
|
12782
|
+
stroke: "#52525B",
|
|
12783
|
+
strokeWidth: "1.5",
|
|
12784
|
+
strokeLinecap: "round",
|
|
12785
|
+
strokeLinejoin: "round"
|
|
12786
|
+
}
|
|
12787
|
+
),
|
|
12788
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12789
|
+
"path",
|
|
12790
|
+
{
|
|
12791
|
+
opacity: "0.13",
|
|
12792
|
+
d: "M176.386 106.126L176.379 107.294",
|
|
12793
|
+
stroke: "#52525B",
|
|
12794
|
+
strokeWidth: "1.5",
|
|
12795
|
+
strokeLinecap: "round",
|
|
12796
|
+
strokeLinejoin: "round"
|
|
12484
12797
|
}
|
|
12485
|
-
|
|
12486
|
-
);
|
|
12487
|
-
return;
|
|
12488
|
-
}
|
|
12489
|
-
await updateActionItem(
|
|
12490
|
-
{
|
|
12491
|
-
action_id: actionId,
|
|
12492
|
-
quantity: data.quantity,
|
|
12493
|
-
unit_price: convertNumber(data.unit_price)
|
|
12494
|
-
},
|
|
12495
|
-
{
|
|
12496
|
-
onSuccess: () => {
|
|
12497
|
-
setEditing(false);
|
|
12498
|
-
},
|
|
12499
|
-
onError: (e) => {
|
|
12500
|
-
ui.toast.error(e.message);
|
|
12501
|
-
}
|
|
12502
|
-
}
|
|
12503
|
-
);
|
|
12504
|
-
});
|
|
12505
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_28px] gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center", children: [
|
|
12506
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full", children: [
|
|
12507
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12508
|
-
Thumbnail,
|
|
12509
|
-
{
|
|
12510
|
-
thumbnail: item.thumbnail,
|
|
12511
|
-
alt: item.product_title ?? void 0
|
|
12512
|
-
}
|
|
12513
|
-
),
|
|
12514
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12515
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12516
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12517
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12518
|
-
ui.Text,
|
|
12519
|
-
{
|
|
12520
|
-
size: "small",
|
|
12521
|
-
leading: "compact",
|
|
12522
|
-
className: "text-ui-fg-subtle",
|
|
12523
|
-
children: [
|
|
12524
|
-
"(",
|
|
12525
|
-
item.variant_title,
|
|
12526
|
-
")"
|
|
12527
|
-
]
|
|
12528
|
-
}
|
|
12529
|
-
)
|
|
12530
|
-
] }),
|
|
12798
|
+
),
|
|
12531
12799
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12532
|
-
|
|
12800
|
+
"rect",
|
|
12533
12801
|
{
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12802
|
+
width: "12",
|
|
12803
|
+
height: "3",
|
|
12804
|
+
rx: "1.5",
|
|
12805
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12806
|
+
fill: "#D4D4D8"
|
|
12538
12807
|
}
|
|
12539
|
-
)
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12553
|
-
Form$2.Field,
|
|
12554
|
-
{
|
|
12555
|
-
control: form.control,
|
|
12556
|
-
name: "unit_price",
|
|
12557
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
12558
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12559
|
-
ui.CurrencyInput,
|
|
12560
|
-
{
|
|
12561
|
-
...field,
|
|
12562
|
-
symbol: getNativeSymbol(currencyCode),
|
|
12563
|
-
code: currencyCode,
|
|
12564
|
-
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value)
|
|
12565
|
-
}
|
|
12566
|
-
) }) });
|
|
12567
|
-
}
|
|
12568
|
-
}
|
|
12569
|
-
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-end w-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
12570
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12571
|
-
ui.IconButton,
|
|
12572
|
-
{
|
|
12573
|
-
type: "button",
|
|
12574
|
-
size: "small",
|
|
12575
|
-
onClick: editing ? onSubmit : () => {
|
|
12576
|
-
setEditing(true);
|
|
12577
|
-
},
|
|
12578
|
-
disabled: isPending,
|
|
12579
|
-
children: editing ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.PencilSquare, {})
|
|
12580
|
-
}
|
|
12581
|
-
)
|
|
12582
|
-
] }) }) });
|
|
12583
|
-
};
|
|
12584
|
-
const variantItemSchema = objectType({
|
|
12585
|
-
quantity: numberType(),
|
|
12586
|
-
unit_price: unionType([numberType(), stringType()])
|
|
12587
|
-
});
|
|
12588
|
-
const CustomItem = ({ item, preview, currencyCode }) => {
|
|
12589
|
-
const [editing, setEditing] = React.useState(false);
|
|
12590
|
-
const { quantity, unit_price, title } = item;
|
|
12591
|
-
const form = reactHookForm.useForm({
|
|
12592
|
-
defaultValues: {
|
|
12593
|
-
title,
|
|
12594
|
-
quantity,
|
|
12595
|
-
unit_price
|
|
12596
|
-
},
|
|
12597
|
-
resolver: zod.zodResolver(customItemSchema)
|
|
12598
|
-
});
|
|
12599
|
-
React.useEffect(() => {
|
|
12600
|
-
form.reset({
|
|
12601
|
-
title,
|
|
12602
|
-
quantity,
|
|
12603
|
-
unit_price
|
|
12604
|
-
});
|
|
12605
|
-
}, [form, title, quantity, unit_price]);
|
|
12606
|
-
const actionId = React.useMemo(() => {
|
|
12607
|
-
var _a, _b;
|
|
12608
|
-
return (_b = (_a = item.actions) == null ? void 0 : _a.find((a) => a.action === "ITEM_ADD")) == null ? void 0 : _b.id;
|
|
12609
|
-
}, [item]);
|
|
12610
|
-
const { mutateAsync: updateActionItem, isPending: isUpdatingActionItem } = useDraftOrderUpdateActionItem(preview.id);
|
|
12611
|
-
const { mutateAsync: removeActionItem, isPending: isRemovingActionItem } = useDraftOrderRemoveActionItem(preview.id);
|
|
12612
|
-
const { mutateAsync: updateOriginalItem, isPending: isUpdatingOriginalItem } = useDraftOrderUpdateItem(preview.id);
|
|
12613
|
-
const isPending = isUpdatingActionItem || isUpdatingOriginalItem;
|
|
12614
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12615
|
-
if (convertNumber(data.unit_price) === item.unit_price && data.quantity === item.quantity && data.title === item.title) {
|
|
12616
|
-
setEditing(false);
|
|
12617
|
-
return;
|
|
12618
|
-
}
|
|
12619
|
-
if (!actionId) {
|
|
12620
|
-
await updateOriginalItem(
|
|
12621
|
-
{
|
|
12622
|
-
item_id: item.id,
|
|
12623
|
-
quantity: data.quantity,
|
|
12624
|
-
unit_price: convertNumber(data.unit_price)
|
|
12625
|
-
},
|
|
12626
|
-
{
|
|
12627
|
-
onSuccess: () => {
|
|
12628
|
-
setEditing(false);
|
|
12629
|
-
},
|
|
12630
|
-
onError: (e) => {
|
|
12631
|
-
ui.toast.error(e.message);
|
|
12808
|
+
),
|
|
12809
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12810
|
+
"rect",
|
|
12811
|
+
{
|
|
12812
|
+
x: "0.00428286",
|
|
12813
|
+
y: "-0.742904",
|
|
12814
|
+
width: "33.5",
|
|
12815
|
+
height: "65.5",
|
|
12816
|
+
rx: "6.75",
|
|
12817
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12818
|
+
fill: "#D4D4D8",
|
|
12819
|
+
stroke: "#52525B",
|
|
12820
|
+
strokeWidth: "1.5"
|
|
12632
12821
|
}
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
control: form.control,
|
|
12677
|
-
name: "title",
|
|
12678
|
-
render: ({ field }) => {
|
|
12679
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }) });
|
|
12822
|
+
),
|
|
12823
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12824
|
+
"rect",
|
|
12825
|
+
{
|
|
12826
|
+
x: "0.00428286",
|
|
12827
|
+
y: "-0.742904",
|
|
12828
|
+
width: "33.5",
|
|
12829
|
+
height: "65.5",
|
|
12830
|
+
rx: "6.75",
|
|
12831
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12832
|
+
fill: "white",
|
|
12833
|
+
stroke: "#52525B",
|
|
12834
|
+
strokeWidth: "1.5"
|
|
12835
|
+
}
|
|
12836
|
+
),
|
|
12837
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12838
|
+
"rect",
|
|
12839
|
+
{
|
|
12840
|
+
width: "12",
|
|
12841
|
+
height: "3",
|
|
12842
|
+
rx: "1.5",
|
|
12843
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12844
|
+
fill: "#D4D4D8"
|
|
12845
|
+
}
|
|
12846
|
+
),
|
|
12847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12848
|
+
"rect",
|
|
12849
|
+
{
|
|
12850
|
+
width: "17",
|
|
12851
|
+
height: "3",
|
|
12852
|
+
rx: "1.5",
|
|
12853
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12854
|
+
fill: "#D4D4D8"
|
|
12855
|
+
}
|
|
12856
|
+
),
|
|
12857
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12858
|
+
"rect",
|
|
12859
|
+
{
|
|
12860
|
+
width: "12",
|
|
12861
|
+
height: "3",
|
|
12862
|
+
rx: "1.5",
|
|
12863
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12864
|
+
fill: "#D4D4D8"
|
|
12680
12865
|
}
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12685
|
-
Form$2.Field,
|
|
12686
|
-
{
|
|
12687
|
-
control: form.control,
|
|
12688
|
-
name: "quantity",
|
|
12689
|
-
render: ({ field }) => {
|
|
12690
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
|
|
12691
|
-
}
|
|
12692
|
-
}
|
|
12693
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }),
|
|
12694
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12695
|
-
Form$2.Field,
|
|
12696
|
-
{
|
|
12697
|
-
control: form.control,
|
|
12698
|
-
name: "unit_price",
|
|
12699
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
12700
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12701
|
-
ui.CurrencyInput,
|
|
12702
|
-
{
|
|
12703
|
-
...field,
|
|
12704
|
-
symbol: getNativeSymbol(currencyCode),
|
|
12705
|
-
code: currencyCode,
|
|
12706
|
-
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value)
|
|
12707
|
-
}
|
|
12708
|
-
) }) });
|
|
12709
|
-
}
|
|
12710
|
-
}
|
|
12711
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
12712
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12713
|
-
ui.IconButton,
|
|
12714
|
-
{
|
|
12715
|
-
type: "button",
|
|
12716
|
-
size: "small",
|
|
12717
|
-
onClick: editing ? onSubmit : () => {
|
|
12718
|
-
setEditing(true);
|
|
12719
|
-
},
|
|
12720
|
-
disabled: isPending,
|
|
12721
|
-
children: editing ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.PencilSquare, {})
|
|
12722
|
-
}
|
|
12723
|
-
)
|
|
12724
|
-
] }) }) });
|
|
12725
|
-
};
|
|
12726
|
-
const StackedModalTrigger = ({
|
|
12727
|
-
type,
|
|
12728
|
-
setModalContent
|
|
12729
|
-
}) => {
|
|
12730
|
-
const { setIsOpen } = useStackedModal();
|
|
12731
|
-
const onClick = React.useCallback(() => {
|
|
12732
|
-
setModalContent(type);
|
|
12733
|
-
setIsOpen(STACKED_MODAL_ID, true);
|
|
12734
|
-
}, [setModalContent, setIsOpen, type]);
|
|
12735
|
-
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Item, { onClick, children: type === "add-items" ? "Add items" : "Add custom item" }) });
|
|
12736
|
-
};
|
|
12737
|
-
const VARIANT_PREFIX = "items";
|
|
12738
|
-
const LIMIT = 50;
|
|
12739
|
-
const ExistingItemsForm = ({ orderId, items }) => {
|
|
12740
|
-
const { setIsOpen } = useStackedModal();
|
|
12741
|
-
const [rowSelection, setRowSelection] = React.useState(
|
|
12742
|
-
items.reduce((acc, item) => {
|
|
12743
|
-
acc[item.variant_id] = true;
|
|
12744
|
-
return acc;
|
|
12745
|
-
}, {})
|
|
12746
|
-
);
|
|
12747
|
-
React.useEffect(() => {
|
|
12748
|
-
setRowSelection(
|
|
12749
|
-
items.reduce((acc, item) => {
|
|
12750
|
-
if (item.variant_id) {
|
|
12751
|
-
acc[item.variant_id] = true;
|
|
12752
|
-
}
|
|
12753
|
-
return acc;
|
|
12754
|
-
}, {})
|
|
12755
|
-
);
|
|
12756
|
-
}, [items]);
|
|
12757
|
-
const { q, order, offset } = useQueryParams(
|
|
12758
|
-
["q", "order", "offset"],
|
|
12759
|
-
VARIANT_PREFIX
|
|
12760
|
-
);
|
|
12761
|
-
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
12762
|
-
{
|
|
12763
|
-
q,
|
|
12764
|
-
order,
|
|
12765
|
-
offset: offset ? parseInt(offset) : void 0,
|
|
12766
|
-
limit: LIMIT
|
|
12767
|
-
},
|
|
12768
|
-
{
|
|
12769
|
-
placeholderData: reactQuery.keepPreviousData
|
|
12770
|
-
}
|
|
12771
|
-
);
|
|
12772
|
-
const columns = useColumns();
|
|
12773
|
-
const { mutateAsync } = useDraftOrderAddItems(orderId);
|
|
12774
|
-
const onSubmit = async () => {
|
|
12775
|
-
const ids = Object.keys(rowSelection).filter(
|
|
12776
|
-
(id) => !items.find((i) => i.variant_id === id)
|
|
12777
|
-
);
|
|
12778
|
-
await mutateAsync(
|
|
12779
|
-
{
|
|
12780
|
-
items: ids.map((id) => ({
|
|
12781
|
-
variant_id: id,
|
|
12782
|
-
quantity: 1
|
|
12783
|
-
}))
|
|
12784
|
-
},
|
|
12785
|
-
{
|
|
12786
|
-
onSuccess: () => {
|
|
12787
|
-
setRowSelection({});
|
|
12788
|
-
setIsOpen(STACKED_MODAL_ID, false);
|
|
12789
|
-
},
|
|
12790
|
-
onError: (e) => {
|
|
12791
|
-
ui.toast.error(e.message);
|
|
12792
|
-
}
|
|
12793
|
-
}
|
|
12794
|
-
);
|
|
12795
|
-
};
|
|
12796
|
-
if (isError) {
|
|
12797
|
-
throw error;
|
|
12798
|
-
}
|
|
12799
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12800
|
-
StackedFocusModal.Content,
|
|
12801
|
-
{
|
|
12802
|
-
onOpenAutoFocus: (e) => {
|
|
12803
|
-
e.preventDefault();
|
|
12804
|
-
const searchInput = document.querySelector(
|
|
12805
|
-
"[data-modal-id='modal-search-input']"
|
|
12806
|
-
);
|
|
12807
|
-
if (searchInput) {
|
|
12808
|
-
searchInput.focus();
|
|
12809
|
-
}
|
|
12810
|
-
},
|
|
12811
|
-
children: [
|
|
12812
|
-
/* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Header, { children: [
|
|
12813
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Product Variants" }) }),
|
|
12814
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Choose product variants to add to the order." }) })
|
|
12815
|
-
] }),
|
|
12816
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12817
|
-
DataTable,
|
|
12866
|
+
),
|
|
12867
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12868
|
+
"path",
|
|
12818
12869
|
{
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12870
|
+
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
12871
|
+
fill: "#A1A1AA"
|
|
12872
|
+
}
|
|
12873
|
+
),
|
|
12874
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12875
|
+
"rect",
|
|
12876
|
+
{
|
|
12877
|
+
width: "17",
|
|
12878
|
+
height: "3",
|
|
12879
|
+
rx: "1.5",
|
|
12880
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12881
|
+
fill: "#A1A1AA"
|
|
12882
|
+
}
|
|
12883
|
+
),
|
|
12884
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12885
|
+
"rect",
|
|
12886
|
+
{
|
|
12887
|
+
width: "12",
|
|
12888
|
+
height: "3",
|
|
12889
|
+
rx: "1.5",
|
|
12890
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12891
|
+
fill: "#A1A1AA"
|
|
12892
|
+
}
|
|
12893
|
+
),
|
|
12894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12895
|
+
"path",
|
|
12896
|
+
{
|
|
12897
|
+
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12898
|
+
fill: "#52525B"
|
|
12899
|
+
}
|
|
12900
|
+
),
|
|
12901
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12902
|
+
"path",
|
|
12903
|
+
{
|
|
12904
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12905
|
+
stroke: "#A1A1AA",
|
|
12906
|
+
strokeWidth: "1.5",
|
|
12907
|
+
strokeLinecap: "round",
|
|
12908
|
+
strokeLinejoin: "round"
|
|
12834
12909
|
}
|
|
12835
12910
|
) }),
|
|
12836
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12911
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12912
|
+
"path",
|
|
12913
|
+
{
|
|
12914
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12915
|
+
stroke: "#A1A1AA",
|
|
12916
|
+
strokeWidth: "1.5",
|
|
12917
|
+
strokeLinecap: "round",
|
|
12918
|
+
strokeLinejoin: "round"
|
|
12919
|
+
}
|
|
12920
|
+
) }),
|
|
12921
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12922
|
+
"path",
|
|
12923
|
+
{
|
|
12924
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12925
|
+
stroke: "#A1A1AA",
|
|
12926
|
+
strokeWidth: "1.5",
|
|
12927
|
+
strokeLinecap: "round",
|
|
12928
|
+
strokeLinejoin: "round"
|
|
12929
|
+
}
|
|
12930
|
+
) }),
|
|
12931
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12932
|
+
"path",
|
|
12933
|
+
{
|
|
12934
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12935
|
+
stroke: "#A1A1AA",
|
|
12936
|
+
strokeWidth: "1.5",
|
|
12937
|
+
strokeLinecap: "round",
|
|
12938
|
+
strokeLinejoin: "round"
|
|
12939
|
+
}
|
|
12940
|
+
) }),
|
|
12941
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12942
|
+
"path",
|
|
12943
|
+
{
|
|
12944
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12945
|
+
stroke: "#A1A1AA",
|
|
12946
|
+
strokeWidth: "1.5",
|
|
12947
|
+
strokeLinecap: "round",
|
|
12948
|
+
strokeLinejoin: "round"
|
|
12949
|
+
}
|
|
12950
|
+
) }),
|
|
12951
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12952
|
+
"path",
|
|
12953
|
+
{
|
|
12954
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12955
|
+
stroke: "#A1A1AA",
|
|
12956
|
+
strokeWidth: "1.5",
|
|
12957
|
+
strokeLinecap: "round",
|
|
12958
|
+
strokeLinejoin: "round"
|
|
12959
|
+
}
|
|
12960
|
+
) }),
|
|
12961
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12962
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12963
|
+
"rect",
|
|
12882
12964
|
{
|
|
12883
|
-
|
|
12884
|
-
|
|
12965
|
+
width: "12",
|
|
12966
|
+
height: "12",
|
|
12967
|
+
fill: "white",
|
|
12968
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12885
12969
|
}
|
|
12886
|
-
)
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
sortAscLabel: "Oldest first",
|
|
12890
|
-
sortDescLabel: "Newest first"
|
|
12891
|
-
}),
|
|
12892
|
-
columnHelper.accessor("created_at", {
|
|
12893
|
-
header: "Created",
|
|
12894
|
-
cell: ({ getValue }) => {
|
|
12895
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12896
|
-
ui.Tooltip,
|
|
12970
|
+
) }),
|
|
12971
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12972
|
+
"rect",
|
|
12897
12973
|
{
|
|
12898
|
-
|
|
12899
|
-
|
|
12974
|
+
width: "12",
|
|
12975
|
+
height: "12",
|
|
12976
|
+
fill: "white",
|
|
12977
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12900
12978
|
}
|
|
12901
|
-
)
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
}
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
}
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Content, { children: [
|
|
12943
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
12944
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
|
|
12945
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12946
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
|
|
12947
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
|
|
12948
|
-
] }),
|
|
12949
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12950
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12951
|
-
Form$2.Field,
|
|
12952
|
-
{
|
|
12953
|
-
control: form.control,
|
|
12954
|
-
name: "title",
|
|
12955
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12956
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12957
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
|
|
12958
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
|
|
12959
|
-
] }),
|
|
12960
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12961
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12962
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12963
|
-
] })
|
|
12964
|
-
] }) })
|
|
12965
|
-
}
|
|
12966
|
-
),
|
|
12967
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12968
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12969
|
-
Form$2.Field,
|
|
12970
|
-
{
|
|
12971
|
-
control: form.control,
|
|
12972
|
-
name: "unit_price",
|
|
12973
|
-
render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12974
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12975
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
|
|
12976
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
|
|
12977
|
-
] }),
|
|
12978
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12979
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12980
|
-
ui.CurrencyInput,
|
|
12981
|
-
{
|
|
12982
|
-
symbol: getNativeSymbol(currencyCode),
|
|
12983
|
-
code: currencyCode,
|
|
12984
|
-
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
|
|
12985
|
-
...field
|
|
12986
|
-
}
|
|
12987
|
-
) }),
|
|
12988
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12989
|
-
] })
|
|
12990
|
-
] }) })
|
|
12991
|
-
}
|
|
12992
|
-
),
|
|
12993
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12994
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12995
|
-
Form$2.Field,
|
|
12996
|
-
{
|
|
12997
|
-
control: form.control,
|
|
12998
|
-
name: "quantity",
|
|
12999
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
13000
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
13001
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
|
|
13002
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
13003
|
-
] }),
|
|
13004
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 w-full", children: [
|
|
13005
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
13006
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13007
|
-
] })
|
|
13008
|
-
] }) })
|
|
13009
|
-
}
|
|
13010
|
-
)
|
|
13011
|
-
] }) }) }),
|
|
13012
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2 justify-end", children: [
|
|
13013
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
13014
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
13015
|
-
] }) })
|
|
13016
|
-
] }) }) });
|
|
12979
|
+
) }),
|
|
12980
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12981
|
+
"rect",
|
|
12982
|
+
{
|
|
12983
|
+
width: "12",
|
|
12984
|
+
height: "12",
|
|
12985
|
+
fill: "white",
|
|
12986
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12987
|
+
}
|
|
12988
|
+
) }),
|
|
12989
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12990
|
+
"rect",
|
|
12991
|
+
{
|
|
12992
|
+
width: "12",
|
|
12993
|
+
height: "12",
|
|
12994
|
+
fill: "white",
|
|
12995
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12996
|
+
}
|
|
12997
|
+
) }),
|
|
12998
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12999
|
+
"rect",
|
|
13000
|
+
{
|
|
13001
|
+
width: "12",
|
|
13002
|
+
height: "12",
|
|
13003
|
+
fill: "white",
|
|
13004
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13005
|
+
}
|
|
13006
|
+
) }),
|
|
13007
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13008
|
+
"rect",
|
|
13009
|
+
{
|
|
13010
|
+
width: "12",
|
|
13011
|
+
height: "12",
|
|
13012
|
+
fill: "white",
|
|
13013
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13014
|
+
}
|
|
13015
|
+
) })
|
|
13016
|
+
] })
|
|
13017
|
+
]
|
|
13018
|
+
}
|
|
13019
|
+
);
|
|
13017
13020
|
};
|
|
13018
|
-
const
|
|
13019
|
-
|
|
13020
|
-
quantity: numberType(),
|
|
13021
|
-
unit_price: unionType([numberType(), stringType()])
|
|
13021
|
+
const schema = objectType({
|
|
13022
|
+
customer_id: stringType().min(1)
|
|
13022
13023
|
});
|
|
13023
13024
|
const widgetModule = { widgets: [] };
|
|
13024
13025
|
const routeModule = {
|
|
@@ -13040,18 +13041,14 @@ const routeModule = {
|
|
|
13040
13041
|
handle,
|
|
13041
13042
|
loader,
|
|
13042
13043
|
children: [
|
|
13043
|
-
{
|
|
13044
|
-
Component: CustomItems,
|
|
13045
|
-
path: "/draft-orders/:id/custom-items"
|
|
13046
|
-
},
|
|
13047
|
-
{
|
|
13048
|
-
Component: Email,
|
|
13049
|
-
path: "/draft-orders/:id/email"
|
|
13050
|
-
},
|
|
13051
13044
|
{
|
|
13052
13045
|
Component: BillingAddress,
|
|
13053
13046
|
path: "/draft-orders/:id/billing-address"
|
|
13054
13047
|
},
|
|
13048
|
+
{
|
|
13049
|
+
Component: CustomItems,
|
|
13050
|
+
path: "/draft-orders/:id/custom-items"
|
|
13051
|
+
},
|
|
13055
13052
|
{
|
|
13056
13053
|
Component: Metadata,
|
|
13057
13054
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13072,13 +13069,17 @@ const routeModule = {
|
|
|
13072
13069
|
Component: ShippingAddress,
|
|
13073
13070
|
path: "/draft-orders/:id/shipping-address"
|
|
13074
13071
|
},
|
|
13075
|
-
{
|
|
13076
|
-
Component: TransferOwnership,
|
|
13077
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
13078
|
-
},
|
|
13079
13072
|
{
|
|
13080
13073
|
Component: Items,
|
|
13081
13074
|
path: "/draft-orders/:id/items"
|
|
13075
|
+
},
|
|
13076
|
+
{
|
|
13077
|
+
Component: Email,
|
|
13078
|
+
path: "/draft-orders/:id/email"
|
|
13079
|
+
},
|
|
13080
|
+
{
|
|
13081
|
+
Component: TransferOwnership,
|
|
13082
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13082
13083
|
}
|
|
13083
13084
|
]
|
|
13084
13085
|
}
|