import React from 'react'; import type { Asset } from '../../../types/assets'; import Modal from '../../../components/ui/Modal'; import Button from '../../../components/ui/Button'; interface AssetDetailsModalProps { isOpen: boolean; onClose: () => void; asset: Asset | null; userRole: string | undefined; } export const AssetDetailsModal: React.FC = ({ isOpen, onClose, asset, userRole }) => { const formatBytes = (bytes: number, decimals = 2) => { if (bytes === 0) return '0 Bytes'; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; }; return ( Close } > {asset && (

Title

{asset.title}

{asset.description && (

Description

{asset.description}

)} {asset.type === 'case_study' && asset.thumbnailUrl && (

Banner Image

Case Study Banner
)} {asset.type === 'case_study' && asset.problemStatement && (

Problem / Challenge

{asset.problemStatement}

)} {asset.type === 'case_study' && asset.solution && (

Suggested Solution

{asset.solution}

)}

Category

{asset.categoryId || 'General'}

Subcategory

{asset.subcategory || '-'}

File Size

{asset.type === 'url' ? 'N/A' : formatBytes(asset.size)}

File Type

{asset.type}

{asset.tags.length > 0 && (

Tags

{asset.tags.map(tag => ( {tag} ))}
)} {userRole === 'ADMIN' && asset.sharedWith && (

Shared With

{asset.sharedWith.length === 0 ? ( Not shared with any organization ) : ( asset.sharedWith.map(sw => ( {sw.organization?.name || 'Unknown Organization'} {sw.user ? `(${sw.user.email})` : '(Entire Org)'} )) )}
)}
)}
); };