-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(page.tsx, Backtrace.tsx, ClipboardButton.tsx): add CustomTimeAgo…
… component to display occurrence creation and update time, add ClipboardButton component to copy occurrence backtrace to clipboard
- Loading branch information
1 parent
5a07370
commit 4eaf18a
Showing
3 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use client'; | ||
|
||
import { Prisma } from '@prisma/client'; | ||
import { useState } from 'react'; | ||
import { HiClipboardCopy } from 'react-icons/hi'; | ||
|
||
export default function ClipboardButton({ json }: { json: Prisma.JsonValue }) { | ||
const [isCopied, setIsCopied] = useState(false); | ||
|
||
const handleCopy = () => { | ||
navigator.clipboard.writeText(JSON.stringify(json, null, 2)); | ||
setIsCopied(true); | ||
|
||
// Reset copied status after 3 seconds | ||
setTimeout(() => { | ||
setIsCopied(false); | ||
}, 3000); | ||
}; | ||
|
||
return ( | ||
<button | ||
onClick={handleCopy} | ||
className="group flex items-center gap-x-1 rounded-lg border border-indigo-500 px-4 py-2 text-xs font-semibold text-indigo-500 shadow-sm transition-colors duration-200 hover:bg-indigo-500 hover:text-white md:gap-x-3 md:text-sm" | ||
> | ||
<HiClipboardCopy className="h-4 w-4 md:h-5 md:w-5" aria-hidden="true" /> | ||
{isCopied ? 'Copied!' : 'Copy to Clipboard'} | ||
</button> | ||
); | ||
} |