-
Notifications
You must be signed in to change notification settings - Fork 2
/
ProfileCreation.js
205 lines (188 loc) · 8.05 KB
/
ProfileCreation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import { StyleSheet, Text, View, TouchableOpacity, TextInput, ScrollView,Alert } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import { useState,useEffect } from 'react';
import { useNavigation } from '@react-navigation/native';
import { addNewDoc,users_collection,organisations_collection,auth } from "./methods.js";
export const ProfileCreation = ({ setIsSigned, setIsLogged }) => {
const navigation = useNavigation();
const [userData, setUserData] = useState({
name: '',
phone: '',
age:'',
interests:[],
city:'',
state:'',
pincode:'',
country:'',
profession:'',
aboutMe: '',
});
return (
<View style={styles.container}>
<ScrollView style={styles.scroll}>
<View style={styles.container}>
<Text style={styles.title}>Profile</Text>
<View style={styles.formContainer}>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>User Name</Text>
<TextInput style={styles.input} onChangeText={(text) => setUserData({...userData, name: text})} value={userData.name}/>
</View>
<View>
<Text style={styles.inputTitle} >Age</Text>
<TextInput style={styles.input} keyboardType="numeric" onChangeText={(text) => setUserData({...userData, age: text})} value={userData.age}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Contact Number</Text>
<TextInput style={styles.input} keyboardType="phone-pad" onChangeText={(text) => setUserData({...userData, phone: text})} value={userData.phone}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>City</Text>
<TextInput style={styles.input} multiline={true} numberOfLines={4} onChangeText={(text) => setUserData({...userData, city: text})} value={userData.city}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>State</Text>
<TextInput style={styles.input} multiline={true} numberOfLines={4} onChangeText={(text) => setUserData({...userData, state: text})} value={userData.state}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Pincode</Text>
<TextInput style={styles.input} onChangeText={(text) => setUserData({...userData, pincode: text})} value={userData.pincode}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Country</Text>
<TextInput style={styles.input} onChangeText={(text) => setUserData({...userData, country: text})} value={userData.country}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Profession</Text>
<TextInput style={styles.input} onChangeText={(text) => setUserData({...userData, profession: text})} value={userData.profession}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Tell Us About Yourself</Text>
<TextInput style={styles.input} multiline={true} numberOfLines={4} onChangeText={(text) => setUserData({...userData, aboutMe: text})} value={userData.aboutMe}/>
</View>
</View>
<TouchableOpacity style={styles.button}
onPress={async () => {
let email = "";
let id = "";
await auth.onAuthStateChanged(function (user) { //If User logged in on startup
if (user) {
email = user.email;
id = user.uid;
}
else{
console.log("No user logged in");
}
});
//if(userData.name && userData.age && userData.phone && userData.city && userData.state && userData.pincode && userData.country && userData.profession && userData.address && userData.aboutMe){{
const db_doc = {
"Name": userData.name,
"Phone": userData.phone,
"Location": {
"City": userData.city,
"State": userData.state,
"Pincode": userData.pincode,
"Country": userData.country
},
"Email": email,
"About Me": userData.aboutMe,
"Completed_Jobs": [],
"Ongoing_Jobs": [],
"UserID": id,
"Age": userData.age,
"Average_Rating":null,
"Completed_Jobs":0,
"Level":0,
"Profession":userData.profession,
"Interests":["Education","Healthcare","Environment","Social Welfare","Animal Welfare"]
};
const db_collection = users_collection;
await addNewDoc(db_collection,db_doc);
/*
"Email": email,
"Start Time": start_time,
"End Time": end_time,
"Start Date": start_date,
"End Date": end_date,
"VolunteerHours": hours,
"OrgID": OrgID,
"VolunteersCount":0,
"TaskID":taskID,
"Country":country,
*/
console.log(userData);
console.log("User Added to Database");
setIsSigned(true);
setIsLogged(true);
navigation.navigate('Feed');
// Send data to backend
}}>
<Text style={styles.text}>Continue</Text>
</TouchableOpacity>
</View>
<StatusBar style="auto" />
</ScrollView>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#F7FFF7",
alignItems: 'center',
},
scroll: {
flex: 1,
margin: 20,
marginLeft: 0,
marginRight: 0,
},
title: {
fontSize: 24,
fontFamily: 'Poppins',
color: "#1A535C",
textAlign: 'center',
marginBottom: 30,
marginTop: 40,
},
formContainer: {
flex: 1,
backgroundColor: "#F7FFF7",
},
inputContainer: {
flex: 1,
backgroundColor: "#F7FFF7",
marginTop: 10,
},
inputTitle: {
fontSize: 18,
fontFamily: 'Poppins',
color: "#1A535C",
paddingTop: 10,
},
input: {
height: 30,
marginVertical: 10,
borderWidth: 2,
width: 300,
borderBottomColor: "#10383F",
borderTopColor: "#F7FFF7",
borderLeftColor: "#F7FFF7",
borderRightColor: "#F7FFF7",
fontFamily: 'Poppins',
color: "#1A535C",
},
button: {
marginTop: 30,
backgroundColor: "#1A535C",
width: 200,
height: 50,
padding: 10,
alignItems: 'center',
justifyContent: 'center',
},
text: {
color: "#F7FFF7",
fontSize: 18,
fontFamily: 'Poppins',
},
});