From 84c7b46155c064eab1dbd030add4a00dee412469 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 30 Aug 2024 18:27:22 +0800 Subject: [PATCH] feat: update invitations Signed-off-by: Innei --- .../src/modules/settings/tabs/invitations.tsx | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/renderer/src/modules/settings/tabs/invitations.tsx b/src/renderer/src/modules/settings/tabs/invitations.tsx index 96b00aa3e0..5c0d4acac8 100644 --- a/src/renderer/src/modules/settings/tabs/invitations.tsx +++ b/src/renderer/src/modules/settings/tabs/invitations.tsx @@ -1,6 +1,11 @@ -import { Avatar, AvatarFallback, AvatarImage } from "@renderer/components/ui/avatar" -import { Button } from "@renderer/components/ui/button" +import { + Avatar, + AvatarFallback, + AvatarImage, +} from "@renderer/components/ui/avatar" import { CopyButton } from "@renderer/components/ui/code-highlighter" +import { RootPortal } from "@renderer/components/ui/portal" +import { useScrollViewElement } from "@renderer/components/ui/scroll-area/hooks" import { Table, TableBody, @@ -27,22 +32,33 @@ export const SettingInvitations = () => { async onError(err) { toast.error(getFetchErrorMessage(err)) }, - onSuccess() { + onSuccess(data) { Queries.invitations.list().invalidate() - toast("🎉 New invitation generated") + toast("🎉 New invitation generated, invite code is copied") + navigator.clipboard.writeText(data.data) }, }) const presentUserProfile = usePresentUserProfileModal("drawer") + const scrollViewElement = useScrollViewElement() + return ( <> -
- +
+ + + - + Code @@ -55,19 +71,19 @@ export const SettingInvitations = () => { - + {invitations.data?.map((row) => ( -
+
{row.code}
- + {row.createdAt && new Date(row.createdAt).toLocaleString()} @@ -79,11 +95,14 @@ export const SettingInvitations = () => { > - {row.users?.name?.slice(0, 2)} + + {row.users?.name?.slice(0, 2)} +
- ) : "Not used"} - + ) : ( + "Not used" + )}
))}