From ea7d688f7cce0465328baa9bf940faa99a8b1f03 Mon Sep 17 00:00:00 2001 From: kenilkb Date: Wed, 15 Jul 2026 18:23:19 +0530 Subject: [PATCH] Refactor: Add Open in New Tab for PDFs/Docs, upgrade details modal to 2-column lg, and enhance document cover thumbnails --- .../features/assets/components/AssetCard.tsx | 123 ++++++------ .../assets/components/AssetDetailsModal.tsx | 176 +++++++++--------- .../assets/components/AssetViewerModal.tsx | 24 +++ 3 files changed, 178 insertions(+), 145 deletions(-) diff --git a/Channel-Frontend/src/features/assets/components/AssetCard.tsx b/Channel-Frontend/src/features/assets/components/AssetCard.tsx index ce186b3..758ed36 100644 --- a/Channel-Frontend/src/features/assets/components/AssetCard.tsx +++ b/Channel-Frontend/src/features/assets/components/AssetCard.tsx @@ -1,9 +1,7 @@ import React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { - Globe, FileText, - Image as ImageIcon, File, Eye, MoreVertical, @@ -14,8 +12,7 @@ import { ExternalLink, Download, Clock, - AlertCircle, - BookOpen + AlertCircle } from 'lucide-react'; import type { Asset } from '../../../types/assets'; import type { User } from '../../../types/auth'; @@ -69,13 +66,7 @@ export const AssetCard: React.FC = ({ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; }; - const getAssetIcon = (type: string) => { - if (type === 'case_study') return BookOpen; - if (type === 'url') return Globe; - if (type.includes('pdf')) return FileText; - if (type.includes('image') || type.includes('png') || type.includes('jpg')) return ImageIcon; - return File; - }; + const isRenderable = (type: string, url: string) => { const isOffice = type.includes('word') || type.includes('presentation') || type.includes('sheet') || @@ -104,7 +95,7 @@ export const AssetCard: React.FC = ({ return resolvedUrl; }; - const Icon = getAssetIcon(asset.type); + const isImage = asset.type.includes('image') || asset.type.includes('png') || asset.type.includes('jpg') || asset.url.match(/\.(png|jpe?g|gif|svg|webp)$/i); const isPdf = asset.type.includes('pdf') || asset.url.toLowerCase().endsWith('.pdf'); @@ -112,8 +103,8 @@ export const AssetCard: React.FC = ({ const isPresentation = asset.type.includes('presentation') || asset.url.toLowerCase().endsWith('.pptx') || asset.url.toLowerCase().endsWith('.ppt'); const isSpreadsheet = asset.type.includes('sheet') || asset.url.toLowerCase().endsWith('.xlsx') || asset.url.toLowerCase().endsWith('.xls') || asset.url.toLowerCase().endsWith('.csv'); - const hasBanner = isImage || (asset.type === 'case_study' && !!asset.thumbnailUrl); - const bannerSrc = (asset.type === 'case_study' && asset.thumbnailUrl) ? asset.thumbnailUrl : asset.url; + const hasBanner = isImage || !!asset.thumbnailUrl; + const bannerSrc = asset.thumbnailUrl ? asset.thumbnailUrl : asset.url; return ( = ({ /> ) : null} - {/* Fallbacks / simulated thumbnails */}
{isPdf ? ( -
-
-
- PDF +
+
+
+ PDF Document
-
-
+
+
-
+
+
+
-
- PDF - +
+ PDF RESOURCE +
) : isPresentation ? ( -
-
-
-
+
+
+
+
-
+
+
-
- SLIDE - PPTX +
+ PRESENTATION + PPTX
) : isWord ? ( -
-
-
- DOC +
+
+
+ Word Doc
-
+
+
-
+
-
- WORD - +
+ DOCX RESOURCE +
) : isSpreadsheet ? ( -
-
-
-
-
-
-
-
-
+
+
+
+ Spreadsheet
-
- SHEET - XLSX +
+
+
+
+
+
+
+
+
+ XLSX SHEET + EXCEL
) : ( -
-
- -
- {asset.type === 'case_study' ? 'CASE STUDY' : asset.type === 'url' ? 'LINK' : 'FILE'} +
+
+
+ Resource File +
+
+ +
+
+ BINARY + {asset.type.split('/').pop() || 'FILE'}
diff --git a/Channel-Frontend/src/features/assets/components/AssetDetailsModal.tsx b/Channel-Frontend/src/features/assets/components/AssetDetailsModal.tsx index 3fb6ebd..74004df 100644 --- a/Channel-Frontend/src/features/assets/components/AssetDetailsModal.tsx +++ b/Channel-Frontend/src/features/assets/components/AssetDetailsModal.tsx @@ -30,7 +30,7 @@ export const AssetDetailsModal: React.FC = ({ isOpen={isOpen && !!asset} onClose={onClose} title="Asset Details" - size="md" + size="2xl" footer={ + {asset && (user?.role === 'ADMIN' || asset.isDownloadable || asset.downloadRequests?.[0]?.status === 'APPROVED') && ( + + )} + {asset && asset.type !== 'url' && (user?.role === 'ADMIN' || asset.isDownloadable || asset.downloadRequests?.[0]?.status === 'APPROVED') && (