@plumile/backoffice-react 0.1.150 → 0.1.152

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.
Files changed (36) hide show
  1. package/lib/esm/auth/authRefreshNotice.css.js +1 -0
  2. package/lib/esm/auth/login/loginPage.css.js +1 -0
  3. package/lib/esm/components/backoffice/actions/BackofficeEntityActionFormDialog.js +192 -144
  4. package/lib/esm/components/backoffice/actions/BackofficeEntityActionFormDialog.js.map +1 -1
  5. package/lib/esm/components/backoffice/billing/backofficeBillingUsageChart.css.js +0 -1
  6. package/lib/esm/components/backoffice/filters/backofficeFilterAction.css.js +1 -0
  7. package/lib/esm/components/backoffice/layout/backofficeSidebarActions.css.js +0 -1
  8. package/lib/esm/components/backoffice/list/RowFlagsCell.css.js +0 -1
  9. package/lib/esm/pages/BackofficeDashboardPage.js +73 -244
  10. package/lib/esm/pages/BackofficeDashboardPage.js.map +1 -1
  11. package/lib/esm/pages/BackofficeDashboardWidgetContent.js +193 -0
  12. package/lib/esm/pages/BackofficeDashboardWidgetContent.js.map +1 -0
  13. package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js +8 -10
  14. package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js.map +1 -1
  15. package/lib/esm/pages/BackofficeEntityDetailPage.js +130 -133
  16. package/lib/esm/pages/BackofficeEntityDetailPage.js.map +1 -1
  17. package/lib/esm/pages/BackofficeEntityDetailUnknownPageRedirect.js +10 -9
  18. package/lib/esm/pages/BackofficeEntityDetailUnknownPageRedirect.js.map +1 -1
  19. package/lib/esm/pages/BackofficeEntityListPage.helpers.js +5 -5
  20. package/lib/esm/pages/BackofficeEntityListPage.helpers.js.map +1 -1
  21. package/lib/esm/pages/BackofficeRedirect.js +13 -0
  22. package/lib/esm/pages/BackofficeRedirect.js.map +1 -0
  23. package/lib/esm/router/createBackofficeRoutes.js +100 -97
  24. package/lib/esm/router/createBackofficeRoutes.js.map +1 -1
  25. package/lib/types/components/backoffice/actions/BackofficeEntityActionFormDialog.d.ts.map +1 -1
  26. package/lib/types/pages/BackofficeDashboardPage.d.ts.map +1 -1
  27. package/lib/types/pages/BackofficeDashboardWidgetContent.d.ts +9 -0
  28. package/lib/types/pages/BackofficeDashboardWidgetContent.d.ts.map +1 -0
  29. package/lib/types/pages/BackofficeEntityDetailLayoutPage.d.ts.map +1 -1
  30. package/lib/types/pages/BackofficeEntityDetailPage.d.ts.map +1 -1
  31. package/lib/types/pages/BackofficeEntityDetailUnknownPageRedirect.d.ts.map +1 -1
  32. package/lib/types/pages/BackofficeRedirect.d.ts +7 -0
  33. package/lib/types/pages/BackofficeRedirect.d.ts.map +1 -0
  34. package/lib/types/router/createBackofficeRoutes.d.ts +3 -1
  35. package/lib/types/router/createBackofficeRoutes.d.ts.map +1 -1
  36. package/package.json +11 -11
@@ -1,273 +1,102 @@
1
1
  import { useBackofficeReactTranslation as e } from "../i18n/useBackofficeReactTranslation.js";
2
2
  import { useBackofficeConfig as t } from "../provider/BackofficeConfigContext.js";
3
3
  import { BackofficeErrorBoundary as n } from "../components/backoffice/errors/BackofficeErrorBoundary.js";
4
- import { BackofficeBillingUsageChart as r } from "../components/backoffice/billing/BackofficeBillingUsageChart.js";
5
- import { buildDataTableColumns as i } from "../components/backoffice/columns/buildDataTableColumns.js";
6
- import { BackofficeRightPageLayout as a } from "../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js";
7
- import { buildDashboardBreadcrumb as o } from "../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js";
8
- import { useBackofficeDashboardConfig as s } from "../provider/useBackofficeLazyValue.js";
9
- import { getWidgetLabel as c, hasWidgetQuery as l, resolveLabel as u } from "./BackofficeDashboardPage.helpers.js";
10
- import { loadingBody as d, tileBody as f, tileCount as p } from "./backofficeDashboardPage.css.js";
11
- import { Suspense as m } from "react";
12
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
- import { useTranslation as _ } from "react-i18next";
14
- import * as v from "react-relay";
15
- import { Spinner as y } from "@plumile/ui/backoffice/atoms/spinner/Spinner.js";
16
- import { BackofficeEmptyState as b } from "@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js";
17
- import { DetailPageTemplate as x } from "@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js";
18
- import { DashboardMetricGroup as S } from "@plumile/ui/components/dashboard/dashboard_metric_group/DashboardMetricGroup.js";
19
- import { DashboardPanel as C } from "@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js";
20
- import { DashboardQuickActions as w } from "@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js";
21
- import { DashboardStatusList as T } from "@plumile/ui/components/dashboard/dashboard_status_list/DashboardStatusList.js";
22
- import { DashboardGrid as E, DashboardGridItem as D } from "@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js";
23
- import { DataTable as O } from "@plumile/ui/components/data-table/DataTable.js";
4
+ import { BackofficeRightPageLayout as r } from "../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js";
5
+ import { buildDashboardBreadcrumb as i } from "../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js";
6
+ import { useBackofficeDashboardConfig as a } from "../provider/useBackofficeLazyValue.js";
7
+ import { getWidgetLabel as o, resolveLabel as s } from "./BackofficeDashboardPage.helpers.js";
8
+ import { loadingBody as c, tileBody as l, tileCount as u } from "./backofficeDashboardPage.css.js";
9
+ import { Suspense as d, lazy as f } from "react";
10
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
11
+ import { useTranslation as h } from "react-i18next";
12
+ import * as g from "react-relay";
13
+ import { Spinner as _ } from "@plumile/ui/backoffice/atoms/spinner/Spinner.js";
14
+ import { BackofficeEmptyState as v } from "@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js";
15
+ import { DetailPageTemplate as y } from "@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js";
16
+ import { DashboardPanel as b } from "@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js";
17
+ import { DashboardQuickActions as x } from "@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js";
18
+ import { DashboardGrid as S, DashboardGridItem as C } from "@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js";
24
19
  //#region src/pages/BackofficeDashboardPage.tsx
