Pages corrections pages missions

This commit is contained in:
alma 2026-01-16 14:42:12 +01:00
parent 3e57811c11
commit e7c6623fb3

View File

@ -724,6 +724,26 @@ export default function CarnetPage() {
const handleMissionFileSelect = async (file: { key: string; name: string; path: string }) => {
if (!selectedMission) return;
// Check file extension to determine if it's a text file
const fileName = file.name.toLowerCase();
const textExtensions = ['.md', '.txt', '.json', '.yaml', '.yml', '.csv', '.log', '.conf', '.config', '.ini', '.env'];
const isTextFile = textExtensions.some(ext => fileName.endsWith(ext));
// For binary files (PDF, images, etc.), download them instead
if (!isTextFile) {
try {
// Get the file URL for download
const fileUrl = `/api/missions/image/${file.key}`;
// Open in new tab or download
window.open(fileUrl, '_blank');
return;
} catch (error) {
console.error('Error opening file:', error);
return;
}
}
// For text files, fetch and open in editor
try {
const response = await fetch(`/api/missions/${selectedMission.id}/files`, {
method: 'POST',