@burdenoff/microfe-support 2026.625.2 → 2026.715.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/generated/global-operations.d.ts +2517 -0
- package/dist/generated/global-types.d.ts +22913 -0
- package/dist/generated/wspace-operations.d.ts +1 -0
- package/dist/generated/wspace-types.d.ts +57850 -0
- package/dist/index.d.ts +5 -0
- package/dist/support/SupportAdminRoot.d.ts +20 -0
- package/dist/support/SupportAdminRoutes.d.ts +13 -0
- package/dist/support/SupportUserRoot.d.ts +17 -0
- package/dist/support/SupportUserRoutes.d.ts +11 -0
- package/dist/support/components/NotificationToast.d.ts +17 -0
- package/dist/support/components/PageLayout.d.ts +71 -0
- package/dist/support/components/RouteHelpers.d.ts +9 -0
- package/dist/support/components/analytics/CategoryBreakdown.d.ts +9 -0
- package/dist/support/components/analytics/MetricCard.d.ts +10 -0
- package/dist/support/components/analytics/PriorityBreakdown.d.ts +9 -0
- package/dist/support/components/analytics/SLAReport.d.ts +23 -0
- package/dist/support/components/analytics/SatisfactionDistribution.d.ts +23 -0
- package/dist/support/components/analytics/TopAgents.d.ts +19 -0
- package/dist/support/components/analytics/TrendChart.d.ts +15 -0
- package/dist/support/components/kb/ArticleForm.d.ts +25 -0
- package/dist/support/components/settings/CannedResponsesSettings.d.ts +21 -0
- package/dist/support/components/settings/SLAPoliciesSettings.d.ts +18 -0
- package/dist/support/components/settings/TicketCategoriesSettings.d.ts +20 -0
- package/dist/support/components/tickets/AttachmentList.d.ts +7 -0
- package/dist/support/components/tickets/MarkdownContent.d.ts +7 -0
- package/dist/support/components/tickets/MessageComposer.d.ts +22 -0
- package/dist/support/components/tickets/MessageThread.d.ts +12 -0
- package/dist/support/components/tickets/TicketDetailHeader.d.ts +16 -0
- package/dist/support/components/tickets/TicketHeader.d.ts +9 -0
- package/dist/support/components/tickets/TicketSidebar.d.ts +7 -0
- package/dist/support/components/ui.d.ts +5 -0
- package/dist/support/components/ui.js +2 -2
- package/dist/support/constants.d.ts +20 -0
- package/dist/support/events/rybbit.d.ts +13 -0
- package/dist/support/hooks/index.d.ts +5 -0
- package/dist/support/hooks/useAnalyticsOperations.d.ts +51 -0
- package/dist/support/hooks/useAttachmentsFailedToast.d.ts +2 -0
- package/dist/support/hooks/useChatOperations.d.ts +27 -0
- package/dist/support/hooks/useKnowledgeBaseOperations.d.ts +55 -0
- package/dist/support/hooks/useNotification.d.ts +20 -0
- package/dist/support/hooks/useRegisterFooter.d.ts +6 -0
- package/dist/support/hooks/useSettingsOperations.d.ts +47 -0
- package/dist/support/hooks/useSupportAttachments.d.ts +10 -0
- package/dist/support/hooks/useTicketListOperations.d.ts +31 -0
- package/dist/support/hooks/useTicketOperations.d.ts +39 -0
- package/dist/support/index.d.ts +44 -0
- package/dist/support/pages/AnalyticsPage.d.ts +1 -0
- package/dist/support/pages/AnalyticsPage.js +144 -113
- package/dist/support/pages/AnalyticsPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailAdminPage.d.ts +7 -0
- package/dist/support/pages/ArticleDetailAdminPage.js +150 -113
- package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailUserPage.d.ts +7 -0
- package/dist/support/pages/ArticleDetailUserPage.js +90 -83
- package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
- package/dist/support/pages/ContactInquiriesPage.d.ts +1 -0
- package/dist/support/pages/ContactInquiriesPage.js +48 -44
- package/dist/support/pages/ContactInquiriesPage.js.map +1 -1
- package/dist/support/pages/ContactInquiryDetailPage.d.ts +1 -0
- package/dist/support/pages/ContactInquiryDetailPage.js +225 -205
- package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
- package/dist/support/pages/CreateArticlePage.d.ts +1 -0
- package/dist/support/pages/CreateArticlePage.js +50 -46
- package/dist/support/pages/CreateArticlePage.js.map +1 -1
- package/dist/support/pages/CreateTicketPage.d.ts +1 -0
- package/dist/support/pages/CreateTicketPage.js +122 -116
- package/dist/support/pages/CreateTicketPage.js.map +1 -1
- package/dist/support/pages/EditArticlePage.d.ts +1 -0
- package/dist/support/pages/EditArticlePage.js +76 -80
- package/dist/support/pages/EditArticlePage.js.map +1 -1
- package/dist/support/pages/JobApplicationDetailPage.d.ts +1 -0
- package/dist/support/pages/JobApplicationDetailPage.js +292 -269
- package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
- package/dist/support/pages/JobApplicationsPage.d.ts +1 -0
- package/dist/support/pages/JobApplicationsPage.js +50 -46
- package/dist/support/pages/JobApplicationsPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseAdminPage.d.ts +7 -0
- package/dist/support/pages/KnowledgeBaseAdminPage.js +84 -81
- package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseUserPage.d.ts +8 -0
- package/dist/support/pages/KnowledgeBaseUserPage.js +76 -75
- package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
- package/dist/support/pages/SettingsPage.d.ts +1 -0
- package/dist/support/pages/SettingsPage.js +215 -182
- package/dist/support/pages/SettingsPage.js.map +1 -1
- package/dist/support/pages/TicketDetailAdminPage.d.ts +8 -0
- package/dist/support/pages/TicketDetailAdminPage.js +158 -128
- package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
- package/dist/support/pages/TicketDetailUserPage.d.ts +8 -0
- package/dist/support/pages/TicketDetailUserPage.js +174 -141
- package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
- package/dist/support/pages/TicketListPage.d.ts +11 -0
- package/dist/support/pages/TicketListPage.js +171 -170
- package/dist/support/pages/TicketListPage.js.map +1 -1
- package/dist/support/providers/SupportProvider.d.ts +16 -0
- package/dist/support/store/supportStore.d.ts +66 -0
- package/dist/support/types/index.d.ts +160 -0
- package/dist/support/utils/attachments.d.ts +27 -0
- package/dist/support/utils/categoryColors.d.ts +10 -0
- package/dist/support/utils/cn.d.ts +6 -0
- package/dist/support/utils/context.d.ts +2 -0
- package/dist/support/utils/errors.d.ts +2 -0
- package/dist/support/utils/i18n.d.ts +4 -0
- package/dist/support/utils/index.d.ts +57 -0
- package/dist/support/utils/markdown.d.ts +2 -0
- package/dist/support/utils/supportFiles.d.ts +15 -0
- package/dist/support/utils/ticketFilters.d.ts +6 -0
- package/dist/support/utils/uiTokens.d.ts +7 -0
- package/dist/utils/nativeBridge.d.ts +2 -0
- package/package.json +4 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useSupport as e } from "../providers/SupportProvider.js";
|
|
2
|
-
import { Button as t } from "../components/ui.js";
|
|
3
|
-
import { EmptyState as
|
|
4
|
-
import { useKnowledgeBaseOperations as
|
|
5
|
-
import { ArticleForm as
|
|
6
|
-
import { useEffect as
|
|
7
|
-
import { AlertCircle as
|
|
8
|
-
import { useNavigate as
|
|
9
|
-
import { jsx as
|
|
2
|
+
import { Button as t, PagePurpose as n } from "../components/ui.js";
|
|
3
|
+
import { EmptyState as r, LoadingState as i, PageLayout as a } from "../components/PageLayout.js";
|
|
4
|
+
import { useKnowledgeBaseOperations as o } from "../hooks/useKnowledgeBaseOperations.js";
|
|
5
|
+
import { ArticleForm as s } from "../components/kb/ArticleForm.js";
|
|
6
|
+
import { useEffect as c, useRef as l, useState as u } from "react";
|
|
7
|
+
import { AlertCircle as d, ArrowLeft as f, CheckCircle as p, FileEdit as m, ShieldAlert as h } from "lucide-react";
|
|
8
|
+
import { useNavigate as g, useParams as _ } from "react-router-dom";
|
|
9
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
10
10
|
//#region src/support/pages/EditArticlePage.tsx
|
|
11
|
-
function
|
|
11
|
+
function b(e) {
|
|
12
12
|
return e ? [
|
|
13
13
|
"admin",
|
|
14
14
|
"super_admin",
|
|
@@ -16,14 +16,14 @@ function y(e) {
|
|
|
16
16
|
"owner"
|
|
17
17
|
].includes(e.toLowerCase()) : !1;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
function x() {
|
|
20
|
+
let x = g(), { slug: S } = _(), { basePath: C = "", currentUser: w } = e(), T = b(w?.role), { articleDetail: E, articleLoading: D, categories: O, updateArticle: k, updatingArticle: A } = o(S), [j, M] = u(null), N = l(null), P = l(null);
|
|
21
|
+
c(() => () => {
|
|
22
|
+
N.current && clearTimeout(N.current), P.current && clearTimeout(P.current);
|
|
23
23
|
}, []);
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
26
|
-
await
|
|
24
|
+
let F = async (e) => {
|
|
25
|
+
if (E?.id) try {
|
|
26
|
+
await k(E.id, {
|
|
27
27
|
title: e.title,
|
|
28
28
|
slug: e.slug,
|
|
29
29
|
content: e.content,
|
|
@@ -32,114 +32,110 @@ function b() {
|
|
|
32
32
|
tags: e.tags.length > 0 ? e.tags : void 0,
|
|
33
33
|
metaDescription: e.metaDescription || void 0,
|
|
34
34
|
status: e.status
|
|
35
|
-
}),
|
|
35
|
+
}), M({
|
|
36
36
|
type: "success",
|
|
37
37
|
message: "Article updated successfully!"
|
|
38
|
-
}),
|
|
38
|
+
}), N.current && clearTimeout(N.current), N.current = setTimeout(() => x(`../../${e.slug}`), 1e3);
|
|
39
39
|
} catch {
|
|
40
|
-
|
|
40
|
+
M({
|
|
41
41
|
type: "error",
|
|
42
42
|
message: "Failed to update article. Please try again."
|
|
43
|
-
}),
|
|
43
|
+
}), P.current && clearTimeout(P.current), P.current = setTimeout(() => M(null), 3e3);
|
|
44
44
|
}
|
|
45
|
-
},
|
|
46
|
-
|
|
45
|
+
}, I = () => {
|
|
46
|
+
x("..");
|
|
47
47
|
};
|
|
48
|
-
if (!
|
|
48
|
+
if (!T) return /* @__PURE__ */ v(a, {
|
|
49
49
|
showHeader: !1,
|
|
50
|
-
children: /* @__PURE__ */
|
|
51
|
-
icon: /* @__PURE__ */
|
|
50
|
+
children: /* @__PURE__ */ v(r, {
|
|
51
|
+
icon: /* @__PURE__ */ v(h, { size: 48 }),
|
|
52
52
|
title: "Admin Access Required",
|
|
53
53
|
description: "You need administrator privileges to edit knowledge base articles.",
|
|
54
|
-
action: /* @__PURE__ */
|
|
55
|
-
onClick: () =>
|
|
56
|
-
children: [/* @__PURE__ */
|
|
54
|
+
action: /* @__PURE__ */ y(t, {
|
|
55
|
+
onClick: () => x(`${C}/kb`),
|
|
56
|
+
children: [/* @__PURE__ */ v(f, { size: 18 }), "Back to Knowledge Base"]
|
|
57
57
|
})
|
|
58
58
|
})
|
|
59
59
|
});
|
|
60
|
-
if (
|
|
60
|
+
if (D) return /* @__PURE__ */ v(a, {
|
|
61
61
|
showHeader: !1,
|
|
62
|
-
children: /* @__PURE__ */
|
|
62
|
+
children: /* @__PURE__ */ v(i, { message: "Loading article..." })
|
|
63
63
|
});
|
|
64
|
-
if (!
|
|
64
|
+
if (!E) return /* @__PURE__ */ v(a, {
|
|
65
65
|
showHeader: !1,
|
|
66
|
-
children: /* @__PURE__ */ v(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
className: "text-text-secondary mb-4",
|
|
75
|
-
children: "The article you're trying to edit doesn't exist."
|
|
76
|
-
}),
|
|
77
|
-
/* @__PURE__ */ _(t, {
|
|
78
|
-
onClick: () => b("../../.."),
|
|
79
|
-
children: "Back to Knowledge Base"
|
|
80
|
-
})
|
|
81
|
-
]
|
|
66
|
+
children: /* @__PURE__ */ v(r, {
|
|
67
|
+
illustration: "empty-search",
|
|
68
|
+
title: "Article not found",
|
|
69
|
+
description: "The article you're trying to edit doesn't exist or has been removed.",
|
|
70
|
+
action: /* @__PURE__ */ v(t, {
|
|
71
|
+
onClick: () => x("../../.."),
|
|
72
|
+
children: "Back to Knowledge Base"
|
|
73
|
+
})
|
|
82
74
|
})
|
|
83
75
|
});
|
|
84
|
-
let
|
|
85
|
-
title:
|
|
86
|
-
slug:
|
|
87
|
-
content:
|
|
88
|
-
excerpt:
|
|
89
|
-
categoryId:
|
|
90
|
-
tags:
|
|
76
|
+
let L = {
|
|
77
|
+
title: E.title,
|
|
78
|
+
slug: E.slug,
|
|
79
|
+
content: E.content,
|
|
80
|
+
excerpt: E.excerpt || "",
|
|
81
|
+
categoryId: E.categoryId || "",
|
|
82
|
+
tags: E.tags || [],
|
|
91
83
|
metaDescription: "",
|
|
92
|
-
status:
|
|
84
|
+
status: E.status
|
|
93
85
|
};
|
|
94
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ y(a, {
|
|
95
87
|
showHeader: !1,
|
|
96
88
|
children: [
|
|
97
|
-
|
|
98
|
-
className: `fixed right-4 top-[calc(var(--header-height,4rem)+1rem)] z-[200] flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-200 ${
|
|
99
|
-
children: [
|
|
89
|
+
j && /* @__PURE__ */ y("div", {
|
|
90
|
+
className: `fixed right-4 top-[calc(var(--header-height,4rem)+1rem)] z-[200] flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-200 ${j.type === "success" ? "bg-success/10 text-success border-success/30" : "bg-error/10 text-error border-error/30"}`,
|
|
91
|
+
children: [j.type === "success" ? /* @__PURE__ */ v(p, {
|
|
100
92
|
size: 20,
|
|
101
93
|
className: "text-success"
|
|
102
|
-
}) : /* @__PURE__ */
|
|
94
|
+
}) : /* @__PURE__ */ v(d, {
|
|
103
95
|
size: 20,
|
|
104
96
|
className: "text-error"
|
|
105
|
-
}), /* @__PURE__ */
|
|
97
|
+
}), /* @__PURE__ */ v("span", {
|
|
106
98
|
className: "font-medium",
|
|
107
|
-
children:
|
|
99
|
+
children: j.message
|
|
108
100
|
})]
|
|
109
101
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ y("div", {
|
|
111
103
|
className: "flex items-center gap-4 mb-6",
|
|
112
|
-
children: [/* @__PURE__ */
|
|
104
|
+
children: [/* @__PURE__ */ v(t, {
|
|
113
105
|
variant: "ghost",
|
|
114
106
|
size: "sm",
|
|
115
|
-
onClick: () =>
|
|
107
|
+
onClick: () => x(".."),
|
|
116
108
|
className: "p-2",
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
}), /* @__PURE__ */
|
|
109
|
+
children: /* @__PURE__ */ v(f, { size: 20 })
|
|
110
|
+
}), /* @__PURE__ */ y("div", {
|
|
119
111
|
className: "flex items-center gap-3",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
112
|
+
children: [/* @__PURE__ */ v("div", {
|
|
121
113
|
className: "p-2 rounded-lg bg-action-primary-bg/10",
|
|
122
|
-
children: /* @__PURE__ */
|
|
114
|
+
children: /* @__PURE__ */ v(m, {
|
|
123
115
|
size: 24,
|
|
124
116
|
className: "text-primary"
|
|
125
117
|
})
|
|
126
|
-
}), /* @__PURE__ */
|
|
118
|
+
}), /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h1", {
|
|
127
119
|
className: "text-2xl font-bold text-text-primary",
|
|
128
120
|
children: "Edit Article"
|
|
129
|
-
}), /* @__PURE__ */
|
|
121
|
+
}), /* @__PURE__ */ v("p", {
|
|
130
122
|
className: "text-sm text-text-secondary",
|
|
131
|
-
children:
|
|
123
|
+
children: E.title
|
|
132
124
|
})] })]
|
|
133
125
|
})]
|
|
134
126
|
}),
|
|
135
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ v(n, {
|
|
128
|
+
className: "mb-6 max-w-3xl",
|
|
129
|
+
children: "Refine an existing knowledge base article. Keep guides accurate as your product evolves, fix unclear steps, or move an article between draft and published. Changes go live for customers as soon as you save a published article."
|
|
130
|
+
}),
|
|
131
|
+
/* @__PURE__ */ v("div", {
|
|
136
132
|
className: "max-w-3xl",
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
initialData:
|
|
139
|
-
categories:
|
|
140
|
-
onSubmit:
|
|
141
|
-
onCancel:
|
|
142
|
-
isSubmitting:
|
|
133
|
+
children: /* @__PURE__ */ v(s, {
|
|
134
|
+
initialData: L,
|
|
135
|
+
categories: O,
|
|
136
|
+
onSubmit: F,
|
|
137
|
+
onCancel: I,
|
|
138
|
+
isSubmitting: A,
|
|
143
139
|
submitLabel: "Update Article"
|
|
144
140
|
})
|
|
145
141
|
})
|
|
@@ -147,6 +143,6 @@ function b() {
|
|
|
147
143
|
});
|
|
148
144
|
}
|
|
149
145
|
//#endregion
|
|
150
|
-
export {
|
|
146
|
+
export { x as EditArticlePage };
|
|
151
147
|
|
|
152
148
|
//# sourceMappingURL=EditArticlePage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditArticlePage.js","names":[],"sources":["../../../src/support/pages/EditArticlePage.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useNavigate, useParams } from 'react-router-dom';\nimport { ArrowLeft, FileEdit, AlertCircle, CheckCircle, ShieldAlert } from 'lucide-react';\nimport { Button } from '../components/ui';\nimport { ArticleForm, type ArticleFormData } from '../components/kb/ArticleForm';\nimport { useKnowledgeBaseOperations } from '../hooks/useKnowledgeBaseOperations';\nimport { PageLayout, LoadingState, EmptyState } from '../components/PageLayout';\nimport { useSupport } from '../providers/SupportProvider';\nimport { ArticleStatus } from '../../generated/global-types';\n\n/**\n * Check if the current user has admin privileges.\n */\nfunction isUserAdmin(role?: string): boolean {\n if (!role) return false;\n const adminRoles = ['admin', 'super_admin', 'workspace_admin', 'owner'];\n return adminRoles.includes(role.toLowerCase());\n}\n\nexport function EditArticlePage() {\n const navigate = useNavigate();\n const { slug } = useParams<{ slug: string }>();\n const { basePath = '', currentUser } = useSupport();\n const isAdmin = isUserAdmin(currentUser?.role);\n const { articleDetail, articleLoading, categories, updateArticle, updatingArticle } =\n useKnowledgeBaseOperations(slug);\n\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const navigateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const notificationTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (navigateTimerRef.current) clearTimeout(navigateTimerRef.current);\n if (notificationTimerRef.current) clearTimeout(notificationTimerRef.current);\n };\n }, []);\n\n const handleSubmit = async (data: ArticleFormData) => {\n if (!articleDetail?.id) return;\n\n try {\n await updateArticle(articleDetail.id, {\n title: data.title,\n slug: data.slug,\n content: data.content,\n excerpt: data.excerpt || undefined,\n categoryId: data.categoryId || undefined,\n tags: data.tags.length > 0 ? data.tags : undefined,\n metaDescription: data.metaDescription || undefined,\n status: data.status as ArticleStatus,\n });\n\n setNotification({ type: 'success', message: 'Article updated successfully!' });\n if (navigateTimerRef.current) clearTimeout(navigateTimerRef.current);\n navigateTimerRef.current = setTimeout(() => navigate(`../../${data.slug}`), 1000);\n } catch {\n setNotification({ type: 'error', message: 'Failed to update article. Please try again.' });\n if (notificationTimerRef.current) clearTimeout(notificationTimerRef.current);\n notificationTimerRef.current = setTimeout(() => setNotification(null), 3000);\n }\n };\n\n const handleCancel = () => {\n navigate('..');\n };\n\n // Non-admin users cannot edit articles\n if (!isAdmin) {\n return (\n <PageLayout showHeader={false}>\n <EmptyState\n icon={<ShieldAlert size={48} />}\n title=\"Admin Access Required\"\n description=\"You need administrator privileges to edit knowledge base articles.\"\n action={\n <Button onClick={() => navigate(`${basePath}/kb`)}>\n <ArrowLeft size={18} />\n Back to Knowledge Base\n </Button>\n }\n />\n </PageLayout>\n );\n }\n\n if (articleLoading) {\n return (\n <PageLayout showHeader={false}>\n <LoadingState message=\"Loading article...\" />\n </PageLayout>\n );\n }\n\n if (!articleDetail) {\n return (\n <PageLayout showHeader={false}>\n <
|
|
1
|
+
{"version":3,"file":"EditArticlePage.js","names":[],"sources":["../../../src/support/pages/EditArticlePage.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useNavigate, useParams } from 'react-router-dom';\nimport { ArrowLeft, FileEdit, AlertCircle, CheckCircle, ShieldAlert } from 'lucide-react';\nimport { Button, PagePurpose } from '../components/ui';\nimport { ArticleForm, type ArticleFormData } from '../components/kb/ArticleForm';\nimport { useKnowledgeBaseOperations } from '../hooks/useKnowledgeBaseOperations';\nimport { PageLayout, LoadingState, EmptyState } from '../components/PageLayout';\nimport { useSupport } from '../providers/SupportProvider';\nimport { ArticleStatus } from '../../generated/global-types';\n\n/**\n * Check if the current user has admin privileges.\n */\nfunction isUserAdmin(role?: string): boolean {\n if (!role) return false;\n const adminRoles = ['admin', 'super_admin', 'workspace_admin', 'owner'];\n return adminRoles.includes(role.toLowerCase());\n}\n\nexport function EditArticlePage() {\n const navigate = useNavigate();\n const { slug } = useParams<{ slug: string }>();\n const { basePath = '', currentUser } = useSupport();\n const isAdmin = isUserAdmin(currentUser?.role);\n const { articleDetail, articleLoading, categories, updateArticle, updatingArticle } =\n useKnowledgeBaseOperations(slug);\n\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const navigateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const notificationTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (navigateTimerRef.current) clearTimeout(navigateTimerRef.current);\n if (notificationTimerRef.current) clearTimeout(notificationTimerRef.current);\n };\n }, []);\n\n const handleSubmit = async (data: ArticleFormData) => {\n if (!articleDetail?.id) return;\n\n try {\n await updateArticle(articleDetail.id, {\n title: data.title,\n slug: data.slug,\n content: data.content,\n excerpt: data.excerpt || undefined,\n categoryId: data.categoryId || undefined,\n tags: data.tags.length > 0 ? data.tags : undefined,\n metaDescription: data.metaDescription || undefined,\n status: data.status as ArticleStatus,\n });\n\n setNotification({ type: 'success', message: 'Article updated successfully!' });\n if (navigateTimerRef.current) clearTimeout(navigateTimerRef.current);\n navigateTimerRef.current = setTimeout(() => navigate(`../../${data.slug}`), 1000);\n } catch {\n setNotification({ type: 'error', message: 'Failed to update article. Please try again.' });\n if (notificationTimerRef.current) clearTimeout(notificationTimerRef.current);\n notificationTimerRef.current = setTimeout(() => setNotification(null), 3000);\n }\n };\n\n const handleCancel = () => {\n navigate('..');\n };\n\n // Non-admin users cannot edit articles\n if (!isAdmin) {\n return (\n <PageLayout showHeader={false}>\n <EmptyState\n icon={<ShieldAlert size={48} />}\n title=\"Admin Access Required\"\n description=\"You need administrator privileges to edit knowledge base articles.\"\n action={\n <Button onClick={() => navigate(`${basePath}/kb`)}>\n <ArrowLeft size={18} />\n Back to Knowledge Base\n </Button>\n }\n />\n </PageLayout>\n );\n }\n\n if (articleLoading) {\n return (\n <PageLayout showHeader={false}>\n <LoadingState message=\"Loading article...\" />\n </PageLayout>\n );\n }\n\n if (!articleDetail) {\n return (\n <PageLayout showHeader={false}>\n <EmptyState\n illustration=\"empty-search\"\n title=\"Article not found\"\n description=\"The article you're trying to edit doesn't exist or has been removed.\"\n action={<Button onClick={() => navigate('../../..')}>Back to Knowledge Base</Button>}\n />\n </PageLayout>\n );\n }\n\n const initialData: Partial<ArticleFormData> = {\n title: articleDetail.title,\n slug: articleDetail.slug,\n content: articleDetail.content,\n excerpt: articleDetail.excerpt || '',\n categoryId: articleDetail.categoryId || '',\n tags: articleDetail.tags || [],\n metaDescription: '',\n status: articleDetail.status as 'DRAFT' | 'PUBLISHED',\n };\n\n return (\n <PageLayout showHeader={false}>\n {/* Notification */}\n {notification && (\n <div\n className={`fixed right-4 top-[calc(var(--header-height,4rem)+1rem)] z-[200] flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-200 ${\n notification.type === 'success'\n ? 'bg-success/10 text-success border-success/30'\n : 'bg-error/10 text-error border-error/30'\n }`}\n >\n {notification.type === 'success' ? (\n <CheckCircle size={20} className=\"text-success\" />\n ) : (\n <AlertCircle size={20} className=\"text-error\" />\n )}\n <span className=\"font-medium\">{notification.message}</span>\n </div>\n )}\n\n {/* Header */}\n <div className=\"flex items-center gap-4 mb-6\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate('..')} className=\"p-2\">\n <ArrowLeft size={20} />\n </Button>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 rounded-lg bg-action-primary-bg/10\">\n <FileEdit size={24} className=\"text-primary\" />\n </div>\n <div>\n <h1 className=\"text-2xl font-bold text-text-primary\">Edit Article</h1>\n <p className=\"text-sm text-text-secondary\">{articleDetail.title}</p>\n </div>\n </div>\n </div>\n\n <PagePurpose className=\"mb-6 max-w-3xl\">\n Refine an existing knowledge base article. Keep guides accurate as your product evolves, fix\n unclear steps, or move an article between draft and published. Changes go live for customers\n as soon as you save a published article.\n </PagePurpose>\n\n {/* Form */}\n <div className=\"max-w-3xl\">\n <ArticleForm\n initialData={initialData}\n categories={categories}\n onSubmit={handleSubmit}\n onCancel={handleCancel}\n isSubmitting={updatingArticle}\n submitLabel=\"Update Article\"\n />\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAS,EAAY,GAAwB;AAG3C,QAFK,IACc;EAAC;EAAS;EAAe;EAAmB;EAAQ,CACrD,SAAS,EAAK,aAAa,CAAC,GAF5B;;AAKpB,SAAgB,IAAkB;CAChC,IAAM,IAAW,GAAa,EACxB,EAAE,YAAS,GAA6B,EACxC,EAAE,cAAW,IAAI,mBAAgB,GAAY,EAC7C,IAAU,EAAY,GAAa,KAAK,EACxC,EAAE,kBAAe,mBAAgB,eAAY,kBAAe,uBAChE,EAA2B,EAAK,EAE5B,CAAC,GAAc,KAAmB,EAG9B,KAAK,EACT,IAAmB,EAA6C,KAAK,EACrE,IAAuB,EAA6C,KAAK;AAE/E,eACe;AAEX,EADI,EAAiB,WAAS,aAAa,EAAiB,QAAQ,EAChE,EAAqB,WAAS,aAAa,EAAqB,QAAQ;IAE7E,EAAE,CAAC;CAEN,IAAM,IAAe,OAAO,MAA0B;AAC/C,SAAe,GAEpB,KAAI;AAcF,GAbA,MAAM,EAAc,EAAc,IAAI;IACpC,OAAO,EAAK;IACZ,MAAM,EAAK;IACX,SAAS,EAAK;IACd,SAAS,EA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