From b70d5501a2aeabca946f8c8c8320d96db9a24710 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 27 Aug 2023 19:54:59 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ApiKeysPage):=20handle=20cas?= =?UTF-8?q?es=20where=20keysList.current=20is=20null=20or=20undefined=20to?= =?UTF-8?q?=20prevent=20errors=20=E2=9C=A8=20feat(ApiKeysPage):=20add=20co?= =?UTF-8?q?nditional=20rendering=20for=20keysList.current=20to=20display?= =?UTF-8?q?=20appropriate=20messages=20when=20there=20are=20no=20keys=20as?= =?UTF-8?q?signed=20or=20when=20loading=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/pages/ApiKeysPage/index.tsx | 211 ++++++++++--------- 1 file changed, 108 insertions(+), 103 deletions(-) diff --git a/src/frontend/src/pages/ApiKeysPage/index.tsx b/src/frontend/src/pages/ApiKeysPage/index.tsx index e2e3bbebe..d4f6b616a 100644 --- a/src/frontend/src/pages/ApiKeysPage/index.tsx +++ b/src/frontend/src/pages/ApiKeysPage/index.tsx @@ -103,15 +103,18 @@ export default function ApiKeysPage() {
- {keysList.current.length === 0 && !loadingKeys && ( - <> -
-

- This user does not have any keys assigned at the moment. -

-
- - )} + {keysList.current && + keysList.current.length === 0 && + !loadingKeys && ( + <> +
+

+ This user does not have any keys assigned at the + moment. +

+
+ + )} <> {loadingKeys && (
@@ -124,103 +127,105 @@ export default function ApiKeysPage() { (loadingKeys ? " border-0" : "") } > - {keysList.current.length > 0 && !loadingKeys && ( - - - - Name - Key - Created - - Last Used - -
- -
-
-
- -
-
- {!loadingKeys && ( - - {keysList.current.map( - (api_keys: ApiKey, index: number) => ( - - - + {keysList.current && + keysList.current.length > 0 && + !loadingKeys && ( +
+ + + Name + Key + Created + + Last Used + +
+ +
+
+
+ +
+
+ {!loadingKeys && ( + + {keysList.current.map( + (api_keys: ApiKey, index: number) => ( + + + + + {api_keys.name} + + + + - {api_keys.name} + {api_keys.api_key} - - - - - {api_keys.api_key} - - - - {moment(api_keys.created_at).format( - "YYYY-MM-DD HH:mm" - )} - - - {moment(api_keys.last_used_at).format( - "YYYY-MM-DD HH:mm" - ) === "Invalid date" - ? "-" - : moment(api_keys.last_used_at).format( - "YYYY-MM-DD HH:mm" - )} - - -
- { - console.log(keys); - handleDeleteKey(keys); - }} - > - + + {moment(api_keys.created_at).format( + "YYYY-MM-DD HH:mm" + )} + + + {moment(api_keys.last_used_at).format( + "YYYY-MM-DD HH:mm" + ) === "Invalid date" + ? "-" + : moment(api_keys.last_used_at).format( + "YYYY-MM-DD HH:mm" + )} + + +
+ { + console.log(keys); + handleDeleteKey(keys); + }} > - - - -
-
- - ) - )} - - )} -
- )} + + + + +
+ + + ) + )} + + )} + + )}