Minnor changes and fix invitation logic
This commit is contained in:
@@ -41,7 +41,7 @@ const handleURL = (url, navigation) => {
|
|||||||
if (path === 'alert') {
|
if (path === 'alert') {
|
||||||
alert(queryParams.str);
|
alert(queryParams.str);
|
||||||
} else {
|
} else {
|
||||||
alert(path + " ::: " + queryParams);
|
//alert(path + " ::: " + queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,15 @@ import { Text, TextInput, Button, Divider, Checkbox } from "react-native-paper";
|
|||||||
import i18n from "../i18nMessages.js";
|
import i18n from "../i18nMessages.js";
|
||||||
import API from "../API";
|
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 = ()=>{
|
let InviteView = ()=>{
|
||||||
const [name, setName] = React.useState("");
|
const [name, setName] = React.useState("");
|
||||||
@@ -11,11 +20,24 @@ let InviteView = ()=>{
|
|||||||
const [checked, setChecked] = React.useState("");
|
const [checked, setChecked] = React.useState("");
|
||||||
|
|
||||||
let sendInvite = async () => {
|
let sendInvite = async () => {
|
||||||
if(name != "" && email != "") return 0;
|
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('');
|
setName('');
|
||||||
setEmail('');
|
setEmail('');
|
||||||
setChecked(false);
|
setChecked(false);
|
||||||
await API.newInvitation(name, email);
|
alert("Invitation sent, thank you!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -39,6 +61,10 @@ let InviteView = ()=>{
|
|||||||
style={{backgroundColor:"rgba(0,0,0,0)"}}
|
style={{backgroundColor:"rgba(0,0,0,0)"}}
|
||||||
value={email}
|
value={email}
|
||||||
onChangeText={text => setEmail(text)}
|
onChangeText={text => setEmail(text)}
|
||||||
|
autoCapitalize='none'
|
||||||
|
autoComplete='email'
|
||||||
|
autoCorrect={false}
|
||||||
|
keyboardType='email-address'
|
||||||
/>
|
/>
|
||||||
<Checkbox.Item
|
<Checkbox.Item
|
||||||
label={i18n.t("message.IKnowThisPerson")}
|
label={i18n.t("message.IKnowThisPerson")}
|
||||||
@@ -46,7 +72,7 @@ let InviteView = ()=>{
|
|||||||
onPress={()=>{setChecked(!checked)}}
|
onPress={()=>{setChecked(!checked)}}
|
||||||
/>
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Button mode="outlined">Invite</Button>
|
<Button mode="outlined" onPress={sendInvite}>Invite</Button>
|
||||||
</ImageBackground>
|
</ImageBackground>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ let NewPostView = (props) => {
|
|||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
alert("Something went wrong");
|
alert("Something went wrong uploading the photo.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uploadedFiles = Promise.all(allUploads);
|
uploadedFiles = Promise.all(allUploads);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ let ProfileSettings = ()=>{
|
|||||||
.catch((err) => console.error(err));
|
.catch((err) => console.error(err));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
alert("Something went wrong");
|
alert("Something went wrong uploading the photo.");
|
||||||
}
|
}
|
||||||
return uploadedFile;
|
return uploadedFile;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user