Skip to content

Commit 1e5cf0c

Browse files
committed
Move user count
1 parent 12bac6d commit 1e5cf0c

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

app/learn-more/page.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22

33
import Link from "next/link";
44
import {aColor} from "@/lib/client/constants";
5+
import {useEffect, useState} from "react";
56

67
export default function LearnMorePage() {
8+
9+
const [totalUsers, setTotalUsers] = useState<number>(0);
10+
useEffect(() => {
11+
const getCount = async () => {
12+
const countResponse = await fetch('/api/profiles/count');
13+
if (countResponse.ok) {
14+
const {count} = await countResponse.json();
15+
setTotalUsers(count);
16+
}
17+
};
18+
19+
getCount();
20+
}, []); // <- runs once after initial mount
721
return (
822
<div className="text-gray-600 dark:text-white min-h-screen p-6">
923
{aColor}
@@ -46,6 +60,8 @@ export default function LearnMorePage() {
4660
<h5 id="github-repo">Source Code</h5>
4761
<p>The source code and instructions for development are available on <a href="https://github.com/BayesBond/BayesBond">GitHub</a>.</p>
4862
</div>
63+
<h3 id="how-to-help">Statistics</h3>
64+
<p>{totalUsers} total users</p>
4965
</div>
5066
</div>
5167
);

app/profiles/page.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,9 @@ export default function ProfilePage() {
3232
const [loading, setLoading] = useState(true);
3333
const [error, setError] = useState('');
3434
const [_, setShowFilters] = useState(true);
35-
const [totalUsers, setTotalUsers] = useState<number>(0);
3635
const [images, setImages] = useState<string[]>([])
3736
const [filters, setFilters] = useState(initialState);
3837

39-
40-
useEffect(() => {
41-
const getCount = async () => {
42-
const countResponse = await fetch('/api/profiles/count');
43-
if (countResponse.ok) {
44-
const {count} = await countResponse.json();
45-
setTotalUsers(count);
46-
}
47-
};
48-
49-
getCount();
50-
}, []); // <- runs once after initial mount
51-
5238
const fetchProfiles = useCallback(async () => {
5339
try {
5440
setLoading(true);

0 commit comments

Comments
 (0)