From facf7ab17787f59bc7b4e9893c2ac4369add2cf0 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Fri, 4 Sep 2026 11:51:27 +0700 Subject: [PATCH] feat: enhance AttachmentPreviewDialog integration; add icon variant and improve file display in material cards --- .../components/attachment-preview-dialog.tsx | 49 +++++++++++++---- .../admin/academic-classes/materials/card.tsx | 23 +++----- .../academic-classes/materials/columns.tsx | 55 ++++++++----------- 3 files changed, 68 insertions(+), 59 deletions(-) diff --git a/resources/js/components/attachment-preview-dialog.tsx b/resources/js/components/attachment-preview-dialog.tsx index 2a27bd5..6c257af 100644 --- a/resources/js/components/attachment-preview-dialog.tsx +++ b/resources/js/components/attachment-preview-dialog.tsx @@ -1,11 +1,17 @@ -import { Paperclip } from 'lucide-react'; +import { Eye, Paperclip } from 'lucide-react'; import { useState } from 'react'; +import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from '@/components/ui/tooltip'; import { cn } from '@/lib/utils'; const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'webp']; @@ -19,12 +25,14 @@ type AttachmentPreviewDialogProps = { fileUrl: string; fileName: string; className?: string; + variant?: 'link' | 'icon'; }; export function AttachmentPreviewDialog({ fileUrl, fileName, className, + variant = 'link', }: AttachmentPreviewDialogProps) { const [open, setOpen] = useState(false); const extension = fileExtension(fileName); @@ -34,17 +42,34 @@ export function AttachmentPreviewDialog({ return ( <> - + {variant === 'icon' ? ( + + + + + Lihat + + ) : ( + + )} )} - {(canUpdate || canDelete) && ( +
+ {material.file_url && material.file_name && ( + + )} - )} +
@@ -63,18 +70,6 @@ export function createMaterialCard(params: CreateCardParams) { ? `${courseClass.course?.code ?? ''} ${courseClass.course?.name ?? ''}` : '-'}

- - {material.files.length > 0 && ( -
- {material.files.map((file) => ( - - ))} -
- )}
); }; diff --git a/resources/js/pages/admin/academic-classes/materials/columns.tsx b/resources/js/pages/admin/academic-classes/materials/columns.tsx index 6e9103b..b3240bf 100644 --- a/resources/js/pages/admin/academic-classes/materials/columns.tsx +++ b/resources/js/pages/admin/academic-classes/materials/columns.tsx @@ -64,38 +64,27 @@ export function createMaterialColumns( return `${courseClass.course?.code ?? ''} ${courseClass.course?.name ?? ''}`; }, }, - { - accessorKey: 'file_name', - header: () => File, - cell: ({ row }) => { - const material = row.original; - - if (!material.file_url || !material.file_name) { - return -; - } - - return ( - - ); - }, - }, ]; - if (canUpdate || canDelete) { - columns.push({ - id: 'actions', - header: () => Aksi, - meta: { - className: 'w-[100px] text-center', - headerClassName: 'w-[100px] text-center', - }, - cell: ({ row }) => { - const material = row.original; + columns.push({ + id: 'actions', + header: () => Aksi, + meta: { + className: 'w-[130px] text-center', + headerClassName: 'w-[130px] text-center', + }, + cell: ({ row }) => { + const material = row.original; - return ( + return ( +
+ {material.file_url && material.file_name && ( + + )} - ); - }, - }); - } +
+ ); + }, + }); return columns; }