@medusajs/draft-order 2.21.1-preview-20260922104932 → 2.21.1
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 +1130 -1130
- package/.medusa/server/src/admin/index.mjs +1130 -1130
- package/package.json +18 -18
|
@@ -8007,817 +8007,140 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
8007
8007
|
const schema$2 = zod.z.object({
|
|
8008
8008
|
sales_channel_id: zod.z.string().min(1)
|
|
8009
8009
|
});
|
|
8010
|
-
const
|
|
8010
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8011
|
+
const Shipping = () => {
|
|
8011
8012
|
const { id } = reactRouterDom.useParams();
|
|
8012
8013
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
8013
|
-
fields: "+
|
|
8014
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
8014
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 });
|
|
8015
8024
|
if (isError) {
|
|
8016
8025
|
throw error;
|
|
8017
8026
|
}
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
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
|
+
] }) });
|
|
8026
8043
|
};
|
|
8027
|
-
const
|
|
8028
|
-
const
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
province: order.shipping_address?.province ?? "",
|
|
8037
|
-
country_code: order.shipping_address?.country_code ?? "",
|
|
8038
|
-
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8039
|
-
phone: order.shipping_address?.phone ?? ""
|
|
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.*"
|
|
8040
8053
|
},
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
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]);
|
|
8044
8068
|
const { handleSuccess } = useRouteModal();
|
|
8045
|
-
const
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
province: data.province,
|
|
8056
|
-
country_code: data.country_code,
|
|
8057
|
-
postal_code: data.postal_code,
|
|
8058
|
-
phone: data.phone
|
|
8059
|
-
}
|
|
8069
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
8070
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
8071
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
8072
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
8073
|
+
const onSubmit = async () => {
|
|
8074
|
+
setIsSubmitting(true);
|
|
8075
|
+
let requestSucceeded = false;
|
|
8076
|
+
await requestOrderEdit(void 0, {
|
|
8077
|
+
onError: (e) => {
|
|
8078
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
8060
8079
|
},
|
|
8061
|
-
{
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8080
|
+
onSuccess: () => {
|
|
8081
|
+
requestSucceeded = true;
|
|
8082
|
+
}
|
|
8083
|
+
});
|
|
8084
|
+
if (!requestSucceeded) {
|
|
8085
|
+
setIsSubmitting(false);
|
|
8086
|
+
return;
|
|
8087
|
+
}
|
|
8088
|
+
await confirmOrderEdit(void 0, {
|
|
8089
|
+
onError: (e) => {
|
|
8090
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
8091
|
+
},
|
|
8092
|
+
onSuccess: () => {
|
|
8093
|
+
handleSuccess();
|
|
8094
|
+
},
|
|
8095
|
+
onSettled: () => {
|
|
8096
|
+
setIsSubmitting(false);
|
|
8097
|
+
}
|
|
8098
|
+
});
|
|
8099
|
+
};
|
|
8100
|
+
const onKeydown = React.useCallback(
|
|
8101
|
+
(e) => {
|
|
8102
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
8103
|
+
if (data || isSubmitting) {
|
|
8104
|
+
return;
|
|
8067
8105
|
}
|
|
8106
|
+
onSubmit();
|
|
8068
8107
|
}
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
),
|
|
8090
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
8108
|
+
},
|
|
8109
|
+
[data, isSubmitting, onSubmit]
|
|
8110
|
+
);
|
|
8111
|
+
React.useEffect(() => {
|
|
8112
|
+
document.addEventListener("keydown", onKeydown);
|
|
8113
|
+
return () => {
|
|
8114
|
+
document.removeEventListener("keydown", onKeydown);
|
|
8115
|
+
};
|
|
8116
|
+
}, [onKeydown]);
|
|
8117
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
8118
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
8119
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
8120
|
+
/* @__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: [
|
|
8121
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8122
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
8123
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
8124
|
+
] }),
|
|
8125
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
8126
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
8127
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
8091
8128
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8092
|
-
|
|
8129
|
+
ui.Text,
|
|
8093
8130
|
{
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8099
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8100
|
-
] })
|
|
8131
|
+
size: "xsmall",
|
|
8132
|
+
weight: "plus",
|
|
8133
|
+
className: "text-ui-fg-muted",
|
|
8134
|
+
children: "Shipping profile"
|
|
8101
8135
|
}
|
|
8102
8136
|
),
|
|
8103
8137
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8104
|
-
|
|
8138
|
+
ui.Text,
|
|
8105
8139
|
{
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8111
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8112
|
-
] })
|
|
8113
|
-
}
|
|
8114
|
-
)
|
|
8115
|
-
] }),
|
|
8116
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8117
|
-
Form$2.Field,
|
|
8118
|
-
{
|
|
8119
|
-
control: form.control,
|
|
8120
|
-
name: "company",
|
|
8121
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8122
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
8123
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8124
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8125
|
-
] })
|
|
8126
|
-
}
|
|
8127
|
-
),
|
|
8128
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8129
|
-
Form$2.Field,
|
|
8130
|
-
{
|
|
8131
|
-
control: form.control,
|
|
8132
|
-
name: "address_1",
|
|
8133
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8134
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
8135
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8136
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8137
|
-
] })
|
|
8138
|
-
}
|
|
8139
|
-
),
|
|
8140
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8141
|
-
Form$2.Field,
|
|
8142
|
-
{
|
|
8143
|
-
control: form.control,
|
|
8144
|
-
name: "address_2",
|
|
8145
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8146
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
8147
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8148
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8149
|
-
] })
|
|
8150
|
-
}
|
|
8151
|
-
),
|
|
8152
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
8153
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8154
|
-
Form$2.Field,
|
|
8155
|
-
{
|
|
8156
|
-
control: form.control,
|
|
8157
|
-
name: "postal_code",
|
|
8158
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8159
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
8160
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8161
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8162
|
-
] })
|
|
8163
|
-
}
|
|
8164
|
-
),
|
|
8165
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8166
|
-
Form$2.Field,
|
|
8167
|
-
{
|
|
8168
|
-
control: form.control,
|
|
8169
|
-
name: "city",
|
|
8170
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8171
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
8172
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8173
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8174
|
-
] })
|
|
8175
|
-
}
|
|
8176
|
-
)
|
|
8177
|
-
] }),
|
|
8178
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8179
|
-
Form$2.Field,
|
|
8180
|
-
{
|
|
8181
|
-
control: form.control,
|
|
8182
|
-
name: "province",
|
|
8183
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8184
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
8185
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8186
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8187
|
-
] })
|
|
8188
|
-
}
|
|
8189
|
-
),
|
|
8190
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8191
|
-
Form$2.Field,
|
|
8192
|
-
{
|
|
8193
|
-
control: form.control,
|
|
8194
|
-
name: "phone",
|
|
8195
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8196
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
8197
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
8198
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8199
|
-
] })
|
|
8200
|
-
}
|
|
8201
|
-
)
|
|
8202
|
-
] }) }),
|
|
8203
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
8204
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
8205
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
8206
|
-
] }) })
|
|
8207
|
-
]
|
|
8208
|
-
}
|
|
8209
|
-
) });
|
|
8210
|
-
};
|
|
8211
|
-
const schema$1 = addressSchema;
|
|
8212
|
-
const TransferOwnership = () => {
|
|
8213
|
-
const { id } = reactRouterDom.useParams();
|
|
8214
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
8215
|
-
fields: "id,customer_id,customer.*"
|
|
8216
|
-
});
|
|
8217
|
-
if (isError) {
|
|
8218
|
-
throw error;
|
|
8219
|
-
}
|
|
8220
|
-
const isReady = !isPending && !!draft_order;
|
|
8221
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
8222
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
8223
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
8224
|
-
/* @__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" }) })
|
|
8225
|
-
] }),
|
|
8226
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
8227
|
-
] });
|
|
8228
|
-
};
|
|
8229
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
8230
|
-
const form = reactHookForm.useForm({
|
|
8231
|
-
defaultValues: {
|
|
8232
|
-
customer_id: order.customer_id || ""
|
|
8233
|
-
},
|
|
8234
|
-
resolver: zod$1.zodResolver(schema)
|
|
8235
|
-
});
|
|
8236
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8237
|
-
const { handleSuccess } = useRouteModal();
|
|
8238
|
-
const name = [order.customer?.first_name, order.customer?.last_name].filter(Boolean).join(" ");
|
|
8239
|
-
const currentCustomer = order.customer ? {
|
|
8240
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
8241
|
-
value: order.customer.id
|
|
8242
|
-
} : null;
|
|
8243
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
8244
|
-
await mutateAsync(
|
|
8245
|
-
{ customer_id: data.customer_id },
|
|
8246
|
-
{
|
|
8247
|
-
onSuccess: () => {
|
|
8248
|
-
ui.toast.success("Customer updated");
|
|
8249
|
-
handleSuccess();
|
|
8250
|
-
},
|
|
8251
|
-
onError: (error) => {
|
|
8252
|
-
ui.toast.error(error.message);
|
|
8253
|
-
}
|
|
8254
|
-
}
|
|
8255
|
-
);
|
|
8256
|
-
});
|
|
8257
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8258
|
-
KeyboundForm,
|
|
8259
|
-
{
|
|
8260
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
8261
|
-
onSubmit,
|
|
8262
|
-
children: [
|
|
8263
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
8264
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
8265
|
-
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
8266
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8267
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
8268
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
8269
|
-
] }),
|
|
8270
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
8271
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
8272
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
8273
|
-
] })
|
|
8274
|
-
] }),
|
|
8275
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8276
|
-
CustomerField,
|
|
8277
|
-
{
|
|
8278
|
-
control: form.control,
|
|
8279
|
-
currentCustomerId: order.customer_id
|
|
8280
|
-
}
|
|
8281
|
-
)
|
|
8282
|
-
] }),
|
|
8283
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
8284
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
8285
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
8286
|
-
] }) })
|
|
8287
|
-
]
|
|
8288
|
-
}
|
|
8289
|
-
) });
|
|
8290
|
-
};
|
|
8291
|
-
const CustomerField = ({ control, currentCustomerId }) => {
|
|
8292
|
-
const customers = useComboboxData({
|
|
8293
|
-
queryFn: async (params) => {
|
|
8294
|
-
return await sdk.admin.customer.list({
|
|
8295
|
-
...params,
|
|
8296
|
-
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
8297
|
-
});
|
|
8298
|
-
},
|
|
8299
|
-
queryKey: ["customers"],
|
|
8300
|
-
getOptions: (data) => {
|
|
8301
|
-
return data.customers.map((customer) => {
|
|
8302
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
8303
|
-
return {
|
|
8304
|
-
label: name ? `${name} (${customer.email})` : customer.email,
|
|
8305
|
-
value: customer.id
|
|
8306
|
-
};
|
|
8307
|
-
});
|
|
8308
|
-
}
|
|
8309
|
-
});
|
|
8310
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8311
|
-
Form$2.Field,
|
|
8312
|
-
{
|
|
8313
|
-
name: "customer_id",
|
|
8314
|
-
control,
|
|
8315
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
8316
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8317
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
8318
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
8319
|
-
] }),
|
|
8320
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8321
|
-
Combobox,
|
|
8322
|
-
{
|
|
8323
|
-
options: customers.options,
|
|
8324
|
-
fetchNextPage: customers.fetchNextPage,
|
|
8325
|
-
isFetchingNextPage: customers.isFetchingNextPage,
|
|
8326
|
-
searchValue: customers.searchValue,
|
|
8327
|
-
onSearchValueChange: customers.onSearchValueChange,
|
|
8328
|
-
placeholder: "Select customer",
|
|
8329
|
-
...field
|
|
8330
|
-
}
|
|
8331
|
-
) }),
|
|
8332
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
8333
|
-
] })
|
|
8334
|
-
}
|
|
8335
|
-
);
|
|
8336
|
-
};
|
|
8337
|
-
const Illustration = () => {
|
|
8338
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8339
|
-
"svg",
|
|
8340
|
-
{
|
|
8341
|
-
width: "280",
|
|
8342
|
-
height: "180",
|
|
8343
|
-
viewBox: "0 0 280 180",
|
|
8344
|
-
fill: "none",
|
|
8345
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
8346
|
-
children: [
|
|
8347
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8348
|
-
"rect",
|
|
8349
|
-
{
|
|
8350
|
-
x: "0.00428286",
|
|
8351
|
-
y: "-0.742904",
|
|
8352
|
-
width: "33.5",
|
|
8353
|
-
height: "65.5",
|
|
8354
|
-
rx: "6.75",
|
|
8355
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
8356
|
-
fill: "#D4D4D8",
|
|
8357
|
-
stroke: "#52525B",
|
|
8358
|
-
strokeWidth: "1.5"
|
|
8359
|
-
}
|
|
8360
|
-
),
|
|
8361
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8362
|
-
"rect",
|
|
8363
|
-
{
|
|
8364
|
-
x: "0.00428286",
|
|
8365
|
-
y: "-0.742904",
|
|
8366
|
-
width: "33.5",
|
|
8367
|
-
height: "65.5",
|
|
8368
|
-
rx: "6.75",
|
|
8369
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
8370
|
-
fill: "white",
|
|
8371
|
-
stroke: "#52525B",
|
|
8372
|
-
strokeWidth: "1.5"
|
|
8373
|
-
}
|
|
8374
|
-
),
|
|
8375
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8376
|
-
"path",
|
|
8377
|
-
{
|
|
8378
|
-
d: "M180.579 107.142L179.126 107.959",
|
|
8379
|
-
stroke: "#52525B",
|
|
8380
|
-
strokeWidth: "1.5",
|
|
8381
|
-
strokeLinecap: "round",
|
|
8382
|
-
strokeLinejoin: "round"
|
|
8383
|
-
}
|
|
8384
|
-
),
|
|
8385
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8386
|
-
"path",
|
|
8387
|
-
{
|
|
8388
|
-
opacity: "0.88",
|
|
8389
|
-
d: "M182.305 109.546L180.257 109.534",
|
|
8390
|
-
stroke: "#52525B",
|
|
8391
|
-
strokeWidth: "1.5",
|
|
8392
|
-
strokeLinecap: "round",
|
|
8393
|
-
strokeLinejoin: "round"
|
|
8394
|
-
}
|
|
8395
|
-
),
|
|
8396
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8397
|
-
"path",
|
|
8398
|
-
{
|
|
8399
|
-
opacity: "0.75",
|
|
8400
|
-
d: "M180.551 111.93L179.108 111.096",
|
|
8401
|
-
stroke: "#52525B",
|
|
8402
|
-
strokeWidth: "1.5",
|
|
8403
|
-
strokeLinecap: "round",
|
|
8404
|
-
strokeLinejoin: "round"
|
|
8405
|
-
}
|
|
8406
|
-
),
|
|
8407
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8408
|
-
"path",
|
|
8409
|
-
{
|
|
8410
|
-
opacity: "0.63",
|
|
8411
|
-
d: "M176.347 112.897L176.354 111.73",
|
|
8412
|
-
stroke: "#52525B",
|
|
8413
|
-
strokeWidth: "1.5",
|
|
8414
|
-
strokeLinecap: "round",
|
|
8415
|
-
strokeLinejoin: "round"
|
|
8416
|
-
}
|
|
8417
|
-
),
|
|
8418
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8419
|
-
"path",
|
|
8420
|
-
{
|
|
8421
|
-
opacity: "0.5",
|
|
8422
|
-
d: "M172.153 111.881L173.606 111.064",
|
|
8423
|
-
stroke: "#52525B",
|
|
8424
|
-
strokeWidth: "1.5",
|
|
8425
|
-
strokeLinecap: "round",
|
|
8426
|
-
strokeLinejoin: "round"
|
|
8427
|
-
}
|
|
8428
|
-
),
|
|
8429
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8430
|
-
"path",
|
|
8431
|
-
{
|
|
8432
|
-
opacity: "0.38",
|
|
8433
|
-
d: "M170.428 109.478L172.476 109.489",
|
|
8434
|
-
stroke: "#52525B",
|
|
8435
|
-
strokeWidth: "1.5",
|
|
8436
|
-
strokeLinecap: "round",
|
|
8437
|
-
strokeLinejoin: "round"
|
|
8438
|
-
}
|
|
8439
|
-
),
|
|
8440
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8441
|
-
"path",
|
|
8442
|
-
{
|
|
8443
|
-
opacity: "0.25",
|
|
8444
|
-
d: "M172.181 107.094L173.624 107.928",
|
|
8445
|
-
stroke: "#52525B",
|
|
8446
|
-
strokeWidth: "1.5",
|
|
8447
|
-
strokeLinecap: "round",
|
|
8448
|
-
strokeLinejoin: "round"
|
|
8449
|
-
}
|
|
8450
|
-
),
|
|
8451
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8452
|
-
"path",
|
|
8453
|
-
{
|
|
8454
|
-
opacity: "0.13",
|
|
8455
|
-
d: "M176.386 106.126L176.379 107.294",
|
|
8456
|
-
stroke: "#52525B",
|
|
8457
|
-
strokeWidth: "1.5",
|
|
8458
|
-
strokeLinecap: "round",
|
|
8459
|
-
strokeLinejoin: "round"
|
|
8460
|
-
}
|
|
8461
|
-
),
|
|
8462
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8463
|
-
"rect",
|
|
8464
|
-
{
|
|
8465
|
-
width: "12",
|
|
8466
|
-
height: "3",
|
|
8467
|
-
rx: "1.5",
|
|
8468
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
8469
|
-
fill: "#D4D4D8"
|
|
8470
|
-
}
|
|
8471
|
-
),
|
|
8472
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8473
|
-
"rect",
|
|
8474
|
-
{
|
|
8475
|
-
x: "0.00428286",
|
|
8476
|
-
y: "-0.742904",
|
|
8477
|
-
width: "33.5",
|
|
8478
|
-
height: "65.5",
|
|
8479
|
-
rx: "6.75",
|
|
8480
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
8481
|
-
fill: "#D4D4D8",
|
|
8482
|
-
stroke: "#52525B",
|
|
8483
|
-
strokeWidth: "1.5"
|
|
8484
|
-
}
|
|
8485
|
-
),
|
|
8486
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8487
|
-
"rect",
|
|
8488
|
-
{
|
|
8489
|
-
x: "0.00428286",
|
|
8490
|
-
y: "-0.742904",
|
|
8491
|
-
width: "33.5",
|
|
8492
|
-
height: "65.5",
|
|
8493
|
-
rx: "6.75",
|
|
8494
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
8495
|
-
fill: "white",
|
|
8496
|
-
stroke: "#52525B",
|
|
8497
|
-
strokeWidth: "1.5"
|
|
8498
|
-
}
|
|
8499
|
-
),
|
|
8500
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8501
|
-
"rect",
|
|
8502
|
-
{
|
|
8503
|
-
width: "12",
|
|
8504
|
-
height: "3",
|
|
8505
|
-
rx: "1.5",
|
|
8506
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
8507
|
-
fill: "#D4D4D8"
|
|
8508
|
-
}
|
|
8509
|
-
),
|
|
8510
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8511
|
-
"rect",
|
|
8512
|
-
{
|
|
8513
|
-
width: "17",
|
|
8514
|
-
height: "3",
|
|
8515
|
-
rx: "1.5",
|
|
8516
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
8517
|
-
fill: "#D4D4D8"
|
|
8518
|
-
}
|
|
8519
|
-
),
|
|
8520
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8521
|
-
"rect",
|
|
8522
|
-
{
|
|
8523
|
-
width: "12",
|
|
8524
|
-
height: "3",
|
|
8525
|
-
rx: "1.5",
|
|
8526
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
8527
|
-
fill: "#D4D4D8"
|
|
8528
|
-
}
|
|
8529
|
-
),
|
|
8530
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8531
|
-
"path",
|
|
8532
|
-
{
|
|
8533
|
-
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
8534
|
-
fill: "#A1A1AA"
|
|
8535
|
-
}
|
|
8536
|
-
),
|
|
8537
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8538
|
-
"rect",
|
|
8539
|
-
{
|
|
8540
|
-
width: "17",
|
|
8541
|
-
height: "3",
|
|
8542
|
-
rx: "1.5",
|
|
8543
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
8544
|
-
fill: "#A1A1AA"
|
|
8545
|
-
}
|
|
8546
|
-
),
|
|
8547
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8548
|
-
"rect",
|
|
8549
|
-
{
|
|
8550
|
-
width: "12",
|
|
8551
|
-
height: "3",
|
|
8552
|
-
rx: "1.5",
|
|
8553
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
8554
|
-
fill: "#A1A1AA"
|
|
8555
|
-
}
|
|
8556
|
-
),
|
|
8557
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8558
|
-
"path",
|
|
8559
|
-
{
|
|
8560
|
-
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
8561
|
-
fill: "#52525B"
|
|
8562
|
-
}
|
|
8563
|
-
),
|
|
8564
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8565
|
-
"path",
|
|
8566
|
-
{
|
|
8567
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
8568
|
-
stroke: "#A1A1AA",
|
|
8569
|
-
strokeWidth: "1.5",
|
|
8570
|
-
strokeLinecap: "round",
|
|
8571
|
-
strokeLinejoin: "round"
|
|
8572
|
-
}
|
|
8573
|
-
) }),
|
|
8574
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8575
|
-
"path",
|
|
8576
|
-
{
|
|
8577
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
8578
|
-
stroke: "#A1A1AA",
|
|
8579
|
-
strokeWidth: "1.5",
|
|
8580
|
-
strokeLinecap: "round",
|
|
8581
|
-
strokeLinejoin: "round"
|
|
8582
|
-
}
|
|
8583
|
-
) }),
|
|
8584
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8585
|
-
"path",
|
|
8586
|
-
{
|
|
8587
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
8588
|
-
stroke: "#A1A1AA",
|
|
8589
|
-
strokeWidth: "1.5",
|
|
8590
|
-
strokeLinecap: "round",
|
|
8591
|
-
strokeLinejoin: "round"
|
|
8592
|
-
}
|
|
8593
|
-
) }),
|
|
8594
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8595
|
-
"path",
|
|
8596
|
-
{
|
|
8597
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
8598
|
-
stroke: "#A1A1AA",
|
|
8599
|
-
strokeWidth: "1.5",
|
|
8600
|
-
strokeLinecap: "round",
|
|
8601
|
-
strokeLinejoin: "round"
|
|
8602
|
-
}
|
|
8603
|
-
) }),
|
|
8604
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8605
|
-
"path",
|
|
8606
|
-
{
|
|
8607
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
8608
|
-
stroke: "#A1A1AA",
|
|
8609
|
-
strokeWidth: "1.5",
|
|
8610
|
-
strokeLinecap: "round",
|
|
8611
|
-
strokeLinejoin: "round"
|
|
8612
|
-
}
|
|
8613
|
-
) }),
|
|
8614
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8615
|
-
"path",
|
|
8616
|
-
{
|
|
8617
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
8618
|
-
stroke: "#A1A1AA",
|
|
8619
|
-
strokeWidth: "1.5",
|
|
8620
|
-
strokeLinecap: "round",
|
|
8621
|
-
strokeLinejoin: "round"
|
|
8622
|
-
}
|
|
8623
|
-
) }),
|
|
8624
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
8625
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8626
|
-
"rect",
|
|
8627
|
-
{
|
|
8628
|
-
width: "12",
|
|
8629
|
-
height: "12",
|
|
8630
|
-
fill: "white",
|
|
8631
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
8632
|
-
}
|
|
8633
|
-
) }),
|
|
8634
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8635
|
-
"rect",
|
|
8636
|
-
{
|
|
8637
|
-
width: "12",
|
|
8638
|
-
height: "12",
|
|
8639
|
-
fill: "white",
|
|
8640
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
8641
|
-
}
|
|
8642
|
-
) }),
|
|
8643
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8644
|
-
"rect",
|
|
8645
|
-
{
|
|
8646
|
-
width: "12",
|
|
8647
|
-
height: "12",
|
|
8648
|
-
fill: "white",
|
|
8649
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
8650
|
-
}
|
|
8651
|
-
) }),
|
|
8652
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8653
|
-
"rect",
|
|
8654
|
-
{
|
|
8655
|
-
width: "12",
|
|
8656
|
-
height: "12",
|
|
8657
|
-
fill: "white",
|
|
8658
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
8659
|
-
}
|
|
8660
|
-
) }),
|
|
8661
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8662
|
-
"rect",
|
|
8663
|
-
{
|
|
8664
|
-
width: "12",
|
|
8665
|
-
height: "12",
|
|
8666
|
-
fill: "white",
|
|
8667
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
8668
|
-
}
|
|
8669
|
-
) }),
|
|
8670
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8671
|
-
"rect",
|
|
8672
|
-
{
|
|
8673
|
-
width: "12",
|
|
8674
|
-
height: "12",
|
|
8675
|
-
fill: "white",
|
|
8676
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
8677
|
-
}
|
|
8678
|
-
) })
|
|
8679
|
-
] })
|
|
8680
|
-
]
|
|
8681
|
-
}
|
|
8682
|
-
);
|
|
8683
|
-
};
|
|
8684
|
-
const schema = zod.z.object({
|
|
8685
|
-
customer_id: zod.z.string().min(1)
|
|
8686
|
-
});
|
|
8687
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
8688
|
-
const Shipping = () => {
|
|
8689
|
-
const { id } = reactRouterDom.useParams();
|
|
8690
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
8691
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
8692
|
-
});
|
|
8693
|
-
const {
|
|
8694
|
-
order: preview,
|
|
8695
|
-
isPending: isPreviewPending,
|
|
8696
|
-
isError: isPreviewError,
|
|
8697
|
-
error: previewError
|
|
8698
|
-
} = useOrderPreview(id);
|
|
8699
|
-
useInitiateOrderEdit({ preview });
|
|
8700
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
8701
|
-
if (isError) {
|
|
8702
|
-
throw error;
|
|
8703
|
-
}
|
|
8704
|
-
if (isPreviewError) {
|
|
8705
|
-
throw previewError;
|
|
8706
|
-
}
|
|
8707
|
-
const orderHasItems = (order?.items?.length || 0) > 0;
|
|
8708
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
8709
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
8710
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
8711
|
-
/* @__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: [
|
|
8712
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
8713
|
-
/* @__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." }) })
|
|
8714
|
-
] }) }) }),
|
|
8715
|
-
/* @__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" }) }) })
|
|
8716
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8717
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
8718
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
8719
|
-
] }) });
|
|
8720
|
-
};
|
|
8721
|
-
const ShippingForm = ({ preview, order }) => {
|
|
8722
|
-
const { setIsOpen } = useStackedModal();
|
|
8723
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
8724
|
-
const [data, setData] = React.useState(null);
|
|
8725
|
-
const appliedShippingOptionIds = preview.shipping_methods?.map((method) => method.shipping_option_id).filter(Boolean);
|
|
8726
|
-
const { shipping_options } = useShippingOptions(
|
|
8727
|
-
{
|
|
8728
|
-
id: appliedShippingOptionIds,
|
|
8729
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
8730
|
-
},
|
|
8731
|
-
{
|
|
8732
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
8733
|
-
}
|
|
8734
|
-
);
|
|
8735
|
-
const uniqueShippingProfiles = React.useMemo(() => {
|
|
8736
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
8737
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
8738
|
-
profiles.set(profile.id, profile);
|
|
8739
|
-
});
|
|
8740
|
-
shipping_options?.forEach((option) => {
|
|
8741
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
8742
|
-
});
|
|
8743
|
-
return Array.from(profiles.values());
|
|
8744
|
-
}, [order.items, shipping_options]);
|
|
8745
|
-
const { handleSuccess } = useRouteModal();
|
|
8746
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
8747
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
8748
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
8749
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
8750
|
-
const onSubmit = async () => {
|
|
8751
|
-
setIsSubmitting(true);
|
|
8752
|
-
let requestSucceeded = false;
|
|
8753
|
-
await requestOrderEdit(void 0, {
|
|
8754
|
-
onError: (e) => {
|
|
8755
|
-
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
8756
|
-
},
|
|
8757
|
-
onSuccess: () => {
|
|
8758
|
-
requestSucceeded = true;
|
|
8759
|
-
}
|
|
8760
|
-
});
|
|
8761
|
-
if (!requestSucceeded) {
|
|
8762
|
-
setIsSubmitting(false);
|
|
8763
|
-
return;
|
|
8764
|
-
}
|
|
8765
|
-
await confirmOrderEdit(void 0, {
|
|
8766
|
-
onError: (e) => {
|
|
8767
|
-
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
8768
|
-
},
|
|
8769
|
-
onSuccess: () => {
|
|
8770
|
-
handleSuccess();
|
|
8771
|
-
},
|
|
8772
|
-
onSettled: () => {
|
|
8773
|
-
setIsSubmitting(false);
|
|
8774
|
-
}
|
|
8775
|
-
});
|
|
8776
|
-
};
|
|
8777
|
-
const onKeydown = React.useCallback(
|
|
8778
|
-
(e) => {
|
|
8779
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
8780
|
-
if (data || isSubmitting) {
|
|
8781
|
-
return;
|
|
8782
|
-
}
|
|
8783
|
-
onSubmit();
|
|
8784
|
-
}
|
|
8785
|
-
},
|
|
8786
|
-
[data, isSubmitting, onSubmit]
|
|
8787
|
-
);
|
|
8788
|
-
React.useEffect(() => {
|
|
8789
|
-
document.addEventListener("keydown", onKeydown);
|
|
8790
|
-
return () => {
|
|
8791
|
-
document.removeEventListener("keydown", onKeydown);
|
|
8792
|
-
};
|
|
8793
|
-
}, [onKeydown]);
|
|
8794
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
8795
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
8796
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
8797
|
-
/* @__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: [
|
|
8798
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8799
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
8800
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
8801
|
-
] }),
|
|
8802
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
8803
|
-
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
8804
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
8805
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8806
|
-
ui.Text,
|
|
8807
|
-
{
|
|
8808
|
-
size: "xsmall",
|
|
8809
|
-
weight: "plus",
|
|
8810
|
-
className: "text-ui-fg-muted",
|
|
8811
|
-
children: "Shipping profile"
|
|
8812
|
-
}
|
|
8813
|
-
),
|
|
8814
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8815
|
-
ui.Text,
|
|
8816
|
-
{
|
|
8817
|
-
size: "xsmall",
|
|
8818
|
-
weight: "plus",
|
|
8819
|
-
className: "text-ui-fg-muted",
|
|
8820
|
-
children: "Action"
|
|
8140
|
+
size: "xsmall",
|
|
8141
|
+
weight: "plus",
|
|
8142
|
+
className: "text-ui-fg-muted",
|
|
8143
|
+
children: "Action"
|
|
8821
8144
|
}
|
|
8822
8145
|
)
|
|
8823
8146
|
] }),
|
|
@@ -9069,415 +8392,1092 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
9069
8392
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9070
8393
|
StackedFocusModal,
|
|
9071
8394
|
{
|
|
9072
|
-
id: STACKED_FOCUS_MODAL_ID,
|
|
9073
|
-
onOpenChangeCallback: (open) => {
|
|
9074
|
-
if (!open) {
|
|
9075
|
-
setData(null);
|
|
9076
|
-
}
|
|
9077
|
-
return open;
|
|
8395
|
+
id: STACKED_FOCUS_MODAL_ID,
|
|
8396
|
+
onOpenChangeCallback: (open) => {
|
|
8397
|
+
if (!open) {
|
|
8398
|
+
setData(null);
|
|
8399
|
+
}
|
|
8400
|
+
return open;
|
|
8401
|
+
},
|
|
8402
|
+
children: data && /* @__PURE__ */ jsxRuntime.jsx(ShippingProfileForm, { data, order, preview })
|
|
8403
|
+
}
|
|
8404
|
+
)
|
|
8405
|
+
] }),
|
|
8406
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
8407
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
8408
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8409
|
+
ui.Button,
|
|
8410
|
+
{
|
|
8411
|
+
size: "small",
|
|
8412
|
+
type: "button",
|
|
8413
|
+
isLoading: isSubmitting,
|
|
8414
|
+
onClick: onSubmit,
|
|
8415
|
+
children: "Save"
|
|
8416
|
+
}
|
|
8417
|
+
)
|
|
8418
|
+
] }) })
|
|
8419
|
+
] });
|
|
8420
|
+
};
|
|
8421
|
+
const StackedModalTrigger = ({
|
|
8422
|
+
shippingProfileId,
|
|
8423
|
+
shippingOption,
|
|
8424
|
+
shippingMethod,
|
|
8425
|
+
setData,
|
|
8426
|
+
children
|
|
8427
|
+
}) => {
|
|
8428
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
8429
|
+
const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
|
|
8430
|
+
const onToggle = () => {
|
|
8431
|
+
if (isOpen) {
|
|
8432
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
8433
|
+
setData(null);
|
|
8434
|
+
} else {
|
|
8435
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
8436
|
+
setData({
|
|
8437
|
+
shippingProfileId,
|
|
8438
|
+
shippingOption,
|
|
8439
|
+
shippingMethod
|
|
8440
|
+
});
|
|
8441
|
+
}
|
|
8442
|
+
};
|
|
8443
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8444
|
+
ui.Button,
|
|
8445
|
+
{
|
|
8446
|
+
size: "small",
|
|
8447
|
+
variant: "secondary",
|
|
8448
|
+
onClick: onToggle,
|
|
8449
|
+
className: "text-ui-fg-primary shrink-0",
|
|
8450
|
+
children
|
|
8451
|
+
}
|
|
8452
|
+
);
|
|
8453
|
+
};
|
|
8454
|
+
const ShippingProfileForm = ({
|
|
8455
|
+
data,
|
|
8456
|
+
order,
|
|
8457
|
+
preview
|
|
8458
|
+
}) => {
|
|
8459
|
+
const { setIsOpen } = useStackedModal();
|
|
8460
|
+
const form = reactHookForm.useForm({
|
|
8461
|
+
resolver: zod$1.zodResolver(shippingMethodSchema),
|
|
8462
|
+
defaultValues: {
|
|
8463
|
+
location_id: data.shippingOption?.service_zone?.fulfillment_set?.location?.id,
|
|
8464
|
+
shipping_option_id: data.shippingOption?.id,
|
|
8465
|
+
custom_amount: data.shippingMethod?.amount
|
|
8466
|
+
}
|
|
8467
|
+
});
|
|
8468
|
+
const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
|
|
8469
|
+
const {
|
|
8470
|
+
mutateAsync: updateShippingMethod,
|
|
8471
|
+
isPending: isUpdatingShippingMethod
|
|
8472
|
+
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
8473
|
+
const onSubmit = form.handleSubmit(async (values) => {
|
|
8474
|
+
if (isEqual__default.default(values, form.formState.defaultValues)) {
|
|
8475
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
8476
|
+
return;
|
|
8477
|
+
}
|
|
8478
|
+
if (data.shippingMethod) {
|
|
8479
|
+
await updateShippingMethod(
|
|
8480
|
+
{
|
|
8481
|
+
method_id: data.shippingMethod.id,
|
|
8482
|
+
shipping_option_id: values.shipping_option_id,
|
|
8483
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
8484
|
+
},
|
|
8485
|
+
{
|
|
8486
|
+
onError: (e) => {
|
|
8487
|
+
ui.toast.error(e.message);
|
|
9078
8488
|
},
|
|
9079
|
-
|
|
8489
|
+
onSuccess: () => {
|
|
8490
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
8491
|
+
}
|
|
9080
8492
|
}
|
|
9081
|
-
)
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
8493
|
+
);
|
|
8494
|
+
return;
|
|
8495
|
+
}
|
|
8496
|
+
await addShippingMethod(
|
|
8497
|
+
{
|
|
8498
|
+
shipping_option_id: values.shipping_option_id,
|
|
8499
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
8500
|
+
},
|
|
8501
|
+
{
|
|
8502
|
+
onError: (e) => {
|
|
8503
|
+
ui.toast.error(e.message);
|
|
8504
|
+
},
|
|
8505
|
+
onSuccess: () => {
|
|
8506
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
9093
8507
|
}
|
|
9094
|
-
|
|
9095
|
-
|
|
8508
|
+
}
|
|
8509
|
+
);
|
|
8510
|
+
});
|
|
8511
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8512
|
+
KeyboundForm,
|
|
8513
|
+
{
|
|
8514
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
8515
|
+
onSubmit,
|
|
8516
|
+
children: [
|
|
8517
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
8518
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
8519
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8520
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
8521
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
8522
|
+
] }),
|
|
8523
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
8524
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8525
|
+
LocationField,
|
|
8526
|
+
{
|
|
8527
|
+
control: form.control,
|
|
8528
|
+
setValue: form.setValue
|
|
8529
|
+
}
|
|
8530
|
+
),
|
|
8531
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
8532
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8533
|
+
ShippingOptionField,
|
|
8534
|
+
{
|
|
8535
|
+
shippingProfileId: data.shippingProfileId,
|
|
8536
|
+
preview,
|
|
8537
|
+
control: form.control
|
|
8538
|
+
}
|
|
8539
|
+
),
|
|
8540
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
8541
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8542
|
+
CustomAmountField,
|
|
8543
|
+
{
|
|
8544
|
+
control: form.control,
|
|
8545
|
+
currencyCode: order.currency_code
|
|
8546
|
+
}
|
|
8547
|
+
),
|
|
8548
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
8549
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8550
|
+
ItemsPreview,
|
|
8551
|
+
{
|
|
8552
|
+
order,
|
|
8553
|
+
shippingProfileId: data.shippingProfileId
|
|
8554
|
+
}
|
|
8555
|
+
)
|
|
8556
|
+
] }) }) }),
|
|
8557
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
8558
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
8559
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8560
|
+
ui.Button,
|
|
8561
|
+
{
|
|
8562
|
+
size: "small",
|
|
8563
|
+
type: "submit",
|
|
8564
|
+
isLoading: isPending || isUpdatingShippingMethod,
|
|
8565
|
+
children: data.shippingMethod ? "Update" : "Add"
|
|
8566
|
+
}
|
|
8567
|
+
)
|
|
8568
|
+
] }) })
|
|
8569
|
+
]
|
|
8570
|
+
}
|
|
8571
|
+
) }) });
|
|
8572
|
+
};
|
|
8573
|
+
const shippingMethodSchema = zod.z.object({
|
|
8574
|
+
location_id: zod.z.string(),
|
|
8575
|
+
shipping_option_id: zod.z.string(),
|
|
8576
|
+
custom_amount: zod.z.union([zod.z.number(), zod.z.string()]).optional()
|
|
8577
|
+
});
|
|
8578
|
+
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
8579
|
+
const matches = order.items.filter(
|
|
8580
|
+
(item) => item.variant?.product?.shipping_profile?.id === shippingProfileId
|
|
8581
|
+
);
|
|
8582
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
8583
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8584
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
8585
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
8586
|
+
] }) }),
|
|
8587
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
8588
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-muted grid grid-cols-2 gap-3 px-4 py-2", children: [
|
|
8589
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
8590
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
8591
|
+
] }),
|
|
8592
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches?.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8593
|
+
"div",
|
|
8594
|
+
{
|
|
8595
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
8596
|
+
children: [
|
|
8597
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
8598
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8599
|
+
Thumbnail,
|
|
8600
|
+
{
|
|
8601
|
+
thumbnail: item.thumbnail,
|
|
8602
|
+
alt: item.product_title ?? void 0
|
|
8603
|
+
}
|
|
8604
|
+
),
|
|
8605
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8606
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
8607
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
8608
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8609
|
+
ui.Text,
|
|
8610
|
+
{
|
|
8611
|
+
size: "small",
|
|
8612
|
+
leading: "compact",
|
|
8613
|
+
className: "text-ui-fg-subtle",
|
|
8614
|
+
children: [
|
|
8615
|
+
"(",
|
|
8616
|
+
item.variant_title,
|
|
8617
|
+
")"
|
|
8618
|
+
]
|
|
8619
|
+
}
|
|
8620
|
+
)
|
|
8621
|
+
] }),
|
|
8622
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8623
|
+
ui.Text,
|
|
8624
|
+
{
|
|
8625
|
+
size: "small",
|
|
8626
|
+
leading: "compact",
|
|
8627
|
+
className: "text-ui-fg-subtle",
|
|
8628
|
+
children: item.variant_sku
|
|
8629
|
+
}
|
|
8630
|
+
)
|
|
8631
|
+
] })
|
|
8632
|
+
] }),
|
|
8633
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8634
|
+
ui.Text,
|
|
8635
|
+
{
|
|
8636
|
+
size: "small",
|
|
8637
|
+
leading: "compact",
|
|
8638
|
+
className: "text-ui-fg-subtle",
|
|
8639
|
+
children: [
|
|
8640
|
+
item.quantity,
|
|
8641
|
+
"x"
|
|
8642
|
+
]
|
|
8643
|
+
}
|
|
8644
|
+
)
|
|
8645
|
+
]
|
|
8646
|
+
},
|
|
8647
|
+
item.id
|
|
8648
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
8649
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
8650
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
8651
|
+
'No items found for "',
|
|
8652
|
+
query,
|
|
8653
|
+
'".'
|
|
8654
|
+
] })
|
|
8655
|
+
] }) })
|
|
8656
|
+
] })
|
|
9096
8657
|
] });
|
|
9097
8658
|
};
|
|
9098
|
-
const
|
|
8659
|
+
const LocationField = ({ control, setValue }) => {
|
|
8660
|
+
const locations = useComboboxData({
|
|
8661
|
+
queryKey: ["locations"],
|
|
8662
|
+
queryFn: async (params) => {
|
|
8663
|
+
return await sdk.admin.stockLocation.list(params);
|
|
8664
|
+
},
|
|
8665
|
+
getOptions: (data) => {
|
|
8666
|
+
return data.stock_locations.map((location) => ({
|
|
8667
|
+
label: location.name,
|
|
8668
|
+
value: location.id
|
|
8669
|
+
}));
|
|
8670
|
+
}
|
|
8671
|
+
});
|
|
8672
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8673
|
+
Form$2.Field,
|
|
8674
|
+
{
|
|
8675
|
+
control,
|
|
8676
|
+
name: "location_id",
|
|
8677
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
8678
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
8679
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8680
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
8681
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
8682
|
+
] }),
|
|
8683
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8684
|
+
Combobox,
|
|
8685
|
+
{
|
|
8686
|
+
options: locations.options,
|
|
8687
|
+
fetchNextPage: locations.fetchNextPage,
|
|
8688
|
+
isFetchingNextPage: locations.isFetchingNextPage,
|
|
8689
|
+
searchValue: locations.searchValue,
|
|
8690
|
+
onSearchValueChange: locations.onSearchValueChange,
|
|
8691
|
+
placeholder: "Select location",
|
|
8692
|
+
onChange: (value) => {
|
|
8693
|
+
setValue("shipping_option_id", "", {
|
|
8694
|
+
shouldDirty: true,
|
|
8695
|
+
shouldTouch: true
|
|
8696
|
+
});
|
|
8697
|
+
onChange(value);
|
|
8698
|
+
},
|
|
8699
|
+
...field
|
|
8700
|
+
}
|
|
8701
|
+
) })
|
|
8702
|
+
] }) });
|
|
8703
|
+
}
|
|
8704
|
+
}
|
|
8705
|
+
);
|
|
8706
|
+
};
|
|
8707
|
+
const ShippingOptionField = ({
|
|
9099
8708
|
shippingProfileId,
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
setData,
|
|
9103
|
-
children
|
|
8709
|
+
preview,
|
|
8710
|
+
control
|
|
9104
8711
|
}) => {
|
|
9105
|
-
const {
|
|
9106
|
-
const
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
setData({
|
|
9114
|
-
shippingProfileId,
|
|
9115
|
-
shippingOption,
|
|
9116
|
-
shippingMethod
|
|
8712
|
+
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
8713
|
+
const shippingOptions = useComboboxData({
|
|
8714
|
+
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
8715
|
+
queryFn: async (params) => {
|
|
8716
|
+
return await sdk.admin.shippingOption.list({
|
|
8717
|
+
...params,
|
|
8718
|
+
stock_location_id: locationId,
|
|
8719
|
+
shipping_profile_id: shippingProfileId
|
|
9117
8720
|
});
|
|
9118
|
-
}
|
|
9119
|
-
|
|
8721
|
+
},
|
|
8722
|
+
getOptions: (data) => {
|
|
8723
|
+
return data.shipping_options.map((option) => {
|
|
8724
|
+
if (option.rules?.find(
|
|
8725
|
+
(r) => r.attribute === "is_return" && r.value === "true"
|
|
8726
|
+
)) {
|
|
8727
|
+
return void 0;
|
|
8728
|
+
}
|
|
8729
|
+
return {
|
|
8730
|
+
label: option.name,
|
|
8731
|
+
value: option.id
|
|
8732
|
+
};
|
|
8733
|
+
}).filter(Boolean);
|
|
8734
|
+
},
|
|
8735
|
+
enabled: !!locationId && !!shippingProfileId,
|
|
8736
|
+
defaultValue: preview.shipping_methods[0]?.shipping_option_id || void 0
|
|
8737
|
+
});
|
|
8738
|
+
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
9120
8739
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9121
|
-
|
|
8740
|
+
Form$2.Field,
|
|
9122
8741
|
{
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
8742
|
+
control,
|
|
8743
|
+
name: "shipping_option_id",
|
|
8744
|
+
render: ({ field }) => {
|
|
8745
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
8746
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8747
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
8748
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
8749
|
+
] }),
|
|
8750
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8751
|
+
ConditionalTooltip,
|
|
8752
|
+
{
|
|
8753
|
+
content: tooltipContent,
|
|
8754
|
+
showTooltip: !locationId || !shippingProfileId,
|
|
8755
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8756
|
+
Combobox,
|
|
8757
|
+
{
|
|
8758
|
+
options: shippingOptions.options,
|
|
8759
|
+
fetchNextPage: shippingOptions.fetchNextPage,
|
|
8760
|
+
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
8761
|
+
searchValue: shippingOptions.searchValue,
|
|
8762
|
+
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
8763
|
+
placeholder: "Select shipping option",
|
|
8764
|
+
...field,
|
|
8765
|
+
disabled: !locationId || !shippingProfileId
|
|
8766
|
+
}
|
|
8767
|
+
) }) })
|
|
8768
|
+
}
|
|
8769
|
+
)
|
|
8770
|
+
] }) });
|
|
8771
|
+
}
|
|
9128
8772
|
}
|
|
9129
8773
|
);
|
|
9130
8774
|
};
|
|
9131
|
-
const
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
preview
|
|
8775
|
+
const CustomAmountField = ({
|
|
8776
|
+
control,
|
|
8777
|
+
currencyCode
|
|
9135
8778
|
}) => {
|
|
9136
|
-
|
|
8779
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8780
|
+
Form$2.Field,
|
|
8781
|
+
{
|
|
8782
|
+
control,
|
|
8783
|
+
name: "custom_amount",
|
|
8784
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
8785
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
8786
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
8787
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
8788
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
8789
|
+
] }),
|
|
8790
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8791
|
+
ui.CurrencyInput,
|
|
8792
|
+
{
|
|
8793
|
+
...field,
|
|
8794
|
+
onValueChange: (value) => onChange(value),
|
|
8795
|
+
symbol: getNativeSymbol(currencyCode),
|
|
8796
|
+
code: currencyCode
|
|
8797
|
+
}
|
|
8798
|
+
) })
|
|
8799
|
+
] });
|
|
8800
|
+
}
|
|
8801
|
+
}
|
|
8802
|
+
);
|
|
8803
|
+
};
|
|
8804
|
+
const ShippingAddress = () => {
|
|
8805
|
+
const { id } = reactRouterDom.useParams();
|
|
8806
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
8807
|
+
fields: "+shipping_address"
|
|
8808
|
+
});
|
|
8809
|
+
if (isError) {
|
|
8810
|
+
throw error;
|
|
8811
|
+
}
|
|
8812
|
+
const isReady = !isPending && !!order;
|
|
8813
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
8814
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
8815
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
8816
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
8817
|
+
] }),
|
|
8818
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
8819
|
+
] });
|
|
8820
|
+
};
|
|
8821
|
+
const ShippingAddressForm = ({ order }) => {
|
|
9137
8822
|
const form = reactHookForm.useForm({
|
|
9138
|
-
resolver: zod$1.zodResolver(shippingMethodSchema),
|
|
9139
8823
|
defaultValues: {
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
8824
|
+
first_name: order.shipping_address?.first_name ?? "",
|
|
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 ?? ""
|
|
8834
|
+
},
|
|
8835
|
+
resolver: zod$1.zodResolver(schema$1)
|
|
9144
8836
|
});
|
|
9145
|
-
const { mutateAsync
|
|
9146
|
-
const {
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
9150
|
-
const onSubmit = form.handleSubmit(async (values) => {
|
|
9151
|
-
if (isEqual__default.default(values, form.formState.defaultValues)) {
|
|
9152
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
9153
|
-
return;
|
|
9154
|
-
}
|
|
9155
|
-
if (data.shippingMethod) {
|
|
9156
|
-
await updateShippingMethod(
|
|
9157
|
-
{
|
|
9158
|
-
method_id: data.shippingMethod.id,
|
|
9159
|
-
shipping_option_id: values.shipping_option_id,
|
|
9160
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
9161
|
-
},
|
|
9162
|
-
{
|
|
9163
|
-
onError: (e) => {
|
|
9164
|
-
ui.toast.error(e.message);
|
|
9165
|
-
},
|
|
9166
|
-
onSuccess: () => {
|
|
9167
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
9168
|
-
}
|
|
9169
|
-
}
|
|
9170
|
-
);
|
|
9171
|
-
return;
|
|
9172
|
-
}
|
|
9173
|
-
await addShippingMethod(
|
|
8837
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8838
|
+
const { handleSuccess } = useRouteModal();
|
|
8839
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
8840
|
+
await mutateAsync(
|
|
9174
8841
|
{
|
|
9175
|
-
|
|
9176
|
-
|
|
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
|
+
}
|
|
9177
8854
|
},
|
|
9178
8855
|
{
|
|
9179
|
-
onError: (e) => {
|
|
9180
|
-
ui.toast.error(e.message);
|
|
9181
|
-
},
|
|
9182
8856
|
onSuccess: () => {
|
|
9183
|
-
|
|
8857
|
+
handleSuccess();
|
|
8858
|
+
},
|
|
8859
|
+
onError: (error) => {
|
|
8860
|
+
ui.toast.error(error.message);
|
|
9184
8861
|
}
|
|
9185
8862
|
}
|
|
9186
8863
|
);
|
|
9187
8864
|
});
|
|
9188
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8865
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9189
8866
|
KeyboundForm,
|
|
9190
8867
|
{
|
|
9191
|
-
className: "flex
|
|
8868
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9192
8869
|
onSubmit,
|
|
9193
8870
|
children: [
|
|
9194
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
8871
|
+
/* @__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: [
|
|
8872
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8873
|
+
Form$2.Field,
|
|
8874
|
+
{
|
|
8875
|
+
control: form.control,
|
|
8876
|
+
name: "country_code",
|
|
8877
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
8878
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
8879
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
8880
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
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
|
+
)
|
|
9199
8909
|
] }),
|
|
9200
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
9201
8910
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9202
|
-
|
|
8911
|
+
Form$2.Field,
|
|
9203
8912
|
{
|
|
9204
8913
|
control: form.control,
|
|
9205
|
-
|
|
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
|
+
] })
|
|
9206
8920
|
}
|
|
9207
8921
|
),
|
|
9208
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
9209
8922
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9210
|
-
|
|
8923
|
+
Form$2.Field,
|
|
9211
8924
|
{
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
8925
|
+
control: form.control,
|
|
8926
|
+
name: "address_1",
|
|
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
|
+
] })
|
|
9215
8932
|
}
|
|
9216
8933
|
),
|
|
9217
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
9218
8934
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9219
|
-
|
|
8935
|
+
Form$2.Field,
|
|
9220
8936
|
{
|
|
9221
8937
|
control: form.control,
|
|
9222
|
-
|
|
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
|
+
] })
|
|
9223
8944
|
}
|
|
9224
8945
|
),
|
|
9225
|
-
/* @__PURE__ */ jsxRuntime.
|
|
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
|
+
] }),
|
|
9226
8972
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9227
|
-
|
|
8973
|
+
Form$2.Field,
|
|
9228
8974
|
{
|
|
9229
|
-
|
|
9230
|
-
|
|
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
|
+
] })
|
|
9231
8982
|
}
|
|
9232
|
-
)
|
|
9233
|
-
] }) }) }),
|
|
9234
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
9235
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
8983
|
+
),
|
|
9236
8984
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9237
|
-
|
|
8985
|
+
Form$2.Field,
|
|
9238
8986
|
{
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
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
|
+
] })
|
|
9243
8994
|
}
|
|
9244
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" })
|
|
9245
9000
|
] }) })
|
|
9246
9001
|
]
|
|
9247
9002
|
}
|
|
9248
|
-
) })
|
|
9003
|
+
) });
|
|
9249
9004
|
};
|
|
9250
|
-
const
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
9267
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
9268
|
-
] }),
|
|
9269
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches?.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9270
|
-
"div",
|
|
9271
|
-
{
|
|
9272
|
-
className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-2 items-center gap-3 rounded-lg px-4 py-2",
|
|
9273
|
-
children: [
|
|
9274
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
9275
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9276
|
-
Thumbnail,
|
|
9277
|
-
{
|
|
9278
|
-
thumbnail: item.thumbnail,
|
|
9279
|
-
alt: item.product_title ?? void 0
|
|
9280
|
-
}
|
|
9281
|
-
),
|
|
9282
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
9283
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
9284
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
9285
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9286
|
-
ui.Text,
|
|
9287
|
-
{
|
|
9288
|
-
size: "small",
|
|
9289
|
-
leading: "compact",
|
|
9290
|
-
className: "text-ui-fg-subtle",
|
|
9291
|
-
children: [
|
|
9292
|
-
"(",
|
|
9293
|
-
item.variant_title,
|
|
9294
|
-
")"
|
|
9295
|
-
]
|
|
9296
|
-
}
|
|
9297
|
-
)
|
|
9298
|
-
] }),
|
|
9299
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9300
|
-
ui.Text,
|
|
9301
|
-
{
|
|
9302
|
-
size: "small",
|
|
9303
|
-
leading: "compact",
|
|
9304
|
-
className: "text-ui-fg-subtle",
|
|
9305
|
-
children: item.variant_sku
|
|
9306
|
-
}
|
|
9307
|
-
)
|
|
9308
|
-
] })
|
|
9309
|
-
] }),
|
|
9310
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9311
|
-
ui.Text,
|
|
9312
|
-
{
|
|
9313
|
-
size: "small",
|
|
9314
|
-
leading: "compact",
|
|
9315
|
-
className: "text-ui-fg-subtle",
|
|
9316
|
-
children: [
|
|
9317
|
-
item.quantity,
|
|
9318
|
-
"x"
|
|
9319
|
-
]
|
|
9320
|
-
}
|
|
9321
|
-
)
|
|
9322
|
-
]
|
|
9323
|
-
},
|
|
9324
|
-
item.id
|
|
9325
|
-
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest flex flex-col items-center justify-center gap-1 gap-x-3 rounded-lg p-4", children: [
|
|
9326
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
9327
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
9328
|
-
'No items found for "',
|
|
9329
|
-
query,
|
|
9330
|
-
'".'
|
|
9331
|
-
] })
|
|
9332
|
-
] }) })
|
|
9333
|
-
] })
|
|
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 })
|
|
9334
9021
|
] });
|
|
9335
9022
|
};
|
|
9336
|
-
const
|
|
9337
|
-
const
|
|
9338
|
-
|
|
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
|
|
9074
|
+
}
|
|
9075
|
+
)
|
|
9076
|
+
] }),
|
|
9077
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
9078
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
9079
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9080
|
+
] }) })
|
|
9081
|
+
]
|
|
9082
|
+
}
|
|
9083
|
+
) });
|
|
9084
|
+
};
|
|
9085
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
9086
|
+
const customers = useComboboxData({
|
|
9339
9087
|
queryFn: async (params) => {
|
|
9340
|
-
return await sdk.admin.
|
|
9088
|
+
return await sdk.admin.customer.list({
|
|
9089
|
+
...params,
|
|
9090
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
9091
|
+
});
|
|
9341
9092
|
},
|
|
9093
|
+
queryKey: ["customers"],
|
|
9342
9094
|
getOptions: (data) => {
|
|
9343
|
-
return data.
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9095
|
+
return data.customers.map((customer) => {
|
|
9096
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
9097
|
+
return {
|
|
9098
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
9099
|
+
value: customer.id
|
|
9100
|
+
};
|
|
9101
|
+
});
|
|
9347
9102
|
}
|
|
9348
9103
|
});
|
|
9349
9104
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9350
9105
|
Form$2.Field,
|
|
9351
9106
|
{
|
|
9107
|
+
name: "customer_id",
|
|
9352
9108
|
control,
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9109
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
9110
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
9111
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "New customer" }),
|
|
9112
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
9113
|
+
] }),
|
|
9114
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9115
|
+
Combobox,
|
|
9116
|
+
{
|
|
9117
|
+
options: customers.options,
|
|
9118
|
+
fetchNextPage: customers.fetchNextPage,
|
|
9119
|
+
isFetchingNextPage: customers.isFetchingNextPage,
|
|
9120
|
+
searchValue: customers.searchValue,
|
|
9121
|
+
onSearchValueChange: customers.onSearchValueChange,
|
|
9122
|
+
placeholder: "Select customer",
|
|
9123
|
+
...field
|
|
9124
|
+
}
|
|
9125
|
+
) }),
|
|
9126
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9127
|
+
] })
|
|
9128
|
+
}
|
|
9129
|
+
);
|
|
9130
|
+
};
|
|
9131
|
+
const Illustration = () => {
|
|
9132
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9133
|
+
"svg",
|
|
9134
|
+
{
|
|
9135
|
+
width: "280",
|
|
9136
|
+
height: "180",
|
|
9137
|
+
viewBox: "0 0 280 180",
|
|
9138
|
+
fill: "none",
|
|
9139
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9140
|
+
children: [
|
|
9141
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9142
|
+
"rect",
|
|
9143
|
+
{
|
|
9144
|
+
x: "0.00428286",
|
|
9145
|
+
y: "-0.742904",
|
|
9146
|
+
width: "33.5",
|
|
9147
|
+
height: "65.5",
|
|
9148
|
+
rx: "6.75",
|
|
9149
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
9150
|
+
fill: "#D4D4D8",
|
|
9151
|
+
stroke: "#52525B",
|
|
9152
|
+
strokeWidth: "1.5"
|
|
9153
|
+
}
|
|
9154
|
+
),
|
|
9155
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9156
|
+
"rect",
|
|
9157
|
+
{
|
|
9158
|
+
x: "0.00428286",
|
|
9159
|
+
y: "-0.742904",
|
|
9160
|
+
width: "33.5",
|
|
9161
|
+
height: "65.5",
|
|
9162
|
+
rx: "6.75",
|
|
9163
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
9164
|
+
fill: "white",
|
|
9165
|
+
stroke: "#52525B",
|
|
9166
|
+
strokeWidth: "1.5"
|
|
9167
|
+
}
|
|
9168
|
+
),
|
|
9169
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9170
|
+
"path",
|
|
9171
|
+
{
|
|
9172
|
+
d: "M180.579 107.142L179.126 107.959",
|
|
9173
|
+
stroke: "#52525B",
|
|
9174
|
+
strokeWidth: "1.5",
|
|
9175
|
+
strokeLinecap: "round",
|
|
9176
|
+
strokeLinejoin: "round"
|
|
9177
|
+
}
|
|
9178
|
+
),
|
|
9179
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9180
|
+
"path",
|
|
9181
|
+
{
|
|
9182
|
+
opacity: "0.88",
|
|
9183
|
+
d: "M182.305 109.546L180.257 109.534",
|
|
9184
|
+
stroke: "#52525B",
|
|
9185
|
+
strokeWidth: "1.5",
|
|
9186
|
+
strokeLinecap: "round",
|
|
9187
|
+
strokeLinejoin: "round"
|
|
9188
|
+
}
|
|
9189
|
+
),
|
|
9190
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9191
|
+
"path",
|
|
9192
|
+
{
|
|
9193
|
+
opacity: "0.75",
|
|
9194
|
+
d: "M180.551 111.93L179.108 111.096",
|
|
9195
|
+
stroke: "#52525B",
|
|
9196
|
+
strokeWidth: "1.5",
|
|
9197
|
+
strokeLinecap: "round",
|
|
9198
|
+
strokeLinejoin: "round"
|
|
9199
|
+
}
|
|
9200
|
+
),
|
|
9201
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9202
|
+
"path",
|
|
9203
|
+
{
|
|
9204
|
+
opacity: "0.63",
|
|
9205
|
+
d: "M176.347 112.897L176.354 111.73",
|
|
9206
|
+
stroke: "#52525B",
|
|
9207
|
+
strokeWidth: "1.5",
|
|
9208
|
+
strokeLinecap: "round",
|
|
9209
|
+
strokeLinejoin: "round"
|
|
9210
|
+
}
|
|
9211
|
+
),
|
|
9212
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9213
|
+
"path",
|
|
9214
|
+
{
|
|
9215
|
+
opacity: "0.5",
|
|
9216
|
+
d: "M172.153 111.881L173.606 111.064",
|
|
9217
|
+
stroke: "#52525B",
|
|
9218
|
+
strokeWidth: "1.5",
|
|
9219
|
+
strokeLinecap: "round",
|
|
9220
|
+
strokeLinejoin: "round"
|
|
9221
|
+
}
|
|
9222
|
+
),
|
|
9223
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9224
|
+
"path",
|
|
9225
|
+
{
|
|
9226
|
+
opacity: "0.38",
|
|
9227
|
+
d: "M170.428 109.478L172.476 109.489",
|
|
9228
|
+
stroke: "#52525B",
|
|
9229
|
+
strokeWidth: "1.5",
|
|
9230
|
+
strokeLinecap: "round",
|
|
9231
|
+
strokeLinejoin: "round"
|
|
9232
|
+
}
|
|
9233
|
+
),
|
|
9234
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9235
|
+
"path",
|
|
9236
|
+
{
|
|
9237
|
+
opacity: "0.25",
|
|
9238
|
+
d: "M172.181 107.094L173.624 107.928",
|
|
9239
|
+
stroke: "#52525B",
|
|
9240
|
+
strokeWidth: "1.5",
|
|
9241
|
+
strokeLinecap: "round",
|
|
9242
|
+
strokeLinejoin: "round"
|
|
9243
|
+
}
|
|
9244
|
+
),
|
|
9245
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9246
|
+
"path",
|
|
9247
|
+
{
|
|
9248
|
+
opacity: "0.13",
|
|
9249
|
+
d: "M176.386 106.126L176.379 107.294",
|
|
9250
|
+
stroke: "#52525B",
|
|
9251
|
+
strokeWidth: "1.5",
|
|
9252
|
+
strokeLinecap: "round",
|
|
9253
|
+
strokeLinejoin: "round"
|
|
9254
|
+
}
|
|
9255
|
+
),
|
|
9256
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9257
|
+
"rect",
|
|
9258
|
+
{
|
|
9259
|
+
width: "12",
|
|
9260
|
+
height: "3",
|
|
9261
|
+
rx: "1.5",
|
|
9262
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
9263
|
+
fill: "#D4D4D8"
|
|
9264
|
+
}
|
|
9265
|
+
),
|
|
9266
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9267
|
+
"rect",
|
|
9268
|
+
{
|
|
9269
|
+
x: "0.00428286",
|
|
9270
|
+
y: "-0.742904",
|
|
9271
|
+
width: "33.5",
|
|
9272
|
+
height: "65.5",
|
|
9273
|
+
rx: "6.75",
|
|
9274
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
9275
|
+
fill: "#D4D4D8",
|
|
9276
|
+
stroke: "#52525B",
|
|
9277
|
+
strokeWidth: "1.5"
|
|
9278
|
+
}
|
|
9279
|
+
),
|
|
9280
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9281
|
+
"rect",
|
|
9282
|
+
{
|
|
9283
|
+
x: "0.00428286",
|
|
9284
|
+
y: "-0.742904",
|
|
9285
|
+
width: "33.5",
|
|
9286
|
+
height: "65.5",
|
|
9287
|
+
rx: "6.75",
|
|
9288
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
9289
|
+
fill: "white",
|
|
9290
|
+
stroke: "#52525B",
|
|
9291
|
+
strokeWidth: "1.5"
|
|
9292
|
+
}
|
|
9293
|
+
),
|
|
9294
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9295
|
+
"rect",
|
|
9296
|
+
{
|
|
9297
|
+
width: "12",
|
|
9298
|
+
height: "3",
|
|
9299
|
+
rx: "1.5",
|
|
9300
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
9301
|
+
fill: "#D4D4D8"
|
|
9302
|
+
}
|
|
9303
|
+
),
|
|
9304
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9305
|
+
"rect",
|
|
9306
|
+
{
|
|
9307
|
+
width: "17",
|
|
9308
|
+
height: "3",
|
|
9309
|
+
rx: "1.5",
|
|
9310
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
9311
|
+
fill: "#D4D4D8"
|
|
9312
|
+
}
|
|
9313
|
+
),
|
|
9314
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9315
|
+
"rect",
|
|
9316
|
+
{
|
|
9317
|
+
width: "12",
|
|
9318
|
+
height: "3",
|
|
9319
|
+
rx: "1.5",
|
|
9320
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
9321
|
+
fill: "#D4D4D8"
|
|
9322
|
+
}
|
|
9323
|
+
),
|
|
9324
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9325
|
+
"path",
|
|
9326
|
+
{
|
|
9327
|
+
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
9328
|
+
fill: "#A1A1AA"
|
|
9329
|
+
}
|
|
9330
|
+
),
|
|
9331
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9332
|
+
"rect",
|
|
9333
|
+
{
|
|
9334
|
+
width: "17",
|
|
9335
|
+
height: "3",
|
|
9336
|
+
rx: "1.5",
|
|
9337
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
9338
|
+
fill: "#A1A1AA"
|
|
9339
|
+
}
|
|
9340
|
+
),
|
|
9341
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9342
|
+
"rect",
|
|
9343
|
+
{
|
|
9344
|
+
width: "12",
|
|
9345
|
+
height: "3",
|
|
9346
|
+
rx: "1.5",
|
|
9347
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
9348
|
+
fill: "#A1A1AA"
|
|
9349
|
+
}
|
|
9350
|
+
),
|
|
9351
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9352
|
+
"path",
|
|
9353
|
+
{
|
|
9354
|
+
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
9355
|
+
fill: "#52525B"
|
|
9356
|
+
}
|
|
9357
|
+
),
|
|
9358
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9359
|
+
"path",
|
|
9360
|
+
{
|
|
9361
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
9362
|
+
stroke: "#A1A1AA",
|
|
9363
|
+
strokeWidth: "1.5",
|
|
9364
|
+
strokeLinecap: "round",
|
|
9365
|
+
strokeLinejoin: "round"
|
|
9366
|
+
}
|
|
9367
|
+
) }),
|
|
9368
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9369
|
+
"path",
|
|
9370
|
+
{
|
|
9371
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
9372
|
+
stroke: "#A1A1AA",
|
|
9373
|
+
strokeWidth: "1.5",
|
|
9374
|
+
strokeLinecap: "round",
|
|
9375
|
+
strokeLinejoin: "round"
|
|
9376
|
+
}
|
|
9377
|
+
) }),
|
|
9378
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9379
|
+
"path",
|
|
9380
|
+
{
|
|
9381
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
9382
|
+
stroke: "#A1A1AA",
|
|
9383
|
+
strokeWidth: "1.5",
|
|
9384
|
+
strokeLinecap: "round",
|
|
9385
|
+
strokeLinejoin: "round"
|
|
9386
|
+
}
|
|
9387
|
+
) }),
|
|
9388
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9389
|
+
"path",
|
|
9390
|
+
{
|
|
9391
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
9392
|
+
stroke: "#A1A1AA",
|
|
9393
|
+
strokeWidth: "1.5",
|
|
9394
|
+
strokeLinecap: "round",
|
|
9395
|
+
strokeLinejoin: "round"
|
|
9396
|
+
}
|
|
9397
|
+
) }),
|
|
9398
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9399
|
+
"path",
|
|
9400
|
+
{
|
|
9401
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
9402
|
+
stroke: "#A1A1AA",
|
|
9403
|
+
strokeWidth: "1.5",
|
|
9404
|
+
strokeLinecap: "round",
|
|
9405
|
+
strokeLinejoin: "round"
|
|
9406
|
+
}
|
|
9407
|
+
) }),
|
|
9408
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9409
|
+
"path",
|
|
9410
|
+
{
|
|
9411
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
9412
|
+
stroke: "#A1A1AA",
|
|
9413
|
+
strokeWidth: "1.5",
|
|
9414
|
+
strokeLinecap: "round",
|
|
9415
|
+
strokeLinejoin: "round"
|
|
9416
|
+
}
|
|
9417
|
+
) }),
|
|
9418
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
9419
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9420
|
+
"rect",
|
|
9362
9421
|
{
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
onSearchValueChange: locations.onSearchValueChange,
|
|
9368
|
-
placeholder: "Select location",
|
|
9369
|
-
onChange: (value) => {
|
|
9370
|
-
setValue("shipping_option_id", "", {
|
|
9371
|
-
shouldDirty: true,
|
|
9372
|
-
shouldTouch: true
|
|
9373
|
-
});
|
|
9374
|
-
onChange(value);
|
|
9375
|
-
},
|
|
9376
|
-
...field
|
|
9422
|
+
width: "12",
|
|
9423
|
+
height: "12",
|
|
9424
|
+
fill: "white",
|
|
9425
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
9377
9426
|
}
|
|
9378
|
-
) })
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
}
|
|
9382
|
-
);
|
|
9383
|
-
};
|
|
9384
|
-
const ShippingOptionField = ({
|
|
9385
|
-
shippingProfileId,
|
|
9386
|
-
preview,
|
|
9387
|
-
control
|
|
9388
|
-
}) => {
|
|
9389
|
-
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
9390
|
-
const shippingOptions = useComboboxData({
|
|
9391
|
-
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
9392
|
-
queryFn: async (params) => {
|
|
9393
|
-
return await sdk.admin.shippingOption.list({
|
|
9394
|
-
...params,
|
|
9395
|
-
stock_location_id: locationId,
|
|
9396
|
-
shipping_profile_id: shippingProfileId
|
|
9397
|
-
});
|
|
9398
|
-
},
|
|
9399
|
-
getOptions: (data) => {
|
|
9400
|
-
return data.shipping_options.map((option) => {
|
|
9401
|
-
if (option.rules?.find(
|
|
9402
|
-
(r) => r.attribute === "is_return" && r.value === "true"
|
|
9403
|
-
)) {
|
|
9404
|
-
return void 0;
|
|
9405
|
-
}
|
|
9406
|
-
return {
|
|
9407
|
-
label: option.name,
|
|
9408
|
-
value: option.id
|
|
9409
|
-
};
|
|
9410
|
-
}).filter(Boolean);
|
|
9411
|
-
},
|
|
9412
|
-
enabled: !!locationId && !!shippingProfileId,
|
|
9413
|
-
defaultValue: preview.shipping_methods[0]?.shipping_option_id || void 0
|
|
9414
|
-
});
|
|
9415
|
-
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
9416
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9417
|
-
Form$2.Field,
|
|
9418
|
-
{
|
|
9419
|
-
control,
|
|
9420
|
-
name: "shipping_option_id",
|
|
9421
|
-
render: ({ field }) => {
|
|
9422
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
9423
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
9424
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
9425
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
9426
|
-
] }),
|
|
9427
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9428
|
-
ConditionalTooltip,
|
|
9427
|
+
) }),
|
|
9428
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9429
|
+
"rect",
|
|
9429
9430
|
{
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
{
|
|
9435
|
-
options: shippingOptions.options,
|
|
9436
|
-
fetchNextPage: shippingOptions.fetchNextPage,
|
|
9437
|
-
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
9438
|
-
searchValue: shippingOptions.searchValue,
|
|
9439
|
-
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
9440
|
-
placeholder: "Select shipping option",
|
|
9441
|
-
...field,
|
|
9442
|
-
disabled: !locationId || !shippingProfileId
|
|
9443
|
-
}
|
|
9444
|
-
) }) })
|
|
9431
|
+
width: "12",
|
|
9432
|
+
height: "12",
|
|
9433
|
+
fill: "white",
|
|
9434
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
9445
9435
|
}
|
|
9446
|
-
)
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
}
|
|
9450
|
-
);
|
|
9451
|
-
};
|
|
9452
|
-
const CustomAmountField = ({
|
|
9453
|
-
control,
|
|
9454
|
-
currencyCode
|
|
9455
|
-
}) => {
|
|
9456
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9457
|
-
Form$2.Field,
|
|
9458
|
-
{
|
|
9459
|
-
control,
|
|
9460
|
-
name: "custom_amount",
|
|
9461
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
9462
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
9463
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
9464
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
9465
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
9466
|
-
] }),
|
|
9467
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9468
|
-
ui.CurrencyInput,
|
|
9436
|
+
) }),
|
|
9437
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9438
|
+
"rect",
|
|
9469
9439
|
{
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9440
|
+
width: "12",
|
|
9441
|
+
height: "12",
|
|
9442
|
+
fill: "white",
|
|
9443
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
9444
|
+
}
|
|
9445
|
+
) }),
|
|
9446
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9447
|
+
"rect",
|
|
9448
|
+
{
|
|
9449
|
+
width: "12",
|
|
9450
|
+
height: "12",
|
|
9451
|
+
fill: "white",
|
|
9452
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
9453
|
+
}
|
|
9454
|
+
) }),
|
|
9455
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9456
|
+
"rect",
|
|
9457
|
+
{
|
|
9458
|
+
width: "12",
|
|
9459
|
+
height: "12",
|
|
9460
|
+
fill: "white",
|
|
9461
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
9462
|
+
}
|
|
9463
|
+
) }),
|
|
9464
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9465
|
+
"rect",
|
|
9466
|
+
{
|
|
9467
|
+
width: "12",
|
|
9468
|
+
height: "12",
|
|
9469
|
+
fill: "white",
|
|
9470
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
9474
9471
|
}
|
|
9475
9472
|
) })
|
|
9476
|
-
] })
|
|
9477
|
-
|
|
9473
|
+
] })
|
|
9474
|
+
]
|
|
9478
9475
|
}
|
|
9479
9476
|
);
|
|
9480
9477
|
};
|
|
9478
|
+
const schema = zod.z.object({
|
|
9479
|
+
customer_id: zod.z.string().min(1)
|
|
9480
|
+
});
|
|
9481
9481
|
const widgetModule = { widgets: [] };
|
|
9482
9482
|
const routeModule = {
|
|
9483
9483
|
routes: [
|
|
@@ -9526,6 +9526,10 @@ const routeModule = {
|
|
|
9526
9526
|
Component: SalesChannel,
|
|
9527
9527
|
path: "/draft-orders/:id/sales-channel"
|
|
9528
9528
|
},
|
|
9529
|
+
{
|
|
9530
|
+
Component: Shipping,
|
|
9531
|
+
path: "/draft-orders/:id/shipping"
|
|
9532
|
+
},
|
|
9529
9533
|
{
|
|
9530
9534
|
Component: ShippingAddress,
|
|
9531
9535
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -9533,10 +9537,6 @@ const routeModule = {
|
|
|
9533
9537
|
{
|
|
9534
9538
|
Component: TransferOwnership,
|
|
9535
9539
|
path: "/draft-orders/:id/transfer-ownership"
|
|
9536
|
-
},
|
|
9537
|
-
{
|
|
9538
|
-
Component: Shipping,
|
|
9539
|
-
path: "/draft-orders/:id/shipping"
|
|
9540
9540
|
}
|
|
9541
9541
|
]
|
|
9542
9542
|
}
|