@@ -6,6 +6,7 @@ import { ConcertData } from "@/components/concert/ConcertType";
66import ListSortClient from "@/components/concert/list/ListSortClient" ;
77import { useCallback , useEffect , useRef , useState } from "react" ;
88import { toast } from "sonner" ;
9+ import { totalConcertCount } from "@/lib/api/concerts" ;
910
1011export default function ConcertListContent ( {
1112 initialList,
@@ -17,6 +18,7 @@ export default function ConcertListContent({
1718 const [ concertsList , setConcertsList ] = useState ( initialList ) ;
1819 const [ hasMore , setHasMore ] = useState ( true ) ;
1920 const [ loading , setLoading ] = useState ( false ) ;
21+ const [ totalCount , setTotalCount ] = useState < number | null > ( null ) ;
2022
2123 const oTarget = useRef ( null ) ;
2224 const pageRef = useRef ( 1 ) ; // 0 시작 이므로
@@ -83,12 +85,25 @@ export default function ConcertListContent({
8385 setLoading ( false ) ;
8486 } , [ initialList , sortType ] ) ;
8587
88+ useEffect ( ( ) => {
89+ const fetchTotalCount = async ( ) => {
90+ const count = await totalConcertCount ( ) ;
91+ if ( count !== null ) {
92+ setTotalCount ( count ) ;
93+ }
94+ } ;
95+
96+ fetchTotalCount ( ) ;
97+ } , [ ] ) ;
98+
8699 return (
87100 < section className = "px-15 py-16" >
88101 < div className = { twMerge ( `mx-auto flex w-full max-w-400 flex-col gap-9` ) } >
89102 < div className = "header flex items-center justify-between" >
90103 < div className = "flex items-center gap-2" >
91- < span className = "text-text-main text-2xl font-bold" > { concertsList . length } </ span >
104+ < span className = "text-text-main text-2xl font-bold" >
105+ { totalCount ?? concertsList . length }
106+ </ span >
92107 < span className = "text-text-main text-lg" > items</ span >
93108 </ div >
94109 < ListSortClient />
0 commit comments