@burdenoff/microfe-export 2026.1107.2 → 2026.1108.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/main.d.ts +0 -2
- package/dist/export/ExportRoot.d.ts +0 -2
- package/dist/export/ExportRoot.js +9 -6
- package/dist/export/ExportRoot.js.map +1 -1
- package/dist/export/ExportRoutes.d.ts +1 -2
- package/dist/export/ExportRoutes.js +1 -2
- package/dist/export/ExportRoutes.js.map +1 -1
- package/dist/export/components/ExportProgressBar.d.ts +1 -2
- package/dist/export/components/ExportProgressBar.js +1 -2
- package/dist/export/components/ExportProgressBar.js.map +1 -1
- package/dist/export/components/ExportStatusBadge.d.ts +1 -3
- package/dist/export/components/ExportStatusBadge.js +7 -8
- package/dist/export/components/ExportStatusBadge.js.map +1 -1
- package/dist/export/components/PageLayout.d.ts +3 -5
- package/dist/export/components/PageLayout.js +1 -2
- package/dist/export/components/PageLayout.js.map +1 -1
- package/dist/export/constants/enums.d.ts +0 -2
- package/dist/export/constants/enums.js +1 -2
- package/dist/export/constants/enums.js.map +1 -1
- package/dist/export/constants/index.d.ts +0 -1
- package/dist/export/hooks/useExportQueries.d.ts +14 -31
- package/dist/export/hooks/useExportQueries.js +162 -163
- package/dist/export/hooks/useExportQueries.js.map +1 -1
- package/dist/export/hooks/useTr.d.ts +0 -2
- package/dist/export/hooks/useTr.js +1 -2
- package/dist/export/hooks/useTr.js.map +1 -1
- package/dist/export/index.d.ts +0 -1
- package/dist/export/index.js +5 -4
- package/dist/export/pages/CreateExportPage.d.ts +1 -2
- package/dist/export/pages/CreateExportPage.js +53 -54
- package/dist/export/pages/CreateExportPage.js.map +1 -1
- package/dist/export/pages/ExportDashboardPage.d.ts +1 -2
- package/dist/export/pages/ExportDashboardPage.js +17 -18
- package/dist/export/pages/ExportDashboardPage.js.map +1 -1
- package/dist/export/pages/ExportDetailPage.d.ts +1 -2
- package/dist/export/pages/ExportDetailPage.js +20 -21
- package/dist/export/pages/ExportDetailPage.js.map +1 -1
- package/dist/export/pages/ExportHistoryPage.d.ts +1 -2
- package/dist/export/pages/ExportHistoryPage.js +21 -20
- package/dist/export/pages/ExportHistoryPage.js.map +1 -1
- package/dist/export/pages/ExportLandingPage.d.ts +1 -2
- package/dist/export/pages/ExportLandingPage.js +1 -2
- package/dist/export/pages/ExportLandingPage.js.map +1 -1
- package/dist/export/pages/ExportTemplatesPage.d.ts +1 -2
- package/dist/export/pages/ExportTemplatesPage.js +25 -30
- package/dist/export/pages/ExportTemplatesPage.js.map +1 -1
- package/dist/export/pages/TemplateDetailPage.d.ts +1 -2
- package/dist/export/pages/TemplateDetailPage.js +11 -12
- package/dist/export/pages/TemplateDetailPage.js.map +1 -1
- package/dist/export/providers/ExportProvider.d.ts +0 -2
- package/dist/export/providers/ExportProvider.js +12 -16
- package/dist/export/providers/ExportProvider.js.map +1 -1
- package/dist/export/store/exportStore.d.ts +0 -2
- package/dist/export/store/exportStore.js +1 -2
- package/dist/export/store/exportStore.js.map +1 -1
- package/dist/export/types/index.d.ts +0 -1
- package/dist/export/utils/cn.d.ts +0 -2
- package/dist/export/utils/cn.js +2 -3
- package/dist/export/utils/cn.js.map +1 -1
- package/dist/export/utils/disabledModules.d.ts +0 -1
- package/dist/export/utils/disabledModules.js +3 -4
- package/dist/export/utils/disabledModules.js.map +1 -1
- package/dist/export/utils/events.d.ts +0 -2
- package/dist/export/utils/events.js +1 -2
- package/dist/export/utils/events.js.map +1 -1
- package/dist/export/utils/exportAuthority.d.ts +0 -2
- package/dist/export/utils/exportAuthority.js +1 -2
- package/dist/export/utils/exportAuthority.js.map +1 -1
- package/dist/export/utils/i18n.d.ts +0 -2
- package/dist/export/utils/i18n.js +1 -2
- package/dist/export/utils/i18n.js.map +1 -1
- package/dist/generated/global-operations.d.ts +4 -2
- package/dist/generated/global-types.d.ts +2 -22
- package/dist/generated/wspace-operations.d.ts +226 -181
- package/dist/generated/wspace-operations.js +1 -2
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +4 -24
- package/dist/generated/wspace-types.js +1 -2
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +1 -2
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +1 -1
- package/dist/node_modules/@apollo/client/errors/utils.js +1 -2
- package/dist/node_modules/@apollo/client/errors/utils.js.map +1 -1
- package/dist/node_modules/@apollo/client/link/core/ApolloLink.js +7 -8
- package/dist/node_modules/@apollo/client/link/core/ApolloLink.js.map +1 -1
- package/dist/node_modules/@apollo/client/link/subscriptions/index.js +15 -16
- package/dist/node_modules/@apollo/client/link/subscriptions/index.js.map +1 -1
- package/dist/node_modules/@apollo/client/link/utils/createOperation.js +5 -6
- package/dist/node_modules/@apollo/client/link/utils/createOperation.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/caching/sizes.js +0 -1
- package/dist/node_modules/@apollo/client/utilities/caching/sizes.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/graphql/print.js +4 -5
- package/dist/node_modules/@apollo/client/utilities/graphql/print.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/caches.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/caches.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js +2 -3
- package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/memoize.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/memoize.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/invariant/index.js +2 -3
- package/dist/node_modules/@apollo/client/utilities/invariant/index.js.map +1 -1
- package/dist/node_modules/@apollo/client/version.js +2 -3
- package/dist/node_modules/@apollo/client/version.js.map +1 -1
- package/dist/node_modules/@wry/caches/lib/weak.js +1 -2
- package/dist/node_modules/@wry/caches/lib/weak.js.map +1 -1
- package/dist/node_modules/@wry/trie/lib/index.js +2 -3
- package/dist/node_modules/@wry/trie/lib/index.js.map +1 -1
- package/dist/node_modules/clsx/dist/clsx.js +8 -7
- package/dist/node_modules/clsx/dist/clsx.js.map +1 -1
- package/dist/node_modules/graphql-ws/dist/client.js +76 -69
- package/dist/node_modules/graphql-ws/dist/client.js.map +1 -1
- package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js +2 -3
- package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +2 -3
- package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +41 -42
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +14 -15
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +21 -18
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +2 -3
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js.map +1 -1
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +229 -167
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
- package/dist/node_modules/{rxjs/node_modules/tslib → tslib}/tslib.es6.js +1 -2
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/test/happydom.d.ts +1 -0
- package/dist/translations/en.d.ts +0 -1
- package/dist/translations/en.js +1 -2
- package/dist/translations/en.js.map +1 -1
- package/dist/utils/nativeBridge.d.ts +0 -1
- package/dist/utils/nativeBridge.js +1 -2
- package/package.json +62 -46
- package/dist/dev/main.d.ts.map +0 -1
- package/dist/export/ExportRoot.d.ts.map +0 -1
- package/dist/export/ExportRoutes.d.ts.map +0 -1
- package/dist/export/components/ExportProgressBar.d.ts.map +0 -1
- package/dist/export/components/ExportStatusBadge.d.ts.map +0 -1
- package/dist/export/components/PageLayout.d.ts.map +0 -1
- package/dist/export/constants/enums.d.ts.map +0 -1
- package/dist/export/constants/index.d.ts.map +0 -1
- package/dist/export/hooks/useExportQueries.d.ts.map +0 -1
- package/dist/export/hooks/useTr.d.ts.map +0 -1
- package/dist/export/index.d.ts.map +0 -1
- package/dist/export/pages/CreateExportPage.d.ts.map +0 -1
- package/dist/export/pages/ExportDashboardPage.d.ts.map +0 -1
- package/dist/export/pages/ExportDetailPage.d.ts.map +0 -1
- package/dist/export/pages/ExportHistoryPage.d.ts.map +0 -1
- package/dist/export/pages/ExportLandingPage.d.ts.map +0 -1
- package/dist/export/pages/ExportTemplatesPage.d.ts.map +0 -1
- package/dist/export/pages/TemplateDetailPage.d.ts.map +0 -1
- package/dist/export/providers/ExportProvider.d.ts.map +0 -1
- package/dist/export/store/exportStore.d.ts.map +0 -1
- package/dist/export/types/index.d.ts.map +0 -1
- package/dist/export/utils/cn.d.ts.map +0 -1
- package/dist/export/utils/disabledModules.d.ts.map +0 -1
- package/dist/export/utils/events.d.ts.map +0 -1
- package/dist/export/utils/exportAuthority.d.ts.map +0 -1
- package/dist/export/utils/i18n.d.ts.map +0 -1
- package/dist/generated/global-operations.d.ts.map +0 -1
- package/dist/generated/global-types.d.ts.map +0 -1
- package/dist/generated/wspace-operations.d.ts.map +0 -1
- package/dist/generated/wspace-types.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/node_modules/rxjs/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/translations/en.d.ts.map +0 -1
- package/dist/utils/nativeBridge.d.ts.map +0 -1
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { useExport as e } from "../providers/ExportProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { useAvailableEntities as t, useCreateExportTemplate as n, useDeleteExportTemplate as r, useExportTemplates as i } from "../hooks/useExportQueries.js";
|
|
3
|
+
import { PageLayout as a } from "../components/PageLayout.js";
|
|
4
|
+
import { getFormatDisplayName as o } from "../constants/enums.js";
|
|
5
|
+
import { useTr as s } from "../hooks/useTr.js";
|
|
6
|
+
import { cn as c } from "../utils/cn.js";
|
|
7
7
|
import { nativeImpact as ee, nativeNotify as l } from "../../utils/nativeBridge.js";
|
|
8
8
|
import { useMemo as u, useState as d } from "react";
|
|
9
9
|
import { ChevronRight as te, FileBox as f, Loader2 as p, Plus as m, Search as h, Sparkles as g, X as _ } from "lucide-react";
|
|
10
10
|
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
11
11
|
import { CTAOverflowMenu as b, IllustratedEmptyState as x, PagePurpose as S } from "@burdenoff/fe-libs/ui";
|
|
12
|
-
|
|
12
|
+
// src/export/pages/ExportTemplatesPage.tsx
|
|
13
13
|
var C = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
14
14
|
function w() {
|
|
15
|
-
let { basePath: w = "/", navigate: T } = e(), E =
|
|
15
|
+
let { basePath: w = "/", navigate: T } = e(), E = s(), { data: D, isLoading: O } = i(), { deleteTemplate: k } = r(), { createTemplate: A, isPending: j } = n(), { data: M } = t(), [N, P] = d(""), [F, I] = d(!1), [L, R] = d(""), [z, B] = d(""), [V, H] = d([]), [U, W] = d("CSV"), [G, K] = d(null), [q, J] = d(null), Y = () => {
|
|
16
16
|
R(""), B(""), H([]), W("CSV"), K(null), I(!0);
|
|
17
17
|
}, X = async () => {
|
|
18
|
-
if (!L.trim())
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
format: U
|
|
33
|
-
}), I(!1);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
K(e instanceof Error ? e.message : E("export.templates.form.errors.createFailed", "Failed to create template."));
|
|
18
|
+
if (!L.trim()) K(E("export.templates.form.errors.nameRequired", "Template name is required."));
|
|
19
|
+
else if (V.length === 0) K(E("export.templates.form.errors.entityRequired", "Select at least one entity type."));
|
|
20
|
+
else {
|
|
21
|
+
K(null);
|
|
22
|
+
try {
|
|
23
|
+
await A({
|
|
24
|
+
name: L.trim(),
|
|
25
|
+
description: z.trim() || void 0,
|
|
26
|
+
entityTypes: V,
|
|
27
|
+
format: U
|
|
28
|
+
}), I(!1);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
K(e instanceof Error ? e.message : E("export.templates.form.errors.createFailed", "Failed to create template."));
|
|
31
|
+
}
|
|
36
32
|
}
|
|
37
33
|
}, Z = (e) => {
|
|
38
34
|
H((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
@@ -54,7 +50,7 @@ function w() {
|
|
|
54
50
|
J(null);
|
|
55
51
|
}
|
|
56
52
|
};
|
|
57
|
-
return /* @__PURE__ */ y(
|
|
53
|
+
return /* @__PURE__ */ y(a, {
|
|
58
54
|
title: E("export.templates.title", "Export Templates"),
|
|
59
55
|
subtitle: E("export.templates.subtitle", "Reusable export configurations for common data exports"),
|
|
60
56
|
icon: /* @__PURE__ */ v(f, { size: 24 }),
|
|
@@ -167,7 +163,7 @@ function w() {
|
|
|
167
163
|
children: M.map((e) => /* @__PURE__ */ v("button", {
|
|
168
164
|
type: "button",
|
|
169
165
|
onClick: () => Z(e.entityType),
|
|
170
|
-
className:
|
|
166
|
+
className: c("px-3 py-1.5 rounded-lg text-sm font-medium border-2 transition-all", V.includes(e.entityType) ? "border-primary bg-action-primary-bg/10 text-primary" : "border-border-subtle bg-bg-surface hover:border-primary/50"),
|
|
171
167
|
children: e.displayName
|
|
172
168
|
}, e.entityType))
|
|
173
169
|
})]
|
|
@@ -243,7 +239,7 @@ function w() {
|
|
|
243
239
|
onKeyDown: (t) => {
|
|
244
240
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), $(e.id));
|
|
245
241
|
},
|
|
246
|
-
className:
|
|
242
|
+
className: c("text-left group cursor-pointer border border-border-seam rounded-xl overflow-hidden bg-bg-surface", "hover:border-primary/40 shadow-[var(--shadow-pop)] transition-colors duration-200", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40", "animate-in fade-in-0"),
|
|
247
243
|
style: { animationDelay: `${t * 50}ms` },
|
|
248
244
|
children: [/* @__PURE__ */ v("div", {
|
|
249
245
|
className: "p-4 border-b bg-bg-sunken/30",
|
|
@@ -262,7 +258,7 @@ function w() {
|
|
|
262
258
|
children: e.name
|
|
263
259
|
}), /* @__PURE__ */ y("p", {
|
|
264
260
|
className: "text-xs text-text-secondary",
|
|
265
|
-
children: [
|
|
261
|
+
children: [o(e.format), e.isDefault && /* @__PURE__ */ v("span", {
|
|
266
262
|
className: "ml-1.5 inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-action-primary-bg/10 text-primary font-medium",
|
|
267
263
|
children: E("export.templates.card.default", "Default")
|
|
268
264
|
})]
|
|
@@ -351,7 +347,6 @@ function w() {
|
|
|
351
347
|
]
|
|
352
348
|
});
|
|
353
349
|
}
|
|
354
|
-
//#endregion
|
|
355
350
|
export { w as ExportTemplatesPage };
|
|
356
351
|
|
|
357
352
|
//# sourceMappingURL=ExportTemplatesPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportTemplatesPage.js","names":[],"sources":["../../../src/export/pages/ExportTemplatesPage.tsx"],"sourcesContent":["import { useState, useMemo } from \"react\";\nimport {\n Search,\n X,\n FileBox,\n Plus,\n ChevronRight,\n Sparkles,\n Loader2,\n} from \"lucide-react\";\nimport {\n CTAOverflowMenu,\n IllustratedEmptyState,\n PagePurpose,\n} from \"@burdenoff/fe-libs/ui\";\nimport { useExport } from \"../providers/ExportProvider\";\nimport {\n useExportTemplates,\n useDeleteExportTemplate,\n useCreateExportTemplate,\n useAvailableEntities,\n} from \"../hooks/useExportQueries\";\nimport { PageLayout } from \"../components/PageLayout\";\nimport { getFormatDisplayName } from \"../constants/enums\";\nimport { useTr } from \"../hooks/useTr\";\nimport { cn } from \"../utils/cn\";\nimport type { ExportFormat } from \"../types\";\nimport { nativeImpact, nativeNotify } from \"../../utils/nativeBridge\";\n\n/**\n * Helper to join paths correctly\n */\nconst joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n return cleanBase + cleanPath;\n};\n\n/**\n * Export Templates Page\n * Template management list for reusable export configurations\n */\nexport function ExportTemplatesPage() {\n const { basePath = \"/\", navigate } = useExport();\n const tr = useTr();\n const { data: templates, isLoading } = useExportTemplates();\n const { deleteTemplate } = useDeleteExportTemplate();\n const { createTemplate, isPending: creating } = useCreateExportTemplate();\n const { data: availableEntities } = useAvailableEntities();\n\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [showCreateForm, setShowCreateForm] = useState(false);\n const [newTemplateName, setNewTemplateName] = useState(\"\");\n const [newTemplateDescription, setNewTemplateDescription] = useState(\"\");\n const [newTemplateEntityTypes, setNewTemplateEntityTypes] = useState<\n string[]\n >([]);\n const [newTemplateFormat, setNewTemplateFormat] =\n useState<ExportFormat>(\"CSV\");\n const [createError, setCreateError] = useState<string | null>(null);\n const [templatePendingDelete, setTemplatePendingDelete] = useState<\n string | null\n >(null);\n\n const handleOpenCreate = () => {\n setNewTemplateName(\"\");\n setNewTemplateDescription(\"\");\n setNewTemplateEntityTypes([]);\n setNewTemplateFormat(\"CSV\");\n setCreateError(null);\n setShowCreateForm(true);\n };\n\n const handleCreateTemplate = async () => {\n if (!newTemplateName.trim()) {\n setCreateError(\n tr(\n \"export.templates.form.errors.nameRequired\",\n \"Template name is required.\",\n ),\n );\n return;\n }\n if (newTemplateEntityTypes.length === 0) {\n setCreateError(\n tr(\n \"export.templates.form.errors.entityRequired\",\n \"Select at least one entity type.\",\n ),\n );\n return;\n }\n setCreateError(null);\n try {\n await createTemplate({\n name: newTemplateName.trim(),\n description: newTemplateDescription.trim() || undefined,\n entityTypes: newTemplateEntityTypes,\n format: newTemplateFormat,\n });\n setShowCreateForm(false);\n } catch (err) {\n setCreateError(\n err instanceof Error\n ? err.message\n : tr(\n \"export.templates.form.errors.createFailed\",\n \"Failed to create template.\",\n ),\n );\n }\n };\n\n const toggleEntity = (entityType: string) => {\n setNewTemplateEntityTypes((prev) =>\n prev.includes(entityType)\n ? prev.filter((e) => e !== entityType)\n : [...prev, entityType],\n );\n };\n\n // Client-side search filter\n const filteredTemplates = useMemo(() => {\n if (!searchQuery) return templates;\n const q = searchQuery.toLowerCase();\n return templates.filter(\n (t) =>\n t.name.toLowerCase().includes(q) ||\n t.entityTypes.some((e) => e.toLowerCase().includes(q)),\n );\n }, [templates, searchQuery]);\n\n const handleTemplateClick = (templateId: string) => {\n navigate?.(joinPath(basePath, `templates/${templateId}`));\n };\n\n const handleDeleteTemplate = async (\n e: React.MouseEvent,\n templateId: string,\n ) => {\n e.stopPropagation();\n nativeImpact(\"medium\");\n setTemplatePendingDelete(templateId);\n };\n\n const confirmDeleteTemplate = async () => {\n if (!templatePendingDelete) return;\n try {\n await deleteTemplate(templatePendingDelete);\n nativeNotify(\"success\");\n } catch {\n nativeNotify(\"error\");\n }\n setTemplatePendingDelete(null);\n };\n\n return (\n <PageLayout\n title={tr(\"export.templates.title\", \"Export Templates\")}\n subtitle={tr(\n \"export.templates.subtitle\",\n \"Reusable export configurations for common data exports\",\n )}\n icon={<FileBox size={24} />}\n headerActions={\n <CTAOverflowMenu\n primary={{\n label: tr(\"export.templates.actions.newTemplate\", \"New Template\"),\n icon: <Plus size={16} />,\n onSelect: handleOpenCreate,\n }}\n actions={[\n {\n label: tr(\"export.templates.actions.newExport\", \"New Export\"),\n icon: <Plus size={16} />,\n onSelect: () => navigate?.(joinPath(basePath, \"new\")),\n },\n ]}\n />\n }\n headerContent={\n <span className=\"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium bg-bg-sunken text-text-secondary\">\n <Sparkles size={12} />\n {tr(\n \"export.templates.summary.available\",\n \"{{count}} template{{suffix}} available\",\n {\n count: filteredTemplates.length,\n suffix: filteredTemplates.length !== 1 ? \"s\" : \"\",\n },\n )}\n </span>\n }\n >\n {/* Page purpose — why templates exist */}\n <PagePurpose icon={<FileBox size={16} />}>\n {tr(\n \"export.templates.purpose\",\n \"Templates save an export setup — the entity types and format you regularly need — so you don't rebuild it each time. Create one here, then start a new export from it in a single click. Handy for recurring backups, periodic audits, or any export you run more than once.\",\n )}\n </PagePurpose>\n\n {/* Create Template Form */}\n {showCreateForm && (\n <div className=\"border border-primary/30 rounded-xl p-6 bg-accent-wash space-y-4\">\n <div className=\"flex items-center justify-between\">\n <h3 className=\"font-semibold text-lg\">\n {tr(\"export.templates.form.title\", \"New Template\")}\n </h3>\n <button\n type=\"button\"\n onClick={() => setShowCreateForm(false)}\n className=\"p-1.5 rounded-md hover:bg-accent\"\n >\n <X size={16} />\n </button>\n </div>\n {createError && (\n <p className=\"text-sm text-status-error-text bg-status-error-bg/10 rounded-lg px-3 py-2\">\n {createError}\n </p>\n )}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"space-y-1\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.name\", \"Name\")} *\n </label>\n <input\n type=\"text\"\n aria-label={tr(\"export.templates.form.fields.name\", \"Name\")}\n placeholder={tr(\n \"export.templates.form.fields.namePlaceholder\",\n \"e.g. Weekly Tags Export\",\n )}\n value={newTemplateName}\n onChange={(e) => setNewTemplateName(e.target.value)}\n className=\"w-full px-3 py-2 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all\"\n />\n </div>\n <div className=\"space-y-1\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.format\", \"Format\")} *\n </label>\n <select\n value={newTemplateFormat}\n onChange={(e) =>\n setNewTemplateFormat(e.target.value as ExportFormat)\n }\n className=\"w-full px-3 py-2 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"CSV\">{tr(\"export.format.csv\", \"CSV\")}</option>\n <option value=\"JSON\">{tr(\"export.format.json\", \"JSON\")}</option>\n </select>\n </div>\n </div>\n <div className=\"space-y-1\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.description\", \"Description\")}\n </label>\n <input\n type=\"text\"\n aria-label={tr(\n \"export.templates.form.fields.description\",\n \"Description\",\n )}\n placeholder={tr(\n \"export.templates.form.fields.descriptionPlaceholder\",\n \"Optional description\",\n )}\n value={newTemplateDescription}\n onChange={(e) => setNewTemplateDescription(e.target.value)}\n className=\"w-full px-3 py-2 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all\"\n />\n </div>\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.entityTypes\", \"Entity Types\")} *{\" \"}\n <span className=\"text-text-secondary font-normal\">\n {tr(\n \"export.templates.form.fields.entityTypesHint\",\n \"(select at least one)\",\n )}\n </span>\n </label>\n <div className=\"flex flex-wrap gap-2\">\n {availableEntities.map((entity) => (\n <button\n key={entity.entityType}\n type=\"button\"\n onClick={() => toggleEntity(entity.entityType)}\n className={cn(\n \"px-3 py-1.5 rounded-lg text-sm font-medium border-2 transition-all\",\n newTemplateEntityTypes.includes(entity.entityType)\n ? \"border-primary bg-action-primary-bg/10 text-primary\"\n : \"border-border-subtle bg-bg-surface hover:border-primary/50\",\n )}\n >\n {entity.displayName}\n </button>\n ))}\n </div>\n </div>\n <div className=\"flex gap-3 pt-2\">\n <button\n type=\"button\"\n onClick={handleCreateTemplate}\n disabled={creating}\n className=\"inline-flex items-center gap-2 px-5 py-2.5 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors font-medium disabled:opacity-50\"\n >\n {creating ? (\n <Loader2 size={16} className=\"animate-spin\" />\n ) : (\n <Plus size={16} />\n )}\n {tr(\"export.templates.form.actions.create\", \"Create Template\")}\n </button>\n <button\n type=\"button\"\n onClick={() => setShowCreateForm(false)}\n className=\"px-5 py-2.5 border-2 border-border-subtle rounded-lg hover:bg-accent transition-colors font-medium\"\n >\n {tr(\"export.templates.form.actions.cancel\", \"Cancel\")}\n </button>\n </div>\n </div>\n )}\n {/* Search */}\n <div className=\"relative group\">\n <Search\n size={18}\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary group-focus-within:text-primary transition-colors\"\n />\n <input\n type=\"text\"\n aria-label={tr(\n \"export.templates.search.placeholder\",\n \"Search templates\",\n )}\n placeholder={tr(\n \"export.templates.search.placeholder\",\n \"Search templates...\",\n )}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2.5 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all duration-200\"\n />\n {searchQuery && (\n <button\n type=\"button\"\n onClick={() => setSearchQuery(\"\")}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 p-1 rounded-md text-text-secondary hover:text-text-primary hover:bg-accent\"\n >\n <X size={16} />\n </button>\n )}\n </div>\n\n {/* Loading */}\n {isLoading && (\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-4\">\n {[...Array(4)].map((_, i) => (\n <div key={i} className=\"border border-border-seam rounded-xl p-5\">\n <div className=\"h-5 w-40 bg-bg-sunken rounded mb-3 animate-vc-shimmer\" />\n <div className=\"h-3 w-full bg-bg-sunken rounded mb-2 animate-vc-shimmer\" />\n <div className=\"flex gap-2 mt-4\">\n <div className=\"h-5 w-16 bg-bg-sunken rounded-full animate-vc-shimmer\" />\n <div className=\"h-5 w-16 bg-bg-sunken rounded-full animate-vc-shimmer\" />\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Templates Grid */}\n {!isLoading ? (\n filteredTemplates.length > 0 ? (\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-4\">\n {filteredTemplates.map((template, index) => (\n <div\n key={template.id}\n role=\"button\"\n tabIndex={0}\n onClick={() => handleTemplateClick(template.id)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handleTemplateClick(template.id);\n }\n }}\n className={cn(\n \"text-left group cursor-pointer border border-border-seam rounded-xl overflow-hidden bg-bg-surface\",\n \"hover:border-primary/40 shadow-[var(--shadow-pop)] transition-colors duration-200\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40\",\n \"animate-in fade-in-0\",\n )}\n style={{ animationDelay: `${index * 50}ms` }}\n >\n {/* Header */}\n <div className=\"p-4 border-b bg-bg-sunken/30\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 rounded-lg bg-action-primary-bg/10\">\n <FileBox size={20} className=\"text-primary\" />\n </div>\n <div>\n <h3 className=\"font-semibold\">{template.name}</h3>\n <p className=\"text-xs text-text-secondary\">\n {getFormatDisplayName(template.format)}\n {template.isDefault && (\n <span className=\"ml-1.5 inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-action-primary-bg/10 text-primary font-medium\">\n {tr(\"export.templates.card.default\", \"Default\")}\n </span>\n )}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={(e) => handleDeleteTemplate(e, template.id)}\n className=\"p-1.5 rounded-md text-text-secondary hover:text-status-error-text hover:bg-status-error-bg/10 transition-colors\"\n aria-label={tr(\n \"export.templates.card.deleteAriaLabel\",\n \"Delete {{name}}\",\n { name: template.name },\n )}\n >\n <X size={14} />\n </button>\n <ChevronRight\n size={18}\n className=\"text-text-secondary group-hover:text-primary transition-colors mt-1\"\n />\n </div>\n </div>\n </div>\n\n {/* Body */}\n <div className=\"p-4\">\n {template.description && (\n <p className=\"text-sm text-text-secondary mb-3 line-clamp-2\">\n {template.description}\n </p>\n )}\n <div className=\"flex flex-wrap gap-1.5 overflow-hidden\">\n {template.entityTypes.slice(0, 6).map((entity) => (\n <span\n key={entity}\n className=\"inline-flex px-2 py-0.5 rounded text-xs font-medium bg-bg-sunken text-text-secondary max-w-full truncate\"\n >\n {entity}\n </span>\n ))}\n {template.entityTypes.length > 6 && (\n <span className=\"inline-flex px-2 py-0.5 rounded text-xs font-medium bg-bg-sunken text-text-secondary\">\n {tr(\n \"export.templates.card.moreEntities\",\n \"+{{count}} more\",\n {\n count: template.entityTypes.length - 6,\n },\n )}\n </span>\n )}\n </div>\n </div>\n </div>\n ))}\n </div>\n ) : (\n <IllustratedEmptyState\n illustration={searchQuery ? \"empty-search\" : \"empty-data\"}\n title={\n searchQuery\n ? tr(\n \"export.templates.empty.filtered.title\",\n \"No matching templates\",\n )\n : tr(\"export.templates.empty.title\", \"No templates yet\")\n }\n description={\n searchQuery\n ? tr(\n \"export.templates.empty.filtered.description\",\n \"Try adjusting your search to find what you are looking for.\",\n )\n : tr(\n \"export.templates.empty.description\",\n \"Create a template to save reusable export configurations.\",\n )\n }\n action={\n searchQuery ? (\n <button\n type=\"button\"\n onClick={() => setSearchQuery(\"\")}\n className=\"inline-flex items-center gap-2 px-4 py-2 border-2 border-border-subtle rounded-lg hover:bg-accent transition-colors font-medium\"\n >\n <X size={16} />\n {tr(\n \"export.templates.empty.filtered.actions.clear\",\n \"Clear Search\",\n )}\n </button>\n ) : (\n <button\n type=\"button\"\n onClick={handleOpenCreate}\n className=\"inline-flex items-center gap-2 px-4 py-2 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors font-medium\"\n >\n <Plus size={16} />\n {tr(\n \"export.templates.empty.actions.newTemplate\",\n \"New Template\",\n )}\n </button>\n )\n }\n />\n )\n ) : null}\n {templatePendingDelete && (\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"template-list-delete-title\"\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-surface/80 backdrop-blur-sm p-4\"\n >\n <div className=\"w-full max-w-md rounded-xl border-2 border-border-subtle bg-bg-surface p-6 shadow-xl\">\n <h2 id=\"template-list-delete-title\" className=\"text-lg font-bold\">\n {tr(\"export.templates.delete.title\", \"Delete template?\")}\n </h2>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {tr(\n \"export.templates.delete.description\",\n \"This removes the saved export configuration. Existing export jobs are not deleted.\",\n )}\n </p>\n <div className=\"mt-6 flex flex-col-reverse sm:flex-row sm:justify-end gap-3\">\n <button\n type=\"button\"\n onClick={() => setTemplatePendingDelete(null)}\n className=\"px-4 py-2 rounded-lg border-2 border-border-subtle hover:bg-accent transition-colors font-medium\"\n >\n {tr(\"export.templates.delete.cancel\", \"Keep Template\")}\n </button>\n <button\n type=\"button\"\n onClick={confirmDeleteTemplate}\n className=\"px-4 py-2 rounded-lg bg-status-error-bg text-status-error-text hover:bg-status-error-bg/90 transition-colors font-medium\"\n >\n {tr(\"export.templates.delete.confirmAction\", \"Delete Template\")}\n </button>\n </div>\n </div>\n </div>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,IAAM,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AAQtD,SAAgB,IAAsB;CACpC,IAAM,EAAE,cAAW,KAAK,gBAAa,GAAW,EAC1C,IAAK,GAAO,EACZ,EAAE,MAAM,GAAW,iBAAc,GAAoB,EACrD,EAAE,sBAAmB,GAAyB,EAC9C,EAAE,mBAAgB,WAAW,MAAa,GAAyB,EACnE,EAAE,MAAM,MAAsB,GAAsB,EAEpD,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAgB,KAAqB,EAAS,GAAM,EACrD,CAAC,GAAiB,KAAsB,EAAS,GAAG,EACpD,CAAC,GAAwB,KAA6B,EAAS,GAAG,EAClE,CAAC,GAAwB,KAA6B,EAE1D,EAAE,CAAC,EACC,CAAC,GAAmB,KACxB,EAAuB,MAAM,EACzB,CAAC,GAAa,KAAkB,EAAwB,KAAK,EAC7D,CAAC,GAAuB,KAA4B,EAExD,KAAK,EAED,UAAyB;AAM7B,EALA,EAAmB,GAAG,E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AAY,SAAS,KAC7B,kBAAC,QAAD;QAAM,WAAU;kBACb,EACC,sCACA,mBACA,EACE,OAAO,EAAS,YAAY,SAAS,GACtC,CACF;QACI,CAAA,CAEL;SACF;QACF;OAvFC,EAAS,GAuFV,CACN;IACE,CAAA,GAEN,kBAAC,GAAD;IACE,cAAc,IAAc,iBAAiB;IAC7C,OACE,IACI,EACE,yCACA,wBACD,GACD,EAAG,gCAAgC,mBAAmB;IAE5D,aACE,IACI,EACE,+CACA,8DACD,GACD,EACE,sCACA,4DACD;IAEP,QACE,IACE,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,EAAe,GAAG;KACjC,WAAU;eAHZ,CAKE,kBAAC,GAAD,EAAG,MAAM,IAAM,CAAA,EACd,EACC,iDACA,eACD,CACM;SAET,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;eAHZ,CAKE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EACjB,EACC,8CACA,eACD,CACM;;IAGb,CAAA;GAGL,KACC,kBAAC,OAAD;IACE,MAAK;IACL,cAAW;IACX,mBAAgB;IAChB,WAAU;cAEV,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,MAAD;OAAI,IAAG;OAA6B,WAAU;iBAC3C,EAAG,iCAAiC,mBAAmB;OACrD,CAAA;MACL,kBAAC,KAAD;OAAG,WAAU;iBACV,EACC,uCACA,qFACD;OACC,CAAA;MACJ,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,UAAD;QACE,MAAK;QACL,eAAe,EAAyB,KAAK;QAC7C,WAAU;kBAET,EAAG,kCAAkC,gBAAgB;QAC/C,CAAA,EACT,kBAAC,UAAD;QACE,MAAK;QACL,SAAS;QACT,WAAU;kBAET,EAAG,yCAAyC,kBAAkB;QACxD,CAAA,CACL;;MACF;;IACF,CAAA;GAEG"}
|
|
1
|
+
{"version":3,"file":"ExportTemplatesPage.js","names":["joinPath","base","path","ExportTemplatesPage","useExport","tr","useTr","templates","useExportTemplates","useDeleteExportTemplate","creating","useCreateExportTemplate","availableEntities","useAvailableEntities","searchQuery","setSearchQuery","useState","showCreateForm","setShowCreateForm","newTemplateName","setNewTemplateName","newTemplateDescription","setNewTemplateDescription","newTemplateEntityTypes","setNewTemplateEntityTypes","newTemplateFormat","setNewTemplateFormat","createError","setCreateError","templatePendingDelete","setTemplatePendingDelete","handleOpenCreate","handleCreateTemplate","createTemplate","err","toggleEntity","prev","entityType","e","filteredTemplates","useMemo","q","handleTemplateClick","basePath","templateId","handleDeleteTemplate","nativeImpact","confirmDeleteTemplate","deleteTemplate","nativeNotify","PageLayout","FileBox","CTAOverflowMenu","Plus","navigate","Sparkles","PagePurpose","X","entity","cn","Loader2","Search","isLoading","i","template","index","getFormatDisplayName","ChevronRight","IllustratedEmptyState"],"sources":["../../../src/export/pages/ExportTemplatesPage.tsx"],"sourcesContent":["import { useState, useMemo } from \"react\";\nimport {\n Search,\n X,\n FileBox,\n Plus,\n ChevronRight,\n Sparkles,\n Loader2,\n} from \"lucide-react\";\nimport {\n CTAOverflowMenu,\n IllustratedEmptyState,\n PagePurpose,\n} from \"@burdenoff/fe-libs/ui\";\nimport { useExport } from \"../providers/ExportProvider\";\nimport {\n useExportTemplates,\n useDeleteExportTemplate,\n useCreateExportTemplate,\n useAvailableEntities,\n} from \"../hooks/useExportQueries\";\nimport { PageLayout } from \"../components/PageLayout\";\nimport { getFormatDisplayName } from \"../constants/enums\";\nimport { useTr } from \"../hooks/useTr\";\nimport { cn } from \"../utils/cn\";\nimport type { ExportFormat } from \"../types\";\nimport { nativeImpact, nativeNotify } from \"../../utils/nativeBridge\";\n\n/**\n * Helper to join paths correctly\n */\nconst joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n return cleanBase + cleanPath;\n};\n\n/**\n * Export Templates Page\n * Template management list for reusable export configurations\n */\nexport function ExportTemplatesPage() {\n const { basePath = \"/\", navigate } = useExport();\n const tr = useTr();\n const { data: templates, isLoading } = useExportTemplates();\n const { deleteTemplate } = useDeleteExportTemplate();\n const { createTemplate, isPending: creating } = useCreateExportTemplate();\n const { data: availableEntities } = useAvailableEntities();\n\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [showCreateForm, setShowCreateForm] = useState(false);\n const [newTemplateName, setNewTemplateName] = useState(\"\");\n const [newTemplateDescription, setNewTemplateDescription] = useState(\"\");\n const [newTemplateEntityTypes, setNewTemplateEntityTypes] = useState<\n string[]\n >([]);\n const [newTemplateFormat, setNewTemplateFormat] =\n useState<ExportFormat>(\"CSV\");\n const [createError, setCreateError] = useState<string | null>(null);\n const [templatePendingDelete, setTemplatePendingDelete] = useState<\n string | null\n >(null);\n\n const handleOpenCreate = () => {\n setNewTemplateName(\"\");\n setNewTemplateDescription(\"\");\n setNewTemplateEntityTypes([]);\n setNewTemplateFormat(\"CSV\");\n setCreateError(null);\n setShowCreateForm(true);\n };\n\n const handleCreateTemplate = async () => {\n if (!newTemplateName.trim()) {\n setCreateError(\n tr(\n \"export.templates.form.errors.nameRequired\",\n \"Template name is required.\",\n ),\n );\n return;\n }\n if (newTemplateEntityTypes.length === 0) {\n setCreateError(\n tr(\n \"export.templates.form.errors.entityRequired\",\n \"Select at least one entity type.\",\n ),\n );\n return;\n }\n setCreateError(null);\n try {\n await createTemplate({\n name: newTemplateName.trim(),\n description: newTemplateDescription.trim() || undefined,\n entityTypes: newTemplateEntityTypes,\n format: newTemplateFormat,\n });\n setShowCreateForm(false);\n } catch (err) {\n setCreateError(\n err instanceof Error\n ? err.message\n : tr(\n \"export.templates.form.errors.createFailed\",\n \"Failed to create template.\",\n ),\n );\n }\n };\n\n const toggleEntity = (entityType: string) => {\n setNewTemplateEntityTypes((prev) =>\n prev.includes(entityType)\n ? prev.filter((e) => e !== entityType)\n : [...prev, entityType],\n );\n };\n\n // Client-side search filter\n const filteredTemplates = useMemo(() => {\n if (!searchQuery) return templates;\n const q = searchQuery.toLowerCase();\n return templates.filter(\n (t) =>\n t.name.toLowerCase().includes(q) ||\n t.entityTypes.some((e) => e.toLowerCase().includes(q)),\n );\n }, [templates, searchQuery]);\n\n const handleTemplateClick = (templateId: string) => {\n navigate?.(joinPath(basePath, `templates/${templateId}`));\n };\n\n const handleDeleteTemplate = async (\n e: React.MouseEvent,\n templateId: string,\n ) => {\n e.stopPropagation();\n nativeImpact(\"medium\");\n setTemplatePendingDelete(templateId);\n };\n\n const confirmDeleteTemplate = async () => {\n if (!templatePendingDelete) return;\n try {\n await deleteTemplate(templatePendingDelete);\n nativeNotify(\"success\");\n } catch {\n nativeNotify(\"error\");\n }\n setTemplatePendingDelete(null);\n };\n\n return (\n <PageLayout\n title={tr(\"export.templates.title\", \"Export Templates\")}\n subtitle={tr(\n \"export.templates.subtitle\",\n \"Reusable export configurations for common data exports\",\n )}\n icon={<FileBox size={24} />}\n headerActions={\n <CTAOverflowMenu\n primary={{\n label: tr(\"export.templates.actions.newTemplate\", \"New Template\"),\n icon: <Plus size={16} />,\n onSelect: handleOpenCreate,\n }}\n actions={[\n {\n label: tr(\"export.templates.actions.newExport\", \"New Export\"),\n icon: <Plus size={16} />,\n onSelect: () => navigate?.(joinPath(basePath, \"new\")),\n },\n ]}\n />\n }\n headerContent={\n <span className=\"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium bg-bg-sunken text-text-secondary\">\n <Sparkles size={12} />\n {tr(\n \"export.templates.summary.available\",\n \"{{count}} template{{suffix}} available\",\n {\n count: filteredTemplates.length,\n suffix: filteredTemplates.length !== 1 ? \"s\" : \"\",\n },\n )}\n </span>\n }\n >\n {/* Page purpose — why templates exist */}\n <PagePurpose icon={<FileBox size={16} />}>\n {tr(\n \"export.templates.purpose\",\n \"Templates save an export setup — the entity types and format you regularly need — so you don't rebuild it each time. Create one here, then start a new export from it in a single click. Handy for recurring backups, periodic audits, or any export you run more than once.\",\n )}\n </PagePurpose>\n\n {/* Create Template Form */}\n {showCreateForm && (\n <div className=\"border border-primary/30 rounded-xl p-6 bg-accent-wash space-y-4\">\n <div className=\"flex items-center justify-between\">\n <h3 className=\"font-semibold text-lg\">\n {tr(\"export.templates.form.title\", \"New Template\")}\n </h3>\n <button\n type=\"button\"\n onClick={() => setShowCreateForm(false)}\n className=\"p-1.5 rounded-md hover:bg-accent\"\n >\n <X size={16} />\n </button>\n </div>\n {createError && (\n <p className=\"text-sm text-status-error-text bg-status-error-bg/10 rounded-lg px-3 py-2\">\n {createError}\n </p>\n )}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"space-y-1\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.name\", \"Name\")} *\n </label>\n <input\n type=\"text\"\n aria-label={tr(\"export.templates.form.fields.name\", \"Name\")}\n placeholder={tr(\n \"export.templates.form.fields.namePlaceholder\",\n \"e.g. Weekly Tags Export\",\n )}\n value={newTemplateName}\n onChange={(e) => setNewTemplateName(e.target.value)}\n className=\"w-full px-3 py-2 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all\"\n />\n </div>\n <div className=\"space-y-1\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.format\", \"Format\")} *\n </label>\n <select\n value={newTemplateFormat}\n onChange={(e) =>\n setNewTemplateFormat(e.target.value as ExportFormat)\n }\n className=\"w-full px-3 py-2 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"CSV\">{tr(\"export.format.csv\", \"CSV\")}</option>\n <option value=\"JSON\">{tr(\"export.format.json\", \"JSON\")}</option>\n </select>\n </div>\n </div>\n <div className=\"space-y-1\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.description\", \"Description\")}\n </label>\n <input\n type=\"text\"\n aria-label={tr(\n \"export.templates.form.fields.description\",\n \"Description\",\n )}\n placeholder={tr(\n \"export.templates.form.fields.descriptionPlaceholder\",\n \"Optional description\",\n )}\n value={newTemplateDescription}\n onChange={(e) => setNewTemplateDescription(e.target.value)}\n className=\"w-full px-3 py-2 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all\"\n />\n </div>\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">\n {tr(\"export.templates.form.fields.entityTypes\", \"Entity Types\")} *{\" \"}\n <span className=\"text-text-secondary font-normal\">\n {tr(\n \"export.templates.form.fields.entityTypesHint\",\n \"(select at least one)\",\n )}\n </span>\n </label>\n <div className=\"flex flex-wrap gap-2\">\n {availableEntities.map((entity) => (\n <button\n key={entity.entityType}\n type=\"button\"\n onClick={() => toggleEntity(entity.entityType)}\n className={cn(\n \"px-3 py-1.5 rounded-lg text-sm font-medium border-2 transition-all\",\n newTemplateEntityTypes.includes(entity.entityType)\n ? \"border-primary bg-action-primary-bg/10 text-primary\"\n : \"border-border-subtle bg-bg-surface hover:border-primary/50\",\n )}\n >\n {entity.displayName}\n </button>\n ))}\n </div>\n </div>\n <div className=\"flex gap-3 pt-2\">\n <button\n type=\"button\"\n onClick={handleCreateTemplate}\n disabled={creating}\n className=\"inline-flex items-center gap-2 px-5 py-2.5 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors font-medium disabled:opacity-50\"\n >\n {creating ? (\n <Loader2 size={16} className=\"animate-spin\" />\n ) : (\n <Plus size={16} />\n )}\n {tr(\"export.templates.form.actions.create\", \"Create Template\")}\n </button>\n <button\n type=\"button\"\n onClick={() => setShowCreateForm(false)}\n className=\"px-5 py-2.5 border-2 border-border-subtle rounded-lg hover:bg-accent transition-colors font-medium\"\n >\n {tr(\"export.templates.form.actions.cancel\", \"Cancel\")}\n </button>\n </div>\n </div>\n )}\n {/* Search */}\n <div className=\"relative group\">\n <Search\n size={18}\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary group-focus-within:text-primary transition-colors\"\n />\n <input\n type=\"text\"\n aria-label={tr(\n \"export.templates.search.placeholder\",\n \"Search templates\",\n )}\n placeholder={tr(\n \"export.templates.search.placeholder\",\n \"Search templates...\",\n )}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2.5 border-2 border-border-subtle rounded-lg bg-bg-surface focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all duration-200\"\n />\n {searchQuery && (\n <button\n type=\"button\"\n onClick={() => setSearchQuery(\"\")}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 p-1 rounded-md text-text-secondary hover:text-text-primary hover:bg-accent\"\n >\n <X size={16} />\n </button>\n )}\n </div>\n\n {/* Loading */}\n {isLoading && (\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-4\">\n {[...Array(4)].map((_, i) => (\n <div key={i} className=\"border border-border-seam rounded-xl p-5\">\n <div className=\"h-5 w-40 bg-bg-sunken rounded mb-3 animate-vc-shimmer\" />\n <div className=\"h-3 w-full bg-bg-sunken rounded mb-2 animate-vc-shimmer\" />\n <div className=\"flex gap-2 mt-4\">\n <div className=\"h-5 w-16 bg-bg-sunken rounded-full animate-vc-shimmer\" />\n <div className=\"h-5 w-16 bg-bg-sunken rounded-full animate-vc-shimmer\" />\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Templates Grid */}\n {!isLoading ? (\n filteredTemplates.length > 0 ? (\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-4\">\n {filteredTemplates.map((template, index) => (\n <div\n key={template.id}\n role=\"button\"\n tabIndex={0}\n onClick={() => handleTemplateClick(template.id)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handleTemplateClick(template.id);\n }\n }}\n className={cn(\n \"text-left group cursor-pointer border border-border-seam rounded-xl overflow-hidden bg-bg-surface\",\n \"hover:border-primary/40 shadow-[var(--shadow-pop)] transition-colors duration-200\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40\",\n \"animate-in fade-in-0\",\n )}\n style={{ animationDelay: `${index * 50}ms` }}\n >\n {/* Header */}\n <div className=\"p-4 border-b bg-bg-sunken/30\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 rounded-lg bg-action-primary-bg/10\">\n <FileBox size={20} className=\"text-primary\" />\n </div>\n <div>\n <h3 className=\"font-semibold\">{template.name}</h3>\n <p className=\"text-xs text-text-secondary\">\n {getFormatDisplayName(template.format)}\n {template.isDefault && (\n <span className=\"ml-1.5 inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-action-primary-bg/10 text-primary font-medium\">\n {tr(\"export.templates.card.default\", \"Default\")}\n </span>\n )}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={(e) => handleDeleteTemplate(e, template.id)}\n className=\"p-1.5 rounded-md text-text-secondary hover:text-status-error-text hover:bg-status-error-bg/10 transition-colors\"\n aria-label={tr(\n \"export.templates.card.deleteAriaLabel\",\n \"Delete {{name}}\",\n { name: template.name },\n )}\n >\n <X size={14} />\n </button>\n <ChevronRight\n size={18}\n className=\"text-text-secondary group-hover:text-primary transition-colors mt-1\"\n />\n </div>\n </div>\n </div>\n\n {/* Body */}\n <div className=\"p-4\">\n {template.description && (\n <p className=\"text-sm text-text-secondary mb-3 line-clamp-2\">\n {template.description}\n </p>\n )}\n <div className=\"flex flex-wrap gap-1.5 overflow-hidden\">\n {template.entityTypes.slice(0, 6).map((entity) => (\n <span\n key={entity}\n className=\"inline-flex px-2 py-0.5 rounded text-xs font-medium bg-bg-sunken text-text-secondary max-w-full truncate\"\n >\n {entity}\n </span>\n ))}\n {template.entityTypes.length > 6 && (\n <span className=\"inline-flex px-2 py-0.5 rounded text-xs font-medium bg-bg-sunken text-text-secondary\">\n {tr(\n \"export.templates.card.moreEntities\",\n \"+{{count}} more\",\n {\n count: template.entityTypes.length - 6,\n },\n )}\n </span>\n )}\n </div>\n </div>\n </div>\n ))}\n </div>\n ) : (\n <IllustratedEmptyState\n illustration={searchQuery ? \"empty-search\" : \"empty-data\"}\n title={\n searchQuery\n ? tr(\n \"export.templates.empty.filtered.title\",\n \"No matching templates\",\n )\n : tr(\"export.templates.empty.title\", \"No templates yet\")\n }\n description={\n searchQuery\n ? tr(\n \"export.templates.empty.filtered.description\",\n \"Try adjusting your search to find what you are looking for.\",\n )\n : tr(\n \"export.templates.empty.description\",\n \"Create a template to save reusable export configurations.\",\n )\n }\n action={\n searchQuery ? (\n <button\n type=\"button\"\n onClick={() => setSearchQuery(\"\")}\n className=\"inline-flex items-center gap-2 px-4 py-2 border-2 border-border-subtle rounded-lg hover:bg-accent transition-colors font-medium\"\n >\n <X size={16} />\n {tr(\n \"export.templates.empty.filtered.actions.clear\",\n \"Clear Search\",\n )}\n </button>\n ) : (\n <button\n type=\"button\"\n onClick={handleOpenCreate}\n className=\"inline-flex items-center gap-2 px-4 py-2 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors font-medium\"\n >\n <Plus size={16} />\n {tr(\n \"export.templates.empty.actions.newTemplate\",\n \"New Template\",\n )}\n </button>\n )\n }\n />\n )\n ) : null}\n {templatePendingDelete && (\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"template-list-delete-title\"\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-surface/80 backdrop-blur-sm p-4\"\n >\n <div className=\"w-full max-w-md rounded-xl border-2 border-border-subtle bg-bg-surface p-6 shadow-xl\">\n <h2 id=\"template-list-delete-title\" className=\"text-lg font-bold\">\n {tr(\"export.templates.delete.title\", \"Delete template?\")}\n </h2>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {tr(\n \"export.templates.delete.description\",\n \"This removes the saved export configuration. Existing export jobs are not deleted.\",\n )}\n </p>\n <div className=\"mt-6 flex flex-col-reverse sm:flex-row sm:justify-end gap-3\">\n <button\n type=\"button\"\n onClick={() => setTemplatePendingDelete(null)}\n className=\"px-4 py-2 rounded-lg border-2 border-border-subtle hover:bg-accent transition-colors font-medium\"\n >\n {tr(\"export.templates.delete.cancel\", \"Keep Template\")}\n </button>\n <button\n type=\"button\"\n onClick={confirmDeleteTemplate}\n className=\"px-4 py-2 rounded-lg bg-status-error-bg text-status-error-text hover:bg-status-error-bg/90 transition-colors font-medium\"\n >\n {tr(\"export.templates.delete.confirmAction\", \"Delete Template\")}\n </button>\n </div>\n </div>\n </div>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,IAAMA,KAAY,GAAc,OACZC,EAAK,SAAS,GAAG,IAAIA,EAAK,MAAM,GAAG,EAAE,IAAIA,MACzCC,EAAK,WAAW,GAAG,IAAIA,IAAO,IAAIA;AAQtD,SAAgBC,IAAsB;CACpC,IAAM,EAAE,cAAW,KAAK,gBAAaC,EAAU,GACzCC,IAAKC,EAAM,GACX,EAAE,MAAMC,GAAW,iBAAcC,EAAmB,GACpD,EAAE,sBAAmBC,EAAwB,GAC7C,EAAE,mBAAgB,WAAWC,MAAaC,EAAwB,GAClE,EAAE,MAAMC,MAAsBC,EAAqB,GAEnD,CAACC,GAAaC,KAAkBC,EAAS,EAAE,GAC3C,CAACC,GAAgBC,KAAqBF,EAAS,EAAK,GACpD,CAACG,GAAiBC,KAAsBJ,EAAS,EAAE,GACnD,CAACK,GAAwBC,KAA6BN,EAAS,EAAE,GACjE,CAACO,GAAwBC,KAA6BR,EAE1D,CAAC,CAAC,GACE,CAACS,GAAmBC,KACxBV,EAAuB,KAAK,GACxB,CAACW,GAAaC,KAAkBZ,EAAwB,IAAI,GAC5D,CAACa,GAAuBC,KAA4Bd,EAExD,IAAI,GAEAe,UAAyB;EAM7B,AALAX,EAAmB,EAAE,GACrBE,EAA0B,EAAE,GAC5BE,EAA0B,CAAC,CAAC,GAC5BE,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,EAAM,MAAM,GAAK,CAAA,GAChBhD,EACC,8CACA,cACF,CACM;;GAGb,CAAA;GAGJwB,KACC,kBAAC,OAAD;IACE,MAAK;IACL,cAAW;IACX,mBAAgB;IAChB,WAAU;IAEV,UAAA,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACE,kBAAC,MAAD;OAAI,IAAG;OAA6B,WAAU;OAC3C,UAAAxB,EAAG,iCAAiC,kBAAkB;MACrD,CAAA;MACJ,kBAAC,KAAD;OAAG,WAAU;OACV,UAAAA,EACC,uCACA,oFACF;MACC,CAAA;MACH,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACE,kBAAC,UAAD;QACE,MAAK;QACL,eAAeyB,EAAyB,IAAI;QAC5C,WAAU;QAET,UAAAzB,EAAG,kCAAkC,eAAe;OAC/C,CAAA,GACR,kBAAC,UAAD;QACE,MAAK;QACL,SAAS0C;QACT,WAAU;QAET,UAAA1C,EAAG,yCAAyC,iBAAiB;OACxD,CAAA,CACL;;KACF;;GACF,CAAA;EAEG;;AAEhB"}
|
|
@@ -3,5 +3,4 @@
|
|
|
3
3
|
* View template details and use it to create a new export.
|
|
4
4
|
* Fetches template from the backend via useExportTemplate hook.
|
|
5
5
|
*/
|
|
6
|
-
export declare function TemplateDetailPage(): import(
|
|
7
|
-
//# sourceMappingURL=TemplateDetailPage.d.ts.map
|
|
6
|
+
export declare function TemplateDetailPage(): import('react').JSX.Element;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { useExport as e } from "../providers/ExportProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useDeleteExportTemplate as t, useExportTemplate as n } from "../hooks/useExportQueries.js";
|
|
3
|
+
import { getArchiveFormatDisplayName as r, getFormatDisplayName as i } from "../constants/enums.js";
|
|
4
|
+
import { PageLayout as a, PageSection as o } from "../components/PageLayout.js";
|
|
5
|
+
import { useTr as s } from "../hooks/useTr.js";
|
|
6
6
|
import { nativeImpact as c, nativeNotify as l } from "../../utils/nativeBridge.js";
|
|
7
7
|
import { useState as u } from "react";
|
|
8
8
|
import { ArrowLeft as d, Clock as f, Download as p, FileBox as m, FileText as h, HardDrive as g, Loader2 as _, Play as v, Trash2 as y } from "lucide-react";
|
|
9
9
|
import { useParams as b } from "react-router";
|
|
10
10
|
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
11
11
|
import { CTAOverflowMenu as C, GlassCard as w, IllustratedEmptyState as T, NextSteps as E, ShowMore as D } from "@burdenoff/fe-libs/ui";
|
|
12
|
-
|
|
12
|
+
// src/export/pages/TemplateDetailPage.tsx
|
|
13
13
|
var O = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
14
14
|
function k() {
|
|
15
|
-
let { templateId: k } = b(), { basePath: A = "/", navigate: j } = e(), M =
|
|
15
|
+
let { templateId: k } = b(), { basePath: A = "/", navigate: j } = e(), M = s(), [N, P] = u(!1), { data: F, isLoading: I } = n(k), { deleteTemplate: L, isPending: R } = t();
|
|
16
16
|
if (I) return /* @__PURE__ */ S("div", {
|
|
17
17
|
className: "flex flex-col items-center justify-center py-20",
|
|
18
18
|
children: [/* @__PURE__ */ x(_, {
|
|
@@ -23,7 +23,7 @@ function k() {
|
|
|
23
23
|
children: M("export.templateDetail.loading", "Loading template details…")
|
|
24
24
|
})]
|
|
25
25
|
});
|
|
26
|
-
if (!F) return /* @__PURE__ */ S(
|
|
26
|
+
if (!F) return /* @__PURE__ */ S(a, {
|
|
27
27
|
showHeader: !1,
|
|
28
28
|
children: [/* @__PURE__ */ S("div", {
|
|
29
29
|
className: "flex items-center gap-3 mb-6",
|
|
@@ -79,7 +79,7 @@ function k() {
|
|
|
79
79
|
icon: /* @__PURE__ */ x(m, { size: 16 }),
|
|
80
80
|
onClick: () => j?.(O(A, "templates"))
|
|
81
81
|
}];
|
|
82
|
-
return /* @__PURE__ */ S(
|
|
82
|
+
return /* @__PURE__ */ S(a, {
|
|
83
83
|
showHeader: !1,
|
|
84
84
|
children: [
|
|
85
85
|
/* @__PURE__ */ x("div", {
|
|
@@ -140,12 +140,12 @@ function k() {
|
|
|
140
140
|
{
|
|
141
141
|
icon: /* @__PURE__ */ x(h, { size: 18 }),
|
|
142
142
|
label: M("export.templateDetail.info.format", "Format"),
|
|
143
|
-
value:
|
|
143
|
+
value: i(F.format)
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
icon: /* @__PURE__ */ x(g, { size: 18 }),
|
|
147
147
|
label: M("export.templateDetail.info.archive", "Archive"),
|
|
148
|
-
value:
|
|
148
|
+
value: r("ZIP")
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
icon: /* @__PURE__ */ x(p, { size: 18 }),
|
|
@@ -180,7 +180,7 @@ function k() {
|
|
|
180
180
|
title: M("export.templateDetail.nextSteps.title", "What's next"),
|
|
181
181
|
steps: H
|
|
182
182
|
}),
|
|
183
|
-
/* @__PURE__ */ x(
|
|
183
|
+
/* @__PURE__ */ x(o, {
|
|
184
184
|
title: M("export.templateDetail.entityTypes.title", "Included Entity Types"),
|
|
185
185
|
description: M("export.templateDetail.entityTypes.description", "Data types that will be exported"),
|
|
186
186
|
children: /* @__PURE__ */ x(D, {
|
|
@@ -235,7 +235,6 @@ function k() {
|
|
|
235
235
|
]
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
|
-
//#endregion
|
|
239
238
|
export { k as TemplateDetailPage };
|
|
240
239
|
|
|
241
240
|
//# sourceMappingURL=TemplateDetailPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateDetailPage.js","names":[],"sources":["../../../src/export/pages/TemplateDetailPage.tsx"],"sourcesContent":["import { useParams } from \"react-router\";\nimport { useState } from \"react\";\nimport {\n ArrowLeft,\n FileBox,\n Download,\n Play,\n Trash2,\n Clock,\n FileText,\n HardDrive,\n Loader2,\n} from \"lucide-react\";\nimport {\n GlassCard,\n CTAOverflowMenu,\n ShowMore,\n IllustratedEmptyState,\n NextSteps,\n type NextStep,\n} from \"@burdenoff/fe-libs/ui\";\nimport type { CTAAction } from \"@burdenoff/fe-libs/ui\";\nimport { useExport } from \"../providers/ExportProvider\";\nimport {\n useExportTemplate,\n useDeleteExportTemplate,\n} from \"../hooks/useExportQueries\";\nimport {\n getFormatDisplayName,\n getArchiveFormatDisplayName,\n} from \"../constants/enums\";\nimport { PageLayout, PageSection } from \"../components/PageLayout\";\nimport { useTr } from \"../hooks/useTr\";\nimport { nativeImpact, nativeNotify } from \"../../utils/nativeBridge\";\n\n/**\n * Helper to join paths correctly\n */\nconst joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n return cleanBase + cleanPath;\n};\n\n/**\n * Template Detail Page\n * View template details and use it to create a new export.\n * Fetches template from the backend via useExportTemplate hook.\n */\nexport function TemplateDetailPage() {\n const { templateId } = useParams<{ templateId: string }>();\n const { basePath = \"/\", navigate } = useExport();\n const tr = useTr();\n const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);\n\n const { data: template, isLoading } = useExportTemplate(templateId);\n const { deleteTemplate, isPending: deleting } = useDeleteExportTemplate();\n\n // Loading\n if (isLoading) {\n return (\n <div className=\"flex flex-col items-center justify-center py-20\">\n <Loader2 size={48} className=\"animate-spin text-primary\" />\n <span className=\"mt-6 text-sm font-medium text-text-secondary\">\n {tr(\"export.templateDetail.loading\", \"Loading template details…\")}\n </span>\n </div>\n );\n }\n\n if (!template) {\n return (\n <PageLayout showHeader={false}>\n <div className=\"flex items-center gap-3 mb-6\">\n <button\n type=\"button\"\n onClick={() => navigate?.(joinPath(basePath, \"templates\"))}\n aria-label={tr(\n \"export.templateDetail.actions.backToTemplates\",\n \"Back to templates\",\n )}\n className=\"p-2.5 hover:bg-accent rounded-lg transition-all duration-200\"\n >\n <ArrowLeft size={20} />\n </button>\n <h1 className=\"text-xl font-bold\">\n {tr(\"export.templateDetail.notFound.title\", \"Template Not Found\")}\n </h1>\n </div>\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={tr(\n \"export.templateDetail.notFound.heading\",\n \"Template not found\",\n )}\n description={tr(\n \"export.templateDetail.notFound.description\",\n \"The template you are looking for does not exist.\",\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigate?.(joinPath(basePath, \"templates\"))}\n className=\"inline-flex items-center gap-2 px-6 py-3 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors font-medium\"\n >\n <ArrowLeft size={18} />\n {tr(\n \"export.templateDetail.actions.backToTemplates\",\n \"Back to Templates\",\n )}\n </button>\n }\n />\n </PageLayout>\n );\n }\n\n const handleUseTemplate = () => {\n // Navigate to new export page pre-selected with this template\n navigate?.(joinPath(basePath, `new?templateId=${templateId}`));\n };\n\n const handleDelete = async () => {\n if (!templateId) return;\n nativeImpact(\"medium\");\n try {\n await deleteTemplate(templateId);\n nativeNotify(\"success\");\n navigate?.(joinPath(basePath, \"templates\"));\n } catch {\n nativeNotify(\"error\");\n }\n };\n\n const overflowActions: CTAAction[] = template.isDefault\n ? []\n : [\n {\n label: tr(\"export.templateDetail.actions.delete\", \"Delete Template\"),\n icon: <Trash2 size={16} />,\n intent: \"destructive\",\n disabled: deleting,\n onSelect: () => setShowDeleteConfirm(true),\n },\n ];\n\n // Next-step guidance — what a new user would do with a saved template.\n const nextSteps: NextStep[] = [\n {\n id: \"use\",\n label: tr(\n \"export.templateDetail.nextSteps.use.label\",\n \"Start an export from this template\",\n ),\n description: tr(\n \"export.templateDetail.nextSteps.use.description\",\n \"Pre-fills a new export with this template's entity types and format.\",\n ),\n icon: <Play size={16} />,\n onClick: handleUseTemplate,\n },\n {\n id: \"browse\",\n label: tr(\n \"export.templateDetail.nextSteps.browse.label\",\n \"Browse all templates\",\n ),\n description: tr(\n \"export.templateDetail.nextSteps.browse.description\",\n \"Manage your other saved export configurations.\",\n ),\n icon: <FileBox size={16} />,\n onClick: () => navigate?.(joinPath(basePath, \"templates\")),\n },\n ];\n\n return (\n <PageLayout showHeader={false}>\n {/* Header */}\n <div className=\"relative overflow-hidden rounded-xl bg-accent-wash border border-border-seam p-6 shadow-[var(--shadow-pop)]\">\n <div className=\"relative z-10 flex flex-col sm:flex-row sm:items-center gap-4\">\n <button\n type=\"button\"\n onClick={() => navigate?.(joinPath(basePath, \"templates\"))}\n aria-label={tr(\n \"export.templateDetail.actions.backToTemplates\",\n \"Back to templates\",\n )}\n className=\"p-2.5 hover:bg-accent rounded-lg transition-colors duration-200 self-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40\"\n >\n <ArrowLeft size={20} />\n </button>\n <div className=\"flex items-center gap-3 flex-1 min-w-0\">\n <div className=\"p-2.5 rounded-lg bg-action-primary-bg/10\">\n <FileBox size={24} className=\"text-primary\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h1 className=\"text-xl sm:text-2xl font-bold truncate\">\n {template.name}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n {template.isDefault\n ? tr(\n \"export.templateDetail.badge.default\",\n \"Default template\",\n )\n : tr(\"export.templateDetail.badge.custom\", \"Custom template\")}\n </p>\n </div>\n </div>\n <div className=\"flex-shrink-0\">\n <CTAOverflowMenu\n primary={{\n label: tr(\"export.templateDetail.actions.use\", \"Use Template\"),\n icon: <Play size={16} />,\n onSelect: handleUseTemplate,\n }}\n actions={overflowActions}\n />\n </div>\n </div>\n </div>\n\n {/* Description */}\n {template.description && (\n <div className=\"border border-border-seam rounded-xl p-5 bg-bg-surface\">\n <p className=\"text-sm text-text-secondary\">{template.description}</p>\n </div>\n )}\n\n {/* Info Grid */}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4\">\n {[\n {\n icon: <FileText size={18} />,\n label: tr(\"export.templateDetail.info.format\", \"Format\"),\n value: getFormatDisplayName(template.format),\n },\n {\n icon: <HardDrive size={18} />,\n label: tr(\"export.templateDetail.info.archive\", \"Archive\"),\n // Backend template doesn't carry archiveFormat, default to ZIP\n value: getArchiveFormatDisplayName(\"ZIP\"),\n },\n {\n icon: <Download size={18} />,\n label: tr(\"export.templateDetail.info.entityTypes\", \"Entity Types\"),\n value: tr(\n \"export.templateDetail.info.entityTypesCount\",\n \"{{count}} type{{suffix}}\",\n {\n count: template.entityTypes.length,\n suffix: template.entityTypes.length !== 1 ? \"s\" : \"\",\n },\n ),\n },\n {\n icon: <Clock size={18} />,\n label: tr(\"export.templateDetail.info.lastUpdated\", \"Last Updated\"),\n value: new Date(template.updatedAt).toLocaleDateString(),\n },\n ].map((item) => (\n <GlassCard\n key={item.label}\n treatment=\"metric\"\n className=\"p-4 border-border-seam\"\n >\n <div className=\"flex items-center gap-2 text-text-secondary mb-1\">\n {item.icon}\n <span className=\"text-xs font-medium\">{item.label}</span>\n </div>\n <p className=\"font-bold text-lg tabular-nums\">{item.value}</p>\n </GlassCard>\n ))}\n </div>\n\n {/* Next-step guidance (dismissable, per-template) */}\n <NextSteps\n storageKey={`export-template-${template.id}`}\n title={tr(\"export.templateDetail.nextSteps.title\", \"What's next\")}\n steps={nextSteps}\n />\n\n {/* Entity Types */}\n <PageSection\n title={tr(\n \"export.templateDetail.entityTypes.title\",\n \"Included Entity Types\",\n )}\n description={tr(\n \"export.templateDetail.entityTypes.description\",\n \"Data types that will be exported\",\n )}\n >\n <ShowMore collapsedHeight={96}>\n <div className=\"flex flex-wrap gap-2\">\n {template.entityTypes.map((entity) => (\n <span\n key={entity}\n className=\"inline-flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium border border-border-seam bg-bg-sunken/30\"\n >\n {entity}\n </span>\n ))}\n </div>\n </ShowMore>\n </PageSection>\n\n {showDeleteConfirm && (\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"template-delete-title\"\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-surface/80 backdrop-blur-sm p-4\"\n >\n <div className=\"w-full max-w-md rounded-xl border-2 border-border-subtle bg-bg-surface p-6 shadow-xl\">\n <h2 id=\"template-delete-title\" className=\"text-lg font-bold\">\n {tr(\"export.templateDetail.delete.title\", \"Delete template?\")}\n </h2>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {tr(\n \"export.templateDetail.delete.description\",\n \"This removes the saved export configuration. Existing export jobs are not deleted.\",\n )}\n </p>\n <div className=\"mt-6 flex flex-col-reverse sm:flex-row sm:justify-end gap-3\">\n <button\n type=\"button\"\n onClick={() => setShowDeleteConfirm(false)}\n className=\"px-4 py-2 rounded-lg border-2 border-border-subtle hover:bg-accent transition-colors font-medium\"\n >\n {tr(\"export.templateDetail.delete.keep\", \"Keep Template\")}\n </button>\n <button\n type=\"button\"\n onClick={handleDelete}\n disabled={deleting}\n className=\"inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-status-error-bg text-status-error-text hover:bg-status-error-bg/90 transition-colors font-medium disabled:opacity-50\"\n >\n {deleting ? (\n <Loader2 size={16} className=\"animate-spin\" />\n ) : null}\n {tr(\n \"export.templateDetail.delete.confirmAction\",\n \"Delete Template\",\n )}\n </button>\n </div>\n </div>\n </div>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,IAAM,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AAStD,SAAgB,IAAqB;CACnC,IAAM,EAAE,kBAAe,GAAmC,EACpD,EAAE,cAAW,KAAK,gBAAa,GAAW,EAC1C,IAAK,GAAO,EACZ,CAAC,GAAmB,KAAwB,EAAS,GAAM,EAE3D,EAAE,MAAM,GAAU,iBAAc,EAAkB,EAAW,EAC7D,EAAE,mBAAgB,WAAW,MAAa,GAAyB;AAGzE,KAAI,EACF,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,GAAD;GAAS,MAAM;GAAI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X,mBAAgB;IAChB,WAAU;cAEV,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,MAAD;OAAI,IAAG;OAAwB,WAAU;iBACtC,EAAG,sCAAsC,mBAAmB;OAC1D,CAAA;MACL,kBAAC,KAAD;OAAG,WAAU;iBACV,EACC,4CACA,qFACD;OACC,CAAA;MACJ,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,UAAD;QACE,MAAK;QACL,eAAe,EAAqB,GAAM;QAC1C,WAAU;kBAET,EAAG,qCAAqC,gBAAgB;QAClD,CAAA,EACT,kBAAC,UAAD;QACE,MAAK;QACL,SAAS;QACT,UAAU;QACV,WAAU;kBAJZ,CAMG,IACC,kBAAC,GAAD;SAAS,MAAM;SAAI,WAAU;SAAiB,CAAA,GAC5C,MACH,EACC,8CACA,kBACD,CACM;UACL;;MACF;;IACF,CAAA;GAEG"}
|
|
1
|
+
{"version":3,"file":"TemplateDetailPage.js","names":["joinPath","base","path","TemplateDetailPage","useParams","useExport","tr","useTr","showDeleteConfirm","setShowDeleteConfirm","useState","template","useExportTemplate","templateId","deleting","useDeleteExportTemplate","isLoading","Loader2","PageLayout","navigate","basePath","ArrowLeft","IllustratedEmptyState","handleUseTemplate","handleDelete","deleteTemplate","nativeNotify","overflowActions","Trash2","nextSteps","Play","FileBox","CTAOverflowMenu","FileText","getFormatDisplayName","HardDrive","getArchiveFormatDisplayName","Download","Clock","GlassCard","item","NextSteps","PageSection","ShowMore","entity"],"sources":["../../../src/export/pages/TemplateDetailPage.tsx"],"sourcesContent":["import { useParams } from \"react-router\";\nimport { useState } from \"react\";\nimport {\n ArrowLeft,\n FileBox,\n Download,\n Play,\n Trash2,\n Clock,\n FileText,\n HardDrive,\n Loader2,\n} from \"lucide-react\";\nimport {\n GlassCard,\n CTAOverflowMenu,\n ShowMore,\n IllustratedEmptyState,\n NextSteps,\n type NextStep,\n} from \"@burdenoff/fe-libs/ui\";\nimport type { CTAAction } from \"@burdenoff/fe-libs/ui\";\nimport { useExport } from \"../providers/ExportProvider\";\nimport {\n useExportTemplate,\n useDeleteExportTemplate,\n} from \"../hooks/useExportQueries\";\nimport {\n getFormatDisplayName,\n getArchiveFormatDisplayName,\n} from \"../constants/enums\";\nimport { PageLayout, PageSection } from \"../components/PageLayout\";\nimport { useTr } from \"../hooks/useTr\";\nimport { nativeImpact, nativeNotify } from \"../../utils/nativeBridge\";\n\n/**\n * Helper to join paths correctly\n */\nconst joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n return cleanBase + cleanPath;\n};\n\n/**\n * Template Detail Page\n * View template details and use it to create a new export.\n * Fetches template from the backend via useExportTemplate hook.\n */\nexport function TemplateDetailPage() {\n const { templateId } = useParams<{ templateId: string }>();\n const { basePath = \"/\", navigate } = useExport();\n const tr = useTr();\n const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);\n\n const { data: template, isLoading } = useExportTemplate(templateId);\n const { deleteTemplate, isPending: deleting } = useDeleteExportTemplate();\n\n // Loading\n if (isLoading) {\n return (\n <div className=\"flex flex-col items-center justify-center py-20\">\n <Loader2 size={48} className=\"animate-spin text-primary\" />\n <span className=\"mt-6 text-sm font-medium text-text-secondary\">\n {tr(\"export.templateDetail.loading\", \"Loading template details…\")}\n </span>\n </div>\n );\n }\n\n if (!template) {\n return (\n <PageLayout showHeader={false}>\n <div className=\"flex items-center gap-3 mb-6\">\n <button\n type=\"button\"\n onClick={() => navigate?.(joinPath(basePath, \"templates\"))}\n aria-label={tr(\n \"export.templateDetail.actions.backToTemplates\",\n \"Back to templates\",\n )}\n className=\"p-2.5 hover:bg-accent rounded-lg transition-all duration-200\"\n >\n <ArrowLeft size={20} />\n </button>\n <h1 className=\"text-xl font-bold\">\n {tr(\"export.templateDetail.notFound.title\", \"Template Not Found\")}\n </h1>\n </div>\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={tr(\n \"export.templateDetail.notFound.heading\",\n \"Template not found\",\n )}\n description={tr(\n \"export.templateDetail.notFound.description\",\n \"The template you are looking for does not exist.\",\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigate?.(joinPath(basePath, \"templates\"))}\n className=\"inline-flex items-center gap-2 px-6 py-3 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors font-medium\"\n >\n <ArrowLeft size={18} />\n {tr(\n \"export.templateDetail.actions.backToTemplates\",\n \"Back to Templates\",\n )}\n </button>\n }\n />\n </PageLayout>\n );\n }\n\n const handleUseTemplate = () => {\n // Navigate to new export page pre-selected with this template\n navigate?.(joinPath(basePath, `new?templateId=${templateId}`));\n };\n\n const handleDelete = async () => {\n if (!templateId) return;\n nativeImpact(\"medium\");\n try {\n await deleteTemplate(templateId);\n nativeNotify(\"success\");\n navigate?.(joinPath(basePath, \"templates\"));\n } catch {\n nativeNotify(\"error\");\n }\n };\n\n const overflowActions: CTAAction[] = template.isDefault\n ? []\n : [\n {\n label: tr(\"export.templateDetail.actions.delete\", \"Delete Template\"),\n icon: <Trash2 size={16} />,\n intent: \"destructive\",\n disabled: deleting,\n onSelect: () => setShowDeleteConfirm(true),\n },\n ];\n\n // Next-step guidance — what a new user would do with a saved template.\n const nextSteps: NextStep[] = [\n {\n id: \"use\",\n label: tr(\n \"export.templateDetail.nextSteps.use.label\",\n \"Start an export from this template\",\n ),\n description: tr(\n \"export.templateDetail.nextSteps.use.description\",\n \"Pre-fills a new export with this template's entity types and format.\",\n ),\n icon: <Play size={16} />,\n onClick: handleUseTemplate,\n },\n {\n id: \"browse\",\n label: tr(\n \"export.templateDetail.nextSteps.browse.label\",\n \"Browse all templates\",\n ),\n description: tr(\n \"export.templateDetail.nextSteps.browse.description\",\n \"Manage your other saved export configurations.\",\n ),\n icon: <FileBox size={16} />,\n onClick: () => navigate?.(joinPath(basePath, \"templates\")),\n },\n ];\n\n return (\n <PageLayout showHeader={false}>\n {/* Header */}\n <div className=\"relative overflow-hidden rounded-xl bg-accent-wash border border-border-seam p-6 shadow-[var(--shadow-pop)]\">\n <div className=\"relative z-10 flex flex-col sm:flex-row sm:items-center gap-4\">\n <button\n type=\"button\"\n onClick={() => navigate?.(joinPath(basePath, \"templates\"))}\n aria-label={tr(\n \"export.templateDetail.actions.backToTemplates\",\n \"Back to templates\",\n )}\n className=\"p-2.5 hover:bg-accent rounded-lg transition-colors duration-200 self-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40\"\n >\n <ArrowLeft size={20} />\n </button>\n <div className=\"flex items-center gap-3 flex-1 min-w-0\">\n <div className=\"p-2.5 rounded-lg bg-action-primary-bg/10\">\n <FileBox size={24} className=\"text-primary\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h1 className=\"text-xl sm:text-2xl font-bold truncate\">\n {template.name}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n {template.isDefault\n ? tr(\n \"export.templateDetail.badge.default\",\n \"Default template\",\n )\n : tr(\"export.templateDetail.badge.custom\", \"Custom template\")}\n </p>\n </div>\n </div>\n <div className=\"flex-shrink-0\">\n <CTAOverflowMenu\n primary={{\n label: tr(\"export.templateDetail.actions.use\", \"Use Template\"),\n icon: <Play size={16} />,\n onSelect: handleUseTemplate,\n }}\n actions={overflowActions}\n />\n </div>\n </div>\n </div>\n\n {/* Description */}\n {template.description && (\n <div className=\"border border-border-seam rounded-xl p-5 bg-bg-surface\">\n <p className=\"text-sm text-text-secondary\">{template.description}</p>\n </div>\n )}\n\n {/* Info Grid */}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4\">\n {[\n {\n icon: <FileText size={18} />,\n label: tr(\"export.templateDetail.info.format\", \"Format\"),\n value: getFormatDisplayName(template.format),\n },\n {\n icon: <HardDrive size={18} />,\n label: tr(\"export.templateDetail.info.archive\", \"Archive\"),\n // Backend template doesn't carry archiveFormat, default to ZIP\n value: getArchiveFormatDisplayName(\"ZIP\"),\n },\n {\n icon: <Download size={18} />,\n label: tr(\"export.templateDetail.info.entityTypes\", \"Entity Types\"),\n value: tr(\n \"export.templateDetail.info.entityTypesCount\",\n \"{{count}} type{{suffix}}\",\n {\n count: template.entityTypes.length,\n suffix: template.entityTypes.length !== 1 ? \"s\" : \"\",\n },\n ),\n },\n {\n icon: <Clock size={18} />,\n label: tr(\"export.templateDetail.info.lastUpdated\", \"Last Updated\"),\n value: new Date(template.updatedAt).toLocaleDateString(),\n },\n ].map((item) => (\n <GlassCard\n key={item.label}\n treatment=\"metric\"\n className=\"p-4 border-border-seam\"\n >\n <div className=\"flex items-center gap-2 text-text-secondary mb-1\">\n {item.icon}\n <span className=\"text-xs font-medium\">{item.label}</span>\n </div>\n <p className=\"font-bold text-lg tabular-nums\">{item.value}</p>\n </GlassCard>\n ))}\n </div>\n\n {/* Next-step guidance (dismissable, per-template) */}\n <NextSteps\n storageKey={`export-template-${template.id}`}\n title={tr(\"export.templateDetail.nextSteps.title\", \"What's next\")}\n steps={nextSteps}\n />\n\n {/* Entity Types */}\n <PageSection\n title={tr(\n \"export.templateDetail.entityTypes.title\",\n \"Included Entity Types\",\n )}\n description={tr(\n \"export.templateDetail.entityTypes.description\",\n \"Data types that will be exported\",\n )}\n >\n <ShowMore collapsedHeight={96}>\n <div className=\"flex flex-wrap gap-2\">\n {template.entityTypes.map((entity) => (\n <span\n key={entity}\n className=\"inline-flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium border border-border-seam bg-bg-sunken/30\"\n >\n {entity}\n </span>\n ))}\n </div>\n </ShowMore>\n </PageSection>\n\n {showDeleteConfirm && (\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"template-delete-title\"\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-surface/80 backdrop-blur-sm p-4\"\n >\n <div className=\"w-full max-w-md rounded-xl border-2 border-border-subtle bg-bg-surface p-6 shadow-xl\">\n <h2 id=\"template-delete-title\" className=\"text-lg font-bold\">\n {tr(\"export.templateDetail.delete.title\", \"Delete template?\")}\n </h2>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {tr(\n \"export.templateDetail.delete.description\",\n \"This removes the saved export configuration. Existing export jobs are not deleted.\",\n )}\n </p>\n <div className=\"mt-6 flex flex-col-reverse sm:flex-row sm:justify-end gap-3\">\n <button\n type=\"button\"\n onClick={() => setShowDeleteConfirm(false)}\n className=\"px-4 py-2 rounded-lg border-2 border-border-subtle hover:bg-accent transition-colors font-medium\"\n >\n {tr(\"export.templateDetail.delete.keep\", \"Keep Template\")}\n </button>\n <button\n type=\"button\"\n onClick={handleDelete}\n disabled={deleting}\n className=\"inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-status-error-bg text-status-error-text hover:bg-status-error-bg/90 transition-colors font-medium disabled:opacity-50\"\n >\n {deleting ? (\n <Loader2 size={16} className=\"animate-spin\" />\n ) : null}\n {tr(\n \"export.templateDetail.delete.confirmAction\",\n \"Delete Template\",\n )}\n </button>\n </div>\n </div>\n </div>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,IAAMA,KAAY,GAAc,OACZC,EAAK,SAAS,GAAG,IAAIA,EAAK,MAAM,GAAG,EAAE,IAAIA,MACzCC,EAAK,WAAW,GAAG,IAAIA,IAAO,IAAIA;AAStD,SAAgBC,IAAqB;CACnC,IAAM,EAAE,kBAAeC,EAAkC,GACnD,EAAE,cAAW,KAAK,gBAAaC,EAAU,GACzCC,IAAKC,EAAM,GACX,CAACC,GAAmBC,KAAwBC,EAAS,EAAK,GAE1D,EAAE,MAAMC,GAAU,iBAAcC,EAAkBC,CAAU,GAC5D,EAAE,mBAAgB,WAAWC,MAAaC,EAAwB;CAGxE,IAAIC,GACF,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACC,GAAD;GAAS,MAAM;GAAI,WAAU;EAA6B,CAAA,GAC1D,kBAAC,QAAD;GAAM,WAAU;GACb,UAAAX,EAAG,iCAAiC,2BAA2B;EAC5D,C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aAAaA,EACX,iDACA,kCACF;IAEA,UAAA,kBAACqC,GAAD;KAAU,iBAAiB;KACzB,UAAA,kBAAC,OAAD;MAAK,WAAU;MACZ,UAAAhC,EAAS,YAAY,KAAK,MACzB,kBAAC,QAAD;OAEE,WAAU;OAET,UAAAiC;MACG,GAJCA,CAID,CACP;KACE,CAAA;IACG,CAAA;GACC,CAAA;GAEZpC,KACC,kBAAC,OAAD;IACE,MAAK;IACL,cAAW;IACX,mBAAgB;IAChB,WAAU;IAEV,UAAA,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACE,kBAAC,MAAD;OAAI,IAAG;OAAwB,WAAU;OACtC,UAAAF,EAAG,sCAAsC,kBAAkB;MAC1D,CAAA;MACJ,kBAAC,KAAD;OAAG,WAAU;OACV,UAAAA,EACC,4CACA,oFACF;MACC,CAAA;MACH,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACE,kBAAC,UAAD;QACE,MAAK;QACL,eAAeG,EAAqB,EAAK;QACzC,WAAU;QAET,UAAAH,EAAG,qCAAqC,eAAe;OAClD,CAAA,GACR,kBAAC,UAAD;QACE,MAAK;QACL,SAASkB;QACT,UAAUV;QACV,WAAU;QAJZ,UAAA,CAMGA,IACC,kBAACG,GAAD;SAAS,MAAM;SAAI,WAAU;QAAgB,CAAA,IAC3C,MACHX,EACC,8CACA,iBACF,CACM;OACL,CAAA,CAAA;;KACF;;GACF,CAAA;EAEG;;AAEhB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { ExportRootProps } from '../types';
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* Hook to access Export context
|
|
6
5
|
*/
|
|
@@ -10,4 +9,3 @@ export declare const useExport: () => ExportRootProps;
|
|
|
10
9
|
* Sets up routing, context, Apollo Client, and React Query client
|
|
11
10
|
*/
|
|
12
11
|
export declare const ExportProvider: FC<PropsWithChildren<ExportRootProps>>;
|
|
13
|
-
//# sourceMappingURL=ExportProvider.d.ts.map
|
|
@@ -10,7 +10,7 @@ import { onError as y } from "@apollo/client/link/error";
|
|
|
10
10
|
import { ApolloProvider as b } from "@apollo/client/react";
|
|
11
11
|
import { isAuthNetworkError as x, redirectToLogin as S } from "@burdenoff/fe-libs/shared/utils";
|
|
12
12
|
import { jsx as C } from "react/jsx-runtime";
|
|
13
|
-
|
|
13
|
+
// src/export/providers/ExportProvider.tsx
|
|
14
14
|
function w(e = []) {
|
|
15
15
|
return e.some((e) => {
|
|
16
16
|
let t = typeof e.extensions?.code == "string" ? e.extensions.code : "", n = typeof e.extensions?.errorCode == "string" ? e.extensions.errorCode : "", r = (e.message ?? "").toLowerCase();
|
|
@@ -44,7 +44,7 @@ var T = a(null), E = () => {
|
|
|
44
44
|
defaultOptions: { queries: {
|
|
45
45
|
retry: 1,
|
|
46
46
|
refetchOnWindowFocus: !1,
|
|
47
|
-
staleTime:
|
|
47
|
+
staleTime: 3e5
|
|
48
48
|
} }
|
|
49
49
|
});
|
|
50
50
|
return e;
|
|
@@ -60,11 +60,8 @@ var T = a(null), E = () => {
|
|
|
60
60
|
}), l = y(({ error: e, operation: t, forward: n }) => {
|
|
61
61
|
if (!e) return;
|
|
62
62
|
let r = w("errors" in e && Array.isArray(e.errors) ? e.errors : []);
|
|
63
|
-
if (!R.current || !r || L.current)
|
|
64
|
-
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
return new g((e) => {
|
|
63
|
+
if (!R.current || !r || L.current) e instanceof Error && x(e) && S();
|
|
64
|
+
else return new g((e) => {
|
|
68
65
|
L.current = !0, R.current().then((r) => {
|
|
69
66
|
if (L.current = !1, !r) {
|
|
70
67
|
S(), e.error(/* @__PURE__ */ Error("Failed to refresh workspace token"));
|
|
@@ -80,15 +77,15 @@ var T = a(null), E = () => {
|
|
|
80
77
|
L.current = !1, e.error(t);
|
|
81
78
|
});
|
|
82
79
|
});
|
|
83
|
-
}), u = o.websocket
|
|
80
|
+
}), u = o.websocket, d = new t(n({
|
|
81
|
+
url: u,
|
|
82
|
+
connectionParams: Object.keys(a).length > 0 ? a : void 0
|
|
83
|
+
})), f = v(({ query: t }) => {
|
|
84
|
+
let n = e(t);
|
|
85
|
+
return n.kind === "OperationDefinition" && n.operation === "subscription";
|
|
86
|
+
}, d, _([l, c]));
|
|
84
87
|
return new p({
|
|
85
|
-
link:
|
|
86
|
-
let n = e(t);
|
|
87
|
-
return n.kind === "OperationDefinition" && n.operation === "subscription";
|
|
88
|
-
}, new t(n({
|
|
89
|
-
url: u,
|
|
90
|
-
connectionParams: Object.keys(a).length > 0 ? a : void 0
|
|
91
|
-
})), _([l, c])),
|
|
88
|
+
link: f,
|
|
92
89
|
cache: new h(),
|
|
93
90
|
defaultOptions: { watchQuery: { fetchPolicy: "cache-and-network" } }
|
|
94
91
|
});
|
|
@@ -110,7 +107,6 @@ var T = a(null), E = () => {
|
|
|
110
107
|
children: /* @__PURE__ */ C(l, { children: V })
|
|
111
108
|
});
|
|
112
109
|
};
|
|
113
|
-
//#endregion
|
|
114
110
|
export { D as ExportProvider, E as useExport };
|
|
115
111
|
|
|
116
112
|
//# sourceMappingURL=ExportProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportProvider.js","names":[],"sources":["../../../src/export/providers/ExportProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { createContext, useContext, useMemo, useRef } from \"react\";\nimport { MemoryRouter } from \"react-router\";\nimport {\n MutationCache,\n QueryClient,\n QueryClientProvider,\n} from \"@tanstack/react-query\";\nimport {\n ApolloClient,\n InMemoryCache,\n HttpLink,\n from,\n split,\n Observable,\n} from \"@apollo/client\";\nimport { getMainDefinition } from \"@apollo/client/utilities\";\nimport { GraphQLWsLink } from \"@apollo/client/link/subscriptions\";\nimport { createClient } from \"graphql-ws\";\nimport { onError } from \"@apollo/client/link/error\";\nimport { ApolloProvider } from \"@apollo/client/react\";\nimport {\n isAuthNetworkError,\n redirectToLogin,\n} from \"@burdenoff/fe-libs/shared/utils\";\nimport {\n exportGatewayHeaders,\n exportGatewayEndpoints,\n} from \"../utils/exportAuthority\";\nimport type { ExportRootProps } from \"../types\";\n\nfunction hasSessionAuthErrors(\n errors: ReadonlyArray<{\n message?: string;\n extensions?: Record<string, unknown>;\n }> = [],\n): boolean {\n return errors.some((error) => {\n const code =\n typeof error.extensions?.code === \"string\" ? error.extensions.code : \"\";\n const errorCode =\n typeof error.extensions?.errorCode === \"string\"\n ? error.extensions.errorCode\n : \"\";\n const message = (error.message ?? \"\").toLowerCase();\n\n return (\n code === \"UNAUTHENTICATED\" ||\n errorCode === \"TOKEN_EXPIRED\" ||\n message.includes(\"token_expired\") ||\n message.includes(\"token expired\") ||\n message.includes(\"session expired\") ||\n message.includes(\"unauthorized\") ||\n message.includes(\"unauthenticated\") ||\n message.includes(\"authentication required\") ||\n message.includes(\"workspace context missing\")\n );\n });\n}\n\n/**\n * Context value for Export microfrontend\n */\ntype ExportContextValue = ExportRootProps;\n\nconst ExportContext = createContext<ExportContextValue | null>(null);\n\n/**\n * Hook to access Export context\n */\nexport const useExport = () => {\n const context = useContext(ExportContext);\n if (!context) {\n throw new Error(\"useExport must be used within ExportProvider\");\n }\n return context;\n};\n\n/**\n * Provider component for Export microfrontend\n * Sets up routing, context, Apollo Client, and React Query client\n */\nexport const ExportProvider: FC<PropsWithChildren<ExportRootProps>> = ({\n children,\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n apiGatewayUrl,\n authToken,\n workspaceToken,\n eventBus,\n getWorkspaceToken,\n}) => {\n const contextValue: ExportContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n apiGatewayUrl,\n authToken,\n workspaceToken,\n eventBus,\n getWorkspaceToken,\n };\n\n // Track refreshing state across renders without triggering re-renders\n const isRefreshingRef = useRef(false);\n\n // Stable ref for getWorkspaceToken so it never invalidates the Apollo client memo\n const getWorkspaceTokenRef = useRef(getWorkspaceToken);\n getWorkspaceTokenRef.current = getWorkspaceToken;\n\n // Create QueryClient instance (memoized to avoid recreation on re-renders)\n const queryClient = useMemo(() => {\n const client = new QueryClient({\n mutationCache: new MutationCache({\n onSuccess: () => {\n void client.invalidateQueries();\n },\n }),\n defaultOptions: {\n queries: {\n retry: 1,\n refetchOnWindowFocus: false,\n staleTime: 5 * 60 * 1000, // 5 minutes\n },\n },\n });\n return client;\n }, []);\n\n // Create ApolloClient instance (memoized, recreated when tokens change)\n // The workspace gateway requires dual-token auth:\n // HTTP and subscription traffic use the public gateway with trusted host\n // credentials and explicit workspace/organization context. No subgraph bypass.\n const apolloClient = useMemo(() => {\n const headers = exportGatewayHeaders({\n authToken,\n workspaceToken,\n workspaceId,\n organizationId,\n });\n // Anonymous/missing-token requests still go through the gateway and fail there.\n const endpoints = exportGatewayEndpoints(\n apiGatewayUrl,\n window.location.origin,\n );\n const serviceUrl = endpoints.http;\n\n const httpLink = new HttpLink({\n uri: serviceUrl,\n headers: Object.keys(headers).length > 0 ? headers : undefined,\n });\n\n // Error link: refresh workspace token on TOKEN_EXPIRED and retry the operation\n const errorLink = onError(({ error, operation, forward }) => {\n if (!error) return;\n\n const errors =\n \"errors\" in error && Array.isArray(error.errors) ? error.errors : [];\n const hasAuthError = hasSessionAuthErrors(errors);\n\n if (\n !getWorkspaceTokenRef.current ||\n !hasAuthError ||\n isRefreshingRef.current\n ) {\n if (error instanceof Error && isAuthNetworkError(error)) {\n redirectToLogin();\n }\n return;\n }\n\n return new Observable((observer) => {\n isRefreshingRef.current = true;\n getWorkspaceTokenRef.current!()\n .then((freshToken) => {\n isRefreshingRef.current = false;\n if (!freshToken) {\n redirectToLogin();\n observer.error(new Error(\"Failed to refresh workspace token\"));\n return;\n }\n // Inject the fresh token into the retry request\n operation.setContext(\n ({\n headers: existingHeaders = {},\n }: {\n headers?: Record<string, string>;\n }) => ({\n headers: {\n ...existingHeaders,\n \"X-Workspace-Authorization\": `Bearer ${freshToken}`,\n },\n }),\n );\n const subscriber = forward(operation).subscribe(observer);\n return () => subscriber.unsubscribe();\n })\n .catch((err: unknown) => {\n isRefreshingRef.current = false;\n observer.error(err);\n });\n });\n });\n\n // WebSocket link for subscriptions (replace http with ws)\n const wsUrl = endpoints.websocket;\n const wsLink = new GraphQLWsLink(\n createClient({\n url: wsUrl,\n connectionParams: Object.keys(headers).length > 0 ? headers : undefined,\n }),\n );\n\n // Split link: use WebSocket for subscriptions, HTTP for queries/mutations\n const splitLink = split(\n ({ query }) => {\n const definition = getMainDefinition(query);\n return (\n definition.kind === \"OperationDefinition\" &&\n definition.operation === \"subscription\"\n );\n },\n wsLink,\n from([errorLink, httpLink]),\n );\n\n return new ApolloClient({\n link: splitLink,\n cache: new InMemoryCache(),\n defaultOptions: {\n watchQuery: {\n fetchPolicy: \"cache-and-network\",\n },\n },\n });\n }, [\n apiGatewayUrl,\n authToken,\n workspaceToken,\n workspaceId,\n organizationId,\n // getWorkspaceToken is intentionally omitted: it's accessed via ref so the\n // Apollo client is not destroyed on every render if the host passes a new\n // function reference each render cycle.\n ]);\n\n // Wrap content with QueryClientProvider and Context.Provider\n const content = (\n <QueryClientProvider client={queryClient}>\n <ExportContext.Provider value={contextValue}>\n {children}\n </ExportContext.Provider>\n </QueryClientProvider>\n );\n\n // When integrated into a shell (basePath provided), the shell already has a router\n // and ApolloProvider so we don't create another one. When standalone (no basePath),\n // use MemoryRouter and ApolloProvider.\n if (basePath) {\n // Integrated mode: shell already has BrowserRouter and ApolloProvider, don't create nested ones\n return content;\n }\n\n // Standalone mode: create MemoryRouter and ApolloProvider for independent operation\n return (\n <ApolloProvider client={apolloClient}>\n <MemoryRouter>{content}</MemoryRouter>\n </ApolloProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAS,EACP,IAGK,EAAE,EACE;AACT,QAAO,EAAO,MAAM,MAAU;EAC5B,IAAM,IACJ,OAAO,EAAM,YAAY,QAAS,WAAW,EAAM,WAAW,OAAO,IACjE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ACL,CAAA;AAYxB,QANI,IAEK,IAKP,kBAAC,GAAD;EAAgB,QAAQ;YACtB,kBAAC,GAAD,EAAA,UAAe,GAAuB,CAAA;EACvB,CAAA"}
|
|
1
|
+
{"version":3,"file":"ExportProvider.js","names":["hasSessionAuthErrors","errors","code","error","errorCode","message","ExportContext","createContext","useExport","context","useContext","ExportProvider","contextValue","isRefreshingRef","useRef","getWorkspaceTokenRef","getWorkspaceToken","queryClient","useMemo","client","QueryClient","MutationCache","apolloClient","headers","exportGatewayHeaders","endpoints","exportGatewayEndpoints","apiGatewayUrl","serviceUrl","httpLink","HttpLink","errorLink","onError","hasAuthError","isAuthNetworkError","redirectToLogin","Observable","freshToken","observer","existingHeaders","subscriber","forward","operation","err","wsUrl","wsLink","GraphQLWsLink","createClient","splitLink","split","definition","getMainDefinition","query","from","ApolloClient","InMemoryCache","authToken","workspaceToken","workspaceId","organizationId","content","QueryClientProvider","basePath","ApolloProvider","MemoryRouter"],"sources":["../../../src/export/providers/ExportProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { createContext, useContext, useMemo, useRef } from \"react\";\nimport { MemoryRouter } from \"react-router\";\nimport {\n MutationCache,\n QueryClient,\n QueryClientProvider,\n} from \"@tanstack/react-query\";\nimport {\n ApolloClient,\n InMemoryCache,\n HttpLink,\n from,\n split,\n Observable,\n} from \"@apollo/client\";\nimport { getMainDefinition } from \"@apollo/client/utilities\";\nimport { GraphQLWsLink } from \"@apollo/client/link/subscriptions\";\nimport { createClient } from \"graphql-ws\";\nimport { onError } from \"@apollo/client/link/error\";\nimport { ApolloProvider } from \"@apollo/client/react\";\nimport {\n isAuthNetworkError,\n redirectToLogin,\n} from \"@burdenoff/fe-libs/shared/utils\";\nimport {\n exportGatewayHeaders,\n exportGatewayEndpoints,\n} from \"../utils/exportAuthority\";\nimport type { ExportRootProps } from \"../types\";\n\nfunction hasSessionAuthErrors(\n errors: ReadonlyArray<{\n message?: string;\n extensions?: Record<string, unknown>;\n }> = [],\n): boolean {\n return errors.some((error) => {\n const code =\n typeof error.extensions?.code === \"string\" ? error.extensions.code : \"\";\n const errorCode =\n typeof error.extensions?.errorCode === \"string\"\n ? error.extensions.errorCode\n : \"\";\n const message = (error.message ?? \"\").toLowerCase();\n\n return (\n code === \"UNAUTHENTICATED\" ||\n errorCode === \"TOKEN_EXPIRED\" ||\n message.includes(\"token_expired\") ||\n message.includes(\"token expired\") ||\n message.includes(\"session expired\") ||\n message.includes(\"unauthorized\") ||\n message.includes(\"unauthenticated\") ||\n message.includes(\"authentication required\") ||\n message.includes(\"workspace context missing\")\n );\n });\n}\n\n/**\n * Context value for Export microfrontend\n */\ntype ExportContextValue = ExportRootProps;\n\nconst ExportContext = createContext<ExportContextValue | null>(null);\n\n/**\n * Hook to access Export context\n */\nexport const useExport = () => {\n const context = useContext(ExportContext);\n if (!context) {\n throw new Error(\"useExport must be used within ExportProvider\");\n }\n return context;\n};\n\n/**\n * Provider component for Export microfrontend\n * Sets up routing, context, Apollo Client, and React Query client\n */\nexport const ExportProvider: FC<PropsWithChildren<ExportRootProps>> = ({\n children,\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n apiGatewayUrl,\n authToken,\n workspaceToken,\n eventBus,\n getWorkspaceToken,\n}) => {\n const contextValue: ExportContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n apiGatewayUrl,\n authToken,\n workspaceToken,\n eventBus,\n getWorkspaceToken,\n };\n\n // Track refreshing state across renders without triggering re-renders\n const isRefreshingRef = useRef(false);\n\n // Stable ref for getWorkspaceToken so it never invalidates the Apollo client memo\n const getWorkspaceTokenRef = useRef(getWorkspaceToken);\n getWorkspaceTokenRef.current = getWorkspaceToken;\n\n // Create QueryClient instance (memoized to avoid recreation on re-renders)\n const queryClient = useMemo(() => {\n const client = new QueryClient({\n mutationCache: new MutationCache({\n onSuccess: () => {\n void client.invalidateQueries();\n },\n }),\n defaultOptions: {\n queries: {\n retry: 1,\n refetchOnWindowFocus: false,\n staleTime: 5 * 60 * 1000, // 5 minutes\n },\n },\n });\n return client;\n }, []);\n\n // Create ApolloClient instance (memoized, recreated when tokens change)\n // The workspace gateway requires dual-token auth:\n // HTTP and subscription traffic use the public gateway with trusted host\n // credentials and explicit workspace/organization context. No subgraph bypass.\n const apolloClient = useMemo(() => {\n const headers = exportGatewayHeaders({\n authToken,\n workspaceToken,\n workspaceId,\n organizationId,\n });\n // Anonymous/missing-token requests still go through the gateway and fail there.\n const endpoints = exportGatewayEndpoints(\n apiGatewayUrl,\n window.location.origin,\n );\n const serviceUrl = endpoints.http;\n\n const httpLink = new HttpLink({\n uri: serviceUrl,\n headers: Object.keys(headers).length > 0 ? headers : undefined,\n });\n\n // Error link: refresh workspace token on TOKEN_EXPIRED and retry the operation\n const errorLink = onError(({ error, operation, forward }) => {\n if (!error) return;\n\n const errors =\n \"errors\" in error && Array.isArray(error.errors) ? error.errors : [];\n const hasAuthError = hasSessionAuthErrors(errors);\n\n if (\n !getWorkspaceTokenRef.current ||\n !hasAuthError ||\n isRefreshingRef.current\n ) {\n if (error instanceof Error && isAuthNetworkError(error)) {\n redirectToLogin();\n }\n return;\n }\n\n return new Observable((observer) => {\n isRefreshingRef.current = true;\n getWorkspaceTokenRef.current!()\n .then((freshToken) => {\n isRefreshingRef.current = false;\n if (!freshToken) {\n redirectToLogin();\n observer.error(new Error(\"Failed to refresh workspace token\"));\n return;\n }\n // Inject the fresh token into the retry request\n operation.setContext(\n ({\n headers: existingHeaders = {},\n }: {\n headers?: Record<string, string>;\n }) => ({\n headers: {\n ...existingHeaders,\n \"X-Workspace-Authorization\": `Bearer ${freshToken}`,\n },\n }),\n );\n const subscriber = forward(operation).subscribe(observer);\n return () => subscriber.unsubscribe();\n })\n .catch((err: unknown) => {\n isRefreshingRef.current = false;\n observer.error(err);\n });\n });\n });\n\n // WebSocket link for subscriptions (replace http with ws)\n const wsUrl = endpoints.websocket;\n const wsLink = new GraphQLWsLink(\n createClient({\n url: wsUrl,\n connectionParams: Object.keys(headers).length > 0 ? headers : undefined,\n }),\n );\n\n // Split link: use WebSocket for subscriptions, HTTP for queries/mutations\n const splitLink = split(\n ({ query }) => {\n const definition = getMainDefinition(query);\n return (\n definition.kind === \"OperationDefinition\" &&\n definition.operation === \"subscription\"\n );\n },\n wsLink,\n from([errorLink, httpLink]),\n );\n\n return new ApolloClient({\n link: splitLink,\n cache: new InMemoryCache(),\n defaultOptions: {\n watchQuery: {\n fetchPolicy: \"cache-and-network\",\n },\n },\n });\n }, [\n apiGatewayUrl,\n authToken,\n workspaceToken,\n workspaceId,\n organizationId,\n // getWorkspaceToken is intentionally omitted: it's accessed via ref so the\n // Apollo client is not destroyed on every render if the host passes a new\n // function reference each render cycle.\n ]);\n\n // Wrap content with QueryClientProvider and Context.Provider\n const content = (\n <QueryClientProvider client={queryClient}>\n <ExportContext.Provider value={contextValue}>\n {children}\n </ExportContext.Provider>\n </QueryClientProvider>\n );\n\n // When integrated into a shell (basePath provided), the shell already has a router\n // and ApolloProvider so we don't create another one. When standalone (no basePath),\n // use MemoryRouter and ApolloProvider.\n if (basePath) {\n // Integrated mode: shell already has BrowserRouter and ApolloProvider, don't create nested ones\n return content;\n }\n\n // Standalone mode: create MemoryRouter and ApolloProvider for independent operation\n return (\n <ApolloProvider client={apolloClient}>\n <MemoryRouter>{content}</MemoryRouter>\n </ApolloProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAASA,EACP,IAGK,CAAC,GACG;CACT,OAAOC,EAAO,MAAM,MAAU;EAC5B,IAAMC,IACJ,OAAOC,EAAM,YAAY,QAAS,WAAWA,EAAM,WAAW,OAAO,IACjEC,IACJ,OAAOD,EAAM,YAAY,aAAc,WACnCA,EAAM,WAAW,YACjB,IACAE,KAAWF,EAAM,WAAW,GAAA,CAAI,YAAY;EAElD,OACED,MAAS,qBACTE,MAAc,mBACdC,EAAQ,SAAS,eAAe,KAChCA,EAAQ,SAAS,eAAe,KA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A,kBAACX,EAAc,UAAf;GAAwB,OAAOM;GAC5B;EACqB,CAAA;CACL,CAAA;CAYvB,OANIkD,IAEKF,IAKP,kBAACG,GAAD;EAAgB,QAAQzC;EACtB,UAAA,kBAAC0C,GAAD,EAAA,UAAeJ,EAAsB,CAAA;CACvB,CAAA;AAEpB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExportJob, ExportFilter, ExportDisplayMode, ExportPagination } from '../types';
|
|
2
|
-
|
|
3
2
|
interface ExportState {
|
|
4
3
|
selectedJob: ExportJob | null;
|
|
5
4
|
viewMode: ExportDisplayMode;
|
|
@@ -14,4 +13,3 @@ interface ExportState {
|
|
|
14
13
|
}
|
|
15
14
|
export declare const useExportStore: import('zustand').UseBoundStore<import('zustand').StoreApi<ExportState>>;
|
|
16
15
|
export {};
|
|
17
|
-
//# sourceMappingURL=exportStore.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { create as e } from "zustand";
|
|
2
|
-
|
|
2
|
+
// src/export/store/exportStore.ts
|
|
3
3
|
var t = {
|
|
4
4
|
search: "",
|
|
5
5
|
status: "all",
|
|
@@ -37,7 +37,6 @@ var t = {
|
|
|
37
37
|
} })),
|
|
38
38
|
resetPagination: () => e({ pagination: n })
|
|
39
39
|
}));
|
|
40
|
-
//#endregion
|
|
41
40
|
export { r as useExportStore };
|
|
42
41
|
|
|
43
42
|
//# sourceMappingURL=exportStore.js.map
|