diff --git a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js --- a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js +++ b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js @@ -17,6 +17,11 @@ import type { NavigationRoute } from '../../navigation/route-names.js'; import { useStyles, useColors } from '../../themes/colors.js'; +const errorMessages: { +[string]: string } = { + already_in_use: 'This Farcaster channel is already tagged to a community.', + channel_not_found: 'Cannot find a channel with the provided name.', +}; + export type TagFarcasterChannelByNameParams = { +communityID: string, }; @@ -37,6 +42,7 @@ const [channelSelectionText, setChannelSelectionText] = React.useState(''); + const [error, setError] = React.useState(null); const neynarClientContext = React.useContext(NeynarClientContext); invariant(neynarClientContext, 'NeynarClientContext is missing'); @@ -54,8 +60,7 @@ farcasterChannelID: channelID, }); } catch (e) { - // TODO: Improve error handling - console.log(e.message); + setError(e.message); throw e; } }, @@ -69,7 +74,7 @@ ); if (!channelInfo) { - // TODO: Improve error handling + setError('channel_not_found'); return; } @@ -87,6 +92,18 @@ neynarClientContext.client, ]); + const errorMessage = React.useMemo(() => { + if (!error) { + return null; + } + + return ( + + {errorMessages[error] ?? 'Unknown error.'} + + ); + }, [error, styles.error]); + const submitButtonVariant = channelSelectionText.length > 0 ? 'enabled' : 'disabled'; @@ -105,6 +122,7 @@ autoCapitalize="none" /> + {errorMessage}