missions s3
This commit is contained in:
parent
cf7538225e
commit
46ed11bd32
@ -2,6 +2,7 @@ import { NextResponse } from 'next/server';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { authOptions } from "@/app/api/auth/options";
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import { getPublicUrl } from '@/lib/s3';
|
||||
|
||||
// Helper function to check authentication
|
||||
async function checkAuth(request: Request) {
|
||||
@ -82,8 +83,14 @@ export async function GET(request: Request) {
|
||||
// Get total count
|
||||
const totalCount = await prisma.mission.count({ where });
|
||||
|
||||
// Transform logo paths to public URLs
|
||||
const missionsWithPublicUrls = missions.map(mission => ({
|
||||
...mission,
|
||||
logo: mission.logo ? getPublicUrl(mission.logo) : null
|
||||
}));
|
||||
|
||||
return NextResponse.json({
|
||||
missions,
|
||||
missions: missionsWithPublicUrls,
|
||||
pagination: {
|
||||
total: totalCount,
|
||||
offset,
|
||||
|
||||
@ -199,12 +199,12 @@ export default function MissionsPage() {
|
||||
<div className="flex-shrink-0 mr-4 w-16 h-16 relative">
|
||||
{mission.logo ? (
|
||||
<img
|
||||
src={mission.logo ? getPublicUrl(mission.logo) : ''}
|
||||
src={mission.logo || ''}
|
||||
alt={mission.name}
|
||||
className="w-full h-full object-cover rounded-md border border-gray-200"
|
||||
onError={(e) => {
|
||||
console.log("Logo failed to load:", mission.logo);
|
||||
console.log("Full URL attempted:", mission.logo ? getPublicUrl(mission.logo) : 'undefined logo');
|
||||
console.log("Full URL attempted:", mission.logo);
|
||||
// If the image fails to load, show the fallback
|
||||
(e.currentTarget as HTMLImageElement).style.display = 'none';
|
||||
// Show the fallback div
|
||||
|
||||
Loading…
Reference in New Issue
Block a user