@medusajs/draft-order 2.23.0 → 2.23.1-preview-20261124142230
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 +520 -520
- package/package.json +18 -18
|
@@ -6026,77 +6026,6 @@ var CustomItemsForm = () => {
|
|
|
6026
6026
|
};
|
|
6027
6027
|
var schema$4 = zod.z.object({ email: zod.z.string().email() });
|
|
6028
6028
|
var handle$8 = { permissions: EDIT_DRAFT_ORDER_PERMISSIONS };
|
|
6029
|
-
// src/admin/routes/draft-orders/[id]/@email/page.tsx
|
|
6030
|
-
var Email = () => {
|
|
6031
|
-
const { id } = (0, react_router_dom.useParams)();
|
|
6032
|
-
const { order, isPending, isError, error } = useOrder(id, { fields: "+email" });
|
|
6033
|
-
if (isError) throw error;
|
|
6034
|
-
const isReady = !isPending && !!order;
|
|
6035
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer.Header, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Title, {
|
|
6036
|
-
asChild: true,
|
|
6037
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Edit Email" })
|
|
6038
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Description, {
|
|
6039
|
-
asChild: true,
|
|
6040
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6041
|
-
className: "sr-only",
|
|
6042
|
-
children: "Edit the email for the draft order"
|
|
6043
|
-
})
|
|
6044
|
-
})] }), isReady && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmailForm, { order })] });
|
|
6045
|
-
};
|
|
6046
|
-
var EmailForm = ({ order }) => {
|
|
6047
|
-
const form = (0, react_hook_form.useForm)({
|
|
6048
|
-
defaultValues: { email: order.email ?? "" },
|
|
6049
|
-
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema$3)
|
|
6050
|
-
});
|
|
6051
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
6052
|
-
const { handleSuccess } = useRouteModal();
|
|
6053
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
6054
|
-
await mutateAsync({ email: data.email }, {
|
|
6055
|
-
onSuccess: () => {
|
|
6056
|
-
handleSuccess();
|
|
6057
|
-
},
|
|
6058
|
-
onError: (error) => {
|
|
6059
|
-
_medusajs_ui.toast.error(error.message);
|
|
6060
|
-
}
|
|
6061
|
-
});
|
|
6062
|
-
});
|
|
6063
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Form, {
|
|
6064
|
-
form,
|
|
6065
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
|
|
6066
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
6067
|
-
onSubmit,
|
|
6068
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Body, {
|
|
6069
|
-
className: "flex flex-col gap-y-6 overflow-y-auto",
|
|
6070
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Field, {
|
|
6071
|
-
control: form.control,
|
|
6072
|
-
name: "email",
|
|
6073
|
-
render: ({ field }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Form$2.Item, { children: [
|
|
6074
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Label, { children: "Email" }),
|
|
6075
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Control, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, { ...field }) }),
|
|
6076
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.ErrorMessage, {})
|
|
6077
|
-
] })
|
|
6078
|
-
})
|
|
6079
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6080
|
-
className: "flex justify-end gap-2",
|
|
6081
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Close, {
|
|
6082
|
-
asChild: true,
|
|
6083
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
6084
|
-
size: "small",
|
|
6085
|
-
variant: "secondary",
|
|
6086
|
-
children: "Cancel"
|
|
6087
|
-
})
|
|
6088
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
6089
|
-
size: "small",
|
|
6090
|
-
type: "submit",
|
|
6091
|
-
isLoading: isPending,
|
|
6092
|
-
children: "Save"
|
|
6093
|
-
})]
|
|
6094
|
-
}) })]
|
|
6095
|
-
})
|
|
6096
|
-
});
|
|
6097
|
-
};
|
|
6098
|
-
var schema$3 = zod.z.object({ email: zod.z.string().email() });
|
|
6099
|
-
var handle$7 = { permissions: EDIT_DRAFT_ORDER_PERMISSIONS };
|
|
6100
6029
|
// src/admin/components/inputs/number-input.tsx
|
|
6101
6030
|
var NumberInput = (0, react.forwardRef)(({ value, onChange, size = "base", min = 0, max = 100, step = 1, className, disabled, ...props }, ref) => {
|
|
6102
6031
|
const handleChange = (event) => {
|
|
@@ -7163,6 +7092,77 @@ var customItemSchema = zod.z.object({
|
|
|
7163
7092
|
quantity: zod.z.number(),
|
|
7164
7093
|
unit_price: zod.z.union([zod.z.number(), zod.z.string()])
|
|
7165
7094
|
});
|
|
7095
|
+
var handle$7 = { permissions: EDIT_DRAFT_ORDER_PERMISSIONS };
|
|
7096
|
+
// src/admin/routes/draft-orders/[id]/@email/page.tsx
|
|
7097
|
+
var Email = () => {
|
|
7098
|
+
const { id } = (0, react_router_dom.useParams)();
|
|
7099
|
+
const { order, isPending, isError, error } = useOrder(id, { fields: "+email" });
|
|
7100
|
+
if (isError) throw error;
|
|
7101
|
+
const isReady = !isPending && !!order;
|
|
7102
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer.Header, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Title, {
|
|
7103
|
+
asChild: true,
|
|
7104
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Edit Email" })
|
|
7105
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Description, {
|
|
7106
|
+
asChild: true,
|
|
7107
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7108
|
+
className: "sr-only",
|
|
7109
|
+
children: "Edit the email for the draft order"
|
|
7110
|
+
})
|
|
7111
|
+
})] }), isReady && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmailForm, { order })] });
|
|
7112
|
+
};
|
|
7113
|
+
var EmailForm = ({ order }) => {
|
|
7114
|
+
const form = (0, react_hook_form.useForm)({
|
|
7115
|
+
defaultValues: { email: order.email ?? "" },
|
|
7116
|
+
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema$3)
|
|
7117
|
+
});
|
|
7118
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7119
|
+
const { handleSuccess } = useRouteModal();
|
|
7120
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
7121
|
+
await mutateAsync({ email: data.email }, {
|
|
7122
|
+
onSuccess: () => {
|
|
7123
|
+
handleSuccess();
|
|
7124
|
+
},
|
|
7125
|
+
onError: (error) => {
|
|
7126
|
+
_medusajs_ui.toast.error(error.message);
|
|
7127
|
+
}
|
|
7128
|
+
});
|
|
7129
|
+
});
|
|
7130
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Form, {
|
|
7131
|
+
form,
|
|
7132
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
|
|
7133
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
7134
|
+
onSubmit,
|
|
7135
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Body, {
|
|
7136
|
+
className: "flex flex-col gap-y-6 overflow-y-auto",
|
|
7137
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Field, {
|
|
7138
|
+
control: form.control,
|
|
7139
|
+
name: "email",
|
|
7140
|
+
render: ({ field }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Form$2.Item, { children: [
|
|
7141
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Label, { children: "Email" }),
|
|
7142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Control, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, { ...field }) }),
|
|
7143
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.ErrorMessage, {})
|
|
7144
|
+
] })
|
|
7145
|
+
})
|
|
7146
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7147
|
+
className: "flex justify-end gap-2",
|
|
7148
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Close, {
|
|
7149
|
+
asChild: true,
|
|
7150
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7151
|
+
size: "small",
|
|
7152
|
+
variant: "secondary",
|
|
7153
|
+
children: "Cancel"
|
|
7154
|
+
})
|
|
7155
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7156
|
+
size: "small",
|
|
7157
|
+
type: "submit",
|
|
7158
|
+
isLoading: isPending,
|
|
7159
|
+
children: "Save"
|
|
7160
|
+
})]
|
|
7161
|
+
}) })]
|
|
7162
|
+
})
|
|
7163
|
+
});
|
|
7164
|
+
};
|
|
7165
|
+
var schema$3 = zod.z.object({ email: zod.z.string().email() });
|
|
7166
7166
|
var handle$6 = { permissions: EDIT_DRAFT_ORDER_PERMISSIONS };
|
|
7167
7167
|
// src/admin/components/common/inline-tip.tsx
|
|
7168
7168
|
/**
|
|
@@ -7456,433 +7456,90 @@ function getHasUneditableRows(metadata) {
|
|
|
7456
7456
|
return Object.values(metadata).some((value) => !EDITABLE_TYPES.includes(typeof value));
|
|
7457
7457
|
}
|
|
7458
7458
|
var handle$5 = { permissions: EDIT_DRAFT_ORDER_PERMISSIONS };
|
|
7459
|
-
// src/admin/
|
|
7460
|
-
var
|
|
7461
|
-
var
|
|
7462
|
-
list: (query) => [PROMOTION_QUERY_KEY, query ? query : void 0],
|
|
7463
|
-
detail: (id, query) => [
|
|
7464
|
-
PROMOTION_QUERY_KEY,
|
|
7465
|
-
id,
|
|
7466
|
-
query ? query : void 0
|
|
7467
|
-
]
|
|
7468
|
-
};
|
|
7469
|
-
var usePromotions = (query, options) => {
|
|
7470
|
-
const { data, ...rest } = (0, _tanstack_react_query.useQuery)({
|
|
7471
|
-
queryKey: promotionsQueryKeys.list(query),
|
|
7472
|
-
queryFn: async () => sdk.admin.promotion.list(query),
|
|
7473
|
-
...options
|
|
7474
|
-
});
|
|
7475
|
-
return {
|
|
7476
|
-
...data,
|
|
7477
|
-
...rest
|
|
7478
|
-
};
|
|
7479
|
-
};
|
|
7480
|
-
// src/admin/routes/draft-orders/[id]/@promotions/page.tsx
|
|
7481
|
-
var Promotions = () => {
|
|
7459
|
+
// src/admin/routes/draft-orders/[id]/@shipping/page.tsx
|
|
7460
|
+
var STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
7461
|
+
var Shipping = () => {
|
|
7482
7462
|
const { id } = (0, react_router_dom.useParams)();
|
|
7483
|
-
const { order
|
|
7463
|
+
const { order, isPending, isError, error } = useOrder(id, { fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code" });
|
|
7464
|
+
const { order: preview, isPending: isPreviewPending, isError: isPreviewError, error: previewError } = useOrderPreview(id);
|
|
7484
7465
|
useInitiateOrderEdit({ preview });
|
|
7485
7466
|
const { onCancel } = useCancelOrderEdit({ preview });
|
|
7467
|
+
if (isError) throw error;
|
|
7486
7468
|
if (isPreviewError) throw previewError;
|
|
7487
|
-
const
|
|
7488
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
7469
|
+
const orderHasItems = (order?.items?.length || 0) > 0;
|
|
7470
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal, {
|
|
7489
7471
|
onClose: onCancel,
|
|
7490
|
-
children:
|
|
7472
|
+
children: !orderHasItems ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7473
|
+
className: "flex h-full flex-col overflow-hidden ",
|
|
7474
|
+
children: [
|
|
7475
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Header, {}),
|
|
7476
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Body, {
|
|
7477
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
7478
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
7479
|
+
className: "flex flex-1 flex-col items-center overflow-y-auto",
|
|
7480
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7481
|
+
className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16",
|
|
7482
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Title, {
|
|
7483
|
+
asChild: true,
|
|
7484
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Shipping" })
|
|
7485
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Description, {
|
|
7486
|
+
asChild: true,
|
|
7487
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
7488
|
+
size: "small",
|
|
7489
|
+
className: "text-ui-fg-subtle",
|
|
7490
|
+
children: "This draft order currently has no items. Add items to the order before adding shipping."
|
|
7491
|
+
})
|
|
7492
|
+
})]
|
|
7493
|
+
})
|
|
7494
|
+
})
|
|
7495
|
+
}),
|
|
7496
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Close, {
|
|
7497
|
+
asChild: true,
|
|
7498
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7499
|
+
size: "small",
|
|
7500
|
+
variant: "secondary",
|
|
7501
|
+
type: "button",
|
|
7502
|
+
children: "Cancel"
|
|
7503
|
+
})
|
|
7504
|
+
}) })
|
|
7505
|
+
]
|
|
7506
|
+
}) : preview && !isPreviewPending && order && !isPending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShippingForm, {
|
|
7507
|
+
preview,
|
|
7508
|
+
order
|
|
7509
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Title, {
|
|
7491
7510
|
asChild: true,
|
|
7492
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
7493
|
-
|
|
7511
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7512
|
+
className: "sr-only",
|
|
7513
|
+
children: "Edit Shipping"
|
|
7514
|
+
})
|
|
7515
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Description, {
|
|
7516
|
+
asChild: true,
|
|
7517
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7518
|
+
className: "sr-only",
|
|
7519
|
+
children: "Loading data for the draft order, please wait..."
|
|
7520
|
+
})
|
|
7521
|
+
})] })
|
|
7494
7522
|
});
|
|
7495
7523
|
};
|
|
7496
|
-
var
|
|
7497
|
-
const {
|
|
7524
|
+
var ShippingForm = ({ preview, order }) => {
|
|
7525
|
+
const { setIsOpen } = useStackedModal();
|
|
7498
7526
|
const [isSubmitting, setIsSubmitting] = (0, react.useState)(false);
|
|
7499
|
-
const [
|
|
7500
|
-
const
|
|
7501
|
-
const {
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
},
|
|
7516
|
-
getOptions: (data) => {
|
|
7517
|
-
return data.promotions.map((promotion) => ({
|
|
7518
|
-
label: promotion.code,
|
|
7519
|
-
value: promotion.code
|
|
7520
|
-
}));
|
|
7521
|
-
}
|
|
7522
|
-
});
|
|
7523
|
-
const add = async (value) => {
|
|
7524
|
-
if (!value) return;
|
|
7525
|
-
addPromotions({ promo_codes: [value] }, {
|
|
7526
|
-
onError: (e) => {
|
|
7527
|
-
_medusajs_ui.toast.error(e.message);
|
|
7528
|
-
comboboxData.onSearchValueChange("");
|
|
7529
|
-
setComboboxValue("");
|
|
7530
|
-
},
|
|
7531
|
-
onSuccess: () => {
|
|
7532
|
-
comboboxData.onSearchValueChange("");
|
|
7533
|
-
setComboboxValue("");
|
|
7534
|
-
}
|
|
7535
|
-
});
|
|
7536
|
-
};
|
|
7537
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
7538
|
-
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
7539
|
-
const onSubmit = async () => {
|
|
7540
|
-
setIsSubmitting(true);
|
|
7541
|
-
let requestSucceeded = false;
|
|
7542
|
-
await requestOrderEdit(void 0, {
|
|
7543
|
-
onError: (e) => {
|
|
7544
|
-
_medusajs_ui.toast.error(e.message);
|
|
7545
|
-
},
|
|
7546
|
-
onSuccess: () => {
|
|
7547
|
-
requestSucceeded = true;
|
|
7548
|
-
}
|
|
7549
|
-
});
|
|
7550
|
-
if (!requestSucceeded) {
|
|
7551
|
-
setIsSubmitting(false);
|
|
7552
|
-
return;
|
|
7553
|
-
}
|
|
7554
|
-
await confirmOrderEdit(void 0, {
|
|
7555
|
-
onError: (e) => {
|
|
7556
|
-
_medusajs_ui.toast.error(e.message);
|
|
7557
|
-
},
|
|
7558
|
-
onSuccess: () => {
|
|
7559
|
-
handleSuccess();
|
|
7560
|
-
},
|
|
7561
|
-
onSettled: () => {
|
|
7562
|
-
setIsSubmitting(false);
|
|
7563
|
-
}
|
|
7564
|
-
});
|
|
7565
|
-
};
|
|
7566
|
-
if (isError) throw error;
|
|
7567
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
|
|
7568
|
-
className: "flex flex-1 flex-col",
|
|
7569
|
-
onSubmit,
|
|
7570
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Body, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7571
|
-
className: "flex flex-col gap-4",
|
|
7572
|
-
children: [
|
|
7573
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7574
|
-
className: "flex flex-col gap-3",
|
|
7575
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7576
|
-
className: "flex flex-col",
|
|
7577
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
|
|
7578
|
-
size: "small",
|
|
7579
|
-
weight: "plus",
|
|
7580
|
-
htmlFor: "promotion-combobox",
|
|
7581
|
-
children: "Apply promotions"
|
|
7582
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Hint, {
|
|
7583
|
-
id: "promotion-combobox-hint",
|
|
7584
|
-
children: "Manage promotions that should be applied to the order."
|
|
7585
|
-
})]
|
|
7586
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Combobox, {
|
|
7587
|
-
id: "promotion-combobox",
|
|
7588
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
7589
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
7590
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
7591
|
-
options: comboboxData.options,
|
|
7592
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
7593
|
-
searchValue: comboboxData.searchValue,
|
|
7594
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
7595
|
-
onChange: add,
|
|
7596
|
-
value: comboboxValue
|
|
7597
|
-
})]
|
|
7598
|
-
}),
|
|
7599
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Divider, { variant: "dashed" }),
|
|
7600
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
7601
|
-
className: "flex flex-col gap-2",
|
|
7602
|
-
children: promotions?.map((promotion) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromotionItem, {
|
|
7603
|
-
promotion,
|
|
7604
|
-
orderId: preview.id,
|
|
7605
|
-
isLoading: isPending
|
|
7606
|
-
}, promotion.id))
|
|
7607
|
-
})
|
|
7608
|
-
]
|
|
7609
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7610
|
-
className: "flex justify-end gap-2",
|
|
7611
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Close, {
|
|
7612
|
-
asChild: true,
|
|
7613
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7614
|
-
size: "small",
|
|
7615
|
-
variant: "secondary",
|
|
7616
|
-
children: "Cancel"
|
|
7617
|
-
})
|
|
7618
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7619
|
-
size: "small",
|
|
7620
|
-
type: "submit",
|
|
7621
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
7622
|
-
children: "Save"
|
|
7623
|
-
})]
|
|
7624
|
-
}) })]
|
|
7625
|
-
});
|
|
7626
|
-
};
|
|
7627
|
-
var PromotionItem = ({ promotion, orderId, isLoading }) => {
|
|
7628
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
7629
|
-
const onRemove = async () => {
|
|
7630
|
-
removePromotions({ promo_codes: [promotion.code] }, { onError: (e) => {
|
|
7631
|
-
_medusajs_ui.toast.error(e.message);
|
|
7632
|
-
} });
|
|
7633
|
-
};
|
|
7634
|
-
const displayValue = getDisplayValue(promotion);
|
|
7635
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7636
|
-
className: (0, _medusajs_ui.clx)("bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2", { "animate-pulse": isLoading }),
|
|
7637
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
7638
|
-
size: "small",
|
|
7639
|
-
weight: "plus",
|
|
7640
|
-
leading: "compact",
|
|
7641
|
-
children: promotion.code
|
|
7642
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7643
|
-
className: "text-ui-fg-subtle flex items-center gap-1.5",
|
|
7644
|
-
children: [displayValue && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7645
|
-
className: "flex items-center gap-1.5",
|
|
7646
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
7647
|
-
size: "small",
|
|
7648
|
-
leading: "compact",
|
|
7649
|
-
children: displayValue
|
|
7650
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
7651
|
-
size: "small",
|
|
7652
|
-
leading: "compact",
|
|
7653
|
-
children: "·"
|
|
7654
|
-
})]
|
|
7655
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
7656
|
-
size: "small",
|
|
7657
|
-
leading: "compact",
|
|
7658
|
-
className: "capitalize",
|
|
7659
|
-
children: promotion.application_method?.allocation
|
|
7660
|
-
})]
|
|
7661
|
-
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.IconButton, {
|
|
7662
|
-
size: "small",
|
|
7663
|
-
type: "button",
|
|
7664
|
-
variant: "transparent",
|
|
7665
|
-
onClick: onRemove,
|
|
7666
|
-
isLoading: isPending || isLoading,
|
|
7667
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_icons.XMark, {})
|
|
7668
|
-
})]
|
|
7669
|
-
}, promotion.id);
|
|
7670
|
-
};
|
|
7671
|
-
function getDisplayValue(promotion) {
|
|
7672
|
-
const value = promotion.application_method?.value;
|
|
7673
|
-
if (!value) return null;
|
|
7674
|
-
if (promotion.application_method?.type === "fixed") {
|
|
7675
|
-
const currency = promotion.application_method?.currency_code;
|
|
7676
|
-
if (!currency) return null;
|
|
7677
|
-
return getLocaleAmount(value, currency);
|
|
7678
|
-
} else if (promotion.application_method?.type === "percentage") return formatPercentage(value);
|
|
7679
|
-
return null;
|
|
7680
|
-
}
|
|
7681
|
-
var formatter = new Intl.NumberFormat([], {
|
|
7682
|
-
style: "percent",
|
|
7683
|
-
minimumFractionDigits: 2
|
|
7684
|
-
});
|
|
7685
|
-
var formatPercentage = (value, isPercentageValue = false) => {
|
|
7686
|
-
let val = value || 0;
|
|
7687
|
-
if (!isPercentageValue) val = val / 100;
|
|
7688
|
-
return formatter.format(val);
|
|
7689
|
-
};
|
|
7690
|
-
function getPromotionIds(items, shippingMethods) {
|
|
7691
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
7692
|
-
for (const item of items) if (item.adjustments) {
|
|
7693
|
-
for (const adjustment of item.adjustments) if (adjustment.promotion_id) promotionIds.add(adjustment.promotion_id);
|
|
7694
|
-
}
|
|
7695
|
-
for (const shippingMethod of shippingMethods) if (shippingMethod.adjustments) {
|
|
7696
|
-
for (const adjustment of shippingMethod.adjustments) if (adjustment.promotion_id) promotionIds.add(adjustment.promotion_id);
|
|
7697
|
-
}
|
|
7698
|
-
return Array.from(promotionIds);
|
|
7699
|
-
}
|
|
7700
|
-
var handle$4 = { permissions: EDIT_DRAFT_ORDER_PROMOTIONS_PERMISSIONS };
|
|
7701
|
-
// src/admin/routes/draft-orders/[id]/@sales-channel/page.tsx
|
|
7702
|
-
var SalesChannel = () => {
|
|
7703
|
-
const { id } = (0, react_router_dom.useParams)();
|
|
7704
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, { fields: "+sales_channel_id" }, { enabled: !!id });
|
|
7705
|
-
if (isError) throw error;
|
|
7706
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
7707
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer.Header, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Title, {
|
|
7708
|
-
asChild: true,
|
|
7709
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Edit Sales Channel" })
|
|
7710
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Description, {
|
|
7711
|
-
asChild: true,
|
|
7712
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7713
|
-
className: "sr-only",
|
|
7714
|
-
children: "Update which sales channel the draft order is associated with"
|
|
7715
|
-
})
|
|
7716
|
-
})] }), ISrEADY && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SalesChannelForm, { order: draft_order })] });
|
|
7717
|
-
};
|
|
7718
|
-
var SalesChannelForm = ({ order }) => {
|
|
7719
|
-
const form = (0, react_hook_form.useForm)({
|
|
7720
|
-
defaultValues: { sales_channel_id: order.sales_channel_id || "" },
|
|
7721
|
-
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema$2)
|
|
7722
|
-
});
|
|
7723
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
7724
|
-
const { handleSuccess } = useRouteModal();
|
|
7725
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
7726
|
-
await mutateAsync({ sales_channel_id: data.sales_channel_id }, {
|
|
7727
|
-
onSuccess: () => {
|
|
7728
|
-
_medusajs_ui.toast.success("Sales channel updated");
|
|
7729
|
-
handleSuccess();
|
|
7730
|
-
},
|
|
7731
|
-
onError: (error) => {
|
|
7732
|
-
_medusajs_ui.toast.error(error.message);
|
|
7733
|
-
}
|
|
7734
|
-
});
|
|
7735
|
-
});
|
|
7736
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Form, {
|
|
7737
|
-
form,
|
|
7738
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
|
|
7739
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7740
|
-
onSubmit,
|
|
7741
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Body, {
|
|
7742
|
-
className: "flex flex-col gap-y-6 overflow-y-auto",
|
|
7743
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SalesChannelField, {
|
|
7744
|
-
control: form.control,
|
|
7745
|
-
order
|
|
7746
|
-
})
|
|
7747
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7748
|
-
className: "flex justify-end gap-2",
|
|
7749
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Close, {
|
|
7750
|
-
asChild: true,
|
|
7751
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7752
|
-
size: "small",
|
|
7753
|
-
variant: "secondary",
|
|
7754
|
-
children: "Cancel"
|
|
7755
|
-
})
|
|
7756
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7757
|
-
size: "small",
|
|
7758
|
-
type: "submit",
|
|
7759
|
-
isLoading: isPending,
|
|
7760
|
-
children: "Save"
|
|
7761
|
-
})]
|
|
7762
|
-
}) })]
|
|
7763
|
-
})
|
|
7764
|
-
});
|
|
7765
|
-
};
|
|
7766
|
-
var SalesChannelField = ({ control, order }) => {
|
|
7767
|
-
const salesChannels = useComboboxData({
|
|
7768
|
-
queryFn: async (params) => {
|
|
7769
|
-
return await sdk.admin.salesChannel.list(params);
|
|
7770
|
-
},
|
|
7771
|
-
queryKey: ["sales-channels"],
|
|
7772
|
-
getOptions: (data) => {
|
|
7773
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
7774
|
-
label: salesChannel.name,
|
|
7775
|
-
value: salesChannel.id
|
|
7776
|
-
}));
|
|
7777
|
-
},
|
|
7778
|
-
defaultValue: order.sales_channel_id || void 0
|
|
7779
|
-
});
|
|
7780
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Field, {
|
|
7781
|
-
control,
|
|
7782
|
-
name: "sales_channel_id",
|
|
7783
|
-
render: ({ field }) => {
|
|
7784
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Form$2.Item, { children: [
|
|
7785
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Label, { children: "Sales Channel" }),
|
|
7786
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Control, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Combobox, {
|
|
7787
|
-
options: salesChannels.options,
|
|
7788
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
7789
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
7790
|
-
searchValue: salesChannels.searchValue,
|
|
7791
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
7792
|
-
placeholder: "Select sales channel",
|
|
7793
|
-
...field
|
|
7794
|
-
}) }),
|
|
7795
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.ErrorMessage, {})
|
|
7796
|
-
] });
|
|
7797
|
-
}
|
|
7798
|
-
});
|
|
7799
|
-
};
|
|
7800
|
-
var schema$2 = zod.z.object({ sales_channel_id: zod.z.string().min(1) });
|
|
7801
|
-
var handle$3 = { permissions: EDIT_DRAFT_ORDER_SALES_CHANNEL_PERMISSIONS };
|
|
7802
|
-
// src/admin/routes/draft-orders/[id]/@shipping/page.tsx
|
|
7803
|
-
var STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
7804
|
-
var Shipping = () => {
|
|
7805
|
-
const { id } = (0, react_router_dom.useParams)();
|
|
7806
|
-
const { order, isPending, isError, error } = useOrder(id, { fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code" });
|
|
7807
|
-
const { order: preview, isPending: isPreviewPending, isError: isPreviewError, error: previewError } = useOrderPreview(id);
|
|
7808
|
-
useInitiateOrderEdit({ preview });
|
|
7809
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
7810
|
-
if (isError) throw error;
|
|
7811
|
-
if (isPreviewError) throw previewError;
|
|
7812
|
-
const orderHasItems = (order?.items?.length || 0) > 0;
|
|
7813
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal, {
|
|
7814
|
-
onClose: onCancel,
|
|
7815
|
-
children: !orderHasItems ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7816
|
-
className: "flex h-full flex-col overflow-hidden ",
|
|
7817
|
-
children: [
|
|
7818
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Header, {}),
|
|
7819
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Body, {
|
|
7820
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
7821
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
7822
|
-
className: "flex flex-1 flex-col items-center overflow-y-auto",
|
|
7823
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7824
|
-
className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16",
|
|
7825
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Title, {
|
|
7826
|
-
asChild: true,
|
|
7827
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Shipping" })
|
|
7828
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Description, {
|
|
7829
|
-
asChild: true,
|
|
7830
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
7831
|
-
size: "small",
|
|
7832
|
-
className: "text-ui-fg-subtle",
|
|
7833
|
-
children: "This draft order currently has no items. Add items to the order before adding shipping."
|
|
7834
|
-
})
|
|
7835
|
-
})]
|
|
7836
|
-
})
|
|
7837
|
-
})
|
|
7838
|
-
}),
|
|
7839
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Close, {
|
|
7840
|
-
asChild: true,
|
|
7841
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
7842
|
-
size: "small",
|
|
7843
|
-
variant: "secondary",
|
|
7844
|
-
type: "button",
|
|
7845
|
-
children: "Cancel"
|
|
7846
|
-
})
|
|
7847
|
-
}) })
|
|
7848
|
-
]
|
|
7849
|
-
}) : preview && !isPreviewPending && order && !isPending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShippingForm, {
|
|
7850
|
-
preview,
|
|
7851
|
-
order
|
|
7852
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Title, {
|
|
7853
|
-
asChild: true,
|
|
7854
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7855
|
-
className: "sr-only",
|
|
7856
|
-
children: "Edit Shipping"
|
|
7857
|
-
})
|
|
7858
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Description, {
|
|
7859
|
-
asChild: true,
|
|
7860
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7861
|
-
className: "sr-only",
|
|
7862
|
-
children: "Loading data for the draft order, please wait..."
|
|
7863
|
-
})
|
|
7864
|
-
})] })
|
|
7865
|
-
});
|
|
7866
|
-
};
|
|
7867
|
-
var ShippingForm = ({ preview, order }) => {
|
|
7868
|
-
const { setIsOpen } = useStackedModal();
|
|
7869
|
-
const [isSubmitting, setIsSubmitting] = (0, react.useState)(false);
|
|
7870
|
-
const [data, setData] = (0, react.useState)(null);
|
|
7871
|
-
const appliedShippingOptionIds = preview.shipping_methods?.map((method) => method.shipping_option_id).filter(Boolean);
|
|
7872
|
-
const { shipping_options } = useShippingOptions({
|
|
7873
|
-
id: appliedShippingOptionIds,
|
|
7874
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
7875
|
-
}, { enabled: appliedShippingOptionIds.length > 0 });
|
|
7876
|
-
const uniqueShippingProfiles = (0, react.useMemo)(() => {
|
|
7877
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
7878
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
7879
|
-
profiles.set(profile.id, profile);
|
|
7880
|
-
});
|
|
7881
|
-
shipping_options?.forEach((option) => {
|
|
7882
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
7883
|
-
});
|
|
7884
|
-
return Array.from(profiles.values());
|
|
7885
|
-
}, [order.items, shipping_options]);
|
|
7527
|
+
const [data, setData] = (0, react.useState)(null);
|
|
7528
|
+
const appliedShippingOptionIds = preview.shipping_methods?.map((method) => method.shipping_option_id).filter(Boolean);
|
|
7529
|
+
const { shipping_options } = useShippingOptions({
|
|
7530
|
+
id: appliedShippingOptionIds,
|
|
7531
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
7532
|
+
}, { enabled: appliedShippingOptionIds.length > 0 });
|
|
7533
|
+
const uniqueShippingProfiles = (0, react.useMemo)(() => {
|
|
7534
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
7535
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
7536
|
+
profiles.set(profile.id, profile);
|
|
7537
|
+
});
|
|
7538
|
+
shipping_options?.forEach((option) => {
|
|
7539
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
7540
|
+
});
|
|
7541
|
+
return Array.from(profiles.values());
|
|
7542
|
+
}, [order.items, shipping_options]);
|
|
7886
7543
|
const { handleSuccess } = useRouteModal();
|
|
7887
7544
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
7888
7545
|
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
@@ -8532,7 +8189,7 @@ var CustomAmountField = ({ control, currencyCode }) => {
|
|
|
8532
8189
|
}
|
|
8533
8190
|
});
|
|
8534
8191
|
};
|
|
8535
|
-
var handle$
|
|
8192
|
+
var handle$4 = { permissions: EDIT_DRAFT_ORDER_SHIPPING_PERMISSIONS };
|
|
8536
8193
|
// src/admin/routes/draft-orders/[id]/@shipping-address/page.tsx
|
|
8537
8194
|
var ShippingAddress = () => {
|
|
8538
8195
|
const { id } = (0, react_router_dom.useParams)();
|
|
@@ -8564,7 +8221,7 @@ var ShippingAddressForm = ({ order }) => {
|
|
|
8564
8221
|
postal_code: order.shipping_address?.postal_code ?? "",
|
|
8565
8222
|
phone: order.shipping_address?.phone ?? ""
|
|
8566
8223
|
},
|
|
8567
|
-
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema$
|
|
8224
|
+
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema$2)
|
|
8568
8225
|
});
|
|
8569
8226
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8570
8227
|
const { handleSuccess } = useRouteModal();
|
|
@@ -8726,8 +8383,8 @@ var ShippingAddressForm = ({ order }) => {
|
|
|
8726
8383
|
})
|
|
8727
8384
|
});
|
|
8728
8385
|
};
|
|
8729
|
-
var schema$
|
|
8730
|
-
var handle$
|
|
8386
|
+
var schema$2 = addressSchema;
|
|
8387
|
+
var handle$3 = { permissions: EDIT_DRAFT_ORDER_PERMISSIONS };
|
|
8731
8388
|
// src/admin/routes/draft-orders/[id]/@transfer-ownership/page.tsx
|
|
8732
8389
|
var TransferOwnership = () => {
|
|
8733
8390
|
const { id } = (0, react_router_dom.useParams)();
|
|
@@ -8748,7 +8405,7 @@ var TransferOwnership = () => {
|
|
|
8748
8405
|
var TransferOwnershipForm = ({ order }) => {
|
|
8749
8406
|
const form = (0, react_hook_form.useForm)({
|
|
8750
8407
|
defaultValues: { customer_id: order.customer_id || "" },
|
|
8751
|
-
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema)
|
|
8408
|
+
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema$1)
|
|
8752
8409
|
});
|
|
8753
8410
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8754
8411
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9140,21 +8797,364 @@ var Illustration = () => {
|
|
|
9140
8797
|
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
9141
8798
|
})
|
|
9142
8799
|
}),
|
|
9143
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("clipPath", {
|
|
9144
|
-
id: "clip5_20915_38670",
|
|
9145
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
9146
|
-
width: "12",
|
|
9147
|
-
height: "12",
|
|
9148
|
-
fill: "white",
|
|
9149
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
9150
|
-
})
|
|
8800
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("clipPath", {
|
|
8801
|
+
id: "clip5_20915_38670",
|
|
8802
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
8803
|
+
width: "12",
|
|
8804
|
+
height: "12",
|
|
8805
|
+
fill: "white",
|
|
8806
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
8807
|
+
})
|
|
8808
|
+
})
|
|
8809
|
+
] })
|
|
8810
|
+
]
|
|
8811
|
+
});
|
|
8812
|
+
};
|
|
8813
|
+
var schema$1 = zod.z.object({ customer_id: zod.z.string().min(1) });
|
|
8814
|
+
var handle$2 = { permissions: TRANSFER_DRAFT_ORDER_PERMISSIONS };
|
|
8815
|
+
// src/admin/routes/draft-orders/[id]/@sales-channel/page.tsx
|
|
8816
|
+
var SalesChannel = () => {
|
|
8817
|
+
const { id } = (0, react_router_dom.useParams)();
|
|
8818
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, { fields: "+sales_channel_id" }, { enabled: !!id });
|
|
8819
|
+
if (isError) throw error;
|
|
8820
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
8821
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer.Header, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Title, {
|
|
8822
|
+
asChild: true,
|
|
8823
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Edit Sales Channel" })
|
|
8824
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Description, {
|
|
8825
|
+
asChild: true,
|
|
8826
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
8827
|
+
className: "sr-only",
|
|
8828
|
+
children: "Update which sales channel the draft order is associated with"
|
|
8829
|
+
})
|
|
8830
|
+
})] }), ISrEADY && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SalesChannelForm, { order: draft_order })] });
|
|
8831
|
+
};
|
|
8832
|
+
var SalesChannelForm = ({ order }) => {
|
|
8833
|
+
const form = (0, react_hook_form.useForm)({
|
|
8834
|
+
defaultValues: { sales_channel_id: order.sales_channel_id || "" },
|
|
8835
|
+
resolver: (0, _hookform_resolvers_zod.zodResolver)(schema)
|
|
8836
|
+
});
|
|
8837
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
8838
|
+
const { handleSuccess } = useRouteModal();
|
|
8839
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
8840
|
+
await mutateAsync({ sales_channel_id: data.sales_channel_id }, {
|
|
8841
|
+
onSuccess: () => {
|
|
8842
|
+
_medusajs_ui.toast.success("Sales channel updated");
|
|
8843
|
+
handleSuccess();
|
|
8844
|
+
},
|
|
8845
|
+
onError: (error) => {
|
|
8846
|
+
_medusajs_ui.toast.error(error.message);
|
|
8847
|
+
}
|
|
8848
|
+
});
|
|
8849
|
+
});
|
|
8850
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Form, {
|
|
8851
|
+
form,
|
|
8852
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
|
|
8853
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
8854
|
+
onSubmit,
|
|
8855
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Body, {
|
|
8856
|
+
className: "flex flex-col gap-y-6 overflow-y-auto",
|
|
8857
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SalesChannelField, {
|
|
8858
|
+
control: form.control,
|
|
8859
|
+
order
|
|
8860
|
+
})
|
|
8861
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8862
|
+
className: "flex justify-end gap-2",
|
|
8863
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Close, {
|
|
8864
|
+
asChild: true,
|
|
8865
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
8866
|
+
size: "small",
|
|
8867
|
+
variant: "secondary",
|
|
8868
|
+
children: "Cancel"
|
|
8869
|
+
})
|
|
8870
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
8871
|
+
size: "small",
|
|
8872
|
+
type: "submit",
|
|
8873
|
+
isLoading: isPending,
|
|
8874
|
+
children: "Save"
|
|
8875
|
+
})]
|
|
8876
|
+
}) })]
|
|
8877
|
+
})
|
|
8878
|
+
});
|
|
8879
|
+
};
|
|
8880
|
+
var SalesChannelField = ({ control, order }) => {
|
|
8881
|
+
const salesChannels = useComboboxData({
|
|
8882
|
+
queryFn: async (params) => {
|
|
8883
|
+
return await sdk.admin.salesChannel.list(params);
|
|
8884
|
+
},
|
|
8885
|
+
queryKey: ["sales-channels"],
|
|
8886
|
+
getOptions: (data) => {
|
|
8887
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
8888
|
+
label: salesChannel.name,
|
|
8889
|
+
value: salesChannel.id
|
|
8890
|
+
}));
|
|
8891
|
+
},
|
|
8892
|
+
defaultValue: order.sales_channel_id || void 0
|
|
8893
|
+
});
|
|
8894
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Field, {
|
|
8895
|
+
control,
|
|
8896
|
+
name: "sales_channel_id",
|
|
8897
|
+
render: ({ field }) => {
|
|
8898
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Form$2.Item, { children: [
|
|
8899
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Label, { children: "Sales Channel" }),
|
|
8900
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.Control, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Combobox, {
|
|
8901
|
+
options: salesChannels.options,
|
|
8902
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
8903
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
8904
|
+
searchValue: salesChannels.searchValue,
|
|
8905
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
8906
|
+
placeholder: "Select sales channel",
|
|
8907
|
+
...field
|
|
8908
|
+
}) }),
|
|
8909
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Form$2.ErrorMessage, {})
|
|
8910
|
+
] });
|
|
8911
|
+
}
|
|
8912
|
+
});
|
|
8913
|
+
};
|
|
8914
|
+
var schema = zod.z.object({ sales_channel_id: zod.z.string().min(1) });
|
|
8915
|
+
var handle$1 = { permissions: EDIT_DRAFT_ORDER_SALES_CHANNEL_PERMISSIONS };
|
|
8916
|
+
// src/admin/hooks/api/promotions.tsx
|
|
8917
|
+
var PROMOTION_QUERY_KEY = "promotions";
|
|
8918
|
+
var promotionsQueryKeys = {
|
|
8919
|
+
list: (query) => [PROMOTION_QUERY_KEY, query ? query : void 0],
|
|
8920
|
+
detail: (id, query) => [
|
|
8921
|
+
PROMOTION_QUERY_KEY,
|
|
8922
|
+
id,
|
|
8923
|
+
query ? query : void 0
|
|
8924
|
+
]
|
|
8925
|
+
};
|
|
8926
|
+
var usePromotions = (query, options) => {
|
|
8927
|
+
const { data, ...rest } = (0, _tanstack_react_query.useQuery)({
|
|
8928
|
+
queryKey: promotionsQueryKeys.list(query),
|
|
8929
|
+
queryFn: async () => sdk.admin.promotion.list(query),
|
|
8930
|
+
...options
|
|
8931
|
+
});
|
|
8932
|
+
return {
|
|
8933
|
+
...data,
|
|
8934
|
+
...rest
|
|
8935
|
+
};
|
|
8936
|
+
};
|
|
8937
|
+
// src/admin/routes/draft-orders/[id]/@promotions/page.tsx
|
|
8938
|
+
var Promotions = () => {
|
|
8939
|
+
const { id } = (0, react_router_dom.useParams)();
|
|
8940
|
+
const { order: preview, isError: isPreviewError, error: previewError } = useOrderPreview(id, void 0);
|
|
8941
|
+
useInitiateOrderEdit({ preview });
|
|
8942
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
8943
|
+
if (isPreviewError) throw previewError;
|
|
8944
|
+
const isReady = !!preview;
|
|
8945
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteDrawer, {
|
|
8946
|
+
onClose: onCancel,
|
|
8947
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Header, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Title, {
|
|
8948
|
+
asChild: true,
|
|
8949
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: "Edit Promotions" })
|
|
8950
|
+
}) }), isReady && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromotionForm, { preview })]
|
|
8951
|
+
});
|
|
8952
|
+
};
|
|
8953
|
+
var PromotionForm = ({ preview }) => {
|
|
8954
|
+
const { items, shipping_methods } = preview;
|
|
8955
|
+
const [isSubmitting, setIsSubmitting] = (0, react.useState)(false);
|
|
8956
|
+
const [comboboxValue, setComboboxValue] = (0, react.useState)("");
|
|
8957
|
+
const { handleSuccess } = useRouteModal();
|
|
8958
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
8959
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
8960
|
+
const { promotions, isPending, isError, error } = usePromotions({ id: promoIds }, { enabled: !!promoIds.length });
|
|
8961
|
+
const comboboxData = useComboboxData({
|
|
8962
|
+
queryKey: [
|
|
8963
|
+
"promotions",
|
|
8964
|
+
"combobox",
|
|
8965
|
+
promoIds
|
|
8966
|
+
],
|
|
8967
|
+
queryFn: async (params) => {
|
|
8968
|
+
return await sdk.admin.promotion.list({
|
|
8969
|
+
...params,
|
|
8970
|
+
id: { $nin: promoIds }
|
|
8971
|
+
});
|
|
8972
|
+
},
|
|
8973
|
+
getOptions: (data) => {
|
|
8974
|
+
return data.promotions.map((promotion) => ({
|
|
8975
|
+
label: promotion.code,
|
|
8976
|
+
value: promotion.code
|
|
8977
|
+
}));
|
|
8978
|
+
}
|
|
8979
|
+
});
|
|
8980
|
+
const add = async (value) => {
|
|
8981
|
+
if (!value) return;
|
|
8982
|
+
addPromotions({ promo_codes: [value] }, {
|
|
8983
|
+
onError: (e) => {
|
|
8984
|
+
_medusajs_ui.toast.error(e.message);
|
|
8985
|
+
comboboxData.onSearchValueChange("");
|
|
8986
|
+
setComboboxValue("");
|
|
8987
|
+
},
|
|
8988
|
+
onSuccess: () => {
|
|
8989
|
+
comboboxData.onSearchValueChange("");
|
|
8990
|
+
setComboboxValue("");
|
|
8991
|
+
}
|
|
8992
|
+
});
|
|
8993
|
+
};
|
|
8994
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
8995
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
8996
|
+
const onSubmit = async () => {
|
|
8997
|
+
setIsSubmitting(true);
|
|
8998
|
+
let requestSucceeded = false;
|
|
8999
|
+
await requestOrderEdit(void 0, {
|
|
9000
|
+
onError: (e) => {
|
|
9001
|
+
_medusajs_ui.toast.error(e.message);
|
|
9002
|
+
},
|
|
9003
|
+
onSuccess: () => {
|
|
9004
|
+
requestSucceeded = true;
|
|
9005
|
+
}
|
|
9006
|
+
});
|
|
9007
|
+
if (!requestSucceeded) {
|
|
9008
|
+
setIsSubmitting(false);
|
|
9009
|
+
return;
|
|
9010
|
+
}
|
|
9011
|
+
await confirmOrderEdit(void 0, {
|
|
9012
|
+
onError: (e) => {
|
|
9013
|
+
_medusajs_ui.toast.error(e.message);
|
|
9014
|
+
},
|
|
9015
|
+
onSuccess: () => {
|
|
9016
|
+
handleSuccess();
|
|
9017
|
+
},
|
|
9018
|
+
onSettled: () => {
|
|
9019
|
+
setIsSubmitting(false);
|
|
9020
|
+
}
|
|
9021
|
+
});
|
|
9022
|
+
};
|
|
9023
|
+
if (isError) throw error;
|
|
9024
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
|
|
9025
|
+
className: "flex flex-1 flex-col",
|
|
9026
|
+
onSubmit,
|
|
9027
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Body, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9028
|
+
className: "flex flex-col gap-4",
|
|
9029
|
+
children: [
|
|
9030
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9031
|
+
className: "flex flex-col gap-3",
|
|
9032
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9033
|
+
className: "flex flex-col",
|
|
9034
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
|
|
9035
|
+
size: "small",
|
|
9036
|
+
weight: "plus",
|
|
9037
|
+
htmlFor: "promotion-combobox",
|
|
9038
|
+
children: "Apply promotions"
|
|
9039
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Hint, {
|
|
9040
|
+
id: "promotion-combobox-hint",
|
|
9041
|
+
children: "Manage promotions that should be applied to the order."
|
|
9042
|
+
})]
|
|
9043
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Combobox, {
|
|
9044
|
+
id: "promotion-combobox",
|
|
9045
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
9046
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
9047
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
9048
|
+
options: comboboxData.options,
|
|
9049
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
9050
|
+
searchValue: comboboxData.searchValue,
|
|
9051
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
9052
|
+
onChange: add,
|
|
9053
|
+
value: comboboxValue
|
|
9054
|
+
})]
|
|
9055
|
+
}),
|
|
9056
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Divider, { variant: "dashed" }),
|
|
9057
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9058
|
+
className: "flex flex-col gap-2",
|
|
9059
|
+
children: promotions?.map((promotion) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromotionItem, {
|
|
9060
|
+
promotion,
|
|
9061
|
+
orderId: preview.id,
|
|
9062
|
+
isLoading: isPending
|
|
9063
|
+
}, promotion.id))
|
|
9151
9064
|
})
|
|
9152
|
-
]
|
|
9153
|
-
|
|
9065
|
+
]
|
|
9066
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9067
|
+
className: "flex justify-end gap-2",
|
|
9068
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteDrawer.Close, {
|
|
9069
|
+
asChild: true,
|
|
9070
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
9071
|
+
size: "small",
|
|
9072
|
+
variant: "secondary",
|
|
9073
|
+
children: "Cancel"
|
|
9074
|
+
})
|
|
9075
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
|
|
9076
|
+
size: "small",
|
|
9077
|
+
type: "submit",
|
|
9078
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
9079
|
+
children: "Save"
|
|
9080
|
+
})]
|
|
9081
|
+
}) })]
|
|
9154
9082
|
});
|
|
9155
9083
|
};
|
|
9156
|
-
var
|
|
9157
|
-
|
|
9084
|
+
var PromotionItem = ({ promotion, orderId, isLoading }) => {
|
|
9085
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
9086
|
+
const onRemove = async () => {
|
|
9087
|
+
removePromotions({ promo_codes: [promotion.code] }, { onError: (e) => {
|
|
9088
|
+
_medusajs_ui.toast.error(e.message);
|
|
9089
|
+
} });
|
|
9090
|
+
};
|
|
9091
|
+
const displayValue = getDisplayValue(promotion);
|
|
9092
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9093
|
+
className: (0, _medusajs_ui.clx)("bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2", { "animate-pulse": isLoading }),
|
|
9094
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
9095
|
+
size: "small",
|
|
9096
|
+
weight: "plus",
|
|
9097
|
+
leading: "compact",
|
|
9098
|
+
children: promotion.code
|
|
9099
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9100
|
+
className: "text-ui-fg-subtle flex items-center gap-1.5",
|
|
9101
|
+
children: [displayValue && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9102
|
+
className: "flex items-center gap-1.5",
|
|
9103
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
9104
|
+
size: "small",
|
|
9105
|
+
leading: "compact",
|
|
9106
|
+
children: displayValue
|
|
9107
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
9108
|
+
size: "small",
|
|
9109
|
+
leading: "compact",
|
|
9110
|
+
children: "·"
|
|
9111
|
+
})]
|
|
9112
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
9113
|
+
size: "small",
|
|
9114
|
+
leading: "compact",
|
|
9115
|
+
className: "capitalize",
|
|
9116
|
+
children: promotion.application_method?.allocation
|
|
9117
|
+
})]
|
|
9118
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.IconButton, {
|
|
9119
|
+
size: "small",
|
|
9120
|
+
type: "button",
|
|
9121
|
+
variant: "transparent",
|
|
9122
|
+
onClick: onRemove,
|
|
9123
|
+
isLoading: isPending || isLoading,
|
|
9124
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_icons.XMark, {})
|
|
9125
|
+
})]
|
|
9126
|
+
}, promotion.id);
|
|
9127
|
+
};
|
|
9128
|
+
function getDisplayValue(promotion) {
|
|
9129
|
+
const value = promotion.application_method?.value;
|
|
9130
|
+
if (!value) return null;
|
|
9131
|
+
if (promotion.application_method?.type === "fixed") {
|
|
9132
|
+
const currency = promotion.application_method?.currency_code;
|
|
9133
|
+
if (!currency) return null;
|
|
9134
|
+
return getLocaleAmount(value, currency);
|
|
9135
|
+
} else if (promotion.application_method?.type === "percentage") return formatPercentage(value);
|
|
9136
|
+
return null;
|
|
9137
|
+
}
|
|
9138
|
+
var formatter = new Intl.NumberFormat([], {
|
|
9139
|
+
style: "percent",
|
|
9140
|
+
minimumFractionDigits: 2
|
|
9141
|
+
});
|
|
9142
|
+
var formatPercentage = (value, isPercentageValue = false) => {
|
|
9143
|
+
let val = value || 0;
|
|
9144
|
+
if (!isPercentageValue) val = val / 100;
|
|
9145
|
+
return formatter.format(val);
|
|
9146
|
+
};
|
|
9147
|
+
function getPromotionIds(items, shippingMethods) {
|
|
9148
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
9149
|
+
for (const item of items) if (item.adjustments) {
|
|
9150
|
+
for (const adjustment of item.adjustments) if (adjustment.promotion_id) promotionIds.add(adjustment.promotion_id);
|
|
9151
|
+
}
|
|
9152
|
+
for (const shippingMethod of shippingMethods) if (shippingMethod.adjustments) {
|
|
9153
|
+
for (const adjustment of shippingMethod.adjustments) if (adjustment.promotion_id) promotionIds.add(adjustment.promotion_id);
|
|
9154
|
+
}
|
|
9155
|
+
return Array.from(promotionIds);
|
|
9156
|
+
}
|
|
9157
|
+
var handle = { permissions: EDIT_DRAFT_ORDER_PROMOTIONS_PERMISSIONS };
|
|
9158
9158
|
// ../../admin/admin-shared/dist/index.mjs
|
|
9159
9159
|
var PRODUCT_CUSTOM_FIELD_MODEL = "product";
|
|
9160
9160
|
var PRODUCT_CUSTOM_FIELD_FORM_ZONES = [
|
|
@@ -9612,13 +9612,13 @@ var plugin = {
|
|
|
9612
9612
|
handle: handle$8
|
|
9613
9613
|
},
|
|
9614
9614
|
{
|
|
9615
|
-
Component:
|
|
9616
|
-
path: "/draft-orders/:id/
|
|
9615
|
+
Component: Items,
|
|
9616
|
+
path: "/draft-orders/:id/items",
|
|
9617
9617
|
handle: handle$7
|
|
9618
9618
|
},
|
|
9619
9619
|
{
|
|
9620
|
-
Component:
|
|
9621
|
-
path: "/draft-orders/:id/
|
|
9620
|
+
Component: Email,
|
|
9621
|
+
path: "/draft-orders/:id/email",
|
|
9622
9622
|
handle: handle$6
|
|
9623
9623
|
},
|
|
9624
9624
|
{
|
|
@@ -9627,28 +9627,28 @@ var plugin = {
|
|
|
9627
9627
|
handle: handle$5
|
|
9628
9628
|
},
|
|
9629
9629
|
{
|
|
9630
|
-
Component:
|
|
9631
|
-
path: "/draft-orders/:id/
|
|
9630
|
+
Component: Shipping,
|
|
9631
|
+
path: "/draft-orders/:id/shipping",
|
|
9632
9632
|
handle: handle$4
|
|
9633
9633
|
},
|
|
9634
9634
|
{
|
|
9635
|
-
Component:
|
|
9636
|
-
path: "/draft-orders/:id/
|
|
9635
|
+
Component: ShippingAddress,
|
|
9636
|
+
path: "/draft-orders/:id/shipping-address",
|
|
9637
9637
|
handle: handle$3
|
|
9638
9638
|
},
|
|
9639
9639
|
{
|
|
9640
|
-
Component:
|
|
9641
|
-
path: "/draft-orders/:id/
|
|
9640
|
+
Component: TransferOwnership,
|
|
9641
|
+
path: "/draft-orders/:id/transfer-ownership",
|
|
9642
9642
|
handle: handle$2
|
|
9643
9643
|
},
|
|
9644
9644
|
{
|
|
9645
|
-
Component:
|
|
9646
|
-
path: "/draft-orders/:id/
|
|
9645
|
+
Component: SalesChannel,
|
|
9646
|
+
path: "/draft-orders/:id/sales-channel",
|
|
9647
9647
|
handle: handle$1
|
|
9648
9648
|
},
|
|
9649
9649
|
{
|
|
9650
|
-
Component:
|
|
9651
|
-
path: "/draft-orders/:id/
|
|
9650
|
+
Component: Promotions,
|
|
9651
|
+
path: "/draft-orders/:id/promotions",
|
|
9652
9652
|
handle
|
|
9653
9653
|
}
|
|
9654
9654
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.1-preview-20261124142230",
|
|
4
4
|
"description": "A draft order plugin for Medusa.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@ariakit/react": "^0.4.15",
|
|
51
51
|
"@babel/runtime": "^8.0.10",
|
|
52
52
|
"@hookform/resolvers": "6.0.0",
|
|
53
|
-
"@medusajs/js-sdk": "2.23.
|
|
53
|
+
"@medusajs/js-sdk": "2.23.1-preview-20261124142230",
|
|
54
54
|
"@tanstack/react-query": "5.107.1",
|
|
55
55
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
56
56
|
"date-fns": "^4.4.0",
|
|
@@ -62,25 +62,25 @@
|
|
|
62
62
|
"zod": "4.6.7"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@medusajs/admin-sdk": "2.23.
|
|
66
|
-
"@medusajs/cli": "2.23.
|
|
67
|
-
"@medusajs/dashboard": "2.23.
|
|
68
|
-
"@medusajs/framework": "2.23.
|
|
69
|
-
"@medusajs/icons": "2.23.
|
|
70
|
-
"@medusajs/test-utils": "2.23.
|
|
71
|
-
"@medusajs/types": "2.23.
|
|
72
|
-
"@medusajs/ui": "4.3.
|
|
73
|
-
"@medusajs/ui-preset": "2.23.
|
|
65
|
+
"@medusajs/admin-sdk": "2.23.1-preview-20261124142230",
|
|
66
|
+
"@medusajs/cli": "2.23.1-preview-20261124142230",
|
|
67
|
+
"@medusajs/dashboard": "2.23.1-preview-20261124142230",
|
|
68
|
+
"@medusajs/framework": "2.23.1-preview-20261124142230",
|
|
69
|
+
"@medusajs/icons": "2.23.1-preview-20261124142230",
|
|
70
|
+
"@medusajs/test-utils": "2.23.1-preview-20261124142230",
|
|
71
|
+
"@medusajs/types": "2.23.1-preview-20261124142230",
|
|
72
|
+
"@medusajs/ui": "4.3.1-preview-20261124142230",
|
|
73
|
+
"@medusajs/ui-preset": "2.23.1-preview-20261124142230",
|
|
74
74
|
"cross-env": "^10.1.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@medusajs/admin-sdk": "2.23.
|
|
78
|
-
"@medusajs/cli": "2.23.
|
|
79
|
-
"@medusajs/dashboard": "2.23.
|
|
80
|
-
"@medusajs/framework": "2.23.
|
|
81
|
-
"@medusajs/icons": "2.23.
|
|
82
|
-
"@medusajs/test-utils": "2.23.
|
|
83
|
-
"@medusajs/ui": "4.3.
|
|
77
|
+
"@medusajs/admin-sdk": "2.23.1-preview-20261124142230",
|
|
78
|
+
"@medusajs/cli": "2.23.1-preview-20261124142230",
|
|
79
|
+
"@medusajs/dashboard": "2.23.1-preview-20261124142230",
|
|
80
|
+
"@medusajs/framework": "2.23.1-preview-20261124142230",
|
|
81
|
+
"@medusajs/icons": "2.23.1-preview-20261124142230",
|
|
82
|
+
"@medusajs/test-utils": "2.23.1-preview-20261124142230",
|
|
83
|
+
"@medusajs/ui": "4.3.1-preview-20261124142230",
|
|
84
84
|
"react": "^19.3.1",
|
|
85
85
|
"react-dom": "^19.3.1",
|
|
86
86
|
"react-router-dom": "^6.30.4 || ^7.0.0"
|