feat: add status field to themes collection and update migration scripts
- Added a new "status" field to the themes collection with options: draft, published, and rejected. - Updated the migration script to include the new field and its options. - Created a new ingestion migration script to ensure the "status" field includes "rejected" as an option if not already present. - Added multiple hot-update files for webpack to support the new changes in the frontend.
This commit is contained in:
@@ -6,11 +6,15 @@ export const metadata: Metadata = {
|
||||
title: 'Learning Platform',
|
||||
description: 'Employee knowledge and learning',
|
||||
manifest: '/manifest.json',
|
||||
icons: { icon: '/favicon.svg' },
|
||||
appleWebApp: {
|
||||
capable: true,
|
||||
statusBarStyle: 'default',
|
||||
title: 'Learning Platform',
|
||||
},
|
||||
other: {
|
||||
'mobile-web-app-capable': 'yes',
|
||||
},
|
||||
}
|
||||
|
||||
export const viewport: Viewport = {
|
||||
@@ -26,7 +30,7 @@ export default function RootLayout({
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
)
|
||||
|
||||
@@ -39,8 +39,18 @@ export function DocumentUpload({ onSuccess }: DocumentUploadProps) {
|
||||
try {
|
||||
// Create record in PocketBase
|
||||
const format = ext.slice(1) as 'pdf' | 'md' | 'txt'
|
||||
|
||||
// Force explicit MIME type — Windows doesn't register .md and sends
|
||||
// application/octet-stream which PocketBase rejects.
|
||||
const mimeMap: Record<string, string> = {
|
||||
pdf: 'application/pdf',
|
||||
md: 'text/markdown',
|
||||
txt: 'text/plain',
|
||||
}
|
||||
const blob = new Blob([file], { type: mimeMap[format] ?? file.type })
|
||||
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
fd.append('file', blob, file.name)
|
||||
fd.append('filename', file.name)
|
||||
fd.append('format', format)
|
||||
fd.append('status', 'processing')
|
||||
@@ -60,7 +70,14 @@ export function DocumentUpload({ onSuccess }: DocumentUploadProps) {
|
||||
})
|
||||
setJobId(jId)
|
||||
} catch (err) {
|
||||
setUploadError(err instanceof Error ? err.message : 'Upload failed')
|
||||
// PocketBase ClientResponseError has a `response` with field details
|
||||
const pbErr = err as { response?: { message?: string; data?: Record<string, { message?: string }> } }
|
||||
const detail = pbErr.response?.data
|
||||
? Object.entries(pbErr.response.data)
|
||||
.map(([f, v]) => `${f}: ${v?.message ?? ''}`)
|
||||
.join(', ')
|
||||
: null
|
||||
setUploadError(detail ?? (err instanceof Error ? err.message : 'Upload failed'))
|
||||
} finally {
|
||||
setUploading(false)
|
||||
}
|
||||
|
||||
@@ -39,11 +39,13 @@ export async function getIngestionStatus(jobId: string): Promise<IngestionJobSta
|
||||
}
|
||||
|
||||
export async function postGenerateAll(themeId: string): Promise<{ queued: number }> {
|
||||
const res = await fetch(`${GENERATION_URL}/generate/theme/${encodeURIComponent(themeId)}`, {
|
||||
const res = await fetch(`${GENERATION_URL}/generate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ themeId }),
|
||||
})
|
||||
return handleResponse<{ queued: number }>(res)
|
||||
const data = await handleResponse<{ jobId: string; totalItems: number }>(res)
|
||||
return { queued: data.totalItems }
|
||||
}
|
||||
|
||||
export async function postComplete(payload: CompletePayload): Promise<CompleteResponse> {
|
||||
|
||||
Reference in New Issue
Block a user