@open-mercato/core 0.4.2-canary-cae9dafa24 → 0.4.2-canary-f6b7824b47
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/dist/modules/api_docs/backend/docs/page.js +1 -4
- package/dist/modules/api_docs/backend/docs/page.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +0 -4
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/sales/acl.js +1 -3
- package/dist/modules/sales/acl.js.map +2 -2
- package/package.json +2 -2
- package/src/modules/api_docs/backend/docs/page.tsx +1 -2
- package/src/modules/auth/lib/setup-app.ts +0 -4
- package/src/modules/customers/README.md +1 -2
- package/src/modules/entities/README.md +1 -1
- package/src/modules/sales/acl.ts +0 -2
- package/src/modules/sales/i18n/de.json +1 -32
- package/src/modules/sales/i18n/en.json +1 -32
- package/src/modules/sales/i18n/es.json +1 -32
- package/src/modules/sales/i18n/pl.json +1 -32
- package/dist/modules/sales/api/dashboard/widgets/new-orders/route.js +0 -163
- package/dist/modules/sales/api/dashboard/widgets/new-orders/route.js.map +0 -7
- package/dist/modules/sales/api/dashboard/widgets/new-quotes/route.js +0 -165
- package/dist/modules/sales/api/dashboard/widgets/new-quotes/route.js.map +0 -7
- package/dist/modules/sales/api/dashboard/widgets/utils.js +0 -38
- package/dist/modules/sales/api/dashboard/widgets/utils.js.map +0 -7
- package/dist/modules/sales/lib/customerSnapshot.js +0 -21
- package/dist/modules/sales/lib/customerSnapshot.js.map +0 -7
- package/dist/modules/sales/lib/dateRange.js +0 -39
- package/dist/modules/sales/lib/dateRange.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-orders/config.js +0 -32
- package/dist/modules/sales/widgets/dashboard/new-orders/config.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js +0 -252
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.js +0 -33
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-quotes/config.js +0 -32
- package/dist/modules/sales/widgets/dashboard/new-quotes/config.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js +0 -272
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.js +0 -33
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.js.map +0 -7
- package/src/modules/sales/api/dashboard/widgets/new-orders/__tests__/route.test.ts +0 -60
- package/src/modules/sales/api/dashboard/widgets/new-orders/route.ts +0 -192
- package/src/modules/sales/api/dashboard/widgets/new-quotes/__tests__/route.test.ts +0 -61
- package/src/modules/sales/api/dashboard/widgets/new-quotes/route.ts +0 -194
- package/src/modules/sales/api/dashboard/widgets/utils.ts +0 -53
- package/src/modules/sales/lib/__tests__/dateRange.test.ts +0 -26
- package/src/modules/sales/lib/customerSnapshot.ts +0 -17
- package/src/modules/sales/lib/dateRange.ts +0 -42
- package/src/modules/sales/widgets/dashboard/new-orders/__tests__/config.test.ts +0 -28
- package/src/modules/sales/widgets/dashboard/new-orders/config.ts +0 -48
- package/src/modules/sales/widgets/dashboard/new-orders/widget.client.tsx +0 -295
- package/src/modules/sales/widgets/dashboard/new-orders/widget.ts +0 -33
- package/src/modules/sales/widgets/dashboard/new-quotes/__tests__/config.test.ts +0 -28
- package/src/modules/sales/widgets/dashboard/new-quotes/config.ts +0 -48
- package/src/modules/sales/widgets/dashboard/new-quotes/widget.client.tsx +0 -322
- package/src/modules/sales/widgets/dashboard/new-quotes/widget.ts +0 -33
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import Link from "next/link";
|
|
5
|
-
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
6
|
-
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
7
|
-
import { Badge } from "@open-mercato/ui/primitives/badge";
|
|
8
|
-
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
9
|
-
import {
|
|
10
|
-
DEFAULT_SETTINGS,
|
|
11
|
-
hydrateSalesNewOrdersSettings
|
|
12
|
-
} from "./config.js";
|
|
13
|
-
function formatCurrency(value, currency, locale) {
|
|
14
|
-
const amount = typeof value === "string" ? Number(value) : Number.NaN;
|
|
15
|
-
if (!Number.isFinite(amount)) return "\u2014";
|
|
16
|
-
const code = currency || "USD";
|
|
17
|
-
try {
|
|
18
|
-
return new Intl.NumberFormat(locale ?? void 0, { style: "currency", currency: code }).format(amount);
|
|
19
|
-
} catch {
|
|
20
|
-
return `${amount.toFixed(2)} ${code}`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function formatRelativeDate(value, locale) {
|
|
24
|
-
const date = new Date(value);
|
|
25
|
-
if (Number.isNaN(date.getTime())) return "";
|
|
26
|
-
const now = /* @__PURE__ */ new Date();
|
|
27
|
-
const diffMs = date.getTime() - now.getTime();
|
|
28
|
-
const absMs = Math.abs(diffMs);
|
|
29
|
-
const rtf = new Intl.RelativeTimeFormat(locale ?? void 0, { numeric: "auto" });
|
|
30
|
-
if (absMs < 60 * 1e3) {
|
|
31
|
-
return rtf.format(Math.round(diffMs / 1e3), "second");
|
|
32
|
-
}
|
|
33
|
-
if (absMs < 60 * 60 * 1e3) {
|
|
34
|
-
return rtf.format(Math.round(diffMs / (60 * 1e3)), "minute");
|
|
35
|
-
}
|
|
36
|
-
if (absMs < 24 * 60 * 60 * 1e3) {
|
|
37
|
-
return rtf.format(Math.round(diffMs / (60 * 60 * 1e3)), "hour");
|
|
38
|
-
}
|
|
39
|
-
return rtf.format(Math.round(diffMs / (24 * 60 * 60 * 1e3)), "day");
|
|
40
|
-
}
|
|
41
|
-
async function loadOrders(settings) {
|
|
42
|
-
const params = new URLSearchParams({
|
|
43
|
-
limit: String(settings.pageSize),
|
|
44
|
-
datePeriod: settings.datePeriod
|
|
45
|
-
});
|
|
46
|
-
if (settings.datePeriod === "custom") {
|
|
47
|
-
if (settings.customFrom) params.set("customFrom", settings.customFrom);
|
|
48
|
-
if (settings.customTo) params.set("customTo", settings.customTo);
|
|
49
|
-
}
|
|
50
|
-
const call = await apiCall(
|
|
51
|
-
`/api/sales/dashboard/widgets/new-orders?${params.toString()}`
|
|
52
|
-
);
|
|
53
|
-
if (!call.ok) {
|
|
54
|
-
const message = typeof call.result?.error === "string" ? call.result.error : `Request failed with status ${call.status}`;
|
|
55
|
-
throw new Error(message);
|
|
56
|
-
}
|
|
57
|
-
const payload = call.result ?? {};
|
|
58
|
-
const rawItems = Array.isArray(payload.items) ? payload.items : [];
|
|
59
|
-
return rawItems.map((item) => {
|
|
60
|
-
if (!item || typeof item !== "object") return null;
|
|
61
|
-
const data = item;
|
|
62
|
-
return {
|
|
63
|
-
id: typeof data.id === "string" ? data.id : null,
|
|
64
|
-
orderNumber: typeof data.orderNumber === "string" ? data.orderNumber : "",
|
|
65
|
-
status: typeof data.status === "string" ? data.status : null,
|
|
66
|
-
fulfillmentStatus: typeof data.fulfillmentStatus === "string" ? data.fulfillmentStatus : null,
|
|
67
|
-
paymentStatus: typeof data.paymentStatus === "string" ? data.paymentStatus : null,
|
|
68
|
-
customerName: typeof data.customerName === "string" ? data.customerName : null,
|
|
69
|
-
customerEntityId: typeof data.customerEntityId === "string" ? data.customerEntityId : null,
|
|
70
|
-
netAmount: typeof data.netAmount === "string" ? data.netAmount : "0",
|
|
71
|
-
grossAmount: typeof data.grossAmount === "string" ? data.grossAmount : "0",
|
|
72
|
-
currency: typeof data.currency === "string" ? data.currency : null,
|
|
73
|
-
createdAt: typeof data.createdAt === "string" ? data.createdAt : ""
|
|
74
|
-
};
|
|
75
|
-
}).filter((item) => !!item && !!item.id && !!item.createdAt);
|
|
76
|
-
}
|
|
77
|
-
const SalesNewOrdersWidget = ({
|
|
78
|
-
mode,
|
|
79
|
-
settings = DEFAULT_SETTINGS,
|
|
80
|
-
onSettingsChange,
|
|
81
|
-
refreshToken,
|
|
82
|
-
onRefreshStateChange
|
|
83
|
-
}) => {
|
|
84
|
-
const t = useT();
|
|
85
|
-
const hydrated = React.useMemo(() => hydrateSalesNewOrdersSettings(settings), [settings]);
|
|
86
|
-
const [items, setItems] = React.useState([]);
|
|
87
|
-
const [loading, setLoading] = React.useState(true);
|
|
88
|
-
const [error, setError] = React.useState(null);
|
|
89
|
-
const [locale, setLocale] = React.useState(void 0);
|
|
90
|
-
React.useEffect(() => {
|
|
91
|
-
if (typeof navigator !== "undefined") {
|
|
92
|
-
setLocale(navigator.language);
|
|
93
|
-
}
|
|
94
|
-
}, []);
|
|
95
|
-
const refresh = React.useCallback(async () => {
|
|
96
|
-
onRefreshStateChange?.(true);
|
|
97
|
-
setLoading(true);
|
|
98
|
-
setError(null);
|
|
99
|
-
try {
|
|
100
|
-
const data = await loadOrders(hydrated);
|
|
101
|
-
setItems(data);
|
|
102
|
-
} catch (err) {
|
|
103
|
-
console.error("Failed to load new orders widget data", err);
|
|
104
|
-
setError(t("sales.widgets.newOrders.error", "Failed to load orders"));
|
|
105
|
-
} finally {
|
|
106
|
-
setLoading(false);
|
|
107
|
-
onRefreshStateChange?.(false);
|
|
108
|
-
}
|
|
109
|
-
}, [hydrated, onRefreshStateChange, t]);
|
|
110
|
-
React.useEffect(() => {
|
|
111
|
-
refresh().catch(() => {
|
|
112
|
-
});
|
|
113
|
-
}, [refresh, refreshToken]);
|
|
114
|
-
if (mode === "settings") {
|
|
115
|
-
return /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
116
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
117
|
-
/* @__PURE__ */ jsx(
|
|
118
|
-
"label",
|
|
119
|
-
{
|
|
120
|
-
htmlFor: "sales-new-orders-page-size",
|
|
121
|
-
className: "text-xs font-semibold uppercase text-muted-foreground",
|
|
122
|
-
children: t("sales.widgets.newOrders.settings.pageSize", "Number of Orders")
|
|
123
|
-
}
|
|
124
|
-
),
|
|
125
|
-
/* @__PURE__ */ jsx(
|
|
126
|
-
"input",
|
|
127
|
-
{
|
|
128
|
-
id: "sales-new-orders-page-size",
|
|
129
|
-
type: "number",
|
|
130
|
-
min: 1,
|
|
131
|
-
max: 20,
|
|
132
|
-
className: "w-24 rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary",
|
|
133
|
-
value: hydrated.pageSize,
|
|
134
|
-
onChange: (event) => {
|
|
135
|
-
const next = Number(event.target.value);
|
|
136
|
-
const value = Number.isFinite(next) ? Math.min(20, Math.max(1, Math.floor(next))) : hydrated.pageSize;
|
|
137
|
-
onSettingsChange({ ...hydrated, pageSize: value });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
] }),
|
|
142
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
143
|
-
/* @__PURE__ */ jsx(
|
|
144
|
-
"label",
|
|
145
|
-
{
|
|
146
|
-
htmlFor: "sales-new-orders-date-period",
|
|
147
|
-
className: "text-xs font-semibold uppercase text-muted-foreground",
|
|
148
|
-
children: t("sales.widgets.newOrders.settings.datePeriod", "Date Period")
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
/* @__PURE__ */ jsxs(
|
|
152
|
-
"select",
|
|
153
|
-
{
|
|
154
|
-
id: "sales-new-orders-date-period",
|
|
155
|
-
className: "w-full rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary",
|
|
156
|
-
value: hydrated.datePeriod,
|
|
157
|
-
onChange: (event) => {
|
|
158
|
-
onSettingsChange({ ...hydrated, datePeriod: event.target.value });
|
|
159
|
-
},
|
|
160
|
-
children: [
|
|
161
|
-
/* @__PURE__ */ jsx("option", { value: "last24h", children: t("sales.widgets.newOrders.settings.last24h", "Last 24 hours") }),
|
|
162
|
-
/* @__PURE__ */ jsx("option", { value: "last7d", children: t("sales.widgets.newOrders.settings.last7d", "Last 7 days") }),
|
|
163
|
-
/* @__PURE__ */ jsx("option", { value: "last30d", children: t("sales.widgets.newOrders.settings.last30d", "Last 30 days") }),
|
|
164
|
-
/* @__PURE__ */ jsx("option", { value: "custom", children: t("sales.widgets.newOrders.settings.custom", "Custom range") })
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
] }),
|
|
169
|
-
hydrated.datePeriod === "custom" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
170
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
171
|
-
/* @__PURE__ */ jsx(
|
|
172
|
-
"label",
|
|
173
|
-
{
|
|
174
|
-
htmlFor: "sales-new-orders-custom-from",
|
|
175
|
-
className: "text-xs font-semibold uppercase text-muted-foreground",
|
|
176
|
-
children: t("sales.widgets.newOrders.settings.customFrom", "From")
|
|
177
|
-
}
|
|
178
|
-
),
|
|
179
|
-
/* @__PURE__ */ jsx(
|
|
180
|
-
"input",
|
|
181
|
-
{
|
|
182
|
-
id: "sales-new-orders-custom-from",
|
|
183
|
-
type: "date",
|
|
184
|
-
className: "w-full rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary",
|
|
185
|
-
value: hydrated.customFrom ?? "",
|
|
186
|
-
onChange: (event) => {
|
|
187
|
-
onSettingsChange({ ...hydrated, customFrom: event.target.value });
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
)
|
|
191
|
-
] }),
|
|
192
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
193
|
-
/* @__PURE__ */ jsx(
|
|
194
|
-
"label",
|
|
195
|
-
{
|
|
196
|
-
htmlFor: "sales-new-orders-custom-to",
|
|
197
|
-
className: "text-xs font-semibold uppercase text-muted-foreground",
|
|
198
|
-
children: t("sales.widgets.newOrders.settings.customTo", "To")
|
|
199
|
-
}
|
|
200
|
-
),
|
|
201
|
-
/* @__PURE__ */ jsx(
|
|
202
|
-
"input",
|
|
203
|
-
{
|
|
204
|
-
id: "sales-new-orders-custom-to",
|
|
205
|
-
type: "date",
|
|
206
|
-
className: "w-full rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary",
|
|
207
|
-
value: hydrated.customTo ?? "",
|
|
208
|
-
onChange: (event) => {
|
|
209
|
-
onSettingsChange({ ...hydrated, customTo: event.target.value });
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
)
|
|
213
|
-
] })
|
|
214
|
-
] }) : null
|
|
215
|
-
] });
|
|
216
|
-
}
|
|
217
|
-
if (error) {
|
|
218
|
-
return /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error });
|
|
219
|
-
}
|
|
220
|
-
if (loading) {
|
|
221
|
-
return /* @__PURE__ */ jsx("div", { className: "flex h-32 items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, { className: "h-6 w-6 text-muted-foreground" }) });
|
|
222
|
-
}
|
|
223
|
-
if (items.length === 0) {
|
|
224
|
-
return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("sales.widgets.newOrders.empty", "No orders found in this period") });
|
|
225
|
-
}
|
|
226
|
-
return /* @__PURE__ */ jsx("ul", { className: "space-y-3", children: items.map((order) => {
|
|
227
|
-
const createdLabel = formatRelativeDate(order.createdAt, locale);
|
|
228
|
-
return /* @__PURE__ */ jsx("li", { className: "rounded-md border p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
229
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
230
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
231
|
-
/* @__PURE__ */ jsx(
|
|
232
|
-
Link,
|
|
233
|
-
{
|
|
234
|
-
className: "text-sm font-medium text-foreground hover:underline",
|
|
235
|
-
href: `/backend/sales/orders/${encodeURIComponent(order.id)}`,
|
|
236
|
-
children: order.orderNumber
|
|
237
|
-
}
|
|
238
|
-
),
|
|
239
|
-
order.status ? /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-[11px]", children: order.status }) : null
|
|
240
|
-
] }),
|
|
241
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: order.customerName ?? t("sales.widgets.newOrders.noCustomer", "No customer") }),
|
|
242
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: createdLabel || t("sales.widgets.newOrders.unknownDate", "Unknown date") })
|
|
243
|
-
] }),
|
|
244
|
-
/* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: formatCurrency(order.grossAmount, order.currency, locale) }) })
|
|
245
|
-
] }) }, order.id);
|
|
246
|
-
}) });
|
|
247
|
-
};
|
|
248
|
-
var widget_client_default = SalesNewOrdersWidget;
|
|
249
|
-
export {
|
|
250
|
-
widget_client_default as default
|
|
251
|
-
};
|
|
252
|
-
//# sourceMappingURL=widget.client.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../src/modules/sales/widgets/dashboard/new-orders/widget.client.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n DEFAULT_SETTINGS,\n hydrateSalesNewOrdersSettings,\n type SalesNewOrdersSettings,\n} from './config'\nimport type { DatePeriodOption } from '../../../lib/dateRange'\n\ntype OrderItem = {\n id: string\n orderNumber: string\n status: string | null\n fulfillmentStatus: string | null\n paymentStatus: string | null\n customerName: string | null\n customerEntityId: string | null\n netAmount: string\n grossAmount: string\n currency: string | null\n createdAt: string\n}\n\nfunction formatCurrency(value: string | null, currency: string | null, locale?: string): string {\n const amount = typeof value === 'string' ? Number(value) : Number.NaN\n if (!Number.isFinite(amount)) return '\u2014'\n const code = currency || 'USD'\n try {\n return new Intl.NumberFormat(locale ?? undefined, { style: 'currency', currency: code }).format(amount)\n } catch {\n return `${amount.toFixed(2)} ${code}`\n }\n}\n\nfunction formatRelativeDate(value: string, locale?: string): string {\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return ''\n const now = new Date()\n const diffMs = date.getTime() - now.getTime()\n const absMs = Math.abs(diffMs)\n const rtf = new Intl.RelativeTimeFormat(locale ?? undefined, { numeric: 'auto' })\n if (absMs < 60 * 1000) {\n return rtf.format(Math.round(diffMs / 1000), 'second')\n }\n if (absMs < 60 * 60 * 1000) {\n return rtf.format(Math.round(diffMs / (60 * 1000)), 'minute')\n }\n if (absMs < 24 * 60 * 60 * 1000) {\n return rtf.format(Math.round(diffMs / (60 * 60 * 1000)), 'hour')\n }\n return rtf.format(Math.round(diffMs / (24 * 60 * 60 * 1000)), 'day')\n}\n\nasync function loadOrders(settings: SalesNewOrdersSettings): Promise<OrderItem[]> {\n const params = new URLSearchParams({\n limit: String(settings.pageSize),\n datePeriod: settings.datePeriod,\n })\n if (settings.datePeriod === 'custom') {\n if (settings.customFrom) params.set('customFrom', settings.customFrom)\n if (settings.customTo) params.set('customTo', settings.customTo)\n }\n const call = await apiCall<{ items?: unknown[]; error?: string }>(\n `/api/sales/dashboard/widgets/new-orders?${params.toString()}`,\n )\n if (!call.ok) {\n const message =\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\n ? ((call.result as Record<string, unknown>).error as string)\n : `Request failed with status ${call.status}`\n throw new Error(message)\n }\n const payload = call.result ?? {}\n const rawItems = Array.isArray((payload as { items?: unknown[] }).items)\n ? (payload as { items: unknown[] }).items\n : []\n return rawItems\n .map((item: unknown): OrderItem | null => {\n if (!item || typeof item !== 'object') return null\n const data = item as any\n return {\n id: typeof data.id === 'string' ? data.id : null,\n orderNumber: typeof data.orderNumber === 'string' ? data.orderNumber : '',\n status: typeof data.status === 'string' ? data.status : null,\n fulfillmentStatus: typeof data.fulfillmentStatus === 'string' ? data.fulfillmentStatus : null,\n paymentStatus: typeof data.paymentStatus === 'string' ? data.paymentStatus : null,\n customerName: typeof data.customerName === 'string' ? data.customerName : null,\n customerEntityId: typeof data.customerEntityId === 'string' ? data.customerEntityId : null,\n netAmount: typeof data.netAmount === 'string' ? data.netAmount : '0',\n grossAmount: typeof data.grossAmount === 'string' ? data.grossAmount : '0',\n currency: typeof data.currency === 'string' ? data.currency : null,\n createdAt: typeof data.createdAt === 'string' ? data.createdAt : '',\n }\n })\n .filter((item: OrderItem | null): item is OrderItem => !!item && !!item.id && !!item.createdAt)\n}\n\nconst SalesNewOrdersWidget: React.FC<DashboardWidgetComponentProps<SalesNewOrdersSettings>> = ({\n mode,\n settings = DEFAULT_SETTINGS,\n onSettingsChange,\n refreshToken,\n onRefreshStateChange,\n}) => {\n const t = useT()\n const hydrated = React.useMemo(() => hydrateSalesNewOrdersSettings(settings), [settings])\n const [items, setItems] = React.useState<OrderItem[]>([])\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\n\n React.useEffect(() => {\n if (typeof navigator !== 'undefined') {\n setLocale(navigator.language)\n }\n }, [])\n\n const refresh = React.useCallback(async () => {\n onRefreshStateChange?.(true)\n setLoading(true)\n setError(null)\n try {\n const data = await loadOrders(hydrated)\n setItems(data)\n } catch (err) {\n console.error('Failed to load new orders widget data', err)\n setError(t('sales.widgets.newOrders.error', 'Failed to load orders'))\n } finally {\n setLoading(false)\n onRefreshStateChange?.(false)\n }\n }, [hydrated, onRefreshStateChange, t])\n\n React.useEffect(() => {\n refresh().catch(() => {})\n }, [refresh, refreshToken])\n\n if (mode === 'settings') {\n return (\n <div className=\"space-y-4 text-sm\">\n <div className=\"space-y-1.5\">\n <label\n htmlFor=\"sales-new-orders-page-size\"\n className=\"text-xs font-semibold uppercase text-muted-foreground\"\n >\n {t('sales.widgets.newOrders.settings.pageSize', 'Number of Orders')}\n </label>\n <input\n id=\"sales-new-orders-page-size\"\n type=\"number\"\n min={1}\n max={20}\n className=\"w-24 rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={hydrated.pageSize}\n onChange={(event) => {\n const next = Number(event.target.value)\n const value = Number.isFinite(next)\n ? Math.min(20, Math.max(1, Math.floor(next)))\n : hydrated.pageSize\n onSettingsChange({ ...hydrated, pageSize: value })\n }}\n />\n </div>\n <div className=\"space-y-1.5\">\n <label\n htmlFor=\"sales-new-orders-date-period\"\n className=\"text-xs font-semibold uppercase text-muted-foreground\"\n >\n {t('sales.widgets.newOrders.settings.datePeriod', 'Date Period')}\n </label>\n <select\n id=\"sales-new-orders-date-period\"\n className=\"w-full rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={hydrated.datePeriod}\n onChange={(event) => {\n onSettingsChange({ ...hydrated, datePeriod: event.target.value as DatePeriodOption })\n }}\n >\n <option value=\"last24h\">{t('sales.widgets.newOrders.settings.last24h', 'Last 24 hours')}</option>\n <option value=\"last7d\">{t('sales.widgets.newOrders.settings.last7d', 'Last 7 days')}</option>\n <option value=\"last30d\">{t('sales.widgets.newOrders.settings.last30d', 'Last 30 days')}</option>\n <option value=\"custom\">{t('sales.widgets.newOrders.settings.custom', 'Custom range')}</option>\n </select>\n </div>\n {hydrated.datePeriod === 'custom' ? (\n <>\n <div className=\"space-y-1.5\">\n <label\n htmlFor=\"sales-new-orders-custom-from\"\n className=\"text-xs font-semibold uppercase text-muted-foreground\"\n >\n {t('sales.widgets.newOrders.settings.customFrom', 'From')}\n </label>\n <input\n id=\"sales-new-orders-custom-from\"\n type=\"date\"\n className=\"w-full rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={hydrated.customFrom ?? ''}\n onChange={(event) => {\n onSettingsChange({ ...hydrated, customFrom: event.target.value })\n }}\n />\n </div>\n <div className=\"space-y-1.5\">\n <label\n htmlFor=\"sales-new-orders-custom-to\"\n className=\"text-xs font-semibold uppercase text-muted-foreground\"\n >\n {t('sales.widgets.newOrders.settings.customTo', 'To')}\n </label>\n <input\n id=\"sales-new-orders-custom-to\"\n type=\"date\"\n className=\"w-full rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={hydrated.customTo ?? ''}\n onChange={(event) => {\n onSettingsChange({ ...hydrated, customTo: event.target.value })\n }}\n />\n </div>\n </>\n ) : null}\n </div>\n )\n }\n\n if (error) {\n return <p className=\"text-sm text-destructive\">{error}</p>\n }\n\n if (loading) {\n return (\n <div className=\"flex h-32 items-center justify-center\">\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n )\n }\n\n if (items.length === 0) {\n return (\n <p className=\"text-sm text-muted-foreground\">\n {t('sales.widgets.newOrders.empty', 'No orders found in this period')}\n </p>\n )\n }\n\n return (\n <ul className=\"space-y-3\">\n {items.map((order) => {\n const createdLabel = formatRelativeDate(order.createdAt, locale)\n return (\n <li key={order.id} className=\"rounded-md border p-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <Link\n className=\"text-sm font-medium text-foreground hover:underline\"\n href={`/backend/sales/orders/${encodeURIComponent(order.id)}`}\n >\n {order.orderNumber}\n </Link>\n {order.status ? (\n <Badge variant=\"outline\" className=\"text-[11px]\">\n {order.status}\n </Badge>\n ) : null}\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {order.customerName ?? t('sales.widgets.newOrders.noCustomer', 'No customer')}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {createdLabel || t('sales.widgets.newOrders.unknownDate', 'Unknown date')}\n </p>\n </div>\n <div className=\"text-right\">\n <p className=\"text-sm font-semibold\">\n {formatCurrency(order.grossAmount, order.currency, locale)}\n </p>\n </div>\n </div>\n </li>\n )\n })}\n </ul>\n )\n}\n\nexport default SalesNewOrdersWidget\n"],
|
|
5
|
-
"mappings": ";AAmJQ,SA6CE,UA5CA,KADF;AAjJR,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAiBP,SAAS,eAAe,OAAsB,UAAyB,QAAyB;AAC9F,QAAM,SAAS,OAAO,UAAU,WAAW,OAAO,KAAK,IAAI,OAAO;AAClE,MAAI,CAAC,OAAO,SAAS,MAAM,EAAG,QAAO;AACrC,QAAM,OAAO,YAAY;AACzB,MAAI;AACF,WAAO,IAAI,KAAK,aAAa,UAAU,QAAW,EAAE,OAAO,YAAY,UAAU,KAAK,CAAC,EAAE,OAAO,MAAM;AAAA,EACxG,QAAQ;AACN,WAAO,GAAG,OAAO,QAAQ,CAAC,CAAC,IAAI,IAAI;AAAA,EACrC;AACF;AAEA,SAAS,mBAAmB,OAAe,QAAyB;AAClE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,SAAS,KAAK,QAAQ,IAAI,IAAI,QAAQ;AAC5C,QAAM,QAAQ,KAAK,IAAI,MAAM;AAC7B,QAAM,MAAM,IAAI,KAAK,mBAAmB,UAAU,QAAW,EAAE,SAAS,OAAO,CAAC;AAChF,MAAI,QAAQ,KAAK,KAAM;AACrB,WAAO,IAAI,OAAO,KAAK,MAAM,SAAS,GAAI,GAAG,QAAQ;AAAA,EACvD;AACA,MAAI,QAAQ,KAAK,KAAK,KAAM;AAC1B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T_SETTINGS,
|
|
4
|
-
hydrateSalesNewOrdersSettings
|
|
5
|
-
} from "./config.js";
|
|
6
|
-
const widget = {
|
|
7
|
-
metadata: {
|
|
8
|
-
id: "sales.dashboard.newOrders",
|
|
9
|
-
title: "New Orders",
|
|
10
|
-
description: "Displays recently created sales orders.",
|
|
11
|
-
features: ["dashboards.view", "sales.widgets.new-orders"],
|
|
12
|
-
defaultSize: "md",
|
|
13
|
-
defaultEnabled: true,
|
|
14
|
-
defaultSettings: DEFAULT_SETTINGS,
|
|
15
|
-
tags: ["sales", "orders"],
|
|
16
|
-
category: "sales",
|
|
17
|
-
icon: "lucide:shopping-cart",
|
|
18
|
-
supportsRefresh: true
|
|
19
|
-
},
|
|
20
|
-
Widget: SalesNewOrdersWidget,
|
|
21
|
-
hydrateSettings: hydrateSalesNewOrdersSettings,
|
|
22
|
-
dehydrateSettings: (settings) => ({
|
|
23
|
-
pageSize: settings.pageSize,
|
|
24
|
-
datePeriod: settings.datePeriod,
|
|
25
|
-
customFrom: settings.customFrom,
|
|
26
|
-
customTo: settings.customTo
|
|
27
|
-
})
|
|
28
|
-
};
|
|
29
|
-
var widget_default = widget;
|
|
30
|
-
export {
|
|
31
|
-
widget_default as default
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=widget.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../src/modules/sales/widgets/dashboard/new-orders/widget.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DashboardWidgetModule } from '@open-mercato/shared/modules/dashboard/widgets'\nimport SalesNewOrdersWidget from './widget.client'\nimport {\n DEFAULT_SETTINGS,\n hydrateSalesNewOrdersSettings,\n type SalesNewOrdersSettings,\n} from './config'\n\nconst widget: DashboardWidgetModule<SalesNewOrdersSettings> = {\n metadata: {\n id: 'sales.dashboard.newOrders',\n title: 'New Orders',\n description: 'Displays recently created sales orders.',\n features: ['dashboards.view', 'sales.widgets.new-orders'],\n defaultSize: 'md',\n defaultEnabled: true,\n defaultSettings: DEFAULT_SETTINGS,\n tags: ['sales', 'orders'],\n category: 'sales',\n icon: 'lucide:shopping-cart',\n supportsRefresh: true,\n },\n Widget: SalesNewOrdersWidget,\n hydrateSettings: hydrateSalesNewOrdersSettings,\n dehydrateSettings: (settings) => ({\n pageSize: settings.pageSize,\n datePeriod: settings.datePeriod,\n customFrom: settings.customFrom,\n customTo: settings.customTo,\n }),\n}\n\nexport default widget\n"],
|
|
5
|
-
"mappings": "AACA,OAAO,0BAA0B;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,MAAM,SAAwD;AAAA,EAC5D,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU,CAAC,mBAAmB,0BAA0B;AAAA,IACxD,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,MAAM,CAAC,SAAS,QAAQ;AAAA,IACxB,UAAU;AAAA,IACV,MAAM;AAAA,IACN,iBAAiB;AAAA,EACnB;AAAA,EACA,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,mBAAmB,CAAC,cAAc;AAAA,IAChC,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,IACrB,YAAY,SAAS;AAAA,IACrB,UAAU,SAAS;AAAA,EACrB;AACF;AAEA,IAAO,iBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const DEFAULT_SETTINGS = {
|
|
2
|
-
pageSize: 5,
|
|
3
|
-
datePeriod: "last24h"
|
|
4
|
-
};
|
|
5
|
-
function hydrateSalesNewQuotesSettings(raw) {
|
|
6
|
-
if (!raw || typeof raw !== "object") return { ...DEFAULT_SETTINGS };
|
|
7
|
-
const input = raw;
|
|
8
|
-
const parsedPageSize = Number(input.pageSize);
|
|
9
|
-
const pageSize = Number.isFinite(parsedPageSize) ? Math.min(20, Math.max(1, Math.floor(parsedPageSize))) : DEFAULT_SETTINGS.pageSize;
|
|
10
|
-
const datePeriod = input.datePeriod === "last24h" || input.datePeriod === "last7d" || input.datePeriod === "last30d" || input.datePeriod === "custom" ? input.datePeriod : DEFAULT_SETTINGS.datePeriod;
|
|
11
|
-
let customFrom;
|
|
12
|
-
let customTo;
|
|
13
|
-
if (datePeriod === "custom") {
|
|
14
|
-
if (typeof input.customFrom === "string" && !Number.isNaN(new Date(input.customFrom).getTime())) {
|
|
15
|
-
customFrom = input.customFrom;
|
|
16
|
-
}
|
|
17
|
-
if (typeof input.customTo === "string" && !Number.isNaN(new Date(input.customTo).getTime())) {
|
|
18
|
-
customTo = input.customTo;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
pageSize,
|
|
23
|
-
datePeriod,
|
|
24
|
-
customFrom,
|
|
25
|
-
customTo
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
DEFAULT_SETTINGS,
|
|
30
|
-
hydrateSalesNewQuotesSettings
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../src/modules/sales/widgets/dashboard/new-quotes/config.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DatePeriodOption } from '../../../lib/dateRange'\n\nexport type SalesNewQuotesSettings = {\n pageSize: number\n datePeriod: DatePeriodOption\n customFrom?: string\n customTo?: string\n}\n\nexport const DEFAULT_SETTINGS: SalesNewQuotesSettings = {\n pageSize: 5,\n datePeriod: 'last24h',\n}\n\nexport function hydrateSalesNewQuotesSettings(raw: unknown): SalesNewQuotesSettings {\n if (!raw || typeof raw !== 'object') return { ...DEFAULT_SETTINGS }\n const input = raw as Partial<SalesNewQuotesSettings>\n const parsedPageSize = Number(input.pageSize)\n const pageSize = Number.isFinite(parsedPageSize)\n ? Math.min(20, Math.max(1, Math.floor(parsedPageSize)))\n : DEFAULT_SETTINGS.pageSize\n\n const datePeriod: DatePeriodOption =\n input.datePeriod === 'last24h' ||\n input.datePeriod === 'last7d' ||\n input.datePeriod === 'last30d' ||\n input.datePeriod === 'custom'\n ? input.datePeriod\n : DEFAULT_SETTINGS.datePeriod\n\n let customFrom: string | undefined\n let customTo: string | undefined\n if (datePeriod === 'custom') {\n if (typeof input.customFrom === 'string' && !Number.isNaN(new Date(input.customFrom).getTime())) {\n customFrom = input.customFrom\n }\n if (typeof input.customTo === 'string' && !Number.isNaN(new Date(input.customTo).getTime())) {\n customTo = input.customTo\n }\n }\n\n return {\n pageSize,\n datePeriod,\n customFrom,\n customTo,\n }\n}\n"],
|
|
5
|
-
"mappings": "AASO,MAAM,mBAA2C;AAAA,EACtD,UAAU;AAAA,EACV,YAAY;AACd;AAEO,SAAS,8BAA8B,KAAsC;AAClF,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO,EAAE,GAAG,iBAAiB;AAClE,QAAM,QAAQ;AACd,QAAM,iBAAiB,OAAO,MAAM,QAAQ;AAC5C,QAAM,WAAW,OAAO,SAAS,cAAc,IAC3C,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,cAAc,CAAC,CAAC,IACpD,iBAAiB;AAErB,QAAM,aACJ,MAAM,eAAe,aACrB,MAAM,eAAe,YACrB,MAAM,eAAe,aACrB,MAAM,eAAe,WACjB,MAAM,aACN,iBAAiB;AAEvB,MAAI;AACJ,MAAI;AACJ,MAAI,eAAe,UAAU;AAC3B,QAAI,OAAO,MAAM,eAAe,YAAY,CAAC,OAAO,MAAM,IAAI,KAAK,MAAM,UAAU,EAAE,QAAQ,CAAC,GAAG;AAC/F,mBAAa,MAAM;AAAA,IACrB;AACA,QAAI,OAAO,MAAM,aAAa,YAAY,CAAC,OAAO,MAAM,IAAI,KAAK,MAAM,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAC3F,iBAAW,MAAM;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|