feat: add new component download icon button

This commit is contained in:
Pablo Lara
2025-05-06 11:57:18 +02:00
parent e9c96b0b11
commit d33703b437
3 changed files with 40 additions and 17 deletions
@@ -2,16 +2,13 @@
import { Tooltip } from "@nextui-org/react";
import { ColumnDef } from "@tanstack/react-table";
import { DownloadIcon } from "lucide-react";
import { useSearchParams } from "next/navigation";
import { InfoIcon } from "@/components/icons";
import { toast } from "@/components/ui";
import { CustomButton } from "@/components/ui/custom";
import { DownloadIconButton, toast } from "@/components/ui";
import { DateWithTime, EntityInfoShort } from "@/components/ui/entities";
import { TriggerSheet } from "@/components/ui/sheet";
import { DataTableColumnHeader, StatusBadge } from "@/components/ui/table";
import { downloadScanZip } from "@/lib/helper";
import { ScanProps } from "@/types";
import { LinkToFindingsFromScan } from "../../link-to-findings-from-scan";
@@ -136,19 +133,10 @@ export const ColumnGetScans: ColumnDef<ScanProps>[] = [
const scanState = row.original.attributes?.state;
return (
<div className="flex w-14 items-center justify-center">
<CustomButton
variant="ghost"
isDisabled={scanState !== "completed"}
onPress={() => downloadScanZip(scanId, toast)}
className="p-0 text-default-500 hover:text-primary disabled:opacity-30"
isIconOnly
ariaLabel="Download .zip"
size="sm"
>
<DownloadIcon size={16} />
</CustomButton>
</div>
<DownloadIconButton
paramId={scanId}
isDisabled={scanState !== "completed"}
/>
);
},
},
@@ -0,0 +1,34 @@
"use client";
import { downloadScanZip } from "@/lib/helper";
import { CustomButton } from "../custom/custom-button";
import { toast } from "@/components/ui";
import { DownloadIcon } from "lucide-react";
interface DownloadIconButtonProps {
paramId: string;
ariaLabel?: string;
isDisabled?: boolean;
}
export const DownloadIconButton = ({
paramId,
ariaLabel = "Download report",
isDisabled = false,
}: DownloadIconButtonProps) => {
return (
<div className="flex w-14 items-center justify-center">
<CustomButton
variant="ghost"
isDisabled={isDisabled}
onPress={() => downloadScanZip(paramId, toast)}
className="p-0 text-default-500 hover:text-primary disabled:opacity-30"
isIconOnly
ariaLabel={ariaLabel}
size="sm"
>
<DownloadIcon size={16} />
</CustomButton>
</div>
);
};
+1
View File
@@ -11,3 +11,4 @@ export * from "./main-layout/main-layout";
export * from "./select/Select";
export * from "./sidebar";
export * from "./toast";
export * from "./download-icon-button/download-icon-button";