25
- var { useLazyLoadQuery: k } = v, A = () => {
20
+ var { useLazyLoadQuery: w } = g, T = f(async () => ({ default: (await import("./BackofficeDashboardWidgetContent.js")).BackofficeDashboardWidgetContent })), E = () => {
26
21
  let { t } = e();
27
- return /* @__PURE__ */ h(b, { title: t("common.notAvailable") });
28
- }, j = () => {
22
+ return /* @__PURE__ */ p(v, { title: t("common.notAvailable") });
23
+ }, D = () => {
29
24
  let { t } = e();
30
- return /* @__PURE__ */ g("div", {
31
- className: d,
32
- children: [/* @__PURE__ */ h(y, { ariaLabel: t("common.loading") }), /* @__PURE__ */ h("span", { children: t("common.loading") })]
25
+ return /* @__PURE__ */ m("div", {
26
+ className: c,
27
+ children: [/* @__PURE__ */ p(_, { ariaLabel: t("common.loading") }), /* @__PURE__ */ p("span", { children: t("common.loading") })]
33
28
  });
34
- }, M = (e) => e ?? "m", N = (e) => {
29
+ }, O = (e) => e ?? "m", k = (e) => {
35
30
  if (e.layout?.span != null) return e.layout.span;
36
- let t = M(e.size);
31
+ let t = O(e.size);
37
32
  return t === "s" ? 3 : t === "m" ? 4 : t === "l" ? 6 : t === "xl" ? 8 : 12;
38
- }, P = (e) => e.layout?.tabletSpan, F = ({ widget: n, globalData: a }) => {
39
- let { t: o } = _(), { t: s } = e(), { entities: c } = t(), l = n.description == null ? void 0 : u(n.description, o), d = (e) => "resolve" in n && n.resolve != null ? n.resolve(e) : null;
40
- if (n.kind === "textBlock") return /* @__PURE__ */ h(C, {
41
- title: u(n.title, o),
42
- subtitle: l,
43
- children: /* @__PURE__ */ h("div", {
44
- className: f,
45
- children: u(n.body, o)
46
- })
47
- });
48
- if (n.kind === "shortcut") {
49
- let e = c[n.entityId], t = u(n.label, o);
50
- return e == null ? /* @__PURE__ */ h(C, {
51
- title: t,
52
- subtitle: l,
53
- children: /* @__PURE__ */ h(A, {})
54
- }) : e.kind === "tool" ? /* @__PURE__ */ h(C, {
55
- title: t,
56
- subtitle: l,
57
- children: /* @__PURE__ */ h(w, { actions: [{
58
- id: e.id,
59
- href: e.routes.list,
60
- label: s("dashboard.actions.openTool")
61
- }] })
62
- }) : /* @__PURE__ */ h(C, {
63
- title: t,
64
- subtitle: l,
65
- children: /* @__PURE__ */ h(w, { actions: [{
66
- id: e.id,
67
- href: e.routes.list,
68
- label: s("dashboard.actions.openList")
69
- }] })
70
- });
71
- }
72
- if (n.kind === "tablePreview") {
73
- let e = d(a);
74
- if (e == null) return /* @__PURE__ */ h(C, {
75
- title: u(n.title, o),
76
- subtitle: l,
77
- children: /* @__PURE__ */ h(A, {})
78
- });
79
- let t = i(e.columns, {
80
- tApp: o,
81
- t: s
82
- });
83
- return /* @__PURE__ */ h(C, {
84
- title: u(n.title, o),
85
- subtitle: l,
86
- children: /* @__PURE__ */ h(O, {
87
- columns: t,
88
- rows: e.rows,
89
- getRowId: (e, t) => {
90
- if (typeof e == "object" && e) {
91
- let { id: t } = e;
92
- if (typeof t == "string" && t.trim() !== "") return t;
93
- }
94
- return String(t);
95
- }
96
- })
97
- });
98
- }
99
- if (n.kind === "metricGroup") {
100
- let e = d(a);
101
- return e == null ? /* @__PURE__ */ h(A, {}) : /* @__PURE__ */ h(S, {
102
- emptyState: /* @__PURE__ */ h(A, {}),
103
- metrics: e.map((e) => ({
104
- id: e.id,
105
- href: e.href,
106
- label: u(e.label, o),
107
- value: e.value ?? s("common.notAvailable"),
108
- hint: e.meta == null ? void 0 : u(e.meta, o)
109
- }))
110
- });
111
- }
112
- if (n.kind === "billingUsageChart") {
113
- let e = d(a), t = u(n.title, o);
114
- return e == null ? /* @__PURE__ */ h(C, {
115
- title: t,
116
- subtitle: l,
117
- children: /* @__PURE__ */ h(A, {})
118
- }) : /* @__PURE__ */ h(C, {
119
- title: t,
120
- subtitle: l,
121
- children: /* @__PURE__ */ h(r, {
122
- ariaLabel: u(n.ariaLabel, o),
123
- buckets: e.buckets,
124
- categories: n.categories.map((e) => ({
125
- id: e.id,
126
- label: u(e.label, o),
127
- color: e.color
128
- })),
129
- currency: e.currency,
130
- emptyLabel: u(n.emptyLabel, o),
131
- from: e.from,
132
- rangePrefix: u(n.rangePrefix, o),
133
- to: e.to,
134
- totalAmount: e.totalAmount
135
- })
136
- });
137
- }
138
- if (n.kind === "quickActions") return /* @__PURE__ */ h(C, {
139
- title: n.title == null ? s("dashboard.actions.openTool") : u(n.title, o),
140
- subtitle: l,
141
- children: /* @__PURE__ */ h(w, {
142
- layout: n.layout?.zone === "aside" ? "stack" : "grid",
143
- emptyState: /* @__PURE__ */ h(A, {}),
144
- actions: n.actions.map((e) => ({
145
- id: e.id,
146
- href: e.href,
147
- label: u(e.label, o)
148
- }))
149
- })
150
- });
151
- if (n.kind === "statusSummary") {
152
- let e = d(a);
153
- return e == null ? /* @__PURE__ */ h(C, {
154
- title: n.title == null ? void 0 : u(n.title, o),
155
- subtitle: l,
156
- children: /* @__PURE__ */ h(A, {})
157
- }) : /* @__PURE__ */ h(C, {
158
- title: n.title == null ? void 0 : u(n.title, o),
159
- subtitle: l,
160
- children: /* @__PURE__ */ h(T, {
161
- emptyState: /* @__PURE__ */ h(A, {}),
162
- items: e.map((e) => ({
163
- id: e.id,
164
- href: e.href,
165
- label: u(e.label, o),
166
- value: e.value ?? s("common.notAvailable")
167
- }))
168
- })
169
- });
170
- }
171
- if (n.kind === "recentItems") return /* @__PURE__ */ h(C, {
172
- title: n.title == null ? s("dashboard.title") : u(n.title, o),
173
- subtitle: l,
174
- children: /* @__PURE__ */ h(A, {})
175
- });
176
- let m = c[n.entityId];
177
- if (m?.kind !== "list-detail") return /* @__PURE__ */ h(C, {
178
- title: u(n.label, o),
179
- subtitle: l,
180
- children: /* @__PURE__ */ h(A, {})
181
- });
182
- let v = d(a), y = s("common.notAvailable");
183
- return typeof v?.count == "number" && (y = v.count), /* @__PURE__ */ h(C, {
184
- title: u(n.label, o),
185
- subtitle: l,
186
- children: /* @__PURE__ */ g("div", {
187
- className: f,
188
- children: [/* @__PURE__ */ h("div", {
189
- className: p,
190
- children: y
191
- }), /* @__PURE__ */ h(w, {
192
- emptyState: /* @__PURE__ */ h(A, {}),
193
- actions: [{
194
- id: m.id,
195
- href: m.routes.list,
196
- label: s("dashboard.actions.openList")
197
- }]
198
- })]
199
- })
200
- });
201
- }, I = ({ widget: e }) => /* @__PURE__ */ h(F, {
202
- widget: e,
203
- globalData: k(e.query, {}, { fetchPolicy: "store-or-network" })
204
- }), L = ({ config: t, globalData: r }) => {
205
- let { t: i } = _(), { t: a } = e();
206
- return /* @__PURE__ */ h(x, {
33
+ }, A = (e) => e.layout?.tabletSpan, j = ({ config: t, globalData: r }) => {
34
+ let { t: i } = h(), { t: a } = e();
35
+ return /* @__PURE__ */ p(y, {
207
36
  header: {
208
- title: u(t.title, i),
209
- subtitle: (t.subtitle == null ? void 0 : u(t.subtitle, i)) ?? a("dashboard.subtitle")
37
+ title: s(t.title, i),
38
+ subtitle: (t.subtitle == null ? void 0 : s(t.subtitle, i)) ?? a("dashboard.subtitle")
210
39
  },
211
- children: /* @__PURE__ */ h(E, {
40
+ children: /* @__PURE__ */ p(S, {
212
41
  columns: 12,
213
42
  children: t.widgets.map((e) => {
214
- let a = u(c(e, t), i), o = l(e) ? /* @__PURE__ */ h(I, { widget: e }) : /* @__PURE__ */ h(F, {
215
- widget: e,
216
- globalData: r
217
- });
218
- return /* @__PURE__ */ h(D, {
43
+ let a = s(o(e, t), i);
44
+ return /* @__PURE__ */ p(C, {
219
45
  minHeight: e.minHeight ?? "auto",
220
- span: N(e),
221
- tabletSpan: P(e),
222
- children: /* @__PURE__ */ h(n, {
223
- fallback: () => /* @__PURE__ */ h(C, {
46
+ span: k(e),
47
+ tabletSpan: A(e),
48
+ children: /* @__PURE__ */ p(n, {
49
+ fallback: () => /* @__PURE__ */ p(b, {
224
50
  title: a,
225
- children: /* @__PURE__ */ h(A, {})
51
+ children: /* @__PURE__ */ p(E, {})
226
52
  }),
227
- children: /* @__PURE__ */ h(m, {
228
- fallback: /* @__PURE__ */ h(C, {
53
+ children: /* @__PURE__ */ p(d, {
54
+ fallback: /* @__PURE__ */ p(b, {
229
55
  title: a,
230
- children: /* @__PURE__ */ h(j, {})
56
+ children: /* @__PURE__ */ p(D, {})
231
57
  }),
232
- children: o
58
+ children: /* @__PURE__ */ p(T, {
59
+ widget: e,
60
+ globalData: r
61
+ })
233
62
  })
234
63
  })
235
64
  }, e.id);
236
65
  })
237
66
  })
238
67
  });
239
- }, R = ({ config: e }) => /* @__PURE__ */ h(L, {
68
+ }, M = ({ config: e }) => /* @__PURE__ */ p(j, {
240
69
  config: e,
241
- globalData: k(e.query, {}, { fetchPolicy: "store-or-network" })
242
- }), z = ({ prepared: n }) => {
243
- let { t: r } = _(), { t: i } = e(), { entities: c } = t(), l = s(), d = n?.config ?? l, m = o(i);
244
- if (d == null) {
245
- let e = Object.values(c).filter((e) => e.kind === "list-detail" && e.hasList).map((e) => ({
70
+ globalData: w(e.query, {}, { fetchPolicy: "store-or-network" })
71
+ }), N = ({ prepared: n }) => {
72
+ let { t: o } = h(), { t: c } = e(), { entities: d } = t(), f = a(), g = n?.config ?? f, _ = i(c);
73
+ if (g == null) {
74
+ let e = Object.values(d).filter((e) => e.kind === "list-detail" && e.hasList).map((e) => ({
246
75
  config: e,
247
- label: u(e.label, r)
76
+ label: s(e.label, o)
248
77
  })).sort((e, t) => e.label.localeCompare(t.label));
249
- return /* @__PURE__ */ h(a, {
250
- breadcrumb: m,
251
- children: /* @__PURE__ */ h(x, {
78
+ return /* @__PURE__ */ p(r, {
79
+ breadcrumb: _,
80
+ children: /* @__PURE__ */ p(y, {
252
81
  header: {
253
- title: i("dashboard.title"),
254
- subtitle: i("dashboard.subtitle")
82
+ title: c("dashboard.title"),
83
+ subtitle: c("dashboard.subtitle")
255
84
  },
256
- children: /* @__PURE__ */ h(E, {
85
+ children: /* @__PURE__ */ p(S, {
257
86
  columns: 12,
258
- children: e.map(({ config: e, label: t }) => /* @__PURE__ */ h(D, {
87
+ children: e.map(({ config: e, label: t }) => /* @__PURE__ */ p(C, {
259
88
  span: 4,
260
- children: /* @__PURE__ */ h(C, {
89
+ children: /* @__PURE__ */ p(b, {
261
90
  title: t,
262
- children: /* @__PURE__ */ g("div", {
263
- className: f,
264
- children: [/* @__PURE__ */ h("div", {
265
- className: p,
266
- children: i("common.notAvailable")
267
- }), /* @__PURE__ */ h(w, { actions: [{
91
+ children: /* @__PURE__ */ m("div", {
92
+ className: l,
93
+ children: [/* @__PURE__ */ p("div", {
94
+ className: u,
95
+ children: c("common.notAvailable")
96
+ }), /* @__PURE__ */ p(x, { actions: [{
268
97
  id: e.id,
269
98
  href: e.routes.list,
270
- label: i("dashboard.actions.openList")
99
+ label: c("dashboard.actions.openList")
271
100
  }] })]
272
101
  })
273
102
  })
@@ -276,18 +105,18 @@ var { useLazyLoadQuery: k } = v, A = () => {
276
105
  })
277
106
  });
278
107
  }
279
- return d.query == null ? /* @__PURE__ */ h(a, {
280
- breadcrumb: m,
281
- children: /* @__PURE__ */ h(L, {
282
- config: d,
108
+ return g.query == null ? /* @__PURE__ */ p(r, {
109
+ breadcrumb: _,
110
+ children: /* @__PURE__ */ p(j, {
111
+ config: g,
283
112
  globalData: null
284
113
  })
285
- }) : /* @__PURE__ */ h(a, {
286
- breadcrumb: m,
287
- children: /* @__PURE__ */ h(R, { config: d })
114
+ }) : /* @__PURE__ */ p(r, {
115
+ breadcrumb: _,
116
+ children: /* @__PURE__ */ p(M, { config: g })
288
117
  });
289
118
  };
290
119
  //#endregion
291
- export { z as BackofficeDashboardPage, z as default };
120
+ export { N as BackofficeDashboardPage, N as default };
292
121
 
293
122
  //# sourceMappingURL=BackofficeDashboardPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BackofficeDashboardPage.js","names":[],"sources":["../../../src/pages/BackofficeDashboardPage.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX, Suspense } from 'react';\nimport type {\n BackofficeDashboardConfig,\n BackofficeDashboardWidget,\n BackofficeDashboardWidgetSpan,\n BackofficeDashboardWidgetTabletSpan,\n BackofficeDashboardWidgetSize,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport { Spinner } from '@plumile/ui/backoffice/atoms/spinner/Spinner.js';\nimport { BackofficeEmptyState } from '@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js';\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\nimport { DashboardMetricGroup } from '@plumile/ui/components/dashboard/dashboard_metric_group/DashboardMetricGroup.js';\nimport { DashboardPanel } from '@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js';\nimport { DashboardQuickActions } from '@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js';\nimport { DashboardStatusList } from '@plumile/ui/components/dashboard/dashboard_status_list/DashboardStatusList.js';\nimport {\n DashboardGrid,\n DashboardGridItem,\n} from '@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js';\nimport { DataTable } from '@plumile/ui/components/data-table/DataTable.js';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport type { GraphQLTaggedNode, OperationType } from 'relay-runtime';\n\nimport { BackofficeErrorBoundary } from '../components/backoffice/errors/BackofficeErrorBoundary.js';\nimport { BackofficeBillingUsageChart } from '../components/backoffice/billing/BackofficeBillingUsageChart.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { useBackofficeDashboardConfig } from '../provider/useBackofficeLazyValue.js';\nimport type { BackofficePreparedDashboardRoute } from '../router/createBackofficeRoutes.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildDashboardBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport {\n getWidgetLabel,\n hasWidgetQuery,\n resolveLabel,\n} from './BackofficeDashboardPage.helpers.js';\n\nimport * as styles from './backofficeDashboardPage.css.js';\n\nconst { useLazyLoadQuery } = ReactRelay;\n\ntype WidgetContentProps = {\n widget: BackofficeDashboardWidget;\n globalData: unknown;\n};\n\nconst DashboardUnavailableState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return <BackofficeEmptyState title={t('common.notAvailable')} />;\n};\n\nconst DashboardLoadingState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return (\n <div className={styles.loadingBody}>\n <Spinner ariaLabel={t('common.loading')} />\n <span>{t('common.loading')}</span>\n </div>\n );\n};\n\nconst resolveWidgetSize = (\n size: BackofficeDashboardWidgetSize | undefined,\n): BackofficeDashboardWidgetSize => {\n return size ?? 'm';\n};\n\nconst resolveWidgetSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetSpan => {\n if (widget.layout?.span != null) {\n return widget.layout.span;\n }\n\n const size = resolveWidgetSize(widget.size);\n if (size === 's') {\n return 3;\n }\n if (size === 'm') {\n return 4;\n }\n if (size === 'l') {\n return 6;\n }\n if (size === 'xl') {\n return 8;\n }\n return 12;\n};\n\nconst resolveWidgetTabletSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetTabletSpan | undefined => {\n return widget.layout?.tabletSpan;\n};\n\nconst WidgetContent = ({\n widget,\n globalData,\n}: WidgetContentProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const description =\n widget.description != null\n ? resolveLabel(widget.description, tApp)\n : undefined;\n\n const resolveData = (data: unknown): unknown => {\n if ('resolve' in widget && widget.resolve != null) {\n return widget.resolve(data);\n }\n return null;\n };\n\n if (widget.kind === 'textBlock') {\n const title = resolveLabel(widget.title, tApp);\n const body = resolveLabel(widget.body, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>{body}</div>\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'shortcut') {\n const entity = entities[widget.entityId];\n const title = resolveLabel(widget.label, tApp);\n if (entity == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n if (entity.kind === 'tool') {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openTool'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'tablePreview') {\n const resolved = resolveData(globalData) as {\n columns: readonly unknown[];\n rows: readonly unknown[];\n } | null;\n if (resolved == null) {\n return (\n <DashboardPanel\n title={resolveLabel(widget.title, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const columns = buildDataTableColumns(resolved.columns as never, {\n tApp,\n t,\n });\n const title = resolveLabel(widget.title, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DataTable\n columns={columns}\n rows={resolved.rows}\n getRowId={(row, index) => {\n if (row != null && typeof row === 'object') {\n const record = row as Record<string, unknown>;\n const { id } = record;\n if (typeof id === 'string' && id.trim() !== '') {\n return id;\n }\n }\n return String(index);\n }}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'metricGroup') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n meta?: I18nLabel;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n return <DashboardUnavailableState />;\n }\n return (\n <DashboardMetricGroup\n emptyState={<DashboardUnavailableState />}\n metrics={resolved.map((metric) => {\n return {\n id: metric.id,\n href: metric.href,\n label: resolveLabel(metric.label, tApp),\n value: metric.value ?? t('common.notAvailable'),\n hint:\n metric.meta != null ? resolveLabel(metric.meta, tApp) : undefined,\n };\n })}\n />\n );\n }\n\n if (widget.kind === 'billingUsageChart') {\n const resolved = resolveData(globalData) as {\n currency: string;\n totalAmount: number;\n from: string | null;\n to: string | null;\n buckets: readonly {\n day: string;\n category: string;\n value: number;\n }[];\n } | null;\n const title = resolveLabel(widget.title, tApp);\n if (resolved == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n return (\n <DashboardPanel title={title} subtitle={description}>\n <BackofficeBillingUsageChart\n ariaLabel={resolveLabel(widget.ariaLabel, tApp)}\n buckets={resolved.buckets}\n categories={widget.categories.map((category) => {\n return {\n id: category.id,\n label: resolveLabel(category.label, tApp),\n color: category.color,\n };\n })}\n currency={resolved.currency}\n emptyLabel={resolveLabel(widget.emptyLabel, tApp)}\n from={resolved.from}\n rangePrefix={resolveLabel(widget.rangePrefix, tApp)}\n to={resolved.to}\n totalAmount={resolved.totalAmount}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'quickActions') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.actions.openTool');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n layout={widget.layout?.zone === 'aside' ? 'stack' : 'grid'}\n emptyState={<DashboardUnavailableState />}\n actions={widget.actions.map((action) => {\n return {\n id: action.id,\n href: action.href,\n label: resolveLabel(action.label, tApp),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'statusSummary') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardStatusList\n emptyState={<DashboardUnavailableState />}\n items={resolved.map((item) => {\n return {\n id: item.id,\n href: item.href,\n label: resolveLabel(item.label, tApp),\n value: item.value ?? t('common.notAvailable'),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'recentItems') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.title');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n const entityManifest = entities[widget.entityId];\n if (entityManifest?.kind !== 'list-detail') {\n return (\n <DashboardPanel\n title={resolveLabel(widget.label, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const resolved = resolveData(globalData) as { count: number | null } | null;\n let countLabel: number | string = t('common.notAvailable');\n if (typeof resolved?.count === 'number') {\n countLabel = resolved.count;\n }\n const title = resolveLabel(widget.label, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>{countLabel}</div>\n <DashboardQuickActions\n emptyState={<DashboardUnavailableState />}\n actions={[\n {\n id: entityManifest.id,\n href: entityManifest.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n );\n};\n\ntype WidgetWithQueryProps = {\n widget: BackofficeDashboardWidget & { query: GraphQLTaggedNode };\n};\n\nconst WidgetWithQuery = ({ widget }: WidgetWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n widget.query,\n {},\n {\n fetchPolicy: 'store-or-network',\n },\n );\n\n return <WidgetContent widget={widget} globalData={data} />;\n};\n\ntype DashboardContentProps = {\n config: BackofficeDashboardConfig;\n globalData: unknown;\n};\n\nconst DashboardContent = ({\n config,\n globalData,\n}: DashboardContentProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n\n const title = resolveLabel(config.title, tApp);\n const subtitle =\n config.subtitle != null ? resolveLabel(config.subtitle, tApp) : undefined;\n\n return (\n <DetailPageTemplate\n header={{\n title,\n subtitle: subtitle ?? t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {config.widgets.map((widget) => {\n const widgetTitle = resolveLabel(\n getWidgetLabel(widget, config),\n tApp,\n );\n const content = hasWidgetQuery(widget) ? (\n <WidgetWithQuery widget={widget} />\n ) : (\n <WidgetContent widget={widget} globalData={globalData} />\n );\n\n return (\n <DashboardGridItem\n key={widget.id}\n minHeight={widget.minHeight ?? 'auto'}\n span={resolveWidgetSpan(widget)}\n tabletSpan={resolveWidgetTabletSpan(widget)}\n >\n <BackofficeErrorBoundary\n fallback={() => {\n return (\n <DashboardPanel title={widgetTitle}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }}\n >\n <Suspense\n fallback={\n <DashboardPanel title={widgetTitle}>\n <DashboardLoadingState />\n </DashboardPanel>\n }\n >\n {content}\n </Suspense>\n </BackofficeErrorBoundary>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n );\n};\n\ntype DashboardWithQueryProps = {\n config: BackofficeDashboardConfig;\n};\n\nconst DashboardWithQuery = ({\n config,\n}: DashboardWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n config.query as never,\n {},\n { fetchPolicy: 'store-or-network' },\n );\n\n return <DashboardContent config={config} globalData={data} />;\n};\n\nexport type BackofficeDashboardPageProps = {\n prepared?: BackofficePreparedDashboardRoute | null;\n};\n\nexport const BackofficeDashboardPage = ({\n prepared,\n}: BackofficeDashboardPageProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const rootDashboard = useBackofficeDashboardConfig();\n const dashboard = prepared?.config ?? rootDashboard;\n const breadcrumb = buildDashboardBreadcrumb(t);\n\n if (dashboard == null) {\n const items = Object.values(entities)\n .filter((config) => {\n return config.kind === 'list-detail' && config.hasList;\n })\n .map((config) => {\n return {\n config,\n label: resolveLabel(config.label, tApp),\n };\n })\n .sort((left, right) => {\n return left.label.localeCompare(right.label);\n });\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n header={{\n title: t('dashboard.title'),\n subtitle: t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {items.map(({ config, label }) => {\n return (\n <DashboardGridItem key={config.id} span={4}>\n <DashboardPanel title={label}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>\n {t('common.notAvailable')}\n </div>\n <DashboardQuickActions\n actions={[\n {\n id: config.id,\n href: config.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n );\n }\n\n if (dashboard.query != null) {\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardWithQuery config={dashboard} />\n </BackofficeRightPageLayout>\n );\n }\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardContent config={dashboard} globalData={null} />\n </BackofficeRightPageLayout>\n );\n};\n\nexport default BackofficeDashboardPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,EAAE,kBAAA,MAAqB,GAOvB,UAA+C;CACnD,IAAM,EAAE,MAAM,EAA8B;CAE5C,OAAO,kBAAC,GAAD,EAAsB,OAAO,EAAE,qBAAqB,EAAI,CAAA;AACjE,GAEM,UAA2C;CAC/C,IAAM,EAAE,MAAM,EAA8B;CAE5C,OACE,kBAAC,OAAD;EAAK,WAAW;YAAhB,CACE,kBAAC,GAAD,EAAS,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MACA,EAAO,SAAS,iBAAiB,EAAO,OAChD,EACA,KAAK,OACG;GACL;GACA,OAAO,EAAa,EAAO,OAAO,CAAI;EACxC,EACD,EACA,MAAM,GAAM,MACJ,EAAK,MAAM,cAAc,EAAM,KAAK,CAC5C;EAEH,OACE,kBAAC,GAAD;GAAuC;aACrC,kBAAC,GAAD;IACE,QAAQ;KACN,OAAO,EAAE,iBAAiB;KAC1B,UAAU,EAAE,oBAAoB;IAClC;cAEA,kBAAC,GAAD;KAAe,SAAS;eACrB,EAAM,KAAK,EAAE,WAAQ,eAElB,kBAAC,GAAD;MAAmC,MAAM;gBACvC,kBAAC,GAAD;OAAgB,OAAO;iBACrB,kBAAC,OAAD;QAAK,WAAW;kBAAhB,CACE,kBAAC,OAAD;SAAK,WAAW;mBACb,EAAE,qBAAqB;QACrB,CAAA,GACL,kBAAC,GAAD,EACE,SAAS,CACP;SACE,IAAI,EAAO;SACX,MAAM,EAAO,OAAO;SACpB,OAAO,EAAE,4BAA4B;QACvC,CACF,EACD,CAAA,CACE;;MACS,CAAA;KACC,GAjBK,EAAO,EAiBZ,CAEtB;IACY,CAAA;GACG,CAAA;EACK,CAAA;CAE/B;CAUA,OARI,EAAU,SAAS,OASrB,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD;GAAkB,QAAQ;GAAW,YAAY;EAAO,CAAA;CAC/B,CAAA,IATzB,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD,EAAoB,QAAQ,EAAY,CAAA;CACf,CAAA;AASjC"}
1
+ {"version":3,"file":"BackofficeDashboardPage.js","names":[],"sources":["../../../src/pages/BackofficeDashboardPage.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { lazy, type JSX, Suspense } from 'react';\nimport type {\n BackofficeDashboardConfig,\n BackofficeDashboardWidget,\n BackofficeDashboardWidgetSpan,\n BackofficeDashboardWidgetTabletSpan,\n BackofficeDashboardWidgetSize,\n} from '@plumile/backoffice-core/types.js';\nimport { Spinner } from '@plumile/ui/backoffice/atoms/spinner/Spinner.js';\nimport { BackofficeEmptyState } from '@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js';\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\nimport { DashboardPanel } from '@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js';\nimport { DashboardQuickActions } from '@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js';\nimport {\n DashboardGrid,\n DashboardGridItem,\n} from '@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport type { OperationType } from 'relay-runtime';\n\nimport { BackofficeErrorBoundary } from '../components/backoffice/errors/BackofficeErrorBoundary.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { useBackofficeDashboardConfig } from '../provider/useBackofficeLazyValue.js';\nimport type { BackofficePreparedDashboardRoute } from '../router/createBackofficeRoutes.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildDashboardBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport {\n getWidgetLabel,\n resolveLabel,\n} from './BackofficeDashboardPage.helpers.js';\n\nimport * as styles from './backofficeDashboardPage.css.js';\n\nconst { useLazyLoadQuery } = ReactRelay;\n\nconst LazyBackofficeDashboardWidgetContent = lazy(async () => {\n const module = await import('./BackofficeDashboardWidgetContent.js');\n return {\n default: module.BackofficeDashboardWidgetContent,\n };\n});\n\nconst DashboardUnavailableState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return <BackofficeEmptyState title={t('common.notAvailable')} />;\n};\n\nconst DashboardLoadingState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return (\n <div className={styles.loadingBody}>\n <Spinner ariaLabel={t('common.loading')} />\n <span>{t('common.loading')}</span>\n </div>\n );\n};\n\nconst resolveWidgetSize = (\n size: BackofficeDashboardWidgetSize | undefined,\n): BackofficeDashboardWidgetSize => {\n return size ?? 'm';\n};\n\nconst resolveWidgetSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetSpan => {\n if (widget.layout?.span != null) {\n return widget.layout.span;\n }\n\n const size = resolveWidgetSize(widget.size);\n if (size === 's') {\n return 3;\n }\n if (size === 'm') {\n return 4;\n }\n if (size === 'l') {\n return 6;\n }\n if (size === 'xl') {\n return 8;\n }\n return 12;\n};\n\nconst resolveWidgetTabletSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetTabletSpan | undefined => {\n return widget.layout?.tabletSpan;\n};\n\ntype DashboardContentProps = {\n config: BackofficeDashboardConfig;\n globalData: unknown;\n};\n\nconst DashboardContent = ({\n config,\n globalData,\n}: DashboardContentProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n\n const title = resolveLabel(config.title, tApp);\n const subtitle =\n config.subtitle != null ? resolveLabel(config.subtitle, tApp) : undefined;\n\n return (\n <DetailPageTemplate\n header={{\n title,\n subtitle: subtitle ?? t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {config.widgets.map((widget) => {\n const widgetTitle = resolveLabel(\n getWidgetLabel(widget, config),\n tApp,\n );\n return (\n <DashboardGridItem\n key={widget.id}\n minHeight={widget.minHeight ?? 'auto'}\n span={resolveWidgetSpan(widget)}\n tabletSpan={resolveWidgetTabletSpan(widget)}\n >\n <BackofficeErrorBoundary\n fallback={() => {\n return (\n <DashboardPanel title={widgetTitle}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }}\n >\n <Suspense\n fallback={\n <DashboardPanel title={widgetTitle}>\n <DashboardLoadingState />\n </DashboardPanel>\n }\n >\n <LazyBackofficeDashboardWidgetContent\n widget={widget}\n globalData={globalData}\n />\n </Suspense>\n </BackofficeErrorBoundary>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n );\n};\n\ntype DashboardWithQueryProps = {\n config: BackofficeDashboardConfig;\n};\n\nconst DashboardWithQuery = ({\n config,\n}: DashboardWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n config.query as never,\n {},\n { fetchPolicy: 'store-or-network' },\n );\n\n return <DashboardContent config={config} globalData={data} />;\n};\n\nexport type BackofficeDashboardPageProps = {\n prepared?: BackofficePreparedDashboardRoute | null;\n};\n\nexport const BackofficeDashboardPage = ({\n prepared,\n}: BackofficeDashboardPageProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const rootDashboard = useBackofficeDashboardConfig();\n const dashboard = prepared?.config ?? rootDashboard;\n const breadcrumb = buildDashboardBreadcrumb(t);\n\n if (dashboard == null) {\n const items = Object.values(entities)\n .filter((config) => {\n return config.kind === 'list-detail' && config.hasList;\n })\n .map((config) => {\n return {\n config,\n label: resolveLabel(config.label, tApp),\n };\n })\n .sort((left, right) => {\n return left.label.localeCompare(right.label);\n });\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n header={{\n title: t('dashboard.title'),\n subtitle: t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {items.map(({ config, label }) => {\n return (\n <DashboardGridItem key={config.id} span={4}>\n <DashboardPanel title={label}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>\n {t('common.notAvailable')}\n </div>\n <DashboardQuickActions\n actions={[\n {\n id: config.id,\n href: config.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n );\n }\n\n if (dashboard.query != null) {\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardWithQuery config={dashboard} />\n </BackofficeRightPageLayout>\n );\n }\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardContent config={dashboard} globalData={null} />\n </BackofficeRightPageLayout>\n );\n};\n\nexport default BackofficeDashboardPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,IAAM,EAAE,kBAAA,MAAqB,GAEvB,IAAuC,EAAK,aAEzC,EACL,UAAS,MAFU,OAAO,0CAEV,iCAClB,EACD,GAEK,UAA+C;CACnD,IAAM,EAAE,MAAM,EAA8B;CAE5C,OAAO,kBAAC,GAAD,EAAsB,OAAO,EAAE,qBAAqB,EAAI,CAAA;AACjE,GAEM,UAA2C;CAC/C,IAAM,EAAE,MAAM,EAA8B;CAE5C,OACE,kBAAC,OAAD;EAAK,WAAW;YAAhB,CACE,kBAAC,GAAD,EAAS,WAAW,EAAE,gBAAgB,EAAI,CAAA,GAC1C,kBAAC,QAAD,EAAA,UAAO,EAAE,gBAAgB,EAAQ,CAAA,CAC9B;;AAET,GAEM,KACJ,MAEO,KAAQ,KAGX,KACJ,MACkC;CAClC,IAAI,EAAO,QAAQ,QAAQ,MACzB,OAAO,EAAO,OAAO;CAGvB,IAAM,IAAO,EAAkB,EAAO,IAAI;CAa1C,OAZI,MAAS,MACJ,IAEL,MAAS,MACJ,IAEL,MAAS,MACJ,IAEL,MAAS,OACJ,IAEF;AACT,GAEM,KACJ,MAEO,EAAO,QAAQ,YAQlB,KAAoB,EACxB,WACA,oBACwC;CACxC,IAAM,EAAE,GAAG,MAAS,EAAe,GAC7B,EAAE,SAAM,EAA8B;CAM5C,OACE,kBAAC,GAAD;EACE,QAAQ;GACN,OAPQ,EAAa,EAAO,OAAO,CAOnC;GACA,WANJ,EAAO,YAAY,OAA6C,KAAA,IAAtC,EAAa,EAAO,UAAU,CAAI,MAMlC,EAAE,oBAAoB;EAC9C;YAEA,kBAAC,GAAD;GAAe,SAAS;aACrB,EAAO,QAAQ,KAAK,MAAW;IAC9B,IAAM,I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AC,GAAD;MAAmC,MAAM;gBACvC,kBAAC,GAAD;OAAgB,OAAO;iBACrB,kBAAC,OAAD;QAAK,WAAW;kBAAhB,CACE,kBAAC,OAAD;SAAK,WAAW;mBACb,EAAE,qBAAqB;QACrB,CAAA,GACL,kBAAC,GAAD,EACE,SAAS,CACP;SACE,IAAI,EAAO;SACX,MAAM,EAAO,OAAO;SACpB,OAAO,EAAE,4BAA4B;QACvC,CACF,EACD,CAAA,CACE;;MACS,CAAA;KACC,GAjBK,EAAO,EAiBZ,CAEtB;IACY,CAAA;GACG,CAAA;EACK,CAAA;CAE/B;CAUA,OARI,EAAU,SAAS,OASrB,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD;GAAkB,QAAQ;GAAW,YAAY;EAAO,CAAA;CAC/B,CAAA,IATzB,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD,EAAoB,QAAQ,EAAY,CAAA;CACf,CAAA;AASjC"}
@@ -0,0 +1,193 @@
1
+ import { useBackofficeReactTranslation as e } from "../i18n/useBackofficeReactTranslation.js";
2
+ import { useBackofficeConfig as t } from "../provider/BackofficeConfigContext.js";
3
+ import { BackofficeBillingUsageChart as n } from "../components/backoffice/billing/BackofficeBillingUsageChart.js";
4
+ import { buildDataTableColumns as r } from "../components/backoffice/columns/buildDataTableColumns.js";
5
+ import { hasWidgetQuery as i, resolveLabel as a } from "./BackofficeDashboardPage.helpers.js";
6
+ import { tileBody as o, tileCount as s } from "./backofficeDashboardPage.css.js";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ import { useTranslation as u } from "react-i18next";
9
+ import * as d from "react-relay";
10
+ import { BackofficeEmptyState as f } from "@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js";
11
+ import { DashboardPanel as p } from "@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js";
12
+ import { DashboardQuickActions as m } from "@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js";
13
+ import { DashboardMetricGroup as h } from "@plumile/ui/components/dashboard/dashboard_metric_group/DashboardMetricGroup.js";
14
+ import { DashboardStatusList as g } from "@plumile/ui/components/dashboard/dashboard_status_list/DashboardStatusList.js";
15
+ import { DataTable as _ } from "@plumile/ui/components/data-table/DataTable.js";
16
+ //#region src/pages/BackofficeDashboardWidgetContent.tsx
17
+ var { useLazyLoadQuery: v } = d, y = () => {
18
+ let { t } = e();
19
+ return /* @__PURE__ */ c(f, { title: t("common.notAvailable") });
20
+ }, b = ({ widget: i, globalData: d }) => {
21
+ let { t: f } = u(), { t: v } = e(), { entities: b } = t(), x = i.description == null ? void 0 : a(i.description, f), S = (e) => "resolve" in i && i.resolve != null ? i.resolve(e) : null;
22
+ if (i.kind === "textBlock") return /* @__PURE__ */ c(p, {
23
+ title: a(i.title, f),
24
+ subtitle: x,
25
+ children: /* @__PURE__ */ c("div", {
26
+ className: o,
27
+ children: a(i.body, f)
28
+ })
29
+ });
30
+ if (i.kind === "shortcut") {
31
+ let e = b[i.entityId], t = a(i.label, f);
32
+ return e == null ? /* @__PURE__ */ c(p, {
33
+ title: t,
34
+ subtitle: x,
35
+ children: /* @__PURE__ */ c(y, {})
36
+ }) : e.kind === "tool" ? /* @__PURE__ */ c(p, {
37
+ title: t,
38
+ subtitle: x,
39
+ children: /* @__PURE__ */ c(m, { actions: [{
40
+ id: e.id,
41
+ href: e.routes.list,
42
+ label: v("dashboard.actions.openTool")
43
+ }] })
44
+ }) : /* @__PURE__ */ c(p, {
45
+ title: t,
46
+ subtitle: x,
47
+ children: /* @__PURE__ */ c(m, { actions: [{
48
+ id: e.id,
49
+ href: e.routes.list,
50
+ label: v("dashboard.actions.openList")
51
+ }] })
52
+ });
53
+ }
54
+ if (i.kind === "tablePreview") {
55
+ let e = S(d);
56
+ if (e == null) return /* @__PURE__ */ c(p, {
57
+ title: a(i.title, f),
58
+ subtitle: x,
59
+ children: /* @__PURE__ */ c(y, {})
60
+ });
61
+ let t = r(e.columns, {
62
+ tApp: f,
63
+ t: v
64
+ });
65
+ return /* @__PURE__ */ c(p, {
66
+ title: a(i.title, f),
67
+ subtitle: x,
68
+ children: /* @__PURE__ */ c(_, {
69
+ columns: t,
70
+ rows: e.rows,
71
+ getRowId: (e, t) => {
72
+ if (typeof e == "object" && e) {
73
+ let { id: t } = e;
74
+ if (typeof t == "string" && t.trim() !== "") return t;
75
+ }
76
+ return String(t);
77
+ }
78
+ })
79
+ });
80
+ }
81
+ if (i.kind === "metricGroup") {
82
+ let e = S(d);
83
+ return e == null ? /* @__PURE__ */ c(y, {}) : /* @__PURE__ */ c(h, {
84
+ emptyState: /* @__PURE__ */ c(y, {}),
85
+ metrics: e.map((e) => ({
86
+ id: e.id,
87
+ href: e.href,
88
+ label: a(e.label, f),
89
+ value: e.value ?? v("common.notAvailable"),
90
+ hint: e.meta == null ? void 0 : a(e.meta, f)
91
+ }))
92
+ });
93
+ }
94
+ if (i.kind === "billingUsageChart") {
95
+ let e = S(d), t = a(i.title, f);
96
+ return e == null ? /* @__PURE__ */ c(p, {
97
+ title: t,
98
+ subtitle: x,
99
+ children: /* @__PURE__ */ c(y, {})
100
+ }) : /* @__PURE__ */ c(p, {
101
+ title: t,
102
+ subtitle: x,
103
+ children: /* @__PURE__ */ c(n, {
104
+ ariaLabel: a(i.ariaLabel, f),
105
+ buckets: e.buckets,
106
+ categories: i.categories.map((e) => ({
107
+ id: e.id,
108
+ label: a(e.label, f),
109
+ color: e.color
110
+ })),
111
+ currency: e.currency,
112
+ emptyLabel: a(i.emptyLabel, f),
113
+ from: e.from,
114
+ rangePrefix: a(i.rangePrefix, f),
115
+ to: e.to,
116
+ totalAmount: e.totalAmount
117
+ })
118
+ });
119
+ }
120
+ if (i.kind === "quickActions") return /* @__PURE__ */ c(p, {
121
+ title: i.title == null ? v("dashboard.actions.openTool") : a(i.title, f),
122
+ subtitle: x,
123
+ children: /* @__PURE__ */ c(m, {
124
+ layout: i.layout?.zone === "aside" ? "stack" : "grid",
125
+ emptyState: /* @__PURE__ */ c(y, {}),
126
+ actions: i.actions.map((e) => ({
127
+ id: e.id,
128
+ href: e.href,
129
+ label: a(e.label, f)
130
+ }))
131
+ })
132
+ });
133
+ if (i.kind === "statusSummary") {
134
+ let e = S(d);
135
+ return e == null ? /* @__PURE__ */ c(p, {
136
+ title: i.title == null ? void 0 : a(i.title, f),
137
+ subtitle: x,
138
+ children: /* @__PURE__ */ c(y, {})
139
+ }) : /* @__PURE__ */ c(p, {
140
+ title: i.title == null ? void 0 : a(i.title, f),
141
+ subtitle: x,
142
+ children: /* @__PURE__ */ c(g, {
143
+ emptyState: /* @__PURE__ */ c(y, {}),
144
+ items: e.map((e) => ({
145
+ id: e.id,
146
+ href: e.href,
147
+ label: a(e.label, f),
148
+ value: e.value ?? v("common.notAvailable")
149
+ }))
150
+ })
151
+ });
152
+ }
153
+ if (i.kind === "recentItems") return /* @__PURE__ */ c(p, {
154
+ title: i.title == null ? v("dashboard.title") : a(i.title, f),
155
+ subtitle: x,
156
+ children: /* @__PURE__ */ c(y, {})
157
+ });
158
+ let C = b[i.entityId];
159
+ if (C?.kind !== "list-detail") return /* @__PURE__ */ c(p, {
160
+ title: a(i.label, f),
161
+ subtitle: x,
162
+ children: /* @__PURE__ */ c(y, {})
163
+ });
164
+ let w = S(d), T = v("common.notAvailable");
165
+ return typeof w?.count == "number" && (T = w.count), /* @__PURE__ */ c(p, {
166
+ title: a(i.label, f),
167
+ subtitle: x,
168
+ children: /* @__PURE__ */ l("div", {
169
+ className: o,
170
+ children: [/* @__PURE__ */ c("div", {
171
+ className: s,
172
+ children: T
173
+ }), /* @__PURE__ */ c(m, {
174
+ emptyState: /* @__PURE__ */ c(y, {}),
175
+ actions: [{
176
+ id: C.id,
177
+ href: C.routes.list,
178
+ label: v("dashboard.actions.openList")
179
+ }]
180
+ })]
181
+ })
182
+ });
183
+ }, x = ({ widget: e }) => /* @__PURE__ */ c(b, {
184
+ widget: e,
185
+ globalData: v(e.query, {}, { fetchPolicy: "store-or-network" })
186
+ }), S = ({ widget: e, globalData: t }) => i(e) ? /* @__PURE__ */ c(x, { widget: e }) : /* @__PURE__ */ c(b, {
187
+ widget: e,
188
+ globalData: t
189
+ });
190
+ //#endregion
191
+ export { S as BackofficeDashboardWidgetContent, S as default };
192
+
193
+ //# sourceMappingURL=BackofficeDashboardWidgetContent.js.map