File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,6 +189,28 @@ export default function Detail() {
189189 // eslint-disable-next-line react-hooks/exhaustive-deps
190190 } , [ lineId , currentDate ] ) ;
191191
192+ // 데이터 사용량 polling (현재 달일 때만 30초 간격)
193+ useEffect ( ( ) => {
194+ const isCurrentMonth =
195+ currentDate . getFullYear ( ) === today . getFullYear ( ) &&
196+ currentDate . getMonth ( ) === today . getMonth ( ) ;
197+
198+ if ( ! lineId || ! isCurrentMonth ) return ;
199+
200+ const interval = setInterval ( async ( ) => {
201+ try {
202+ const yearMonth = formatYearMonth ( currentDate ) ;
203+ const dataRes = await userService . getDataUsage ( lineId , yearMonth ) ;
204+ setDataUsage ( dataRes . data ) ;
205+ } catch {
206+ // polling 실패는 무시
207+ }
208+ } , 10000 ) ;
209+
210+ return ( ) => clearInterval ( interval ) ;
211+ // eslint-disable-next-line react-hooks/exhaustive-deps
212+ } , [ lineId , currentDate ] ) ;
213+
192214 const fetchMonthData = async ( newDate : Date ) => {
193215 const yearMonth = formatYearMonth ( newDate ) ;
194216
You can’t perform that action at this time.
0 commit comments