- 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.
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
import { Link } from '@inertiajs/react';
|
|
import type { ReactNode } from 'react';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from '@/components/ui/tooltip';
|
|
|
|
export type RowAction = {
|
|
label: string;
|
|
icon: ReactNode;
|
|
iconClassName?: string;
|
|
show?: boolean;
|
|
onClick?: () => void;
|
|
href?: string;
|
|
};
|
|
|
|
type RowActionsProps = {
|
|
actions: RowAction[];
|
|
wrapperClassName?: string;
|
|
};
|
|
|
|
export function RowActions({
|
|
actions,
|
|
wrapperClassName = 'flex items-center justify-center gap-1',
|
|
}: RowActionsProps) {
|
|
return (
|
|
<TooltipProvider>
|
|
<div className={wrapperClassName}>
|
|
{actions
|
|
.filter((action) => action.show !== false)
|
|
.map((action) => (
|
|
<Tooltip key={action.label}>
|
|
<TooltipTrigger asChild>
|
|
{action.href ? (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
asChild
|
|
className={action.iconClassName}
|
|
>
|
|
<Link href={action.href}>
|
|
{action.icon}
|
|
</Link>
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
onClick={action.onClick}
|
|
className={action.iconClassName}
|
|
>
|
|
{action.icon}
|
|
</Button>
|
|
)}
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top">
|
|
{action.label}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
))}
|
|
</div>
|
|
</TooltipProvider>
|
|
);
|
|
}
|