Skip to content

Commit

Permalink
fix: LoginBottomSheet type 충돌 문제 type state로 관리하여 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
lsy20140 committed Oct 8, 2024
1 parent 4cc1526 commit c4993b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/domain/home/learning/TodayQuiz/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ export default function TodayQuiz() {
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')
}
}, [userId, openBottomSheet, skipLogin])
}, [skipLogin, openBottomSheet, userId])

const handleClick = () => {
if (!userId) {
openBottomSheet('login')
setLoginSheetType('loginBtn')
return
}
router.push('/') // quiz url로 변경
Expand Down Expand Up @@ -66,7 +71,10 @@ export default function TodayQuiz() {
/>
</div>
</div>
<LoginBottomSheet isOpen={bottomSheetType === 'login'} type="loginBtn" />
<LoginBottomSheet
isOpen={bottomSheetType === 'login'}
type={loginSheetType}
/>
</>
)
}

0 comments on commit c4993b3

Please sign in to comment.