File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed
Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change 22
33import Link from "next/link" ;
44import { aColor } from "@/lib/client/constants" ;
5+ import { useEffect , useState } from "react" ;
56
67export 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 ) ;
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments