mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 17:11:23 -05:00
Fix image URLs and add lightbox
This commit is contained in:
@@ -3,6 +3,7 @@ import { Badge } from '@/components/ui/badge';
|
|||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { Image as ImageIcon } from 'lucide-react';
|
import { Image as ImageIcon } from 'lucide-react';
|
||||||
|
import { PhotoModal } from './PhotoModal';
|
||||||
|
|
||||||
interface EntityEditPreviewProps {
|
interface EntityEditPreviewProps {
|
||||||
submissionId: string;
|
submissionId: string;
|
||||||
@@ -32,6 +33,8 @@ export const EntityEditPreview = ({ submissionId, entityType, entityName }: Enti
|
|||||||
const [changedFields, setChangedFields] = useState<string[]>([]);
|
const [changedFields, setChangedFields] = useState<string[]>([]);
|
||||||
const [bannerImageUrl, setBannerImageUrl] = useState<string | null>(null);
|
const [bannerImageUrl, setBannerImageUrl] = useState<string | null>(null);
|
||||||
const [cardImageUrl, setCardImageUrl] = useState<string | null>(null);
|
const [cardImageUrl, setCardImageUrl] = useState<string | null>(null);
|
||||||
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
|
const [selectedImageIndex, setSelectedImageIndex] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchSubmissionItems();
|
fetchSubmissionItems();
|
||||||
@@ -118,6 +121,23 @@ export const EntityEditPreview = ({ submissionId, entityType, entityName }: Enti
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build photos array for modal
|
||||||
|
const photos = [];
|
||||||
|
if (bannerImageUrl) {
|
||||||
|
photos.push({
|
||||||
|
id: 'banner',
|
||||||
|
url: `${bannerImageUrl}/public`,
|
||||||
|
caption: 'New Banner Image'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (cardImageUrl) {
|
||||||
|
photos.push({
|
||||||
|
id: 'card',
|
||||||
|
url: `${cardImageUrl}/public`,
|
||||||
|
caption: 'New Card Image'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div className="flex items-center gap-2 flex-wrap">
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
@@ -152,10 +172,13 @@ export const EntityEditPreview = ({ submissionId, entityType, entityName }: Enti
|
|||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
{bannerImageUrl && (
|
{bannerImageUrl && (
|
||||||
<Card className="overflow-hidden">
|
<Card className="overflow-hidden cursor-pointer hover:ring-2 hover:ring-primary transition-all" onClick={() => {
|
||||||
|
setSelectedImageIndex(0);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
}}>
|
||||||
<CardContent className="p-2">
|
<CardContent className="p-2">
|
||||||
<img
|
<img
|
||||||
src={`${bannerImageUrl}/thumbnail`}
|
src={`${bannerImageUrl}/public`}
|
||||||
alt="New banner"
|
alt="New banner"
|
||||||
className="w-full h-24 object-cover rounded"
|
className="w-full h-24 object-cover rounded"
|
||||||
/>
|
/>
|
||||||
@@ -166,10 +189,13 @@ export const EntityEditPreview = ({ submissionId, entityType, entityName }: Enti
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
{cardImageUrl && (
|
{cardImageUrl && (
|
||||||
<Card className="overflow-hidden">
|
<Card className="overflow-hidden cursor-pointer hover:ring-2 hover:ring-primary transition-all" onClick={() => {
|
||||||
|
setSelectedImageIndex(bannerImageUrl ? 1 : 0);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
}}>
|
||||||
<CardContent className="p-2">
|
<CardContent className="p-2">
|
||||||
<img
|
<img
|
||||||
src={`${cardImageUrl}/thumbnail`}
|
src={`${cardImageUrl}/public`}
|
||||||
alt="New card"
|
alt="New card"
|
||||||
className="w-full h-24 object-cover rounded"
|
className="w-full h-24 object-cover rounded"
|
||||||
/>
|
/>
|
||||||
@@ -186,6 +212,13 @@ export const EntityEditPreview = ({ submissionId, entityType, entityName }: Enti
|
|||||||
<div className="text-xs text-muted-foreground italic">
|
<div className="text-xs text-muted-foreground italic">
|
||||||
Click "Review Items" for full details
|
Click "Review Items" for full details
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<PhotoModal
|
||||||
|
photos={photos}
|
||||||
|
initialIndex={selectedImageIndex}
|
||||||
|
isOpen={isModalOpen}
|
||||||
|
onClose={() => setIsModalOpen(false)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user