feat: add UploadZone component and database utility for file processing
All checks were successful
On Push to Main / test (push) Successful in 31s
On Push to Main / publish (push) Successful in 59s
On Push to Main / deploy-dev (push) Successful in 1m35s

This commit is contained in:
RaymondVerhoef
2026-05-19 12:00:14 +02:00
parent d23b0b6b16
commit 8529def748
2 changed files with 21 additions and 13 deletions

View File

@@ -70,7 +70,7 @@ const UploadZone = ({ onUploadComplete }) => {
<p className="font-medium text-lg">Drag files here</p> <p className="font-medium text-lg">Drag files here</p>
<p className="text-sm text-fg-muted mb-4">Supports .txt and .md (max 5MB)</p> <p className="text-sm text-fg-muted mb-4">Supports .txt and .md (max 5MB)</p>
<Button variant="outline" type="button" disabled={isProcessing}> <Button variant="outline" type="button" disabled={isProcessing}>
{isProcessing && !syncProgress ? 'AI extraction in progress...' : 'Browse files'} {isProcessing ? 'AI extraction in progress...' : 'Browse files'}
</Button> </Button>
<input <input
type="file" type="file"

View File

@@ -8,22 +8,26 @@ export async function getTopics() {
export async function saveTopics(topics) { export async function saveTopics(topics) {
const existing = await pb.collection('topics').getFullList({ fields: 'id' }); const existing = await pb.collection('topics').getFullList({ fields: 'id' });
await Promise.all(existing.map(r => pb.collection('topics').delete(r.id, { requestKey: null }))); for (const r of existing) {
return Promise.all(topics.map(t => pb.collection('topics').create({ await pb.collection('topics').delete(r.id, { requestKey: null });
id: t.id, }
label: t.label, for (const t of topics) {
type: t.type, await pb.collection('topics').create({
description: t.description, id: t.id,
learning_relevance: t.learning_relevance || 'standard', label: t.label,
}, { requestKey: null }))); type: t.type,
description: t.description,
learning_relevance: t.learning_relevance || 'standard',
}, { requestKey: null });
}
} }
export async function upsertTopic(topic) { export async function upsertTopic(topic) {
try { try {
await pb.collection('topics').getOne(topic.id); await pb.collection('topics').getOne(topic.id);
return pb.collection('topics').update(topic.id, topic); return await pb.collection('topics').update(topic.id, topic);
} catch { } catch {
return pb.collection('topics').create({ id: topic.id, ...topic }); return await pb.collection('topics').create({ id: topic.id, ...topic });
} }
} }
@@ -35,8 +39,12 @@ export async function getRelations() {
export async function saveRelations(relations) { export async function saveRelations(relations) {
const existing = await pb.collection('relations').getFullList({ fields: 'id' }); const existing = await pb.collection('relations').getFullList({ fields: 'id' });
await Promise.all(existing.map(r => pb.collection('relations').delete(r.id, { requestKey: null }))); for (const r of existing) {
return Promise.all(relations.map(r => pb.collection('relations').create(r, { requestKey: null }))); await pb.collection('relations').delete(r.id, { requestKey: null });
}
for (const r of relations) {
await pb.collection('relations').create(r, { requestKey: null });
}
} }
export async function addRelation(relation) { export async function addRelation(relation) {