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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user