Skip to content

Commit 5730d95

Browse files
committed
Update stats
1 parent 56c3ccb commit 5730d95

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/components/Stats.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
const Stats = ({ conducted }) => {
3+
const Stats = ({ conducted, attending }) => {
44
const heading = {
55
color: '#291755',
66
marginBottom: '10px'
@@ -60,7 +60,7 @@ const Stats = ({ conducted }) => {
6060
<br />
6161
attended
6262
</p>
63-
<div style={circle}>0</div>
63+
<div style={circle}>{attending}</div>
6464
</div>
6565
</div>
6666
</div>

src/components/dashboard.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import BookmarkedEvents from './BookmarkedEvents';
88
import Calendar from './Calendar';
99
import Loader from './Loader';
1010
import NewEvents from './NewEvents';
11-
import Publications from './Publications';
11+
// import Publications from './Publications';
1212
import Stats from './Stats';
1313

1414
const useStyles = makeStyles(theme => ({
@@ -23,6 +23,7 @@ export default function Dashboard() {
2323
const user = useSelector(state => state.account.user);
2424
const [userEvents, setUserEvents] = useState([]);
2525
const [loading, setLoading] = useState(true);
26+
const [attending, setAttending] = useState(0);
2627

2728
useEffect(() => {
2829
const fetchUserEvents = async () => {
@@ -34,6 +35,14 @@ export default function Dashboard() {
3435
.where('createdBy', '==', `${userId}`)
3536
.get();
3637

38+
const userRef = await db.collection('users').doc(userId);
39+
userRef.get().then(doc => {
40+
if (doc.exists) {
41+
let data = doc.data();
42+
setAttending(data.attending.length);
43+
}
44+
});
45+
3746
setUserEvents(
3847
userEventCollection.docs.map(doc => doc.data()),
3948
setLoading(false)
@@ -49,12 +58,12 @@ export default function Dashboard() {
4958
<Box display="flex">
5059
<Box flexGrow={1}>
5160
{userEvents.length > 0 && <Calendar userEvents={userEvents} />}
52-
<Stats conducted={userEvents.length} />
61+
<Stats conducted={userEvents.length} attending={attending} />
5362
<BookmarkedEvents />
5463
</Box>
5564
<Box maxWidth="28em" minWidth="24em">
5665
<NewEvents />
57-
<Publications />
66+
{/* <Publications /> */}
5867
</Box>
5968
</Box>
6069
</main>

0 commit comments

Comments
 (0)