Skip to content

Commit

Permalink
Merge pull request #125 from kakao-tech-campus-2nd-step3/fix-login-error
Browse files Browse the repository at this point in the history
Fix login error
  • Loading branch information
ppochaco authored Nov 7, 2024
2 parents e6620ef + 4bdfb82 commit 4a27458
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
13 changes: 13 additions & 0 deletions src/api/services/user/login.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@ export const useKakaoLogin = ({ code }: KakaoLoginParam) => {
queryFn: () => kakaoLogin({ code }),
})
}

const login = async () => {
await fetchInstance.get('/api/user/login')
}

export const useLogin = () => {
return useQuery({
queryKey: ['login'],
queryFn: () => login(),
refetchOnWindowFocus: false,
enabled: false,
})
}
36 changes: 18 additions & 18 deletions src/pages/LoginPage/KakaoLoginButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { Link } from 'react-router-dom'

import { Flex, Image, Text } from '@chakra-ui/react'

import { useLogin } from '@/api/services/user/login.api'
import KakaoSymbol from '@/assets/kakao-logo-symbol.svg'

export const KakaoLoginButton = () => {
const { refetch } = useLogin()

return (
<Link to="/api/user/login">
<Flex
background="kakao"
rounded="6px"
justifyContent="center"
alignItems="center"
height={10}
gap={3}
_hover={{ cursor: 'pointer' }}
>
<Image src={KakaoSymbol} width={5} />
<Text fontSize="14px" fontWeight="bold" color="rgba(0, 0, 0, 0.85)">
카카오 로그인
</Text>
</Flex>
</Link>
<Flex
background="kakao"
rounded="6px"
justifyContent="center"
alignItems="center"
height={10}
gap={3}
_hover={{ cursor: 'pointer' }}
onClick={() => refetch()}
>
<Image src={KakaoSymbol} width={5} />
<Text fontSize="14px" fontWeight="bold" color="rgba(0, 0, 0, 0.85)">
카카오 로그인
</Text>
</Flex>
)
}

0 comments on commit 4a27458

Please sign in to comment.