dstpabuaran.com/resources/js/components/dialogs/image-preview-button.tsx
Yoga Pangestu 166419134f Refactor component imports for consistency and organization
- Updated import paths for various components to align with new directory structure.
- Changed imports from 'row-actions', 'confirm-dialog', 'image-preview-button', and 'file-upload' to their respective new locations in 'data-display', 'dialogs', and 'inputs'.
- Adjusted imports in multiple pages including purchase, restock, transaction, category, customer, product, raw-material, supplier, roles, and settings.
- Ensured all relevant components are imported from their new locations to maintain functionality.
2026-08-07 13:48:46 +07:00

47 lines
1.4 KiB
TypeScript

import { useState } from 'react';
import { ImagePreviewModal } from '@/components/dialogs';
type ImagePreviewButtonProps = {
srcs: string[];
title?: string;
alt?: string;
className?: string;
};
export function ImagePreviewButton({
srcs,
title,
alt,
className = 'h-10 w-10',
}: ImagePreviewButtonProps) {
const [open, setOpen] = useState(false);
return (
<>
<button
type="button"
onClick={() => setOpen(true)}
className={`relative block overflow-hidden rounded-md border bg-muted transition-opacity hover:opacity-80 ${className}`}
>
<img
src={srcs[0]}
alt={alt ?? title ?? 'Preview'}
className="h-full w-full object-cover"
/>
{srcs.length > 1 && (
<span className="absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground">
{srcs.length}
</span>
)}
</button>
<ImagePreviewModal
open={open}
onOpenChange={setOpen}
src={srcs[0]}
sources={srcs}
title={title}
/>
</>
);
}