restructure: flatten workspace nesting, move devcontainer to root
- backend/workspaces/backend/ → backend/ - backend/workspaces/frontend/ → frontend/ - backend/.devcontainer/ + .vscode/ → repo root (where VS Code expects them) - loose scripts/SQL files → scripts/ - replace nested git repo with single repo at project root - update docker-compose.yml build context and devcontainer.json path - add root .gitignore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
62
frontend/src/routes/conversations/+page.server.ts
Normal file
62
frontend/src/routes/conversations/+page.server.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
export async function load({ url, fetch }) {
|
||||
|
||||
|
||||
const baseUrl = env.API_INTERNAL_URL || 'http://localhost:8080';
|
||||
|
||||
// 1. Parameter auslesen
|
||||
const senderId = url.searchParams.get('senderId') || '';
|
||||
const receiverId = url.searchParams.get('receiverId') || '';
|
||||
const from = url.searchParams.get('from') || '';
|
||||
const to = url.searchParams.get('to') || '';
|
||||
const dir = url.searchParams.get('dir') || 'DESC';
|
||||
|
||||
let documents = [];
|
||||
let senderName = '';
|
||||
let receiverName = '';
|
||||
|
||||
// 2. Fetch-Requests vorbereiten
|
||||
const requests = [];
|
||||
|
||||
// Dokumente laden (nur wenn beide IDs da sind)
|
||||
if (senderId && receiverId) {
|
||||
const query = new URLSearchParams({ senderId, receiverId, dir });
|
||||
if (from) query.set('from', from);
|
||||
if (to) query.set('to', to);
|
||||
requests.push(
|
||||
fetch(`${baseUrl}/api/documents/conversation?${query}`)
|
||||
.then(r => r.ok ? r.json() : [])
|
||||
.then(data => documents = data)
|
||||
);
|
||||
}
|
||||
|
||||
// Namen auflösen für Typeahead Initial Value
|
||||
if (senderId) {
|
||||
requests.push(
|
||||
fetch(`${baseUrl}/api/persons/${senderId}`)
|
||||
.then(r => r.ok ? r.json() : null)
|
||||
.then(p => senderName = p ? `${p.firstName} ${p.lastName}` : '')
|
||||
);
|
||||
}
|
||||
|
||||
if (receiverId) {
|
||||
requests.push(
|
||||
fetch(`${baseUrl}/api/persons/${receiverId}`)
|
||||
.then(r => r.ok ? r.json() : null)
|
||||
.then(p => receiverName = p ? `${p.firstName} ${p.lastName}` : '')
|
||||
);
|
||||
}
|
||||
|
||||
// Alles parallel abfeuern
|
||||
await Promise.all(requests);
|
||||
|
||||
return {
|
||||
documents,
|
||||
initialValues: {
|
||||
senderName,
|
||||
receiverName
|
||||
},
|
||||
filters: { senderId, receiverId, from, to, dir }
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user