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: { creator: {
select: { select: {
id: true, id: true,
name: true,
email: true email: true
} }
}, },
@ -45,7 +44,6 @@ export async function GET(
user: { user: {
select: { select: {
id: true, id: true,
name: true,
email: true email: true
} }
} }

View File

@ -44,6 +44,13 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'N
useEffect(() => { useEffect(() => {
const fetchNoteContent = async () => { const fetchNoteContent = async () => {
if (note?.id) { 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); setIsLoading(true);
setError(null); setError(null);
@ -56,6 +63,13 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'N
return; 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 // If cache miss, fetch from API
try { try {
const response = await fetch(`/api/storage/files/content?path=${encodeURIComponent(note.id)}`); 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 { } else {
setTitle(note.title || ''); setTitle(note.title || '');
} }
// Set content from note if provided, otherwise it will be fetched
if (note.content !== undefined) {
setContent(note.content);
}
if (note.id) { if (note.id) {
fetchNoteContent(); fetchNoteContent();
} else { } else {
setContent(''); if (note.content === undefined) {
setContent('');
}
} }
} else { } else {
setTitle(''); setTitle('');