@medusajs/draft-order 0.0.1 → 0.0.2
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 +11326 -0
- package/.medusa/server/src/admin/index.mjs +11322 -0
- package/package.json +16 -16
- package/.medusa/server/src/admin/components/common/action-menu.js +0 -77
- package/.medusa/server/src/admin/components/common/conditional-tooltip.js +0 -15
- package/.medusa/server/src/admin/components/common/data-table.js +0 -249
- package/.medusa/server/src/admin/components/common/form.js +0 -151
- package/.medusa/server/src/admin/components/common/inline-tip.js +0 -42
- package/.medusa/server/src/admin/components/common/keybound-form.js +0 -32
- package/.medusa/server/src/admin/components/common/page-skeleton.js +0 -51
- package/.medusa/server/src/admin/components/common/thumbnail.js +0 -15
- package/.medusa/server/src/admin/components/draft-orders/activity-section.js +0 -205
- package/.medusa/server/src/admin/components/draft-orders/customer-section.js +0 -165
- package/.medusa/server/src/admin/components/draft-orders/general-section.js +0 -36
- package/.medusa/server/src/admin/components/draft-orders/json-view-section.js +0 -140
- package/.medusa/server/src/admin/components/draft-orders/metadata-section.js +0 -28
- package/.medusa/server/src/admin/components/draft-orders/shipping-section.js +0 -211
- package/.medusa/server/src/admin/components/draft-orders/summary-section.js +0 -148
- package/.medusa/server/src/admin/components/inputs/combobox.js +0 -311
- package/.medusa/server/src/admin/components/inputs/country-select.js +0 -59
- package/.medusa/server/src/admin/components/inputs/number-input.js +0 -100
- package/.medusa/server/src/admin/components/inputs/switch-block.js +0 -30
- package/.medusa/server/src/admin/components/modals/index.js +0 -19
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +0 -57
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +0 -71
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +0 -60
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +0 -30
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +0 -12
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +0 -55
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +0 -63
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +0 -47
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +0 -14
- package/.medusa/server/src/admin/components/utilities/generic-forward-ref.js +0 -7
- package/.medusa/server/src/admin/hooks/api/customers.js +0 -53
- package/.medusa/server/src/admin/hooks/api/draft-orders.js +0 -161
- package/.medusa/server/src/admin/hooks/api/orders.js +0 -274
- package/.medusa/server/src/admin/hooks/api/product-variants.js +0 -21
- package/.medusa/server/src/admin/hooks/api/regions.js +0 -35
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +0 -35
- package/.medusa/server/src/admin/hooks/api/shipping-options.js +0 -35
- package/.medusa/server/src/admin/hooks/api/users.js +0 -26
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +0 -61
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +0 -89
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +0 -22
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +0 -14
- package/.medusa/server/src/admin/hooks/order-edits/use-cancel-order-edit.js +0 -25
- package/.medusa/server/src/admin/hooks/order-edits/use-initiate-order-edit.js +0 -39
- package/.medusa/server/src/admin/lib/data/countries.js +0 -1762
- package/.medusa/server/src/admin/lib/data/currencies.js +0 -36
- package/.medusa/server/src/admin/lib/queries/draft-order-details.js +0 -1
- package/.medusa/server/src/admin/lib/queries/sdk.js +0 -10
- package/.medusa/server/src/admin/lib/schemas/address.js +0 -16
- package/.medusa/server/src/admin/lib/utils/address-utils.js +0 -57
- package/.medusa/server/src/admin/lib/utils/date-utils.js +0 -27
- package/.medusa/server/src/admin/lib/utils/order-utils.js +0 -13
- package/.medusa/server/src/admin/routes/draft-orders/@create/page.js +0 -659
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@billing-address/page.js +0 -228
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@custom-items/page.js +0 -38
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@email/page.js +0 -89
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@items/page.js +0 -576
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@metadata/page.js +0 -338
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@promotions/page.js +0 -70
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@sales-channel/page.js +0 -113
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@shipping/page.js +0 -465
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@shipping-address/page.js +0 -241
- package/.medusa/server/src/admin/routes/draft-orders/_id_/page.js +0 -70
- package/.medusa/server/src/admin/routes/draft-orders/page.js +0 -148
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Photo } from "@medusajs/icons";
|
|
3
|
-
const Thumbnail = ({ thumbnail, alt = "" }) => {
|
|
4
|
-
return /* @__PURE__ */ jsx("div", { className: "relative w-6 h-8 rounded overflow-hidden flex items-center justify-center bg-ui-bg-component", children: thumbnail ? /* @__PURE__ */ jsx(
|
|
5
|
-
"img",
|
|
6
|
-
{
|
|
7
|
-
src: thumbnail,
|
|
8
|
-
className: "w-full h-full object-cover",
|
|
9
|
-
alt: alt ?? void 0
|
|
10
|
-
}
|
|
11
|
-
) : /* @__PURE__ */ jsx(Photo, {}) });
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
Thumbnail
|
|
15
|
-
};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Container, Heading, Text, clx, Tooltip, Avatar, Skeleton } from "@medusajs/ui";
|
|
3
|
-
import { Collapsible } from "radix-ui";
|
|
4
|
-
import { useMemo, useState } from "react";
|
|
5
|
-
import { Link } from "react-router-dom";
|
|
6
|
-
import { useUser } from "../../hooks/api/users.js";
|
|
7
|
-
import { getFullDate, getRelativeDate } from "../../lib/utils/date-utils.js";
|
|
8
|
-
const ActivitySection = ({ order, changes }) => {
|
|
9
|
-
const activityItems = useMemo(
|
|
10
|
-
() => getActivityItems(order, changes),
|
|
11
|
-
[order, changes]
|
|
12
|
-
);
|
|
13
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0 overflow-hidden", children: [
|
|
14
|
-
/* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(Heading, { children: "Activity" }) }),
|
|
15
|
-
/* @__PURE__ */ jsx(ActivityItemList, { items: activityItems })
|
|
16
|
-
] });
|
|
17
|
-
};
|
|
18
|
-
const ActivityItemList = ({ items }) => {
|
|
19
|
-
if (items.length <= 3) {
|
|
20
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-0.5 px-6 pb-6", children: items.map((item, idx) => /* @__PURE__ */ jsx(
|
|
21
|
-
ActivityItem,
|
|
22
|
-
{
|
|
23
|
-
item,
|
|
24
|
-
isFirst: idx === items.length - 1
|
|
25
|
-
},
|
|
26
|
-
idx
|
|
27
|
-
)) });
|
|
28
|
-
}
|
|
29
|
-
const lastItems = items.slice(0, 2);
|
|
30
|
-
const collapsibleItems = items.slice(2, items.length - 1);
|
|
31
|
-
const firstItem = items[items.length - 1];
|
|
32
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-0.5 px-6 pb-6", children: [
|
|
33
|
-
lastItems.map((item, idx) => /* @__PURE__ */ jsx(ActivityItem, { item }, idx)),
|
|
34
|
-
/* @__PURE__ */ jsx(CollapsibleActivityItemList, { items: collapsibleItems }),
|
|
35
|
-
/* @__PURE__ */ jsx(ActivityItem, { item: firstItem, isFirst: true }, items.length - 1)
|
|
36
|
-
] });
|
|
37
|
-
};
|
|
38
|
-
const CollapsibleActivityItemList = ({
|
|
39
|
-
items
|
|
40
|
-
}) => {
|
|
41
|
-
const [open, setOpen] = useState(false);
|
|
42
|
-
return /* @__PURE__ */ jsxs(Collapsible.Root, { open, onOpenChange: setOpen, children: [
|
|
43
|
-
!open && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
|
|
44
|
-
/* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y bg-clip-content" }) }),
|
|
45
|
-
/* @__PURE__ */ jsx(Collapsible.Trigger, { className: "text-left p-0 m-0 pb-4 text-ui-fg-muted hover:text-ui-fg-base focus:text-ui-fg-base outline-none transition-colors", children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: `Show ${items.length} more ${items.length === 1 ? "activity" : "activities"}` }) })
|
|
46
|
-
] }),
|
|
47
|
-
/* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-0.5", children: items.map((item, idx) => {
|
|
48
|
-
return /* @__PURE__ */ jsx(ActivityItem, { item }, idx);
|
|
49
|
-
}) }) })
|
|
50
|
-
] });
|
|
51
|
-
};
|
|
52
|
-
const ActivityItem = ({ item, isFirst = false }) => {
|
|
53
|
-
const { user, isPending, isError, error } = useUser(item.userId, void 0, {
|
|
54
|
-
enabled: !!item.userId
|
|
55
|
-
});
|
|
56
|
-
if (isError) {
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
const isUserLoaded = !isPending && !!user && !!item.userId;
|
|
60
|
-
return /* @__PURE__ */ jsxs(
|
|
61
|
-
"div",
|
|
62
|
-
{
|
|
63
|
-
className: clx("grid grid-cols-[20px_1fr] items-start gap-x-2 w-full"),
|
|
64
|
-
children: [
|
|
65
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-0.5 h-full", children: [
|
|
66
|
-
/* @__PURE__ */ jsx("div", { className: "size-5 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "size-2.5 rounded-full shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "size-1.5 rounded-full bg-ui-tag-neutral-icon" }) }) }),
|
|
67
|
-
!isFirst && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "h-full w-px bg-ui-border-base" }) })
|
|
68
|
-
] }),
|
|
69
|
-
/* @__PURE__ */ jsxs("div", { className: clx("flex flex-col", !isFirst && "pb-4"), children: [
|
|
70
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 justify-between", children: [
|
|
71
|
-
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.label }),
|
|
72
|
-
/* @__PURE__ */ jsx(
|
|
73
|
-
Tooltip,
|
|
74
|
-
{
|
|
75
|
-
content: getFullDate({ date: item.timestamp, includeTime: true }),
|
|
76
|
-
children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "cursor-default", children: getRelativeDate(item.timestamp) })
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
] }),
|
|
80
|
-
item.content && renderContent(item.content),
|
|
81
|
-
item.userId && /* @__PURE__ */ jsx("div", { className: "pt-2 text-ui-fg-muted", children: isUserLoaded ? /* @__PURE__ */ jsx(Link, { to: `/settings/users/${user.id}`, className: "w-fit", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1.5 w-fit", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(Text, { size: "small", children: "By" }),
|
|
83
|
-
/* @__PURE__ */ jsx(
|
|
84
|
-
Avatar,
|
|
85
|
-
{
|
|
86
|
-
size: "2xsmall",
|
|
87
|
-
fallback: [user.first_name, user.last_name].filter(Boolean).join("").slice(0, 1)
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
/* @__PURE__ */ jsxs(Text, { size: "small", children: [
|
|
91
|
-
user.first_name,
|
|
92
|
-
" ",
|
|
93
|
-
user.last_name
|
|
94
|
-
] })
|
|
95
|
-
] }) }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1.5", children: [
|
|
96
|
-
/* @__PURE__ */ jsx(Text, { size: "small", children: "By" }),
|
|
97
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "rounded-full w-5 h-5" }),
|
|
98
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "w-[75px] h-4" })
|
|
99
|
-
] }) })
|
|
100
|
-
] })
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
function renderContent(content) {
|
|
106
|
-
if (typeof content === "string") {
|
|
107
|
-
return /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: content });
|
|
108
|
-
}
|
|
109
|
-
return content;
|
|
110
|
-
}
|
|
111
|
-
function getEditActivityItems(change) {
|
|
112
|
-
const activityItems = [];
|
|
113
|
-
const counts = {
|
|
114
|
-
itemsAdded: 0,
|
|
115
|
-
itemsRemoved: 0,
|
|
116
|
-
shippingMethodsAdded: 0,
|
|
117
|
-
shippingMethodsRemoved: 0
|
|
118
|
-
};
|
|
119
|
-
for (const action of change.actions) {
|
|
120
|
-
if (!action.details) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
switch (action.action) {
|
|
124
|
-
case "ITEM_ADD":
|
|
125
|
-
counts.itemsAdded += action.details.quantity;
|
|
126
|
-
break;
|
|
127
|
-
case "ITEM_UPDATE":
|
|
128
|
-
const diff = action.details.quantity_diff;
|
|
129
|
-
diff > 0 ? counts.itemsAdded += diff : counts.itemsRemoved += diff;
|
|
130
|
-
break;
|
|
131
|
-
case "SHIPPING_ADD":
|
|
132
|
-
counts.shippingMethodsAdded += 1;
|
|
133
|
-
break;
|
|
134
|
-
case "SHIPPING_REMOVE":
|
|
135
|
-
counts.shippingMethodsRemoved += 1;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const createActivityItem = (type, added, removed) => {
|
|
140
|
-
if (added === 0 && removed === 0) return;
|
|
141
|
-
const getText = (count, singular, plural) => count === 1 ? `${count} ${singular}` : `${count} ${plural}`;
|
|
142
|
-
const addedText = getText(
|
|
143
|
-
added,
|
|
144
|
-
type === "items" ? "item" : "shipping method",
|
|
145
|
-
type === "items" ? "items" : "shipping methods"
|
|
146
|
-
);
|
|
147
|
-
const removedText = getText(
|
|
148
|
-
Math.abs(removed),
|
|
149
|
-
type === "items" ? "item" : "shipping method",
|
|
150
|
-
type === "items" ? "items" : "shipping methods"
|
|
151
|
-
);
|
|
152
|
-
const content = added && removed ? `Added ${addedText}, removed ${removedText}` : added ? `Added ${addedText}` : `Removed ${removedText}`;
|
|
153
|
-
const label = added && removed ? `${type === "items" ? "Items" : "Shipping methods"} updated` : added ? `${type === "items" ? "Items" : "Shipping methods"} added` : `${type === "items" ? "Items" : "Shipping methods"} removed`;
|
|
154
|
-
activityItems.push({
|
|
155
|
-
label,
|
|
156
|
-
content,
|
|
157
|
-
timestamp: new Date(change.created_at).toISOString(),
|
|
158
|
-
userId: change.confirmed_by
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
createActivityItem("items", counts.itemsAdded, counts.itemsRemoved);
|
|
162
|
-
createActivityItem(
|
|
163
|
-
"shipping",
|
|
164
|
-
counts.shippingMethodsAdded,
|
|
165
|
-
counts.shippingMethodsRemoved
|
|
166
|
-
);
|
|
167
|
-
return activityItems;
|
|
168
|
-
}
|
|
169
|
-
function getTransferActivityItem(change) {
|
|
170
|
-
return {
|
|
171
|
-
label: "Transferred",
|
|
172
|
-
content: "Draft order transferred",
|
|
173
|
-
timestamp: new Date(change.created_at).toISOString()
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function getActivityItems(order, changes) {
|
|
177
|
-
const items = [];
|
|
178
|
-
if (order.created_at) {
|
|
179
|
-
items.push({
|
|
180
|
-
label: "Created",
|
|
181
|
-
content: "Draft order created",
|
|
182
|
-
timestamp: new Date(order.created_at).toISOString()
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
changes.forEach((change) => {
|
|
186
|
-
if (!change.change_type || !change.confirmed_at) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
switch (change.change_type) {
|
|
190
|
-
case "edit": {
|
|
191
|
-
items.push(...getEditActivityItems(change));
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
case "transfer":
|
|
195
|
-
items.push(getTransferActivityItem(change));
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
return items.sort(
|
|
200
|
-
(a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
export {
|
|
204
|
-
ActivitySection
|
|
205
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { FlyingBox, CurrencyDollar, Envelope } from "@medusajs/icons";
|
|
3
|
-
import { Container, Heading, Text, Avatar, Copy } from "@medusajs/ui";
|
|
4
|
-
import { Link } from "react-router-dom";
|
|
5
|
-
import { isSameAddress, getFormattedAddress } from "../../lib/utils/address-utils.js";
|
|
6
|
-
import { ActionMenu } from "../common/action-menu.js";
|
|
7
|
-
const CustomerSection = ({ order }) => {
|
|
8
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0 divide-y", children: [
|
|
9
|
-
/* @__PURE__ */ jsx(Header, {}),
|
|
10
|
-
/* @__PURE__ */ jsx(ID, { order }),
|
|
11
|
-
/* @__PURE__ */ jsx(Contact, { order }),
|
|
12
|
-
/* @__PURE__ */ jsx(Addresses, { order })
|
|
13
|
-
] });
|
|
14
|
-
};
|
|
15
|
-
const Header = () => {
|
|
16
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4 gap-2", children: [
|
|
17
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Customer" }),
|
|
18
|
-
/* @__PURE__ */ jsx(
|
|
19
|
-
ActionMenu,
|
|
20
|
-
{
|
|
21
|
-
groups: [
|
|
22
|
-
{
|
|
23
|
-
actions: [
|
|
24
|
-
{
|
|
25
|
-
label: "Edit shipping address",
|
|
26
|
-
to: "shipping-address",
|
|
27
|
-
icon: /* @__PURE__ */ jsx(FlyingBox, {})
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: "Edit billing address",
|
|
31
|
-
to: "billing-address",
|
|
32
|
-
icon: /* @__PURE__ */ jsx(CurrencyDollar, {})
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
actions: [
|
|
38
|
-
{
|
|
39
|
-
label: "Edit email",
|
|
40
|
-
to: `email`,
|
|
41
|
-
icon: /* @__PURE__ */ jsx(Envelope, {})
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
] });
|
|
49
|
-
};
|
|
50
|
-
const ID = ({ order }) => {
|
|
51
|
-
const id = order.customer_id;
|
|
52
|
-
const name = getOrderCustomer(order);
|
|
53
|
-
const email = order.email;
|
|
54
|
-
const fallback = (name || email || "").charAt(0).toUpperCase();
|
|
55
|
-
return /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
56
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: "ID" }),
|
|
57
|
-
/* @__PURE__ */ jsx(
|
|
58
|
-
Link,
|
|
59
|
-
{
|
|
60
|
-
to: `/customers/${id}`,
|
|
61
|
-
className: "focus:shadow-borders-focus rounded-[4px] outline-none transition-shadow",
|
|
62
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
63
|
-
/* @__PURE__ */ jsx(Avatar, { size: "2xsmall", fallback }),
|
|
64
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
65
|
-
Text,
|
|
66
|
-
{
|
|
67
|
-
size: "small",
|
|
68
|
-
leading: "compact",
|
|
69
|
-
className: "text-ui-fg-subtle hover:text-ui-fg-base transition-fg truncate",
|
|
70
|
-
children: name || email
|
|
71
|
-
}
|
|
72
|
-
) })
|
|
73
|
-
] })
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
] });
|
|
77
|
-
};
|
|
78
|
-
const Contact = ({ order }) => {
|
|
79
|
-
var _a, _b;
|
|
80
|
-
const phone = ((_a = order.shipping_address) == null ? void 0 : _a.phone) || ((_b = order.billing_address) == null ? void 0 : _b.phone);
|
|
81
|
-
const email = order.email || "";
|
|
82
|
-
return /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
|
|
83
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: "Contact" }),
|
|
84
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
85
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
|
|
86
|
-
/* @__PURE__ */ jsx(
|
|
87
|
-
Text,
|
|
88
|
-
{
|
|
89
|
-
size: "small",
|
|
90
|
-
leading: "compact",
|
|
91
|
-
className: "text-pretty break-all",
|
|
92
|
-
children: email
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Copy, { content: email, className: "text-ui-fg-muted" }) })
|
|
96
|
-
] }),
|
|
97
|
-
phone && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
|
|
98
|
-
/* @__PURE__ */ jsx(
|
|
99
|
-
Text,
|
|
100
|
-
{
|
|
101
|
-
size: "small",
|
|
102
|
-
leading: "compact",
|
|
103
|
-
className: "text-pretty break-all",
|
|
104
|
-
children: phone
|
|
105
|
-
}
|
|
106
|
-
),
|
|
107
|
-
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Copy, { content: email, className: "text-ui-fg-muted" }) })
|
|
108
|
-
] })
|
|
109
|
-
] })
|
|
110
|
-
] });
|
|
111
|
-
};
|
|
112
|
-
const AddressPrint = ({
|
|
113
|
-
address,
|
|
114
|
-
type
|
|
115
|
-
}) => {
|
|
116
|
-
return /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
|
|
117
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: type === "shipping" ? "Shipping address" : "Billing address" }),
|
|
118
|
-
address ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
|
|
119
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: getFormattedAddress(address).map((line, i) => {
|
|
120
|
-
return /* @__PURE__ */ jsxs("span", { className: "break-words", children: [
|
|
121
|
-
line,
|
|
122
|
-
/* @__PURE__ */ jsx("br", {})
|
|
123
|
-
] }, i);
|
|
124
|
-
}) }),
|
|
125
|
-
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
126
|
-
Copy,
|
|
127
|
-
{
|
|
128
|
-
content: getFormattedAddress(address).join("\n"),
|
|
129
|
-
className: "text-ui-fg-muted"
|
|
130
|
-
}
|
|
131
|
-
) })
|
|
132
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "-" })
|
|
133
|
-
] });
|
|
134
|
-
};
|
|
135
|
-
const Addresses = ({ order }) => {
|
|
136
|
-
return /* @__PURE__ */ jsxs("div", { className: "divide-y", children: [
|
|
137
|
-
/* @__PURE__ */ jsx(AddressPrint, { address: order.shipping_address, type: "shipping" }),
|
|
138
|
-
!isSameAddress(order.shipping_address, order.billing_address) ? /* @__PURE__ */ jsx(AddressPrint, { address: order.billing_address, type: "billing" }) : /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-center px-6 py-4", children: [
|
|
139
|
-
/* @__PURE__ */ jsx(
|
|
140
|
-
Text,
|
|
141
|
-
{
|
|
142
|
-
size: "small",
|
|
143
|
-
leading: "compact",
|
|
144
|
-
weight: "plus",
|
|
145
|
-
className: "text-ui-fg-subtle",
|
|
146
|
-
children: "Billing address"
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: "Same as shipping address" })
|
|
150
|
-
] })
|
|
151
|
-
] });
|
|
152
|
-
};
|
|
153
|
-
function getOrderCustomer(obj) {
|
|
154
|
-
const { first_name: sFirstName, last_name: sLastName } = obj.shipping_address || {};
|
|
155
|
-
const { first_name: bFirstName, last_name: bLastName } = obj.billing_address || {};
|
|
156
|
-
const { first_name: cFirstName, last_name: cLastName } = obj.customer || {};
|
|
157
|
-
const customerName = [cFirstName, cLastName].filter(Boolean).join(" ");
|
|
158
|
-
const shippingName = [sFirstName, sLastName].filter(Boolean).join(" ");
|
|
159
|
-
const billingName = [bFirstName, bLastName].filter(Boolean).join(" ");
|
|
160
|
-
const name = customerName || shippingName || billingName;
|
|
161
|
-
return name;
|
|
162
|
-
}
|
|
163
|
-
export {
|
|
164
|
-
CustomerSection
|
|
165
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Container, Heading, Copy, Badge, Skeleton, Text } from "@medusajs/ui";
|
|
3
|
-
import { Link } from "react-router-dom";
|
|
4
|
-
import { useRegion } from "../../hooks/api/regions.js";
|
|
5
|
-
import { getFullDate } from "../../lib/utils/date-utils.js";
|
|
6
|
-
const GeneralSection = ({ order }) => {
|
|
7
|
-
var _a;
|
|
8
|
-
const { region, isPending, isError, error } = useRegion(
|
|
9
|
-
order.region_id,
|
|
10
|
-
void 0,
|
|
11
|
-
{
|
|
12
|
-
enabled: !!order.region_id
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
const isRegionLoaded = !!region && !isPending;
|
|
16
|
-
if (isError) {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
return /* @__PURE__ */ jsx(Container, { className: "flex items-center justify-between gap-4", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
20
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
21
|
-
/* @__PURE__ */ jsxs(Heading, { children: [
|
|
22
|
-
"Draft Order #",
|
|
23
|
-
order.display_id
|
|
24
|
-
] }),
|
|
25
|
-
/* @__PURE__ */ jsx(Copy, { content: `#${order.display_id}` }),
|
|
26
|
-
isRegionLoaded ? /* @__PURE__ */ jsx(Badge, { size: "2xsmall", rounded: "full", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: `/settings/regions/${region == null ? void 0 : region.id}`, children: region == null ? void 0 : region.name }) }) : /* @__PURE__ */ jsx(Skeleton, { className: "w-14 h-5 rounded-full" })
|
|
27
|
-
] }),
|
|
28
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: `${getFullDate({
|
|
29
|
-
date: order.created_at,
|
|
30
|
-
includeTime: true
|
|
31
|
-
})} from ${(_a = order.sales_channel) == null ? void 0 : _a.name}` })
|
|
32
|
-
] }) });
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
GeneralSection
|
|
36
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowUpRightOnBox, XMarkMini, TriangleDownMini, Check, SquareTwoStack } from "@medusajs/icons";
|
|
3
|
-
import { Container, Heading, Badge, Drawer, IconButton, Kbd } from "@medusajs/ui";
|
|
4
|
-
import Primitive from "@uiw/react-json-view";
|
|
5
|
-
import { Suspense, useState } from "react";
|
|
6
|
-
const JsonViewSection = ({ data }) => {
|
|
7
|
-
const numberOfKeys = Object.keys(data).length;
|
|
8
|
-
return /* @__PURE__ */ jsxs(Container, { className: "flex items-center justify-between px-6 py-4", children: [
|
|
9
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
10
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "JSON" }),
|
|
11
|
-
/* @__PURE__ */ jsx(Badge, { size: "2xsmall", rounded: "full", children: `${numberOfKeys} ${numberOfKeys === 1 ? "key" : "keys"}` })
|
|
12
|
-
] }),
|
|
13
|
-
/* @__PURE__ */ jsxs(Drawer, { children: [
|
|
14
|
-
/* @__PURE__ */ jsx(Drawer.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
15
|
-
IconButton,
|
|
16
|
-
{
|
|
17
|
-
size: "small",
|
|
18
|
-
variant: "transparent",
|
|
19
|
-
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
20
|
-
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {})
|
|
21
|
-
}
|
|
22
|
-
) }),
|
|
23
|
-
/* @__PURE__ */ jsxs(Drawer.Content, { className: "bg-ui-contrast-bg-base text-ui-code-fg-subtle !shadow-elevation-commandbar overflow-hidden border border-none max-md:inset-x-2 max-md:max-w-[calc(100%-16px)]", children: [
|
|
24
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-code-bg-base flex items-center justify-between px-6 py-4", children: [
|
|
25
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
26
|
-
/* @__PURE__ */ jsx(Drawer.Title, { asChild: true, children: /* @__PURE__ */ jsxs(Heading, { className: "text-ui-contrast-fg-primary", children: [
|
|
27
|
-
"JSON",
|
|
28
|
-
" ",
|
|
29
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle", children: numberOfKeys }, "count-span")
|
|
30
|
-
] }) }),
|
|
31
|
-
/* @__PURE__ */ jsx(Drawer.Description, { className: "sr-only", children: "View the JSON representation of the draft order." })
|
|
32
|
-
] }),
|
|
33
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
34
|
-
/* @__PURE__ */ jsx(Kbd, { className: "bg-ui-contrast-bg-subtle border-ui-contrast-border-base text-ui-contrast-fg-secondary", children: "esc" }),
|
|
35
|
-
/* @__PURE__ */ jsx(Drawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
36
|
-
IconButton,
|
|
37
|
-
{
|
|
38
|
-
size: "small",
|
|
39
|
-
variant: "transparent",
|
|
40
|
-
className: "text-ui-contrast-fg-secondary hover:text-ui-contrast-fg-primary hover:bg-ui-contrast-bg-base-hover active:bg-ui-contrast-bg-base-pressed focus-visible:bg-ui-contrast-bg-base-hover focus-visible:shadow-borders-interactive-with-active",
|
|
41
|
-
children: /* @__PURE__ */ jsx(XMarkMini, {})
|
|
42
|
-
}
|
|
43
|
-
) })
|
|
44
|
-
] })
|
|
45
|
-
] }),
|
|
46
|
-
/* @__PURE__ */ jsx(Drawer.Body, { className: "flex flex-1 flex-col overflow-hidden px-[5px] py-0 pb-[5px]", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-contrast-bg-subtle flex-1 overflow-auto rounded-b-[4px] rounded-t-lg p-3", children: /* @__PURE__ */ jsx(
|
|
47
|
-
Suspense,
|
|
48
|
-
{
|
|
49
|
-
fallback: /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col" }),
|
|
50
|
-
children: /* @__PURE__ */ jsxs(
|
|
51
|
-
Primitive,
|
|
52
|
-
{
|
|
53
|
-
value: data,
|
|
54
|
-
displayDataTypes: false,
|
|
55
|
-
style: {
|
|
56
|
-
"--w-rjv-font-family": "Roboto Mono, monospace",
|
|
57
|
-
"--w-rjv-line-color": "var(--contrast-border-base)",
|
|
58
|
-
"--w-rjv-curlybraces-color": "var(--contrast-fg-secondary)",
|
|
59
|
-
"--w-rjv-brackets-color": "var(--contrast-fg-secondary)",
|
|
60
|
-
"--w-rjv-key-string": "var(--contrast-fg-primary)",
|
|
61
|
-
"--w-rjv-info-color": "var(--contrast-fg-secondary)",
|
|
62
|
-
"--w-rjv-type-string-color": "var(--tag-green-icon)",
|
|
63
|
-
"--w-rjv-quotes-string-color": "var(--tag-green-icon)",
|
|
64
|
-
"--w-rjv-type-boolean-color": "var(--tag-orange-icon)",
|
|
65
|
-
"--w-rjv-type-int-color": "var(--tag-orange-icon)",
|
|
66
|
-
"--w-rjv-type-float-color": "var(--tag-orange-icon)",
|
|
67
|
-
"--w-rjv-type-bigint-color": "var(--tag-orange-icon)",
|
|
68
|
-
"--w-rjv-key-number": "var(--contrast-fg-secondary)",
|
|
69
|
-
"--w-rjv-arrow-color": "var(--contrast-fg-secondary)",
|
|
70
|
-
"--w-rjv-copied-color": "var(--contrast-fg-secondary)",
|
|
71
|
-
"--w-rjv-copied-success-color": "var(--contrast-fg-primary)",
|
|
72
|
-
"--w-rjv-colon-color": "var(--contrast-fg-primary)",
|
|
73
|
-
"--w-rjv-ellipsis-color": "var(--contrast-fg-secondary)"
|
|
74
|
-
},
|
|
75
|
-
collapsed: 1,
|
|
76
|
-
children: [
|
|
77
|
-
/* @__PURE__ */ jsx(Primitive.Quote, { render: () => /* @__PURE__ */ jsx("span", {}) }),
|
|
78
|
-
/* @__PURE__ */ jsx(
|
|
79
|
-
Primitive.Null,
|
|
80
|
-
{
|
|
81
|
-
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-red-icon", children: "null" })
|
|
82
|
-
}
|
|
83
|
-
),
|
|
84
|
-
/* @__PURE__ */ jsx(
|
|
85
|
-
Primitive.Undefined,
|
|
86
|
-
{
|
|
87
|
-
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-blue-icon", children: "undefined" })
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
/* @__PURE__ */ jsx(
|
|
91
|
-
Primitive.CountInfo,
|
|
92
|
-
{
|
|
93
|
-
render: (_props, { value }) => {
|
|
94
|
-
return /* @__PURE__ */ jsx("span", { className: "text-ui-contrast-fg-secondary ml-2", children: `${Object.keys(value).length} ${Object.keys(value).length === 1 ? "key" : "keys"}` });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
),
|
|
98
|
-
/* @__PURE__ */ jsx(Primitive.Arrow, { children: /* @__PURE__ */ jsx(TriangleDownMini, { className: "text-ui-contrast-fg-secondary -ml-[0.5px]" }) }),
|
|
99
|
-
/* @__PURE__ */ jsx(Primitive.Colon, { children: /* @__PURE__ */ jsx("span", { className: "mr-1", children: ":" }) }),
|
|
100
|
-
/* @__PURE__ */ jsx(
|
|
101
|
-
Primitive.Copied,
|
|
102
|
-
{
|
|
103
|
-
render: ({ style }, { value }) => {
|
|
104
|
-
return /* @__PURE__ */ jsx(Copied, { style, value });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
) }) })
|
|
113
|
-
] })
|
|
114
|
-
] })
|
|
115
|
-
] });
|
|
116
|
-
};
|
|
117
|
-
const Copied = ({ style, value }) => {
|
|
118
|
-
const [copied, setCopied] = useState(false);
|
|
119
|
-
const handler = (e) => {
|
|
120
|
-
e.stopPropagation();
|
|
121
|
-
setCopied(true);
|
|
122
|
-
if (typeof value === "string") {
|
|
123
|
-
navigator.clipboard.writeText(value);
|
|
124
|
-
} else {
|
|
125
|
-
const json = JSON.stringify(value, null, 2);
|
|
126
|
-
navigator.clipboard.writeText(json);
|
|
127
|
-
}
|
|
128
|
-
setTimeout(() => {
|
|
129
|
-
setCopied(false);
|
|
130
|
-
}, 2e3);
|
|
131
|
-
};
|
|
132
|
-
const styl = { whiteSpace: "nowrap", width: "20px" };
|
|
133
|
-
if (copied) {
|
|
134
|
-
return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, children: /* @__PURE__ */ jsx(Check, { className: "text-ui-contrast-fg-primary" }) });
|
|
135
|
-
}
|
|
136
|
-
return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, onClick: handler, children: /* @__PURE__ */ jsx(SquareTwoStack, { className: "text-ui-contrast-fg-secondary" }) });
|
|
137
|
-
};
|
|
138
|
-
export {
|
|
139
|
-
JsonViewSection
|
|
140
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowUpRightOnBox } from "@medusajs/icons";
|
|
3
|
-
import { Container, Heading, Badge, IconButton } from "@medusajs/ui";
|
|
4
|
-
import { Link } from "react-router-dom";
|
|
5
|
-
const MetadataSection = ({ order }) => {
|
|
6
|
-
return /* @__PURE__ */ jsxs(Container, { className: "flex items-center justify-between", children: [
|
|
7
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
8
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Metadata" }),
|
|
9
|
-
/* @__PURE__ */ jsxs(Badge, { size: "2xsmall", rounded: "full", children: [
|
|
10
|
-
Object.keys(order.metadata || {}).length,
|
|
11
|
-
" keys"
|
|
12
|
-
] })
|
|
13
|
-
] }),
|
|
14
|
-
/* @__PURE__ */ jsx(
|
|
15
|
-
IconButton,
|
|
16
|
-
{
|
|
17
|
-
variant: "transparent",
|
|
18
|
-
size: "small",
|
|
19
|
-
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
20
|
-
asChild: true,
|
|
21
|
-
children: /* @__PURE__ */ jsx(Link, { to: "metadata", children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {}) })
|
|
22
|
-
}
|
|
23
|
-
)
|
|
24
|
-
] });
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
MetadataSection
|
|
28
|
-
};
|