From 96e858f08c3b5d9401e02aa08548536518fa9c1e Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 25 Jun 2023 22:42:06 +0800 Subject: [PATCH] chore: update shortcut permission button --- web/src/components/ShortcutView.tsx | 51 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/web/src/components/ShortcutView.tsx b/web/src/components/ShortcutView.tsx index 0e0168d..1caa9c8 100644 --- a/web/src/components/ShortcutView.tsx +++ b/web/src/components/ShortcutView.tsx @@ -17,10 +17,7 @@ interface Props { const ShortcutView = (props: Props) => { const { shortcut, handleEdit } = props; const user = useAppSelector((state) => state.user.user as User); - - const havePermission = (shortcut: Shortcut) => { - return user.role === "ADMIN" || shortcut.creatorId === user.id; - }; + const havePermission = user.role === "ADMIN" || shortcut.creatorId === user.id; const handleCopyButtonClick = (shortcut: Shortcut) => { copy(absolutifyLink(`/s/${shortcut.name}`)); @@ -58,29 +55,29 @@ const ShortcutView = (props: Props) => { - - - - - } - > + {havePermission && ( + + + + + } + > + )} {shortcut.description &&

{shortcut.description}

}