Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add fallback error handling in InviteMEmberModal

Joshen Lim5f7ec79e6e3a
diff --git a/studio/components/to-be-cleaned/ModalsDeprecated/InviteMemberModal.js b/studio/components/to-be-cleaned/ModalsDeprecated/InviteMemberModal.js
index 5aeda705f6f..bede35b4b46 100644
--- a/studio/components/to-be-cleaned/ModalsDeprecated/InviteMemberModal.js
+++ b/studio/components/to-be-cleaned/ModalsDeprecated/InviteMemberModal.js
@@ -1,7 +1,6 @@
import { createContext, useContext, useCallback, useState, useEffect } from 'react'
-import { debounce } from 'lodash'
+import { debounce, isUndefined } from 'lodash'
import { observer, useLocalObservable } from 'mobx-react-lite'
-import toast from 'react-hot-toast'
import { post } from 'lib/common/fetch'
import { Button, IconKey, IconLoader, IconUser, IconX, Input, Typography } from '@supabase/ui'
import { Modal } from '@supabase/ui'
@@ -71,7 +70,9 @@ function InviteMemberModal({ organization, members = [] }) {
org_id: orgId,
user_id: PageState.selectedProfile.id,
})
- if (response?.error) {
+ if (isUndefined(response)) {
+ ui.setNotification({ category: 'error', message: 'Failed to search profile' })
+ } else if (response?.error) {
ui.setNotification({
category: 'error',
message: `Failed to add member: ${response.error.message}`,
@@ -140,7 +141,9 @@ const InputSearchWithResults = observer(({ className }) => {
}
setLoading(true)
const response = await post(`${API_URL}/profile/search`, { keywords: PageState.keywords })
- if (response?.error) {
+ if (isUndefined(response)) {
+ ui.setNotification({ category: 'error', message: 'Failed to search profile' })
+ } else if (response.error) {
ui.setNotification({
category: 'error',
message: `Failed to search profile: ${response.error.message}`,