Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 54 additions & 55 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import { BadgeSection } from './domains/badge'
import CatchmindLobbyPage from './domains/games/pages/CatchmindLobbyPage'
import CatchmindWaitingPage from './domains/games/pages/CatchmindWaitingPage'
import CatchmindPlayPage from './domains/games/pages/CatchmindPlayPage'
import {NewsListPage, NewsDetailPage, NewsQuizPage, NewsWordsPage, NewsStatsPage} from './domains/news'
import {dailyService, statsService} from './domains/vocab/services/vocabService'
import {getNewsStats, getDashboardStats} from './domains/news/services/newsService'
import {useChat} from './contexts/ChatContext'
import {useSettings} from './contexts/SettingsContext'
import {useAuth} from './contexts/AuthContext'
import { NewsListPage, NewsDetailPage, NewsQuizPage, NewsWordsPage, NewsStatsPage } from './domains/news'
import { dailyService, statsService } from './domains/vocab/services/vocabService'
import { getNewsStats, getDashboardStats } from './domains/news/services/newsService'
import { useChat } from './contexts/ChatContext'
import { useSettings } from './contexts/SettingsContext'
import { useAuth } from './contexts/AuthContext'
import LoginPage from './pages/Login'
import SignUpPage from './pages/SignUp'

Expand Down Expand Up @@ -93,8 +93,7 @@ function PublicRoute({ children }) {
function Dashboard() {
const navigate = useNavigate()
const [expandedCard, setExpandedCard] = useState(null)
const { t } = useSettings()
const {t, isKorean} = useSettings()
const { t, isKorean } = useSettings()
const [activityData, setActivityData] = useState(null)
const [loadingActivity, setLoadingActivity] = useState(true)

Expand Down Expand Up @@ -467,14 +466,14 @@ function Dashboard() {
</Grid>

{/* Today's Activity Stats */}
<Box sx={{mt: 6}}>
<Box sx={{ mt: 6 }}>
{loadingActivity ? (
<Grid container spacing={2}>
{[...Array(4)].map((_, i) => (
<Grid key={i} size={{xs: 6, md: 3}}>
<Card sx={{borderRadius: '16px', height: 140}}>
<CardContent sx={{p: 2.5, textAlign: 'center'}}>
<CircularProgress size={24}/>
<Grid key={i} size={{ xs: 6, md: 3 }}>
<Card sx={{ borderRadius: '16px', height: 140 }}>
<CardContent sx={{ p: 2.5, textAlign: 'center' }}>
<CircularProgress size={24} />
</CardContent>
</Card>
</Grid>
Expand All @@ -483,7 +482,7 @@ function Dashboard() {
) : (
<Grid container spacing={2}>
{/* 오늘 외운 단어 */}
<Grid size={{xs: 6, md: 3}}>
<Grid size={{ xs: 6, md: 3 }}>
<Card
onClick={() => navigate('/vocab')}
sx={{
Expand All @@ -497,7 +496,7 @@ function Dashboard() {
},
}}
>
<CardContent sx={{p: 2.5, textAlign: 'center'}}>
<CardContent sx={{ p: 2.5, textAlign: 'center' }}>
<Box
sx={{
width: 48,
Expand All @@ -511,7 +510,7 @@ function Dashboard() {
mb: 1.5,
}}
>
<VocabIcon sx={{color: '#f97316', fontSize: 24}}/>
<VocabIcon sx={{ color: '#f97316', fontSize: 24 }} />
</Box>
<Typography variant="h4" fontWeight={800} color="#f97316">
{activityData?.todayWords || 0}
Expand All @@ -528,7 +527,7 @@ function Dashboard() {
</Card>
</Grid>
{/* 읽은 뉴스 */}
<Grid size={{xs: 6, md: 3}}>
<Grid size={{ xs: 6, md: 3 }}>
<Card
onClick={() => navigate('/news')}
sx={{
Expand All @@ -542,7 +541,7 @@ function Dashboard() {
},
}}
>
<CardContent sx={{p: 2.5, textAlign: 'center'}}>
<CardContent sx={{ p: 2.5, textAlign: 'center' }}>
<Box
sx={{
width: 48,
Expand All @@ -556,7 +555,7 @@ function Dashboard() {
mb: 1.5,
}}
>
<NewsIcon sx={{color: '#8b5cf6', fontSize: 24}}/>
<NewsIcon sx={{ color: '#8b5cf6', fontSize: 24 }} />
</Box>
<Typography variant="h4" fontWeight={800} color="#8b5cf6">
{activityData?.newsRead || 0}
Expand All @@ -568,7 +567,7 @@ function Dashboard() {
</Card>
</Grid>
{/* 총 학습 단어 */}
<Grid size={{xs: 6, md: 3}}>
<Grid size={{ xs: 6, md: 3 }}>
<Card
onClick={() => navigate('/vocab/words')}
sx={{
Expand All @@ -582,7 +581,7 @@ function Dashboard() {
},
}}
>
<CardContent sx={{p: 2.5, textAlign: 'center'}}>
<CardContent sx={{ p: 2.5, textAlign: 'center' }}>
<Box
sx={{
width: 48,
Expand All @@ -596,7 +595,7 @@ function Dashboard() {
mb: 1.5,
}}
>
<WordListIcon sx={{color: '#f97316', fontSize: 24}}/>
<WordListIcon sx={{ color: '#f97316', fontSize: 24 }} />
</Box>
<Typography variant="h4" fontWeight={800} color="#f97316">
{activityData?.totalWords || 0}
Expand All @@ -608,7 +607,7 @@ function Dashboard() {
</Card>
</Grid>
{/* 연속 학습 */}
<Grid size={{xs: 6, md: 3}}>
<Grid size={{ xs: 6, md: 3 }}>
<Card
onClick={() => navigate('/reports')}
sx={{
Expand All @@ -622,7 +621,7 @@ function Dashboard() {
},
}}
>
<CardContent sx={{p: 2.5, textAlign: 'center'}}>
<CardContent sx={{ p: 2.5, textAlign: 'center' }}>
<Box
sx={{
width: 48,
Expand All @@ -636,7 +635,7 @@ function Dashboard() {
mb: 1.5,
}}
>
<LearnIcon sx={{color: '#ec4899', fontSize: 24}}/>
<LearnIcon sx={{ color: '#ec4899', fontSize: 24 }} />
</Box>
<Typography variant="h4" fontWeight={800} color="#ec4899">
{Math.max(activityData?.vocabStreak || 0, activityData?.newsStreak || 0)}
Expand Down Expand Up @@ -666,7 +665,7 @@ function OpicPage() {


function ReportsPage() {
const {isKorean} = useSettings()
const { isKorean } = useSettings()
const [loading, setLoading] = useState(true)
const [stats, setStats] = useState({
totalStudyDays: 0,
Expand All @@ -685,7 +684,7 @@ function ReportsPage() {
setLoading(true)
const [vocabStatsRes, vocabHistoryRes, newsStatsRes] = await Promise.allSettled([
statsService.getOverall().catch(() => null),
statsService.getDaily(null, {limit: 30}).catch(() => null),
statsService.getDaily(null, { limit: 30 }).catch(() => null),
getNewsStats().catch(() => null),
])

Expand Down Expand Up @@ -719,9 +718,9 @@ function ReportsPage() {

if (loading) {
return (
<Container maxWidth="lg" sx={{py: 4}}>
<Container maxWidth="lg" sx={{ py: 4 }}>
<Box display="flex" justifyContent="center" alignItems="center" minHeight="40vh">
<CircularProgress/>
<CircularProgress />
</Box>
</Container>
)
Expand Down Expand Up @@ -815,13 +814,13 @@ function ReportsPage() {

{/* 뉴스 학습 통계 */}
{(stats.newsRead > 0 || stats.newsQuizScore > 0) && (
<Card sx={{p: 3, borderRadius: '20px', mb: 4, backgroundColor: '#f5f3ff'}}>
<Card sx={{ p: 3, borderRadius: '20px', mb: 4, backgroundColor: '#f5f3ff' }}>
<Typography variant="h6" fontWeight={700} gutterBottom color="#8b5cf6">
{isKorean ? '뉴스 학습' : 'News Learning'}
</Typography>
<Grid container spacing={3}>
<Grid size={{xs: 6}}>
<Box sx={{textAlign: 'center'}}>
<Grid size={{ xs: 6 }}>
<Box sx={{ textAlign: 'center' }}>
<Typography variant="h3" fontWeight={800} color="#8b5cf6">
{stats.newsRead}
</Typography>
Expand All @@ -830,8 +829,8 @@ function ReportsPage() {
</Typography>
</Box>
</Grid>
<Grid size={{xs: 6}}>
<Box sx={{textAlign: 'center'}}>
<Grid size={{ xs: 6 }}>
<Box sx={{ textAlign: 'center' }}>
<Typography variant="h3" fontWeight={800} color="#8b5cf6">
{stats.newsQuizScore}%
</Typography>
Expand Down Expand Up @@ -1161,27 +1160,27 @@ function App() {
<MainLayout />
</ProtectedRoute>
}>
<Route path="/" element={<Dashboard/>}/>
<Route path="/dashboard" element={<Dashboard/>}/>
<Route path="/opic" element={<OpicPage/>}/>
<Route path="/freetalk/people" element={<FreetalkPeoplePage/>}/>
<Route path="/freetalk/ai" element={<FreetalkAiPage/>}/>
<Route path="/writing" element={<WritingPage/>}/>
<Route path="/vocab" element={<VocabDashboard/>}/>
<Route path="/vocab/daily" element={<DailyLearning/>}/>
<Route path="/vocab/test" element={<TestPage/>}/>
<Route path="/vocab/words" element={<WordListPage/>}/>
<Route path="/vocab/stats" element={<StatsPage/>}/>
<Route path="/reports" element={<ReportsPage/>}/>
<Route path="/settings" element={<SettingsPage/>}/>
<Route path="/games/catchmind" element={<CatchmindLobbyPage/>}/>
<Route path="/games/catchmind/:roomId/waiting" element={<CatchmindWaitingPage/>}/>
<Route path="/games/catchmind/:roomId/play" element={<CatchmindPlayPage/>}/>
<Route path="/news" element={<NewsListPage/>}/>
<Route path="/news/:articleId" element={<NewsDetailPage/>}/>
<Route path="/news/:articleId/quiz" element={<NewsQuizPage/>}/>
<Route path="/news/words" element={<NewsWordsPage/>}/>
<Route path="/news/stats" element={<NewsStatsPage/>}/>
<Route path="/" element={<Dashboard />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/opic" element={<OpicPage />} />
<Route path="/freetalk/people" element={<FreetalkPeoplePage />} />
<Route path="/freetalk/ai" element={<FreetalkAiPage />} />
<Route path="/writing" element={<WritingPage />} />
<Route path="/vocab" element={<VocabDashboard />} />
<Route path="/vocab/daily" element={<DailyLearning />} />
<Route path="/vocab/test" element={<TestPage />} />
<Route path="/vocab/words" element={<WordListPage />} />
<Route path="/vocab/stats" element={<StatsPage />} />
<Route path="/reports" element={<ReportsPage />} />
<Route path="/settings" element={<SettingsPage />} />
<Route path="/games/catchmind" element={<CatchmindLobbyPage />} />
<Route path="/games/catchmind/:roomId/waiting" element={<CatchmindWaitingPage />} />
<Route path="/games/catchmind/:roomId/play" element={<CatchmindPlayPage />} />
<Route path="/news" element={<NewsListPage />} />
<Route path="/news/:articleId" element={<NewsDetailPage />} />
<Route path="/news/:articleId/quiz" element={<NewsQuizPage />} />
<Route path="/news/words" element={<NewsWordsPage />} />
<Route path="/news/stats" element={<NewsStatsPage />} />
</Route>

{/* 404 */}
Expand Down
Loading