@burdenoff/microfe-support 2026.1109.1 → 2026.1115.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 +62 -0
- package/dist/generated/global-operations.js +104 -69
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js +17 -15
- package/dist/generated/global-types.js.map +1 -1
- package/dist/support/SupportUserRoot.js +32 -28
- package/dist/support/SupportUserRoot.js.map +1 -1
- package/dist/support/SupportUserRoutes.d.ts +1 -0
- package/dist/support/SupportUserRoutes.js +31 -28
- package/dist/support/SupportUserRoutes.js.map +1 -1
- package/dist/support/components/PageLayout.js +35 -35
- package/dist/support/components/RouteHelpers.d.ts +2 -1
- package/dist/support/components/RouteHelpers.js +3 -3
- package/dist/support/components/RouteHelpers.js.map +1 -1
- package/dist/support/components/help/RelatedArticles.d.ts +12 -0
- package/dist/support/components/help/RelatedArticles.js +55 -0
- package/dist/support/components/help/RelatedArticles.js.map +1 -0
- package/dist/support/components/help/RequestDetailHeader.d.ts +18 -0
- package/dist/support/components/help/RequestDetailHeader.js +129 -0
- package/dist/support/components/help/RequestDetailHeader.js.map +1 -0
- package/dist/support/components/help/SatisfactionReview.d.ts +18 -0
- package/dist/support/components/help/SatisfactionReview.js +103 -0
- package/dist/support/components/help/SatisfactionReview.js.map +1 -0
- package/dist/support/components/help/StarRating.d.ts +16 -0
- package/dist/support/components/help/StarRating.js +63 -0
- package/dist/support/components/help/StarRating.js.map +1 -0
- package/dist/support/components/help/StatusGroupPill.d.ts +11 -0
- package/dist/support/components/help/StatusGroupPill.js +19 -0
- package/dist/support/components/help/StatusGroupPill.js.map +1 -0
- package/dist/support/components/settings/TicketCategoriesSettings.js +69 -69
- package/dist/support/components/settings/TicketCategoriesSettings.js.map +1 -1
- package/dist/support/components/tickets/MessageComposer.js +7 -7
- package/dist/support/components/tickets/MessageComposer.js.map +1 -1
- package/dist/support/components/tickets/TicketDetailHeader.js +54 -60
- package/dist/support/components/tickets/TicketDetailHeader.js.map +1 -1
- package/dist/support/components/ui.js +1 -1
- package/dist/support/constants.d.ts +23 -0
- package/dist/support/constants.js +2 -2
- package/dist/support/constants.js.map +1 -1
- package/dist/support/hooks/useDebouncedValue.d.ts +6 -0
- package/dist/support/hooks/useDebouncedValue.js +12 -0
- package/dist/support/hooks/useDebouncedValue.js.map +1 -0
- package/dist/support/hooks/useKnowledgeBaseOperations.d.ts +8 -1
- package/dist/support/hooks/useKnowledgeBaseOperations.js +86 -81
- package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
- package/dist/support/hooks/useSupportVariant.d.ts +11 -0
- package/dist/support/hooks/useSupportVariant.js +11 -0
- package/dist/support/hooks/useSupportVariant.js.map +1 -0
- package/dist/support/hooks/useTicketCreatedToast.d.ts +16 -0
- package/dist/support/hooks/useTicketCreatedToast.js +25 -0
- package/dist/support/hooks/useTicketCreatedToast.js.map +1 -0
- package/dist/support/hooks/useTicketLabels.d.ts +22 -0
- package/dist/support/hooks/useTicketLabels.js +40 -0
- package/dist/support/hooks/useTicketLabels.js.map +1 -0
- package/dist/support/index.d.ts +1 -1
- package/dist/support/pages/ArticleDetailAdminPage.js +84 -84
- package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailUserPage.d.ts +5 -0
- package/dist/support/pages/ArticleDetailUserPage.js +133 -69
- package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
- package/dist/support/pages/AskForHelpPage.d.ts +11 -0
- package/dist/support/pages/AskForHelpPage.js +396 -0
- package/dist/support/pages/AskForHelpPage.js.map +1 -0
- package/dist/support/pages/ContactInquiriesPage.js +73 -73
- package/dist/support/pages/ContactInquiryDetailPage.js +47 -47
- package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
- package/dist/support/pages/CreateTicketPage.d.ts +4 -0
- package/dist/support/pages/CreateTicketPage.js +121 -117
- package/dist/support/pages/CreateTicketPage.js.map +1 -1
- package/dist/support/pages/HelpHubPage.d.ts +9 -0
- package/dist/support/pages/HelpHubPage.js +272 -0
- package/dist/support/pages/HelpHubPage.js.map +1 -0
- package/dist/support/pages/JobApplicationDetailPage.js +388 -388
- package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
- package/dist/support/pages/JobApplicationsPage.js +35 -35
- package/dist/support/pages/JobPostingDetailPage.js +236 -236
- package/dist/support/pages/JobPostingDetailPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseUserPage.d.ts +6 -1
- package/dist/support/pages/KnowledgeBaseUserPage.js +188 -137
- package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
- package/dist/support/pages/MyRequestsPage.d.ts +16 -0
- package/dist/support/pages/MyRequestsPage.js +389 -0
- package/dist/support/pages/MyRequestsPage.js.map +1 -0
- package/dist/support/pages/TicketDetailUserPage.d.ts +5 -0
- package/dist/support/pages/TicketDetailUserPage.js +285 -192
- package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
- package/dist/support/pages/TicketListPage.d.ts +7 -0
- package/dist/support/pages/TicketListPage.js +150 -153
- package/dist/support/pages/TicketListPage.js.map +1 -1
- package/dist/support/providers/SupportProvider.js +8 -7
- package/dist/support/providers/SupportProvider.js.map +1 -1
- package/dist/support/store/supportStore.d.ts +5 -0
- package/dist/support/store/supportStore.js +1 -0
- package/dist/support/store/supportStore.js.map +1 -1
- package/dist/support/translations/en.d.ts +279 -0
- package/dist/support/translations/en.js +270 -1
- package/dist/support/translations/en.js.map +1 -1
- package/dist/support/types/index.d.ts +13 -0
- package/dist/support/utils/cameFrom.d.ts +16 -0
- package/dist/support/utils/cameFrom.js +22 -0
- package/dist/support/utils/cameFrom.js.map +1 -0
- package/dist/support/utils/dates.d.ts +15 -0
- package/dist/support/utils/dates.js +35 -0
- package/dist/support/utils/dates.js.map +1 -0
- package/dist/support/utils/reopen.d.ts +27 -0
- package/dist/support/utils/reopen.js +27 -0
- package/dist/support/utils/reopen.js.map +1 -0
- package/dist/support/utils/requestTechnicalDetails.d.ts +13 -0
- package/dist/support/utils/requestTechnicalDetails.js +38 -0
- package/dist/support/utils/requestTechnicalDetails.js.map +1 -0
- package/dist/support/utils/ticketFilters.d.ts +16 -0
- package/dist/support/utils/ticketFilters.js +24 -12
- package/dist/support/utils/ticketFilters.js.map +1 -1
- package/dist/support/utils/ticketStatusGroups.d.ts +20 -0
- package/dist/support/utils/ticketStatusGroups.js +39 -0
- package/dist/support/utils/ticketStatusGroups.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,158 +1,163 @@
|
|
|
1
1
|
import { emitSupportKbArticleRated as e } from "../events/rybbit.js";
|
|
2
2
|
import { useSupportStore as t } from "../store/supportStore.js";
|
|
3
|
-
import { useArchiveKnowledgeBaseArticleMutation as n, useCreateKnowledgeBaseArticleMutation as
|
|
3
|
+
import { useArchiveKnowledgeBaseArticleMutation as n, useCreateKnowledgeBaseArticleMutation as ee, useDeleteKnowledgeBaseArticleMutation as te, useGetArticleBySlugQuery 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";
|
|
4
|
+
import { ArticleStatus as m } from "../../generated/global-types.js";
|
|
4
5
|
import { asRefetch as h } from "../utils/refetch.js";
|
|
5
6
|
import { useCallback as g, useEffect as _ } from "react";
|
|
6
7
|
import { useEventBus as v } from "@burdenoff/fe-libs/shared/events";
|
|
7
8
|
// src/support/hooks/useKnowledgeBaseOperations.ts
|
|
8
|
-
function y(y) {
|
|
9
|
-
let {
|
|
9
|
+
function y(y, b = {}) {
|
|
10
|
+
let { publishedOnly: x = !1 } = b, { kbSearch: S, selectedArticle: C, updateKbSearch: w, setKbResults: T, setSelectedArticle: E } = t(), D = v(), { data: O, loading: k, error: A, fetchMore: j, refetch: M } = a({ variables: {
|
|
10
11
|
limit: 20,
|
|
11
12
|
offset: 0,
|
|
12
13
|
filter: {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
status: x ? m.Published : void 0,
|
|
15
|
+
categoryId: S.filters.categoryId || void 0,
|
|
16
|
+
tags: S.filters.tags.length > 0 ? S.filters.tags : void 0
|
|
15
17
|
}
|
|
16
|
-
} }),
|
|
18
|
+
} }), { data: N, loading: P } = o({ variables: { limit: 10 } }), { data: F, loading: I } = s({ variables: { limit: 50 } }), { data: L, loading: R, error: z } = d({
|
|
17
19
|
variables: {
|
|
18
|
-
query:
|
|
20
|
+
query: S.query || "",
|
|
19
21
|
limit: 20,
|
|
20
|
-
categoryId:
|
|
22
|
+
categoryId: S.filters.categoryId || void 0
|
|
21
23
|
},
|
|
22
|
-
skip: !
|
|
24
|
+
skip: !S.query
|
|
23
25
|
});
|
|
24
26
|
_(() => {
|
|
25
|
-
if (
|
|
26
|
-
let e =
|
|
27
|
-
|
|
27
|
+
if (L?.searchKnowledgeBase) {
|
|
28
|
+
let e = L.searchKnowledgeBase;
|
|
29
|
+
T(e);
|
|
28
30
|
}
|
|
29
|
-
}, [
|
|
30
|
-
let { data:
|
|
31
|
-
variables: {
|
|
32
|
-
skip: !
|
|
33
|
-
}),
|
|
31
|
+
}, [L, T]);
|
|
32
|
+
let B = !!y && x, V = y && !B ? O?.knowledgeBaseArticles?.nodes?.find((e) => e.slug === y)?.id : void 0, { data: H, loading: U, error: W, refetch: ne } = r({
|
|
33
|
+
variables: { slug: y ?? "" },
|
|
34
|
+
skip: !B
|
|
35
|
+
}), G = B ? "" : C?.id || V || "", { data: K, loading: q, error: J, refetch: Y } = i({
|
|
36
|
+
variables: { id: G },
|
|
37
|
+
skip: !G
|
|
38
|
+
}), X = B ? H?.knowledgeBaseArticleBySlug ?? null : K?.knowledgeBaseArticle ?? null, Z = B ? U : q, re = B ? W : J, Q = B ? ne : Y, [ie, { loading: ae }] = l({
|
|
34
39
|
onCompleted: () => {
|
|
35
|
-
|
|
40
|
+
Q();
|
|
36
41
|
},
|
|
37
42
|
onError: (e) => {
|
|
38
43
|
console.error("Failed to rate article:", e);
|
|
39
44
|
}
|
|
40
|
-
}), [
|
|
45
|
+
}), [$] = u({ onError: (e) => {
|
|
41
46
|
console.error("Failed to record view:", e);
|
|
42
|
-
} }), [
|
|
47
|
+
} }), [oe, { loading: se }] = ee({
|
|
43
48
|
onCompleted: () => {
|
|
44
|
-
|
|
49
|
+
M();
|
|
45
50
|
},
|
|
46
51
|
onError: (e) => {
|
|
47
52
|
console.error("Failed to create article:", e);
|
|
48
53
|
}
|
|
49
|
-
}), [
|
|
54
|
+
}), [ce, { loading: le }] = p({
|
|
50
55
|
onCompleted: () => {
|
|
51
|
-
|
|
56
|
+
M(), Q();
|
|
52
57
|
},
|
|
53
58
|
onError: (e) => {
|
|
54
59
|
console.error("Failed to update article:", e);
|
|
55
60
|
}
|
|
56
|
-
}), [
|
|
61
|
+
}), [ue, { loading: de }] = te({
|
|
57
62
|
onCompleted: () => {
|
|
58
|
-
|
|
63
|
+
M();
|
|
59
64
|
},
|
|
60
65
|
onError: (e) => {
|
|
61
66
|
console.error("Failed to delete article:", e);
|
|
62
67
|
}
|
|
63
|
-
}), [
|
|
68
|
+
}), [fe, { loading: pe }] = c({
|
|
64
69
|
onCompleted: () => {
|
|
65
|
-
|
|
70
|
+
M(), Q();
|
|
66
71
|
},
|
|
67
72
|
onError: (e) => {
|
|
68
73
|
console.error("Failed to publish article:", e);
|
|
69
74
|
}
|
|
70
|
-
}), [
|
|
75
|
+
}), [me, { loading: he }] = f({
|
|
71
76
|
onCompleted: () => {
|
|
72
|
-
|
|
77
|
+
M(), Q();
|
|
73
78
|
},
|
|
74
79
|
onError: (e) => {
|
|
75
80
|
console.error("Failed to unpublish article:", e);
|
|
76
81
|
}
|
|
77
|
-
}), [
|
|
82
|
+
}), [ge, { loading: _e }] = n({
|
|
78
83
|
onCompleted: () => {
|
|
79
|
-
|
|
84
|
+
M(), Q();
|
|
80
85
|
},
|
|
81
86
|
onError: (e) => {
|
|
82
87
|
console.error("Failed to archive article:", e);
|
|
83
88
|
}
|
|
84
|
-
}),
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
S
|
|
88
|
-
},
|
|
89
|
-
let e =
|
|
90
|
-
|
|
89
|
+
}), ve = g((e, t) => {
|
|
90
|
+
w(e.trim(), t);
|
|
91
|
+
}, [w]), ye = (e) => {
|
|
92
|
+
w(S.query, e);
|
|
93
|
+
}, be = () => {
|
|
94
|
+
let e = O?.knowledgeBaseArticles?.nodes?.length || 0;
|
|
95
|
+
O?.knowledgeBaseArticles?.hasMore && j({
|
|
91
96
|
variables: { offset: e },
|
|
92
97
|
updateQuery: (e, { fetchMoreResult: t }) => t ? { knowledgeBaseArticles: {
|
|
93
98
|
...t.knowledgeBaseArticles,
|
|
94
99
|
nodes: [...e.knowledgeBaseArticles?.nodes || [], ...t.knowledgeBaseArticles?.nodes || []]
|
|
95
100
|
} } : e
|
|
96
101
|
});
|
|
97
|
-
},
|
|
102
|
+
}, xe = async (t, n) => {
|
|
98
103
|
try {
|
|
99
|
-
await
|
|
104
|
+
await ie({ variables: {
|
|
100
105
|
id: t,
|
|
101
106
|
helpful: n
|
|
102
|
-
} }), e(
|
|
107
|
+
} }), e(D, t, n);
|
|
103
108
|
} catch (e) {
|
|
104
109
|
throw console.error("Failed to vote on article:", e), e;
|
|
105
110
|
}
|
|
106
|
-
},
|
|
111
|
+
}, Se = g(async (e) => {
|
|
107
112
|
try {
|
|
108
|
-
await
|
|
113
|
+
await $({ variables: { id: e } }), D.emit("support.kb.article_viewed", { articleId: e });
|
|
109
114
|
} catch (e) {
|
|
110
115
|
console.error("Failed to record view:", e);
|
|
111
116
|
}
|
|
112
|
-
}, [
|
|
117
|
+
}, [D, $]);
|
|
113
118
|
return {
|
|
114
|
-
articles:
|
|
115
|
-
popularArticles:
|
|
116
|
-
categories:
|
|
117
|
-
searchResults:
|
|
118
|
-
articleDetail:
|
|
119
|
-
totalArticles:
|
|
120
|
-
totalResults:
|
|
121
|
-
hasMoreArticles:
|
|
119
|
+
articles: O?.knowledgeBaseArticles?.nodes || [],
|
|
120
|
+
popularArticles: N?.popularArticles || [],
|
|
121
|
+
categories: F?.ticketCategories?.nodes || [],
|
|
122
|
+
searchResults: S.results,
|
|
123
|
+
articleDetail: X,
|
|
124
|
+
totalArticles: O?.knowledgeBaseArticles?.totalCount || 0,
|
|
125
|
+
totalResults: L?.searchKnowledgeBase?.length || 0,
|
|
126
|
+
hasMoreArticles: O?.knowledgeBaseArticles?.hasMore || !1,
|
|
122
127
|
hasMoreResults: !1,
|
|
123
|
-
articlesLoading:
|
|
124
|
-
popularLoading:
|
|
125
|
-
categoriesLoading:
|
|
126
|
-
searchLoading:
|
|
127
|
-
articleLoading:
|
|
128
|
-
ratingArticle:
|
|
129
|
-
creatingArticle:
|
|
130
|
-
updatingArticle:
|
|
131
|
-
deletingArticle:
|
|
132
|
-
publishingArticle:
|
|
133
|
-
unpublishingArticle:
|
|
134
|
-
archivingArticle:
|
|
135
|
-
articlesError:
|
|
136
|
-
searchError:
|
|
137
|
-
articleError:
|
|
138
|
-
searchArticles:
|
|
139
|
-
filterArticles:
|
|
140
|
-
loadMoreArticles:
|
|
141
|
-
voteArticle:
|
|
142
|
-
recordView:
|
|
143
|
-
refetchArticles: h(
|
|
144
|
-
refetchArticle: h(
|
|
145
|
-
setSelectedArticle:
|
|
128
|
+
articlesLoading: k,
|
|
129
|
+
popularLoading: P,
|
|
130
|
+
categoriesLoading: I,
|
|
131
|
+
searchLoading: R,
|
|
132
|
+
articleLoading: Z,
|
|
133
|
+
ratingArticle: ae,
|
|
134
|
+
creatingArticle: se,
|
|
135
|
+
updatingArticle: le,
|
|
136
|
+
deletingArticle: de,
|
|
137
|
+
publishingArticle: pe,
|
|
138
|
+
unpublishingArticle: he,
|
|
139
|
+
archivingArticle: _e,
|
|
140
|
+
articlesError: A,
|
|
141
|
+
searchError: z,
|
|
142
|
+
articleError: re,
|
|
143
|
+
searchArticles: ve,
|
|
144
|
+
filterArticles: ye,
|
|
145
|
+
loadMoreArticles: be,
|
|
146
|
+
voteArticle: xe,
|
|
147
|
+
recordView: Se,
|
|
148
|
+
refetchArticles: h(M),
|
|
149
|
+
refetchArticle: h(Q),
|
|
150
|
+
setSelectedArticle: E,
|
|
146
151
|
createArticle: async (e) => {
|
|
147
152
|
try {
|
|
148
|
-
return (await
|
|
153
|
+
return (await oe({ variables: { input: e } })).data?.createKnowledgeBaseArticle;
|
|
149
154
|
} catch (e) {
|
|
150
155
|
throw console.error("Failed to create article:", e), e;
|
|
151
156
|
}
|
|
152
157
|
},
|
|
153
158
|
updateArticle: async (e, t) => {
|
|
154
159
|
try {
|
|
155
|
-
return (await
|
|
160
|
+
return (await ce({ variables: {
|
|
156
161
|
id: e,
|
|
157
162
|
input: t
|
|
158
163
|
} })).data?.updateKnowledgeBaseArticle;
|
|
@@ -162,28 +167,28 @@ function y(y) {
|
|
|
162
167
|
},
|
|
163
168
|
deleteArticle: async (e) => {
|
|
164
169
|
try {
|
|
165
|
-
return (await
|
|
170
|
+
return (await ue({ variables: { id: e } })).data?.deleteKnowledgeBaseArticle;
|
|
166
171
|
} catch (e) {
|
|
167
172
|
throw console.error("Failed to delete article:", e), e;
|
|
168
173
|
}
|
|
169
174
|
},
|
|
170
175
|
publishArticle: async (e) => {
|
|
171
176
|
try {
|
|
172
|
-
return (await
|
|
177
|
+
return (await fe({ variables: { id: e } })).data?.publishKnowledgeBaseArticle;
|
|
173
178
|
} catch (e) {
|
|
174
179
|
throw console.error("Failed to publish article:", e), e;
|
|
175
180
|
}
|
|
176
181
|
},
|
|
177
182
|
unpublishArticle: async (e) => {
|
|
178
183
|
try {
|
|
179
|
-
return (await
|
|
184
|
+
return (await me({ variables: { id: e } })).data?.unpublishKnowledgeBaseArticle;
|
|
180
185
|
} catch (e) {
|
|
181
186
|
throw console.error("Failed to unpublish article:", e), e;
|
|
182
187
|
}
|
|
183
188
|
},
|
|
184
189
|
archiveArticle: async (e) => {
|
|
185
190
|
try {
|
|
186
|
-
return (await
|
|
191
|
+
return (await ge({ variables: { id: e } })).data?.archiveKnowledgeBaseArticle;
|
|
187
192
|
} catch (e) {
|
|
188
193
|
throw console.error("Failed to archive article:", e), e;
|
|
189
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKnowledgeBaseOperations.js","names":["useKnowledgeBaseOperations","useSupportStore","eventBus","useEventBus","articlesData","articlesLoading","articlesError","fetchMoreArticles","refetchArticles","useGetArticlesQuery","kbSearch","articleIdFromSlug","articleSlug","article","popularData","popularLoading","useGetPopularArticlesQuery","categoriesData","categoriesLoading","useGetTicketCategoriesQuery","searchData","searchLoading","searchError","useSearchKnowledgeBaseQuery","articles","setKbResults","articleData","articleLoading","articleError","refetchArticle","useGetArticleQuery","selectedArticle","rateArticleMutation","ratingArticle","useRateArticleMutation","error","recordViewMutation","useRecordArticleViewMutation","createArticleMutation","creatingArticle","useCreateKnowledgeBaseArticleMutation","updateArticleMutation","updatingArticle","useUpdateKnowledgeBaseArticleMutation","deleteArticleMutation","deletingArticle","useDeleteKnowledgeBaseArticleMutation","publishArticleMutation","publishingArticle","usePublishKnowledgeBaseArticleMutation","unpublishArticleMutation","unpublishingArticle","useUnpublishKnowledgeBaseArticleMutation","archiveArticleMutation","archivingArticle","useArchiveKnowledgeBaseArticleMutation","searchArticles","query","filters","filterArticles","loadMoreArticles","currentCount","fetchMoreResult","prev","voteArticle","articleId","emitSupportKbArticleRated","helpful","recordView","useCallback","asRefetch"],"sources":["../../../src/support/hooks/useKnowledgeBaseOperations.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { emitSupportKbArticleRated } from '../events/rybbit';\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';\nimport { asRefetch } from '../utils/refetch';\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 emitSupportKbArticleRated(eventBus, articleId, helpful);\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', {\n articleId,\n });\n } catch (error) {\n console.error('Failed to record view:', error);\n }\n },\n [eventBus, recordViewMutation]\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: asRefetch(refetchArticles),\n refetchArticle: asRefetch(refetchArticle),\n setSelectedArticle,\n\n // CRUD Operations\n createArticle,\n updateArticle,\n deleteArticle,\n publishArticle,\n unpublishArticle,\n archiveArticle,\n };\n}\n"],"mappings":";;;;;;;AA+BA,SAAgBA,EAA2B,GAAsB;CAC/D,IAAM,EAAE,aAAU,oBAAiB,mBAAgB,iBAAc,0BAC/DC,EAAgB,GACZC,IAAWC,EAAY,GAGvB,EACJ,MAAMC,GACN,SAASC,GACT,OAAOC,GACP,WAAWC,GACX,SAASC,MACPC,EAAoB,EACtB,WAAW;EACT,OAAO;EACP,QAAQ;EACR,QAAQ;GAEN,YAAYC,EAAS,QAAQ,cAAc,KAAA;GAC3C,MAAMA,EAAS,QAAQ,KAAK,SAAS,IAAIA,EAAS,QAAQ,OAAO,KAAA;EACnE;CACF,EACF,CAAC,GAEKC,IAAoBC,IACtBR,GAAc,uBAAuB,OAAO,MACzC,MAA0CS,EAAQ,SAASD,CAC9D,CAAC,EAAE,KACH,KAAA,GAGE,EAAE,MAAME,GAAa,SAASC,MAAmBC,EAA2B,EAChF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EAAE,MAAMC,GAAgB,SAASC,MAAsBC,EAA4B,EACvF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EACJ,MAAMC,GACN,SAASC,IACT,OAAOC,MACLC,EAA4B;EAC9B,WAAW;GACT,OAAOb,EAAS,SAAS;GACzB,OAAO;GACP,YAAYA,EAAS,QAAQ,cAAc,KAAA;EAC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MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASZ,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;EA0EE,yBAvE8B,MAAe;GAC7C,IAAI;IAIF,QAAO,MAHce,EAAyB,EAC5C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASf,GAAO;IAEd,MADA,QAAQ,MAAM,gCAAgCA,CAAK,GAC7CA;GACR;EACF;EA8DE,uBA3D4B,MAAe;GAC3C,IAAI;IAIF,QAAO,MAHckB,GAAuB,EAC1C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASlB,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;CAkDA;AACF"}
|
|
1
|
+
{"version":3,"file":"useKnowledgeBaseOperations.js","names":["useKnowledgeBaseOperations","options","useSupportStore","eventBus","useEventBus","articlesData","articlesLoading","articlesError","fetchMoreArticles","refetchArticles","useGetArticlesQuery","publishedOnly","ArticleStatus","kbSearch","popularData","popularLoading","useGetPopularArticlesQuery","categoriesData","categoriesLoading","useGetTicketCategoriesQuery","searchData","searchLoading","searchError","useSearchKnowledgeBaseQuery","articles","setKbResults","lookUpBySlug","articleSlug","articleIdFromSlug","article","articleBySlugData","articleBySlugLoading","articleBySlugError","refetchArticleBySlug","useGetArticleBySlugQuery","articleIdToLoad","selectedArticle","articleByIdData","articleByIdLoading","articleByIdError","refetchArticleById","useGetArticleQuery","articleDetail","articleLoading","articleError","refetchArticle","rateArticleMutation","ratingArticle","useRateArticleMutation","error","recordViewMutation","useRecordArticleViewMutation","createArticleMutation","creatingArticle","useCreateKnowledgeBaseArticleMutation","updateArticleMutation","updatingArticle","useUpdateKnowledgeBaseArticleMutation","deleteArticleMutation","deletingArticle","useDeleteKnowledgeBaseArticleMutation","publishArticleMutation","publishingArticle","usePublishKnowledgeBaseArticleMutation","unpublishArticleMutation","unpublishingArticle","useUnpublishKnowledgeBaseArticleMutation","archiveArticleMutation","archivingArticle","useArchiveKnowledgeBaseArticleMutation","searchArticles","useCallback","query","filters","updateKbSearch","filterArticles","loadMoreArticles","currentCount","fetchMoreResult","prev","voteArticle","articleId","emitSupportKbArticleRated","helpful","recordView","asRefetch"],"sources":["../../../src/support/hooks/useKnowledgeBaseOperations.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { emitSupportKbArticleRated } from '../events/rybbit';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n useGetArticlesQuery,\n useGetArticleQuery,\n useGetArticleBySlugQuery,\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 {\n ArticleStatus,\n type KnowledgeBaseArticle,\n type KnowledgeBaseArticleFilterInput,\n type CreateKnowledgeBaseArticleInput,\n type UpdateKnowledgeBaseArticleInput,\n} from '../../generated/global-types';\nimport type { KnowledgeBaseArticleState } from '../store/supportStore';\nimport { asRefetch } from '../utils/refetch';\n\n// Input types for article operations (re-export for consumers)\nexport type { CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput };\n\nexport interface UseKnowledgeBaseOperationsOptions {\n /**\n * List only PUBLISHED articles. The user-facing pages set this; the admin\n * pages leave it off so authors still see drafts and archived articles.\n */\n publishedOnly?: boolean;\n}\n\nexport function useKnowledgeBaseOperations(\n articleSlug?: string,\n options: UseKnowledgeBaseOperationsOptions = {}\n) {\n const { publishedOnly = false } = options;\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 // Admin pages see every status (drafts included); user pages ask for\n // published articles only.\n status: publishedOnly ? ArticleStatus.Published : undefined,\n categoryId: kbSearch.filters.categoryId || undefined,\n tags: kbSearch.filters.tags.length > 0 ? kbSearch.filters.tags : undefined,\n } as KnowledgeBaseArticleFilterInput,\n },\n });\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 //\n // User pages (`publishedOnly`) look a routed slug up directly by slug, so an\n // article past the first 20 listed ones still opens. Admin pages keep the id\n // lookup: `knowledgeBaseArticleBySlug` is pinned to the request's tenant,\n // while `knowledgeBaseArticle(id)` lets staff open any tenant's article, so\n // the slug is resolved to an id from the (unfiltered for staff) admin list.\n const lookUpBySlug = Boolean(articleSlug) && publishedOnly;\n const articleIdFromSlug =\n articleSlug && !lookUpBySlug\n ? articlesData?.knowledgeBaseArticles?.nodes?.find(\n (article: { slug: string; id: string }) => article.slug === articleSlug\n )?.id\n : undefined;\n const {\n data: articleBySlugData,\n loading: articleBySlugLoading,\n error: articleBySlugError,\n refetch: refetchArticleBySlug,\n } = useGetArticleBySlugQuery({\n variables: { slug: articleSlug ?? '' },\n skip: !lookUpBySlug,\n });\n const articleIdToLoad = lookUpBySlug ? '' : selectedArticle?.id || articleIdFromSlug || '';\n const {\n data: articleByIdData,\n loading: articleByIdLoading,\n error: articleByIdError,\n refetch: refetchArticleById,\n } = useGetArticleQuery({\n variables: { id: articleIdToLoad },\n skip: !articleIdToLoad,\n });\n const articleDetail = lookUpBySlug\n ? (articleBySlugData?.knowledgeBaseArticleBySlug ?? null)\n : (articleByIdData?.knowledgeBaseArticle ?? null);\n const articleLoading = lookUpBySlug ? articleBySlugLoading : articleByIdLoading;\n const articleError = lookUpBySlug ? articleBySlugError : articleByIdError;\n const refetchArticle = lookUpBySlug ? refetchArticleBySlug : refetchArticleById;\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 // Memoised so pages can search from an effect (search as you type).\n const searchArticles = useCallback(\n (query: string, filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(query.trim(), filters);\n },\n [updateKbSearch]\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 emitSupportKbArticleRated(eventBus, articleId, helpful);\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', {\n articleId,\n });\n } catch (error) {\n console.error('Failed to record view:', error);\n }\n },\n [eventBus, recordViewMutation]\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,\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: asRefetch(refetchArticles),\n refetchArticle: asRefetch(refetchArticle),\n setSelectedArticle,\n\n // CRUD Operations\n createArticle,\n updateArticle,\n deleteArticle,\n publishArticle,\n unpublishArticle,\n archiveArticle,\n };\n}\n"],"mappings":";;;;;;;;AAyCA,SAAgBA,EACd,GACA,IAA6C,CAAC,GAC9C;CACA,IAAM,EAAE,mBAAgB,OAAUC,GAC5B,EAAE,aAAU,oBAAiB,mBAAgB,iBAAc,0BAC/DC,EAAgB,GACZC,IAAWC,EAAY,GAGvB,EACJ,MAAMC,GACN,SAASC,GACT,OAAOC,GACP,WAAWC,GACX,SAASC,MACPC,EAAoB,EACtB,WAAW;EACT,OAAO;EACP,QAAQ;EACR,QAAQ;GAGN,QAAQC,IAAgBC,EAAc,YAAY,KAAA;GAClD,YAAYC,EAAS,QAAQ,cAAc,KAAA;GAC3C,MAAMA,EAAS,QAAQ,KAAK,SAAS,IAAIA,EAAS,QAAQ,OAAO,KAAA;EACnE;CACF,EACF,CAAC,GAGK,EAAE,MAAMC,GAAa,SAASC,MAAmBC,EAA2B,EAChF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EAAE,MAAMC,GAAgB,SAASC,MAAsBC,EAA4B,EACvF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EACJ,MAAMC,GACN,SAASC,GACT,O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GACtB,SAASH,GAAO;IAEd,MADA,QAAQ,MAAM,6BAA6BA,CAAK,GAC1CA;GACR;EACF;EA8GE,sBA3G2B,GAAY,MAA2C;GAClF,IAAI;IAIF,QAAO,MAHcM,GAAsB,EACzC,WAAW;KAAE;KAAI;IAAM,EACzB,CAAC,EAAA,CACa,MAAM;GACtB,SAASN,GAAO;IAEd,MADA,QAAQ,MAAM,6BAA6BA,CAAK,GAC1CA;GACR;EACF;EAkGE,sBA/F2B,MAAe;GAC1C,IAAI;IAIF,QAAO,MAHcS,GAAsB,EACzC,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAAST,GAAO;IAEd,MADA,QAAQ,MAAM,6BAA6BA,CAAK,GAC1CA;GACR;EACF;EAsFE,uBAnF4B,MAAe;GAC3C,IAAI;IAIF,QAAO,MAHcY,GAAuB,EAC1C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASZ,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;EA0EE,yBAvE8B,MAAe;GAC7C,IAAI;IAIF,QAAO,MAHce,GAAyB,EAC5C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASf,GAAO;IAEd,MADA,QAAQ,MAAM,gCAAgCA,CAAK,GAC7CA;GACR;EACF;EA8DE,uBA3D4B,MAAe;GAC3C,IAAI;IAIF,QAAO,MAHckB,GAAuB,EAC1C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASlB,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;CAkDA;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SupportVariant } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* The opt-in variant the host app passed to the support root, if any.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useSupportVariant(): SupportVariant | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Reports whether the host app opted into the FluidGrids Navigation v2 Help &
|
|
8
|
+
* support changes (BOFF-11844). Every FluidGrids-only behaviour must be gated on
|
|
9
|
+
* this so the module is unchanged in the other apps that embed it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useIsFluidgridsVariant(): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useSupport as e } from "../providers/SupportProvider.js";
|
|
2
|
+
// src/support/hooks/useSupportVariant.ts
|
|
3
|
+
function t() {
|
|
4
|
+
return e().variant;
|
|
5
|
+
}
|
|
6
|
+
function n() {
|
|
7
|
+
return t() === "fluidgrids";
|
|
8
|
+
}
|
|
9
|
+
export { n as useIsFluidgridsVariant, t as useSupportVariant };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=useSupportVariant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSupportVariant.js","names":["useSupportVariant","useSupport","useIsFluidgridsVariant"],"sources":["../../../src/support/hooks/useSupportVariant.ts"],"sourcesContent":["import { useSupport } from '../providers/SupportProvider';\nimport type { SupportVariant } from '../types';\n\n/**\n * The opt-in variant the host app passed to the support root, if any.\n */\nexport function useSupportVariant(): SupportVariant | undefined {\n return useSupport().variant;\n}\n\n/**\n * Reports whether the host app opted into the FluidGrids Navigation v2 Help &\n * support changes (BOFF-11844). Every FluidGrids-only behaviour must be gated on\n * this so the module is unchanged in the other apps that embed it.\n */\nexport function useIsFluidgridsVariant(): boolean {\n return useSupportVariant() === 'fluidgrids';\n}\n"],"mappings":";;AAMA,SAAgBA,IAAgD;CAC9D,OAAOC,EAAW,CAAC,CAAC;AACtB;AAOA,SAAgBC,IAAkC;CAChD,OAAOF,EAAkB,MAAM;AACjC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UseNotificationApi } from './useNotification';
|
|
2
|
+
/**
|
|
3
|
+
* Shows the "request sent" toast on the request page that "Ask for help" opens
|
|
4
|
+
* right after creating it, so the form does not have to wait on screen.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `useAttachmentsFailedToast`: it reads a code-only query flag, shows
|
|
7
|
+
* a message composed here, and removes the flag with `replace: true` so going
|
|
8
|
+
* back does not show the toast again.
|
|
9
|
+
*
|
|
10
|
+
* The effect reads and then rewrites the search params, so it runs again after
|
|
11
|
+
* its own update. A ref records that the current flag was already handled, so
|
|
12
|
+
* the toast fires once per flag even if `notify` or `message` change identity
|
|
13
|
+
* before the router drops the param. The ref resets once the flag is gone, so
|
|
14
|
+
* a later request opened with the flag toasts again.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useTicketCreatedToast(notify: UseNotificationApi['notify'], message: string): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TICKET_CREATED_PARAM as e } from "../constants.js";
|
|
2
|
+
import { useEffect as t, useRef as n } from "react";
|
|
3
|
+
import { useSearchParams as r } from "react-router";
|
|
4
|
+
// src/support/hooks/useTicketCreatedToast.ts
|
|
5
|
+
function i(i, a) {
|
|
6
|
+
let [o, s] = r(), c = n(!1);
|
|
7
|
+
t(() => {
|
|
8
|
+
if (!o.has("created")) {
|
|
9
|
+
c.current = !1;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (c.current) return;
|
|
13
|
+
c.current = !0, i("success", a);
|
|
14
|
+
let t = new URLSearchParams(o);
|
|
15
|
+
t.delete(e), s(t, { replace: !0 });
|
|
16
|
+
}, [
|
|
17
|
+
a,
|
|
18
|
+
i,
|
|
19
|
+
o,
|
|
20
|
+
s
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
export { i as useTicketCreatedToast };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=useTicketCreatedToast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTicketCreatedToast.js","names":["useTicketCreatedToast","searchParams","setSearchParams","useSearchParams","handledRef","useRef","notify","message","nextParams","TICKET_CREATED_PARAM"],"sources":["../../../src/support/hooks/useTicketCreatedToast.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useSearchParams } from 'react-router';\n\nimport { TICKET_CREATED_PARAM } from '../constants';\nimport type { UseNotificationApi } from './useNotification';\n\n/**\n * Shows the \"request sent\" toast on the request page that \"Ask for help\" opens\n * right after creating it, so the form does not have to wait on screen.\n *\n * Mirrors `useAttachmentsFailedToast`: it reads a code-only query flag, shows\n * a message composed here, and removes the flag with `replace: true` so going\n * back does not show the toast again.\n *\n * The effect reads and then rewrites the search params, so it runs again after\n * its own update. A ref records that the current flag was already handled, so\n * the toast fires once per flag even if `notify` or `message` change identity\n * before the router drops the param. The ref resets once the flag is gone, so\n * a later request opened with the flag toasts again.\n */\nexport function useTicketCreatedToast(notify: UseNotificationApi['notify'], message: string): void {\n const [searchParams, setSearchParams] = useSearchParams();\n const handledRef = useRef(false);\n\n useEffect(() => {\n if (!searchParams.has(TICKET_CREATED_PARAM)) {\n handledRef.current = false;\n return;\n }\n if (handledRef.current) {\n return;\n }\n handledRef.current = true;\n\n notify('success', message);\n\n const nextParams = new URLSearchParams(searchParams);\n nextParams.delete(TICKET_CREATED_PARAM);\n setSearchParams(nextParams, { replace: true });\n }, [message, notify, searchParams, setSearchParams]);\n}\n"],"mappings":";;;;AAoBA,SAAgBA,EAAsB,GAAsC,GAAuB;CACjG,IAAM,CAACC,GAAcC,KAAmBC,EAAgB,GAClDC,IAAaC,EAAO,EAAK;CAE/B,QAAgB;EACd,IAAI,CAACJ,EAAa,IAAA,SAAwB,GAAG;GAC3C,EAAW,UAAU;GACrB;EACF;EACA,IAAIG,EAAW,SACb;EAIF,AAFA,EAAW,UAAU,IAErBE,EAAO,WAAWC,CAAO;EAEzB,IAAMC,IAAa,IAAI,gBAAgBP,CAAY;EAEnD,AADAO,EAAW,OAAOC,CAAoB,GACtCP,EAAgBM,GAAY,EAAE,SAAS,GAAK,CAAC;CAC/C,GAAG;EAACD;EAASD;EAAQL;EAAcC;CAAe,CAAC;AACrD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SupportTicket, SupportTicketCategory, SupportTicketPriority, SupportTicketStatus } from '../../generated/global-types';
|
|
2
|
+
import { TicketStatusGroup } from '../utils/ticketStatusGroups';
|
|
3
|
+
export interface TicketLabels {
|
|
4
|
+
status: Record<SupportTicketStatus, string>;
|
|
5
|
+
priority: Record<SupportTicketPriority, string>;
|
|
6
|
+
statusGroup: Record<TicketStatusGroup, string>;
|
|
7
|
+
/** Labels for the legacy `category` enum that older requests still carry. */
|
|
8
|
+
legacyCategory: Record<SupportTicketCategory, string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The category name to show for a request: the configured category when it
|
|
12
|
+
* has one, otherwise the translated legacy enum label, otherwise null.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getRequestCategoryName(ticket: Pick<SupportTicket, 'ticketCategory' | 'category'>, legacyLabels: Record<SupportTicketCategory, string>): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Translated status, priority and status-bucket labels.
|
|
17
|
+
*
|
|
18
|
+
* The status and priority words read the shared `support.shared.*` keys, so a
|
|
19
|
+
* host's translation overrides (FluidGrids' plain wording, for example) reach
|
|
20
|
+
* every list, card and header that shows them.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useTicketLabels(): TicketLabels;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useTr as e } from "./useTr.js";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
// src/support/hooks/useTicketLabels.ts
|
|
4
|
+
function n(e, t) {
|
|
5
|
+
return e.ticketCategory?.name ? e.ticketCategory.name : e.category ? t[e.category] ?? null : null;
|
|
6
|
+
}
|
|
7
|
+
function r() {
|
|
8
|
+
let n = e();
|
|
9
|
+
return t(() => ({
|
|
10
|
+
status: {
|
|
11
|
+
NEW: n("support.shared.status.new", "New"),
|
|
12
|
+
IN_PROGRESS: n("support.shared.status.inProgress", "In Progress"),
|
|
13
|
+
WAITING_CUSTOMER: n("support.shared.status.waitingCustomer", "Waiting on Customer"),
|
|
14
|
+
RESOLVED: n("support.shared.status.resolved", "Resolved"),
|
|
15
|
+
CLOSED: n("support.shared.status.closed", "Closed"),
|
|
16
|
+
REOPENED: n("support.shared.status.reopened", "Reopened")
|
|
17
|
+
},
|
|
18
|
+
priority: {
|
|
19
|
+
CRITICAL: n("support.shared.priority.critical", "Critical"),
|
|
20
|
+
HIGH: n("support.shared.priority.high", "High"),
|
|
21
|
+
NORMAL: n("support.shared.priority.normal", "Normal"),
|
|
22
|
+
LOW: n("support.shared.priority.low", "Low")
|
|
23
|
+
},
|
|
24
|
+
statusGroup: {
|
|
25
|
+
open: n("support.shared.statusGroup.open", "Open"),
|
|
26
|
+
waiting: n("support.shared.statusGroup.waiting", "Waiting for you"),
|
|
27
|
+
closed: n("support.shared.statusGroup.closed", "Closed")
|
|
28
|
+
},
|
|
29
|
+
legacyCategory: {
|
|
30
|
+
BILLING_ACCOUNT: n("support.shared.category.billingAccount", "Billing & Account"),
|
|
31
|
+
BUG_REPORT: n("support.shared.category.bugReport", "Bug Report"),
|
|
32
|
+
FEATURE_REQUEST: n("support.shared.category.featureRequest", "Feature Request"),
|
|
33
|
+
GENERAL_SUPPORT: n("support.shared.category.generalSupport", "General Support"),
|
|
34
|
+
TECHNICAL_SUPPORT: n("support.shared.category.technicalSupport", "Technical Support")
|
|
35
|
+
}
|
|
36
|
+
}), [n]);
|
|
37
|
+
}
|
|
38
|
+
export { n as getRequestCategoryName, r as useTicketLabels };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=useTicketLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTicketLabels.js","names":["getRequestCategoryName","ticket","legacyLabels","useTicketLabels","tr","useTr","useMemo"],"sources":["../../../src/support/hooks/useTicketLabels.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type {\n SupportTicket,\n SupportTicketCategory,\n SupportTicketPriority,\n SupportTicketStatus,\n} from '../../generated/global-types';\nimport type { TicketStatusGroup } from '../utils/ticketStatusGroups';\nimport { useTr } from './useTr';\n\nexport interface TicketLabels {\n status: Record<SupportTicketStatus, string>;\n priority: Record<SupportTicketPriority, string>;\n statusGroup: Record<TicketStatusGroup, string>;\n /** Labels for the legacy `category` enum that older requests still carry. */\n legacyCategory: Record<SupportTicketCategory, string>;\n}\n\n/**\n * The category name to show for a request: the configured category when it\n * has one, otherwise the translated legacy enum label, otherwise null.\n */\nexport function getRequestCategoryName(\n ticket: Pick<SupportTicket, 'ticketCategory' | 'category'>,\n legacyLabels: Record<SupportTicketCategory, string>\n): string | null {\n if (ticket.ticketCategory?.name) return ticket.ticketCategory.name;\n return ticket.category ? (legacyLabels[ticket.category] ?? null) : null;\n}\n\n/**\n * Translated status, priority and status-bucket labels.\n *\n * The status and priority words read the shared `support.shared.*` keys, so a\n * host's translation overrides (FluidGrids' plain wording, for example) reach\n * every list, card and header that shows them.\n */\nexport function useTicketLabels(): TicketLabels {\n const tr = useTr();\n return useMemo(\n () => ({\n status: {\n NEW: tr('support.shared.status.new', 'New'),\n IN_PROGRESS: tr('support.shared.status.inProgress', 'In Progress'),\n WAITING_CUSTOMER: tr('support.shared.status.waitingCustomer', 'Waiting on Customer'),\n RESOLVED: tr('support.shared.status.resolved', 'Resolved'),\n CLOSED: tr('support.shared.status.closed', 'Closed'),\n REOPENED: tr('support.shared.status.reopened', 'Reopened'),\n },\n priority: {\n CRITICAL: tr('support.shared.priority.critical', 'Critical'),\n HIGH: tr('support.shared.priority.high', 'High'),\n NORMAL: tr('support.shared.priority.normal', 'Normal'),\n LOW: tr('support.shared.priority.low', 'Low'),\n },\n statusGroup: {\n open: tr('support.shared.statusGroup.open', 'Open'),\n waiting: tr('support.shared.statusGroup.waiting', 'Waiting for you'),\n closed: tr('support.shared.statusGroup.closed', 'Closed'),\n },\n legacyCategory: {\n BILLING_ACCOUNT: tr('support.shared.category.billingAccount', 'Billing & Account'),\n BUG_REPORT: tr('support.shared.category.bugReport', 'Bug Report'),\n FEATURE_REQUEST: tr('support.shared.category.featureRequest', 'Feature Request'),\n GENERAL_SUPPORT: tr('support.shared.category.generalSupport', 'General Support'),\n TECHNICAL_SUPPORT: tr('support.shared.category.technicalSupport', 'Technical Support'),\n },\n }),\n [tr]\n );\n}\n"],"mappings":";;;AAsBA,SAAgBA,EACd,GACA,GACe;CAEf,OADIC,EAAO,gBAAgB,OAAaA,EAAO,eAAe,OACvDA,EAAO,WAAYC,EAAaD,EAAO,aAAa,OAAQ;AACrE;AASA,SAAgBE,IAAgC;CAC9C,IAAMC,IAAKC,EAAM;CACjB,OAAOC,SACE;EACL,QAAQ;GACN,KAAKF,EAAG,6BAA6B,KAAK;GAC1C,aAAaA,EAAG,oCAAoC,aAAa;GACjE,kBAAkBA,EAAG,yCAAyC,qBAAqB;GACnF,UAAUA,EAAG,kCAAkC,UAAU;GACzD,QAAQA,EAAG,gCAAgC,QAAQ;GACnD,UAAUA,EAAG,kCAAkC,UAAU;EAC3D;EACA,UAAU;GACR,UAAUA,EAAG,oCAAoC,UAAU;GAC3D,MAAMA,EAAG,gCAAgC,MAAM;GAC/C,QAAQA,EAAG,kCAAkC,QAAQ;GACrD,KAAKA,EAAG,+BAA+B,KAAK;EAC9C;EACA,aAAa;GACX,MAAMA,EAAG,mCAAmC,MAAM;GAClD,SAASA,EAAG,sCAAsC,iBAAiB;GACnE,QAAQA,EAAG,qCAAqC,QAAQ;EAC1D;EACA,gBAAgB;GACd,iBAAiBA,EAAG,0CAA0C,mBAAmB;GACjF,YAAYA,EAAG,qCAAqC,YAAY;GAChE,iBAAiBA,EAAG,0CAA0C,iBAAiB;GAC/E,iBAAiBA,EAAG,0CAA0C,iBAAiB;GAC/E,mBAAmBA,EAAG,4CAA4C,mBAAmB;EACvF;CACF,IACA,CAACA,CAAE,CACL;AACF"}
|
package/dist/support/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
export { SupportUserRoot } from './SupportUserRoot';
|
|
39
39
|
export { SupportAdminRoot } from './SupportAdminRoot';
|
|
40
40
|
export { SUPPORT_RYBBIT_EVENT_ALLOWLIST } from './events/rybbit';
|
|
41
|
-
export type { SupportRootProps, Ticket, SLAMetrics, ChatSession, ChatMessage, TicketFilters, AddTicketMessageInput, ViewMode, KnowledgeBaseArticleState, SupportTicketStatus, SupportTicketPriority, SLABreachStatus, } from './types';
|
|
41
|
+
export type { SupportRootProps, SupportVariant, Ticket, SLAMetrics, ChatSession, ChatMessage, TicketFilters, AddTicketMessageInput, ViewMode, KnowledgeBaseArticleState, SupportTicketStatus, SupportTicketPriority, SLABreachStatus, } from './types';
|
|
42
42
|
export { useSupport } from './providers/SupportProvider';
|
|
43
43
|
export { useTicketOperations, useChatOperations, useKnowledgeBaseOperations, useAnalyticsOperations, useSupportStore, } from './hooks';
|
|
44
44
|
export { formatTicketStatus, getPriorityColor, getPriorityIcon, formatFileSize, formatTimeAgo, formatDuration, calculateSLAStatus, truncateText, getInitials, isValidEmail, stringToColor, } from './utils';
|