Pages corrections
This commit is contained in:
parent
fba75ce4a6
commit
588707bd68
@ -303,13 +303,33 @@ export default function CarnetPage() {
|
|||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
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
|
// Update state
|
||||||
setNotes(data);
|
setNotes(mappedNotes);
|
||||||
|
|
||||||
// Update cache
|
// Update cache
|
||||||
notesCache.set(cacheKey, data);
|
notesCache.set(cacheKey, mappedNotes);
|
||||||
} else {
|
} else {
|
||||||
const errorData = await response.json().catch(() => ({}));
|
const errorData = await response.json().catch(() => ({}));
|
||||||
console.error('Error fetching notes:', errorData.message || response.statusText);
|
console.error('Error fetching notes:', errorData.message || response.statusText);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user