-
Notifications
You must be signed in to change notification settings - Fork 2
/
OrgProfileCreation.js
176 lines (162 loc) · 6.33 KB
/
OrgProfileCreation.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
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 OrgProfileCreation = ({ setIsSigned, setIsLogged }) => {
const navigation = useNavigation();
const [orgData, setOrgData] = useState({
name: '',
phone: '',
address: '',
website: '',
aboutUs: '',
});
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}>Organisation Name</Text>
<TextInput style={styles.input} onChangeText={(text) => setOrgData({...orgData, name: text})} value={orgData.name}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Contact Number</Text>
<TextInput style={styles.input} keyboardType="phone-pad" onChangeText={(text) => setOrgData({...orgData, phone: text})} value={orgData.phone}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Address</Text>
<TextInput style={styles.input} multiline={true} numberOfLines={2} onChangeText={(text) => setOrgData({...orgData, address: text})} value={orgData.address}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Tell Us About Yourself</Text>
<TextInput style={styles.input} multiline={true} numberOfLines={2} onChangeText={(text) => setOrgData({...orgData, aboutUs: text})} value={orgData.aboutUs}/>
</View>
<View style={styles.inputContainer}>
<Text style={styles.inputTitle}>Website</Text>
<TextInput style={styles.input} onChangeText={(text) => setOrgData({...orgData, website: text})} value={orgData.website}/>
</View>
</View>
<TouchableOpacity style={styles.button}
onPress={async () => {
let email = "";
let id = "";
await auth.onAuthStateChanged(async function (user) { //If User logged in on startup
if (user) {
email = user.email;
id = user.uid;
console.log("email"+email);
}
else{
console.log("No user logged in");
}
});
console.log("email"+email);
if(orgData.aboutUs && orgData.address && orgData.name && orgData.phone && orgData.website ){{
const db_doc = {
"Name": orgData.name,
"Phone": orgData.phone,
"Address": orgData.address,
"Email": email,
"Website": orgData.website,
"About Us": orgData.aboutUs,
"Completed Projects": [],
"Ongoing Projects": [],
"OrgID": id,
};
const db_collection = organisations_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(orgData);
console.log("Org Added to Database");
setIsSigned(true);
setIsLogged(true);
navigation.navigate('OrganizationFeed');
// Send data to backend
}}else{
Alert.alert("Please fill all the fields");
}
}}>
<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',
},
});