@burdenoff/microfe-support 2026.511.1 → 2026.512.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.js +177 -93
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js.map +1 -1
- package/dist/support/SupportAdminRoutes.js +15 -12
- package/dist/support/SupportAdminRoutes.js.map +1 -1
- package/dist/support/components/settings/CannedResponsesSettings.js +204 -71
- package/dist/support/components/settings/CannedResponsesSettings.js.map +1 -1
- package/dist/support/components/tickets/MessageComposer.js +137 -107
- package/dist/support/components/tickets/MessageComposer.js.map +1 -1
- package/dist/support/components/tickets/MessageThread.js +11 -11
- package/dist/support/components/tickets/MessageThread.js.map +1 -1
- package/dist/support/components/tickets/TicketHeader.js +55 -45
- package/dist/support/components/tickets/TicketHeader.js.map +1 -1
- package/dist/support/components/tickets/TicketSidebar.js +105 -114
- package/dist/support/components/tickets/TicketSidebar.js.map +1 -1
- package/dist/support/hooks/useKnowledgeBaseOperations.js +79 -76
- package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
- package/dist/support/hooks/useSettingsOperations.js +15 -9
- package/dist/support/hooks/useSettingsOperations.js.map +1 -1
- package/dist/support/hooks/useTicketOperations.js +130 -86
- package/dist/support/hooks/useTicketOperations.js.map +1 -1
- package/dist/support/pages/AnalyticsPage.js +41 -45
- package/dist/support/pages/AnalyticsPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailAdminPage.js +148 -147
- package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailUserPage.js +71 -70
- package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
- package/dist/support/pages/CreateTicketPage.js +120 -138
- package/dist/support/pages/CreateTicketPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseAdminPage.js +27 -24
- package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseUserPage.js +27 -24
- package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
- package/dist/support/pages/SettingsPage.js +3 -1
- package/dist/support/pages/SettingsPage.js.map +1 -1
- package/dist/support/pages/TicketDetailAdminPage.js +121 -94
- package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
- package/dist/support/pages/TicketListPage.js +168 -157
- package/dist/support/pages/TicketListPage.js.map +1 -1
- package/dist/support/utils/index.js +19 -14
- package/dist/support/utils/index.js.map +1 -1
- package/dist/support/utils/supportFiles.js +27 -24
- package/dist/support/utils/supportFiles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,89 +1,91 @@
|
|
|
1
1
|
import { useSupportStore as e } from "../store/supportStore.js";
|
|
2
|
-
import { useArchiveKnowledgeBaseArticleMutation as t, useCreateKnowledgeBaseArticleMutation as n, useDeleteKnowledgeBaseArticleMutation as r, useGetArticleQuery as i, useGetArticlesQuery as a, useGetPopularArticlesQuery as o, useGetTicketCategoriesQuery as s, usePublishKnowledgeBaseArticleMutation as c, useRateArticleMutation as l, useRecordArticleViewMutation as u, useSearchKnowledgeBaseQuery as d, useUnpublishKnowledgeBaseArticleMutation as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { useEventBus as
|
|
2
|
+
import { useArchiveKnowledgeBaseArticleMutation as t, useCreateKnowledgeBaseArticleMutation as n, useDeleteKnowledgeBaseArticleMutation as r, useGetArticleQuery as i, useGetArticlesQuery as a, useGetPopularArticlesQuery as o, useGetTicketCategoriesQuery as s, usePublishKnowledgeBaseArticleMutation as c, useRateArticleMutation as l, useRecordArticleViewMutation as u, useSearchKnowledgeBaseQuery as d, useUnpublishKnowledgeBaseArticleMutation as f, useUpdateKnowledgeBaseArticleMutation as p } from "../../generated/global-operations.js";
|
|
3
|
+
import { useCallback as m, useEffect as h } from "react";
|
|
4
|
+
import { useEventBus as g } from "@burdenoff/fe-libs/shared/events";
|
|
5
5
|
//#region src/support/hooks/useKnowledgeBaseOperations.ts
|
|
6
|
-
function
|
|
7
|
-
let { kbSearch:
|
|
6
|
+
function _(_) {
|
|
7
|
+
let { kbSearch: v, selectedArticle: y, updateKbSearch: b, setKbResults: x, setSelectedArticle: S } = e(), C = g(), { data: w, loading: T, error: E, fetchMore: D, refetch: O } = a({ variables: {
|
|
8
8
|
limit: 20,
|
|
9
9
|
offset: 0,
|
|
10
10
|
filter: {
|
|
11
|
-
categoryId:
|
|
12
|
-
tags:
|
|
11
|
+
categoryId: v.filters.categoryId || void 0,
|
|
12
|
+
tags: v.filters.tags.length > 0 ? v.filters.tags : void 0
|
|
13
13
|
}
|
|
14
|
-
} }),
|
|
14
|
+
} }), k = _ ? w?.knowledgeBaseArticles?.nodes?.find((e) => e.slug === _)?.id : void 0, { data: A, loading: j } = o({ variables: { limit: 10 } }), { data: M, loading: N } = s({ variables: { limit: 50 } }), { data: P, loading: ee, error: F } = d({
|
|
15
15
|
variables: {
|
|
16
|
-
query:
|
|
16
|
+
query: v.query || "",
|
|
17
17
|
limit: 20,
|
|
18
|
-
categoryId:
|
|
18
|
+
categoryId: v.filters.categoryId || void 0
|
|
19
19
|
},
|
|
20
|
-
skip: !
|
|
20
|
+
skip: !v.query
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
let e =
|
|
25
|
-
|
|
22
|
+
h(() => {
|
|
23
|
+
if (P?.searchKnowledgeBase) {
|
|
24
|
+
let e = P.searchKnowledgeBase;
|
|
25
|
+
x(e);
|
|
26
26
|
}
|
|
27
|
-
}, [
|
|
28
|
-
let { data:
|
|
29
|
-
variables: { id:
|
|
30
|
-
skip: !
|
|
31
|
-
}), [
|
|
27
|
+
}, [P, x]);
|
|
28
|
+
let { data: I, loading: L, error: R, refetch: z } = i({
|
|
29
|
+
variables: { id: y?.id || k || "" },
|
|
30
|
+
skip: !y?.id && !k
|
|
31
|
+
}), [B, { loading: V }] = l({
|
|
32
32
|
onCompleted: () => {
|
|
33
|
-
|
|
33
|
+
z();
|
|
34
34
|
},
|
|
35
35
|
onError: (e) => {
|
|
36
36
|
console.error("Failed to rate article:", e);
|
|
37
37
|
}
|
|
38
|
-
}), [
|
|
38
|
+
}), [H] = u({ onError: (e) => {
|
|
39
39
|
console.error("Failed to record view:", e);
|
|
40
|
-
} }), [
|
|
40
|
+
} }), [U, { loading: W }] = n({
|
|
41
41
|
onCompleted: () => {
|
|
42
|
-
|
|
42
|
+
O();
|
|
43
43
|
},
|
|
44
44
|
onError: (e) => {
|
|
45
45
|
console.error("Failed to create article:", e);
|
|
46
46
|
}
|
|
47
|
-
}), [
|
|
47
|
+
}), [G, { loading: K }] = p({
|
|
48
48
|
onCompleted: () => {
|
|
49
|
-
|
|
49
|
+
O(), z();
|
|
50
50
|
},
|
|
51
51
|
onError: (e) => {
|
|
52
52
|
console.error("Failed to update article:", e);
|
|
53
53
|
}
|
|
54
|
-
}), [
|
|
54
|
+
}), [q, { loading: J }] = r({
|
|
55
55
|
onCompleted: () => {
|
|
56
|
-
|
|
56
|
+
O();
|
|
57
57
|
},
|
|
58
58
|
onError: (e) => {
|
|
59
59
|
console.error("Failed to delete article:", e);
|
|
60
60
|
}
|
|
61
|
-
}), [
|
|
61
|
+
}), [Y, { loading: X }] = c({
|
|
62
62
|
onCompleted: () => {
|
|
63
|
-
|
|
63
|
+
O(), z();
|
|
64
64
|
},
|
|
65
65
|
onError: (e) => {
|
|
66
66
|
console.error("Failed to publish article:", e);
|
|
67
67
|
}
|
|
68
|
-
}), [
|
|
68
|
+
}), [Z, { loading: Q }] = f({
|
|
69
69
|
onCompleted: () => {
|
|
70
|
-
|
|
70
|
+
O(), z();
|
|
71
71
|
},
|
|
72
72
|
onError: (e) => {
|
|
73
73
|
console.error("Failed to unpublish article:", e);
|
|
74
74
|
}
|
|
75
|
-
}), [
|
|
75
|
+
}), [$, { loading: te }] = t({
|
|
76
76
|
onCompleted: () => {
|
|
77
|
-
|
|
77
|
+
O(), z();
|
|
78
78
|
},
|
|
79
79
|
onError: (e) => {
|
|
80
80
|
console.error("Failed to archive article:", e);
|
|
81
81
|
}
|
|
82
|
-
}),
|
|
83
|
-
|
|
82
|
+
}), ne = (e, t) => {
|
|
83
|
+
b(e.trim(), t);
|
|
84
|
+
}, re = (e) => {
|
|
85
|
+
b(v.query, e);
|
|
84
86
|
}, ie = () => {
|
|
85
|
-
let e =
|
|
86
|
-
|
|
87
|
+
let e = w?.knowledgeBaseArticles?.nodes?.length || 0;
|
|
88
|
+
w?.knowledgeBaseArticles?.hasMore && D({
|
|
87
89
|
variables: { offset: e },
|
|
88
90
|
updateQuery: (e, { fetchMoreResult: t }) => t ? { knowledgeBaseArticles: {
|
|
89
91
|
...t.knowledgeBaseArticles,
|
|
@@ -92,65 +94,66 @@ function g(g) {
|
|
|
92
94
|
});
|
|
93
95
|
}, ae = async (e, t) => {
|
|
94
96
|
try {
|
|
95
|
-
await
|
|
97
|
+
await B({ variables: {
|
|
96
98
|
id: e,
|
|
97
99
|
helpful: t
|
|
98
|
-
} }),
|
|
100
|
+
} }), C.emit("support.kb.article_rated", {
|
|
99
101
|
articleId: e,
|
|
100
102
|
rating: t ? "helpful" : "not_helpful"
|
|
101
103
|
});
|
|
102
104
|
} catch (e) {
|
|
103
105
|
throw console.error("Failed to vote on article:", e), e;
|
|
104
106
|
}
|
|
105
|
-
}, oe =
|
|
107
|
+
}, oe = m(async (e) => {
|
|
106
108
|
try {
|
|
107
|
-
await
|
|
109
|
+
await H({ variables: { id: e } }), C.emit("support.kb.article_viewed", { articleId: e });
|
|
108
110
|
} catch (e) {
|
|
109
111
|
console.error("Failed to record view:", e);
|
|
110
112
|
}
|
|
111
|
-
}, [
|
|
113
|
+
}, [H, C]);
|
|
112
114
|
return {
|
|
113
|
-
articles:
|
|
114
|
-
popularArticles:
|
|
115
|
-
categories:
|
|
116
|
-
searchResults:
|
|
117
|
-
articleDetail:
|
|
118
|
-
totalArticles:
|
|
119
|
-
totalResults:
|
|
120
|
-
hasMoreArticles:
|
|
115
|
+
articles: w?.knowledgeBaseArticles?.nodes || [],
|
|
116
|
+
popularArticles: A?.popularArticles || [],
|
|
117
|
+
categories: M?.ticketCategories?.nodes || [],
|
|
118
|
+
searchResults: v.results,
|
|
119
|
+
articleDetail: I?.knowledgeBaseArticle || null,
|
|
120
|
+
totalArticles: w?.knowledgeBaseArticles?.totalCount || 0,
|
|
121
|
+
totalResults: P?.searchKnowledgeBase?.length || 0,
|
|
122
|
+
hasMoreArticles: w?.knowledgeBaseArticles?.hasMore || !1,
|
|
121
123
|
hasMoreResults: !1,
|
|
122
|
-
articlesLoading:
|
|
123
|
-
popularLoading:
|
|
124
|
-
categoriesLoading:
|
|
125
|
-
searchLoading:
|
|
126
|
-
articleLoading:
|
|
127
|
-
ratingArticle:
|
|
128
|
-
creatingArticle:
|
|
129
|
-
updatingArticle:
|
|
130
|
-
deletingArticle:
|
|
131
|
-
publishingArticle:
|
|
132
|
-
unpublishingArticle:
|
|
133
|
-
archivingArticle:
|
|
134
|
-
articlesError:
|
|
124
|
+
articlesLoading: T,
|
|
125
|
+
popularLoading: j,
|
|
126
|
+
categoriesLoading: N,
|
|
127
|
+
searchLoading: ee,
|
|
128
|
+
articleLoading: L,
|
|
129
|
+
ratingArticle: V,
|
|
130
|
+
creatingArticle: W,
|
|
131
|
+
updatingArticle: K,
|
|
132
|
+
deletingArticle: J,
|
|
133
|
+
publishingArticle: X,
|
|
134
|
+
unpublishingArticle: Q,
|
|
135
|
+
archivingArticle: te,
|
|
136
|
+
articlesError: E,
|
|
135
137
|
searchError: F,
|
|
136
|
-
articleError:
|
|
137
|
-
searchArticles:
|
|
138
|
+
articleError: R,
|
|
139
|
+
searchArticles: ne,
|
|
140
|
+
filterArticles: re,
|
|
138
141
|
loadMoreArticles: ie,
|
|
139
142
|
voteArticle: ae,
|
|
140
143
|
recordView: oe,
|
|
141
|
-
refetchArticles:
|
|
142
|
-
refetchArticle:
|
|
143
|
-
setSelectedArticle:
|
|
144
|
+
refetchArticles: O,
|
|
145
|
+
refetchArticle: z,
|
|
146
|
+
setSelectedArticle: S,
|
|
144
147
|
createArticle: async (e) => {
|
|
145
148
|
try {
|
|
146
|
-
return (await
|
|
149
|
+
return (await U({ variables: { input: e } })).data?.createKnowledgeBaseArticle;
|
|
147
150
|
} catch (e) {
|
|
148
151
|
throw console.error("Failed to create article:", e), e;
|
|
149
152
|
}
|
|
150
153
|
},
|
|
151
154
|
updateArticle: async (e, t) => {
|
|
152
155
|
try {
|
|
153
|
-
return (await
|
|
156
|
+
return (await G({ variables: {
|
|
154
157
|
id: e,
|
|
155
158
|
input: t
|
|
156
159
|
} })).data?.updateKnowledgeBaseArticle;
|
|
@@ -160,28 +163,28 @@ function g(g) {
|
|
|
160
163
|
},
|
|
161
164
|
deleteArticle: async (e) => {
|
|
162
165
|
try {
|
|
163
|
-
return (await
|
|
166
|
+
return (await q({ variables: { id: e } })).data?.deleteKnowledgeBaseArticle;
|
|
164
167
|
} catch (e) {
|
|
165
168
|
throw console.error("Failed to delete article:", e), e;
|
|
166
169
|
}
|
|
167
170
|
},
|
|
168
171
|
publishArticle: async (e) => {
|
|
169
172
|
try {
|
|
170
|
-
return (await
|
|
173
|
+
return (await Y({ variables: { id: e } })).data?.publishKnowledgeBaseArticle;
|
|
171
174
|
} catch (e) {
|
|
172
175
|
throw console.error("Failed to publish article:", e), e;
|
|
173
176
|
}
|
|
174
177
|
},
|
|
175
178
|
unpublishArticle: async (e) => {
|
|
176
179
|
try {
|
|
177
|
-
return (await
|
|
180
|
+
return (await Z({ variables: { id: e } })).data?.unpublishKnowledgeBaseArticle;
|
|
178
181
|
} catch (e) {
|
|
179
182
|
throw console.error("Failed to unpublish article:", e), e;
|
|
180
183
|
}
|
|
181
184
|
},
|
|
182
185
|
archiveArticle: async (e) => {
|
|
183
186
|
try {
|
|
184
|
-
return (await
|
|
187
|
+
return (await $({ variables: { id: e } })).data?.archiveKnowledgeBaseArticle;
|
|
185
188
|
} catch (e) {
|
|
186
189
|
throw console.error("Failed to archive article:", e), e;
|
|
187
190
|
}
|
|
@@ -189,6 +192,6 @@ function g(g) {
|
|
|
189
192
|
};
|
|
190
193
|
}
|
|
191
194
|
//#endregion
|
|
192
|
-
export {
|
|
195
|
+
export { _ as useKnowledgeBaseOperations };
|
|
193
196
|
|
|
194
197
|
//# sourceMappingURL=useKnowledgeBaseOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKnowledgeBaseOperations.js","names":[],"sources":["../../../src/support/hooks/useKnowledgeBaseOperations.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n useGetArticlesQuery,\n useGetArticleQuery,\n useGetPopularArticlesQuery,\n useGetTicketCategoriesQuery,\n useSearchKnowledgeBaseQuery,\n useRateArticleMutation,\n useRecordArticleViewMutation,\n useCreateKnowledgeBaseArticleMutation,\n useUpdateKnowledgeBaseArticleMutation,\n useDeleteKnowledgeBaseArticleMutation,\n usePublishKnowledgeBaseArticleMutation,\n useUnpublishKnowledgeBaseArticleMutation,\n useArchiveKnowledgeBaseArticleMutation,\n} from '../../generated/global-operations';\nimport type {\n KnowledgeBaseArticle,\n KnowledgeBaseArticleFilterInput,\n CreateKnowledgeBaseArticleInput,\n UpdateKnowledgeBaseArticleInput,\n} from '../../generated/global-types';\nimport type { KnowledgeBaseArticleState } from '../store/supportStore';\n\n// Input types for article operations (re-export for consumers)\nexport type { CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput };\n\nexport function useKnowledgeBaseOperations(articleSlug?: string) {\n const { kbSearch, selectedArticle, updateKbSearch, setKbResults, setSelectedArticle } =\n useSupportStore();\n const eventBus = useEventBus();\n\n // Query: Get articles list (show all statuses - admins can see drafts)\n const {\n data: articlesData,\n loading: articlesLoading,\n error: articlesError,\n fetchMore: fetchMoreArticles,\n refetch: refetchArticles,\n } = useGetArticlesQuery({\n variables: {\n limit: 20,\n offset: 0,\n filter: {\n // Don't filter by status - show all articles including drafts\n categoryId: kbSearch.filters.categoryId || undefined,\n tags: kbSearch.filters.tags.length > 0 ? kbSearch.filters.tags : undefined,\n } as KnowledgeBaseArticleFilterInput,\n },\n });\n\n const articleIdFromSlug = articleSlug\n ? articlesData?.knowledgeBaseArticles?.nodes?.find(\n (article: { slug: string; id: string }) => article.slug === articleSlug\n )?.id\n : undefined;\n\n // Query: Get popular articles\n const { data: popularData, loading: popularLoading } = useGetPopularArticlesQuery({\n variables: { limit: 10 },\n });\n\n // Query: Get categories\n const { data: categoriesData, loading: categoriesLoading } = useGetTicketCategoriesQuery({\n variables: { limit: 50 },\n });\n\n // Query: Search articles\n const {\n data: searchData,\n loading: searchLoading,\n error: searchError,\n refetch: refetchSearch,\n } = useSearchKnowledgeBaseQuery({\n variables: {\n query: kbSearch.query || '',\n limit: 20,\n categoryId: kbSearch.filters.categoryId || undefined,\n },\n skip: !kbSearch.query,\n });\n\n // Update kbResults when search data changes\n useEffect(() => {\n if (searchData?.searchKnowledgeBase) {\n const articles = searchData.searchKnowledgeBase;\n setKbResults(articles as KnowledgeBaseArticleState[]);\n }\n }, [searchData, setKbResults]);\n\n // Query: Get article detail\n const {\n data: articleData,\n loading: articleLoading,\n error: articleError,\n refetch: refetchArticle,\n } = useGetArticleQuery({\n variables: { id: selectedArticle?.id || articleIdFromSlug || '' },\n skip: !selectedArticle?.id && !articleIdFromSlug,\n });\n\n // Mutation: Rate article\n const [rateArticleMutation, { loading: ratingArticle }] = useRateArticleMutation({\n onCompleted: () => {\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to rate article:', error);\n },\n });\n\n // Mutation: Record article view\n const [recordViewMutation] = useRecordArticleViewMutation({\n onError: (error) => {\n console.error('Failed to record view:', error);\n },\n });\n\n // Mutation: Create article\n const [createArticleMutation, { loading: creatingArticle }] =\n useCreateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to create article:', error);\n },\n });\n\n // Mutation: Update article\n const [updateArticleMutation, { loading: updatingArticle }] =\n useUpdateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to update article:', error);\n },\n });\n\n // Mutation: Delete article\n const [deleteArticleMutation, { loading: deletingArticle }] =\n useDeleteKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to delete article:', error);\n },\n });\n\n // Mutation: Publish article\n const [publishArticleMutation, { loading: publishingArticle }] =\n usePublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to publish article:', error);\n },\n });\n\n // Mutation: Unpublish article\n const [unpublishArticleMutation, { loading: unpublishingArticle }] =\n useUnpublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to unpublish article:', error);\n },\n });\n\n // Mutation: Archive article\n const [archiveArticleMutation, { loading: archivingArticle }] =\n useArchiveKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to archive article:', error);\n },\n });\n\n // Helper: Search articles\n const searchArticles = (query: string, filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(query, filters);\n refetchSearch();\n };\n\n // Helper: Load more articles (offset-based pagination)\n const loadMoreArticles = () => {\n const currentCount = articlesData?.knowledgeBaseArticles?.nodes?.length || 0;\n if (articlesData?.knowledgeBaseArticles?.hasMore) {\n fetchMoreArticles({\n variables: {\n offset: currentCount,\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n knowledgeBaseArticles: {\n ...fetchMoreResult.knowledgeBaseArticles,\n nodes: [\n ...(prev.knowledgeBaseArticles?.nodes || []),\n ...(fetchMoreResult.knowledgeBaseArticles?.nodes || []),\n ],\n },\n };\n },\n });\n }\n };\n\n // Helper: Vote on article helpfulness\n const voteArticle = async (articleId: string, helpful: boolean) => {\n try {\n await rateArticleMutation({\n variables: { id: articleId, helpful },\n });\n eventBus.emit('support.kb.article_rated', {\n articleId,\n rating: helpful ? 'helpful' : 'not_helpful',\n });\n } catch (error) {\n console.error('Failed to vote on article:', error);\n throw error;\n }\n };\n\n // Helper: Record article view (memoized to prevent multiple calls)\n const recordView = useCallback(\n async (articleId: string) => {\n try {\n await recordViewMutation({\n variables: { id: articleId },\n });\n eventBus.emit('support.kb.article_viewed', { articleId });\n } catch (error) {\n console.error('Failed to record view:', error);\n }\n },\n [recordViewMutation, eventBus]\n );\n\n // Helper: Create article\n const createArticle = async (input: CreateKnowledgeBaseArticleInput) => {\n try {\n const result = await createArticleMutation({\n variables: { input },\n });\n return result.data?.createKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to create article:', error);\n throw error;\n }\n };\n\n // Helper: Update article\n const updateArticle = async (id: string, input: UpdateKnowledgeBaseArticleInput) => {\n try {\n const result = await updateArticleMutation({\n variables: { id, input },\n });\n return result.data?.updateKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to update article:', error);\n throw error;\n }\n };\n\n // Helper: Delete article\n const deleteArticle = async (id: string) => {\n try {\n const result = await deleteArticleMutation({\n variables: { id },\n });\n return result.data?.deleteKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to delete article:', error);\n throw error;\n }\n };\n\n // Helper: Publish article\n const publishArticle = async (id: string) => {\n try {\n const result = await publishArticleMutation({\n variables: { id },\n });\n return result.data?.publishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to publish article:', error);\n throw error;\n }\n };\n\n // Helper: Unpublish article\n const unpublishArticle = async (id: string) => {\n try {\n const result = await unpublishArticleMutation({\n variables: { id },\n });\n return result.data?.unpublishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to unpublish article:', error);\n throw error;\n }\n };\n\n // Helper: Archive article\n const archiveArticle = async (id: string) => {\n try {\n const result = await archiveArticleMutation({\n variables: { id },\n });\n return result.data?.archiveKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to archive article:', error);\n throw error;\n }\n };\n\n return {\n // Data\n articles: (articlesData?.knowledgeBaseArticles?.nodes || []) as KnowledgeBaseArticle[],\n popularArticles: (popularData?.popularArticles || []) as KnowledgeBaseArticle[],\n categories: categoriesData?.ticketCategories?.nodes || [],\n searchResults: kbSearch.results,\n articleDetail: articleData?.knowledgeBaseArticle || null,\n totalArticles: articlesData?.knowledgeBaseArticles?.totalCount || 0,\n totalResults: searchData?.searchKnowledgeBase?.length || 0,\n hasMoreArticles: articlesData?.knowledgeBaseArticles?.hasMore || false,\n hasMoreResults: false, // searchKnowledgeBase returns array, no pagination\n\n // Loading states\n articlesLoading,\n popularLoading,\n categoriesLoading,\n searchLoading,\n articleLoading,\n ratingArticle,\n creatingArticle,\n updatingArticle,\n deletingArticle,\n publishingArticle,\n unpublishingArticle,\n archivingArticle,\n\n // Errors\n articlesError,\n searchError,\n articleError,\n\n // Read Operations\n searchArticles,\n loadMoreArticles,\n voteArticle,\n recordView,\n refetchArticles,\n refetchArticle,\n setSelectedArticle,\n\n // CRUD Operations\n createArticle,\n updateArticle,\n deleteArticle,\n publishArticle,\n unpublishArticle,\n archiveArticle,\n };\n}\n"],"mappings":";;;;;AA6BA,SAAgB,EAA2B,GAAsB;CAC/D,IAAM,EAAE,aAAU,oBAAiB,mBAAgB,iBAAc,0BAC/D,GAAiB,EACb,IAAW,GAAa,EAGxB,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,WAAW,GACX,SAAS,MACP,EAAoB,EACtB,WAAW;EACT,OAAO;EACP,QAAQ;EACR,QAAQ;GAEN,YAAY,EAAS,QAAQ,cAAc,KAAA;GAC3C,MAAM,EAAS,QAAQ,KAAK,SAAS,IAAI,EAAS,QAAQ,OAAO,KAAA;GAClE;EACF,EACF,CAAC,EAEI,IAAoB,IACtB,GAAc,uBAAuB,OAAO,MACzC,MAA0C,EAAQ,SAAS,EAC7D,E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OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,8BAA8B,EAAM,EAC5C;;;EA2ER,kBAtEuB,OAAO,MAAe;AAC7C,OAAI;AAIF,YAHe,MAAM,EAAyB,EAC5C,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,gCAAgC,EAAM,EAC9C;;;EA+DR,gBA1DqB,OAAO,MAAe;AAC3C,OAAI;AAIF,YAHe,MAAM,GAAuB,EAC1C,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,8BAA8B,EAAM,EAC5C;;;EAmDT"}
|
|
1
|
+
{"version":3,"file":"useKnowledgeBaseOperations.js","names":[],"sources":["../../../src/support/hooks/useKnowledgeBaseOperations.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n useGetArticlesQuery,\n useGetArticleQuery,\n useGetPopularArticlesQuery,\n useGetTicketCategoriesQuery,\n useSearchKnowledgeBaseQuery,\n useRateArticleMutation,\n useRecordArticleViewMutation,\n useCreateKnowledgeBaseArticleMutation,\n useUpdateKnowledgeBaseArticleMutation,\n useDeleteKnowledgeBaseArticleMutation,\n usePublishKnowledgeBaseArticleMutation,\n useUnpublishKnowledgeBaseArticleMutation,\n useArchiveKnowledgeBaseArticleMutation,\n} from '../../generated/global-operations';\nimport type {\n KnowledgeBaseArticle,\n KnowledgeBaseArticleFilterInput,\n CreateKnowledgeBaseArticleInput,\n UpdateKnowledgeBaseArticleInput,\n} from '../../generated/global-types';\nimport type { KnowledgeBaseArticleState } from '../store/supportStore';\n\n// Input types for article operations (re-export for consumers)\nexport type { CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput };\n\nexport function useKnowledgeBaseOperations(articleSlug?: string) {\n const { kbSearch, selectedArticle, updateKbSearch, setKbResults, setSelectedArticle } =\n useSupportStore();\n const eventBus = useEventBus();\n\n // Query: Get articles list (show all statuses - admins can see drafts)\n const {\n data: articlesData,\n loading: articlesLoading,\n error: articlesError,\n fetchMore: fetchMoreArticles,\n refetch: refetchArticles,\n } = useGetArticlesQuery({\n variables: {\n limit: 20,\n offset: 0,\n filter: {\n // Don't filter by status - show all articles including drafts\n categoryId: kbSearch.filters.categoryId || undefined,\n tags: kbSearch.filters.tags.length > 0 ? kbSearch.filters.tags : undefined,\n } as KnowledgeBaseArticleFilterInput,\n },\n });\n\n const articleIdFromSlug = articleSlug\n ? articlesData?.knowledgeBaseArticles?.nodes?.find(\n (article: { slug: string; id: string }) => article.slug === articleSlug\n )?.id\n : undefined;\n\n // Query: Get popular articles\n const { data: popularData, loading: popularLoading } = useGetPopularArticlesQuery({\n variables: { limit: 10 },\n });\n\n // Query: Get categories\n const { data: categoriesData, loading: categoriesLoading } = useGetTicketCategoriesQuery({\n variables: { limit: 50 },\n });\n\n // Query: Search articles\n const {\n data: searchData,\n loading: searchLoading,\n error: searchError,\n } = useSearchKnowledgeBaseQuery({\n variables: {\n query: kbSearch.query || '',\n limit: 20,\n categoryId: kbSearch.filters.categoryId || undefined,\n },\n skip: !kbSearch.query,\n });\n\n // Update kbResults when search data changes\n useEffect(() => {\n if (searchData?.searchKnowledgeBase) {\n const articles = searchData.searchKnowledgeBase;\n setKbResults(articles as KnowledgeBaseArticleState[]);\n }\n }, [searchData, setKbResults]);\n\n // Query: Get article detail\n const {\n data: articleData,\n loading: articleLoading,\n error: articleError,\n refetch: refetchArticle,\n } = useGetArticleQuery({\n variables: { id: selectedArticle?.id || articleIdFromSlug || '' },\n skip: !selectedArticle?.id && !articleIdFromSlug,\n });\n\n // Mutation: Rate article\n const [rateArticleMutation, { loading: ratingArticle }] = useRateArticleMutation({\n onCompleted: () => {\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to rate article:', error);\n },\n });\n\n // Mutation: Record article view\n const [recordViewMutation] = useRecordArticleViewMutation({\n onError: (error) => {\n console.error('Failed to record view:', error);\n },\n });\n\n // Mutation: Create article\n const [createArticleMutation, { loading: creatingArticle }] =\n useCreateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to create article:', error);\n },\n });\n\n // Mutation: Update article\n const [updateArticleMutation, { loading: updatingArticle }] =\n useUpdateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to update article:', error);\n },\n });\n\n // Mutation: Delete article\n const [deleteArticleMutation, { loading: deletingArticle }] =\n useDeleteKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to delete article:', error);\n },\n });\n\n // Mutation: Publish article\n const [publishArticleMutation, { loading: publishingArticle }] =\n usePublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to publish article:', error);\n },\n });\n\n // Mutation: Unpublish article\n const [unpublishArticleMutation, { loading: unpublishingArticle }] =\n useUnpublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to unpublish article:', error);\n },\n });\n\n // Mutation: Archive article\n const [archiveArticleMutation, { loading: archivingArticle }] =\n useArchiveKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to archive article:', error);\n },\n });\n\n // Helper: Search articles\n const searchArticles = (query: string, filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(query.trim(), filters);\n };\n\n const filterArticles = (filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(kbSearch.query, filters);\n };\n\n // Helper: Load more articles (offset-based pagination)\n const loadMoreArticles = () => {\n const currentCount = articlesData?.knowledgeBaseArticles?.nodes?.length || 0;\n if (articlesData?.knowledgeBaseArticles?.hasMore) {\n fetchMoreArticles({\n variables: {\n offset: currentCount,\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n knowledgeBaseArticles: {\n ...fetchMoreResult.knowledgeBaseArticles,\n nodes: [\n ...(prev.knowledgeBaseArticles?.nodes || []),\n ...(fetchMoreResult.knowledgeBaseArticles?.nodes || []),\n ],\n },\n };\n },\n });\n }\n };\n\n // Helper: Vote on article helpfulness\n const voteArticle = async (articleId: string, helpful: boolean) => {\n try {\n await rateArticleMutation({\n variables: { id: articleId, helpful },\n });\n eventBus.emit('support.kb.article_rated', {\n articleId,\n rating: helpful ? 'helpful' : 'not_helpful',\n });\n } catch (error) {\n console.error('Failed to vote on article:', error);\n throw error;\n }\n };\n\n // Helper: Record article view (memoized to prevent multiple calls)\n const recordView = useCallback(\n async (articleId: string) => {\n try {\n await recordViewMutation({\n variables: { id: articleId },\n });\n eventBus.emit('support.kb.article_viewed', { articleId });\n } catch (error) {\n console.error('Failed to record view:', error);\n }\n },\n [recordViewMutation, eventBus]\n );\n\n // Helper: Create article\n const createArticle = async (input: CreateKnowledgeBaseArticleInput) => {\n try {\n const result = await createArticleMutation({\n variables: { input },\n });\n return result.data?.createKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to create article:', error);\n throw error;\n }\n };\n\n // Helper: Update article\n const updateArticle = async (id: string, input: UpdateKnowledgeBaseArticleInput) => {\n try {\n const result = await updateArticleMutation({\n variables: { id, input },\n });\n return result.data?.updateKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to update article:', error);\n throw error;\n }\n };\n\n // Helper: Delete article\n const deleteArticle = async (id: string) => {\n try {\n const result = await deleteArticleMutation({\n variables: { id },\n });\n return result.data?.deleteKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to delete article:', error);\n throw error;\n }\n };\n\n // Helper: Publish article\n const publishArticle = async (id: string) => {\n try {\n const result = await publishArticleMutation({\n variables: { id },\n });\n return result.data?.publishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to publish article:', error);\n throw error;\n }\n };\n\n // Helper: Unpublish article\n const unpublishArticle = async (id: string) => {\n try {\n const result = await unpublishArticleMutation({\n variables: { id },\n });\n return result.data?.unpublishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to unpublish article:', error);\n throw error;\n }\n };\n\n // Helper: Archive article\n const archiveArticle = async (id: string) => {\n try {\n const result = await archiveArticleMutation({\n variables: { id },\n });\n return result.data?.archiveKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to archive article:', error);\n throw error;\n }\n };\n\n return {\n // Data\n articles: (articlesData?.knowledgeBaseArticles?.nodes || []) as KnowledgeBaseArticle[],\n popularArticles: (popularData?.popularArticles || []) as KnowledgeBaseArticle[],\n categories: categoriesData?.ticketCategories?.nodes || [],\n searchResults: kbSearch.results,\n articleDetail: articleData?.knowledgeBaseArticle || null,\n totalArticles: articlesData?.knowledgeBaseArticles?.totalCount || 0,\n totalResults: searchData?.searchKnowledgeBase?.length || 0,\n hasMoreArticles: articlesData?.knowledgeBaseArticles?.hasMore || false,\n hasMoreResults: false, // searchKnowledgeBase returns array, no pagination\n\n // Loading states\n articlesLoading,\n popularLoading,\n categoriesLoading,\n searchLoading,\n articleLoading,\n ratingArticle,\n creatingArticle,\n updatingArticle,\n deletingArticle,\n publishingArticle,\n unpublishingArticle,\n archivingArticle,\n\n // Errors\n articlesError,\n searchError,\n articleError,\n\n // Read Operations\n searchArticles,\n filterArticles,\n loadMoreArticles,\n voteArticle,\n recordView,\n refetchArticles,\n refetchArticle,\n setSelectedArticle,\n\n // CRUD Operations\n createArticle,\n updateArticle,\n deleteArticle,\n publishArticle,\n unpublishArticle,\n archiveArticle,\n };\n}\n"],"mappings":";;;;;AA6BA,SAAgB,EAA2B,GAAsB;CAC/D,IAAM,EAAE,aAAU,oBAAiB,mBAAgB,iBAAc,0BAC/D,GAAiB,EACb,IAAW,GAAa,EAGxB,EACJ,MAAM,GACN,SAA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ACzB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,6BAA6B,EAAM,EAC3C;;;EAoGR,eA/FoB,OAAO,MAAe;AAC1C,OAAI;AAIF,YAHe,MAAM,EAAsB,EACzC,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,6BAA6B,EAAM,EAC3C;;;EAwFR,gBAnFqB,OAAO,MAAe;AAC3C,OAAI;AAIF,YAHe,MAAM,EAAuB,EAC1C,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,8BAA8B,EAAM,EAC5C;;;EA4ER,kBAvEuB,OAAO,MAAe;AAC7C,OAAI;AAIF,YAHe,MAAM,EAAyB,EAC5C,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,gCAAgC,EAAM,EAC9C;;;EAgER,gBA3DqB,OAAO,MAAe;AAC3C,OAAI;AAIF,YAHe,MAAM,EAAuB,EAC1C,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;YACb,GAAO;AAEd,UADA,QAAQ,MAAM,8BAA8B,EAAM,EAC5C;;;EAoDT"}
|
|
@@ -91,7 +91,7 @@ function f() {
|
|
|
91
91
|
createSLAPolicy: async (e) => {
|
|
92
92
|
let t = await w({ variables: { input: e } });
|
|
93
93
|
if (!t.data?.createSLAPolicy) throw Error("Failed to create SLA policy");
|
|
94
|
-
return t.data.createSLAPolicy;
|
|
94
|
+
return await h(), t.data.createSLAPolicy;
|
|
95
95
|
},
|
|
96
96
|
updateSLAPolicy: async (e, t) => {
|
|
97
97
|
let n = await E({ variables: {
|
|
@@ -99,14 +99,17 @@ function f() {
|
|
|
99
99
|
input: t
|
|
100
100
|
} });
|
|
101
101
|
if (!n.data?.updateSLAPolicy) throw Error("Failed to update SLA policy");
|
|
102
|
-
return n.data.updateSLAPolicy;
|
|
102
|
+
return await h(), n.data.updateSLAPolicy;
|
|
103
|
+
},
|
|
104
|
+
deleteSLAPolicy: async (e) => {
|
|
105
|
+
let t = await O({ variables: { id: e } });
|
|
106
|
+
return await h(), t.data?.deleteSLAPolicy;
|
|
103
107
|
},
|
|
104
|
-
deleteSLAPolicy: async (e) => (await O({ variables: { id: e } })).data?.deleteSLAPolicy,
|
|
105
108
|
refetchSLAPolicies: h,
|
|
106
109
|
createCannedResponse: async (e) => {
|
|
107
110
|
let t = await A({ variables: { input: e } });
|
|
108
111
|
if (!t.data?.createCannedResponse) throw Error("Failed to create canned response");
|
|
109
|
-
return t.data.createCannedResponse;
|
|
112
|
+
return await y(), t.data.createCannedResponse;
|
|
110
113
|
},
|
|
111
114
|
updateCannedResponse: async (e, t) => {
|
|
112
115
|
let n = await M({ variables: {
|
|
@@ -114,14 +117,17 @@ function f() {
|
|
|
114
117
|
input: t
|
|
115
118
|
} });
|
|
116
119
|
if (!n.data?.updateCannedResponse) throw Error("Failed to update canned response");
|
|
117
|
-
return n.data.updateCannedResponse;
|
|
120
|
+
return await y(), n.data.updateCannedResponse;
|
|
121
|
+
},
|
|
122
|
+
deleteCannedResponse: async (e) => {
|
|
123
|
+
let t = await P({ variables: { id: e } });
|
|
124
|
+
return await y(), t.data?.deleteCannedResponse;
|
|
118
125
|
},
|
|
119
|
-
deleteCannedResponse: async (e) => (await P({ variables: { id: e } })).data?.deleteCannedResponse,
|
|
120
126
|
refetchCannedResponses: y,
|
|
121
127
|
createTicketCategory: async (e) => {
|
|
122
128
|
let t = await I({ variables: { input: e } });
|
|
123
129
|
if (!t.data?.createTicketCategory) throw Error("Failed to create category");
|
|
124
|
-
return t.data.createTicketCategory;
|
|
130
|
+
return await C(), t.data.createTicketCategory;
|
|
125
131
|
},
|
|
126
132
|
updateTicketCategory: async (e, t) => {
|
|
127
133
|
let n = await R({ variables: {
|
|
@@ -129,12 +135,12 @@ function f() {
|
|
|
129
135
|
input: t
|
|
130
136
|
} });
|
|
131
137
|
if (!n.data?.updateTicketCategory) throw Error("Failed to update category");
|
|
132
|
-
return n.data.updateTicketCategory;
|
|
138
|
+
return await C(), n.data.updateTicketCategory;
|
|
133
139
|
},
|
|
134
140
|
deleteTicketCategory: async (e) => {
|
|
135
141
|
let t = await B({ variables: { id: e } });
|
|
136
142
|
if (t.data?.deleteTicketCategory === void 0 || t.data?.deleteTicketCategory === null) throw Error("Failed to delete category");
|
|
137
|
-
return t.data.deleteTicketCategory;
|
|
143
|
+
return await C(), t.data.deleteTicketCategory;
|
|
138
144
|
},
|
|
139
145
|
refetchCategories: C
|
|
140
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSettingsOperations.js","names":[],"sources":["../../../src/support/hooks/useSettingsOperations.ts"],"sourcesContent":["import {\n useGetSlaPoliciesQuery,\n useCreateSlaPolicyMutation,\n useUpdateSlaPolicyMutation,\n useDeleteSlaPolicyMutation,\n useGetCannedResponsesQuery,\n useCreateCannedResponseMutation,\n useUpdateCannedResponseMutation,\n useDeleteCannedResponseMutation,\n useGetTicketCategoriesQuery,\n useCreateTicketCategoryMutation,\n useUpdateTicketCategoryMutation,\n useDeleteTicketCategoryMutation,\n} from '../../generated/global-operations';\nimport type {\n CreateSlaPolicyInput,\n UpdateSlaPolicyInput,\n CreateCannedResponseInput,\n UpdateCannedResponseInput,\n CreateTicketCategoryInput,\n UpdateTicketCategoryInput,\n} from '../../generated/global-types';\n\n// Re-export input types for consumers\nexport type {\n CreateSlaPolicyInput,\n UpdateSlaPolicyInput,\n CreateCannedResponseInput,\n UpdateCannedResponseInput,\n CreateTicketCategoryInput,\n UpdateTicketCategoryInput,\n};\n\nexport function useSettingsOperations() {\n // Query: Get SLA policies\n const {\n data: slaPoliciesData,\n loading: slaPoliciesLoading,\n error: slaPoliciesError,\n refetch: refetchSLAPolicies,\n } = useGetSlaPoliciesQuery({\n variables: { limit: 50 },\n });\n\n // Query: Get canned responses\n const {\n data: cannedResponsesData,\n loading: cannedResponsesLoading,\n error: cannedResponsesError,\n refetch: refetchCannedResponses,\n } = useGetCannedResponsesQuery({\n variables: { limit: 100 },\n });\n\n // Query: Get ticket categories\n const {\n data: categoriesData,\n loading: categoriesLoading,\n error: categoriesError,\n refetch: refetchCategories,\n } = useGetTicketCategoriesQuery({\n variables: { limit: 50 },\n });\n\n // Mutation: Create SLA policy\n const [createSLAPolicyMutation, { loading: createSLAPolicyLoading }] = useCreateSlaPolicyMutation(\n {\n onCompleted: () => {\n refetchSLAPolicies();\n },\n onError: (error) => {\n console.error('Failed to create SLA policy:', error);\n },\n }\n );\n\n // Mutation: Update SLA policy\n const [updateSLAPolicyMutation, { loading: updateSLAPolicyLoading }] = useUpdateSlaPolicyMutation(\n {\n onCompleted: () => {\n refetchSLAPolicies();\n },\n onError: (error) => {\n console.error('Failed to update SLA policy:', error);\n },\n }\n );\n\n // Mutation: Delete SLA policy\n const [deleteSLAPolicyMutation, { loading: deleteSLAPolicyLoading }] = useDeleteSlaPolicyMutation(\n {\n onCompleted: () => {\n refetchSLAPolicies();\n },\n onError: (error) => {\n console.error('Failed to delete SLA policy:', error);\n },\n }\n );\n\n // Mutation: Create canned response\n const [createCannedResponseMutation, { loading: createCannedResponseLoading }] =\n useCreateCannedResponseMutation({\n onCompleted: () => {\n refetchCannedResponses();\n },\n onError: (error) => {\n console.error('Failed to create canned response:', error);\n },\n });\n\n // Mutation: Update canned response\n const [updateCannedResponseMutation, { loading: updateCannedResponseLoading }] =\n useUpdateCannedResponseMutation({\n onCompleted: () => {\n refetchCannedResponses();\n },\n onError: (error) => {\n console.error('Failed to update canned response:', error);\n },\n });\n\n // Mutation: Delete canned response\n const [deleteCannedResponseMutation, { loading: deleteCannedResponseLoading }] =\n useDeleteCannedResponseMutation({\n onCompleted: () => {\n refetchCannedResponses();\n },\n onError: (error) => {\n console.error('Failed to delete canned response:', error);\n },\n });\n\n // Mutation: Create ticket category\n const [createTicketCategoryMutation, { loading: createCategoryLoading }] =\n useCreateTicketCategoryMutation({\n onCompleted: () => {\n refetchCategories();\n },\n onError: (error) => {\n console.error('Failed to create category:', error);\n },\n });\n\n // Mutation: Update ticket category\n const [updateTicketCategoryMutation, { loading: updateCategoryLoading }] =\n useUpdateTicketCategoryMutation({\n onCompleted: () => {\n refetchCategories();\n },\n onError: (error) => {\n console.error('Failed to update category:', error);\n },\n });\n\n // Mutation: Delete ticket category\n const [deleteTicketCategoryMutation, { loading: deleteCategoryLoading }] =\n useDeleteTicketCategoryMutation({\n onCompleted: () => {\n refetchCategories();\n },\n onError: (error) => {\n console.error('Failed to delete category:', error);\n },\n });\n\n // Helper: Create SLA policy\n const createSLAPolicy = async (input: CreateSlaPolicyInput) => {\n const result = await createSLAPolicyMutation({\n variables: { input },\n });\n if (!result.data?.createSLAPolicy) {\n throw new Error('Failed to create SLA policy');\n }\n return result.data.createSLAPolicy;\n };\n\n // Helper: Update SLA policy\n const updateSLAPolicy = async (id: string, input: UpdateSlaPolicyInput) => {\n const result = await updateSLAPolicyMutation({\n variables: { id, input },\n });\n if (!result.data?.updateSLAPolicy) {\n throw new Error('Failed to update SLA policy');\n }\n return result.data.updateSLAPolicy;\n };\n\n // Helper: Delete SLA policy\n const deleteSLAPolicy = async (id: string) => {\n const result = await deleteSLAPolicyMutation({\n variables: { id },\n });\n return result.data?.deleteSLAPolicy;\n };\n\n // Helper: Create canned response\n const createCannedResponse = async (input: CreateCannedResponseInput) => {\n const result = await createCannedResponseMutation({\n variables: { input },\n });\n if (!result.data?.createCannedResponse) {\n throw new Error('Failed to create canned response');\n }\n return result.data.createCannedResponse;\n };\n\n // Helper: Update canned response\n const updateCannedResponse = async (id: string, input: UpdateCannedResponseInput) => {\n const result = await updateCannedResponseMutation({\n variables: { id, input },\n });\n if (!result.data?.updateCannedResponse) {\n throw new Error('Failed to update canned response');\n }\n return result.data.updateCannedResponse;\n };\n\n // Helper: Delete canned response\n const deleteCannedResponse = async (id: string) => {\n const result = await deleteCannedResponseMutation({\n variables: { id },\n });\n return result.data?.deleteCannedResponse;\n };\n\n // Helper: Create ticket category\n const createTicketCategory = async (input: CreateTicketCategoryInput) => {\n const result = await createTicketCategoryMutation({\n variables: { input },\n });\n if (!result.data?.createTicketCategory) {\n throw new Error('Failed to create category');\n }\n return result.data.createTicketCategory;\n };\n\n // Helper: Update ticket category\n const updateTicketCategory = async (id: string, input: UpdateTicketCategoryInput) => {\n const result = await updateTicketCategoryMutation({\n variables: { id, input },\n });\n if (!result.data?.updateTicketCategory) {\n throw new Error('Failed to update category');\n }\n return result.data.updateTicketCategory;\n };\n\n // Helper: Delete ticket category\n const deleteTicketCategory = async (id: string) => {\n const result = await deleteTicketCategoryMutation({\n variables: { id },\n });\n if (\n result.data?.deleteTicketCategory === undefined ||\n result.data?.deleteTicketCategory === null\n ) {\n throw new Error('Failed to delete category');\n }\n return result.data.deleteTicketCategory;\n };\n\n return {\n // Data\n slaPolicies: slaPoliciesData?.slaPolicies?.nodes || [],\n totalSLAPolicies: slaPoliciesData?.slaPolicies?.totalCount || 0,\n cannedResponses: cannedResponsesData?.cannedResponses?.nodes || [],\n totalCannedResponses: cannedResponsesData?.cannedResponses?.totalCount || 0,\n ticketCategories: categoriesData?.ticketCategories?.nodes || [],\n totalCategories: categoriesData?.ticketCategories?.totalCount || 0,\n\n // Loading states\n slaPoliciesLoading,\n cannedResponsesLoading,\n categoriesLoading,\n createSLAPolicyLoading,\n updateSLAPolicyLoading,\n deleteSLAPolicyLoading,\n createCannedResponseLoading,\n updateCannedResponseLoading,\n deleteCannedResponseLoading,\n createCategoryLoading,\n updateCategoryLoading,\n deleteCategoryLoading,\n isLoading: slaPoliciesLoading || cannedResponsesLoading || categoriesLoading,\n\n // Errors\n slaPoliciesError,\n cannedResponsesError,\n categoriesError,\n\n // SLA Policy Operations\n createSLAPolicy,\n updateSLAPolicy,\n deleteSLAPolicy,\n refetchSLAPolicies,\n\n // Canned Response Operations\n createCannedResponse,\n updateCannedResponse,\n deleteCannedResponse,\n refetchCannedResponses,\n\n // Ticket Category Operations\n createTicketCategory,\n updateTicketCategory,\n deleteTicketCategory,\n refetchCategories,\n };\n}\n"],"mappings":";;AAiCA,SAAgB,IAAwB;CAEtC,IAAM,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,MACP,EAAuB,EACzB,WAAW,EAAE,OAAO,IAAI,EACzB,CAAC,EAGI,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,MACP,EAA2B,EAC7B,WAAW,EAAE,OAAO,KAAK,EAC1B,CAAC,EAGI,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,MACP,EAA4B,EAC9B,WAAW,EAAE,OAAO,IAAI,EACzB,CAAC,EAGI,CAAC,GAAyB,EAAE,SAAS,OAA4B,EACrE;EACE,mBAAmB;AACjB,MAAoB;;EAEtB,UAAU,MAAU;AAClB,WAAQ,MAAM,gCAAgC,EAAM;;EAEvD,CACF,EAGK,CAAC,GAAyB,EAAE,SAAS,OAA4B,EACrE;EACE,mBAAmB;AACjB,MAAoB;;EAEtB,UAAU,MAAU;AAClB,WAAQ,MAAM,gCAAgC,EAAM;;EAEvD,CACF,EAGK,CAAC,GAAyB,EAAE,SAAS,OAA4B,EACrE;EACE,mBAAmB;AACjB,MAAoB;;EAEtB,UAAU,MAAU;AAClB,WAAQ,MAAM,gCAAgC,EAAM;;EAEvD,CACF,EAGK,CAAC,GAA8B,EAAE,SAAS,OAC9C,EAAgC;EAC9B,mBAAmB;AACjB,MAAwB;;EAE1B,UAAU,MAAU;AAClB,WAAQ,MAAM,qCAAqC,EAAM;;EAE5D,CAAC,EAGE,CAAC,GAA8B,EAAE,SAAS,OAC9C,EAAgC;EAC9B,mBAAmB;AACjB,MAAwB;;EAE1B,UAAU,MAAU;AAClB,WAAQ,MAAM,qCAAqC,EAAM;;EAE5D,CAAC,EAGE,CAAC,GAA8B,EAAE,SAAS,OAC9C,EAAgC;EAC9B,mBAAmB;AACjB,MAAwB;;EAE1B,UAAU,MAAU;AAClB,WAAQ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WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;EAsGpB;EAGA,sBArG2B,OAAO,MAAqC;GACvE,IAAM,IAAS,MAAM,EAA6B,EAChD,WAAW,EAAE,UAAO,EACrB,CAAC;AACF,OAAI,CAAC,EAAO,MAAM,qBAChB,OAAU,MAAM,mCAAmC;AAErD,UAAO,EAAO,KAAK;;EA+FnB,sBA3F2B,OAAO,GAAY,MAAqC;GACnF,IAAM,IAAS,MAAM,EAA6B,EAChD,WAAW;IAAE;IAAI;IAAO,EACzB,CAAC;AACF,OAAI,CAAC,EAAO,MAAM,qBAChB,OAAU,MAAM,mCAAmC;AAErD,UAAO,EAAO,KAAK;;EAqFnB,sBAjF2B,OAAO,OACnB,MAAM,EAA6B,EAChD,WAAW,EAAE,OAAI,EAClB,CAAC,EACY,MAAM;EA8EpB;EAGA,sBA7E2B,OAAO,MAAqC;GACvE,IAAM,IAAS,MAAM,EAA6B,EAChD,WAAW,EAAE,UAAO,EACrB,CAAC;AACF,OAAI,CAAC,EAAO,MAAM,qBAChB,OAAU,MAAM,4BAA4B;AAE9C,UAAO,EAAO,KAAK;;EAuEnB,sBAnE2B,OAAO,GAAY,MAAqC;GACnF,IAAM,IAAS,MAAM,EAA6B,EAChD,WAAW;IAAE;IAAI;IAAO,EACzB,CAAC;AACF,OAAI,CAAC,EAAO,MAAM,qBAChB,OAAU,MAAM,4BAA4B;AAE9C,UAAO,EAAO,KAAK;;EA6DnB,sBAzD2B,OAAO,MAAe;GACjD,IAAM,IAAS,MAAM,EAA6B,EAChD,WAAW,EAAE,OAAI,EAClB,CAAC;AACF,OACE,EAAO,MAAM,yBAAyB,KAAA,KACtC,EAAO,MAAM,yBAAyB,KAEtC,OAAU,MAAM,4BAA4B;AAE9C,UAAO,EAAO,KAAK;;EAgDnB;EACD"}
|
|
1
|
+
{"version":3,"file":"useSettingsOperations.js","names":[],"sources":["../../../src/support/hooks/useSettingsOperations.ts"],"sourcesContent":["import {\n useGetSlaPoliciesQuery,\n useCreateSlaPolicyMutation,\n useUpdateSlaPolicyMutation,\n useDeleteSlaPolicyMutation,\n useGetCannedResponsesQuery,\n useCreateCannedResponseMutation,\n useUpdateCannedResponseMutation,\n useDeleteCannedResponseMutation,\n useGetTicketCategoriesQuery,\n useCreateTicketCategoryMutation,\n useUpdateTicketCategoryMutation,\n useDeleteTicketCategoryMutation,\n} from '../../generated/global-operations';\nimport type {\n CreateSlaPolicyInput,\n UpdateSlaPolicyInput,\n CreateCannedResponseInput,\n UpdateCannedResponseInput,\n CreateTicketCategoryInput,\n UpdateTicketCategoryInput,\n} from '../../generated/global-types';\n\n// Re-export input types for consumers\nexport type {\n CreateSlaPolicyInput,\n UpdateSlaPolicyInput,\n CreateCannedResponseInput,\n UpdateCannedResponseInput,\n CreateTicketCategoryInput,\n UpdateTicketCategoryInput,\n};\n\nexport function useSettingsOperations() {\n // Query: Get SLA policies\n const {\n data: slaPoliciesData,\n loading: slaPoliciesLoading,\n error: slaPoliciesError,\n refetch: refetchSLAPolicies,\n } = useGetSlaPoliciesQuery({\n variables: { limit: 50 },\n });\n\n // Query: Get canned responses\n const {\n data: cannedResponsesData,\n loading: cannedResponsesLoading,\n error: cannedResponsesError,\n refetch: refetchCannedResponses,\n } = useGetCannedResponsesQuery({\n variables: { limit: 100 },\n });\n\n // Query: Get ticket categories\n const {\n data: categoriesData,\n loading: categoriesLoading,\n error: categoriesError,\n refetch: refetchCategories,\n } = useGetTicketCategoriesQuery({\n variables: { limit: 50 },\n });\n\n // Mutation: Create SLA policy\n const [createSLAPolicyMutation, { loading: createSLAPolicyLoading }] = useCreateSlaPolicyMutation(\n {\n onCompleted: () => {\n refetchSLAPolicies();\n },\n onError: (error) => {\n console.error('Failed to create SLA policy:', error);\n },\n }\n );\n\n // Mutation: Update SLA policy\n const [updateSLAPolicyMutation, { loading: updateSLAPolicyLoading }] = useUpdateSlaPolicyMutation(\n {\n onCompleted: () => {\n refetchSLAPolicies();\n },\n onError: (error) => {\n console.error('Failed to update SLA policy:', error);\n },\n }\n );\n\n // Mutation: Delete SLA policy\n const [deleteSLAPolicyMutation, { loading: deleteSLAPolicyLoading }] = useDeleteSlaPolicyMutation(\n {\n onCompleted: () => {\n refetchSLAPolicies();\n },\n onError: (error) => {\n console.error('Failed to delete SLA policy:', error);\n },\n }\n );\n\n // Mutation: Create canned response\n const [createCannedResponseMutation, { loading: createCannedResponseLoading }] =\n useCreateCannedResponseMutation({\n onCompleted: () => {\n refetchCannedResponses();\n },\n onError: (error) => {\n console.error('Failed to create canned response:', error);\n },\n });\n\n // Mutation: Update canned response\n const [updateCannedResponseMutation, { loading: updateCannedResponseLoading }] =\n useUpdateCannedResponseMutation({\n onCompleted: () => {\n refetchCannedResponses();\n },\n onError: (error) => {\n console.error('Failed to update canned response:', error);\n },\n });\n\n // Mutation: Delete canned response\n const [deleteCannedResponseMutation, { loading: deleteCannedResponseLoading }] =\n useDeleteCannedResponseMutation({\n onCompleted: () => {\n refetchCannedResponses();\n },\n onError: (error) => {\n console.error('Failed to delete canned response:', error);\n },\n });\n\n // Mutation: Create ticket category\n const [createTicketCategoryMutation, { loading: createCategoryLoading }] =\n useCreateTicketCategoryMutation({\n onCompleted: () => {\n refetchCategories();\n },\n onError: (error) => {\n console.error('Failed to create category:', error);\n },\n });\n\n // Mutation: Update ticket category\n const [updateTicketCategoryMutation, { loading: updateCategoryLoading }] =\n useUpdateTicketCategoryMutation({\n onCompleted: () => {\n refetchCategories();\n },\n onError: (error) => {\n console.error('Failed to update category:', error);\n },\n });\n\n // Mutation: Delete ticket category\n const [deleteTicketCategoryMutation, { loading: deleteCategoryLoading }] =\n useDeleteTicketCategoryMutation({\n onCompleted: () => {\n refetchCategories();\n },\n onError: (error) => {\n console.error('Failed to delete category:', error);\n },\n });\n\n // Helper: Create SLA policy\n const createSLAPolicy = async (input: CreateSlaPolicyInput) => {\n const result = await createSLAPolicyMutation({\n variables: { input },\n });\n if (!result.data?.createSLAPolicy) {\n throw new Error('Failed to create SLA policy');\n }\n await refetchSLAPolicies();\n return result.data.createSLAPolicy;\n };\n\n // Helper: Update SLA policy\n const updateSLAPolicy = async (id: string, input: UpdateSlaPolicyInput) => {\n const result = await updateSLAPolicyMutation({\n variables: { id, input },\n });\n if (!result.data?.updateSLAPolicy) {\n throw new Error('Failed to update SLA policy');\n }\n await refetchSLAPolicies();\n return result.data.updateSLAPolicy;\n };\n\n // Helper: Delete SLA policy\n const deleteSLAPolicy = async (id: string) => {\n const result = await deleteSLAPolicyMutation({\n variables: { id },\n });\n await refetchSLAPolicies();\n return result.data?.deleteSLAPolicy;\n };\n\n // Helper: Create canned response\n const createCannedResponse = async (input: CreateCannedResponseInput) => {\n const result = await createCannedResponseMutation({\n variables: { input },\n });\n if (!result.data?.createCannedResponse) {\n throw new Error('Failed to create canned response');\n }\n await refetchCannedResponses();\n return result.data.createCannedResponse;\n };\n\n // Helper: Update canned response\n const updateCannedResponse = async (id: string, input: UpdateCannedResponseInput) => {\n const result = await updateCannedResponseMutation({\n variables: { id, input },\n });\n if (!result.data?.updateCannedResponse) {\n throw new Error('Failed to update canned response');\n }\n await refetchCannedResponses();\n return result.data.updateCannedResponse;\n };\n\n // Helper: Delete canned response\n const deleteCannedResponse = async (id: string) => {\n const result = await deleteCannedResponseMutation({\n variables: { id },\n });\n await refetchCannedResponses();\n return result.data?.deleteCannedResponse;\n };\n\n // Helper: Create ticket category\n const createTicketCategory = async (input: CreateTicketCategoryInput) => {\n const result = await createTicketCategoryMutation({\n variables: { input },\n });\n if (!result.data?.createTicketCategory) {\n throw new Error('Failed to create category');\n }\n await refetchCategories();\n return result.data.createTicketCategory;\n };\n\n // Helper: Update ticket category\n const updateTicketCategory = async (id: string, input: UpdateTicketCategoryInput) => {\n const result = await updateTicketCategoryMutation({\n variables: { id, input },\n });\n if (!result.data?.updateTicketCategory) {\n throw new Error('Failed to update category');\n }\n await refetchCategories();\n return result.data.updateTicketCategory;\n };\n\n // Helper: Delete ticket category\n const deleteTicketCategory = async (id: string) => {\n const result = await deleteTicketCategoryMutation({\n variables: { id },\n });\n if (\n result.data?.deleteTicketCategory === undefined ||\n result.data?.deleteTicketCategory === null\n ) {\n throw new Error('Failed to delete category');\n }\n await refetchCategories();\n return result.data.deleteTicketCategory;\n };\n\n return {\n // Data\n slaPolicies: slaPoliciesData?.slaPolicies?.nodes || [],\n totalSLAPolicies: slaPoliciesData?.slaPolicies?.totalCount || 0,\n cannedResponses: cannedResponsesData?.cannedResponses?.nodes || [],\n totalCannedResponses: cannedResponsesData?.cannedResponses?.totalCount || 0,\n ticketCategories: categoriesData?.ticketCategories?.nodes || [],\n totalCategories: categoriesData?.ticketCategories?.totalCount || 0,\n\n // Loading states\n slaPoliciesLoading,\n cannedResponsesLoading,\n categoriesLoading,\n createSLAPolicyLoading,\n updateSLAPolicyLoading,\n deleteSLAPolicyLoading,\n createCannedResponseLoading,\n updateCannedResponseLoading,\n deleteCannedResponseLoading,\n createCategoryLoading,\n updateCategoryLoading,\n deleteCategoryLoading,\n isLoading: slaPoliciesLoading || cannedResponsesLoading || categoriesLoading,\n\n // Errors\n slaPoliciesError,\n cannedResponsesError,\n categoriesError,\n\n // SLA Policy Operations\n createSLAPolicy,\n updateSLAPolicy,\n deleteSLAPolicy,\n refetchSLAPolicies,\n\n // Canned Response Operations\n createCannedResponse,\n updateCannedResponse,\n deleteCannedResponse,\n refetchCannedResponses,\n\n // Ticket Category Operations\n createTicketCategory,\n updateTicketCategory,\n deleteTicketCategory,\n refetchCategories,\n };\n}\n"],"mappings":";;AAiCA,SAAgB,IAAwB;CAEtC,IAAM,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,MACP,EAAuB,EACzB,WAAW,EAAE,OAAO,IAAI,EACzB,CAAC,EAGI,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,MACP,EAA2B,EAC7B,WAAW,EAAE,OAAO,KAAK,EAC1B,CAAC,EAGI,EACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,MACP,EAA4B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