-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
21 changed files
with
293 additions
and
101 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { get } from '@/lib/axios' | ||
|
||
// 유저 상위 퍼센트 조회 | ||
export async function getUserPrecedence() { | ||
const res = await get<number>('/skill/precedence') | ||
return res | ||
} | ||
|
||
export async function getUserAbility() { | ||
const res = await get('/skill/ability') | ||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { get } from '@/lib/axios' | ||
|
||
export async function getTodayParticipants() { | ||
const res = await get<number>('/learnings/today/participants') | ||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
import { WordsList } from '@/components/domain/home/dictionary/RecentlyAddedWords/data' | ||
import { getUserPrecedence } from '@/api/auth/skill' | ||
import { getTodayParticipants } from '@/api/quiz' | ||
import { getTodayWords } from '@/api/words' | ||
import CommunicationStats from '@/components/domain/home/learning/CommunicationStats' | ||
import TodayQuiz from '@/components/domain/home/learning/TodayQuiz' | ||
import TodayWords from '@/components/domain/home/learning/TodayWords' | ||
import { | ||
HydrationBoundary, | ||
QueryClient, | ||
dehydrate, | ||
} from '@tanstack/react-query' | ||
|
||
export default async function LearningTab() { | ||
const queryClient = new QueryClient() | ||
|
||
await Promise.all([ | ||
queryClient.prefetchQuery({ | ||
queryKey: ['today', 'participants'], | ||
queryFn: getTodayParticipants, | ||
}), | ||
queryClient.prefetchQuery({ | ||
queryKey: ['words', 'today'], | ||
queryFn: getTodayWords, | ||
}), | ||
queryClient.prefetchQuery({ | ||
queryKey: ['skill', 'precedence'], | ||
queryFn: getUserPrecedence, | ||
}), | ||
]) | ||
|
||
export default function LearningTab() { | ||
return ( | ||
<div className="w-full my-12 flex flex-col items-center gap-[60px]"> | ||
<TodayQuiz todaySolvedCnt={50} /> | ||
<TodayWords wordsList={WordsList} /> | ||
<CommunicationStats /> | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<TodayQuiz /> | ||
<TodayWords /> | ||
<CommunicationStats /> | ||
</HydrationBoundary> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { useRouter } from 'next/navigation' | ||
|
||
export default function LoginButton() { | ||
const router = useRouter() | ||
return ( | ||
<> | ||
<div className="px-2 py-1 font-medium text-sm bg-[#47D3AD] text-[#0E121B] rounded-[4px]"> | ||
<button | ||
className="px-2 py-1 font-medium text-sm bg-[#47D3AD] text-[#0E121B] rounded-[4px]" | ||
onClick={() => router.push('/')} | ||
> | ||
로그인 | ||
</div> | ||
</button> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
src/components/domain/home/dictionary/RecentlyAddedWords/data.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/components/domain/home/learning/CommunicationStats/TotalChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 14 additions & 7 deletions
21
src/components/domain/home/learning/CommunicationStats/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 68 additions & 36 deletions
104
src/components/domain/home/learning/TodayQuiz/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,80 @@ | ||
'use client' | ||
import Button from '@/components/common/Button' | ||
import LoginBottomSheet from '@/components/shared/LoginBottomSheet' | ||
import { useGetTodayParticipants } from '@/hooks/quiz/useGetTodayParticipants' | ||
import { useAuthStore } from '@/store/useAuthStore' | ||
import useUIStore from '@/store/useUIStore' | ||
import { getTodayDate } from '@/utils/date' | ||
import Image from 'next/image' | ||
import Link from 'next/link' | ||
import { useRouter } from 'next/navigation' | ||
import { useEffect, useState } from 'react' | ||
|
||
type TodayQuizProps = { | ||
todaySolvedCnt: number | ||
} | ||
export default function TodayQuiz() { | ||
const { participants } = useGetTodayParticipants() | ||
const { userId } = useAuthStore() | ||
const { bottomSheetType, openBottomSheet } = useUIStore() | ||
const router = useRouter() | ||
const [skipLogin, setSkipLogin] = useState<string | null>(null) | ||
const [loginSheetType, setLoginSheetType] = useState< | ||
'loginBtn' | 'learningTab' | ||
>('loginBtn') | ||
|
||
useEffect(() => { | ||
if (typeof window === undefined) return | ||
setSkipLogin(localStorage.getItem('skipLogin')) | ||
if (!userId && skipLogin === 'false') { | ||
openBottomSheet('login') | ||
setLoginSheetType('learningTab') | ||
} | ||
}, [skipLogin, openBottomSheet, userId]) | ||
|
||
export default function TodayQuiz({ todaySolvedCnt }: TodayQuizProps) { | ||
const handleClick = () => { | ||
if (!userId) { | ||
openBottomSheet('login') | ||
setLoginSheetType('loginBtn') | ||
return | ||
} | ||
router.push('/') // quiz url로 변경 | ||
} | ||
return ( | ||
<div className="w-full px-4 text-onSurface-300 "> | ||
<p className="text-h2 text-onSurface-300 mb-3"> | ||
<span className="text-primary-400">{getTodayDate() + ' '}</span> | ||
용어 퀴즈💫 | ||
</p> | ||
<div | ||
className="w-full flex justify-between p-5 rounded-2xl" | ||
style={{ | ||
backgroundImage: | ||
'linear-gradient(120deg, #0FB -25.6%, #3D7DF3 31.25%, #6E32E6 86.98%)', | ||
}} | ||
> | ||
<div className="flex flex-col justify-between text-onSurface-300"> | ||
<p className="text-h1 mb-2">용어 퀴즈</p> | ||
<p className="mb-5"> | ||
오늘 | ||
<span className="text-primary-100 text-h3">{todaySolvedCnt}</span> | ||
명이 퀴즈에 | ||
<br /> | ||
참여했어요. | ||
</p> | ||
<Link href={'#'}> | ||
<Button type="black" width={36 * 4}> | ||
<> | ||
<div className="w-full px-4 text-onSurface-300 "> | ||
<p className="text-h2 text-onSurface-300 mb-3"> | ||
<span className="text-primary-400">{getTodayDate() + ' '}</span> | ||
용어 퀴즈💫 | ||
</p> | ||
<div | ||
className="w-full flex justify-between p-5 rounded-2xl" | ||
style={{ | ||
backgroundImage: | ||
'linear-gradient(120deg, #0FB -25.6%, #3D7DF3 31.25%, #6E32E6 86.98%)', | ||
}} | ||
> | ||
<div className="flex flex-col justify-between text-onSurface-300"> | ||
<p className="text-h1 mb-2">용어 퀴즈</p> | ||
<p className="mb-5"> | ||
오늘 | ||
<span className="text-primary-100 text-h3">{participants}</span> | ||
명이 퀴즈에 | ||
<br /> | ||
참여했어요. | ||
</p> | ||
<Button type="black" width={36 * 4} onClick={handleClick}> | ||
퀴즈 풀러 가기 | ||
</Button> | ||
</Link> | ||
</div> | ||
<Image | ||
alt="quiz_img" | ||
src={'/images/home_quiz.svg'} | ||
width={179} | ||
height={166} | ||
/> | ||
</div> | ||
<Image | ||
alt="quiz_img" | ||
src={'/images/home_quiz.svg'} | ||
width={179} | ||
height={166} | ||
/> | ||
</div> | ||
</div> | ||
<LoginBottomSheet | ||
isOpen={bottomSheetType === 'login'} | ||
type={loginSheetType} | ||
/> | ||
</> | ||
) | ||
} |
Oops, something went wrong.