From 8529def7485f6391699ad03fbf8f795e8a294560 Mon Sep 17 00:00:00 2001 From: RaymondVerhoef Date: Tue, 19 May 2026 12:00:14 +0200 Subject: [PATCH] feat: add UploadZone component and database utility for file processing --- src/components/admin/UploadZone.jsx | 2 +- src/lib/db.js | 32 ++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/admin/UploadZone.jsx b/src/components/admin/UploadZone.jsx index ac4519e..aa75b10 100644 --- a/src/components/admin/UploadZone.jsx +++ b/src/components/admin/UploadZone.jsx @@ -70,7 +70,7 @@ const UploadZone = ({ onUploadComplete }) => {

Drag files here

Supports .txt and .md (max 5MB)

pb.collection('topics').delete(r.id, { requestKey: null }))); - return Promise.all(topics.map(t => pb.collection('topics').create({ - id: t.id, - label: t.label, - type: t.type, - description: t.description, - learning_relevance: t.learning_relevance || 'standard', - }, { requestKey: null }))); + for (const r of existing) { + await pb.collection('topics').delete(r.id, { requestKey: null }); + } + for (const t of topics) { + await pb.collection('topics').create({ + id: t.id, + label: t.label, + type: t.type, + description: t.description, + learning_relevance: t.learning_relevance || 'standard', + }, { requestKey: null }); + } } export async function upsertTopic(topic) { try { 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 { - 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) { const existing = await pb.collection('relations').getFullList({ fields: 'id' }); - await Promise.all(existing.map(r => pb.collection('relations').delete(r.id, { requestKey: null }))); - return Promise.all(relations.map(r => pb.collection('relations').create(r, { requestKey: null }))); + for (const r of existing) { + 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) {