Pages corrections

This commit is contained in:
alma 2026-01-16 12:02:42 +01:00
parent fba75ce4a6
commit 588707bd68

View File

@ -303,13 +303,33 @@ export default function CarnetPage() {
if (response.ok) {
const data = await response.json();
console.log(`Fetched ${data.length} notes from ${folderLowercase} folder`);
console.log(`Fetched ${data.length} files from ${folderLowercase} folder`, data);
// Map API response to Note format
// API returns: { key, name, size, lastModified }
// Frontend expects: { id, title, content, lastModified, type, mime, etag }
const mappedNotes: Note[] = data.map((file: any) => {
// Extract title from filename (remove .md extension if present)
const title = file.name?.replace(/\.md$/, '') || file.name || 'Untitled';
return {
id: file.key || file.id || '',
title: title,
content: '', // Content will be loaded when note is selected
lastModified: file.lastModified ? new Date(file.lastModified).toISOString() : new Date().toISOString(),
type: 'file',
mime: file.name?.endsWith('.md') ? 'text/markdown' : 'text/plain',
etag: file.key || '' // Use key as etag for now
};
});
console.log(`Mapped ${mappedNotes.length} notes from ${folderLowercase} folder`);
// Update state
setNotes(data);
setNotes(mappedNotes);
// Update cache
notesCache.set(cacheKey, data);
notesCache.set(cacheKey, mappedNotes);
} else {
const errorData = await response.json().catch(() => ({}));
console.error('Error fetching notes:', errorData.message || response.statusText);