From fbff6e025af36564d5e815d725e600bb3a8ec803 Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Fri, 17 May 2024 11:52:37 +0400 Subject: [PATCH 01/14] token key popup --- .../ApiTokenForm/CreateTokenField/index.tsx | 13 +++++++++-- .../TokenCreationDialogSuccess/index.tsx | 20 ++++++++++++++--- .../token-creation-dialog-sucess.module.scss | 22 ++++++++++++++++++- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/features/dashboard/components/ApiTokenForm/CreateTokenField/index.tsx b/src/features/dashboard/components/ApiTokenForm/CreateTokenField/index.tsx index ac38aef27..a4a14e59d 100644 --- a/src/features/dashboard/components/ApiTokenForm/CreateTokenField/index.tsx +++ b/src/features/dashboard/components/ApiTokenForm/CreateTokenField/index.tsx @@ -36,14 +36,18 @@ const CreateTokenField = ({ }: TCreateTokenField) => { const { tokens } = useApiToken(); const [input_value, setInputValue] = useState(''); + const [lastInputValue, setLastInputValue] = useState(''); const numberOfTokens = tokens.length; useEffect(() => { if (form_is_cleared) { + setLastInputValue(input_value); setInputValue(''); setFormIsCleared(false); } - }, [form_is_cleared]); + }, [form_is_cleared, input_value, setFormIsCleared]); + + const inputToPass = form_is_cleared ? lastInputValue : input_value; const getTokenNames = useMemo(() => { const token_names = []; for (const token_object of tokens) { @@ -87,7 +91,12 @@ const CreateTokenField = ({ {...register} placeholder='' /> - {is_toggle && } + {is_toggle && ( + + )}