@medusajs/draft-order 2.21.0 → 2.21.1-preview-20260916094546
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 +490 -490
- package/.medusa/server/src/admin/index.mjs +490 -490
- package/package.json +18 -18
|
@@ -6168,95 +6168,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
6168
6168
|
) });
|
|
6169
6169
|
};
|
|
6170
6170
|
const schema$5 = addressSchema;
|
|
6171
|
-
const CustomItems = () => {
|
|
6172
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
6173
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
6174
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
6175
|
-
] });
|
|
6176
|
-
};
|
|
6177
|
-
const CustomItemsForm = () => {
|
|
6178
|
-
const form = reactHookForm.useForm({
|
|
6179
|
-
resolver: zod$1.zodResolver(schema$4)
|
|
6180
|
-
});
|
|
6181
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
6182
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
6183
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6184
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6185
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
6186
|
-
] }) })
|
|
6187
|
-
] }) });
|
|
6188
|
-
};
|
|
6189
|
-
const schema$4 = zod.z.object({
|
|
6190
|
-
email: zod.z.string().email()
|
|
6191
|
-
});
|
|
6192
|
-
const Email = () => {
|
|
6193
|
-
const { id } = reactRouterDom.useParams();
|
|
6194
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
6195
|
-
fields: "+email"
|
|
6196
|
-
});
|
|
6197
|
-
if (isError) {
|
|
6198
|
-
throw error;
|
|
6199
|
-
}
|
|
6200
|
-
const isReady = !isPending && !!order;
|
|
6201
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
6202
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
6203
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
6204
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
6205
|
-
] }),
|
|
6206
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
6207
|
-
] });
|
|
6208
|
-
};
|
|
6209
|
-
const EmailForm = ({ order }) => {
|
|
6210
|
-
const form = reactHookForm.useForm({
|
|
6211
|
-
defaultValues: {
|
|
6212
|
-
email: order.email ?? ""
|
|
6213
|
-
},
|
|
6214
|
-
resolver: zod$1.zodResolver(schema$3)
|
|
6215
|
-
});
|
|
6216
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6217
|
-
const { handleSuccess } = useRouteModal();
|
|
6218
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
6219
|
-
await mutateAsync(
|
|
6220
|
-
{ email: data.email },
|
|
6221
|
-
{
|
|
6222
|
-
onSuccess: () => {
|
|
6223
|
-
handleSuccess();
|
|
6224
|
-
},
|
|
6225
|
-
onError: (error) => {
|
|
6226
|
-
ui.toast.error(error.message);
|
|
6227
|
-
}
|
|
6228
|
-
}
|
|
6229
|
-
);
|
|
6230
|
-
});
|
|
6231
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6232
|
-
KeyboundForm,
|
|
6233
|
-
{
|
|
6234
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
6235
|
-
onSubmit,
|
|
6236
|
-
children: [
|
|
6237
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6238
|
-
Form$2.Field,
|
|
6239
|
-
{
|
|
6240
|
-
control: form.control,
|
|
6241
|
-
name: "email",
|
|
6242
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
6243
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
6244
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
6245
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
6246
|
-
] })
|
|
6247
|
-
}
|
|
6248
|
-
) }),
|
|
6249
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6250
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
6251
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
6252
|
-
] }) })
|
|
6253
|
-
]
|
|
6254
|
-
}
|
|
6255
|
-
) });
|
|
6256
|
-
};
|
|
6257
|
-
const schema$3 = zod.z.object({
|
|
6258
|
-
email: zod.z.string().email()
|
|
6259
|
-
});
|
|
6260
6171
|
const NumberInput = React.forwardRef(
|
|
6261
6172
|
({
|
|
6262
6173
|
value,
|
|
@@ -7276,6 +7187,95 @@ const customItemSchema = zod.z.object({
|
|
|
7276
7187
|
quantity: zod.z.number(),
|
|
7277
7188
|
unit_price: zod.z.union([zod.z.number(), zod.z.string()])
|
|
7278
7189
|
});
|
|
7190
|
+
const Email = () => {
|
|
7191
|
+
const { id } = reactRouterDom.useParams();
|
|
7192
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
7193
|
+
fields: "+email"
|
|
7194
|
+
});
|
|
7195
|
+
if (isError) {
|
|
7196
|
+
throw error;
|
|
7197
|
+
}
|
|
7198
|
+
const isReady = !isPending && !!order;
|
|
7199
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7200
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
7201
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
7202
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
7203
|
+
] }),
|
|
7204
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
7205
|
+
] });
|
|
7206
|
+
};
|
|
7207
|
+
const EmailForm = ({ order }) => {
|
|
7208
|
+
const form = reactHookForm.useForm({
|
|
7209
|
+
defaultValues: {
|
|
7210
|
+
email: order.email ?? ""
|
|
7211
|
+
},
|
|
7212
|
+
resolver: zod$1.zodResolver(schema$4)
|
|
7213
|
+
});
|
|
7214
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7215
|
+
const { handleSuccess } = useRouteModal();
|
|
7216
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
7217
|
+
await mutateAsync(
|
|
7218
|
+
{ email: data.email },
|
|
7219
|
+
{
|
|
7220
|
+
onSuccess: () => {
|
|
7221
|
+
handleSuccess();
|
|
7222
|
+
},
|
|
7223
|
+
onError: (error) => {
|
|
7224
|
+
ui.toast.error(error.message);
|
|
7225
|
+
}
|
|
7226
|
+
}
|
|
7227
|
+
);
|
|
7228
|
+
});
|
|
7229
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7230
|
+
KeyboundForm,
|
|
7231
|
+
{
|
|
7232
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
7233
|
+
onSubmit,
|
|
7234
|
+
children: [
|
|
7235
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7236
|
+
Form$2.Field,
|
|
7237
|
+
{
|
|
7238
|
+
control: form.control,
|
|
7239
|
+
name: "email",
|
|
7240
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7241
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
7242
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
7243
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
7244
|
+
] })
|
|
7245
|
+
}
|
|
7246
|
+
) }),
|
|
7247
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7248
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7249
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7250
|
+
] }) })
|
|
7251
|
+
]
|
|
7252
|
+
}
|
|
7253
|
+
) });
|
|
7254
|
+
};
|
|
7255
|
+
const schema$4 = zod.z.object({
|
|
7256
|
+
email: zod.z.string().email()
|
|
7257
|
+
});
|
|
7258
|
+
const CustomItems = () => {
|
|
7259
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
7260
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
7261
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
7262
|
+
] });
|
|
7263
|
+
};
|
|
7264
|
+
const CustomItemsForm = () => {
|
|
7265
|
+
const form = reactHookForm.useForm({
|
|
7266
|
+
resolver: zod$1.zodResolver(schema$3)
|
|
7267
|
+
});
|
|
7268
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
7269
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
7270
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7271
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7272
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
7273
|
+
] }) })
|
|
7274
|
+
] }) });
|
|
7275
|
+
};
|
|
7276
|
+
const schema$3 = zod.z.object({
|
|
7277
|
+
email: zod.z.string().email()
|
|
7278
|
+
});
|
|
7279
7279
|
const InlineTip = React.forwardRef(
|
|
7280
7280
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
7281
7281
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -7901,170 +7901,64 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
7901
7901
|
}
|
|
7902
7902
|
return Array.from(promotionIds);
|
|
7903
7903
|
}
|
|
7904
|
-
const
|
|
7904
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
7905
|
+
const Shipping = () => {
|
|
7905
7906
|
const { id } = reactRouterDom.useParams();
|
|
7906
|
-
const {
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
);
|
|
7907
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
7908
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
7909
|
+
});
|
|
7910
|
+
const {
|
|
7911
|
+
order: preview,
|
|
7912
|
+
isPending: isPreviewPending,
|
|
7913
|
+
isError: isPreviewError,
|
|
7914
|
+
error: previewError
|
|
7915
|
+
} = useOrderPreview(id);
|
|
7916
|
+
useInitiateOrderEdit({ preview });
|
|
7917
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
7915
7918
|
if (isError) {
|
|
7916
7919
|
throw error;
|
|
7917
7920
|
}
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7921
|
+
if (isPreviewError) {
|
|
7922
|
+
throw previewError;
|
|
7923
|
+
}
|
|
7924
|
+
const orderHasItems = (order?.items?.length || 0) > 0;
|
|
7925
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
7926
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
7927
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
7928
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
7929
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
7930
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
7931
|
+
] }) }) }),
|
|
7932
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
7933
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
7934
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
7935
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
7936
|
+
] }) });
|
|
7926
7937
|
};
|
|
7927
|
-
const
|
|
7928
|
-
const
|
|
7929
|
-
|
|
7930
|
-
|
|
7938
|
+
const ShippingForm = ({ preview, order }) => {
|
|
7939
|
+
const { setIsOpen } = useStackedModal();
|
|
7940
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
7941
|
+
const [data, setData] = React.useState(null);
|
|
7942
|
+
const appliedShippingOptionIds = preview.shipping_methods?.map((method) => method.shipping_option_id).filter(Boolean);
|
|
7943
|
+
const { shipping_options } = useShippingOptions(
|
|
7944
|
+
{
|
|
7945
|
+
id: appliedShippingOptionIds,
|
|
7946
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
7931
7947
|
},
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
const
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
onError: (error) => {
|
|
7947
|
-
ui.toast.error(error.message);
|
|
7948
|
-
}
|
|
7949
|
-
}
|
|
7950
|
-
);
|
|
7951
|
-
});
|
|
7952
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7953
|
-
KeyboundForm,
|
|
7954
|
-
{
|
|
7955
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7956
|
-
onSubmit,
|
|
7957
|
-
children: [
|
|
7958
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
7959
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
7960
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
7961
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
7962
|
-
] }) })
|
|
7963
|
-
]
|
|
7964
|
-
}
|
|
7965
|
-
) });
|
|
7966
|
-
};
|
|
7967
|
-
const SalesChannelField = ({ control, order }) => {
|
|
7968
|
-
const salesChannels = useComboboxData({
|
|
7969
|
-
queryFn: async (params) => {
|
|
7970
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7971
|
-
},
|
|
7972
|
-
queryKey: ["sales-channels"],
|
|
7973
|
-
getOptions: (data) => {
|
|
7974
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7975
|
-
label: salesChannel.name,
|
|
7976
|
-
value: salesChannel.id
|
|
7977
|
-
}));
|
|
7978
|
-
},
|
|
7979
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7980
|
-
});
|
|
7981
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7982
|
-
Form$2.Field,
|
|
7983
|
-
{
|
|
7984
|
-
control,
|
|
7985
|
-
name: "sales_channel_id",
|
|
7986
|
-
render: ({ field }) => {
|
|
7987
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
7988
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
7989
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7990
|
-
Combobox,
|
|
7991
|
-
{
|
|
7992
|
-
options: salesChannels.options,
|
|
7993
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7994
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7995
|
-
searchValue: salesChannels.searchValue,
|
|
7996
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7997
|
-
placeholder: "Select sales channel",
|
|
7998
|
-
...field
|
|
7999
|
-
}
|
|
8000
|
-
) }),
|
|
8001
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8002
|
-
] });
|
|
8003
|
-
}
|
|
8004
|
-
}
|
|
8005
|
-
);
|
|
8006
|
-
};
|
|
8007
|
-
const schema$2 = zod.z.object({
|
|
8008
|
-
sales_channel_id: zod.z.string().min(1)
|
|
8009
|
-
});
|
|
8010
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8011
|
-
const Shipping = () => {
|
|
8012
|
-
const { id } = reactRouterDom.useParams();
|
|
8013
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
8014
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
8015
|
-
});
|
|
8016
|
-
const {
|
|
8017
|
-
order: preview,
|
|
8018
|
-
isPending: isPreviewPending,
|
|
8019
|
-
isError: isPreviewError,
|
|
8020
|
-
error: previewError
|
|
8021
|
-
} = useOrderPreview(id);
|
|
8022
|
-
useInitiateOrderEdit({ preview });
|
|
8023
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
8024
|
-
if (isError) {
|
|
8025
|
-
throw error;
|
|
8026
|
-
}
|
|
8027
|
-
if (isPreviewError) {
|
|
8028
|
-
throw previewError;
|
|
8029
|
-
}
|
|
8030
|
-
const orderHasItems = (order?.items?.length || 0) > 0;
|
|
8031
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
8032
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
8033
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
8034
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
8035
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
8036
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
8037
|
-
] }) }) }),
|
|
8038
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
8039
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8040
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
8041
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
8042
|
-
] }) });
|
|
8043
|
-
};
|
|
8044
|
-
const ShippingForm = ({ preview, order }) => {
|
|
8045
|
-
const { setIsOpen } = useStackedModal();
|
|
8046
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
8047
|
-
const [data, setData] = React.useState(null);
|
|
8048
|
-
const appliedShippingOptionIds = preview.shipping_methods?.map((method) => method.shipping_option_id).filter(Boolean);
|
|
8049
|
-
const { shipping_options } = useShippingOptions(
|
|
8050
|
-
{
|
|
8051
|
-
id: appliedShippingOptionIds,
|
|
8052
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
8053
|
-
},
|
|
8054
|
-
{
|
|
8055
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
8056
|
-
}
|
|
8057
|
-
);
|
|
8058
|
-
const uniqueShippingProfiles = React.useMemo(() => {
|
|
8059
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
8060
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
8061
|
-
profiles.set(profile.id, profile);
|
|
8062
|
-
});
|
|
8063
|
-
shipping_options?.forEach((option) => {
|
|
8064
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
8065
|
-
});
|
|
8066
|
-
return Array.from(profiles.values());
|
|
8067
|
-
}, [order.items, shipping_options]);
|
|
7948
|
+
{
|
|
7949
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
7950
|
+
}
|
|
7951
|
+
);
|
|
7952
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
7953
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
7954
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
7955
|
+
profiles.set(profile.id, profile);
|
|
7956
|
+
});
|
|
7957
|
+
shipping_options?.forEach((option) => {
|
|
7958
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
7959
|
+
});
|
|
7960
|
+
return Array.from(profiles.values());
|
|
7961
|
+
}, [order.items, shipping_options]);
|
|
8068
7962
|
const { handleSuccess } = useRouteModal();
|
|
8069
7963
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
8070
7964
|
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
@@ -8801,59 +8695,43 @@ const CustomAmountField = ({
|
|
|
8801
8695
|
}
|
|
8802
8696
|
);
|
|
8803
8697
|
};
|
|
8804
|
-
const
|
|
8698
|
+
const TransferOwnership = () => {
|
|
8805
8699
|
const { id } = reactRouterDom.useParams();
|
|
8806
|
-
const {
|
|
8807
|
-
fields: "
|
|
8700
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
8701
|
+
fields: "id,customer_id,customer.*"
|
|
8808
8702
|
});
|
|
8809
8703
|
if (isError) {
|
|
8810
8704
|
throw error;
|
|
8811
8705
|
}
|
|
8812
|
-
const isReady = !isPending && !!
|
|
8706
|
+
const isReady = !isPending && !!draft_order;
|
|
8813
8707
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
8814
8708
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
8815
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
8816
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
8709
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
8710
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
8817
8711
|
] }),
|
|
8818
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8712
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
8819
8713
|
] });
|
|
8820
8714
|
};
|
|
8821
|
-
const
|
|
8715
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
8822
8716
|
const form = reactHookForm.useForm({
|
|
8823
8717
|
defaultValues: {
|
|
8824
|
-
|
|
8825
|
-
last_name: order.shipping_address?.last_name ?? "",
|
|
8826
|
-
company: order.shipping_address?.company ?? "",
|
|
8827
|
-
address_1: order.shipping_address?.address_1 ?? "",
|
|
8828
|
-
address_2: order.shipping_address?.address_2 ?? "",
|
|
8829
|
-
city: order.shipping_address?.city ?? "",
|
|
8830
|
-
province: order.shipping_address?.province ?? "",
|
|
8831
|
-
country_code: order.shipping_address?.country_code ?? "",
|
|
8832
|
-
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8833
|
-
phone: order.shipping_address?.phone ?? ""
|
|
8718
|
+
customer_id: order.customer_id || ""
|
|
8834
8719
|
},
|
|
8835
|
-
resolver: zod$1.zodResolver(schema$
|
|
8720
|
+
resolver: zod$1.zodResolver(schema$2)
|
|
8836
8721
|
});
|
|
8837
8722
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8838
8723
|
const { handleSuccess } = useRouteModal();
|
|
8724
|
+
const name = [order.customer?.first_name, order.customer?.last_name].filter(Boolean).join(" ");
|
|
8725
|
+
const currentCustomer = order.customer ? {
|
|
8726
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
8727
|
+
value: order.customer.id
|
|
8728
|
+
} : null;
|
|
8839
8729
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
8840
8730
|
await mutateAsync(
|
|
8841
|
-
{
|
|
8842
|
-
shipping_address: {
|
|
8843
|
-
first_name: data.first_name,
|
|
8844
|
-
last_name: data.last_name,
|
|
8845
|
-
company: data.company,
|
|
8846
|
-
address_1: data.address_1,
|
|
8847
|
-
address_2: data.address_2,
|
|
8848
|
-
city: data.city,
|
|
8849
|
-
province: data.province,
|
|
8850
|
-
country_code: data.country_code,
|
|
8851
|
-
postal_code: data.postal_code,
|
|
8852
|
-
phone: data.phone
|
|
8853
|
-
}
|
|
8854
|
-
},
|
|
8731
|
+
{ customer_id: data.customer_id },
|
|
8855
8732
|
{
|
|
8856
8733
|
onSuccess: () => {
|
|
8734
|
+
ui.toast.success("Customer updated");
|
|
8857
8735
|
handleSuccess();
|
|
8858
8736
|
},
|
|
8859
8737
|
onError: (error) => {
|
|
@@ -8868,209 +8746,23 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
8868
8746
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
8869
8747
|
onSubmit,
|
|
8870
8748
|
children: [
|
|
8871
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8872
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8873
|
-
|
|
8874
|
-
{
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
}
|
|
8883
|
-
),
|
|
8884
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
8885
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8886
|
-
Form$2.Field,
|
|
8887
|
-
{
|
|
8888
|
-
control: form.control,
|
|
8889
|
-
name: "first_name",
|
|
8890
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8891
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
8892
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8893
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8894
|
-
] })
|
|
8895
|
-
}
|
|
8896
|
-
),
|
|
8897
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8898
|
-
Form$2.Field,
|
|
8899
|
-
{
|
|
8900
|
-
control: form.control,
|
|
8901
|
-
name: "last_name",
|
|
8902
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8903
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
8904
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8905
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8906
|
-
] })
|
|
8907
|
-
}
|
|
8908
|
-
)
|
|
8749
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
8750
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
8751
|
+
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
8752
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8753
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
8754
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
8755
|
+
] }),
|
|
8756
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
8757
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
8758
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
8759
|
+
] })
|
|
8909
8760
|
] }),
|
|
8910
8761
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8911
|
-
|
|
8912
|
-
{
|
|
8913
|
-
control: form.control,
|
|
8914
|
-
name: "company",
|
|
8915
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8916
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
8917
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8918
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8919
|
-
] })
|
|
8920
|
-
}
|
|
8921
|
-
),
|
|
8922
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8923
|
-
Form$2.Field,
|
|
8762
|
+
CustomerField,
|
|
8924
8763
|
{
|
|
8925
8764
|
control: form.control,
|
|
8926
|
-
|
|
8927
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8928
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
8929
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8930
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8931
|
-
] })
|
|
8932
|
-
}
|
|
8933
|
-
),
|
|
8934
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8935
|
-
Form$2.Field,
|
|
8936
|
-
{
|
|
8937
|
-
control: form.control,
|
|
8938
|
-
name: "address_2",
|
|
8939
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8940
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
8941
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8942
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8943
|
-
] })
|
|
8944
|
-
}
|
|
8945
|
-
),
|
|
8946
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
8947
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8948
|
-
Form$2.Field,
|
|
8949
|
-
{
|
|
8950
|
-
control: form.control,
|
|
8951
|
-
name: "postal_code",
|
|
8952
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8953
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
8954
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8955
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8956
|
-
] })
|
|
8957
|
-
}
|
|
8958
|
-
),
|
|
8959
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8960
|
-
Form$2.Field,
|
|
8961
|
-
{
|
|
8962
|
-
control: form.control,
|
|
8963
|
-
name: "city",
|
|
8964
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8965
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
8966
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8967
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8968
|
-
] })
|
|
8969
|
-
}
|
|
8970
|
-
)
|
|
8971
|
-
] }),
|
|
8972
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8973
|
-
Form$2.Field,
|
|
8974
|
-
{
|
|
8975
|
-
control: form.control,
|
|
8976
|
-
name: "province",
|
|
8977
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8978
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
8979
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8980
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8981
|
-
] })
|
|
8982
|
-
}
|
|
8983
|
-
),
|
|
8984
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8985
|
-
Form$2.Field,
|
|
8986
|
-
{
|
|
8987
|
-
control: form.control,
|
|
8988
|
-
name: "phone",
|
|
8989
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8990
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
8991
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8992
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8993
|
-
] })
|
|
8994
|
-
}
|
|
8995
|
-
)
|
|
8996
|
-
] }) }),
|
|
8997
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
8998
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
8999
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9000
|
-
] }) })
|
|
9001
|
-
]
|
|
9002
|
-
}
|
|
9003
|
-
) });
|
|
9004
|
-
};
|
|
9005
|
-
const schema$1 = addressSchema;
|
|
9006
|
-
const TransferOwnership = () => {
|
|
9007
|
-
const { id } = reactRouterDom.useParams();
|
|
9008
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
9009
|
-
fields: "id,customer_id,customer.*"
|
|
9010
|
-
});
|
|
9011
|
-
if (isError) {
|
|
9012
|
-
throw error;
|
|
9013
|
-
}
|
|
9014
|
-
const isReady = !isPending && !!draft_order;
|
|
9015
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9016
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9017
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
9018
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
9019
|
-
] }),
|
|
9020
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
9021
|
-
] });
|
|
9022
|
-
};
|
|
9023
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
9024
|
-
const form = reactHookForm.useForm({
|
|
9025
|
-
defaultValues: {
|
|
9026
|
-
customer_id: order.customer_id || ""
|
|
9027
|
-
},
|
|
9028
|
-
resolver: zod$1.zodResolver(schema)
|
|
9029
|
-
});
|
|
9030
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9031
|
-
const { handleSuccess } = useRouteModal();
|
|
9032
|
-
const name = [order.customer?.first_name, order.customer?.last_name].filter(Boolean).join(" ");
|
|
9033
|
-
const currentCustomer = order.customer ? {
|
|
9034
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
9035
|
-
value: order.customer.id
|
|
9036
|
-
} : null;
|
|
9037
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9038
|
-
await mutateAsync(
|
|
9039
|
-
{ customer_id: data.customer_id },
|
|
9040
|
-
{
|
|
9041
|
-
onSuccess: () => {
|
|
9042
|
-
ui.toast.success("Customer updated");
|
|
9043
|
-
handleSuccess();
|
|
9044
|
-
},
|
|
9045
|
-
onError: (error) => {
|
|
9046
|
-
ui.toast.error(error.message);
|
|
9047
|
-
}
|
|
9048
|
-
}
|
|
9049
|
-
);
|
|
9050
|
-
});
|
|
9051
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9052
|
-
KeyboundForm,
|
|
9053
|
-
{
|
|
9054
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9055
|
-
onSubmit,
|
|
9056
|
-
children: [
|
|
9057
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
9058
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
9059
|
-
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
9060
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
9061
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
9062
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
9063
|
-
] }),
|
|
9064
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
9065
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
9066
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
9067
|
-
] })
|
|
9068
|
-
] }),
|
|
9069
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9070
|
-
CustomerField,
|
|
9071
|
-
{
|
|
9072
|
-
control: form.control,
|
|
9073
|
-
currentCustomerId: order.customer_id
|
|
8765
|
+
currentCustomerId: order.customer_id
|
|
9074
8766
|
}
|
|
9075
8767
|
)
|
|
9076
8768
|
] }),
|
|
@@ -9475,9 +9167,317 @@ const Illustration = () => {
|
|
|
9475
9167
|
}
|
|
9476
9168
|
);
|
|
9477
9169
|
};
|
|
9478
|
-
const schema = zod.z.object({
|
|
9170
|
+
const schema$2 = zod.z.object({
|
|
9479
9171
|
customer_id: zod.z.string().min(1)
|
|
9480
9172
|
});
|
|
9173
|
+
const ShippingAddress = () => {
|
|
9174
|
+
const { id } = reactRouterDom.useParams();
|
|
9175
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9176
|
+
fields: "+shipping_address"
|
|
9177
|
+
});
|
|
9178
|
+
if (isError) {
|
|
9179
|
+
throw error;
|
|
9180
|
+
}
|
|
9181
|
+
const isReady = !isPending && !!order;
|
|
9182
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9183
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9184
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
9185
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
9186
|
+
] }),
|
|
9187
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
9188
|
+
] });
|
|
9189
|
+
};
|
|
9190
|
+
const ShippingAddressForm = ({ order }) => {
|
|
9191
|
+
const form = reactHookForm.useForm({
|
|
9192
|
+
defaultValues: {
|
|
9193
|
+
first_name: order.shipping_address?.first_name ?? "",
|
|
9194
|
+
last_name: order.shipping_address?.last_name ?? "",
|
|
9195
|
+
company: order.shipping_address?.company ?? "",
|
|
9196
|
+
address_1: order.shipping_address?.address_1 ?? "",
|
|
9197
|
+
address_2: order.shipping_address?.address_2 ?? "",
|
|
9198
|
+
city: order.shipping_address?.city ?? "",
|
|
9199
|
+
province: order.shipping_address?.province ?? "",
|
|
9200
|
+
country_code: order.shipping_address?.country_code ?? "",
|
|
9201
|
+
postal_code: order.shipping_address?.postal_code ?? "",
|
|
9202
|
+
phone: order.shipping_address?.phone ?? ""
|
|
9203
|
+
},
|
|
9204
|
+
resolver: zod$1.zodResolver(schema$1)
|
|
9205
|
+
});
|
|
9206
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9207
|
+
const { handleSuccess } = useRouteModal();
|
|
9208
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9209
|
+
await mutateAsync(
|
|
9210
|
+
{
|
|
9211
|
+
shipping_address: {
|
|
9212
|
+
first_name: data.first_name,
|
|
9213
|
+
last_name: data.last_name,
|
|
9214
|
+
company: data.company,
|
|
9215
|
+
address_1: data.address_1,
|
|
9216
|
+
address_2: data.address_2,
|
|
9217
|
+
city: data.city,
|
|
9218
|
+
province: data.province,
|
|
9219
|
+
country_code: data.country_code,
|
|
9220
|
+
postal_code: data.postal_code,
|
|
9221
|
+
phone: data.phone
|
|
9222
|
+
}
|
|
9223
|
+
},
|
|
9224
|
+
{
|
|
9225
|
+
onSuccess: () => {
|
|
9226
|
+
handleSuccess();
|
|
9227
|
+
},
|
|
9228
|
+
onError: (error) => {
|
|
9229
|
+
ui.toast.error(error.message);
|
|
9230
|
+
}
|
|
9231
|
+
}
|
|
9232
|
+
);
|
|
9233
|
+
});
|
|
9234
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9235
|
+
KeyboundForm,
|
|
9236
|
+
{
|
|
9237
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9238
|
+
onSubmit,
|
|
9239
|
+
children: [
|
|
9240
|
+
/* @__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: [
|
|
9241
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9242
|
+
Form$2.Field,
|
|
9243
|
+
{
|
|
9244
|
+
control: form.control,
|
|
9245
|
+
name: "country_code",
|
|
9246
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9247
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9248
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9249
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9250
|
+
] })
|
|
9251
|
+
}
|
|
9252
|
+
),
|
|
9253
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9254
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9255
|
+
Form$2.Field,
|
|
9256
|
+
{
|
|
9257
|
+
control: form.control,
|
|
9258
|
+
name: "first_name",
|
|
9259
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9260
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9261
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9262
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9263
|
+
] })
|
|
9264
|
+
}
|
|
9265
|
+
),
|
|
9266
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9267
|
+
Form$2.Field,
|
|
9268
|
+
{
|
|
9269
|
+
control: form.control,
|
|
9270
|
+
name: "last_name",
|
|
9271
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9272
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9273
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9274
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9275
|
+
] })
|
|
9276
|
+
}
|
|
9277
|
+
)
|
|
9278
|
+
] }),
|
|
9279
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9280
|
+
Form$2.Field,
|
|
9281
|
+
{
|
|
9282
|
+
control: form.control,
|
|
9283
|
+
name: "company",
|
|
9284
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9285
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9286
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9287
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9288
|
+
] })
|
|
9289
|
+
}
|
|
9290
|
+
),
|
|
9291
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9292
|
+
Form$2.Field,
|
|
9293
|
+
{
|
|
9294
|
+
control: form.control,
|
|
9295
|
+
name: "address_1",
|
|
9296
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9297
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9298
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9299
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9300
|
+
] })
|
|
9301
|
+
}
|
|
9302
|
+
),
|
|
9303
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9304
|
+
Form$2.Field,
|
|
9305
|
+
{
|
|
9306
|
+
control: form.control,
|
|
9307
|
+
name: "address_2",
|
|
9308
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9309
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9310
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9311
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9312
|
+
] })
|
|
9313
|
+
}
|
|
9314
|
+
),
|
|
9315
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9316
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9317
|
+
Form$2.Field,
|
|
9318
|
+
{
|
|
9319
|
+
control: form.control,
|
|
9320
|
+
name: "postal_code",
|
|
9321
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9322
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9323
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9324
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9325
|
+
] })
|
|
9326
|
+
}
|
|
9327
|
+
),
|
|
9328
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9329
|
+
Form$2.Field,
|
|
9330
|
+
{
|
|
9331
|
+
control: form.control,
|
|
9332
|
+
name: "city",
|
|
9333
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9334
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9335
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9336
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9337
|
+
] })
|
|
9338
|
+
}
|
|
9339
|
+
)
|
|
9340
|
+
] }),
|
|
9341
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9342
|
+
Form$2.Field,
|
|
9343
|
+
{
|
|
9344
|
+
control: form.control,
|
|
9345
|
+
name: "province",
|
|
9346
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9347
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9348
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9349
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9350
|
+
] })
|
|
9351
|
+
}
|
|
9352
|
+
),
|
|
9353
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9354
|
+
Form$2.Field,
|
|
9355
|
+
{
|
|
9356
|
+
control: form.control,
|
|
9357
|
+
name: "phone",
|
|
9358
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9359
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9360
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9361
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9362
|
+
] })
|
|
9363
|
+
}
|
|
9364
|
+
)
|
|
9365
|
+
] }) }),
|
|
9366
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9367
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9368
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9369
|
+
] }) })
|
|
9370
|
+
]
|
|
9371
|
+
}
|
|
9372
|
+
) });
|
|
9373
|
+
};
|
|
9374
|
+
const schema$1 = addressSchema;
|
|
9375
|
+
const SalesChannel = () => {
|
|
9376
|
+
const { id } = reactRouterDom.useParams();
|
|
9377
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
9378
|
+
id,
|
|
9379
|
+
{
|
|
9380
|
+
fields: "+sales_channel_id"
|
|
9381
|
+
},
|
|
9382
|
+
{
|
|
9383
|
+
enabled: !!id
|
|
9384
|
+
}
|
|
9385
|
+
);
|
|
9386
|
+
if (isError) {
|
|
9387
|
+
throw error;
|
|
9388
|
+
}
|
|
9389
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
9390
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9391
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9392
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
9393
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
9394
|
+
] }),
|
|
9395
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
9396
|
+
] });
|
|
9397
|
+
};
|
|
9398
|
+
const SalesChannelForm = ({ order }) => {
|
|
9399
|
+
const form = reactHookForm.useForm({
|
|
9400
|
+
defaultValues: {
|
|
9401
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
9402
|
+
},
|
|
9403
|
+
resolver: zod$1.zodResolver(schema)
|
|
9404
|
+
});
|
|
9405
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9406
|
+
const { handleSuccess } = useRouteModal();
|
|
9407
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9408
|
+
await mutateAsync(
|
|
9409
|
+
{
|
|
9410
|
+
sales_channel_id: data.sales_channel_id
|
|
9411
|
+
},
|
|
9412
|
+
{
|
|
9413
|
+
onSuccess: () => {
|
|
9414
|
+
ui.toast.success("Sales channel updated");
|
|
9415
|
+
handleSuccess();
|
|
9416
|
+
},
|
|
9417
|
+
onError: (error) => {
|
|
9418
|
+
ui.toast.error(error.message);
|
|
9419
|
+
}
|
|
9420
|
+
}
|
|
9421
|
+
);
|
|
9422
|
+
});
|
|
9423
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9424
|
+
KeyboundForm,
|
|
9425
|
+
{
|
|
9426
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9427
|
+
onSubmit,
|
|
9428
|
+
children: [
|
|
9429
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
9430
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9431
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9432
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9433
|
+
] }) })
|
|
9434
|
+
]
|
|
9435
|
+
}
|
|
9436
|
+
) });
|
|
9437
|
+
};
|
|
9438
|
+
const SalesChannelField = ({ control, order }) => {
|
|
9439
|
+
const salesChannels = useComboboxData({
|
|
9440
|
+
queryFn: async (params) => {
|
|
9441
|
+
return await sdk.admin.salesChannel.list(params);
|
|
9442
|
+
},
|
|
9443
|
+
queryKey: ["sales-channels"],
|
|
9444
|
+
getOptions: (data) => {
|
|
9445
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
9446
|
+
label: salesChannel.name,
|
|
9447
|
+
value: salesChannel.id
|
|
9448
|
+
}));
|
|
9449
|
+
},
|
|
9450
|
+
defaultValue: order.sales_channel_id || void 0
|
|
9451
|
+
});
|
|
9452
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9453
|
+
Form$2.Field,
|
|
9454
|
+
{
|
|
9455
|
+
control,
|
|
9456
|
+
name: "sales_channel_id",
|
|
9457
|
+
render: ({ field }) => {
|
|
9458
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9459
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
9460
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9461
|
+
Combobox,
|
|
9462
|
+
{
|
|
9463
|
+
options: salesChannels.options,
|
|
9464
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
9465
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
9466
|
+
searchValue: salesChannels.searchValue,
|
|
9467
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
9468
|
+
placeholder: "Select sales channel",
|
|
9469
|
+
...field
|
|
9470
|
+
}
|
|
9471
|
+
) }),
|
|
9472
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9473
|
+
] });
|
|
9474
|
+
}
|
|
9475
|
+
}
|
|
9476
|
+
);
|
|
9477
|
+
};
|
|
9478
|
+
const schema = zod.z.object({
|
|
9479
|
+
sales_channel_id: zod.z.string().min(1)
|
|
9480
|
+
});
|
|
9481
9481
|
const widgetModule = { widgets: [] };
|
|
9482
9482
|
const routeModule = {
|
|
9483
9483
|
routes: [
|
|
@@ -9503,16 +9503,16 @@ const routeModule = {
|
|
|
9503
9503
|
path: "/draft-orders/:id/billing-address"
|
|
9504
9504
|
},
|
|
9505
9505
|
{
|
|
9506
|
-
Component:
|
|
9507
|
-
path: "/draft-orders/:id/
|
|
9506
|
+
Component: Items,
|
|
9507
|
+
path: "/draft-orders/:id/items"
|
|
9508
9508
|
},
|
|
9509
9509
|
{
|
|
9510
9510
|
Component: Email,
|
|
9511
9511
|
path: "/draft-orders/:id/email"
|
|
9512
9512
|
},
|
|
9513
9513
|
{
|
|
9514
|
-
Component:
|
|
9515
|
-
path: "/draft-orders/:id/items"
|
|
9514
|
+
Component: CustomItems,
|
|
9515
|
+
path: "/draft-orders/:id/custom-items"
|
|
9516
9516
|
},
|
|
9517
9517
|
{
|
|
9518
9518
|
Component: Metadata,
|
|
@@ -9522,21 +9522,21 @@ const routeModule = {
|
|
|
9522
9522
|
Component: Promotions,
|
|
9523
9523
|
path: "/draft-orders/:id/promotions"
|
|
9524
9524
|
},
|
|
9525
|
-
{
|
|
9526
|
-
Component: SalesChannel,
|
|
9527
|
-
path: "/draft-orders/:id/sales-channel"
|
|
9528
|
-
},
|
|
9529
9525
|
{
|
|
9530
9526
|
Component: Shipping,
|
|
9531
9527
|
path: "/draft-orders/:id/shipping"
|
|
9532
9528
|
},
|
|
9529
|
+
{
|
|
9530
|
+
Component: TransferOwnership,
|
|
9531
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
9532
|
+
},
|
|
9533
9533
|
{
|
|
9534
9534
|
Component: ShippingAddress,
|
|
9535
9535
|
path: "/draft-orders/:id/shipping-address"
|
|
9536
9536
|
},
|
|
9537
9537
|
{
|
|
9538
|
-
Component:
|
|
9539
|
-
path: "/draft-orders/:id/
|
|
9538
|
+
Component: SalesChannel,
|
|
9539
|
+
path: "/draft-orders/:id/sales-channel"
|
|
9540
9540
|
}
|
|
9541
9541
|
]
|
|
9542
9542
|
}
|