mirror of
https://github.com/BramSuurdje/proxmox-helper-scripts.git
synced 2026-10-03 04:22:34 -04:00
refactor: Update utils.tsx to include handleCopy function and dependencies
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
30
src/lib/utils.tsx
Normal file
30
src/lib/utils.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { toast } from "sonner";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { ClipboardCheck } from "lucide-react";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
export const handleCopy = (type: string, value: any) => {
|
||||
navigator.clipboard.writeText(value);
|
||||
|
||||
let warning = localStorage.getItem("warning");
|
||||
|
||||
if (warning === null) {
|
||||
localStorage.setItem("warning", "1");
|
||||
setTimeout(() => {
|
||||
toast.error(
|
||||
"be careful when copying scripts from the internet. Always remember check the source!",
|
||||
{ duration: 8000 },
|
||||
);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
toast.success(
|
||||
`copied ${type} to clipboard`, {
|
||||
icon: <ClipboardCheck className="h-4 w-4" />,
|
||||
}
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user