Pages corrections pages missions

This commit is contained in:
alma 2026-01-16 14:38:26 +01:00
parent eee7fb06b5
commit 3e57811c11
2 changed files with 21 additions and 3 deletions

View File

@ -33,7 +33,6 @@ export async function GET(
creator: {
select: {
id: true,
name: true,
email: true
}
},
@ -45,7 +44,6 @@ export async function GET(
user: {
select: {
id: true,
name: true,
email: true
}
}

View File

@ -44,6 +44,13 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'N
useEffect(() => {
const fetchNoteContent = async () => {
if (note?.id) {
// If content is already provided (e.g., for mission files), use it directly
if (note.content !== undefined && note.content !== '') {
setContent(note.content);
setIsLoading(false);
return;
}
setIsLoading(true);
setError(null);
@ -56,6 +63,13 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'N
return;
}
// For mission files, don't try to fetch via storage API
if (note.id.startsWith('missions/')) {
console.warn('Mission file content should be provided directly, not fetched');
setIsLoading(false);
return;
}
// If cache miss, fetch from API
try {
const response = await fetch(`/api/storage/files/content?path=${encodeURIComponent(note.id)}`);
@ -98,10 +112,16 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'N
} else {
setTitle(note.title || '');
}
// Set content from note if provided, otherwise it will be fetched
if (note.content !== undefined) {
setContent(note.content);
}
if (note.id) {
fetchNoteContent();
} else {
setContent('');
if (note.content === undefined) {
setContent('');
}
}
} else {
setTitle('');