diff --git a/native/account/registration/connect-farcaster.react.js b/native/account/registration/connect-farcaster.react.js --- a/native/account/registration/connect-farcaster.react.js +++ b/native/account/registration/connect-farcaster.react.js @@ -23,6 +23,10 @@ ConnectEthereumRouteName, AvatarSelectionRouteName, } from '../../navigation/route-names.js'; +import { + getFarcasterAccountAlreadyLinkedAlertDetails, + type AlertDetails, +} from '../../utils/alert-messages.js'; import { useStaffCanSee } from '../../utils/staff-utils.js'; export type ConnectFarcasterParams = ?{ @@ -110,10 +114,7 @@ identityServiceClient?.identityClient.getFarcasterUsers; invariant(getFarcasterUsers, 'Could not get getFarcasterUsers'); - const [queuedAlert, setQueuedAlert] = React.useState(); + const [queuedAlert, setQueuedAlert] = React.useState(); const onSuccess = React.useCallback( async (fid: string) => { @@ -121,10 +122,11 @@ const commFCUsers = await getFarcasterUsers([fid]); if (commFCUsers.length > 0 && commFCUsers[0].farcasterID === fid) { const commUsername = commFCUsers[0].username; - setQueuedAlert({ - title: 'Farcaster account already linked', - body: `That Farcaster account is already linked to ${commUsername}`, - }); + + const alert = + getFarcasterAccountAlreadyLinkedAlertDetails(commUsername); + + setQueuedAlert(alert); setWebViewState('closed'); } else { goToNextStep(fid); @@ -136,7 +138,7 @@ } catch (e) { setQueuedAlert({ title: 'Failed to query Comm', - body: + message: 'We failed to query Comm to see if that Farcaster account is ' + 'already linked', }); @@ -151,7 +153,7 @@ if (!queuedAlert || !isAppForegrounded) { return; } - Alert.alert(queuedAlert.title, queuedAlert.body); + Alert.alert(queuedAlert.title, queuedAlert.message); setQueuedAlert(null); }, [queuedAlert, isAppForegrounded]); diff --git a/native/utils/alert-messages.js b/native/utils/alert-messages.js --- a/native/utils/alert-messages.js +++ b/native/utils/alert-messages.js @@ -2,7 +2,7 @@ import { Platform } from 'react-native'; -type AlertDetails = { +export type AlertDetails = { +title: string, +message: string, }; @@ -12,31 +12,49 @@ android: 'Play Store', }); -export const AppOutOfDateAlertDetails: AlertDetails = { +const AppOutOfDateAlertDetails: AlertDetails = { title: 'App out of date', message: 'Your app version is pretty old, and the server doesn’t know how ' + `to speak to it anymore. Please use the ${platformStore} to update!`, }; -export const UsernameReservedAlertDetails: AlertDetails = { +const UsernameReservedAlertDetails: AlertDetails = { title: 'Username reserved', message: 'This username is currently reserved. Please contact support@' + 'comm.app if you would like to claim this account.', }; -export const UsernameTakenAlertDetails: AlertDetails = { +const UsernameTakenAlertDetails: AlertDetails = { title: 'Username taken', message: 'An account with that username already exists', }; -export const UserNotFoundAlertDetails: AlertDetails = { +const UserNotFoundAlertDetails: AlertDetails = { title: 'Incorrect username or password', message: "Either that user doesn't exist, or the password is incorrect", }; -export const UnknownErrorAlertDetails: AlertDetails = { +const UnknownErrorAlertDetails: AlertDetails = { title: 'Unknown error', message: 'Uhh... try again?', }; + +const getFarcasterAccountAlreadyLinkedAlertDetails = ( + commUsername: ?string, +): AlertDetails => ({ + title: 'Farcaster account already linked', + message: `That Farcaster account is already linked to ${ + commUsername ? commUsername : 'another account' + }`, +}); + +export { + AppOutOfDateAlertDetails, + UsernameReservedAlertDetails, + UsernameTakenAlertDetails, + UserNotFoundAlertDetails, + UnknownErrorAlertDetails, + getFarcasterAccountAlreadyLinkedAlertDetails, +};