forked from AkshayWarrier/Volunteer-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrgTaskDescription.js
273 lines (249 loc) · 8.4 KB
/
OrgTaskDescription.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
import { StyleSheet, Text, View, Image, Linking,Alert } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import { useState,useEffect } from 'react';
import Icon from 'react-native-vector-icons/FontAwesome';
import { TouchableOpacity } from 'react-native';
import { doc,updateDoc } from "firebase/firestore";
import { addNewDoc,query_db,users_collection,organisations_collection,auth,tasks_collection,volunteers_collection } from "./methods.js";
import { db} from "./config.js";
export const OrgTaskDescription = ({ route }) => {
const [org_data, setOrgData] = useState([]);
const [isVolunteered, setIsVolunteered] = useState(false);
const [user, setUser] = useState(null);
const [isUser, setIsUser] = useState(false);
const data = route.params;
//const [task_data, setTaskData] = useState(data.data);
//setTaskData(data.data);
const imgsrc = {
"Environmental": require("./assets/images/environment.png"),
"Community": require("./assets/images/community.png"),
"Animal": require("./assets/images/user.png"),
"Education": require("./assets/images/education.png"),
"Health":require("./assets/images/education.png"),
}
// let org_address = "";
// let org_website = "";
// let org_phone = "";
// let org_description = "";
// let org_email = "";
useEffect(() => {auth.onAuthStateChanged(async function(user) {
if (user) {
// currentUser should be available now
const user_query = await query_db("Email", "==", user.email,users_collection);
if(user_query.empty){
// isUser = false;
setIsUser(false);
}
else{
//isUser = true;
setIsUser(true);
}
const user_info = {
"Name": user.displayName,
"Email": user.email,
"Photo": user.photoURL,
}
setUser(user_info);
// isUser = true;
let org_dat = {};
const org_info = await query_db("Name", "==", data.data.organisation,organisations_collection);
org_info.forEach((doc) => {
org_dat = {
"Name": doc.data().Name,
"Address": doc.data().Address,
"Phone": doc.data().Phone,
"Email": doc.data().Email,
"Website": doc.data().Website,
"Description": doc.data()["About Us"],
"OrgID": doc.data().OrgID,
}
setOrgData(org_dat);
});
const volunteers_query = await query_db("Email", "==", user.email,volunteers_collection);
for(const doc of volunteers_query.docs){
if(doc.data().TaskID == data.data.taskID){ //check if user has already submitted for volunteering
setIsVolunteered(true);
}
}
}
else{
console.log("could not load user info from google");
// No user logged in.
}
});}, []);
if(org_data.length == 0) {
return(
<View style={styles.loadingContainer}>
<Text style={styles.title}>Loading...</Text>
</View>
)
}
else{
return (
<View style={styles.container}>
<Image source={imgsrc[data.data.type]} style={styles.image} />
<View style={styles.titleContainer}>
<Text style={styles.title}>{data.data.name}</Text>
</View>
<View style={styles.tagContainer}>
<View style={styles.logoContainer}>
{data.data.type === "Environmental" && <Icon name="tree" size={15} color="#FF6B6B" />}
{data.data.type === "Community" && <Icon name="user" size={15} color="#FF6B6B" />}
{data.data.type === "Animal" && <Icon name="paw" size={15} color="#FF6B6B" />}
{data.data.type === "Education" && <Icon name="book" size={15} color="#FF6B6B" />}
{data.data.type === "Health" && <Icon name="medkit" size={15} color="#FF6B6B" />}
<Text style={styles.logoText}>{`${data.data.type} `}</Text>
</View>
<View style={styles.logoContainer}>
<Icon name="map-marker" size={17} color="#FF6B6B" />
<Text style={styles.logoText}>
{data.data.remote ? "Remote" : data.data.location}
</Text>
</View>
</View>
<View style={styles.descriptionContainer}>
<Text style={styles.subtitle}>Job Description</Text>
<Text style={styles.description}>{data.data.description}</Text>
</View>
<View style={styles.descriptionContainer}>
<Text style={styles.subtitle}>{org_data.Name}</Text>
{/* placeholder */}
<Text style={styles.description}>{`${org_data.Description}`} </Text>
</View>
<View style={styles.tagContainer}>
<View style={styles.logoContainer}>
<Icon name="phone" size={15} color="#FF6B6B" />
<Text style={styles.logoText}>{`${org_data.Phone}`}</Text>
</View>
<View style={styles.logoContainer}>
<Icon name="envelope" size={15} color="#FF6B6B" />
<Text style={styles.logoText}>{`${org_data.Email}`}</Text>
</View>
{/* <View style={styles.logoContainer}>
<Icon name="search" size={15} color="#FF6B6B" />
<Text style={styles.logoText}>abc.org</Text>
</View> */}
</View>
<View style={styles.dataContainer}>
<View style={styles.dataTile}>
<Icon name="clock-o" size={40} color="#FF6B6B" />
<Text style={styles.data}>{`${data.data.startDate}`}</Text>
</View>
<View style={styles.dataTile}>
{/* <Icon name="male" size={17} color="#FF6B6B" /> */}
<Text style={styles.dataIcon}>{`${data.data.volunteersCount}`}</Text>
<Text style={styles.data}>Volunteers</Text>
</View>
</View>
<TouchableOpacity style={styles.editButton}>
<Text style={styles.editText}>Edit Task</Text>
</TouchableOpacity>
<StatusBar style="auto" />
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#F7FFF7",
},
image: {
width: "100%",
height: 200,
},
titleContainer: {
backgroundColor: "rgba(78, 205, 196, 0.3);",
padding: 10,
marginBottom: 5,
},
title: {
color: "#10383F",
fontSize: 25,
fontWeight: "bold",
},
tagContainer: {
flexDirection: "row",
marginBottom: 5,
// justifyContent: "center",
},
logoContainer: {
flex: 1,
flexDirection: "row",
color: "#FF6B6B",
alignItems: "center",
justifyContent: "center",
},
logoText: {
color: "#FF6B6B",
fontSize: 14,
fontWeight: "500",
paddingLeft: 2
},
descriptionContainer: {
flex:1,
padding: 10,
},
subtitle: {
color: "#10383F",
fontSize: 20,
fontWeight: "bold",
marginBottom: 2,
},
description: {
color: "#1A535C",
fontSize: 14,
fontWeight: "400",
},
volunteerButton: {
backgroundColor: "#1A535C",
width: "100%",
height: 60,
justifyContent: "center",
alignItems: "center",
marginTop: 10,
},
volunteerText: {
color: "#F7FFF7",
fontSize: 24,
},
dataContainer: {
flexDirection: "row",
padding: 10,
marginTop: 10,
flex: 1,
},
dataTile: {
flex: 1,
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
},
data: {
color: "#FF6B6B",
fontSize: 14,
fontWeight: "500",
},
dataIcon: {
color: "#FF6B6B",
fontSize: 30,
fontWeight: "700",
},
loadingContainer: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
editButton: {
backgroundColor: "#1A535C",
width: "100%",
height: 60,
justifyContent: "center",
alignItems: "center",
marginTop: 10,
},
editText: {
color: "#F7FFF7",
fontSize: 24,
},
});