From e37ff5c3d57703c01af8925e18241d552d3bc44d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:01:51 +1100 Subject: [PATCH] [UI] Enhanced null checks (#8706) (#8711) * Extra null check in SettingList.tsx * Null checks on error responses (cherry picked from commit 378d69f0b36db3a35b65857a10cf9f56f64eda85) Co-authored-by: Oliver --- src/frontend/src/components/forms/AuthenticationForm.tsx | 2 +- src/frontend/src/components/settings/SettingList.tsx | 2 +- src/frontend/src/pages/Auth/Set-Password.tsx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/components/forms/AuthenticationForm.tsx b/src/frontend/src/components/forms/AuthenticationForm.tsx index 66057b5ae3..5ae0e5f0db 100644 --- a/src/frontend/src/components/forms/AuthenticationForm.tsx +++ b/src/frontend/src/components/forms/AuthenticationForm.tsx @@ -202,7 +202,7 @@ export function RegistrationForm() { } }) .catch((err) => { - if (err.response.status === 400) { + if (err.response?.status === 400) { setIsRegistering(false); for (const [key, value] of Object.entries(err.response.data)) { registrationForm.setFieldError(key, value as string); diff --git a/src/frontend/src/components/settings/SettingList.tsx b/src/frontend/src/components/settings/SettingList.tsx index bec4f1097f..4ae79ed631 100644 --- a/src/frontend/src/components/settings/SettingList.tsx +++ b/src/frontend/src/components/settings/SettingList.tsx @@ -158,7 +158,7 @@ export function SettingList({ ); })} - {(keys || allKeys).length === 0 && ( + {(keys || allKeys)?.length === 0 && ( No settings specified diff --git a/src/frontend/src/pages/Auth/Set-Password.tsx b/src/frontend/src/pages/Auth/Set-Password.tsx index 88f9870031..31f0b4aa19 100644 --- a/src/frontend/src/pages/Auth/Set-Password.tsx +++ b/src/frontend/src/pages/Auth/Set-Password.tsx @@ -77,8 +77,8 @@ export default function Set_Password() { }) .catch((err) => { if ( - err.response.status === 400 && - err.response.data?.token == 'Invalid value' + err.response?.status === 400 && + err.response?.data?.token == 'Invalid value' ) { invalidToken(); } else {