From 36638b3a9d5a9b8c0da95ce606082a3337c9aa03 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Wed, 11 Dec 2024 20:46:33 -0500 Subject: [PATCH] Add show/hide functionality for API token --- src/views/Settings/APITokenSettings.jsx | 63 +++++++++++++++++++------ 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/src/views/Settings/APITokenSettings.jsx b/src/views/Settings/APITokenSettings.jsx index 6262906..b896688 100644 --- a/src/views/Settings/APITokenSettings.jsx +++ b/src/views/Settings/APITokenSettings.jsx @@ -1,4 +1,14 @@ -import { Box, Button, Card, Chip, Divider, Typography } from '@mui/joy' +import { CopyAll } from '@mui/icons-material' +import { + Box, + Button, + Card, + Chip, + Divider, + IconButton, + Input, + Typography, +} from '@mui/joy' import moment from 'moment' import { useContext, useEffect, useState } from 'react' import { UserContext } from '../../contexts/UserContext' @@ -13,6 +23,7 @@ import TextModal from '../Modals/Inputs/TextModal' const APITokenSettings = () => { const [tokens, setTokens] = useState([]) const [isGetTokenNameModalOpen, setIsGetTokenNameModalOpen] = useState(false) + const [showTokenId, setShowTokenId] = useState(null) const { userProfile, setUserProfile } = useContext(UserContext) useEffect(() => { GetLongLiveTokens().then(resp => { @@ -61,19 +72,21 @@ const APITokenSettings = () => { - {token.token && ( - - )} + + {showTokenId === token?.id && ( + + { + navigator.clipboard.writeText(token.token) + alert('Token copied to clipboard') + setShowTokenId(null) + }} + > + + + } + /> + + )} ))}