@medusajs/draft-order 2.10.2-preview-20250903000308 → 2.10.2-preview-20250903060148
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 +529 -529
- package/.medusa/server/src/admin/index.mjs +529 -529
- package/package.json +16 -16
|
@@ -9560,196 +9560,6 @@ const ID = () => {
|
|
|
9560
9560
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9561
9561
|
] });
|
|
9562
9562
|
};
|
|
9563
|
-
const BillingAddress = () => {
|
|
9564
|
-
const { id } = reactRouterDom.useParams();
|
|
9565
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9566
|
-
fields: "+billing_address"
|
|
9567
|
-
});
|
|
9568
|
-
if (isError) {
|
|
9569
|
-
throw error;
|
|
9570
|
-
}
|
|
9571
|
-
const isReady = !isPending && !!order;
|
|
9572
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9573
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9574
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9575
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9576
|
-
] }),
|
|
9577
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9578
|
-
] });
|
|
9579
|
-
};
|
|
9580
|
-
const BillingAddressForm = ({ order }) => {
|
|
9581
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9582
|
-
const form = reactHookForm.useForm({
|
|
9583
|
-
defaultValues: {
|
|
9584
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9585
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9586
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9587
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9588
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9589
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9590
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9591
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9592
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9593
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9594
|
-
},
|
|
9595
|
-
resolver: zod.zodResolver(schema$5)
|
|
9596
|
-
});
|
|
9597
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9598
|
-
const { handleSuccess } = useRouteModal();
|
|
9599
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9600
|
-
await mutateAsync(
|
|
9601
|
-
{ billing_address: data },
|
|
9602
|
-
{
|
|
9603
|
-
onSuccess: () => {
|
|
9604
|
-
handleSuccess();
|
|
9605
|
-
},
|
|
9606
|
-
onError: (error) => {
|
|
9607
|
-
ui.toast.error(error.message);
|
|
9608
|
-
}
|
|
9609
|
-
}
|
|
9610
|
-
);
|
|
9611
|
-
});
|
|
9612
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9613
|
-
KeyboundForm,
|
|
9614
|
-
{
|
|
9615
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9616
|
-
onSubmit,
|
|
9617
|
-
children: [
|
|
9618
|
-
/* @__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: [
|
|
9619
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9620
|
-
Form$2.Field,
|
|
9621
|
-
{
|
|
9622
|
-
control: form.control,
|
|
9623
|
-
name: "country_code",
|
|
9624
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9625
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9626
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9627
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9628
|
-
] })
|
|
9629
|
-
}
|
|
9630
|
-
),
|
|
9631
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9632
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9633
|
-
Form$2.Field,
|
|
9634
|
-
{
|
|
9635
|
-
control: form.control,
|
|
9636
|
-
name: "first_name",
|
|
9637
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9638
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9639
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9640
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9641
|
-
] })
|
|
9642
|
-
}
|
|
9643
|
-
),
|
|
9644
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9645
|
-
Form$2.Field,
|
|
9646
|
-
{
|
|
9647
|
-
control: form.control,
|
|
9648
|
-
name: "last_name",
|
|
9649
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9650
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last 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
|
-
] }),
|
|
9657
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9658
|
-
Form$2.Field,
|
|
9659
|
-
{
|
|
9660
|
-
control: form.control,
|
|
9661
|
-
name: "company",
|
|
9662
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9663
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9664
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9665
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9666
|
-
] })
|
|
9667
|
-
}
|
|
9668
|
-
),
|
|
9669
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9670
|
-
Form$2.Field,
|
|
9671
|
-
{
|
|
9672
|
-
control: form.control,
|
|
9673
|
-
name: "address_1",
|
|
9674
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9675
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
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_2",
|
|
9686
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9687
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
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.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9694
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9695
|
-
Form$2.Field,
|
|
9696
|
-
{
|
|
9697
|
-
control: form.control,
|
|
9698
|
-
name: "postal_code",
|
|
9699
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9700
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9701
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9702
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9703
|
-
] })
|
|
9704
|
-
}
|
|
9705
|
-
),
|
|
9706
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9707
|
-
Form$2.Field,
|
|
9708
|
-
{
|
|
9709
|
-
control: form.control,
|
|
9710
|
-
name: "city",
|
|
9711
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9712
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
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
|
-
] }),
|
|
9719
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9720
|
-
Form$2.Field,
|
|
9721
|
-
{
|
|
9722
|
-
control: form.control,
|
|
9723
|
-
name: "province",
|
|
9724
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9725
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9726
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9727
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9728
|
-
] })
|
|
9729
|
-
}
|
|
9730
|
-
),
|
|
9731
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9732
|
-
Form$2.Field,
|
|
9733
|
-
{
|
|
9734
|
-
control: form.control,
|
|
9735
|
-
name: "phone",
|
|
9736
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9737
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
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
|
-
] }) }),
|
|
9744
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9745
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9746
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9747
|
-
] }) })
|
|
9748
|
-
]
|
|
9749
|
-
}
|
|
9750
|
-
) });
|
|
9751
|
-
};
|
|
9752
|
-
const schema$5 = addressSchema;
|
|
9753
9563
|
const Email = () => {
|
|
9754
9564
|
const { id } = reactRouterDom.useParams();
|
|
9755
9565
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9772,7 +9582,7 @@ const EmailForm = ({ order }) => {
|
|
|
9772
9582
|
defaultValues: {
|
|
9773
9583
|
email: order.email ?? ""
|
|
9774
9584
|
},
|
|
9775
|
-
resolver: zod.zodResolver(schema$
|
|
9585
|
+
resolver: zod.zodResolver(schema$5)
|
|
9776
9586
|
});
|
|
9777
9587
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9778
9588
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9815,7 +9625,7 @@ const EmailForm = ({ order }) => {
|
|
|
9815
9625
|
}
|
|
9816
9626
|
) });
|
|
9817
9627
|
};
|
|
9818
|
-
const schema$
|
|
9628
|
+
const schema$5 = objectType({
|
|
9819
9629
|
email: stringType().email()
|
|
9820
9630
|
});
|
|
9821
9631
|
const NumberInput = React.forwardRef(
|
|
@@ -10792,27 +10602,356 @@ const customItemSchema = objectType({
|
|
|
10792
10602
|
quantity: numberType(),
|
|
10793
10603
|
unit_price: unionType([numberType(), stringType()])
|
|
10794
10604
|
});
|
|
10795
|
-
const
|
|
10605
|
+
const InlineTip = React.forwardRef(
|
|
10606
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10607
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10608
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10609
|
+
"div",
|
|
10610
|
+
{
|
|
10611
|
+
ref,
|
|
10612
|
+
className: ui.clx(
|
|
10613
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10614
|
+
className
|
|
10615
|
+
),
|
|
10616
|
+
...props,
|
|
10617
|
+
children: [
|
|
10618
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10619
|
+
"div",
|
|
10620
|
+
{
|
|
10621
|
+
role: "presentation",
|
|
10622
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10623
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10624
|
+
})
|
|
10625
|
+
}
|
|
10626
|
+
),
|
|
10627
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
10628
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10629
|
+
labelValue,
|
|
10630
|
+
":"
|
|
10631
|
+
] }),
|
|
10632
|
+
" ",
|
|
10633
|
+
children
|
|
10634
|
+
] })
|
|
10635
|
+
]
|
|
10636
|
+
}
|
|
10637
|
+
);
|
|
10638
|
+
}
|
|
10639
|
+
);
|
|
10640
|
+
InlineTip.displayName = "InlineTip";
|
|
10641
|
+
const MetadataFieldSchema = objectType({
|
|
10642
|
+
key: stringType(),
|
|
10643
|
+
disabled: booleanType().optional(),
|
|
10644
|
+
value: anyType()
|
|
10645
|
+
});
|
|
10646
|
+
const MetadataSchema = objectType({
|
|
10647
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10648
|
+
});
|
|
10649
|
+
const Metadata = () => {
|
|
10650
|
+
const { id } = reactRouterDom.useParams();
|
|
10651
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10652
|
+
fields: "metadata"
|
|
10653
|
+
});
|
|
10654
|
+
if (isError) {
|
|
10655
|
+
throw error;
|
|
10656
|
+
}
|
|
10657
|
+
const isReady = !isPending && !!order;
|
|
10796
10658
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10797
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10798
|
-
|
|
10659
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10660
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10661
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10662
|
+
] }),
|
|
10663
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10799
10664
|
] });
|
|
10800
10665
|
};
|
|
10801
|
-
const
|
|
10802
|
-
|
|
10803
|
-
|
|
10666
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10667
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10668
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10669
|
+
const { handleSuccess } = useRouteModal();
|
|
10670
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10671
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10672
|
+
const form = reactHookForm.useForm({
|
|
10673
|
+
defaultValues: {
|
|
10674
|
+
metadata: getDefaultValues(metadata)
|
|
10675
|
+
},
|
|
10676
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
10804
10677
|
});
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10678
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10679
|
+
const parsedData = parseValues(data);
|
|
10680
|
+
await mutateAsync(
|
|
10681
|
+
{
|
|
10682
|
+
metadata: parsedData
|
|
10683
|
+
},
|
|
10684
|
+
{
|
|
10685
|
+
onSuccess: () => {
|
|
10686
|
+
ui.toast.success("Metadata updated");
|
|
10687
|
+
handleSuccess();
|
|
10688
|
+
},
|
|
10689
|
+
onError: (error) => {
|
|
10690
|
+
ui.toast.error(error.message);
|
|
10691
|
+
}
|
|
10692
|
+
}
|
|
10693
|
+
);
|
|
10694
|
+
});
|
|
10695
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
10696
|
+
control: form.control,
|
|
10697
|
+
name: "metadata"
|
|
10698
|
+
});
|
|
10699
|
+
function deleteRow(index) {
|
|
10700
|
+
remove(index);
|
|
10701
|
+
if (fields.length === 1) {
|
|
10702
|
+
insert(0, {
|
|
10703
|
+
key: "",
|
|
10704
|
+
value: "",
|
|
10705
|
+
disabled: false
|
|
10706
|
+
});
|
|
10707
|
+
}
|
|
10708
|
+
}
|
|
10709
|
+
function insertRow(index, position) {
|
|
10710
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10711
|
+
key: "",
|
|
10712
|
+
value: "",
|
|
10713
|
+
disabled: false
|
|
10714
|
+
});
|
|
10715
|
+
}
|
|
10716
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10717
|
+
KeyboundForm,
|
|
10718
|
+
{
|
|
10719
|
+
onSubmit: handleSubmit,
|
|
10720
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10721
|
+
children: [
|
|
10722
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10723
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10724
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10725
|
+
/* @__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" }) }),
|
|
10726
|
+
/* @__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" }) })
|
|
10727
|
+
] }),
|
|
10728
|
+
fields.map((field, index) => {
|
|
10729
|
+
const isDisabled = field.disabled || false;
|
|
10730
|
+
let placeholder = "-";
|
|
10731
|
+
if (typeof field.value === "object") {
|
|
10732
|
+
placeholder = "{ ... }";
|
|
10733
|
+
}
|
|
10734
|
+
if (Array.isArray(field.value)) {
|
|
10735
|
+
placeholder = "[ ... ]";
|
|
10736
|
+
}
|
|
10737
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10738
|
+
ConditionalTooltip,
|
|
10739
|
+
{
|
|
10740
|
+
showTooltip: isDisabled,
|
|
10741
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
10742
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10743
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10744
|
+
"div",
|
|
10745
|
+
{
|
|
10746
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10747
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10748
|
+
}),
|
|
10749
|
+
children: [
|
|
10750
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10751
|
+
Form$2.Field,
|
|
10752
|
+
{
|
|
10753
|
+
control: form.control,
|
|
10754
|
+
name: `metadata.${index}.key`,
|
|
10755
|
+
render: ({ field: field2 }) => {
|
|
10756
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10757
|
+
GridInput,
|
|
10758
|
+
{
|
|
10759
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10760
|
+
...field2,
|
|
10761
|
+
disabled: isDisabled,
|
|
10762
|
+
placeholder: "Key"
|
|
10763
|
+
}
|
|
10764
|
+
) }) });
|
|
10765
|
+
}
|
|
10766
|
+
}
|
|
10767
|
+
),
|
|
10768
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10769
|
+
Form$2.Field,
|
|
10770
|
+
{
|
|
10771
|
+
control: form.control,
|
|
10772
|
+
name: `metadata.${index}.value`,
|
|
10773
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10774
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10775
|
+
GridInput,
|
|
10776
|
+
{
|
|
10777
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
10778
|
+
...field2,
|
|
10779
|
+
value: isDisabled ? placeholder : value,
|
|
10780
|
+
disabled: isDisabled,
|
|
10781
|
+
placeholder: "Value"
|
|
10782
|
+
}
|
|
10783
|
+
) }) });
|
|
10784
|
+
}
|
|
10785
|
+
}
|
|
10786
|
+
)
|
|
10787
|
+
]
|
|
10788
|
+
}
|
|
10789
|
+
),
|
|
10790
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
10791
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10792
|
+
ui.DropdownMenu.Trigger,
|
|
10793
|
+
{
|
|
10794
|
+
className: ui.clx(
|
|
10795
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
10796
|
+
{
|
|
10797
|
+
hidden: isDisabled
|
|
10798
|
+
}
|
|
10799
|
+
),
|
|
10800
|
+
disabled: isDisabled,
|
|
10801
|
+
asChild: true,
|
|
10802
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
10803
|
+
}
|
|
10804
|
+
),
|
|
10805
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
10806
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10807
|
+
ui.DropdownMenu.Item,
|
|
10808
|
+
{
|
|
10809
|
+
className: "gap-x-2",
|
|
10810
|
+
onClick: () => insertRow(index, "above"),
|
|
10811
|
+
children: [
|
|
10812
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
10813
|
+
"Insert row above"
|
|
10814
|
+
]
|
|
10815
|
+
}
|
|
10816
|
+
),
|
|
10817
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10818
|
+
ui.DropdownMenu.Item,
|
|
10819
|
+
{
|
|
10820
|
+
className: "gap-x-2",
|
|
10821
|
+
onClick: () => insertRow(index, "below"),
|
|
10822
|
+
children: [
|
|
10823
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
10824
|
+
"Insert row below"
|
|
10825
|
+
]
|
|
10826
|
+
}
|
|
10827
|
+
),
|
|
10828
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
10829
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10830
|
+
ui.DropdownMenu.Item,
|
|
10831
|
+
{
|
|
10832
|
+
className: "gap-x-2",
|
|
10833
|
+
onClick: () => deleteRow(index),
|
|
10834
|
+
children: [
|
|
10835
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
10836
|
+
"Delete row"
|
|
10837
|
+
]
|
|
10838
|
+
}
|
|
10839
|
+
)
|
|
10840
|
+
] })
|
|
10841
|
+
] })
|
|
10842
|
+
] })
|
|
10843
|
+
},
|
|
10844
|
+
field.id
|
|
10845
|
+
);
|
|
10846
|
+
})
|
|
10847
|
+
] }),
|
|
10848
|
+
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." })
|
|
10849
|
+
] }),
|
|
10850
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10851
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10852
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10853
|
+
] }) })
|
|
10854
|
+
]
|
|
10855
|
+
}
|
|
10856
|
+
) });
|
|
10812
10857
|
};
|
|
10813
|
-
const
|
|
10814
|
-
|
|
10858
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
10859
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10860
|
+
"input",
|
|
10861
|
+
{
|
|
10862
|
+
ref,
|
|
10863
|
+
...props,
|
|
10864
|
+
autoComplete: "off",
|
|
10865
|
+
className: ui.clx(
|
|
10866
|
+
"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",
|
|
10867
|
+
className
|
|
10868
|
+
)
|
|
10869
|
+
}
|
|
10870
|
+
);
|
|
10815
10871
|
});
|
|
10872
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
10873
|
+
const PlaceholderInner = () => {
|
|
10874
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
10875
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
10876
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10877
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
10878
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
10879
|
+
] }) })
|
|
10880
|
+
] });
|
|
10881
|
+
};
|
|
10882
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
10883
|
+
function getDefaultValues(metadata) {
|
|
10884
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
10885
|
+
return [
|
|
10886
|
+
{
|
|
10887
|
+
key: "",
|
|
10888
|
+
value: "",
|
|
10889
|
+
disabled: false
|
|
10890
|
+
}
|
|
10891
|
+
];
|
|
10892
|
+
}
|
|
10893
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
10894
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
10895
|
+
return {
|
|
10896
|
+
key,
|
|
10897
|
+
value,
|
|
10898
|
+
disabled: true
|
|
10899
|
+
};
|
|
10900
|
+
}
|
|
10901
|
+
let stringValue = value;
|
|
10902
|
+
if (typeof value !== "string") {
|
|
10903
|
+
stringValue = JSON.stringify(value);
|
|
10904
|
+
}
|
|
10905
|
+
return {
|
|
10906
|
+
key,
|
|
10907
|
+
value: stringValue,
|
|
10908
|
+
original_key: key
|
|
10909
|
+
};
|
|
10910
|
+
});
|
|
10911
|
+
}
|
|
10912
|
+
function parseValues(values) {
|
|
10913
|
+
const metadata = values.metadata;
|
|
10914
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
10915
|
+
if (isEmpty) {
|
|
10916
|
+
return null;
|
|
10917
|
+
}
|
|
10918
|
+
const update = {};
|
|
10919
|
+
metadata.forEach((field) => {
|
|
10920
|
+
let key = field.key;
|
|
10921
|
+
let value = field.value;
|
|
10922
|
+
const disabled = field.disabled;
|
|
10923
|
+
if (!key || !value) {
|
|
10924
|
+
return;
|
|
10925
|
+
}
|
|
10926
|
+
if (disabled) {
|
|
10927
|
+
update[key] = value;
|
|
10928
|
+
return;
|
|
10929
|
+
}
|
|
10930
|
+
key = key.trim();
|
|
10931
|
+
value = value.trim();
|
|
10932
|
+
if (value === "true") {
|
|
10933
|
+
update[key] = true;
|
|
10934
|
+
} else if (value === "false") {
|
|
10935
|
+
update[key] = false;
|
|
10936
|
+
} else {
|
|
10937
|
+
const parsedNumber = parseFloat(value);
|
|
10938
|
+
if (!isNaN(parsedNumber)) {
|
|
10939
|
+
update[key] = parsedNumber;
|
|
10940
|
+
} else {
|
|
10941
|
+
update[key] = value;
|
|
10942
|
+
}
|
|
10943
|
+
}
|
|
10944
|
+
});
|
|
10945
|
+
return update;
|
|
10946
|
+
}
|
|
10947
|
+
function getHasUneditableRows(metadata) {
|
|
10948
|
+
if (!metadata) {
|
|
10949
|
+
return false;
|
|
10950
|
+
}
|
|
10951
|
+
return Object.values(metadata).some(
|
|
10952
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10953
|
+
);
|
|
10954
|
+
}
|
|
10816
10955
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
10817
10956
|
const promotionsQueryKeys = {
|
|
10818
10957
|
list: (query2) => [
|
|
@@ -11118,7 +11257,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11118
11257
|
defaultValues: {
|
|
11119
11258
|
sales_channel_id: order.sales_channel_id || ""
|
|
11120
11259
|
},
|
|
11121
|
-
resolver: zod.zodResolver(schema$
|
|
11260
|
+
resolver: zod.zodResolver(schema$4)
|
|
11122
11261
|
});
|
|
11123
11262
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11124
11263
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11193,7 +11332,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11193
11332
|
}
|
|
11194
11333
|
);
|
|
11195
11334
|
};
|
|
11196
|
-
const schema$
|
|
11335
|
+
const schema$4 = objectType({
|
|
11197
11336
|
sales_channel_id: stringType().min(1)
|
|
11198
11337
|
});
|
|
11199
11338
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -12035,7 +12174,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12035
12174
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12036
12175
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12037
12176
|
},
|
|
12038
|
-
resolver: zod.zodResolver(schema$
|
|
12177
|
+
resolver: zod.zodResolver(schema$3)
|
|
12039
12178
|
});
|
|
12040
12179
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12041
12180
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12205,7 +12344,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12205
12344
|
}
|
|
12206
12345
|
) });
|
|
12207
12346
|
};
|
|
12208
|
-
const schema$
|
|
12347
|
+
const schema$3 = addressSchema;
|
|
12209
12348
|
const TransferOwnership = () => {
|
|
12210
12349
|
const { id } = reactRouterDom.useParams();
|
|
12211
12350
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12229,7 +12368,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12229
12368
|
defaultValues: {
|
|
12230
12369
|
customer_id: order.customer_id || ""
|
|
12231
12370
|
},
|
|
12232
|
-
resolver: zod.zodResolver(schema)
|
|
12371
|
+
resolver: zod.zodResolver(schema$2)
|
|
12233
12372
|
});
|
|
12234
12373
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12235
12374
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12679,57 +12818,34 @@ const Illustration = () => {
|
|
|
12679
12818
|
}
|
|
12680
12819
|
);
|
|
12681
12820
|
};
|
|
12682
|
-
const schema = objectType({
|
|
12821
|
+
const schema$2 = objectType({
|
|
12683
12822
|
customer_id: stringType().min(1)
|
|
12684
12823
|
});
|
|
12685
|
-
const
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
}
|
|
12706
|
-
),
|
|
12707
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
12708
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
12709
|
-
labelValue,
|
|
12710
|
-
":"
|
|
12711
|
-
] }),
|
|
12712
|
-
" ",
|
|
12713
|
-
children
|
|
12714
|
-
] })
|
|
12715
|
-
]
|
|
12716
|
-
}
|
|
12717
|
-
);
|
|
12718
|
-
}
|
|
12719
|
-
);
|
|
12720
|
-
InlineTip.displayName = "InlineTip";
|
|
12721
|
-
const MetadataFieldSchema = objectType({
|
|
12722
|
-
key: stringType(),
|
|
12723
|
-
disabled: booleanType().optional(),
|
|
12724
|
-
value: anyType()
|
|
12725
|
-
});
|
|
12726
|
-
const MetadataSchema = objectType({
|
|
12727
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
12824
|
+
const CustomItems = () => {
|
|
12825
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12826
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
12827
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
12828
|
+
] });
|
|
12829
|
+
};
|
|
12830
|
+
const CustomItemsForm = () => {
|
|
12831
|
+
const form = reactHookForm.useForm({
|
|
12832
|
+
resolver: zod.zodResolver(schema$1)
|
|
12833
|
+
});
|
|
12834
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12835
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
12836
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12837
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12838
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
12839
|
+
] }) })
|
|
12840
|
+
] }) });
|
|
12841
|
+
};
|
|
12842
|
+
const schema$1 = objectType({
|
|
12843
|
+
email: stringType().email()
|
|
12728
12844
|
});
|
|
12729
|
-
const
|
|
12845
|
+
const BillingAddress = () => {
|
|
12730
12846
|
const { id } = reactRouterDom.useParams();
|
|
12731
12847
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12732
|
-
fields: "
|
|
12848
|
+
fields: "+billing_address"
|
|
12733
12849
|
});
|
|
12734
12850
|
if (isError) {
|
|
12735
12851
|
throw error;
|
|
@@ -12737,33 +12853,36 @@ const Metadata = () => {
|
|
|
12737
12853
|
const isReady = !isPending && !!order;
|
|
12738
12854
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12739
12855
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12740
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
12741
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
12856
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
12857
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12742
12858
|
] }),
|
|
12743
|
-
|
|
12859
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
12744
12860
|
] });
|
|
12745
12861
|
};
|
|
12746
|
-
const
|
|
12747
|
-
|
|
12748
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
12749
|
-
const { handleSuccess } = useRouteModal();
|
|
12750
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
12751
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
12862
|
+
const BillingAddressForm = ({ order }) => {
|
|
12863
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12752
12864
|
const form = reactHookForm.useForm({
|
|
12753
12865
|
defaultValues: {
|
|
12754
|
-
|
|
12866
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12867
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12868
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12869
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12870
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12871
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12872
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12873
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12874
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12875
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12755
12876
|
},
|
|
12756
|
-
resolver: zod.zodResolver(
|
|
12877
|
+
resolver: zod.zodResolver(schema)
|
|
12757
12878
|
});
|
|
12758
|
-
const
|
|
12759
|
-
|
|
12879
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12880
|
+
const { handleSuccess } = useRouteModal();
|
|
12881
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12760
12882
|
await mutateAsync(
|
|
12761
|
-
{
|
|
12762
|
-
metadata: parsedData
|
|
12763
|
-
},
|
|
12883
|
+
{ billing_address: data },
|
|
12764
12884
|
{
|
|
12765
12885
|
onSuccess: () => {
|
|
12766
|
-
ui.toast.success("Metadata updated");
|
|
12767
12886
|
handleSuccess();
|
|
12768
12887
|
},
|
|
12769
12888
|
onError: (error) => {
|
|
@@ -12772,266 +12891,147 @@ const MetadataForm = ({ orderId, metadata }) => {
|
|
|
12772
12891
|
}
|
|
12773
12892
|
);
|
|
12774
12893
|
});
|
|
12775
|
-
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
12776
|
-
control: form.control,
|
|
12777
|
-
name: "metadata"
|
|
12778
|
-
});
|
|
12779
|
-
function deleteRow(index) {
|
|
12780
|
-
remove(index);
|
|
12781
|
-
if (fields.length === 1) {
|
|
12782
|
-
insert(0, {
|
|
12783
|
-
key: "",
|
|
12784
|
-
value: "",
|
|
12785
|
-
disabled: false
|
|
12786
|
-
});
|
|
12787
|
-
}
|
|
12788
|
-
}
|
|
12789
|
-
function insertRow(index, position) {
|
|
12790
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
12791
|
-
key: "",
|
|
12792
|
-
value: "",
|
|
12793
|
-
disabled: false
|
|
12794
|
-
});
|
|
12795
|
-
}
|
|
12796
12894
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12797
12895
|
KeyboundForm,
|
|
12798
12896
|
{
|
|
12799
|
-
onSubmit: handleSubmit,
|
|
12800
12897
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12898
|
+
onSubmit,
|
|
12801
12899
|
children: [
|
|
12802
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12803
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12900
|
+
/* @__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: [
|
|
12901
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12902
|
+
Form$2.Field,
|
|
12903
|
+
{
|
|
12904
|
+
control: form.control,
|
|
12905
|
+
name: "country_code",
|
|
12906
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12907
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12908
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12909
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12910
|
+
] })
|
|
12911
|
+
}
|
|
12912
|
+
),
|
|
12913
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12914
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12915
|
+
Form$2.Field,
|
|
12916
|
+
{
|
|
12917
|
+
control: form.control,
|
|
12918
|
+
name: "first_name",
|
|
12919
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12920
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12921
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12922
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12923
|
+
] })
|
|
12813
12924
|
}
|
|
12814
|
-
|
|
12815
|
-
|
|
12925
|
+
),
|
|
12926
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12927
|
+
Form$2.Field,
|
|
12928
|
+
{
|
|
12929
|
+
control: form.control,
|
|
12930
|
+
name: "last_name",
|
|
12931
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12932
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12933
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12934
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12935
|
+
] })
|
|
12936
|
+
}
|
|
12937
|
+
)
|
|
12938
|
+
] }),
|
|
12939
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12940
|
+
Form$2.Field,
|
|
12941
|
+
{
|
|
12942
|
+
control: form.control,
|
|
12943
|
+
name: "company",
|
|
12944
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12945
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12946
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12947
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12948
|
+
] })
|
|
12949
|
+
}
|
|
12950
|
+
),
|
|
12951
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12952
|
+
Form$2.Field,
|
|
12953
|
+
{
|
|
12954
|
+
control: form.control,
|
|
12955
|
+
name: "address_1",
|
|
12956
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12957
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12958
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12959
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12960
|
+
] })
|
|
12961
|
+
}
|
|
12962
|
+
),
|
|
12963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12964
|
+
Form$2.Field,
|
|
12965
|
+
{
|
|
12966
|
+
control: form.control,
|
|
12967
|
+
name: "address_2",
|
|
12968
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12969
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12970
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12971
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12972
|
+
] })
|
|
12973
|
+
}
|
|
12974
|
+
),
|
|
12975
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12976
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12977
|
+
Form$2.Field,
|
|
12978
|
+
{
|
|
12979
|
+
control: form.control,
|
|
12980
|
+
name: "postal_code",
|
|
12981
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12982
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12983
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12985
|
+
] })
|
|
12986
|
+
}
|
|
12987
|
+
),
|
|
12988
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12989
|
+
Form$2.Field,
|
|
12990
|
+
{
|
|
12991
|
+
control: form.control,
|
|
12992
|
+
name: "city",
|
|
12993
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12994
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
12995
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12996
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12997
|
+
] })
|
|
12816
12998
|
}
|
|
12817
|
-
|
|
12818
|
-
ConditionalTooltip,
|
|
12819
|
-
{
|
|
12820
|
-
showTooltip: isDisabled,
|
|
12821
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
12822
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
12823
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12824
|
-
"div",
|
|
12825
|
-
{
|
|
12826
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
12827
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
12828
|
-
}),
|
|
12829
|
-
children: [
|
|
12830
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12831
|
-
Form$2.Field,
|
|
12832
|
-
{
|
|
12833
|
-
control: form.control,
|
|
12834
|
-
name: `metadata.${index}.key`,
|
|
12835
|
-
render: ({ field: field2 }) => {
|
|
12836
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12837
|
-
GridInput,
|
|
12838
|
-
{
|
|
12839
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
12840
|
-
...field2,
|
|
12841
|
-
disabled: isDisabled,
|
|
12842
|
-
placeholder: "Key"
|
|
12843
|
-
}
|
|
12844
|
-
) }) });
|
|
12845
|
-
}
|
|
12846
|
-
}
|
|
12847
|
-
),
|
|
12848
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12849
|
-
Form$2.Field,
|
|
12850
|
-
{
|
|
12851
|
-
control: form.control,
|
|
12852
|
-
name: `metadata.${index}.value`,
|
|
12853
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
12854
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12855
|
-
GridInput,
|
|
12856
|
-
{
|
|
12857
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
12858
|
-
...field2,
|
|
12859
|
-
value: isDisabled ? placeholder : value,
|
|
12860
|
-
disabled: isDisabled,
|
|
12861
|
-
placeholder: "Value"
|
|
12862
|
-
}
|
|
12863
|
-
) }) });
|
|
12864
|
-
}
|
|
12865
|
-
}
|
|
12866
|
-
)
|
|
12867
|
-
]
|
|
12868
|
-
}
|
|
12869
|
-
),
|
|
12870
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
12871
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12872
|
-
ui.DropdownMenu.Trigger,
|
|
12873
|
-
{
|
|
12874
|
-
className: ui.clx(
|
|
12875
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
12876
|
-
{
|
|
12877
|
-
hidden: isDisabled
|
|
12878
|
-
}
|
|
12879
|
-
),
|
|
12880
|
-
disabled: isDisabled,
|
|
12881
|
-
asChild: true,
|
|
12882
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
12883
|
-
}
|
|
12884
|
-
),
|
|
12885
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
12886
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12887
|
-
ui.DropdownMenu.Item,
|
|
12888
|
-
{
|
|
12889
|
-
className: "gap-x-2",
|
|
12890
|
-
onClick: () => insertRow(index, "above"),
|
|
12891
|
-
children: [
|
|
12892
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
12893
|
-
"Insert row above"
|
|
12894
|
-
]
|
|
12895
|
-
}
|
|
12896
|
-
),
|
|
12897
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12898
|
-
ui.DropdownMenu.Item,
|
|
12899
|
-
{
|
|
12900
|
-
className: "gap-x-2",
|
|
12901
|
-
onClick: () => insertRow(index, "below"),
|
|
12902
|
-
children: [
|
|
12903
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
12904
|
-
"Insert row below"
|
|
12905
|
-
]
|
|
12906
|
-
}
|
|
12907
|
-
),
|
|
12908
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
12909
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12910
|
-
ui.DropdownMenu.Item,
|
|
12911
|
-
{
|
|
12912
|
-
className: "gap-x-2",
|
|
12913
|
-
onClick: () => deleteRow(index),
|
|
12914
|
-
children: [
|
|
12915
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
12916
|
-
"Delete row"
|
|
12917
|
-
]
|
|
12918
|
-
}
|
|
12919
|
-
)
|
|
12920
|
-
] })
|
|
12921
|
-
] })
|
|
12922
|
-
] })
|
|
12923
|
-
},
|
|
12924
|
-
field.id
|
|
12925
|
-
);
|
|
12926
|
-
})
|
|
12999
|
+
)
|
|
12927
13000
|
] }),
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
13001
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13002
|
+
Form$2.Field,
|
|
13003
|
+
{
|
|
13004
|
+
control: form.control,
|
|
13005
|
+
name: "province",
|
|
13006
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13007
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13008
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13009
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13010
|
+
] })
|
|
13011
|
+
}
|
|
13012
|
+
),
|
|
13013
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13014
|
+
Form$2.Field,
|
|
13015
|
+
{
|
|
13016
|
+
control: form.control,
|
|
13017
|
+
name: "phone",
|
|
13018
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13019
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13022
|
+
] })
|
|
13023
|
+
}
|
|
13024
|
+
)
|
|
13025
|
+
] }) }),
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13027
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12932
13028
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12933
13029
|
] }) })
|
|
12934
13030
|
]
|
|
12935
13031
|
}
|
|
12936
13032
|
) });
|
|
12937
13033
|
};
|
|
12938
|
-
const
|
|
12939
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12940
|
-
"input",
|
|
12941
|
-
{
|
|
12942
|
-
ref,
|
|
12943
|
-
...props,
|
|
12944
|
-
autoComplete: "off",
|
|
12945
|
-
className: ui.clx(
|
|
12946
|
-
"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",
|
|
12947
|
-
className
|
|
12948
|
-
)
|
|
12949
|
-
}
|
|
12950
|
-
);
|
|
12951
|
-
});
|
|
12952
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
12953
|
-
const PlaceholderInner = () => {
|
|
12954
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12955
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
12956
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12957
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
12958
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
12959
|
-
] }) })
|
|
12960
|
-
] });
|
|
12961
|
-
};
|
|
12962
|
-
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
12963
|
-
function getDefaultValues(metadata) {
|
|
12964
|
-
if (!metadata || !Object.keys(metadata).length) {
|
|
12965
|
-
return [
|
|
12966
|
-
{
|
|
12967
|
-
key: "",
|
|
12968
|
-
value: "",
|
|
12969
|
-
disabled: false
|
|
12970
|
-
}
|
|
12971
|
-
];
|
|
12972
|
-
}
|
|
12973
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
12974
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
12975
|
-
return {
|
|
12976
|
-
key,
|
|
12977
|
-
value,
|
|
12978
|
-
disabled: true
|
|
12979
|
-
};
|
|
12980
|
-
}
|
|
12981
|
-
let stringValue = value;
|
|
12982
|
-
if (typeof value !== "string") {
|
|
12983
|
-
stringValue = JSON.stringify(value);
|
|
12984
|
-
}
|
|
12985
|
-
return {
|
|
12986
|
-
key,
|
|
12987
|
-
value: stringValue,
|
|
12988
|
-
original_key: key
|
|
12989
|
-
};
|
|
12990
|
-
});
|
|
12991
|
-
}
|
|
12992
|
-
function parseValues(values) {
|
|
12993
|
-
const metadata = values.metadata;
|
|
12994
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
12995
|
-
if (isEmpty) {
|
|
12996
|
-
return null;
|
|
12997
|
-
}
|
|
12998
|
-
const update = {};
|
|
12999
|
-
metadata.forEach((field) => {
|
|
13000
|
-
let key = field.key;
|
|
13001
|
-
let value = field.value;
|
|
13002
|
-
const disabled = field.disabled;
|
|
13003
|
-
if (!key || !value) {
|
|
13004
|
-
return;
|
|
13005
|
-
}
|
|
13006
|
-
if (disabled) {
|
|
13007
|
-
update[key] = value;
|
|
13008
|
-
return;
|
|
13009
|
-
}
|
|
13010
|
-
key = key.trim();
|
|
13011
|
-
value = value.trim();
|
|
13012
|
-
if (value === "true") {
|
|
13013
|
-
update[key] = true;
|
|
13014
|
-
} else if (value === "false") {
|
|
13015
|
-
update[key] = false;
|
|
13016
|
-
} else {
|
|
13017
|
-
const parsedNumber = parseFloat(value);
|
|
13018
|
-
if (!isNaN(parsedNumber)) {
|
|
13019
|
-
update[key] = parsedNumber;
|
|
13020
|
-
} else {
|
|
13021
|
-
update[key] = value;
|
|
13022
|
-
}
|
|
13023
|
-
}
|
|
13024
|
-
});
|
|
13025
|
-
return update;
|
|
13026
|
-
}
|
|
13027
|
-
function getHasUneditableRows(metadata) {
|
|
13028
|
-
if (!metadata) {
|
|
13029
|
-
return false;
|
|
13030
|
-
}
|
|
13031
|
-
return Object.values(metadata).some(
|
|
13032
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
13033
|
-
);
|
|
13034
|
-
}
|
|
13034
|
+
const schema = addressSchema;
|
|
13035
13035
|
const widgetModule = { widgets: [] };
|
|
13036
13036
|
const routeModule = {
|
|
13037
13037
|
routes: [
|
|
@@ -13052,10 +13052,6 @@ const routeModule = {
|
|
|
13052
13052
|
handle,
|
|
13053
13053
|
loader,
|
|
13054
13054
|
children: [
|
|
13055
|
-
{
|
|
13056
|
-
Component: BillingAddress,
|
|
13057
|
-
path: "/draft-orders/:id/billing-address"
|
|
13058
|
-
},
|
|
13059
13055
|
{
|
|
13060
13056
|
Component: Email,
|
|
13061
13057
|
path: "/draft-orders/:id/email"
|
|
@@ -13065,8 +13061,8 @@ const routeModule = {
|
|
|
13065
13061
|
path: "/draft-orders/:id/items"
|
|
13066
13062
|
},
|
|
13067
13063
|
{
|
|
13068
|
-
Component:
|
|
13069
|
-
path: "/draft-orders/:id/
|
|
13064
|
+
Component: Metadata,
|
|
13065
|
+
path: "/draft-orders/:id/metadata"
|
|
13070
13066
|
},
|
|
13071
13067
|
{
|
|
13072
13068
|
Component: Promotions,
|
|
@@ -13089,8 +13085,12 @@ const routeModule = {
|
|
|
13089
13085
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13090
13086
|
},
|
|
13091
13087
|
{
|
|
13092
|
-
Component:
|
|
13093
|
-
path: "/draft-orders/:id/
|
|
13088
|
+
Component: CustomItems,
|
|
13089
|
+
path: "/draft-orders/:id/custom-items"
|
|
13090
|
+
},
|
|
13091
|
+
{
|
|
13092
|
+
Component: BillingAddress,
|
|
13093
|
+
path: "/draft-orders/:id/billing-address"
|
|
13094
13094
|
}
|
|
13095
13095
|
]
|
|
13096
13096
|
}
|