diff --git a/frontend/issues-inbox.html b/frontend/issues-inbox.html index 67a458a..8e5dddf 100644 --- a/frontend/issues-inbox.html +++ b/frontend/issues-inbox.html @@ -137,10 +137,6 @@

새로 등록된 신고 사항을 확인하고 처리하세요

- -
`; }).join(''); } - // 수신함 통계 로드 (실제 API 연동) + // 통계 로드 (새로운 기준) async function loadStatistics() { try { - const response = await fetch('/api/inbox/statistics', { - headers: { - 'Authorization': `Bearer ${localStorage.getItem('access_token')}`, - 'Content-Type': 'application/json' + // 현재 수신함 이슈들을 기반으로 통계 계산 + const today = new Date(); + const todayStart = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + + // 전체: 수신함에 남아있는 목록 개수 (pending_review 상태) + const totalCount = issues.length; + + // 금일 신규: 오늘 올라온 목록 숫자 (확인된 것 포함) + const todayNewCount = issues.filter(issue => { + const reportDate = new Date(issue.report_date); + return reportDate >= todayStart; + }).length; + + // 금일 처리: 오늘 처리된 건수 (API에서 가져와야 함) + let todayProcessedCount = 0; + try { + const processedResponse = await fetch('/api/inbox/statistics', { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('access_token')}`, + 'Content-Type': 'application/json' + } + }); + if (processedResponse.ok) { + const stats = await processedResponse.json(); + todayProcessedCount = stats.today_processed || 0; } - }); - - if (response.ok) { - const stats = await response.json(); - document.getElementById('newIssuesCount').textContent = stats.pending_review || 0; - document.getElementById('pendingIssuesCount').textContent = stats.total_in_management || 0; - document.getElementById('todayProcessedCount').textContent = stats.today_processed || 0; - document.getElementById('totalIssuesCount').textContent = stats.total_issues || 0; - } else { - console.error('통계 로드 실패'); + } catch (e) { + console.log('처리된 건수 조회 실패:', e); } + + // 미해결: 오늘꺼 제외한 남아있는 것들 + const unresolvedCount = issues.filter(issue => { + const reportDate = new Date(issue.report_date); + return reportDate < todayStart; + }).length; + + // 통계 업데이트 + document.getElementById('totalCount').textContent = totalCount; + document.getElementById('todayNewCount').textContent = todayNewCount; + document.getElementById('todayProcessedCount').textContent = todayProcessedCount; + document.getElementById('unresolvedCount').textContent = unresolvedCount; + + console.log('📊 통계 업데이트:', { + 전체: totalCount, + 금일신규: todayNewCount, + 금일처리: todayProcessedCount, + 미해결: unresolvedCount + }); + } catch (error) { console.error('통계 로드 오류:', error); + // 오류 시 기본값 설정 + document.getElementById('totalCount').textContent = '0'; + document.getElementById('todayNewCount').textContent = '0'; + document.getElementById('todayProcessedCount').textContent = '0'; + document.getElementById('unresolvedCount').textContent = '0'; } } - // 읽음 처리 - function markAsRead(issueId) { - readStatus.add(issueId); - localStorage.setItem('inbox_read_status', JSON.stringify([...readStatus])); - displayIssues(); - } - - // 모두 읽음 처리 - function markAllAsRead() { - filteredIssues.forEach(issue => readStatus.add(issue.id)); - localStorage.setItem('inbox_read_status', JSON.stringify([...readStatus])); - displayIssues(); - } // 새로고침 function refreshInbox() { loadIssues(); } - // 부적합 상세 보기 + // 신고 상세 보기 function viewIssueDetail(issueId) { - markAsRead(issueId); window.location.href = `/issue-view.html#detail-${issueId}`; } @@ -1063,3 +1105,4 @@ +