diff --git a/web/beacon-app/src/features/auth/hooks/useRegister.ts b/web/beacon-app/src/features/auth/hooks/useRegister.ts index 19f4de246..2010ab736 100644 --- a/web/beacon-app/src/features/auth/hooks/useRegister.ts +++ b/web/beacon-app/src/features/auth/hooks/useRegister.ts @@ -17,7 +17,7 @@ export function useRegister(): RegistrationMutation { message: 'Register failed', }, }); - if (error.response.status === 409) { + if (error?.response?.status === 409) { toast.error(t`User already exists.`); } else { toast.error(error?.response?.data?.error); diff --git a/web/beacon-app/src/features/members/hooks/useFetchMember.ts b/web/beacon-app/src/features/members/hooks/useFetchMember.ts index 2e2eeaad7..c89a6dd3b 100644 --- a/web/beacon-app/src/features/members/hooks/useFetchMember.ts +++ b/web/beacon-app/src/features/members/hooks/useFetchMember.ts @@ -17,7 +17,7 @@ export function useFetchMember(memberID: string): MemberQuery { ...memberDetailQuery(memberID), onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/members/hooks/useFetchProfile.ts b/web/beacon-app/src/features/members/hooks/useFetchProfile.ts index 2303049da..b94a4f400 100644 --- a/web/beacon-app/src/features/members/hooks/useFetchProfile.ts +++ b/web/beacon-app/src/features/members/hooks/useFetchProfile.ts @@ -17,7 +17,7 @@ export function useFetchProfile(): ProfileQuery { ...profileQuery(), onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/onboarding/components/steps/organization/index.tsx b/web/beacon-app/src/features/onboarding/components/steps/organization/index.tsx index 3170bcf39..4c6f84f2b 100644 --- a/web/beacon-app/src/features/onboarding/components/steps/organization/index.tsx +++ b/web/beacon-app/src/features/onboarding/components/steps/organization/index.tsx @@ -16,7 +16,7 @@ const OrganizationStep = () => { const state = useOrgStore((state: any) => state) as any; // Display error if organization name is already taken. - const hasError = error && error.response.status === 409; + const hasError = error && error?.response?.status === 409; const isInvited = isInvitedUser(profile); const submitFormHandler = (values: any) => { if (isInvited) { diff --git a/web/beacon-app/src/features/onboarding/components/steps/preference/index.tsx b/web/beacon-app/src/features/onboarding/components/steps/preference/index.tsx index cc3e281da..0576870e2 100644 --- a/web/beacon-app/src/features/onboarding/components/steps/preference/index.tsx +++ b/web/beacon-app/src/features/onboarding/components/steps/preference/index.tsx @@ -16,7 +16,7 @@ const UserPreferenceStep = () => { const { profile } = useFetchProfile(); const { wasProfileUpdated, isUpdatingProfile, error, updateProfile, hasProfileFailed } = useUpdateProfile(); - const hasError = error && error.response.status === 400; + const hasError = error && error?.response?.status === 400; const submitFormHandler = (values: any) => { const requestPayload = { diff --git a/web/beacon-app/src/features/onboarding/components/steps/workspace/index.tsx b/web/beacon-app/src/features/onboarding/components/steps/workspace/index.tsx index 0abaf520d..f6e7e2c5a 100644 --- a/web/beacon-app/src/features/onboarding/components/steps/workspace/index.tsx +++ b/web/beacon-app/src/features/onboarding/components/steps/workspace/index.tsx @@ -16,10 +16,10 @@ const WorkspaceStep = () => { const { updateProfile, wasProfileUpdated, isUpdatingProfile, reset, error } = useUpdateProfile(); // Check if the workspace is already taken. - const hasError = error && error.response.status === 409; + const hasError = error && error?.response?.status === 409; // Check for workspace URL validation error. - const hasValidationError = error && error.response.status === 400; + const hasValidationError = error && error?.response?.status === 400; const validationError = error?.response?.data?.validation_errors?.[0]?.error; diff --git a/web/beacon-app/src/features/projects/hooks/useFetchProject.ts b/web/beacon-app/src/features/projects/hooks/useFetchProject.ts index 966ebba0c..62f8f85e3 100644 --- a/web/beacon-app/src/features/projects/hooks/useFetchProject.ts +++ b/web/beacon-app/src/features/projects/hooks/useFetchProject.ts @@ -11,7 +11,7 @@ export function useFetchProject(projectID: string): ProjectDetailQuery { enabled: !!projectID, onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/projects/hooks/useFetchTenantProjects.ts b/web/beacon-app/src/features/projects/hooks/useFetchTenantProjects.ts index c7d216477..4dc4b3eea 100644 --- a/web/beacon-app/src/features/projects/hooks/useFetchTenantProjects.ts +++ b/web/beacon-app/src/features/projects/hooks/useFetchTenantProjects.ts @@ -12,7 +12,7 @@ export function useFetchTenantProjects(tenantID: string): ProjectsQuery { enabled: !!tenantID, onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/teams/components/ChangeRoleModal.tsx b/web/beacon-app/src/features/teams/components/ChangeRoleModal.tsx index 1af7cb4b1..e6cb9b39a 100644 --- a/web/beacon-app/src/features/teams/components/ChangeRoleModal.tsx +++ b/web/beacon-app/src/features/teams/components/ChangeRoleModal.tsx @@ -34,7 +34,7 @@ function ChangeRoleModal({ openChangeRoleModal, setOpenChangeRoleModal }: Change { onError(error, _variables, _context) { toast.error((error as any)?.response?.data?.error || 'Something went wrong'); - if ((error as any)?.response.status === 400) { + if ((error as any)?.response?.status === 400) { setOpenChangeRoleModal({ ...openChangeRoleModal, opened: false }); } }, diff --git a/web/beacon-app/src/features/tenants/hooks/useFetchTenants.ts b/web/beacon-app/src/features/tenants/hooks/useFetchTenants.ts index ad57e8949..bfd6d0351 100644 --- a/web/beacon-app/src/features/tenants/hooks/useFetchTenants.ts +++ b/web/beacon-app/src/features/tenants/hooks/useFetchTenants.ts @@ -11,7 +11,7 @@ export function useFetchTenants(): TenantsQuery { const query = useQuery([RQK.TENANTS], tenantsRequest(axiosInstance), { onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/topics/components/Modal/RevokeAPIKeyModal.tsx b/web/beacon-app/src/features/topics/components/Modal/RevokeAPIKeyModal.tsx index bf2929116..47cb0195f 100644 --- a/web/beacon-app/src/features/topics/components/Modal/RevokeAPIKeyModal.tsx +++ b/web/beacon-app/src/features/topics/components/Modal/RevokeAPIKeyModal.tsx @@ -52,13 +52,13 @@ const RevokeAPIKeyModal = ({ onOpen, onClose }: RevokeAPIKeyModalProps) => { // handle error useEffect(() => { - if (error && error.response.status === 401) { + if (error && error?.response?.status === 401) { toast.error( t`You do not have permission to revoke API keys. Please contact your administrator to change your role to a role with permission to revoke API keys.` ); } - if (error && error.response.status !== 401) { + if (error && error?.response?.status !== 401) { toast.error( error?.response?.data?.error || t`Sorry, we were unable to revoke the API key. Please try again. If the issue persists, contact our support team for assistance.` diff --git a/web/beacon-app/src/features/topics/hooks/useFetchTopic.ts b/web/beacon-app/src/features/topics/hooks/useFetchTopic.ts index 38c14c5c0..2e7998a9b 100644 --- a/web/beacon-app/src/features/topics/hooks/useFetchTopic.ts +++ b/web/beacon-app/src/features/topics/hooks/useFetchTopic.ts @@ -12,7 +12,7 @@ export function useFetchTopic(topicID: string): TopicQuery { enabled: !!topicID, onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/topics/hooks/useFetchTopicEvents.ts b/web/beacon-app/src/features/topics/hooks/useFetchTopicEvents.ts index ff5fd29c5..3f9ecd091 100644 --- a/web/beacon-app/src/features/topics/hooks/useFetchTopicEvents.ts +++ b/web/beacon-app/src/features/topics/hooks/useFetchTopicEvents.ts @@ -14,7 +14,7 @@ export function useFetchTopicEvents(topicID: string): TopicEventsQuery { refetchInterval: 60000, onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/topics/hooks/useFetchTopics.ts b/web/beacon-app/src/features/topics/hooks/useFetchTopics.ts index adf2b8915..34844196a 100644 --- a/web/beacon-app/src/features/topics/hooks/useFetchTopics.ts +++ b/web/beacon-app/src/features/topics/hooks/useFetchTopics.ts @@ -12,7 +12,7 @@ export function useFetchTopics(projectID: string): TopicsQuery { enabled: !!projectID, onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/features/topics/routes/TopicDetailPage.tsx b/web/beacon-app/src/features/topics/routes/TopicDetailPage.tsx index 6c9009550..264ac9c5d 100644 --- a/web/beacon-app/src/features/topics/routes/TopicDetailPage.tsx +++ b/web/beacon-app/src/features/topics/routes/TopicDetailPage.tsx @@ -29,7 +29,7 @@ const TopicDetailPage = () => { // if user switch to another organization and topic is not found then // we need to redirect the user to the projects page useEffect(() => { - if (error && error.response.status === 401) { + if (error && error?.response?.status === 401) { navigate(PATH_DASHBOARD.PROJECTS); } }, [error, navigate]); diff --git a/web/beacon-app/src/hooks/useFetchPermissions/useFetchPermissions.ts b/web/beacon-app/src/hooks/useFetchPermissions/useFetchPermissions.ts index e3ab6ac7f..58e077f5e 100644 --- a/web/beacon-app/src/hooks/useFetchPermissions/useFetchPermissions.ts +++ b/web/beacon-app/src/hooks/useFetchPermissions/useFetchPermissions.ts @@ -10,7 +10,7 @@ function useFetchPermissions() { const query = useQuery([RQK.PERMISSIONS], permissionsRequest(axiosInstance), { onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/hooks/useFetchQuickView/useFetchQuickView.ts b/web/beacon-app/src/hooks/useFetchQuickView/useFetchQuickView.ts index 36230bb0e..eb62fd280 100644 --- a/web/beacon-app/src/hooks/useFetchQuickView/useFetchQuickView.ts +++ b/web/beacon-app/src/hooks/useFetchQuickView/useFetchQuickView.ts @@ -11,7 +11,7 @@ function useFetchTenantQuickView(tenantID: string) { enabled: !!tenantID, onError: (error: any) => { // stop logging 401 & 403 errors to sentry - if (error.response.status !== 401 && error.response.status !== 403) { + if (error?.response?.status !== 401 && error?.response?.status !== 403) { Sentry.captureException(error); } }, diff --git a/web/beacon-app/src/hooks/useResendEmail.ts b/web/beacon-app/src/hooks/useResendEmail.ts index 9f2c2e342..bca46eee7 100644 --- a/web/beacon-app/src/hooks/useResendEmail.ts +++ b/web/beacon-app/src/hooks/useResendEmail.ts @@ -18,7 +18,7 @@ const useResendEmail = () => { }), }); // send the status code to the client - const status = response.status; + const status = response?.status; return status; } catch (error) {