Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update ui for token-created-modal

Kiran K9efe8d3807f8
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx
index 0552e2b39d..829b09a344 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx
@@ -33,8 +33,7 @@ export default function TokensPageClient() {
error,
} = useSWR<TokenProps[]>(`/api/tokens?workspaceId=${workspaceId}`, fetcher);
- const limit = tokens?.length || 0;
- const { pagination, setPagination } = usePagination(limit);
+ const { pagination, setPagination } = usePagination();
const [createdToken, setCreatedToken] = useState<string | null>(null);
@@ -126,10 +125,8 @@ export default function TokensPageClient() {
cell: ({ row }) => <RowMenuButton token={row.original} />,
},
],
- ...(!limit && {
- pagination,
- onPaginationChange: setPagination,
- }),
+ pagination,
+ onPaginationChange: setPagination,
rowCount: tokens?.length || 0,
thClassName: "border-l-0",
tdClassName: "border-l-0",
@@ -179,11 +176,7 @@ export default function TokensPageClient() {
</div>
{tokens?.length !== 0 ? (
- <Table
- {...tableProps}
- table={table}
- containerClassName="border-neutral-300"
- />
+ <Table {...tableProps} table={table} />
) : (
<AnimatedEmptyState
title="No tokens found"
diff --git a/apps/web/ui/modals/token-created-modal.tsx b/apps/web/ui/modals/token-created-modal.tsx
index 85403a55b4..584434ad83 100644
--- a/apps/web/ui/modals/token-created-modal.tsx
+++ b/apps/web/ui/modals/token-created-modal.tsx
@@ -1,4 +1,4 @@
-import { Button, CopyButton, Modal } from "@dub/ui";
+import { Button, Copy, Modal, Tick, useCopyToClipboard } from "@dub/ui";
import {
Dispatch,
SetStateAction,
@@ -6,6 +6,7 @@ import {
useMemo,
useState,
} from "react";
+import { toast } from "sonner";
function TokenCreatedModal({
showTokenCreatedModal,
@@ -16,6 +17,8 @@ function TokenCreatedModal({
setShowTokenCreatedModal: Dispatch<SetStateAction<boolean>>;
token: string;
}) {
+ const [copied, copyToClipboard] = useCopyToClipboard();
+
return (
<Modal
showModal={showTokenCreatedModal}
@@ -24,7 +27,7 @@ function TokenCreatedModal({
>
<div className="space-y-2 border-b border-neutral-200 px-4 py-4 sm:px-6">
<h3 className="text-lg font-medium">API Key Created</h3>
- <p className="text-sm text-gray-500">
+ <p className="text-sm text-neutral-500">
For security reasons, we will only show you the key once. Please copy
and store it somewhere safe.
</p>
@@ -33,9 +36,25 @@ function TokenCreatedModal({
<div className="flex flex-col space-y-4 bg-neutral-50 px-4 py-8 sm:px-6">
<div className="flex flex-col gap-1">
<h2 className="text-sm font-medium text-neutral-800">API key</h2>
- <div className="flex items-center justify-between rounded-md border border-gray-300 bg-white p-3">
- <p className="font-mono text-sm text-gray-500">{token}</p>
- <CopyButton value={token} className="rounded-md" />
+ <div className="flex items-center justify-between rounded-md border border-neutral-200 bg-white p-2">
+ <p className="font-mono text-sm text-neutral-500">{token}</p>
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ toast.promise(copyToClipboard(token), {
+ success: "Copied to clipboard!",
+ });
+ }}
+ type="button"
+ className="text-neutral-90 flex h-7 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2 py-1 text-xs font-medium hover:bg-neutral-50"
+ >
+ {copied ? (
+ <Tick className="h-3.5 w-3.5" />
+ ) : (
+ <Copy className="h-3.5 w-3.5" />
+ )}
+ {copied ? "Copied" : "Copy"}
+ </button>
</div>
</div>
<Button text="Done" onClick={() => setShowTokenCreatedModal(false)} />