import { _ } from '@joplin/lib/locale'; import * as React from 'react'; import { useCallback } from 'react'; import { View, Text, Linking } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; import SettingsButton from './SettingsButton'; import { accountTypeToString } from '@joplin/lib/utils/joplinCloud/types'; import { LinkButton } from '../../buttons'; import { ConfigScreenStyles } from './configScreenStyles'; import { Divider } from 'react-native-paper'; import Logger from '@joplin/utils/Logger'; const logger = Logger.create('JoplinCloudConfig'); type JoplinCloudConfigProps = { styles: ConfigScreenStyles; accountType: string; inboxEmail: string; website: string; userEmail: string; }; export const emailToNoteLabel = () => _('Email to note'); export const emailToNoteDescription = () => _('Any email sent to this address will be converted into a note and added to your collection. The note will be saved into the Inbox notebook'); const JoplinCloudConfig = (props: JoplinCloudConfigProps) => { const isEmailToNoteAvailableInAccount = props.accountType !== '1'; const inboxEmailValue = props.inboxEmail ?? '-'; const goToJoplinCloudProfile = useCallback(async () => { await Linking.openURL(`${props.website}/users/me`); }, [props.website]); const accountTypeName = () => { try { if (!props.accountType) return 'Unknown'; return accountTypeToString(parseInt(props.accountType, 10)); } catch (error) { logger.error(error); return 'Unknown'; } }; return ( {_('Account information')} {_('Account type')} {accountTypeName()} {_('Email')} {props.userEmail} {_('Go to Joplin Cloud profile')} {emailToNoteLabel()} {inboxEmailValue} { !isEmailToNoteAvailableInAccount && ( {_('Your account doesn\'t have access to this feature')} ) } isEmailToNoteAvailableInAccount && Clipboard.setString(props.inboxEmail)} description={emailToNoteDescription()} statusComponent={undefined} styles={props.styles} disabled={!isEmailToNoteAvailableInAccount} /> ); }; export default JoplinCloudConfig;