diff --git a/app/admin/page.tsx b/app/admin/page.tsx index e499ccc..2d5b16f 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from 'react'; import { Card, Portal, MediaItem, CardType } from '@/types'; -import { EXTERNAL_LINK_ENABLED } from '@/lib/config'; +import { EXTERNAL_LINK_ENABLED as EXTERNAL_LINK_DEFAULT } from '@/lib/config'; function CardTypeSelect({ value, @@ -72,6 +72,13 @@ const isPdfFile = (file: File) => const isVideoFile = (file: File) => file.type.startsWith('video/') || /\.(mp4|webm|mov|m4v|ogv)$/i.test(file.name); +const extractFileName = (url: string): string => { + const match = url.match(/[?&]name=([^&]+)/); + if (match) return decodeURIComponent(match[1]); + const seg = url.split('/').pop() || 'download'; + return seg.split('?')[0]; +}; + async function uploadBlobAsImage(blob: Blob, name: string): Promise { const formData = new FormData(); formData.append('file', new File([blob], name, { type: blob.type || 'image/png' })); @@ -168,6 +175,9 @@ export default function AdminDashboard() { const [confirmDialog, setConfirmDialog] = useState<{ message: string, onConfirm: () => void } | null>(null); const [pdfProgress, setPdfProgress] = useState<{ name: string; page: number; total: number } | null>(null); + // External Link feature flag: priorità al setting del portale, fallback alla costante in lib/config. + const externalLinksOn = portal.externalLinkEnabled ?? EXTERNAL_LINK_DEFAULT; + // Helper to show auto-dismissing toast const showToast = (message: string) => { setToast(message); @@ -488,6 +498,7 @@ export default function AdminDashboard() { {portal.logoUrl && (
Logo Preview +
)} @@ -501,12 +512,13 @@ export default function AdminDashboard() { {portal.heroImageUrl && (
Hero Preview +
)} -
+
+
@@ -564,7 +588,7 @@ export default function AdminDashboard() { options={[ { value: 'INFO_PAGE', label: 'Info Page' }, { value: 'IMAGE_GALLERY', label: 'Image Gallery' }, - ...(EXTERNAL_LINK_ENABLED ? [{ value: 'EXTERNAL_LINK' as CardType, label: 'External Link' }] : []), + ...(externalLinksOn ? [{ value: 'EXTERNAL_LINK' as CardType, label: 'External Link' }] : []), ]} /> @@ -638,6 +662,13 @@ export default function AdminDashboard() { {isEditing.imageUrl && (
Cover preview +
- {/* Gallery Media (images + videos + PDFs) */} + {/* Gallery Media (images + videos + PDFs) — nascosta per INFO_PAGE (solo cover ammessa) */} + {isEditing.cardType !== 'INFO_PAGE' && (
)} +