diff --git a/apps/dashboard/app/(app)/logs/components/log-details/components/log-meta.tsx b/apps/dashboard/app/(app)/logs/components/log-details/components/log-meta.tsx index 9fa3fc717..bc7cfd930 100644 --- a/apps/dashboard/app/(app)/logs/components/log-details/components/log-meta.tsx +++ b/apps/dashboard/app/(app)/logs/components/log-details/components/log-meta.tsx @@ -1,12 +1,36 @@ +import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; +import { toast } from "@/components/ui/toaster"; +import { Copy } from "lucide-react"; export const LogMetaSection = ({ content }: { content: string }) => { + const handleClick = () => { + navigator.clipboard + .writeText(content) + .then(() => { + toast.success("Meta copied to clipboard"); + }) + .catch((error) => { + console.error("Failed to copy to clipboard:", error); + toast.error("Failed to copy to clipboard"); + }); + }; + return (
Meta
- +
{content}
+
diff --git a/apps/dashboard/app/(app)/logs/components/log-details/components/log-section.tsx b/apps/dashboard/app/(app)/logs/components/log-details/components/log-section.tsx index 6729ca914..2d956ed26 100644 --- a/apps/dashboard/app/(app)/logs/components/log-details/components/log-section.tsx +++ b/apps/dashboard/app/(app)/logs/components/log-details/components/log-section.tsx @@ -1,4 +1,7 @@ +import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; +import { toast } from "@/components/ui/toaster"; +import { Copy } from "lucide-react"; export const LogSection = ({ details, @@ -7,11 +10,25 @@ export const LogSection = ({ details: string | string[]; title: string; }) => { + const handleClick = () => { + navigator.clipboard + .writeText(getFormattedContent(details)) + .then(() => { + toast.success(`${title} copied to clipboard`); + }) + .catch((error) => { + console.error("Failed to copy to clipboard:", error); + toast.error("Failed to copy to clipboard"); + }); + }; + return (
- {title} +
+ {title} +
- +
             {Array.isArray(details)
               ? details.map((header) => {
@@ -19,7 +36,7 @@ export const LogSection = ({
                   const value = valueParts.join(":").trim();
                   return (
                     
-                      {key}
+                      {key}
                       : {value}
                       {"\n"}
                     
@@ -27,8 +44,30 @@ export const LogSection = ({
                 })
               : details}
           
+
); }; + +const getFormattedContent = (details: string | string[]) => { + if (Array.isArray(details)) { + return details + .map((header) => { + const [key, ...valueParts] = header.split(":"); + const value = valueParts.join(":").trim(); + return `${key}: ${value}`; + }) + .join("\n"); + } + return details; +};