@medusajs/draft-order 2.11.4-preview-20251118120154 → 2.11.4-preview-20251118180132
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 +454 -454
- package/.medusa/server/src/admin/index.mjs +454 -454
- package/package.json +16 -16
|
@@ -9755,27 +9755,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9755
9755
|
) });
|
|
9756
9756
|
};
|
|
9757
9757
|
const schema$5 = addressSchema;
|
|
9758
|
-
const CustomItems = () => {
|
|
9759
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9760
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9761
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9762
|
-
] });
|
|
9763
|
-
};
|
|
9764
|
-
const CustomItemsForm = () => {
|
|
9765
|
-
const form = useForm({
|
|
9766
|
-
resolver: zodResolver(schema$4)
|
|
9767
|
-
});
|
|
9768
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9769
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9770
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9771
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9772
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9773
|
-
] }) })
|
|
9774
|
-
] }) });
|
|
9775
|
-
};
|
|
9776
|
-
const schema$4 = objectType({
|
|
9777
|
-
email: stringType().email()
|
|
9778
|
-
});
|
|
9779
9758
|
const Email = () => {
|
|
9780
9759
|
const { id } = useParams();
|
|
9781
9760
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9798,7 +9777,7 @@ const EmailForm = ({ order }) => {
|
|
|
9798
9777
|
defaultValues: {
|
|
9799
9778
|
email: order.email ?? ""
|
|
9800
9779
|
},
|
|
9801
|
-
resolver: zodResolver(schema$
|
|
9780
|
+
resolver: zodResolver(schema$4)
|
|
9802
9781
|
});
|
|
9803
9782
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9804
9783
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9841,6 +9820,27 @@ const EmailForm = ({ order }) => {
|
|
|
9841
9820
|
}
|
|
9842
9821
|
) });
|
|
9843
9822
|
};
|
|
9823
|
+
const schema$4 = objectType({
|
|
9824
|
+
email: stringType().email()
|
|
9825
|
+
});
|
|
9826
|
+
const CustomItems = () => {
|
|
9827
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9828
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9829
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9830
|
+
] });
|
|
9831
|
+
};
|
|
9832
|
+
const CustomItemsForm = () => {
|
|
9833
|
+
const form = useForm({
|
|
9834
|
+
resolver: zodResolver(schema$3)
|
|
9835
|
+
});
|
|
9836
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9837
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9838
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9839
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9840
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9841
|
+
] }) })
|
|
9842
|
+
] }) });
|
|
9843
|
+
};
|
|
9844
9844
|
const schema$3 = objectType({
|
|
9845
9845
|
email: stringType().email()
|
|
9846
9846
|
});
|
|
@@ -11095,88 +11095,46 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11095
11095
|
}
|
|
11096
11096
|
return Array.from(promotionIds);
|
|
11097
11097
|
}
|
|
11098
|
-
const
|
|
11099
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
11100
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
11101
|
-
return /* @__PURE__ */ jsxs(
|
|
11102
|
-
"div",
|
|
11103
|
-
{
|
|
11104
|
-
ref,
|
|
11105
|
-
className: clx(
|
|
11106
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
11107
|
-
className
|
|
11108
|
-
),
|
|
11109
|
-
...props,
|
|
11110
|
-
children: [
|
|
11111
|
-
/* @__PURE__ */ jsx(
|
|
11112
|
-
"div",
|
|
11113
|
-
{
|
|
11114
|
-
role: "presentation",
|
|
11115
|
-
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
11116
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
11117
|
-
})
|
|
11118
|
-
}
|
|
11119
|
-
),
|
|
11120
|
-
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
11121
|
-
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
11122
|
-
labelValue,
|
|
11123
|
-
":"
|
|
11124
|
-
] }),
|
|
11125
|
-
" ",
|
|
11126
|
-
children
|
|
11127
|
-
] })
|
|
11128
|
-
]
|
|
11129
|
-
}
|
|
11130
|
-
);
|
|
11131
|
-
}
|
|
11132
|
-
);
|
|
11133
|
-
InlineTip.displayName = "InlineTip";
|
|
11134
|
-
const MetadataFieldSchema = objectType({
|
|
11135
|
-
key: stringType(),
|
|
11136
|
-
disabled: booleanType().optional(),
|
|
11137
|
-
value: anyType()
|
|
11138
|
-
});
|
|
11139
|
-
const MetadataSchema = objectType({
|
|
11140
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
11141
|
-
});
|
|
11142
|
-
const Metadata = () => {
|
|
11098
|
+
const SalesChannel = () => {
|
|
11143
11099
|
const { id } = useParams();
|
|
11144
|
-
const {
|
|
11145
|
-
|
|
11146
|
-
|
|
11100
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11101
|
+
id,
|
|
11102
|
+
{
|
|
11103
|
+
fields: "+sales_channel_id"
|
|
11104
|
+
},
|
|
11105
|
+
{
|
|
11106
|
+
enabled: !!id
|
|
11107
|
+
}
|
|
11108
|
+
);
|
|
11147
11109
|
if (isError) {
|
|
11148
11110
|
throw error;
|
|
11149
11111
|
}
|
|
11150
|
-
const
|
|
11112
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11151
11113
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11152
11114
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11153
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
11154
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
11115
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11116
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11155
11117
|
] }),
|
|
11156
|
-
|
|
11118
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11157
11119
|
] });
|
|
11158
11120
|
};
|
|
11159
|
-
const
|
|
11160
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
11161
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
11162
|
-
const { handleSuccess } = useRouteModal();
|
|
11163
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
11164
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
11121
|
+
const SalesChannelForm = ({ order }) => {
|
|
11165
11122
|
const form = useForm({
|
|
11166
11123
|
defaultValues: {
|
|
11167
|
-
|
|
11124
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11168
11125
|
},
|
|
11169
|
-
resolver: zodResolver(
|
|
11126
|
+
resolver: zodResolver(schema$2)
|
|
11170
11127
|
});
|
|
11171
|
-
const
|
|
11172
|
-
|
|
11128
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11129
|
+
const { handleSuccess } = useRouteModal();
|
|
11130
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11173
11131
|
await mutateAsync(
|
|
11174
11132
|
{
|
|
11175
|
-
|
|
11133
|
+
sales_channel_id: data.sales_channel_id
|
|
11176
11134
|
},
|
|
11177
11135
|
{
|
|
11178
11136
|
onSuccess: () => {
|
|
11179
|
-
toast.success("
|
|
11137
|
+
toast.success("Sales channel updated");
|
|
11180
11138
|
handleSuccess();
|
|
11181
11139
|
},
|
|
11182
11140
|
onError: (error) => {
|
|
@@ -11185,319 +11143,11 @@ const MetadataForm = ({ orderId, metadata }) => {
|
|
|
11185
11143
|
}
|
|
11186
11144
|
);
|
|
11187
11145
|
});
|
|
11188
|
-
const { fields, insert, remove } = useFieldArray({
|
|
11189
|
-
control: form.control,
|
|
11190
|
-
name: "metadata"
|
|
11191
|
-
});
|
|
11192
|
-
function deleteRow(index) {
|
|
11193
|
-
remove(index);
|
|
11194
|
-
if (fields.length === 1) {
|
|
11195
|
-
insert(0, {
|
|
11196
|
-
key: "",
|
|
11197
|
-
value: "",
|
|
11198
|
-
disabled: false
|
|
11199
|
-
});
|
|
11200
|
-
}
|
|
11201
|
-
}
|
|
11202
|
-
function insertRow(index, position) {
|
|
11203
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
11204
|
-
key: "",
|
|
11205
|
-
value: "",
|
|
11206
|
-
disabled: false
|
|
11207
|
-
});
|
|
11208
|
-
}
|
|
11209
11146
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11210
11147
|
KeyboundForm,
|
|
11211
11148
|
{
|
|
11212
|
-
onSubmit: handleSubmit,
|
|
11213
11149
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11214
|
-
|
|
11215
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
11216
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
11217
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
11218
|
-
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
11219
|
-
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
11220
|
-
] }),
|
|
11221
|
-
fields.map((field, index) => {
|
|
11222
|
-
const isDisabled = field.disabled || false;
|
|
11223
|
-
let placeholder = "-";
|
|
11224
|
-
if (typeof field.value === "object") {
|
|
11225
|
-
placeholder = "{ ... }";
|
|
11226
|
-
}
|
|
11227
|
-
if (Array.isArray(field.value)) {
|
|
11228
|
-
placeholder = "[ ... ]";
|
|
11229
|
-
}
|
|
11230
|
-
return /* @__PURE__ */ jsx(
|
|
11231
|
-
ConditionalTooltip,
|
|
11232
|
-
{
|
|
11233
|
-
showTooltip: isDisabled,
|
|
11234
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
11235
|
-
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
11236
|
-
/* @__PURE__ */ jsxs(
|
|
11237
|
-
"div",
|
|
11238
|
-
{
|
|
11239
|
-
className: clx("grid grid-cols-2 divide-x", {
|
|
11240
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
11241
|
-
}),
|
|
11242
|
-
children: [
|
|
11243
|
-
/* @__PURE__ */ jsx(
|
|
11244
|
-
Form$2.Field,
|
|
11245
|
-
{
|
|
11246
|
-
control: form.control,
|
|
11247
|
-
name: `metadata.${index}.key`,
|
|
11248
|
-
render: ({ field: field2 }) => {
|
|
11249
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11250
|
-
GridInput,
|
|
11251
|
-
{
|
|
11252
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
11253
|
-
...field2,
|
|
11254
|
-
disabled: isDisabled,
|
|
11255
|
-
placeholder: "Key"
|
|
11256
|
-
}
|
|
11257
|
-
) }) });
|
|
11258
|
-
}
|
|
11259
|
-
}
|
|
11260
|
-
),
|
|
11261
|
-
/* @__PURE__ */ jsx(
|
|
11262
|
-
Form$2.Field,
|
|
11263
|
-
{
|
|
11264
|
-
control: form.control,
|
|
11265
|
-
name: `metadata.${index}.value`,
|
|
11266
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
11267
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11268
|
-
GridInput,
|
|
11269
|
-
{
|
|
11270
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11271
|
-
...field2,
|
|
11272
|
-
value: isDisabled ? placeholder : value,
|
|
11273
|
-
disabled: isDisabled,
|
|
11274
|
-
placeholder: "Value"
|
|
11275
|
-
}
|
|
11276
|
-
) }) });
|
|
11277
|
-
}
|
|
11278
|
-
}
|
|
11279
|
-
)
|
|
11280
|
-
]
|
|
11281
|
-
}
|
|
11282
|
-
),
|
|
11283
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
11284
|
-
/* @__PURE__ */ jsx(
|
|
11285
|
-
DropdownMenu.Trigger,
|
|
11286
|
-
{
|
|
11287
|
-
className: clx(
|
|
11288
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11289
|
-
{
|
|
11290
|
-
hidden: isDisabled
|
|
11291
|
-
}
|
|
11292
|
-
),
|
|
11293
|
-
disabled: isDisabled,
|
|
11294
|
-
asChild: true,
|
|
11295
|
-
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
11296
|
-
}
|
|
11297
|
-
),
|
|
11298
|
-
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
11299
|
-
/* @__PURE__ */ jsxs(
|
|
11300
|
-
DropdownMenu.Item,
|
|
11301
|
-
{
|
|
11302
|
-
className: "gap-x-2",
|
|
11303
|
-
onClick: () => insertRow(index, "above"),
|
|
11304
|
-
children: [
|
|
11305
|
-
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11306
|
-
"Insert row above"
|
|
11307
|
-
]
|
|
11308
|
-
}
|
|
11309
|
-
),
|
|
11310
|
-
/* @__PURE__ */ jsxs(
|
|
11311
|
-
DropdownMenu.Item,
|
|
11312
|
-
{
|
|
11313
|
-
className: "gap-x-2",
|
|
11314
|
-
onClick: () => insertRow(index, "below"),
|
|
11315
|
-
children: [
|
|
11316
|
-
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11317
|
-
"Insert row below"
|
|
11318
|
-
]
|
|
11319
|
-
}
|
|
11320
|
-
),
|
|
11321
|
-
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
11322
|
-
/* @__PURE__ */ jsxs(
|
|
11323
|
-
DropdownMenu.Item,
|
|
11324
|
-
{
|
|
11325
|
-
className: "gap-x-2",
|
|
11326
|
-
onClick: () => deleteRow(index),
|
|
11327
|
-
children: [
|
|
11328
|
-
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
11329
|
-
"Delete row"
|
|
11330
|
-
]
|
|
11331
|
-
}
|
|
11332
|
-
)
|
|
11333
|
-
] })
|
|
11334
|
-
] })
|
|
11335
|
-
] })
|
|
11336
|
-
},
|
|
11337
|
-
field.id
|
|
11338
|
-
);
|
|
11339
|
-
})
|
|
11340
|
-
] }),
|
|
11341
|
-
hasUneditableRows && /* @__PURE__ */ 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." })
|
|
11342
|
-
] }),
|
|
11343
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11344
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11345
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11346
|
-
] }) })
|
|
11347
|
-
]
|
|
11348
|
-
}
|
|
11349
|
-
) });
|
|
11350
|
-
};
|
|
11351
|
-
const GridInput = forwardRef(({ className, ...props }, ref) => {
|
|
11352
|
-
return /* @__PURE__ */ jsx(
|
|
11353
|
-
"input",
|
|
11354
|
-
{
|
|
11355
|
-
ref,
|
|
11356
|
-
...props,
|
|
11357
|
-
autoComplete: "off",
|
|
11358
|
-
className: clx(
|
|
11359
|
-
"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",
|
|
11360
|
-
className
|
|
11361
|
-
)
|
|
11362
|
-
}
|
|
11363
|
-
);
|
|
11364
|
-
});
|
|
11365
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
11366
|
-
const PlaceholderInner = () => {
|
|
11367
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11368
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11369
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11370
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11371
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11372
|
-
] }) })
|
|
11373
|
-
] });
|
|
11374
|
-
};
|
|
11375
|
-
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
11376
|
-
function getDefaultValues(metadata) {
|
|
11377
|
-
if (!metadata || !Object.keys(metadata).length) {
|
|
11378
|
-
return [
|
|
11379
|
-
{
|
|
11380
|
-
key: "",
|
|
11381
|
-
value: "",
|
|
11382
|
-
disabled: false
|
|
11383
|
-
}
|
|
11384
|
-
];
|
|
11385
|
-
}
|
|
11386
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
11387
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11388
|
-
return {
|
|
11389
|
-
key,
|
|
11390
|
-
value,
|
|
11391
|
-
disabled: true
|
|
11392
|
-
};
|
|
11393
|
-
}
|
|
11394
|
-
let stringValue = value;
|
|
11395
|
-
if (typeof value !== "string") {
|
|
11396
|
-
stringValue = JSON.stringify(value);
|
|
11397
|
-
}
|
|
11398
|
-
return {
|
|
11399
|
-
key,
|
|
11400
|
-
value: stringValue,
|
|
11401
|
-
original_key: key
|
|
11402
|
-
};
|
|
11403
|
-
});
|
|
11404
|
-
}
|
|
11405
|
-
function parseValues(values) {
|
|
11406
|
-
const metadata = values.metadata;
|
|
11407
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11408
|
-
if (isEmpty) {
|
|
11409
|
-
return null;
|
|
11410
|
-
}
|
|
11411
|
-
const update = {};
|
|
11412
|
-
metadata.forEach((field) => {
|
|
11413
|
-
let key = field.key;
|
|
11414
|
-
let value = field.value;
|
|
11415
|
-
const disabled = field.disabled;
|
|
11416
|
-
if (!key || !value) {
|
|
11417
|
-
return;
|
|
11418
|
-
}
|
|
11419
|
-
if (disabled) {
|
|
11420
|
-
update[key] = value;
|
|
11421
|
-
return;
|
|
11422
|
-
}
|
|
11423
|
-
key = key.trim();
|
|
11424
|
-
value = value.trim();
|
|
11425
|
-
if (value === "true") {
|
|
11426
|
-
update[key] = true;
|
|
11427
|
-
} else if (value === "false") {
|
|
11428
|
-
update[key] = false;
|
|
11429
|
-
} else {
|
|
11430
|
-
const parsedNumber = parseFloat(value);
|
|
11431
|
-
if (!isNaN(parsedNumber)) {
|
|
11432
|
-
update[key] = parsedNumber;
|
|
11433
|
-
} else {
|
|
11434
|
-
update[key] = value;
|
|
11435
|
-
}
|
|
11436
|
-
}
|
|
11437
|
-
});
|
|
11438
|
-
return update;
|
|
11439
|
-
}
|
|
11440
|
-
function getHasUneditableRows(metadata) {
|
|
11441
|
-
if (!metadata) {
|
|
11442
|
-
return false;
|
|
11443
|
-
}
|
|
11444
|
-
return Object.values(metadata).some(
|
|
11445
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11446
|
-
);
|
|
11447
|
-
}
|
|
11448
|
-
const SalesChannel = () => {
|
|
11449
|
-
const { id } = useParams();
|
|
11450
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11451
|
-
id,
|
|
11452
|
-
{
|
|
11453
|
-
fields: "+sales_channel_id"
|
|
11454
|
-
},
|
|
11455
|
-
{
|
|
11456
|
-
enabled: !!id
|
|
11457
|
-
}
|
|
11458
|
-
);
|
|
11459
|
-
if (isError) {
|
|
11460
|
-
throw error;
|
|
11461
|
-
}
|
|
11462
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11463
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11464
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11465
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11466
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11467
|
-
] }),
|
|
11468
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11469
|
-
] });
|
|
11470
|
-
};
|
|
11471
|
-
const SalesChannelForm = ({ order }) => {
|
|
11472
|
-
const form = useForm({
|
|
11473
|
-
defaultValues: {
|
|
11474
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11475
|
-
},
|
|
11476
|
-
resolver: zodResolver(schema$2)
|
|
11477
|
-
});
|
|
11478
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11479
|
-
const { handleSuccess } = useRouteModal();
|
|
11480
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11481
|
-
await mutateAsync(
|
|
11482
|
-
{
|
|
11483
|
-
sales_channel_id: data.sales_channel_id
|
|
11484
|
-
},
|
|
11485
|
-
{
|
|
11486
|
-
onSuccess: () => {
|
|
11487
|
-
toast.success("Sales channel updated");
|
|
11488
|
-
handleSuccess();
|
|
11489
|
-
},
|
|
11490
|
-
onError: (error) => {
|
|
11491
|
-
toast.error(error.message);
|
|
11492
|
-
}
|
|
11493
|
-
}
|
|
11494
|
-
);
|
|
11495
|
-
});
|
|
11496
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11497
|
-
KeyboundForm,
|
|
11498
|
-
{
|
|
11499
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11500
|
-
onSubmit,
|
|
11150
|
+
onSubmit,
|
|
11501
11151
|
children: [
|
|
11502
11152
|
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11503
11153
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -13037,65 +12687,415 @@ const Illustration = () => {
|
|
|
13037
12687
|
const schema = objectType({
|
|
13038
12688
|
customer_id: stringType().min(1)
|
|
13039
12689
|
});
|
|
13040
|
-
const
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
12690
|
+
const InlineTip = forwardRef(
|
|
12691
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
12692
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
12693
|
+
return /* @__PURE__ */ jsxs(
|
|
12694
|
+
"div",
|
|
12695
|
+
{
|
|
12696
|
+
ref,
|
|
12697
|
+
className: clx(
|
|
12698
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
12699
|
+
className
|
|
12700
|
+
),
|
|
12701
|
+
...props,
|
|
12702
|
+
children: [
|
|
12703
|
+
/* @__PURE__ */ jsx(
|
|
12704
|
+
"div",
|
|
12705
|
+
{
|
|
12706
|
+
role: "presentation",
|
|
12707
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
12708
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
12709
|
+
})
|
|
12710
|
+
}
|
|
12711
|
+
),
|
|
12712
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
12713
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
12714
|
+
labelValue,
|
|
12715
|
+
":"
|
|
12716
|
+
] }),
|
|
12717
|
+
" ",
|
|
12718
|
+
children
|
|
12719
|
+
] })
|
|
12720
|
+
]
|
|
12721
|
+
}
|
|
12722
|
+
);
|
|
12723
|
+
}
|
|
12724
|
+
);
|
|
12725
|
+
InlineTip.displayName = "InlineTip";
|
|
12726
|
+
const MetadataFieldSchema = objectType({
|
|
12727
|
+
key: stringType(),
|
|
12728
|
+
disabled: booleanType().optional(),
|
|
12729
|
+
value: anyType()
|
|
12730
|
+
});
|
|
12731
|
+
const MetadataSchema = objectType({
|
|
12732
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
12733
|
+
});
|
|
12734
|
+
const Metadata = () => {
|
|
12735
|
+
const { id } = useParams();
|
|
12736
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12737
|
+
fields: "metadata"
|
|
12738
|
+
});
|
|
12739
|
+
if (isError) {
|
|
12740
|
+
throw error;
|
|
12741
|
+
}
|
|
12742
|
+
const isReady = !isPending && !!order;
|
|
12743
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12744
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12745
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
12746
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
12747
|
+
] }),
|
|
12748
|
+
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
12749
|
+
] });
|
|
12750
|
+
};
|
|
12751
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
12752
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
12753
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
12754
|
+
const { handleSuccess } = useRouteModal();
|
|
12755
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
12756
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
12757
|
+
const form = useForm({
|
|
12758
|
+
defaultValues: {
|
|
12759
|
+
metadata: getDefaultValues(metadata)
|
|
12760
|
+
},
|
|
12761
|
+
resolver: zodResolver(MetadataSchema)
|
|
12762
|
+
});
|
|
12763
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
12764
|
+
const parsedData = parseValues(data);
|
|
12765
|
+
await mutateAsync(
|
|
12766
|
+
{
|
|
12767
|
+
metadata: parsedData
|
|
12768
|
+
},
|
|
12769
|
+
{
|
|
12770
|
+
onSuccess: () => {
|
|
12771
|
+
toast.success("Metadata updated");
|
|
12772
|
+
handleSuccess();
|
|
12773
|
+
},
|
|
12774
|
+
onError: (error) => {
|
|
12775
|
+
toast.error(error.message);
|
|
12776
|
+
}
|
|
12777
|
+
}
|
|
12778
|
+
);
|
|
12779
|
+
});
|
|
12780
|
+
const { fields, insert, remove } = useFieldArray({
|
|
12781
|
+
control: form.control,
|
|
12782
|
+
name: "metadata"
|
|
12783
|
+
});
|
|
12784
|
+
function deleteRow(index) {
|
|
12785
|
+
remove(index);
|
|
12786
|
+
if (fields.length === 1) {
|
|
12787
|
+
insert(0, {
|
|
12788
|
+
key: "",
|
|
12789
|
+
value: "",
|
|
12790
|
+
disabled: false
|
|
12791
|
+
});
|
|
12792
|
+
}
|
|
12793
|
+
}
|
|
12794
|
+
function insertRow(index, position) {
|
|
12795
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
12796
|
+
key: "",
|
|
12797
|
+
value: "",
|
|
12798
|
+
disabled: false
|
|
12799
|
+
});
|
|
12800
|
+
}
|
|
12801
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12802
|
+
KeyboundForm,
|
|
12803
|
+
{
|
|
12804
|
+
onSubmit: handleSubmit,
|
|
12805
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12806
|
+
children: [
|
|
12807
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
12808
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
12809
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
12810
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
12811
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
12812
|
+
] }),
|
|
12813
|
+
fields.map((field, index) => {
|
|
12814
|
+
const isDisabled = field.disabled || false;
|
|
12815
|
+
let placeholder = "-";
|
|
12816
|
+
if (typeof field.value === "object") {
|
|
12817
|
+
placeholder = "{ ... }";
|
|
12818
|
+
}
|
|
12819
|
+
if (Array.isArray(field.value)) {
|
|
12820
|
+
placeholder = "[ ... ]";
|
|
12821
|
+
}
|
|
12822
|
+
return /* @__PURE__ */ jsx(
|
|
12823
|
+
ConditionalTooltip,
|
|
12824
|
+
{
|
|
12825
|
+
showTooltip: isDisabled,
|
|
12826
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
12827
|
+
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
12828
|
+
/* @__PURE__ */ jsxs(
|
|
12829
|
+
"div",
|
|
12830
|
+
{
|
|
12831
|
+
className: clx("grid grid-cols-2 divide-x", {
|
|
12832
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
12833
|
+
}),
|
|
12834
|
+
children: [
|
|
12835
|
+
/* @__PURE__ */ jsx(
|
|
12836
|
+
Form$2.Field,
|
|
12837
|
+
{
|
|
12838
|
+
control: form.control,
|
|
12839
|
+
name: `metadata.${index}.key`,
|
|
12840
|
+
render: ({ field: field2 }) => {
|
|
12841
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12842
|
+
GridInput,
|
|
12843
|
+
{
|
|
12844
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
12845
|
+
...field2,
|
|
12846
|
+
disabled: isDisabled,
|
|
12847
|
+
placeholder: "Key"
|
|
12848
|
+
}
|
|
12849
|
+
) }) });
|
|
12850
|
+
}
|
|
12851
|
+
}
|
|
12852
|
+
),
|
|
12853
|
+
/* @__PURE__ */ jsx(
|
|
12854
|
+
Form$2.Field,
|
|
12855
|
+
{
|
|
12856
|
+
control: form.control,
|
|
12857
|
+
name: `metadata.${index}.value`,
|
|
12858
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
12859
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12860
|
+
GridInput,
|
|
12861
|
+
{
|
|
12862
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
12863
|
+
...field2,
|
|
12864
|
+
value: isDisabled ? placeholder : value,
|
|
12865
|
+
disabled: isDisabled,
|
|
12866
|
+
placeholder: "Value"
|
|
12867
|
+
}
|
|
12868
|
+
) }) });
|
|
12869
|
+
}
|
|
12870
|
+
}
|
|
12871
|
+
)
|
|
12872
|
+
]
|
|
12873
|
+
}
|
|
12874
|
+
),
|
|
12875
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
12876
|
+
/* @__PURE__ */ jsx(
|
|
12877
|
+
DropdownMenu.Trigger,
|
|
12878
|
+
{
|
|
12879
|
+
className: clx(
|
|
12880
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
12881
|
+
{
|
|
12882
|
+
hidden: isDisabled
|
|
12883
|
+
}
|
|
12884
|
+
),
|
|
12885
|
+
disabled: isDisabled,
|
|
12886
|
+
asChild: true,
|
|
12887
|
+
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
12888
|
+
}
|
|
12889
|
+
),
|
|
12890
|
+
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
12891
|
+
/* @__PURE__ */ jsxs(
|
|
12892
|
+
DropdownMenu.Item,
|
|
12893
|
+
{
|
|
12894
|
+
className: "gap-x-2",
|
|
12895
|
+
onClick: () => insertRow(index, "above"),
|
|
12896
|
+
children: [
|
|
12897
|
+
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
12898
|
+
"Insert row above"
|
|
12899
|
+
]
|
|
12900
|
+
}
|
|
12901
|
+
),
|
|
12902
|
+
/* @__PURE__ */ jsxs(
|
|
12903
|
+
DropdownMenu.Item,
|
|
12904
|
+
{
|
|
12905
|
+
className: "gap-x-2",
|
|
12906
|
+
onClick: () => insertRow(index, "below"),
|
|
12907
|
+
children: [
|
|
12908
|
+
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
12909
|
+
"Insert row below"
|
|
12910
|
+
]
|
|
12911
|
+
}
|
|
12912
|
+
),
|
|
12913
|
+
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
12914
|
+
/* @__PURE__ */ jsxs(
|
|
12915
|
+
DropdownMenu.Item,
|
|
12916
|
+
{
|
|
12917
|
+
className: "gap-x-2",
|
|
12918
|
+
onClick: () => deleteRow(index),
|
|
12919
|
+
children: [
|
|
12920
|
+
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
12921
|
+
"Delete row"
|
|
12922
|
+
]
|
|
12923
|
+
}
|
|
12924
|
+
)
|
|
12925
|
+
] })
|
|
12926
|
+
] })
|
|
12927
|
+
] })
|
|
12928
|
+
},
|
|
12929
|
+
field.id
|
|
12930
|
+
);
|
|
12931
|
+
})
|
|
12932
|
+
] }),
|
|
12933
|
+
hasUneditableRows && /* @__PURE__ */ 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." })
|
|
12934
|
+
] }),
|
|
12935
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12936
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12937
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12938
|
+
] }) })
|
|
12939
|
+
]
|
|
12940
|
+
}
|
|
12941
|
+
) });
|
|
12942
|
+
};
|
|
12943
|
+
const GridInput = forwardRef(({ className, ...props }, ref) => {
|
|
12944
|
+
return /* @__PURE__ */ jsx(
|
|
12945
|
+
"input",
|
|
12946
|
+
{
|
|
12947
|
+
ref,
|
|
12948
|
+
...props,
|
|
12949
|
+
autoComplete: "off",
|
|
12950
|
+
className: clx(
|
|
12951
|
+
"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",
|
|
12952
|
+
className
|
|
12953
|
+
)
|
|
12954
|
+
}
|
|
12955
|
+
);
|
|
12956
|
+
});
|
|
12957
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
12958
|
+
const PlaceholderInner = () => {
|
|
12959
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12960
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
12961
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12962
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
12963
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
12964
|
+
] }) })
|
|
12965
|
+
] });
|
|
12966
|
+
};
|
|
12967
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
12968
|
+
function getDefaultValues(metadata) {
|
|
12969
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
12970
|
+
return [
|
|
12971
|
+
{
|
|
12972
|
+
key: "",
|
|
12973
|
+
value: "",
|
|
12974
|
+
disabled: false
|
|
12975
|
+
}
|
|
12976
|
+
];
|
|
12977
|
+
}
|
|
12978
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
12979
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
12980
|
+
return {
|
|
12981
|
+
key,
|
|
12982
|
+
value,
|
|
12983
|
+
disabled: true
|
|
12984
|
+
};
|
|
12985
|
+
}
|
|
12986
|
+
let stringValue = value;
|
|
12987
|
+
if (typeof value !== "string") {
|
|
12988
|
+
stringValue = JSON.stringify(value);
|
|
12989
|
+
}
|
|
12990
|
+
return {
|
|
12991
|
+
key,
|
|
12992
|
+
value: stringValue,
|
|
12993
|
+
original_key: key
|
|
12994
|
+
};
|
|
12995
|
+
});
|
|
12996
|
+
}
|
|
12997
|
+
function parseValues(values) {
|
|
12998
|
+
const metadata = values.metadata;
|
|
12999
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
13000
|
+
if (isEmpty) {
|
|
13001
|
+
return null;
|
|
13002
|
+
}
|
|
13003
|
+
const update = {};
|
|
13004
|
+
metadata.forEach((field) => {
|
|
13005
|
+
let key = field.key;
|
|
13006
|
+
let value = field.value;
|
|
13007
|
+
const disabled = field.disabled;
|
|
13008
|
+
if (!key || !value) {
|
|
13009
|
+
return;
|
|
13010
|
+
}
|
|
13011
|
+
if (disabled) {
|
|
13012
|
+
update[key] = value;
|
|
13013
|
+
return;
|
|
13014
|
+
}
|
|
13015
|
+
key = key.trim();
|
|
13016
|
+
value = value.trim();
|
|
13017
|
+
if (value === "true") {
|
|
13018
|
+
update[key] = true;
|
|
13019
|
+
} else if (value === "false") {
|
|
13020
|
+
update[key] = false;
|
|
13021
|
+
} else {
|
|
13022
|
+
const parsedNumber = parseFloat(value);
|
|
13023
|
+
if (!isNaN(parsedNumber)) {
|
|
13024
|
+
update[key] = parsedNumber;
|
|
13025
|
+
} else {
|
|
13026
|
+
update[key] = value;
|
|
13027
|
+
}
|
|
13028
|
+
}
|
|
13029
|
+
});
|
|
13030
|
+
return update;
|
|
13031
|
+
}
|
|
13032
|
+
function getHasUneditableRows(metadata) {
|
|
13033
|
+
if (!metadata) {
|
|
13034
|
+
return false;
|
|
13035
|
+
}
|
|
13036
|
+
return Object.values(metadata).some(
|
|
13037
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
13038
|
+
);
|
|
13039
|
+
}
|
|
13040
|
+
const widgetModule = { widgets: [] };
|
|
13041
|
+
const routeModule = {
|
|
13042
|
+
routes: [
|
|
13043
|
+
{
|
|
13044
|
+
Component: List,
|
|
13045
|
+
path: "/draft-orders",
|
|
13046
|
+
handle: handle$1,
|
|
13047
|
+
children: [
|
|
13048
|
+
{
|
|
13049
|
+
Component: Create,
|
|
13050
|
+
path: "/draft-orders/create"
|
|
13051
|
+
}
|
|
13052
|
+
]
|
|
13053
|
+
},
|
|
13054
|
+
{
|
|
13055
|
+
Component: ID,
|
|
13056
|
+
path: "/draft-orders/:id",
|
|
13057
|
+
handle,
|
|
13058
|
+
loader,
|
|
13059
|
+
children: [
|
|
13060
|
+
{
|
|
13061
|
+
Component: BillingAddress,
|
|
13062
|
+
path: "/draft-orders/:id/billing-address"
|
|
13063
|
+
},
|
|
13064
|
+
{
|
|
13065
|
+
Component: Email,
|
|
13066
|
+
path: "/draft-orders/:id/email"
|
|
13067
|
+
},
|
|
13068
|
+
{
|
|
13069
|
+
Component: CustomItems,
|
|
13070
|
+
path: "/draft-orders/:id/custom-items"
|
|
13071
|
+
},
|
|
13072
|
+
{
|
|
13073
|
+
Component: Items,
|
|
13074
|
+
path: "/draft-orders/:id/items"
|
|
13075
|
+
},
|
|
13076
|
+
{
|
|
13077
|
+
Component: Promotions,
|
|
13078
|
+
path: "/draft-orders/:id/promotions"
|
|
13079
|
+
},
|
|
13080
|
+
{
|
|
13081
|
+
Component: SalesChannel,
|
|
13082
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13083
|
+
},
|
|
13084
|
+
{
|
|
13085
|
+
Component: Shipping,
|
|
13086
|
+
path: "/draft-orders/:id/shipping"
|
|
13087
|
+
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: ShippingAddress,
|
|
13090
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
+
},
|
|
13092
|
+
{
|
|
13093
|
+
Component: TransferOwnership,
|
|
13094
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
|
+
},
|
|
13096
|
+
{
|
|
13097
|
+
Component: Metadata,
|
|
13098
|
+
path: "/draft-orders/:id/metadata"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|