spine-framework-portal 0.2.28 → 0.2.29
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.
|
@@ -39,7 +39,7 @@ export function KBGenerator({ ticket, onGenerated, onCancel }: KBGeneratorProps)
|
|
|
39
39
|
const handleSave = async () => {
|
|
40
40
|
if (!generatedArticle) return
|
|
41
41
|
try {
|
|
42
|
-
const res = await apiFetch('
|
|
42
|
+
const res = await apiFetch('/api/admin-data', {
|
|
43
43
|
method: 'POST',
|
|
44
44
|
headers: { 'Content-Type': 'application/json' },
|
|
45
45
|
body: JSON.stringify({
|
package/hooks/useCommunity.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface CommunityPost {
|
|
|
11
11
|
design_schema?: Record<string, any>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const BASE = '
|
|
14
|
+
const BASE = '/api/admin-data?entity=items&type_slug=community_post'
|
|
15
15
|
|
|
16
16
|
async function fetchJSON(path: string, options?: RequestInit) {
|
|
17
17
|
const res = await apiFetch(path, {
|
|
@@ -58,7 +58,7 @@ export function useCreatePost() {
|
|
|
58
58
|
setLoading(true)
|
|
59
59
|
setError(null)
|
|
60
60
|
try {
|
|
61
|
-
return await fetchJSON('
|
|
61
|
+
return await fetchJSON('/api/admin-data', {
|
|
62
62
|
method: 'POST',
|
|
63
63
|
body: JSON.stringify({ entity: 'items', type_slug: 'community_post', ...fields }),
|
|
64
64
|
})
|
package/hooks/useCourses.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function useCourseLessons() {
|
|
|
34
34
|
setLoading(true)
|
|
35
35
|
setError(null)
|
|
36
36
|
try {
|
|
37
|
-
const data = await fetchJSON('
|
|
37
|
+
const data = await fetchJSON('/api/admin-data?entity=items&type_slug=course_lesson')
|
|
38
38
|
setLessons(data || [])
|
|
39
39
|
} catch (e: any) {
|
|
40
40
|
setError(e.message)
|
|
@@ -54,7 +54,7 @@ export function useCompleteLesson() {
|
|
|
54
54
|
const completeLesson = useCallback(async (lessonId: string) => {
|
|
55
55
|
setLoading(true)
|
|
56
56
|
try {
|
|
57
|
-
return await fetchJSON(
|
|
57
|
+
return await fetchJSON(`/api/admin-data?entity=items&id=${lessonId}`, {
|
|
58
58
|
method: 'PATCH',
|
|
59
59
|
body: JSON.stringify({ status: 'completed' }),
|
|
60
60
|
})
|
package/hooks/useKBArticles.ts
CHANGED
|
@@ -46,7 +46,7 @@ export function useKBArticles(search = '') {
|
|
|
46
46
|
setArticles(Array.isArray(results) ? results : [])
|
|
47
47
|
} else {
|
|
48
48
|
// No search — show all published articles
|
|
49
|
-
const data = await fetchJSON(
|
|
49
|
+
const data = await fetchJSON(`/api/admin-data?entity=items&type_slug=kb_article&status=published`)
|
|
50
50
|
const visible = (data || []).filter((a: KBArticle) => a.data?.security_level !== 'restricted')
|
|
51
51
|
setArticles(visible)
|
|
52
52
|
}
|
|
@@ -71,7 +71,7 @@ export function useKBArticle(id: string | null) {
|
|
|
71
71
|
if (!id) { setArticle(null); return }
|
|
72
72
|
setLoading(true)
|
|
73
73
|
setError(null)
|
|
74
|
-
fetchJSON(
|
|
74
|
+
fetchJSON(`/api/admin-data?entity=items&id=${id}`)
|
|
75
75
|
.then(setArticle)
|
|
76
76
|
.catch((e: any) => setError(e.message))
|
|
77
77
|
.finally(() => setLoading(false))
|
|
@@ -63,13 +63,13 @@ export function usePortalThread(targetType: string, targetId: string | null, dom
|
|
|
63
63
|
setError(null)
|
|
64
64
|
try {
|
|
65
65
|
const threads = await fetchJSON(
|
|
66
|
-
|
|
66
|
+
`/api/admin-data?entity=threads&target_type=${targetType}&target_id=${targetId}&type_slug=${threadTypeSlug}`
|
|
67
67
|
)
|
|
68
68
|
const found: PortalThread | null = Array.isArray(threads) ? (threads[0] ?? null) : null
|
|
69
69
|
setThread(found)
|
|
70
70
|
if (found?.id) {
|
|
71
71
|
const msgs = await fetchJSON(
|
|
72
|
-
|
|
72
|
+
`/api/admin-data?entity=messages&thread_id=${found.id}&sort_direction=asc`
|
|
73
73
|
)
|
|
74
74
|
setMessages(Array.isArray(msgs) ? msgs : [])
|
|
75
75
|
} else {
|
|
@@ -88,7 +88,7 @@ export function usePortalThread(targetType: string, targetId: string | null, dom
|
|
|
88
88
|
let activeThread = thread
|
|
89
89
|
|
|
90
90
|
if (!activeThread?.id) {
|
|
91
|
-
activeThread = await fetchJSON('
|
|
91
|
+
activeThread = await fetchJSON('/api/admin-data', {
|
|
92
92
|
method: 'POST',
|
|
93
93
|
body: JSON.stringify({
|
|
94
94
|
entity: 'threads',
|
|
@@ -104,7 +104,7 @@ export function usePortalThread(targetType: string, targetId: string | null, dom
|
|
|
104
104
|
// Calculate next sequence based on current messages to avoid stale state
|
|
105
105
|
const nextSequence = messages.reduce((max, m) => Math.max(max, m.sequence || 0), 0) + 1
|
|
106
106
|
|
|
107
|
-
const msg = await fetchJSON('
|
|
107
|
+
const msg = await fetchJSON('/api/admin-data', {
|
|
108
108
|
method: 'POST',
|
|
109
109
|
body: JSON.stringify({
|
|
110
110
|
entity: 'messages',
|
package/hooks/useTickets.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface Ticket {
|
|
|
11
11
|
design_schema?: Record<string, any>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const BASE = '
|
|
14
|
+
const BASE = '/api/admin-data?entity=items&type_slug=support_ticket'
|
|
15
15
|
|
|
16
16
|
async function fetchJSON(path: string, options?: RequestInit) {
|
|
17
17
|
const res = await apiFetch(path, {
|
|
@@ -59,7 +59,7 @@ export function useTicket(id: string | null) {
|
|
|
59
59
|
if (!id) return
|
|
60
60
|
setLoading(true)
|
|
61
61
|
setError(null)
|
|
62
|
-
fetchJSON(
|
|
62
|
+
fetchJSON(`/api/admin-data?entity=items&id=${id}`)
|
|
63
63
|
.then(setTicket)
|
|
64
64
|
.catch((e: any) => setError(e.message))
|
|
65
65
|
.finally(() => setLoading(false))
|
|
@@ -76,7 +76,7 @@ export function useCreateTicket() {
|
|
|
76
76
|
setLoading(true)
|
|
77
77
|
setError(null)
|
|
78
78
|
try {
|
|
79
|
-
return await fetchJSON('
|
|
79
|
+
return await fetchJSON('/api/admin-data', {
|
|
80
80
|
method: 'POST',
|
|
81
81
|
body: JSON.stringify({ entity: 'items', type_slug: 'support_ticket', ...fields }),
|
|
82
82
|
})
|
|
@@ -206,7 +206,7 @@ export function useUpdateTicket() {
|
|
|
206
206
|
const updateTicket = useCallback(async (id: string, updates: { status?: string; data?: any }) => {
|
|
207
207
|
setLoading(true)
|
|
208
208
|
try {
|
|
209
|
-
return await fetchJSON(
|
|
209
|
+
return await fetchJSON(`/api/admin-data?entity=items&id=${id}`, {
|
|
210
210
|
method: 'PATCH',
|
|
211
211
|
body: JSON.stringify(updates),
|
|
212
212
|
})
|