-
Notifications
You must be signed in to change notification settings - Fork 2
/
VolunteerFeed.js
110 lines (95 loc) · 2.62 KB
/
VolunteerFeed.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
import { StyleSheet, Text, View } from 'react-native';
import { ScrollView, TouchableOpacity,RefreshControl } from 'react-native';
import { FeedCard } from './FeedCard';
import { getDocs, collection, doc, setDoc } from "firebase/firestore";
import { db} from "./config.js";
import { useState, useEffect,useCallback } from 'react';
let tasks =[];
const wait = (timeout) => {
return new Promise(resolve => {
setTimeout(resolve, timeout);
});
}
export const VolunteerFeed = () => {
const [taskData, setTaskData] = useState([]);
const [refreshing, setRefreshing] = useState(false);
const onRefresh = useCallback(() => {
setRefreshing(true);
wait(2000).then(() => setRefreshing(false));
}, []);
useEffect(() => {
try {
// console.log("entered useEffect")
let task_data = [];
const querySnapshot = getDocs(collection(db, "tasks"))
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
task_data.push(doc.data());
});
// console.log(task_data);
let data = task_data;
setTaskData(data);
// console.log(data);
});
} catch (error) {
console.log(error);
}
}, [refreshing]);
return (
<View style={styles.screen}>
<ScrollView
style={styles.container}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
{
taskData.map((task, index) => {
// console.log("check3");
return (
<FeedCard key={index} name={task.Name} organisation={task.OrgName} type={task.Tag} remote={task.Remote} location={task.City.label + ', ' + task.State.label} description={task["Job Description"]} startDate={task["Start Date"]} formLink={task["FormLink"]} volunteersCount={task["Volunteers Registered"]} volunteersReq={task.volunteersReq} taskID={task["Task ID"]} />
)
})
}
</ScrollView>
</View>
)
}
const styles = StyleSheet.create({
screen: {
flex: 1,
},
container: {
flex: 1,
backgroundColor: "#F7FFF7",
// alignItems: 'center',
padding: 10,
},
button: {
position: 'absolute',
bottom: 30,
right: 30,
width: 60,
height: 60,
backgroundColor: "#F7FFF7",
color: "#1A535C",
borderRadius: 50,
},
icon: {
fontSize: 30,
color: "#1A535C",
textAlign: 'center',
textAlignVertical: 'center',
height: 60,
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontSize: 20,
fontWeight: '500',
color: '#1A535C',
},
});