diff --git a/app/api/missions/[missionId]/route.ts b/app/api/missions/[missionId]/route.ts index 04adceb..800f317 100644 --- a/app/api/missions/[missionId]/route.ts +++ b/app/api/missions/[missionId]/route.ts @@ -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 } } diff --git a/components/carnet/editor.tsx b/components/carnet/editor.tsx index 157c31f..f7a2f0c 100644 --- a/components/carnet/editor.tsx +++ b/components/carnet/editor.tsx @@ -44,6 +44,13 @@ export const Editor: React.FC = ({ 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 = ({ 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 = ({ 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('');