feat: implement delete confirmation dialog component for better UX refactor: update supplier and role index pages to utilize new form dialog and delete confirm dialog components feat: add reusable form dialog component for creating and editing entities feat: introduce filter popover component for enhanced filtering options in data tables feat: create image preview button component for displaying images with modal preview feat: add page header component for consistent page layout feat: implement row actions component for handling actions on table rows feat: add status badge component for displaying entity statuses feat: create toggle status component for easily toggling entity states feat: implement draft save hook for auto-saving form data feat: add server table hook for managing server-side pagination and filtering feat: create utility functions for formatting dates and numbers feat: add constants for month names and measurement units
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { useState } from 'react';
|
|
import { ImagePreviewModal } from '@/components/image-preview-modal';
|
|
|
|
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}
|
|
/>
|
|
</>
|
|
);
|
|
}
|