Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ const CreateAccessToken = () => {
const createMutation = api.accessToken.create.useMutation({
onSuccess: ({ token }) => {
setAccessToken(token);
copy(token);
toast.success("Access token copied to clipboard.");

toast.promise(copy(token), {
loading: "copying token...",
success: "Access token copied to clipboard.",
error: "error copying token",
});
setOpen(true);
setLoading(false);
},

onError: (error) => {
Expand All @@ -33,17 +38,15 @@ const CreateAccessToken = () => {

onSettled: () => {
setLoading(false);
router.refresh();
},
});

return (
<Fragment>
<Button
onClick={(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
e.preventDefault();
onClick={async () => {
setLoading(true);
createMutation.mutate({
await createMutation.mutateAsync({
typeEnum: "api",
});
}}
Expand All @@ -67,6 +70,9 @@ const CreateAccessToken = () => {
open,
onOpenChange: (val) => {
setOpen(val);
if (!val) {
router.refresh();
}
},
}}
>
Expand All @@ -75,8 +81,11 @@ const CreateAccessToken = () => {
<Card
className="cursor-copy break-words p-3 mt-2"
onClick={() => {
copy(accessToken as string);
toast.success("Access token copied to clipboard.");
toast.promise(copy(accessToken), {
loading: "copying token...",
success: "Access token copied to clipboard.",
error: "error copying token",
});
}}
>
<code className="text-sm font-mono text-rose-600">
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function RootLayout({
<NextAuthProvider session={session}>
<TRPCReactProvider cookies={cookies().toString()}>
<main>{children}</main>
<Toaster richColors />
<Toaster closeButton richColors />
{nodeEnv === "development" && <ScreenSize />}
</TRPCReactProvider>
</NextAuthProvider>
Expand Down