import React from 'react' import { ActivityIndicator, StyleSheet, TouchableOpacity, View, } from 'react-native' import {TextInput} from './util' import { FontAwesomeIcon, FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' import LinearGradient from 'react-native-linear-gradient' import {Text} from '../util/text/Text' import {useStores} from 'state/index' import {s, gradients} from 'lib/styles' import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' import {ErrorMessage} from '../util/error/ErrorMessage' import {cleanError} from 'lib/strings/errors' export const snapPoints = ['80%'] export function Component({}: {}) { const pal = usePalette('default') const theme = useTheme() const store = useStores() const [email, setEmail] = React.useState('') const [isEmailSent, setIsEmailSent] = React.useState(false) const [isProcessing, setIsProcessing] = React.useState(false) const [error, setError] = React.useState('') const onPressSignup = async () => { setError('') setIsProcessing(true) try { const res = await fetch('https://bsky.app/api/waitlist', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({email}), }) const resBody = await res.json() if (resBody.success) { setIsEmailSent(true) } else { setError( resBody.error || 'Something went wrong. Check your email and try again.', ) } } catch (e: any) { setError(cleanError(e)) } setIsProcessing(false) } const onCancel = () => { store.shell.closeModal() } return ( Join the waitlist Bluesky uses invites to build a healthier community. If you don't know anybody with an invite, you can sign up for the waitlist and we'll send one soon. {error ? ( ) : undefined} {isProcessing ? ( ) : isEmailSent ? ( Your email has been saved! We'll be in touch soon. ) : ( <> Join Waitlist Cancel )} ) } const styles = StyleSheet.create({ container: { flex: 1, }, innerContainer: { paddingBottom: 20, }, title: { textAlign: 'center', marginTop: 12, marginBottom: 12, }, description: { textAlign: 'center', paddingHorizontal: 22, marginBottom: 10, }, textInput: { borderWidth: 1, borderRadius: 6, paddingHorizontal: 16, paddingVertical: 12, fontSize: 20, marginHorizontal: 20, }, btn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', borderRadius: 32, padding: 14, marginHorizontal: 20, }, error: { borderRadius: 6, marginHorizontal: 20, marginBottom: 20, }, })