import React from "react"; import { View, ImageBackground } from "react-native"; import { Text, TextInput, Button, Divider, Checkbox } from "react-native-paper"; import i18n from "../i18nMessages.js"; import API from "../API"; const validateEmail = (text) => { let reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w\w+)+$/; if (reg.test(text) === false) { console.log("Email is Not Correct"); return false; } return true; } let InviteView = ()=>{ const [name, setName] = React.useState(""); const [email, setEmail] = React.useState(""); const [checked, setChecked] = React.useState(""); let sendInvite = async () => { if(name == "" || email == "" || !checked){ alert("Please make sure to fill all the inputs"); return 0; } if(!validateEmail(email)){ alert("Please input a valid email"); return 0; } const response = await API.newInvitation(name, email); if(response?.status !== "ok"){ alert(response.status); return 0; } //console.log(response); setName(''); setEmail(''); setChecked(false); alert("Invitation sent, thank you!"); } return ( {i18n.t("message.invite")} setName(text)} /> setEmail(text)} autoCapitalize='none' autoComplete='email' autoCorrect={false} keyboardType='email-address' /> {setChecked(!checked)}} /> ) } export default InviteView;