@medusajs/draft-order 2.11.3-preview-20251031120214 → 2.11.3-preview-20251031180155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +946 -945
- package/.medusa/server/src/admin/index.mjs +944 -944
- package/package.json +54 -23
|
@@ -14,14 +14,15 @@ const reactHookForm = require("react-hook-form");
|
|
|
14
14
|
const radixUi = require("radix-ui");
|
|
15
15
|
const react = require("@ariakit/react");
|
|
16
16
|
const matchSorter = require("match-sorter");
|
|
17
|
-
const debounce = require("lodash
|
|
17
|
+
const debounce = require("lodash.debounce");
|
|
18
18
|
const Primitive = require("@uiw/react-json-view");
|
|
19
|
-
const
|
|
19
|
+
const isEqual = require("lodash.isequal");
|
|
20
20
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
21
21
|
const React__default = /* @__PURE__ */ _interopDefault(React);
|
|
22
22
|
const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
|
|
23
23
|
const debounce__default = /* @__PURE__ */ _interopDefault(debounce);
|
|
24
24
|
const Primitive__default = /* @__PURE__ */ _interopDefault(Primitive);
|
|
25
|
+
const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
|
|
25
26
|
function useQueryParams(keys, prefix) {
|
|
26
27
|
const [params] = reactRouterDom.useSearchParams();
|
|
27
28
|
const result = {};
|
|
@@ -9571,6 +9572,196 @@ const ID = () => {
|
|
|
9571
9572
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9572
9573
|
] });
|
|
9573
9574
|
};
|
|
9575
|
+
const BillingAddress = () => {
|
|
9576
|
+
const { id } = reactRouterDom.useParams();
|
|
9577
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9578
|
+
fields: "+billing_address"
|
|
9579
|
+
});
|
|
9580
|
+
if (isError) {
|
|
9581
|
+
throw error;
|
|
9582
|
+
}
|
|
9583
|
+
const isReady = !isPending && !!order;
|
|
9584
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9585
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9586
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9588
|
+
] }),
|
|
9589
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9590
|
+
] });
|
|
9591
|
+
};
|
|
9592
|
+
const BillingAddressForm = ({ order }) => {
|
|
9593
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9594
|
+
const form = reactHookForm.useForm({
|
|
9595
|
+
defaultValues: {
|
|
9596
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9597
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9598
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9599
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9600
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9601
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9602
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9603
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9604
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9605
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9606
|
+
},
|
|
9607
|
+
resolver: zod.zodResolver(schema$5)
|
|
9608
|
+
});
|
|
9609
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9610
|
+
const { handleSuccess } = useRouteModal();
|
|
9611
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9612
|
+
await mutateAsync(
|
|
9613
|
+
{ billing_address: data },
|
|
9614
|
+
{
|
|
9615
|
+
onSuccess: () => {
|
|
9616
|
+
handleSuccess();
|
|
9617
|
+
},
|
|
9618
|
+
onError: (error) => {
|
|
9619
|
+
ui.toast.error(error.message);
|
|
9620
|
+
}
|
|
9621
|
+
}
|
|
9622
|
+
);
|
|
9623
|
+
});
|
|
9624
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9625
|
+
KeyboundForm,
|
|
9626
|
+
{
|
|
9627
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9628
|
+
onSubmit,
|
|
9629
|
+
children: [
|
|
9630
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9631
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9632
|
+
Form$2.Field,
|
|
9633
|
+
{
|
|
9634
|
+
control: form.control,
|
|
9635
|
+
name: "country_code",
|
|
9636
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9637
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9638
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9639
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9640
|
+
] })
|
|
9641
|
+
}
|
|
9642
|
+
),
|
|
9643
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9644
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9645
|
+
Form$2.Field,
|
|
9646
|
+
{
|
|
9647
|
+
control: form.control,
|
|
9648
|
+
name: "first_name",
|
|
9649
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9650
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9651
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9652
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9653
|
+
] })
|
|
9654
|
+
}
|
|
9655
|
+
),
|
|
9656
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9657
|
+
Form$2.Field,
|
|
9658
|
+
{
|
|
9659
|
+
control: form.control,
|
|
9660
|
+
name: "last_name",
|
|
9661
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9662
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9663
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9664
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9665
|
+
] })
|
|
9666
|
+
}
|
|
9667
|
+
)
|
|
9668
|
+
] }),
|
|
9669
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9670
|
+
Form$2.Field,
|
|
9671
|
+
{
|
|
9672
|
+
control: form.control,
|
|
9673
|
+
name: "company",
|
|
9674
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9677
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9678
|
+
] })
|
|
9679
|
+
}
|
|
9680
|
+
),
|
|
9681
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9682
|
+
Form$2.Field,
|
|
9683
|
+
{
|
|
9684
|
+
control: form.control,
|
|
9685
|
+
name: "address_1",
|
|
9686
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9687
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9689
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9690
|
+
] })
|
|
9691
|
+
}
|
|
9692
|
+
),
|
|
9693
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9694
|
+
Form$2.Field,
|
|
9695
|
+
{
|
|
9696
|
+
control: form.control,
|
|
9697
|
+
name: "address_2",
|
|
9698
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9699
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9700
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9701
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9702
|
+
] })
|
|
9703
|
+
}
|
|
9704
|
+
),
|
|
9705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9707
|
+
Form$2.Field,
|
|
9708
|
+
{
|
|
9709
|
+
control: form.control,
|
|
9710
|
+
name: "postal_code",
|
|
9711
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9712
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9713
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9714
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9715
|
+
] })
|
|
9716
|
+
}
|
|
9717
|
+
),
|
|
9718
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9719
|
+
Form$2.Field,
|
|
9720
|
+
{
|
|
9721
|
+
control: form.control,
|
|
9722
|
+
name: "city",
|
|
9723
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9724
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9725
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9726
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9727
|
+
] })
|
|
9728
|
+
}
|
|
9729
|
+
)
|
|
9730
|
+
] }),
|
|
9731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9732
|
+
Form$2.Field,
|
|
9733
|
+
{
|
|
9734
|
+
control: form.control,
|
|
9735
|
+
name: "province",
|
|
9736
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9739
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9740
|
+
] })
|
|
9741
|
+
}
|
|
9742
|
+
),
|
|
9743
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9744
|
+
Form$2.Field,
|
|
9745
|
+
{
|
|
9746
|
+
control: form.control,
|
|
9747
|
+
name: "phone",
|
|
9748
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9749
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9750
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9751
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9752
|
+
] })
|
|
9753
|
+
}
|
|
9754
|
+
)
|
|
9755
|
+
] }) }),
|
|
9756
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9757
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9758
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9759
|
+
] }) })
|
|
9760
|
+
]
|
|
9761
|
+
}
|
|
9762
|
+
) });
|
|
9763
|
+
};
|
|
9764
|
+
const schema$5 = addressSchema;
|
|
9574
9765
|
const CustomItems = () => {
|
|
9575
9766
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9576
9767
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9579,7 +9770,7 @@ const CustomItems = () => {
|
|
|
9579
9770
|
};
|
|
9580
9771
|
const CustomItemsForm = () => {
|
|
9581
9772
|
const form = reactHookForm.useForm({
|
|
9582
|
-
resolver: zod.zodResolver(schema$
|
|
9773
|
+
resolver: zod.zodResolver(schema$4)
|
|
9583
9774
|
});
|
|
9584
9775
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9585
9776
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9589,45 +9780,113 @@ const CustomItemsForm = () => {
|
|
|
9589
9780
|
] }) })
|
|
9590
9781
|
] }) });
|
|
9591
9782
|
};
|
|
9592
|
-
const schema$
|
|
9783
|
+
const schema$4 = objectType({
|
|
9593
9784
|
email: stringType().email()
|
|
9594
9785
|
});
|
|
9595
|
-
const
|
|
9596
|
-
(
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
}
|
|
9624
|
-
};
|
|
9625
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9626
|
-
"div",
|
|
9786
|
+
const Email = () => {
|
|
9787
|
+
const { id } = reactRouterDom.useParams();
|
|
9788
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9789
|
+
fields: "+email"
|
|
9790
|
+
});
|
|
9791
|
+
if (isError) {
|
|
9792
|
+
throw error;
|
|
9793
|
+
}
|
|
9794
|
+
const isReady = !isPending && !!order;
|
|
9795
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9796
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9797
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9798
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9799
|
+
] }),
|
|
9800
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9801
|
+
] });
|
|
9802
|
+
};
|
|
9803
|
+
const EmailForm = ({ order }) => {
|
|
9804
|
+
const form = reactHookForm.useForm({
|
|
9805
|
+
defaultValues: {
|
|
9806
|
+
email: order.email ?? ""
|
|
9807
|
+
},
|
|
9808
|
+
resolver: zod.zodResolver(schema$3)
|
|
9809
|
+
});
|
|
9810
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9811
|
+
const { handleSuccess } = useRouteModal();
|
|
9812
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9813
|
+
await mutateAsync(
|
|
9814
|
+
{ email: data.email },
|
|
9627
9815
|
{
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9816
|
+
onSuccess: () => {
|
|
9817
|
+
handleSuccess();
|
|
9818
|
+
},
|
|
9819
|
+
onError: (error) => {
|
|
9820
|
+
ui.toast.error(error.message);
|
|
9821
|
+
}
|
|
9822
|
+
}
|
|
9823
|
+
);
|
|
9824
|
+
});
|
|
9825
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9826
|
+
KeyboundForm,
|
|
9827
|
+
{
|
|
9828
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9829
|
+
onSubmit,
|
|
9830
|
+
children: [
|
|
9831
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9832
|
+
Form$2.Field,
|
|
9833
|
+
{
|
|
9834
|
+
control: form.control,
|
|
9835
|
+
name: "email",
|
|
9836
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9837
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9839
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9840
|
+
] })
|
|
9841
|
+
}
|
|
9842
|
+
) }),
|
|
9843
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9844
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9845
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9846
|
+
] }) })
|
|
9847
|
+
]
|
|
9848
|
+
}
|
|
9849
|
+
) });
|
|
9850
|
+
};
|
|
9851
|
+
const schema$3 = objectType({
|
|
9852
|
+
email: stringType().email()
|
|
9853
|
+
});
|
|
9854
|
+
const NumberInput = React.forwardRef(
|
|
9855
|
+
({
|
|
9856
|
+
value,
|
|
9857
|
+
onChange,
|
|
9858
|
+
size = "base",
|
|
9859
|
+
min = 0,
|
|
9860
|
+
max = 100,
|
|
9861
|
+
step = 1,
|
|
9862
|
+
className,
|
|
9863
|
+
disabled,
|
|
9864
|
+
...props
|
|
9865
|
+
}, ref) => {
|
|
9866
|
+
const handleChange = (event) => {
|
|
9867
|
+
const newValue = event.target.value === "" ? min : Number(event.target.value);
|
|
9868
|
+
if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
|
|
9869
|
+
onChange(newValue);
|
|
9870
|
+
}
|
|
9871
|
+
};
|
|
9872
|
+
const handleIncrement = () => {
|
|
9873
|
+
const newValue = value + step;
|
|
9874
|
+
if (max === void 0 || newValue <= max) {
|
|
9875
|
+
onChange(newValue);
|
|
9876
|
+
}
|
|
9877
|
+
};
|
|
9878
|
+
const handleDecrement = () => {
|
|
9879
|
+
const newValue = value - step;
|
|
9880
|
+
if (min === void 0 || newValue >= min) {
|
|
9881
|
+
onChange(newValue);
|
|
9882
|
+
}
|
|
9883
|
+
};
|
|
9884
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9885
|
+
"div",
|
|
9886
|
+
{
|
|
9887
|
+
className: ui.clx(
|
|
9888
|
+
"inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
|
|
9889
|
+
"[&:has(input:focus)]:shadow-borders-interactive-with-active",
|
|
9631
9890
|
{
|
|
9632
9891
|
"h-7": size === "small",
|
|
9633
9892
|
"h-8": size === "base"
|
|
@@ -10566,116 +10825,466 @@ const customItemSchema = objectType({
|
|
|
10566
10825
|
quantity: numberType(),
|
|
10567
10826
|
unit_price: unionType([numberType(), stringType()])
|
|
10568
10827
|
});
|
|
10569
|
-
const
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
}
|
|
10589
|
-
|
|
10828
|
+
const InlineTip = React.forwardRef(
|
|
10829
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10830
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10831
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10832
|
+
"div",
|
|
10833
|
+
{
|
|
10834
|
+
ref,
|
|
10835
|
+
className: ui.clx(
|
|
10836
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10837
|
+
className
|
|
10838
|
+
),
|
|
10839
|
+
...props,
|
|
10840
|
+
children: [
|
|
10841
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10842
|
+
"div",
|
|
10843
|
+
{
|
|
10844
|
+
role: "presentation",
|
|
10845
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10846
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10847
|
+
})
|
|
10848
|
+
}
|
|
10849
|
+
),
|
|
10850
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
10851
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10852
|
+
labelValue,
|
|
10853
|
+
":"
|
|
10854
|
+
] }),
|
|
10855
|
+
" ",
|
|
10856
|
+
children
|
|
10857
|
+
] })
|
|
10858
|
+
]
|
|
10859
|
+
}
|
|
10860
|
+
);
|
|
10861
|
+
}
|
|
10862
|
+
);
|
|
10863
|
+
InlineTip.displayName = "InlineTip";
|
|
10864
|
+
const MetadataFieldSchema = objectType({
|
|
10865
|
+
key: stringType(),
|
|
10866
|
+
disabled: booleanType().optional(),
|
|
10867
|
+
value: anyType()
|
|
10868
|
+
});
|
|
10869
|
+
const MetadataSchema = objectType({
|
|
10870
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10871
|
+
});
|
|
10872
|
+
const Metadata = () => {
|
|
10590
10873
|
const { id } = reactRouterDom.useParams();
|
|
10591
|
-
const {
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
useInitiateOrderEdit({ preview });
|
|
10597
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10598
|
-
if (isPreviewError) {
|
|
10599
|
-
throw previewError;
|
|
10874
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10875
|
+
fields: "metadata"
|
|
10876
|
+
});
|
|
10877
|
+
if (isError) {
|
|
10878
|
+
throw error;
|
|
10600
10879
|
}
|
|
10601
|
-
const isReady = !!
|
|
10602
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, {
|
|
10603
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10604
|
-
|
|
10880
|
+
const isReady = !isPending && !!order;
|
|
10881
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10882
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10883
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10884
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10885
|
+
] }),
|
|
10886
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10605
10887
|
] });
|
|
10606
10888
|
};
|
|
10607
|
-
const
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
10889
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10890
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10891
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10611
10892
|
const { handleSuccess } = useRouteModal();
|
|
10612
|
-
const
|
|
10613
|
-
const
|
|
10614
|
-
const
|
|
10615
|
-
{
|
|
10616
|
-
|
|
10617
|
-
},
|
|
10618
|
-
{
|
|
10619
|
-
enabled: !!promoIds.length
|
|
10620
|
-
}
|
|
10621
|
-
);
|
|
10622
|
-
const comboboxData = useComboboxData({
|
|
10623
|
-
queryKey: ["promotions", "combobox", promoIds],
|
|
10624
|
-
queryFn: async (params) => {
|
|
10625
|
-
return await sdk.admin.promotion.list({
|
|
10626
|
-
...params,
|
|
10627
|
-
id: {
|
|
10628
|
-
$nin: promoIds
|
|
10629
|
-
}
|
|
10630
|
-
});
|
|
10893
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10894
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10895
|
+
const form = reactHookForm.useForm({
|
|
10896
|
+
defaultValues: {
|
|
10897
|
+
metadata: getDefaultValues(metadata)
|
|
10631
10898
|
},
|
|
10632
|
-
|
|
10633
|
-
return data.promotions.map((promotion) => ({
|
|
10634
|
-
label: promotion.code,
|
|
10635
|
-
value: promotion.code
|
|
10636
|
-
}));
|
|
10637
|
-
}
|
|
10899
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
10638
10900
|
});
|
|
10639
|
-
const
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
}
|
|
10643
|
-
addPromotions(
|
|
10901
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10902
|
+
const parsedData = parseValues(data);
|
|
10903
|
+
await mutateAsync(
|
|
10644
10904
|
{
|
|
10645
|
-
|
|
10905
|
+
metadata: parsedData
|
|
10646
10906
|
},
|
|
10647
10907
|
{
|
|
10648
|
-
onError: (e) => {
|
|
10649
|
-
ui.toast.error(e.message);
|
|
10650
|
-
comboboxData.onSearchValueChange("");
|
|
10651
|
-
setComboboxValue("");
|
|
10652
|
-
},
|
|
10653
10908
|
onSuccess: () => {
|
|
10654
|
-
|
|
10655
|
-
|
|
10909
|
+
ui.toast.success("Metadata updated");
|
|
10910
|
+
handleSuccess();
|
|
10911
|
+
},
|
|
10912
|
+
onError: (error) => {
|
|
10913
|
+
ui.toast.error(error.message);
|
|
10656
10914
|
}
|
|
10657
10915
|
}
|
|
10658
10916
|
);
|
|
10659
|
-
};
|
|
10660
|
-
const {
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
}
|
|
10672
|
-
});
|
|
10673
|
-
if (!requestSucceeded) {
|
|
10674
|
-
setIsSubmitting(false);
|
|
10675
|
-
return;
|
|
10917
|
+
});
|
|
10918
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
10919
|
+
control: form.control,
|
|
10920
|
+
name: "metadata"
|
|
10921
|
+
});
|
|
10922
|
+
function deleteRow(index) {
|
|
10923
|
+
remove(index);
|
|
10924
|
+
if (fields.length === 1) {
|
|
10925
|
+
insert(0, {
|
|
10926
|
+
key: "",
|
|
10927
|
+
value: "",
|
|
10928
|
+
disabled: false
|
|
10929
|
+
});
|
|
10676
10930
|
}
|
|
10677
|
-
|
|
10678
|
-
|
|
10931
|
+
}
|
|
10932
|
+
function insertRow(index, position) {
|
|
10933
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10934
|
+
key: "",
|
|
10935
|
+
value: "",
|
|
10936
|
+
disabled: false
|
|
10937
|
+
});
|
|
10938
|
+
}
|
|
10939
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10940
|
+
KeyboundForm,
|
|
10941
|
+
{
|
|
10942
|
+
onSubmit: handleSubmit,
|
|
10943
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10944
|
+
children: [
|
|
10945
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10946
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10948
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
10949
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
10950
|
+
] }),
|
|
10951
|
+
fields.map((field, index) => {
|
|
10952
|
+
const isDisabled = field.disabled || false;
|
|
10953
|
+
let placeholder = "-";
|
|
10954
|
+
if (typeof field.value === "object") {
|
|
10955
|
+
placeholder = "{ ... }";
|
|
10956
|
+
}
|
|
10957
|
+
if (Array.isArray(field.value)) {
|
|
10958
|
+
placeholder = "[ ... ]";
|
|
10959
|
+
}
|
|
10960
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10961
|
+
ConditionalTooltip,
|
|
10962
|
+
{
|
|
10963
|
+
showTooltip: isDisabled,
|
|
10964
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
10965
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10966
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10967
|
+
"div",
|
|
10968
|
+
{
|
|
10969
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10970
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10971
|
+
}),
|
|
10972
|
+
children: [
|
|
10973
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10974
|
+
Form$2.Field,
|
|
10975
|
+
{
|
|
10976
|
+
control: form.control,
|
|
10977
|
+
name: `metadata.${index}.key`,
|
|
10978
|
+
render: ({ field: field2 }) => {
|
|
10979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10980
|
+
GridInput,
|
|
10981
|
+
{
|
|
10982
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10983
|
+
...field2,
|
|
10984
|
+
disabled: isDisabled,
|
|
10985
|
+
placeholder: "Key"
|
|
10986
|
+
}
|
|
10987
|
+
) }) });
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
),
|
|
10991
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10992
|
+
Form$2.Field,
|
|
10993
|
+
{
|
|
10994
|
+
control: form.control,
|
|
10995
|
+
name: `metadata.${index}.value`,
|
|
10996
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10997
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10998
|
+
GridInput,
|
|
10999
|
+
{
|
|
11000
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11001
|
+
...field2,
|
|
11002
|
+
value: isDisabled ? placeholder : value,
|
|
11003
|
+
disabled: isDisabled,
|
|
11004
|
+
placeholder: "Value"
|
|
11005
|
+
}
|
|
11006
|
+
) }) });
|
|
11007
|
+
}
|
|
11008
|
+
}
|
|
11009
|
+
)
|
|
11010
|
+
]
|
|
11011
|
+
}
|
|
11012
|
+
),
|
|
11013
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11014
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11015
|
+
ui.DropdownMenu.Trigger,
|
|
11016
|
+
{
|
|
11017
|
+
className: ui.clx(
|
|
11018
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11019
|
+
{
|
|
11020
|
+
hidden: isDisabled
|
|
11021
|
+
}
|
|
11022
|
+
),
|
|
11023
|
+
disabled: isDisabled,
|
|
11024
|
+
asChild: true,
|
|
11025
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11026
|
+
}
|
|
11027
|
+
),
|
|
11028
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11029
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11030
|
+
ui.DropdownMenu.Item,
|
|
11031
|
+
{
|
|
11032
|
+
className: "gap-x-2",
|
|
11033
|
+
onClick: () => insertRow(index, "above"),
|
|
11034
|
+
children: [
|
|
11035
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11036
|
+
"Insert row above"
|
|
11037
|
+
]
|
|
11038
|
+
}
|
|
11039
|
+
),
|
|
11040
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11041
|
+
ui.DropdownMenu.Item,
|
|
11042
|
+
{
|
|
11043
|
+
className: "gap-x-2",
|
|
11044
|
+
onClick: () => insertRow(index, "below"),
|
|
11045
|
+
children: [
|
|
11046
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11047
|
+
"Insert row below"
|
|
11048
|
+
]
|
|
11049
|
+
}
|
|
11050
|
+
),
|
|
11051
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11052
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11053
|
+
ui.DropdownMenu.Item,
|
|
11054
|
+
{
|
|
11055
|
+
className: "gap-x-2",
|
|
11056
|
+
onClick: () => deleteRow(index),
|
|
11057
|
+
children: [
|
|
11058
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11059
|
+
"Delete row"
|
|
11060
|
+
]
|
|
11061
|
+
}
|
|
11062
|
+
)
|
|
11063
|
+
] })
|
|
11064
|
+
] })
|
|
11065
|
+
] })
|
|
11066
|
+
},
|
|
11067
|
+
field.id
|
|
11068
|
+
);
|
|
11069
|
+
})
|
|
11070
|
+
] }),
|
|
11071
|
+
hasUneditableRows && /* @__PURE__ */ jsxRuntime.jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
11072
|
+
] }),
|
|
11073
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11074
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11075
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11076
|
+
] }) })
|
|
11077
|
+
]
|
|
11078
|
+
}
|
|
11079
|
+
) });
|
|
11080
|
+
};
|
|
11081
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
11082
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11083
|
+
"input",
|
|
11084
|
+
{
|
|
11085
|
+
ref,
|
|
11086
|
+
...props,
|
|
11087
|
+
autoComplete: "off",
|
|
11088
|
+
className: ui.clx(
|
|
11089
|
+
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
11090
|
+
className
|
|
11091
|
+
)
|
|
11092
|
+
}
|
|
11093
|
+
);
|
|
11094
|
+
});
|
|
11095
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
11096
|
+
const PlaceholderInner = () => {
|
|
11097
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11098
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11099
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11100
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11101
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11102
|
+
] }) })
|
|
11103
|
+
] });
|
|
11104
|
+
};
|
|
11105
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
11106
|
+
function getDefaultValues(metadata) {
|
|
11107
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
11108
|
+
return [
|
|
11109
|
+
{
|
|
11110
|
+
key: "",
|
|
11111
|
+
value: "",
|
|
11112
|
+
disabled: false
|
|
11113
|
+
}
|
|
11114
|
+
];
|
|
11115
|
+
}
|
|
11116
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
11117
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11118
|
+
return {
|
|
11119
|
+
key,
|
|
11120
|
+
value,
|
|
11121
|
+
disabled: true
|
|
11122
|
+
};
|
|
11123
|
+
}
|
|
11124
|
+
let stringValue = value;
|
|
11125
|
+
if (typeof value !== "string") {
|
|
11126
|
+
stringValue = JSON.stringify(value);
|
|
11127
|
+
}
|
|
11128
|
+
return {
|
|
11129
|
+
key,
|
|
11130
|
+
value: stringValue,
|
|
11131
|
+
original_key: key
|
|
11132
|
+
};
|
|
11133
|
+
});
|
|
11134
|
+
}
|
|
11135
|
+
function parseValues(values) {
|
|
11136
|
+
const metadata = values.metadata;
|
|
11137
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11138
|
+
if (isEmpty) {
|
|
11139
|
+
return null;
|
|
11140
|
+
}
|
|
11141
|
+
const update = {};
|
|
11142
|
+
metadata.forEach((field) => {
|
|
11143
|
+
let key = field.key;
|
|
11144
|
+
let value = field.value;
|
|
11145
|
+
const disabled = field.disabled;
|
|
11146
|
+
if (!key || !value) {
|
|
11147
|
+
return;
|
|
11148
|
+
}
|
|
11149
|
+
if (disabled) {
|
|
11150
|
+
update[key] = value;
|
|
11151
|
+
return;
|
|
11152
|
+
}
|
|
11153
|
+
key = key.trim();
|
|
11154
|
+
value = value.trim();
|
|
11155
|
+
if (value === "true") {
|
|
11156
|
+
update[key] = true;
|
|
11157
|
+
} else if (value === "false") {
|
|
11158
|
+
update[key] = false;
|
|
11159
|
+
} else {
|
|
11160
|
+
const parsedNumber = parseFloat(value);
|
|
11161
|
+
if (!isNaN(parsedNumber)) {
|
|
11162
|
+
update[key] = parsedNumber;
|
|
11163
|
+
} else {
|
|
11164
|
+
update[key] = value;
|
|
11165
|
+
}
|
|
11166
|
+
}
|
|
11167
|
+
});
|
|
11168
|
+
return update;
|
|
11169
|
+
}
|
|
11170
|
+
function getHasUneditableRows(metadata) {
|
|
11171
|
+
if (!metadata) {
|
|
11172
|
+
return false;
|
|
11173
|
+
}
|
|
11174
|
+
return Object.values(metadata).some(
|
|
11175
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11176
|
+
);
|
|
11177
|
+
}
|
|
11178
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
11179
|
+
const promotionsQueryKeys = {
|
|
11180
|
+
list: (query2) => [
|
|
11181
|
+
PROMOTION_QUERY_KEY,
|
|
11182
|
+
query2 ? query2 : void 0
|
|
11183
|
+
],
|
|
11184
|
+
detail: (id, query2) => [
|
|
11185
|
+
PROMOTION_QUERY_KEY,
|
|
11186
|
+
id,
|
|
11187
|
+
query2 ? query2 : void 0
|
|
11188
|
+
]
|
|
11189
|
+
};
|
|
11190
|
+
const usePromotions = (query2, options) => {
|
|
11191
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
11192
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
11193
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11194
|
+
...options
|
|
11195
|
+
});
|
|
11196
|
+
return { ...data, ...rest };
|
|
11197
|
+
};
|
|
11198
|
+
const Promotions = () => {
|
|
11199
|
+
const { id } = reactRouterDom.useParams();
|
|
11200
|
+
const {
|
|
11201
|
+
order: preview,
|
|
11202
|
+
isError: isPreviewError,
|
|
11203
|
+
error: previewError
|
|
11204
|
+
} = useOrderPreview(id, void 0);
|
|
11205
|
+
useInitiateOrderEdit({ preview });
|
|
11206
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11207
|
+
if (isPreviewError) {
|
|
11208
|
+
throw previewError;
|
|
11209
|
+
}
|
|
11210
|
+
const isReady = !!preview;
|
|
11211
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11212
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
11213
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11214
|
+
] });
|
|
11215
|
+
};
|
|
11216
|
+
const PromotionForm = ({ preview }) => {
|
|
11217
|
+
const { items, shipping_methods } = preview;
|
|
11218
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11219
|
+
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
11220
|
+
const { handleSuccess } = useRouteModal();
|
|
11221
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11222
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11223
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
11224
|
+
{
|
|
11225
|
+
id: promoIds
|
|
11226
|
+
},
|
|
11227
|
+
{
|
|
11228
|
+
enabled: !!promoIds.length
|
|
11229
|
+
}
|
|
11230
|
+
);
|
|
11231
|
+
const comboboxData = useComboboxData({
|
|
11232
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
11233
|
+
queryFn: async (params) => {
|
|
11234
|
+
return await sdk.admin.promotion.list({
|
|
11235
|
+
...params,
|
|
11236
|
+
id: {
|
|
11237
|
+
$nin: promoIds
|
|
11238
|
+
}
|
|
11239
|
+
});
|
|
11240
|
+
},
|
|
11241
|
+
getOptions: (data) => {
|
|
11242
|
+
return data.promotions.map((promotion) => ({
|
|
11243
|
+
label: promotion.code,
|
|
11244
|
+
value: promotion.code
|
|
11245
|
+
}));
|
|
11246
|
+
}
|
|
11247
|
+
});
|
|
11248
|
+
const add = async (value) => {
|
|
11249
|
+
if (!value) {
|
|
11250
|
+
return;
|
|
11251
|
+
}
|
|
11252
|
+
addPromotions(
|
|
11253
|
+
{
|
|
11254
|
+
promo_codes: [value]
|
|
11255
|
+
},
|
|
11256
|
+
{
|
|
11257
|
+
onError: (e) => {
|
|
11258
|
+
ui.toast.error(e.message);
|
|
11259
|
+
comboboxData.onSearchValueChange("");
|
|
11260
|
+
setComboboxValue("");
|
|
11261
|
+
},
|
|
11262
|
+
onSuccess: () => {
|
|
11263
|
+
comboboxData.onSearchValueChange("");
|
|
11264
|
+
setComboboxValue("");
|
|
11265
|
+
}
|
|
11266
|
+
}
|
|
11267
|
+
);
|
|
11268
|
+
};
|
|
11269
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11270
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
11271
|
+
const onSubmit = async () => {
|
|
11272
|
+
setIsSubmitting(true);
|
|
11273
|
+
let requestSucceeded = false;
|
|
11274
|
+
await requestOrderEdit(void 0, {
|
|
11275
|
+
onError: (e) => {
|
|
11276
|
+
ui.toast.error(e.message);
|
|
11277
|
+
},
|
|
11278
|
+
onSuccess: () => {
|
|
11279
|
+
requestSucceeded = true;
|
|
11280
|
+
}
|
|
11281
|
+
});
|
|
11282
|
+
if (!requestSucceeded) {
|
|
11283
|
+
setIsSubmitting(false);
|
|
11284
|
+
return;
|
|
11285
|
+
}
|
|
11286
|
+
await confirmOrderEdit(void 0, {
|
|
11287
|
+
onError: (e) => {
|
|
10679
11288
|
ui.toast.error(e.message);
|
|
10680
11289
|
},
|
|
10681
11290
|
onSuccess: () => {
|
|
@@ -10705,493 +11314,143 @@ const PromotionForm = ({ preview }) => {
|
|
|
10705
11314
|
fetchNextPage: comboboxData.fetchNextPage,
|
|
10706
11315
|
options: comboboxData.options,
|
|
10707
11316
|
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
10708
|
-
searchValue: comboboxData.searchValue,
|
|
10709
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
10710
|
-
onChange: add,
|
|
10711
|
-
value: comboboxValue
|
|
10712
|
-
}
|
|
10713
|
-
)
|
|
10714
|
-
] }),
|
|
10715
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10716
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
10717
|
-
PromotionItem,
|
|
10718
|
-
{
|
|
10719
|
-
promotion,
|
|
10720
|
-
orderId: preview.id,
|
|
10721
|
-
isLoading: isPending
|
|
10722
|
-
},
|
|
10723
|
-
promotion.id
|
|
10724
|
-
)) })
|
|
10725
|
-
] }) }),
|
|
10726
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10727
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10728
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10729
|
-
ui.Button,
|
|
10730
|
-
{
|
|
10731
|
-
size: "small",
|
|
10732
|
-
type: "submit",
|
|
10733
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
10734
|
-
children: "Save"
|
|
10735
|
-
}
|
|
10736
|
-
)
|
|
10737
|
-
] }) })
|
|
10738
|
-
] });
|
|
10739
|
-
};
|
|
10740
|
-
const PromotionItem = ({
|
|
10741
|
-
promotion,
|
|
10742
|
-
orderId,
|
|
10743
|
-
isLoading
|
|
10744
|
-
}) => {
|
|
10745
|
-
var _a;
|
|
10746
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
10747
|
-
const onRemove = async () => {
|
|
10748
|
-
removePromotions(
|
|
10749
|
-
{
|
|
10750
|
-
promo_codes: [promotion.code]
|
|
10751
|
-
},
|
|
10752
|
-
{
|
|
10753
|
-
onError: (e) => {
|
|
10754
|
-
ui.toast.error(e.message);
|
|
10755
|
-
}
|
|
10756
|
-
}
|
|
10757
|
-
);
|
|
10758
|
-
};
|
|
10759
|
-
const displayValue = getDisplayValue(promotion);
|
|
10760
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10761
|
-
"div",
|
|
10762
|
-
{
|
|
10763
|
-
className: ui.clx(
|
|
10764
|
-
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
10765
|
-
{
|
|
10766
|
-
"animate-pulse": isLoading
|
|
10767
|
-
}
|
|
10768
|
-
),
|
|
10769
|
-
children: [
|
|
10770
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10771
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
10772
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
10773
|
-
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
10774
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
10775
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
10776
|
-
] }),
|
|
10777
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
10778
|
-
] })
|
|
10779
|
-
] }),
|
|
10780
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10781
|
-
ui.IconButton,
|
|
10782
|
-
{
|
|
10783
|
-
size: "small",
|
|
10784
|
-
type: "button",
|
|
10785
|
-
variant: "transparent",
|
|
10786
|
-
onClick: onRemove,
|
|
10787
|
-
isLoading: isPending || isLoading,
|
|
10788
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
10789
|
-
}
|
|
10790
|
-
)
|
|
10791
|
-
]
|
|
10792
|
-
},
|
|
10793
|
-
promotion.id
|
|
10794
|
-
);
|
|
10795
|
-
};
|
|
10796
|
-
function getDisplayValue(promotion) {
|
|
10797
|
-
var _a, _b, _c, _d;
|
|
10798
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
10799
|
-
if (!value) {
|
|
10800
|
-
return null;
|
|
10801
|
-
}
|
|
10802
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
10803
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
10804
|
-
if (!currency) {
|
|
10805
|
-
return null;
|
|
10806
|
-
}
|
|
10807
|
-
return getLocaleAmount(value, currency);
|
|
10808
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
10809
|
-
return formatPercentage(value);
|
|
10810
|
-
}
|
|
10811
|
-
return null;
|
|
10812
|
-
}
|
|
10813
|
-
const formatter = new Intl.NumberFormat([], {
|
|
10814
|
-
style: "percent",
|
|
10815
|
-
minimumFractionDigits: 2
|
|
10816
|
-
});
|
|
10817
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
10818
|
-
let val = value || 0;
|
|
10819
|
-
if (!isPercentageValue) {
|
|
10820
|
-
val = val / 100;
|
|
10821
|
-
}
|
|
10822
|
-
return formatter.format(val);
|
|
10823
|
-
};
|
|
10824
|
-
function getPromotionIds(items, shippingMethods) {
|
|
10825
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
10826
|
-
for (const item of items) {
|
|
10827
|
-
if (item.adjustments) {
|
|
10828
|
-
for (const adjustment of item.adjustments) {
|
|
10829
|
-
if (adjustment.promotion_id) {
|
|
10830
|
-
promotionIds.add(adjustment.promotion_id);
|
|
10831
|
-
}
|
|
10832
|
-
}
|
|
10833
|
-
}
|
|
10834
|
-
}
|
|
10835
|
-
for (const shippingMethod of shippingMethods) {
|
|
10836
|
-
if (shippingMethod.adjustments) {
|
|
10837
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
10838
|
-
if (adjustment.promotion_id) {
|
|
10839
|
-
promotionIds.add(adjustment.promotion_id);
|
|
10840
|
-
}
|
|
10841
|
-
}
|
|
10842
|
-
}
|
|
10843
|
-
}
|
|
10844
|
-
return Array.from(promotionIds);
|
|
10845
|
-
}
|
|
10846
|
-
const InlineTip = React.forwardRef(
|
|
10847
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10848
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10849
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10850
|
-
"div",
|
|
10851
|
-
{
|
|
10852
|
-
ref,
|
|
10853
|
-
className: ui.clx(
|
|
10854
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10855
|
-
className
|
|
10856
|
-
),
|
|
10857
|
-
...props,
|
|
10858
|
-
children: [
|
|
10859
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10860
|
-
"div",
|
|
10861
|
-
{
|
|
10862
|
-
role: "presentation",
|
|
10863
|
-
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10864
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10865
|
-
})
|
|
10866
|
-
}
|
|
10867
|
-
),
|
|
10868
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
10869
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10870
|
-
labelValue,
|
|
10871
|
-
":"
|
|
10872
|
-
] }),
|
|
10873
|
-
" ",
|
|
10874
|
-
children
|
|
10875
|
-
] })
|
|
10876
|
-
]
|
|
10877
|
-
}
|
|
10878
|
-
);
|
|
10879
|
-
}
|
|
10880
|
-
);
|
|
10881
|
-
InlineTip.displayName = "InlineTip";
|
|
10882
|
-
const MetadataFieldSchema = objectType({
|
|
10883
|
-
key: stringType(),
|
|
10884
|
-
disabled: booleanType().optional(),
|
|
10885
|
-
value: anyType()
|
|
10886
|
-
});
|
|
10887
|
-
const MetadataSchema = objectType({
|
|
10888
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
10889
|
-
});
|
|
10890
|
-
const Metadata = () => {
|
|
10891
|
-
const { id } = reactRouterDom.useParams();
|
|
10892
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10893
|
-
fields: "metadata"
|
|
10894
|
-
});
|
|
10895
|
-
if (isError) {
|
|
10896
|
-
throw error;
|
|
10897
|
-
}
|
|
10898
|
-
const isReady = !isPending && !!order;
|
|
10899
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10900
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10901
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10902
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10903
|
-
] }),
|
|
10904
|
-
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
11317
|
+
searchValue: comboboxData.searchValue,
|
|
11318
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11319
|
+
onChange: add,
|
|
11320
|
+
value: comboboxValue
|
|
11321
|
+
}
|
|
11322
|
+
)
|
|
11323
|
+
] }),
|
|
11324
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11325
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11326
|
+
PromotionItem,
|
|
11327
|
+
{
|
|
11328
|
+
promotion,
|
|
11329
|
+
orderId: preview.id,
|
|
11330
|
+
isLoading: isPending
|
|
11331
|
+
},
|
|
11332
|
+
promotion.id
|
|
11333
|
+
)) })
|
|
11334
|
+
] }) }),
|
|
11335
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11336
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11337
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11338
|
+
ui.Button,
|
|
11339
|
+
{
|
|
11340
|
+
size: "small",
|
|
11341
|
+
type: "submit",
|
|
11342
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
11343
|
+
children: "Save"
|
|
11344
|
+
}
|
|
11345
|
+
)
|
|
11346
|
+
] }) })
|
|
10905
11347
|
] });
|
|
10906
11348
|
};
|
|
10907
|
-
const
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
const
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
},
|
|
10917
|
-
resolver: zod.zodResolver(MetadataSchema)
|
|
10918
|
-
});
|
|
10919
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10920
|
-
const parsedData = parseValues(data);
|
|
10921
|
-
await mutateAsync(
|
|
11349
|
+
const PromotionItem = ({
|
|
11350
|
+
promotion,
|
|
11351
|
+
orderId,
|
|
11352
|
+
isLoading
|
|
11353
|
+
}) => {
|
|
11354
|
+
var _a;
|
|
11355
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11356
|
+
const onRemove = async () => {
|
|
11357
|
+
removePromotions(
|
|
10922
11358
|
{
|
|
10923
|
-
|
|
11359
|
+
promo_codes: [promotion.code]
|
|
10924
11360
|
},
|
|
10925
11361
|
{
|
|
10926
|
-
|
|
10927
|
-
ui.toast.
|
|
10928
|
-
handleSuccess();
|
|
10929
|
-
},
|
|
10930
|
-
onError: (error) => {
|
|
10931
|
-
ui.toast.error(error.message);
|
|
11362
|
+
onError: (e) => {
|
|
11363
|
+
ui.toast.error(e.message);
|
|
10932
11364
|
}
|
|
10933
11365
|
}
|
|
10934
11366
|
);
|
|
10935
|
-
}
|
|
10936
|
-
const
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
});
|
|
10940
|
-
function deleteRow(index) {
|
|
10941
|
-
remove(index);
|
|
10942
|
-
if (fields.length === 1) {
|
|
10943
|
-
insert(0, {
|
|
10944
|
-
key: "",
|
|
10945
|
-
value: "",
|
|
10946
|
-
disabled: false
|
|
10947
|
-
});
|
|
10948
|
-
}
|
|
10949
|
-
}
|
|
10950
|
-
function insertRow(index, position) {
|
|
10951
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
10952
|
-
key: "",
|
|
10953
|
-
value: "",
|
|
10954
|
-
disabled: false
|
|
10955
|
-
});
|
|
10956
|
-
}
|
|
10957
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10958
|
-
KeyboundForm,
|
|
11367
|
+
};
|
|
11368
|
+
const displayValue = getDisplayValue(promotion);
|
|
11369
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11370
|
+
"div",
|
|
10959
11371
|
{
|
|
10960
|
-
|
|
10961
|
-
|
|
11372
|
+
className: ui.clx(
|
|
11373
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11374
|
+
{
|
|
11375
|
+
"animate-pulse": isLoading
|
|
11376
|
+
}
|
|
11377
|
+
),
|
|
10962
11378
|
children: [
|
|
10963
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10964
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11379
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11380
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11381
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11382
|
+
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11383
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11384
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
10968
11385
|
] }),
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
let placeholder = "-";
|
|
10972
|
-
if (typeof field.value === "object") {
|
|
10973
|
-
placeholder = "{ ... }";
|
|
10974
|
-
}
|
|
10975
|
-
if (Array.isArray(field.value)) {
|
|
10976
|
-
placeholder = "[ ... ]";
|
|
10977
|
-
}
|
|
10978
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10979
|
-
ConditionalTooltip,
|
|
10980
|
-
{
|
|
10981
|
-
showTooltip: isDisabled,
|
|
10982
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
10983
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10984
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10985
|
-
"div",
|
|
10986
|
-
{
|
|
10987
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10988
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10989
|
-
}),
|
|
10990
|
-
children: [
|
|
10991
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10992
|
-
Form$2.Field,
|
|
10993
|
-
{
|
|
10994
|
-
control: form.control,
|
|
10995
|
-
name: `metadata.${index}.key`,
|
|
10996
|
-
render: ({ field: field2 }) => {
|
|
10997
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10998
|
-
GridInput,
|
|
10999
|
-
{
|
|
11000
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
11001
|
-
...field2,
|
|
11002
|
-
disabled: isDisabled,
|
|
11003
|
-
placeholder: "Key"
|
|
11004
|
-
}
|
|
11005
|
-
) }) });
|
|
11006
|
-
}
|
|
11007
|
-
}
|
|
11008
|
-
),
|
|
11009
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11010
|
-
Form$2.Field,
|
|
11011
|
-
{
|
|
11012
|
-
control: form.control,
|
|
11013
|
-
name: `metadata.${index}.value`,
|
|
11014
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
11015
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11016
|
-
GridInput,
|
|
11017
|
-
{
|
|
11018
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11019
|
-
...field2,
|
|
11020
|
-
value: isDisabled ? placeholder : value,
|
|
11021
|
-
disabled: isDisabled,
|
|
11022
|
-
placeholder: "Value"
|
|
11023
|
-
}
|
|
11024
|
-
) }) });
|
|
11025
|
-
}
|
|
11026
|
-
}
|
|
11027
|
-
)
|
|
11028
|
-
]
|
|
11029
|
-
}
|
|
11030
|
-
),
|
|
11031
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11032
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11033
|
-
ui.DropdownMenu.Trigger,
|
|
11034
|
-
{
|
|
11035
|
-
className: ui.clx(
|
|
11036
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11037
|
-
{
|
|
11038
|
-
hidden: isDisabled
|
|
11039
|
-
}
|
|
11040
|
-
),
|
|
11041
|
-
disabled: isDisabled,
|
|
11042
|
-
asChild: true,
|
|
11043
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11044
|
-
}
|
|
11045
|
-
),
|
|
11046
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11047
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11048
|
-
ui.DropdownMenu.Item,
|
|
11049
|
-
{
|
|
11050
|
-
className: "gap-x-2",
|
|
11051
|
-
onClick: () => insertRow(index, "above"),
|
|
11052
|
-
children: [
|
|
11053
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11054
|
-
"Insert row above"
|
|
11055
|
-
]
|
|
11056
|
-
}
|
|
11057
|
-
),
|
|
11058
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11059
|
-
ui.DropdownMenu.Item,
|
|
11060
|
-
{
|
|
11061
|
-
className: "gap-x-2",
|
|
11062
|
-
onClick: () => insertRow(index, "below"),
|
|
11063
|
-
children: [
|
|
11064
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11065
|
-
"Insert row below"
|
|
11066
|
-
]
|
|
11067
|
-
}
|
|
11068
|
-
),
|
|
11069
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11070
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11071
|
-
ui.DropdownMenu.Item,
|
|
11072
|
-
{
|
|
11073
|
-
className: "gap-x-2",
|
|
11074
|
-
onClick: () => deleteRow(index),
|
|
11075
|
-
children: [
|
|
11076
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11077
|
-
"Delete row"
|
|
11078
|
-
]
|
|
11079
|
-
}
|
|
11080
|
-
)
|
|
11081
|
-
] })
|
|
11082
|
-
] })
|
|
11083
|
-
] })
|
|
11084
|
-
},
|
|
11085
|
-
field.id
|
|
11086
|
-
);
|
|
11087
|
-
})
|
|
11088
|
-
] }),
|
|
11089
|
-
hasUneditableRows && /* @__PURE__ */ jsxRuntime.jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
11386
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11387
|
+
] })
|
|
11090
11388
|
] }),
|
|
11091
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11092
|
-
|
|
11093
|
-
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
autoComplete: "off",
|
|
11106
|
-
className: ui.clx(
|
|
11107
|
-
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
11108
|
-
className
|
|
11109
|
-
)
|
|
11110
|
-
}
|
|
11389
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11390
|
+
ui.IconButton,
|
|
11391
|
+
{
|
|
11392
|
+
size: "small",
|
|
11393
|
+
type: "button",
|
|
11394
|
+
variant: "transparent",
|
|
11395
|
+
onClick: onRemove,
|
|
11396
|
+
isLoading: isPending || isLoading,
|
|
11397
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11398
|
+
}
|
|
11399
|
+
)
|
|
11400
|
+
]
|
|
11401
|
+
},
|
|
11402
|
+
promotion.id
|
|
11111
11403
|
);
|
|
11112
|
-
});
|
|
11113
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
11114
|
-
const PlaceholderInner = () => {
|
|
11115
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11116
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11117
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11118
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11119
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11120
|
-
] }) })
|
|
11121
|
-
] });
|
|
11122
11404
|
};
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
key: "",
|
|
11129
|
-
value: "",
|
|
11130
|
-
disabled: false
|
|
11131
|
-
}
|
|
11132
|
-
];
|
|
11405
|
+
function getDisplayValue(promotion) {
|
|
11406
|
+
var _a, _b, _c, _d;
|
|
11407
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11408
|
+
if (!value) {
|
|
11409
|
+
return null;
|
|
11133
11410
|
}
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
value,
|
|
11139
|
-
disabled: true
|
|
11140
|
-
};
|
|
11141
|
-
}
|
|
11142
|
-
let stringValue = value;
|
|
11143
|
-
if (typeof value !== "string") {
|
|
11144
|
-
stringValue = JSON.stringify(value);
|
|
11411
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11412
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11413
|
+
if (!currency) {
|
|
11414
|
+
return null;
|
|
11145
11415
|
}
|
|
11146
|
-
return
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
});
|
|
11416
|
+
return getLocaleAmount(value, currency);
|
|
11417
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11418
|
+
return formatPercentage(value);
|
|
11419
|
+
}
|
|
11420
|
+
return null;
|
|
11152
11421
|
}
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11422
|
+
const formatter = new Intl.NumberFormat([], {
|
|
11423
|
+
style: "percent",
|
|
11424
|
+
minimumFractionDigits: 2
|
|
11425
|
+
});
|
|
11426
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11427
|
+
let val = value || 0;
|
|
11428
|
+
if (!isPercentageValue) {
|
|
11429
|
+
val = val / 100;
|
|
11158
11430
|
}
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
if (
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11431
|
+
return formatter.format(val);
|
|
11432
|
+
};
|
|
11433
|
+
function getPromotionIds(items, shippingMethods) {
|
|
11434
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
11435
|
+
for (const item of items) {
|
|
11436
|
+
if (item.adjustments) {
|
|
11437
|
+
for (const adjustment of item.adjustments) {
|
|
11438
|
+
if (adjustment.promotion_id) {
|
|
11439
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11170
11442
|
}
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
if (
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
const parsedNumber = parseFloat(value);
|
|
11179
|
-
if (!isNaN(parsedNumber)) {
|
|
11180
|
-
update[key] = parsedNumber;
|
|
11181
|
-
} else {
|
|
11182
|
-
update[key] = value;
|
|
11443
|
+
}
|
|
11444
|
+
for (const shippingMethod of shippingMethods) {
|
|
11445
|
+
if (shippingMethod.adjustments) {
|
|
11446
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11447
|
+
if (adjustment.promotion_id) {
|
|
11448
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11449
|
+
}
|
|
11183
11450
|
}
|
|
11184
11451
|
}
|
|
11185
|
-
});
|
|
11186
|
-
return update;
|
|
11187
|
-
}
|
|
11188
|
-
function getHasUneditableRows(metadata) {
|
|
11189
|
-
if (!metadata) {
|
|
11190
|
-
return false;
|
|
11191
11452
|
}
|
|
11192
|
-
return
|
|
11193
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11194
|
-
);
|
|
11453
|
+
return Array.from(promotionIds);
|
|
11195
11454
|
}
|
|
11196
11455
|
const SalesChannel = () => {
|
|
11197
11456
|
const { id } = reactRouterDom.useParams();
|
|
@@ -11221,7 +11480,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11221
11480
|
defaultValues: {
|
|
11222
11481
|
sales_channel_id: order.sales_channel_id || ""
|
|
11223
11482
|
},
|
|
11224
|
-
resolver: zod.zodResolver(schema$
|
|
11483
|
+
resolver: zod.zodResolver(schema$2)
|
|
11225
11484
|
});
|
|
11226
11485
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11227
11486
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11296,7 +11555,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11296
11555
|
}
|
|
11297
11556
|
);
|
|
11298
11557
|
};
|
|
11299
|
-
const schema$
|
|
11558
|
+
const schema$2 = objectType({
|
|
11300
11559
|
sales_channel_id: stringType().min(1)
|
|
11301
11560
|
});
|
|
11302
11561
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -11324,7 +11583,7 @@ const Shipping = () => {
|
|
|
11324
11583
|
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11325
11584
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11326
11585
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11327
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.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 py-16
|
|
11586
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.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-6 py-16", children: [
|
|
11328
11587
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11329
11588
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11330
11589
|
] }) }) }),
|
|
@@ -11411,14 +11670,14 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11411
11670
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11412
11671
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11413
11672
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11414
|
-
/* @__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 py-16
|
|
11673
|
+
/* @__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: [
|
|
11415
11674
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11416
11675
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11417
11676
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11418
11677
|
] }),
|
|
11419
11678
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11420
|
-
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle
|
|
11421
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
11679
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11680
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
11422
11681
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11423
11682
|
ui.Text,
|
|
11424
11683
|
{
|
|
@@ -11460,8 +11719,8 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11460
11719
|
value: profile.id,
|
|
11461
11720
|
className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
|
|
11462
11721
|
children: [
|
|
11463
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
11464
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3
|
|
11722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
|
|
11723
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-x-3 overflow-hidden", children: [
|
|
11465
11724
|
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11466
11725
|
ui.IconButton,
|
|
11467
11726
|
{
|
|
@@ -11469,12 +11728,12 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11469
11728
|
variant: "transparent",
|
|
11470
11729
|
className: "group/trigger",
|
|
11471
11730
|
disabled: !hasItems,
|
|
11472
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90
|
|
11731
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "transition-transform group-data-[state=open]/trigger:rotate-90" })
|
|
11473
11732
|
}
|
|
11474
11733
|
) }),
|
|
11475
11734
|
!shippingOption ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
11476
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
11477
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-
|
|
11735
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-bg-component-hover flex size-6 items-center justify-center rounded", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "text-ui-fg-subtle" }) }) }),
|
|
11736
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col", children: [
|
|
11478
11737
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11479
11738
|
ui.Text,
|
|
11480
11739
|
{
|
|
@@ -11498,7 +11757,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11498
11757
|
}
|
|
11499
11758
|
)
|
|
11500
11759
|
] })
|
|
11501
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start
|
|
11760
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-1 items-center gap-[5px] overflow-hidden max-sm:flex-col max-sm:items-start", children: [
|
|
11502
11761
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11503
11762
|
ui.Tooltip,
|
|
11504
11763
|
{
|
|
@@ -11515,7 +11774,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11515
11774
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11516
11775
|
ui.Badge,
|
|
11517
11776
|
{
|
|
11518
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11777
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
11519
11778
|
size: "xsmall",
|
|
11520
11779
|
children: [
|
|
11521
11780
|
/* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "shrink-0" }),
|
|
@@ -11540,7 +11799,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11540
11799
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11541
11800
|
ui.Badge,
|
|
11542
11801
|
{
|
|
11543
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11802
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
11544
11803
|
size: "xsmall",
|
|
11545
11804
|
children: [
|
|
11546
11805
|
/* @__PURE__ */ jsxRuntime.jsx(icons.Buildings, { className: "shrink-0" }),
|
|
@@ -11553,7 +11812,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11553
11812
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11554
11813
|
ui.Badge,
|
|
11555
11814
|
{
|
|
11556
|
-
className: "flex items-center gap-x-[3px] overflow-hidden
|
|
11815
|
+
className: "flex cursor-default items-center gap-x-[3px] overflow-hidden",
|
|
11557
11816
|
size: "xsmall",
|
|
11558
11817
|
children: [
|
|
11559
11818
|
/* @__PURE__ */ jsxRuntime.jsx(icons.TruckFast, { className: "shrink-0" }),
|
|
@@ -11624,17 +11883,17 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
11624
11883
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11625
11884
|
"div",
|
|
11626
11885
|
{
|
|
11627
|
-
className: "
|
|
11886
|
+
className: "flex items-center gap-x-3 px-3",
|
|
11628
11887
|
children: [
|
|
11629
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
11888
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-[56px] w-5 flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11630
11889
|
ui.Divider,
|
|
11631
11890
|
{
|
|
11632
11891
|
variant: "dashed",
|
|
11633
11892
|
orientation: "vertical"
|
|
11634
11893
|
}
|
|
11635
11894
|
) }),
|
|
11636
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
11637
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7
|
|
11895
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 py-2", children: [
|
|
11896
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-7 items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11638
11897
|
ui.Text,
|
|
11639
11898
|
{
|
|
11640
11899
|
size: "small",
|
|
@@ -11771,7 +12030,7 @@ const ShippingProfileForm = ({
|
|
|
11771
12030
|
isPending: isUpdatingShippingMethod
|
|
11772
12031
|
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
11773
12032
|
const onSubmit = form.handleSubmit(async (values) => {
|
|
11774
|
-
if (
|
|
12033
|
+
if (isEqual__default.default(values, form.formState.defaultValues)) {
|
|
11775
12034
|
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11776
12035
|
return;
|
|
11777
12036
|
}
|
|
@@ -11815,7 +12074,7 @@ const ShippingProfileForm = ({
|
|
|
11815
12074
|
onSubmit,
|
|
11816
12075
|
children: [
|
|
11817
12076
|
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
11818
|
-
/* @__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 py-16
|
|
12077
|
+
/* @__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-6 py-16", children: [
|
|
11819
12078
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11820
12079
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11821
12080
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
@@ -11888,14 +12147,14 @@ const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
|
11888
12147
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
11889
12148
|
] }) }),
|
|
11890
12149
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11891
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2
|
|
12150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
|
|
11892
12151
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
11893
12152
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
11894
12153
|
] }),
|
|
11895
12154
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11896
12155
|
"div",
|
|
11897
12156
|
{
|
|
11898
|
-
className: "
|
|
12157
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
11899
12158
|
children: [
|
|
11900
12159
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
11901
12160
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -11948,7 +12207,7 @@ const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
|
11948
12207
|
]
|
|
11949
12208
|
},
|
|
11950
12209
|
item.id
|
|
11951
|
-
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3
|
|
12210
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
11952
12211
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
11953
12212
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
11954
12213
|
'No items found for "',
|
|
@@ -12138,7 +12397,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12138
12397
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12139
12398
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12140
12399
|
},
|
|
12141
|
-
resolver: zod.zodResolver(schema$
|
|
12400
|
+
resolver: zod.zodResolver(schema$1)
|
|
12142
12401
|
});
|
|
12143
12402
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12144
12403
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12308,7 +12567,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12308
12567
|
}
|
|
12309
12568
|
) });
|
|
12310
12569
|
};
|
|
12311
|
-
const schema$
|
|
12570
|
+
const schema$1 = addressSchema;
|
|
12312
12571
|
const TransferOwnership = () => {
|
|
12313
12572
|
const { id } = reactRouterDom.useParams();
|
|
12314
12573
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12332,7 +12591,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12332
12591
|
defaultValues: {
|
|
12333
12592
|
customer_id: order.customer_id || ""
|
|
12334
12593
|
},
|
|
12335
|
-
resolver: zod.zodResolver(schema
|
|
12594
|
+
resolver: zod.zodResolver(schema)
|
|
12336
12595
|
});
|
|
12337
12596
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12338
12597
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12719,330 +12978,72 @@ const Illustration = () => {
|
|
|
12719
12978
|
stroke: "#A1A1AA",
|
|
12720
12979
|
strokeWidth: "1.5",
|
|
12721
12980
|
strokeLinecap: "round",
|
|
12722
|
-
strokeLinejoin: "round"
|
|
12723
|
-
}
|
|
12724
|
-
) }),
|
|
12725
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12726
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12727
|
-
"rect",
|
|
12728
|
-
{
|
|
12729
|
-
width: "12",
|
|
12730
|
-
height: "12",
|
|
12731
|
-
fill: "white",
|
|
12732
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12733
|
-
}
|
|
12734
|
-
) }),
|
|
12735
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12736
|
-
"rect",
|
|
12737
|
-
{
|
|
12738
|
-
width: "12",
|
|
12739
|
-
height: "12",
|
|
12740
|
-
fill: "white",
|
|
12741
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12742
|
-
}
|
|
12743
|
-
) }),
|
|
12744
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12745
|
-
"rect",
|
|
12746
|
-
{
|
|
12747
|
-
width: "12",
|
|
12748
|
-
height: "12",
|
|
12749
|
-
fill: "white",
|
|
12750
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12751
|
-
}
|
|
12752
|
-
) }),
|
|
12753
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12754
|
-
"rect",
|
|
12755
|
-
{
|
|
12756
|
-
width: "12",
|
|
12757
|
-
height: "12",
|
|
12758
|
-
fill: "white",
|
|
12759
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12760
|
-
}
|
|
12761
|
-
) }),
|
|
12762
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12763
|
-
"rect",
|
|
12764
|
-
{
|
|
12765
|
-
width: "12",
|
|
12766
|
-
height: "12",
|
|
12767
|
-
fill: "white",
|
|
12768
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12769
|
-
}
|
|
12770
|
-
) }),
|
|
12771
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12772
|
-
"rect",
|
|
12773
|
-
{
|
|
12774
|
-
width: "12",
|
|
12775
|
-
height: "12",
|
|
12776
|
-
fill: "white",
|
|
12777
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12778
|
-
}
|
|
12779
|
-
) })
|
|
12780
|
-
] })
|
|
12781
|
-
]
|
|
12782
|
-
}
|
|
12783
|
-
);
|
|
12784
|
-
};
|
|
12785
|
-
const schema$2 = objectType({
|
|
12786
|
-
customer_id: stringType().min(1)
|
|
12787
|
-
});
|
|
12788
|
-
const Email = () => {
|
|
12789
|
-
const { id } = reactRouterDom.useParams();
|
|
12790
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12791
|
-
fields: "+email"
|
|
12792
|
-
});
|
|
12793
|
-
if (isError) {
|
|
12794
|
-
throw error;
|
|
12795
|
-
}
|
|
12796
|
-
const isReady = !isPending && !!order;
|
|
12797
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12798
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12799
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
12800
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12801
|
-
] }),
|
|
12802
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
12803
|
-
] });
|
|
12804
|
-
};
|
|
12805
|
-
const EmailForm = ({ order }) => {
|
|
12806
|
-
const form = reactHookForm.useForm({
|
|
12807
|
-
defaultValues: {
|
|
12808
|
-
email: order.email ?? ""
|
|
12809
|
-
},
|
|
12810
|
-
resolver: zod.zodResolver(schema$1)
|
|
12811
|
-
});
|
|
12812
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12813
|
-
const { handleSuccess } = useRouteModal();
|
|
12814
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12815
|
-
await mutateAsync(
|
|
12816
|
-
{ email: data.email },
|
|
12817
|
-
{
|
|
12818
|
-
onSuccess: () => {
|
|
12819
|
-
handleSuccess();
|
|
12820
|
-
},
|
|
12821
|
-
onError: (error) => {
|
|
12822
|
-
ui.toast.error(error.message);
|
|
12823
|
-
}
|
|
12824
|
-
}
|
|
12825
|
-
);
|
|
12826
|
-
});
|
|
12827
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12828
|
-
KeyboundForm,
|
|
12829
|
-
{
|
|
12830
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12831
|
-
onSubmit,
|
|
12832
|
-
children: [
|
|
12833
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12834
|
-
Form$2.Field,
|
|
12835
|
-
{
|
|
12836
|
-
control: form.control,
|
|
12837
|
-
name: "email",
|
|
12838
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12839
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
12840
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12841
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12842
|
-
] })
|
|
12981
|
+
strokeLinejoin: "round"
|
|
12843
12982
|
}
|
|
12844
12983
|
) }),
|
|
12845
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12846
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12847
|
-
|
|
12848
|
-
] }) })
|
|
12849
|
-
]
|
|
12850
|
-
}
|
|
12851
|
-
) });
|
|
12852
|
-
};
|
|
12853
|
-
const schema$1 = objectType({
|
|
12854
|
-
email: stringType().email()
|
|
12855
|
-
});
|
|
12856
|
-
const BillingAddress = () => {
|
|
12857
|
-
const { id } = reactRouterDom.useParams();
|
|
12858
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12859
|
-
fields: "+billing_address"
|
|
12860
|
-
});
|
|
12861
|
-
if (isError) {
|
|
12862
|
-
throw error;
|
|
12863
|
-
}
|
|
12864
|
-
const isReady = !isPending && !!order;
|
|
12865
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12866
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12867
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
12868
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12869
|
-
] }),
|
|
12870
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
12871
|
-
] });
|
|
12872
|
-
};
|
|
12873
|
-
const BillingAddressForm = ({ order }) => {
|
|
12874
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12875
|
-
const form = reactHookForm.useForm({
|
|
12876
|
-
defaultValues: {
|
|
12877
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12878
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12879
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12880
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12881
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12882
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12883
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12884
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12885
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12886
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12887
|
-
},
|
|
12888
|
-
resolver: zod.zodResolver(schema)
|
|
12889
|
-
});
|
|
12890
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12891
|
-
const { handleSuccess } = useRouteModal();
|
|
12892
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12893
|
-
await mutateAsync(
|
|
12894
|
-
{ billing_address: data },
|
|
12895
|
-
{
|
|
12896
|
-
onSuccess: () => {
|
|
12897
|
-
handleSuccess();
|
|
12898
|
-
},
|
|
12899
|
-
onError: (error) => {
|
|
12900
|
-
ui.toast.error(error.message);
|
|
12901
|
-
}
|
|
12902
|
-
}
|
|
12903
|
-
);
|
|
12904
|
-
});
|
|
12905
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12906
|
-
KeyboundForm,
|
|
12907
|
-
{
|
|
12908
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12909
|
-
onSubmit,
|
|
12910
|
-
children: [
|
|
12911
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12912
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12913
|
-
Form$2.Field,
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12985
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12986
|
+
"rect",
|
|
12914
12987
|
{
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12920
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12921
|
-
] })
|
|
12988
|
+
width: "12",
|
|
12989
|
+
height: "12",
|
|
12990
|
+
fill: "white",
|
|
12991
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12922
12992
|
}
|
|
12923
|
-
),
|
|
12924
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12925
|
-
|
|
12926
|
-
Form$2.Field,
|
|
12927
|
-
{
|
|
12928
|
-
control: form.control,
|
|
12929
|
-
name: "first_name",
|
|
12930
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12931
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12932
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12933
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12934
|
-
] })
|
|
12935
|
-
}
|
|
12936
|
-
),
|
|
12937
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12938
|
-
Form$2.Field,
|
|
12939
|
-
{
|
|
12940
|
-
control: form.control,
|
|
12941
|
-
name: "last_name",
|
|
12942
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12943
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12944
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12945
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12946
|
-
] })
|
|
12947
|
-
}
|
|
12948
|
-
)
|
|
12949
|
-
] }),
|
|
12950
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12951
|
-
Form$2.Field,
|
|
12993
|
+
) }),
|
|
12994
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12995
|
+
"rect",
|
|
12952
12996
|
{
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12958
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12959
|
-
] })
|
|
12997
|
+
width: "12",
|
|
12998
|
+
height: "12",
|
|
12999
|
+
fill: "white",
|
|
13000
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12960
13001
|
}
|
|
12961
|
-
),
|
|
12962
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12963
|
-
|
|
13002
|
+
) }),
|
|
13003
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13004
|
+
"rect",
|
|
12964
13005
|
{
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12970
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12971
|
-
] })
|
|
13006
|
+
width: "12",
|
|
13007
|
+
height: "12",
|
|
13008
|
+
fill: "white",
|
|
13009
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12972
13010
|
}
|
|
12973
|
-
),
|
|
12974
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12975
|
-
|
|
13011
|
+
) }),
|
|
13012
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
+
"rect",
|
|
12976
13014
|
{
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12982
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12983
|
-
] })
|
|
13015
|
+
width: "12",
|
|
13016
|
+
height: "12",
|
|
13017
|
+
fill: "white",
|
|
13018
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12984
13019
|
}
|
|
12985
|
-
),
|
|
12986
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12987
|
-
|
|
12988
|
-
Form$2.Field,
|
|
12989
|
-
{
|
|
12990
|
-
control: form.control,
|
|
12991
|
-
name: "postal_code",
|
|
12992
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12993
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12994
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12995
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12996
|
-
] })
|
|
12997
|
-
}
|
|
12998
|
-
),
|
|
12999
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13000
|
-
Form$2.Field,
|
|
13001
|
-
{
|
|
13002
|
-
control: form.control,
|
|
13003
|
-
name: "city",
|
|
13004
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13005
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
13006
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13007
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13008
|
-
] })
|
|
13009
|
-
}
|
|
13010
|
-
)
|
|
13011
|
-
] }),
|
|
13012
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
-
Form$2.Field,
|
|
13020
|
+
) }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
+
"rect",
|
|
13014
13023
|
{
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13020
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13021
|
-
] })
|
|
13024
|
+
width: "12",
|
|
13025
|
+
height: "12",
|
|
13026
|
+
fill: "white",
|
|
13027
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13022
13028
|
}
|
|
13023
|
-
),
|
|
13024
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13025
|
-
|
|
13029
|
+
) }),
|
|
13030
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13031
|
+
"rect",
|
|
13026
13032
|
{
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13032
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13033
|
-
] })
|
|
13033
|
+
width: "12",
|
|
13034
|
+
height: "12",
|
|
13035
|
+
fill: "white",
|
|
13036
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13034
13037
|
}
|
|
13035
|
-
)
|
|
13036
|
-
] })
|
|
13037
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13038
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13039
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13040
|
-
] }) })
|
|
13038
|
+
) })
|
|
13039
|
+
] })
|
|
13041
13040
|
]
|
|
13042
13041
|
}
|
|
13043
|
-
)
|
|
13042
|
+
);
|
|
13044
13043
|
};
|
|
13045
|
-
const schema =
|
|
13044
|
+
const schema = objectType({
|
|
13045
|
+
customer_id: stringType().min(1)
|
|
13046
|
+
});
|
|
13046
13047
|
const widgetModule = { widgets: [] };
|
|
13047
13048
|
const routeModule = {
|
|
13048
13049
|
routes: [
|
|
@@ -13063,22 +13064,30 @@ const routeModule = {
|
|
|
13063
13064
|
handle,
|
|
13064
13065
|
loader,
|
|
13065
13066
|
children: [
|
|
13067
|
+
{
|
|
13068
|
+
Component: BillingAddress,
|
|
13069
|
+
path: "/draft-orders/:id/billing-address"
|
|
13070
|
+
},
|
|
13066
13071
|
{
|
|
13067
13072
|
Component: CustomItems,
|
|
13068
13073
|
path: "/draft-orders/:id/custom-items"
|
|
13069
13074
|
},
|
|
13070
13075
|
{
|
|
13071
|
-
Component:
|
|
13072
|
-
path: "/draft-orders/:id/
|
|
13076
|
+
Component: Email,
|
|
13077
|
+
path: "/draft-orders/:id/email"
|
|
13073
13078
|
},
|
|
13074
13079
|
{
|
|
13075
|
-
Component:
|
|
13076
|
-
path: "/draft-orders/:id/
|
|
13080
|
+
Component: Items,
|
|
13081
|
+
path: "/draft-orders/:id/items"
|
|
13077
13082
|
},
|
|
13078
13083
|
{
|
|
13079
13084
|
Component: Metadata,
|
|
13080
13085
|
path: "/draft-orders/:id/metadata"
|
|
13081
13086
|
},
|
|
13087
|
+
{
|
|
13088
|
+
Component: Promotions,
|
|
13089
|
+
path: "/draft-orders/:id/promotions"
|
|
13090
|
+
},
|
|
13082
13091
|
{
|
|
13083
13092
|
Component: SalesChannel,
|
|
13084
13093
|
path: "/draft-orders/:id/sales-channel"
|
|
@@ -13094,14 +13103,6 @@ const routeModule = {
|
|
|
13094
13103
|
{
|
|
13095
13104
|
Component: TransferOwnership,
|
|
13096
13105
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
|
-
},
|
|
13098
|
-
{
|
|
13099
|
-
Component: Email,
|
|
13100
|
-
path: "/draft-orders/:id/email"
|
|
13101
|
-
},
|
|
13102
|
-
{
|
|
13103
|
-
Component: BillingAddress,
|
|
13104
|
-
path: "/draft-orders/:id/billing-address"
|
|
13105
13106
|
}
|
|
13106
13107
|
]
|
|
13107
13108
|
}
|