mission-tab deletemission
This commit is contained in:
parent
aafe4d7035
commit
96738a341f
@ -6,7 +6,7 @@ import { N8nService } from '@/lib/services/n8n-service';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { s3Client } from '@/lib/s3';
|
||||
import { CopyObjectCommand, DeleteObjectCommand, HeadObjectCommand } from '@aws-sdk/client-s3';
|
||||
import { uploadMissionLogo, uploadMissionAttachment } from '@/lib/mission-uploads';
|
||||
import { uploadMissionLogo, uploadMissionAttachment, getMissionFileUrl } from '@/lib/mission-uploads';
|
||||
|
||||
// Types
|
||||
interface MissionCreateInput {
|
||||
@ -284,6 +284,7 @@ export async function POST(request: Request) {
|
||||
|
||||
// Step 3: Upload logo to Minio if present
|
||||
let logoPath = null;
|
||||
let logoUrl = null; // Public URL for the logo
|
||||
if (body.logo?.data) {
|
||||
try {
|
||||
// Convert base64 to File object
|
||||
@ -296,13 +297,25 @@ export async function POST(request: Request) {
|
||||
logoPath = filePath;
|
||||
uploadedFiles.push({ type: 'logo', path: filePath });
|
||||
|
||||
// Generate public URL for the logo (using the API endpoint)
|
||||
// Use the helper function to construct the URL
|
||||
const relativeUrl = getMissionFileUrl(filePath);
|
||||
|
||||
// Construct full URL with base domain
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.NEXT_PUBLIC_APP_URL || 'https://hub.slm-lab.net';
|
||||
logoUrl = `${baseUrl}${relativeUrl}`;
|
||||
|
||||
// Update mission with logo path
|
||||
await prisma.mission.update({
|
||||
where: { id: mission.id },
|
||||
data: { logo: filePath }
|
||||
});
|
||||
|
||||
console.log('Logo uploaded successfully:', { logoPath });
|
||||
console.log('Logo uploaded successfully:', {
|
||||
logoPath,
|
||||
logoUrl,
|
||||
baseUrl
|
||||
});
|
||||
} catch (uploadError) {
|
||||
console.error('Error uploading logo:', uploadError);
|
||||
throw new Error('Failed to upload logo');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user