@medusajs/draft-order 2.22.6 → 2.22.7-snapshot-20261112111749
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 +532 -532
- package/.medusa/server/src/admin/index.mjs +532 -532
- package/package.json +18 -18
|
@@ -6098,198 +6098,6 @@ const ID = () => {
|
|
|
6098
6098
|
}
|
|
6099
6099
|
);
|
|
6100
6100
|
};
|
|
6101
|
-
const BillingAddress = () => {
|
|
6102
|
-
const { id } = reactRouterDom.useParams();
|
|
6103
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
6104
|
-
fields: "+billing_address"
|
|
6105
|
-
});
|
|
6106
|
-
if (isError) {
|
|
6107
|
-
throw error;
|
|
6108
|
-
}
|
|
6109
|
-
const isReady = !isPending && !!order;
|
|
6110
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
6111
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
6112
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
6113
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
6114
|
-
] }),
|
|
6115
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
6116
|
-
] });
|
|
6117
|
-
};
|
|
6118
|
-
const BillingAddressForm = ({ order }) => {
|
|
6119
|
-
const form = reactHookForm.useForm({
|
|
6120
|
-
defaultValues: {
|
|
6121
|
-
first_name: order.billing_address?.first_name ?? "",
|
|
6122
|
-
last_name: order.billing_address?.last_name ?? "",
|
|
6123
|
-
company: order.billing_address?.company ?? "",
|
|
6124
|
-
address_1: order.billing_address?.address_1 ?? "",
|
|
6125
|
-
address_2: order.billing_address?.address_2 ?? "",
|
|
6126
|
-
city: order.billing_address?.city ?? "",
|
|
6127
|
-
province: order.billing_address?.province ?? "",
|
|
6128
|
-
country_code: order.billing_address?.country_code ?? "",
|
|
6129
|
-
postal_code: order.billing_address?.postal_code ?? "",
|
|
6130
|
-
phone: order.billing_address?.phone ?? ""
|
|
6131
|
-
},
|
|
6132
|
-
resolver: zod$1.zodResolver(schema$5)
|
|
6133
|
-
});
|
|
6134
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6135
|
-
const { handleSuccess } = useRouteModal();
|
|
6136
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
6137
|
-
await mutateAsync(
|
|
6138
|
-
{ billing_address: data },
|
|
6139
|
-
{
|
|
6140
|
-
onSuccess: () => {
|
|
6141
|
-
handleSuccess();
|
|
6142
|
-
},
|
|
6143
|
-
onError: (error) => {
|
|
6144
|
-
ui.toast.error(error.message);
|
|
6145
|
-
}
|
|
6146
|
-
}
|
|
6147
|
-
);
|
|
6148
|
-
});
|
|
6149
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6150
|
-
KeyboundForm,
|
|
6151
|
-
{
|
|
6152
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
6153
|
-
onSubmit,
|
|
6154
|
-
children: [
|
|
6155
|
-
/* @__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: [
|
|
6156
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6157
|
-
Form$2.Field,
|
|
6158
|
-
{
|
|
6159
|
-
control: form.control,
|
|
6160
|
-
name: "country_code",
|
|
6161
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6162
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
6163
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
6164
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6165
|
-
] })
|
|
6166
|
-
}
|
|
6167
|
-
),
|
|
6168
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
6169
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6170
|
-
Form$2.Field,
|
|
6171
|
-
{
|
|
6172
|
-
control: form.control,
|
|
6173
|
-
name: "first_name",
|
|
6174
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6175
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
6176
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6177
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6178
|
-
] })
|
|
6179
|
-
}
|
|
6180
|
-
),
|
|
6181
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6182
|
-
Form$2.Field,
|
|
6183
|
-
{
|
|
6184
|
-
control: form.control,
|
|
6185
|
-
name: "last_name",
|
|
6186
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6187
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
6188
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6189
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6190
|
-
] })
|
|
6191
|
-
}
|
|
6192
|
-
)
|
|
6193
|
-
] }),
|
|
6194
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6195
|
-
Form$2.Field,
|
|
6196
|
-
{
|
|
6197
|
-
control: form.control,
|
|
6198
|
-
name: "company",
|
|
6199
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6200
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
6201
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6202
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6203
|
-
] })
|
|
6204
|
-
}
|
|
6205
|
-
),
|
|
6206
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6207
|
-
Form$2.Field,
|
|
6208
|
-
{
|
|
6209
|
-
control: form.control,
|
|
6210
|
-
name: "address_1",
|
|
6211
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6212
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
6213
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6214
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6215
|
-
] })
|
|
6216
|
-
}
|
|
6217
|
-
),
|
|
6218
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6219
|
-
Form$2.Field,
|
|
6220
|
-
{
|
|
6221
|
-
control: form.control,
|
|
6222
|
-
name: "address_2",
|
|
6223
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6224
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
6225
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6226
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6227
|
-
] })
|
|
6228
|
-
}
|
|
6229
|
-
),
|
|
6230
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
6231
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6232
|
-
Form$2.Field,
|
|
6233
|
-
{
|
|
6234
|
-
control: form.control,
|
|
6235
|
-
name: "postal_code",
|
|
6236
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6237
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
6238
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6239
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6240
|
-
] })
|
|
6241
|
-
}
|
|
6242
|
-
),
|
|
6243
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6244
|
-
Form$2.Field,
|
|
6245
|
-
{
|
|
6246
|
-
control: form.control,
|
|
6247
|
-
name: "city",
|
|
6248
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6249
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
6250
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6251
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6252
|
-
] })
|
|
6253
|
-
}
|
|
6254
|
-
)
|
|
6255
|
-
] }),
|
|
6256
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6257
|
-
Form$2.Field,
|
|
6258
|
-
{
|
|
6259
|
-
control: form.control,
|
|
6260
|
-
name: "province",
|
|
6261
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6262
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
6263
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6264
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6265
|
-
] })
|
|
6266
|
-
}
|
|
6267
|
-
),
|
|
6268
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6269
|
-
Form$2.Field,
|
|
6270
|
-
{
|
|
6271
|
-
control: form.control,
|
|
6272
|
-
name: "phone",
|
|
6273
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6274
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
6275
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6276
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6277
|
-
] })
|
|
6278
|
-
}
|
|
6279
|
-
)
|
|
6280
|
-
] }) }),
|
|
6281
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6282
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6283
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
6284
|
-
] }) })
|
|
6285
|
-
]
|
|
6286
|
-
}
|
|
6287
|
-
) });
|
|
6288
|
-
};
|
|
6289
|
-
const schema$5 = addressSchema;
|
|
6290
|
-
const handle$9 = {
|
|
6291
|
-
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
6292
|
-
};
|
|
6293
6101
|
const CustomItems = () => {
|
|
6294
6102
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
6295
6103
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -6298,7 +6106,7 @@ const CustomItems = () => {
|
|
|
6298
6106
|
};
|
|
6299
6107
|
const CustomItemsForm = () => {
|
|
6300
6108
|
const form = reactHookForm.useForm({
|
|
6301
|
-
resolver: zod$1.zodResolver(schema$
|
|
6109
|
+
resolver: zod$1.zodResolver(schema$5)
|
|
6302
6110
|
});
|
|
6303
6111
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
6304
6112
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -6308,10 +6116,10 @@ const CustomItemsForm = () => {
|
|
|
6308
6116
|
] }) })
|
|
6309
6117
|
] }) });
|
|
6310
6118
|
};
|
|
6311
|
-
const schema$
|
|
6119
|
+
const schema$5 = zod.z.object({
|
|
6312
6120
|
email: zod.z.string().email()
|
|
6313
6121
|
});
|
|
6314
|
-
const handle$
|
|
6122
|
+
const handle$9 = {
|
|
6315
6123
|
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
6316
6124
|
};
|
|
6317
6125
|
const Email = () => {
|
|
@@ -6336,7 +6144,7 @@ const EmailForm = ({ order }) => {
|
|
|
6336
6144
|
defaultValues: {
|
|
6337
6145
|
email: order.email ?? ""
|
|
6338
6146
|
},
|
|
6339
|
-
resolver: zod$1.zodResolver(schema$
|
|
6147
|
+
resolver: zod$1.zodResolver(schema$4)
|
|
6340
6148
|
});
|
|
6341
6149
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6342
6150
|
const { handleSuccess } = useRouteModal();
|
|
@@ -6379,10 +6187,10 @@ const EmailForm = ({ order }) => {
|
|
|
6379
6187
|
}
|
|
6380
6188
|
) });
|
|
6381
6189
|
};
|
|
6382
|
-
const schema$
|
|
6190
|
+
const schema$4 = zod.z.object({
|
|
6383
6191
|
email: zod.z.string().email()
|
|
6384
6192
|
});
|
|
6385
|
-
const handle$
|
|
6193
|
+
const handle$8 = {
|
|
6386
6194
|
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
6387
6195
|
};
|
|
6388
6196
|
const NumberInput = React.forwardRef(
|
|
@@ -7406,57 +7214,13 @@ const customItemSchema = zod.z.object({
|
|
|
7406
7214
|
quantity: zod.z.number(),
|
|
7407
7215
|
unit_price: zod.z.union([zod.z.number(), zod.z.string()])
|
|
7408
7216
|
});
|
|
7409
|
-
const handle$
|
|
7217
|
+
const handle$7 = {
|
|
7410
7218
|
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
7411
7219
|
};
|
|
7412
|
-
const
|
|
7413
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
7414
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
7415
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7416
|
-
"div",
|
|
7417
|
-
{
|
|
7418
|
-
ref,
|
|
7419
|
-
className: ui.clx(
|
|
7420
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
7421
|
-
className
|
|
7422
|
-
),
|
|
7423
|
-
...props,
|
|
7424
|
-
children: [
|
|
7425
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7426
|
-
"div",
|
|
7427
|
-
{
|
|
7428
|
-
role: "presentation",
|
|
7429
|
-
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
7430
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
7431
|
-
})
|
|
7432
|
-
}
|
|
7433
|
-
),
|
|
7434
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
7435
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
7436
|
-
labelValue,
|
|
7437
|
-
":"
|
|
7438
|
-
] }),
|
|
7439
|
-
" ",
|
|
7440
|
-
children
|
|
7441
|
-
] })
|
|
7442
|
-
]
|
|
7443
|
-
}
|
|
7444
|
-
);
|
|
7445
|
-
}
|
|
7446
|
-
);
|
|
7447
|
-
InlineTip.displayName = "InlineTip";
|
|
7448
|
-
const MetadataFieldSchema = zod.z.object({
|
|
7449
|
-
key: zod.z.string(),
|
|
7450
|
-
disabled: zod.z.boolean().optional(),
|
|
7451
|
-
value: zod.z.any()
|
|
7452
|
-
});
|
|
7453
|
-
const MetadataSchema = zod.z.object({
|
|
7454
|
-
metadata: zod.z.array(MetadataFieldSchema)
|
|
7455
|
-
});
|
|
7456
|
-
const Metadata = () => {
|
|
7220
|
+
const BillingAddress = () => {
|
|
7457
7221
|
const { id } = reactRouterDom.useParams();
|
|
7458
7222
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
7459
|
-
fields: "
|
|
7223
|
+
fields: "+billing_address"
|
|
7460
7224
|
});
|
|
7461
7225
|
if (isError) {
|
|
7462
7226
|
throw error;
|
|
@@ -7464,33 +7228,35 @@ const Metadata = () => {
|
|
|
7464
7228
|
const isReady = !isPending && !!order;
|
|
7465
7229
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7466
7230
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
7467
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
7468
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
7231
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
7232
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
7469
7233
|
] }),
|
|
7470
|
-
|
|
7234
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
7471
7235
|
] });
|
|
7472
7236
|
};
|
|
7473
|
-
const
|
|
7474
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
7475
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
7476
|
-
const { handleSuccess } = useRouteModal();
|
|
7477
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
7478
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
7237
|
+
const BillingAddressForm = ({ order }) => {
|
|
7479
7238
|
const form = reactHookForm.useForm({
|
|
7480
7239
|
defaultValues: {
|
|
7481
|
-
|
|
7240
|
+
first_name: order.billing_address?.first_name ?? "",
|
|
7241
|
+
last_name: order.billing_address?.last_name ?? "",
|
|
7242
|
+
company: order.billing_address?.company ?? "",
|
|
7243
|
+
address_1: order.billing_address?.address_1 ?? "",
|
|
7244
|
+
address_2: order.billing_address?.address_2 ?? "",
|
|
7245
|
+
city: order.billing_address?.city ?? "",
|
|
7246
|
+
province: order.billing_address?.province ?? "",
|
|
7247
|
+
country_code: order.billing_address?.country_code ?? "",
|
|
7248
|
+
postal_code: order.billing_address?.postal_code ?? "",
|
|
7249
|
+
phone: order.billing_address?.phone ?? ""
|
|
7482
7250
|
},
|
|
7483
|
-
resolver: zod$1.zodResolver(
|
|
7251
|
+
resolver: zod$1.zodResolver(schema$3)
|
|
7484
7252
|
});
|
|
7485
|
-
const
|
|
7486
|
-
|
|
7253
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7254
|
+
const { handleSuccess } = useRouteModal();
|
|
7255
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
7487
7256
|
await mutateAsync(
|
|
7488
|
-
{
|
|
7489
|
-
metadata: parsedData
|
|
7490
|
-
},
|
|
7257
|
+
{ billing_address: data },
|
|
7491
7258
|
{
|
|
7492
7259
|
onSuccess: () => {
|
|
7493
|
-
ui.toast.success("Metadata updated");
|
|
7494
7260
|
handleSuccess();
|
|
7495
7261
|
},
|
|
7496
7262
|
onError: (error) => {
|
|
@@ -7499,267 +7265,148 @@ const MetadataForm = ({ orderId, metadata }) => {
|
|
|
7499
7265
|
}
|
|
7500
7266
|
);
|
|
7501
7267
|
});
|
|
7502
|
-
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
7503
|
-
control: form.control,
|
|
7504
|
-
name: "metadata"
|
|
7505
|
-
});
|
|
7506
|
-
function deleteRow(index) {
|
|
7507
|
-
remove(index);
|
|
7508
|
-
if (fields.length === 1) {
|
|
7509
|
-
insert(0, {
|
|
7510
|
-
key: "",
|
|
7511
|
-
value: "",
|
|
7512
|
-
disabled: false
|
|
7513
|
-
});
|
|
7514
|
-
}
|
|
7515
|
-
}
|
|
7516
|
-
function insertRow(index, position) {
|
|
7517
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
7518
|
-
key: "",
|
|
7519
|
-
value: "",
|
|
7520
|
-
disabled: false
|
|
7521
|
-
});
|
|
7522
|
-
}
|
|
7523
7268
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7524
7269
|
KeyboundForm,
|
|
7525
7270
|
{
|
|
7526
|
-
onSubmit: handleSubmit,
|
|
7527
7271
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
7272
|
+
onSubmit,
|
|
7528
7273
|
children: [
|
|
7529
|
-
/* @__PURE__ */ jsxRuntime.
|
|
7530
|
-
/* @__PURE__ */ jsxRuntime.
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7274
|
+
/* @__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: [
|
|
7275
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7276
|
+
Form$2.Field,
|
|
7277
|
+
{
|
|
7278
|
+
control: form.control,
|
|
7279
|
+
name: "country_code",
|
|
7280
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7281
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
7282
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
7283
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7284
|
+
] })
|
|
7285
|
+
}
|
|
7286
|
+
),
|
|
7287
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
7288
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7289
|
+
Form$2.Field,
|
|
7290
|
+
{
|
|
7291
|
+
control: form.control,
|
|
7292
|
+
name: "first_name",
|
|
7293
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7294
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
7295
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7296
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7297
|
+
] })
|
|
7540
7298
|
}
|
|
7541
|
-
|
|
7542
|
-
|
|
7299
|
+
),
|
|
7300
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7301
|
+
Form$2.Field,
|
|
7302
|
+
{
|
|
7303
|
+
control: form.control,
|
|
7304
|
+
name: "last_name",
|
|
7305
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7306
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
7307
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7308
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7309
|
+
] })
|
|
7543
7310
|
}
|
|
7544
|
-
|
|
7545
|
-
ConditionalTooltip,
|
|
7546
|
-
{
|
|
7547
|
-
showTooltip: isDisabled,
|
|
7548
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
7549
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
7550
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7551
|
-
"div",
|
|
7552
|
-
{
|
|
7553
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
7554
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
7555
|
-
}),
|
|
7556
|
-
children: [
|
|
7557
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7558
|
-
Form$2.Field,
|
|
7559
|
-
{
|
|
7560
|
-
control: form.control,
|
|
7561
|
-
name: `metadata.${index}.key`,
|
|
7562
|
-
render: ({ field: field2 }) => {
|
|
7563
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7564
|
-
GridInput,
|
|
7565
|
-
{
|
|
7566
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
7567
|
-
...field2,
|
|
7568
|
-
disabled: isDisabled,
|
|
7569
|
-
placeholder: "Key"
|
|
7570
|
-
}
|
|
7571
|
-
) }) });
|
|
7572
|
-
}
|
|
7573
|
-
}
|
|
7574
|
-
),
|
|
7575
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7576
|
-
Form$2.Field,
|
|
7577
|
-
{
|
|
7578
|
-
control: form.control,
|
|
7579
|
-
name: `metadata.${index}.value`,
|
|
7580
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
7581
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7582
|
-
GridInput,
|
|
7583
|
-
{
|
|
7584
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
7585
|
-
...field2,
|
|
7586
|
-
value: isDisabled ? placeholder : value,
|
|
7587
|
-
disabled: isDisabled,
|
|
7588
|
-
placeholder: "Value"
|
|
7589
|
-
}
|
|
7590
|
-
) }) });
|
|
7591
|
-
}
|
|
7592
|
-
}
|
|
7593
|
-
)
|
|
7594
|
-
]
|
|
7595
|
-
}
|
|
7596
|
-
),
|
|
7597
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
7598
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7599
|
-
ui.DropdownMenu.Trigger,
|
|
7600
|
-
{
|
|
7601
|
-
className: ui.clx(
|
|
7602
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
7603
|
-
{
|
|
7604
|
-
hidden: isDisabled
|
|
7605
|
-
}
|
|
7606
|
-
),
|
|
7607
|
-
disabled: isDisabled,
|
|
7608
|
-
asChild: true,
|
|
7609
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
7610
|
-
}
|
|
7611
|
-
),
|
|
7612
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
7613
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7614
|
-
ui.DropdownMenu.Item,
|
|
7615
|
-
{
|
|
7616
|
-
className: "gap-x-2",
|
|
7617
|
-
onClick: () => insertRow(index, "above"),
|
|
7618
|
-
children: [
|
|
7619
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
7620
|
-
"Insert row above"
|
|
7621
|
-
]
|
|
7622
|
-
}
|
|
7623
|
-
),
|
|
7624
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7625
|
-
ui.DropdownMenu.Item,
|
|
7626
|
-
{
|
|
7627
|
-
className: "gap-x-2",
|
|
7628
|
-
onClick: () => insertRow(index, "below"),
|
|
7629
|
-
children: [
|
|
7630
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
7631
|
-
"Insert row below"
|
|
7632
|
-
]
|
|
7633
|
-
}
|
|
7634
|
-
),
|
|
7635
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
7636
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7637
|
-
ui.DropdownMenu.Item,
|
|
7638
|
-
{
|
|
7639
|
-
className: "gap-x-2",
|
|
7640
|
-
onClick: () => deleteRow(index),
|
|
7641
|
-
children: [
|
|
7642
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
7643
|
-
"Delete row"
|
|
7644
|
-
]
|
|
7645
|
-
}
|
|
7646
|
-
)
|
|
7647
|
-
] })
|
|
7648
|
-
] })
|
|
7649
|
-
] })
|
|
7650
|
-
},
|
|
7651
|
-
field.id
|
|
7652
|
-
);
|
|
7653
|
-
})
|
|
7311
|
+
)
|
|
7654
7312
|
] }),
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7313
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7314
|
+
Form$2.Field,
|
|
7315
|
+
{
|
|
7316
|
+
control: form.control,
|
|
7317
|
+
name: "company",
|
|
7318
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7319
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
7320
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7321
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7322
|
+
] })
|
|
7323
|
+
}
|
|
7324
|
+
),
|
|
7325
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7326
|
+
Form$2.Field,
|
|
7327
|
+
{
|
|
7328
|
+
control: form.control,
|
|
7329
|
+
name: "address_1",
|
|
7330
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7331
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
7332
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7333
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7334
|
+
] })
|
|
7335
|
+
}
|
|
7336
|
+
),
|
|
7337
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7338
|
+
Form$2.Field,
|
|
7339
|
+
{
|
|
7340
|
+
control: form.control,
|
|
7341
|
+
name: "address_2",
|
|
7342
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7343
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
7344
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7345
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7346
|
+
] })
|
|
7347
|
+
}
|
|
7348
|
+
),
|
|
7349
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
7350
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7351
|
+
Form$2.Field,
|
|
7352
|
+
{
|
|
7353
|
+
control: form.control,
|
|
7354
|
+
name: "postal_code",
|
|
7355
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7356
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
7357
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7358
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7359
|
+
] })
|
|
7360
|
+
}
|
|
7361
|
+
),
|
|
7362
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7363
|
+
Form$2.Field,
|
|
7364
|
+
{
|
|
7365
|
+
control: form.control,
|
|
7366
|
+
name: "city",
|
|
7367
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7368
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
7369
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7370
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7371
|
+
] })
|
|
7372
|
+
}
|
|
7373
|
+
)
|
|
7374
|
+
] }),
|
|
7375
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7376
|
+
Form$2.Field,
|
|
7377
|
+
{
|
|
7378
|
+
control: form.control,
|
|
7379
|
+
name: "province",
|
|
7380
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7381
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
7382
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7383
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7384
|
+
] })
|
|
7385
|
+
}
|
|
7386
|
+
),
|
|
7387
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7388
|
+
Form$2.Field,
|
|
7389
|
+
{
|
|
7390
|
+
control: form.control,
|
|
7391
|
+
name: "phone",
|
|
7392
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7393
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
7394
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7395
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7396
|
+
] })
|
|
7397
|
+
}
|
|
7398
|
+
)
|
|
7399
|
+
] }) }),
|
|
7400
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7401
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7659
7402
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7660
7403
|
] }) })
|
|
7661
7404
|
]
|
|
7662
7405
|
}
|
|
7663
7406
|
) });
|
|
7664
7407
|
};
|
|
7665
|
-
const
|
|
7666
|
-
|
|
7667
|
-
"input",
|
|
7668
|
-
{
|
|
7669
|
-
ref,
|
|
7670
|
-
...props,
|
|
7671
|
-
autoComplete: "off",
|
|
7672
|
-
className: ui.clx(
|
|
7673
|
-
"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",
|
|
7674
|
-
className
|
|
7675
|
-
)
|
|
7676
|
-
}
|
|
7677
|
-
);
|
|
7678
|
-
});
|
|
7679
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
7680
|
-
const PlaceholderInner = () => {
|
|
7681
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
7682
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
7683
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
7684
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
7685
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
7686
|
-
] }) })
|
|
7687
|
-
] });
|
|
7688
|
-
};
|
|
7689
|
-
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
7690
|
-
function getDefaultValues(metadata) {
|
|
7691
|
-
if (!metadata || !Object.keys(metadata).length) {
|
|
7692
|
-
return [
|
|
7693
|
-
{
|
|
7694
|
-
key: "",
|
|
7695
|
-
value: "",
|
|
7696
|
-
disabled: false
|
|
7697
|
-
}
|
|
7698
|
-
];
|
|
7699
|
-
}
|
|
7700
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
7701
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
7702
|
-
return {
|
|
7703
|
-
key,
|
|
7704
|
-
value,
|
|
7705
|
-
disabled: true
|
|
7706
|
-
};
|
|
7707
|
-
}
|
|
7708
|
-
let stringValue = value;
|
|
7709
|
-
if (typeof value !== "string") {
|
|
7710
|
-
stringValue = JSON.stringify(value);
|
|
7711
|
-
}
|
|
7712
|
-
return {
|
|
7713
|
-
key,
|
|
7714
|
-
value: stringValue,
|
|
7715
|
-
original_key: key
|
|
7716
|
-
};
|
|
7717
|
-
});
|
|
7718
|
-
}
|
|
7719
|
-
function parseValues(values) {
|
|
7720
|
-
const metadata = values.metadata;
|
|
7721
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
7722
|
-
if (isEmpty) {
|
|
7723
|
-
return null;
|
|
7724
|
-
}
|
|
7725
|
-
const update = {};
|
|
7726
|
-
metadata.forEach((field) => {
|
|
7727
|
-
let key = field.key;
|
|
7728
|
-
let value = field.value;
|
|
7729
|
-
const disabled = field.disabled;
|
|
7730
|
-
if (!key || !value) {
|
|
7731
|
-
return;
|
|
7732
|
-
}
|
|
7733
|
-
if (disabled) {
|
|
7734
|
-
update[key] = value;
|
|
7735
|
-
return;
|
|
7736
|
-
}
|
|
7737
|
-
key = key.trim();
|
|
7738
|
-
value = value.trim();
|
|
7739
|
-
if (value === "true") {
|
|
7740
|
-
update[key] = true;
|
|
7741
|
-
} else if (value === "false") {
|
|
7742
|
-
update[key] = false;
|
|
7743
|
-
} else {
|
|
7744
|
-
const parsedNumber = parseFloat(value);
|
|
7745
|
-
if (!isNaN(parsedNumber)) {
|
|
7746
|
-
update[key] = parsedNumber;
|
|
7747
|
-
} else {
|
|
7748
|
-
update[key] = value;
|
|
7749
|
-
}
|
|
7750
|
-
}
|
|
7751
|
-
});
|
|
7752
|
-
return update;
|
|
7753
|
-
}
|
|
7754
|
-
function getHasUneditableRows(metadata) {
|
|
7755
|
-
if (!metadata) {
|
|
7756
|
-
return false;
|
|
7757
|
-
}
|
|
7758
|
-
return Object.values(metadata).some(
|
|
7759
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
7760
|
-
);
|
|
7761
|
-
}
|
|
7762
|
-
const handle$5 = {
|
|
7408
|
+
const schema$3 = addressSchema;
|
|
7409
|
+
const handle$6 = {
|
|
7763
7410
|
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
7764
7411
|
};
|
|
7765
7412
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
@@ -8037,7 +7684,7 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
8037
7684
|
}
|
|
8038
7685
|
return Array.from(promotionIds);
|
|
8039
7686
|
}
|
|
8040
|
-
const handle$
|
|
7687
|
+
const handle$5 = {
|
|
8041
7688
|
permissions: EDIT_DRAFT_ORDER_PROMOTIONS_PERMISSIONS
|
|
8042
7689
|
};
|
|
8043
7690
|
const SalesChannel = () => {
|
|
@@ -8146,7 +7793,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
8146
7793
|
const schema$2 = zod.z.object({
|
|
8147
7794
|
sales_channel_id: zod.z.string().min(1)
|
|
8148
7795
|
});
|
|
8149
|
-
const handle$
|
|
7796
|
+
const handle$4 = {
|
|
8150
7797
|
permissions: EDIT_DRAFT_ORDER_SALES_CHANNEL_PERMISSIONS
|
|
8151
7798
|
};
|
|
8152
7799
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -8943,7 +8590,7 @@ const CustomAmountField = ({
|
|
|
8943
8590
|
}
|
|
8944
8591
|
);
|
|
8945
8592
|
};
|
|
8946
|
-
const handle$
|
|
8593
|
+
const handle$3 = {
|
|
8947
8594
|
permissions: EDIT_DRAFT_ORDER_SHIPPING_PERMISSIONS
|
|
8948
8595
|
};
|
|
8949
8596
|
const ShippingAddress = () => {
|
|
@@ -9148,7 +8795,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
9148
8795
|
) });
|
|
9149
8796
|
};
|
|
9150
8797
|
const schema$1 = addressSchema;
|
|
9151
|
-
const handle$
|
|
8798
|
+
const handle$2 = {
|
|
9152
8799
|
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
9153
8800
|
};
|
|
9154
8801
|
const TransferOwnership = () => {
|
|
@@ -9623,13 +9270,366 @@ const Illustration = () => {
|
|
|
9623
9270
|
] })
|
|
9624
9271
|
]
|
|
9625
9272
|
}
|
|
9626
|
-
);
|
|
9273
|
+
);
|
|
9274
|
+
};
|
|
9275
|
+
const schema = zod.z.object({
|
|
9276
|
+
customer_id: zod.z.string().min(1)
|
|
9277
|
+
});
|
|
9278
|
+
const handle$1 = {
|
|
9279
|
+
permissions: TRANSFER_DRAFT_ORDER_PERMISSIONS
|
|
9280
|
+
};
|
|
9281
|
+
const InlineTip = React.forwardRef(
|
|
9282
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
9283
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
9284
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9285
|
+
"div",
|
|
9286
|
+
{
|
|
9287
|
+
ref,
|
|
9288
|
+
className: ui.clx(
|
|
9289
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
9290
|
+
className
|
|
9291
|
+
),
|
|
9292
|
+
...props,
|
|
9293
|
+
children: [
|
|
9294
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9295
|
+
"div",
|
|
9296
|
+
{
|
|
9297
|
+
role: "presentation",
|
|
9298
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
9299
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
9300
|
+
})
|
|
9301
|
+
}
|
|
9302
|
+
),
|
|
9303
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
9304
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
9305
|
+
labelValue,
|
|
9306
|
+
":"
|
|
9307
|
+
] }),
|
|
9308
|
+
" ",
|
|
9309
|
+
children
|
|
9310
|
+
] })
|
|
9311
|
+
]
|
|
9312
|
+
}
|
|
9313
|
+
);
|
|
9314
|
+
}
|
|
9315
|
+
);
|
|
9316
|
+
InlineTip.displayName = "InlineTip";
|
|
9317
|
+
const MetadataFieldSchema = zod.z.object({
|
|
9318
|
+
key: zod.z.string(),
|
|
9319
|
+
disabled: zod.z.boolean().optional(),
|
|
9320
|
+
value: zod.z.any()
|
|
9321
|
+
});
|
|
9322
|
+
const MetadataSchema = zod.z.object({
|
|
9323
|
+
metadata: zod.z.array(MetadataFieldSchema)
|
|
9324
|
+
});
|
|
9325
|
+
const Metadata = () => {
|
|
9326
|
+
const { id } = reactRouterDom.useParams();
|
|
9327
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9328
|
+
fields: "metadata"
|
|
9329
|
+
});
|
|
9330
|
+
if (isError) {
|
|
9331
|
+
throw error;
|
|
9332
|
+
}
|
|
9333
|
+
const isReady = !isPending && !!order;
|
|
9334
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9335
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9336
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
9337
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
9338
|
+
] }),
|
|
9339
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order?.metadata })
|
|
9340
|
+
] });
|
|
9341
|
+
};
|
|
9342
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
9343
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
9344
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
9345
|
+
const { handleSuccess } = useRouteModal();
|
|
9346
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
9347
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
9348
|
+
const form = reactHookForm.useForm({
|
|
9349
|
+
defaultValues: {
|
|
9350
|
+
metadata: getDefaultValues(metadata)
|
|
9351
|
+
},
|
|
9352
|
+
resolver: zod$1.zodResolver(MetadataSchema)
|
|
9353
|
+
});
|
|
9354
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
9355
|
+
const parsedData = parseValues(data);
|
|
9356
|
+
await mutateAsync(
|
|
9357
|
+
{
|
|
9358
|
+
metadata: parsedData
|
|
9359
|
+
},
|
|
9360
|
+
{
|
|
9361
|
+
onSuccess: () => {
|
|
9362
|
+
ui.toast.success("Metadata updated");
|
|
9363
|
+
handleSuccess();
|
|
9364
|
+
},
|
|
9365
|
+
onError: (error) => {
|
|
9366
|
+
ui.toast.error(error.message);
|
|
9367
|
+
}
|
|
9368
|
+
}
|
|
9369
|
+
);
|
|
9370
|
+
});
|
|
9371
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
9372
|
+
control: form.control,
|
|
9373
|
+
name: "metadata"
|
|
9374
|
+
});
|
|
9375
|
+
function deleteRow(index) {
|
|
9376
|
+
remove(index);
|
|
9377
|
+
if (fields.length === 1) {
|
|
9378
|
+
insert(0, {
|
|
9379
|
+
key: "",
|
|
9380
|
+
value: "",
|
|
9381
|
+
disabled: false
|
|
9382
|
+
});
|
|
9383
|
+
}
|
|
9384
|
+
}
|
|
9385
|
+
function insertRow(index, position) {
|
|
9386
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
9387
|
+
key: "",
|
|
9388
|
+
value: "",
|
|
9389
|
+
disabled: false
|
|
9390
|
+
});
|
|
9391
|
+
}
|
|
9392
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9393
|
+
KeyboundForm,
|
|
9394
|
+
{
|
|
9395
|
+
onSubmit: handleSubmit,
|
|
9396
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9397
|
+
children: [
|
|
9398
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
9399
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
9400
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
9401
|
+
/* @__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" }) }),
|
|
9402
|
+
/* @__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" }) })
|
|
9403
|
+
] }),
|
|
9404
|
+
fields.map((field, index) => {
|
|
9405
|
+
const isDisabled = field.disabled || false;
|
|
9406
|
+
let placeholder = "-";
|
|
9407
|
+
if (typeof field.value === "object") {
|
|
9408
|
+
placeholder = "{ ... }";
|
|
9409
|
+
}
|
|
9410
|
+
if (Array.isArray(field.value)) {
|
|
9411
|
+
placeholder = "[ ... ]";
|
|
9412
|
+
}
|
|
9413
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9414
|
+
ConditionalTooltip,
|
|
9415
|
+
{
|
|
9416
|
+
showTooltip: isDisabled,
|
|
9417
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
9418
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
9419
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9420
|
+
"div",
|
|
9421
|
+
{
|
|
9422
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
9423
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
9424
|
+
}),
|
|
9425
|
+
children: [
|
|
9426
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9427
|
+
Form$2.Field,
|
|
9428
|
+
{
|
|
9429
|
+
control: form.control,
|
|
9430
|
+
name: `metadata.${index}.key`,
|
|
9431
|
+
render: ({ field: field2 }) => {
|
|
9432
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9433
|
+
GridInput,
|
|
9434
|
+
{
|
|
9435
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
9436
|
+
...field2,
|
|
9437
|
+
disabled: isDisabled,
|
|
9438
|
+
placeholder: "Key"
|
|
9439
|
+
}
|
|
9440
|
+
) }) });
|
|
9441
|
+
}
|
|
9442
|
+
}
|
|
9443
|
+
),
|
|
9444
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9445
|
+
Form$2.Field,
|
|
9446
|
+
{
|
|
9447
|
+
control: form.control,
|
|
9448
|
+
name: `metadata.${index}.value`,
|
|
9449
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
9450
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9451
|
+
GridInput,
|
|
9452
|
+
{
|
|
9453
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
9454
|
+
...field2,
|
|
9455
|
+
value: isDisabled ? placeholder : value,
|
|
9456
|
+
disabled: isDisabled,
|
|
9457
|
+
placeholder: "Value"
|
|
9458
|
+
}
|
|
9459
|
+
) }) });
|
|
9460
|
+
}
|
|
9461
|
+
}
|
|
9462
|
+
)
|
|
9463
|
+
]
|
|
9464
|
+
}
|
|
9465
|
+
),
|
|
9466
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
9467
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9468
|
+
ui.DropdownMenu.Trigger,
|
|
9469
|
+
{
|
|
9470
|
+
className: ui.clx(
|
|
9471
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
9472
|
+
{
|
|
9473
|
+
hidden: isDisabled
|
|
9474
|
+
}
|
|
9475
|
+
),
|
|
9476
|
+
disabled: isDisabled,
|
|
9477
|
+
asChild: true,
|
|
9478
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
9479
|
+
}
|
|
9480
|
+
),
|
|
9481
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
9482
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9483
|
+
ui.DropdownMenu.Item,
|
|
9484
|
+
{
|
|
9485
|
+
className: "gap-x-2",
|
|
9486
|
+
onClick: () => insertRow(index, "above"),
|
|
9487
|
+
children: [
|
|
9488
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
9489
|
+
"Insert row above"
|
|
9490
|
+
]
|
|
9491
|
+
}
|
|
9492
|
+
),
|
|
9493
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9494
|
+
ui.DropdownMenu.Item,
|
|
9495
|
+
{
|
|
9496
|
+
className: "gap-x-2",
|
|
9497
|
+
onClick: () => insertRow(index, "below"),
|
|
9498
|
+
children: [
|
|
9499
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
9500
|
+
"Insert row below"
|
|
9501
|
+
]
|
|
9502
|
+
}
|
|
9503
|
+
),
|
|
9504
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
9505
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9506
|
+
ui.DropdownMenu.Item,
|
|
9507
|
+
{
|
|
9508
|
+
className: "gap-x-2",
|
|
9509
|
+
onClick: () => deleteRow(index),
|
|
9510
|
+
children: [
|
|
9511
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
9512
|
+
"Delete row"
|
|
9513
|
+
]
|
|
9514
|
+
}
|
|
9515
|
+
)
|
|
9516
|
+
] })
|
|
9517
|
+
] })
|
|
9518
|
+
] })
|
|
9519
|
+
},
|
|
9520
|
+
field.id
|
|
9521
|
+
);
|
|
9522
|
+
})
|
|
9523
|
+
] }),
|
|
9524
|
+
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." })
|
|
9525
|
+
] }),
|
|
9526
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
9527
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
9528
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9529
|
+
] }) })
|
|
9530
|
+
]
|
|
9531
|
+
}
|
|
9532
|
+
) });
|
|
9627
9533
|
};
|
|
9628
|
-
const
|
|
9629
|
-
|
|
9534
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
9535
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9536
|
+
"input",
|
|
9537
|
+
{
|
|
9538
|
+
ref,
|
|
9539
|
+
...props,
|
|
9540
|
+
autoComplete: "off",
|
|
9541
|
+
className: ui.clx(
|
|
9542
|
+
"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",
|
|
9543
|
+
className
|
|
9544
|
+
)
|
|
9545
|
+
}
|
|
9546
|
+
);
|
|
9630
9547
|
});
|
|
9548
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
9549
|
+
const PlaceholderInner = () => {
|
|
9550
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
9551
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
9552
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
9553
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
9554
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
9555
|
+
] }) })
|
|
9556
|
+
] });
|
|
9557
|
+
};
|
|
9558
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
9559
|
+
function getDefaultValues(metadata) {
|
|
9560
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
9561
|
+
return [
|
|
9562
|
+
{
|
|
9563
|
+
key: "",
|
|
9564
|
+
value: "",
|
|
9565
|
+
disabled: false
|
|
9566
|
+
}
|
|
9567
|
+
];
|
|
9568
|
+
}
|
|
9569
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
9570
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
9571
|
+
return {
|
|
9572
|
+
key,
|
|
9573
|
+
value,
|
|
9574
|
+
disabled: true
|
|
9575
|
+
};
|
|
9576
|
+
}
|
|
9577
|
+
let stringValue = value;
|
|
9578
|
+
if (typeof value !== "string") {
|
|
9579
|
+
stringValue = JSON.stringify(value);
|
|
9580
|
+
}
|
|
9581
|
+
return {
|
|
9582
|
+
key,
|
|
9583
|
+
value: stringValue,
|
|
9584
|
+
original_key: key
|
|
9585
|
+
};
|
|
9586
|
+
});
|
|
9587
|
+
}
|
|
9588
|
+
function parseValues(values) {
|
|
9589
|
+
const metadata = values.metadata;
|
|
9590
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
9591
|
+
if (isEmpty) {
|
|
9592
|
+
return null;
|
|
9593
|
+
}
|
|
9594
|
+
const update = {};
|
|
9595
|
+
metadata.forEach((field) => {
|
|
9596
|
+
let key = field.key;
|
|
9597
|
+
let value = field.value;
|
|
9598
|
+
const disabled = field.disabled;
|
|
9599
|
+
if (!key || !value) {
|
|
9600
|
+
return;
|
|
9601
|
+
}
|
|
9602
|
+
if (disabled) {
|
|
9603
|
+
update[key] = value;
|
|
9604
|
+
return;
|
|
9605
|
+
}
|
|
9606
|
+
key = key.trim();
|
|
9607
|
+
value = value.trim();
|
|
9608
|
+
if (value === "true") {
|
|
9609
|
+
update[key] = true;
|
|
9610
|
+
} else if (value === "false") {
|
|
9611
|
+
update[key] = false;
|
|
9612
|
+
} else {
|
|
9613
|
+
const parsedNumber = parseFloat(value);
|
|
9614
|
+
if (!isNaN(parsedNumber)) {
|
|
9615
|
+
update[key] = parsedNumber;
|
|
9616
|
+
} else {
|
|
9617
|
+
update[key] = value;
|
|
9618
|
+
}
|
|
9619
|
+
}
|
|
9620
|
+
});
|
|
9621
|
+
return update;
|
|
9622
|
+
}
|
|
9623
|
+
function getHasUneditableRows(metadata) {
|
|
9624
|
+
if (!metadata) {
|
|
9625
|
+
return false;
|
|
9626
|
+
}
|
|
9627
|
+
return Object.values(metadata).some(
|
|
9628
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
9629
|
+
);
|
|
9630
|
+
}
|
|
9631
9631
|
const handle = {
|
|
9632
|
-
permissions:
|
|
9632
|
+
permissions: EDIT_DRAFT_ORDER_PERMISSIONS
|
|
9633
9633
|
};
|
|
9634
9634
|
const widgetModule = { widgets: [] };
|
|
9635
9635
|
const routeModule = {
|
|
@@ -9652,54 +9652,54 @@ const routeModule = {
|
|
|
9652
9652
|
handle: handle$a,
|
|
9653
9653
|
loader,
|
|
9654
9654
|
children: [
|
|
9655
|
-
{
|
|
9656
|
-
Component: BillingAddress,
|
|
9657
|
-
path: "/draft-orders/:id/billing-address",
|
|
9658
|
-
handle: handle$9
|
|
9659
|
-
},
|
|
9660
9655
|
{
|
|
9661
9656
|
Component: CustomItems,
|
|
9662
9657
|
path: "/draft-orders/:id/custom-items",
|
|
9663
|
-
handle: handle$
|
|
9658
|
+
handle: handle$9
|
|
9664
9659
|
},
|
|
9665
9660
|
{
|
|
9666
9661
|
Component: Email,
|
|
9667
9662
|
path: "/draft-orders/:id/email",
|
|
9668
|
-
handle: handle$
|
|
9663
|
+
handle: handle$8
|
|
9669
9664
|
},
|
|
9670
9665
|
{
|
|
9671
9666
|
Component: Items,
|
|
9672
9667
|
path: "/draft-orders/:id/items",
|
|
9673
|
-
handle: handle$
|
|
9668
|
+
handle: handle$7
|
|
9674
9669
|
},
|
|
9675
9670
|
{
|
|
9676
|
-
Component:
|
|
9677
|
-
path: "/draft-orders/:id/
|
|
9678
|
-
handle: handle$
|
|
9671
|
+
Component: BillingAddress,
|
|
9672
|
+
path: "/draft-orders/:id/billing-address",
|
|
9673
|
+
handle: handle$6
|
|
9679
9674
|
},
|
|
9680
9675
|
{
|
|
9681
9676
|
Component: Promotions,
|
|
9682
9677
|
path: "/draft-orders/:id/promotions",
|
|
9683
|
-
handle: handle$
|
|
9678
|
+
handle: handle$5
|
|
9684
9679
|
},
|
|
9685
9680
|
{
|
|
9686
9681
|
Component: SalesChannel,
|
|
9687
9682
|
path: "/draft-orders/:id/sales-channel",
|
|
9688
|
-
handle: handle$
|
|
9683
|
+
handle: handle$4
|
|
9689
9684
|
},
|
|
9690
9685
|
{
|
|
9691
9686
|
Component: Shipping,
|
|
9692
9687
|
path: "/draft-orders/:id/shipping",
|
|
9693
|
-
handle: handle$
|
|
9688
|
+
handle: handle$3
|
|
9694
9689
|
},
|
|
9695
9690
|
{
|
|
9696
9691
|
Component: ShippingAddress,
|
|
9697
9692
|
path: "/draft-orders/:id/shipping-address",
|
|
9698
|
-
handle: handle$
|
|
9693
|
+
handle: handle$2
|
|
9699
9694
|
},
|
|
9700
9695
|
{
|
|
9701
9696
|
Component: TransferOwnership,
|
|
9702
9697
|
path: "/draft-orders/:id/transfer-ownership",
|
|
9698
|
+
handle: handle$1
|
|
9699
|
+
},
|
|
9700
|
+
{
|
|
9701
|
+
Component: Metadata,
|
|
9702
|
+
path: "/draft-orders/:id/metadata",
|
|
9703
9703
|
handle
|
|
9704
9704
|
}
|
|
9705
9705
|
]
|