Skip to content

Commit db19331

Browse files
authored
Merge pull request #18 from DevKor-github/feat/#17/get-is-login
[#17] feat: ๋กœ๊ทธ์ธ ๋˜์–ด์žˆ๋Š”์ง€ ์•Œ๋ ค์ฃผ๋Š” ํ›…์„ ๋งŒ๋“ค์—ˆ๋”ฐ
2 parents 01ad4b1 + fd55788 commit db19331

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

โ€Žsrc/common/hooks/apis/useGetIsLogin.tsโ€Ž

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ import client from '@/common/utils/client';
22
import { useQuery } from '@tanstack/react-query';
33

44
const getIsLogin = async () => {
5-
const response = await client.get('/api/test/is-login');
6-
return response.data;
5+
try {
6+
const response = await client.get('/api/test/is-login');
7+
if (response.status === 200) {
8+
if (response.data.data) return true;
9+
}
10+
return false;
11+
} catch {
12+
return false;
13+
}
714
};
815

916
const useGetIsLogin = () => {
1017
return useQuery({
1118
queryKey: ['isLogin'],
1219
queryFn: getIsLogin,
13-
enabled: false,
1420
});
1521
};
1622

โ€Žsrc/pages/HomePage/index.tsxโ€Ž

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,26 @@ import AppScreenWithSafeArea from '@/common/components/AppScreenWithSafeArea';
99
import Chip from '@/common/components/Chip';
1010
import SelectButton from '@/common/components/SelectButton';
1111
import TestAPIButton from '@/common/components/TestAPIButton';
12+
import useGetIsLogin from '@/common/hooks/apis/useGetIsLogin';
1213

1314
const HomePage: ActivityComponentType = () => {
1415
const { push } = useFlow();
16+
const { data: isLogin } = useGetIsLogin();
1517
const [active, setActive] = useState(false);
18+
1619
return (
1720
<AppScreenWithSafeArea>
18-
<h1 className={s.Title}>๋ฆฌํ”ผ์นด ์งฑ</h1>
19-
<h1 className={s.Title}>์Œ ์žฌ๋ฐ‹๋‹ค</h1>
20-
<div className={s.LoginBtn}>
21-
<a href={`${import.meta.env.VITE_API_URL}/oauth2/authorization/kakao`}>์นด์นด์˜คํ†ก ๋กœ๊ทธ์ธ</a>
22-
<a href={`${import.meta.env.VITE_API_URL}/oauth2/authorization/google`}>๊ตฌ๊ธ€ ๋กœ๊ทธ์ธ</a>
23-
<i className={s.Container}>๋ฐฑ์—”๋“œ์—๋ชฝ ๋กœ๊ทธ์ธ ๊ณ ์ณ์ค˜</i>
24-
<TestAPIButton />
21+
<div className={s.Wrapper}>
22+
<h1 className={s.Title}>๋ฆฌํ”ผ์นด ์งฑ</h1>
23+
<h1 className={s.Title}>์Œ ์žฌ๋ฐ‹๋‹ค</h1>
24+
{isLogin ? (
25+
<TestAPIButton />
26+
) : (
27+
<div className={s.LoginBtn}>
28+
<a href={`${import.meta.env.VITE_API_URL}/oauth2/authorization/kakao`}>์นด์นด์˜คํ†ก ๋กœ๊ทธ์ธ</a>
29+
<a href={`${import.meta.env.VITE_API_URL}/oauth2/authorization/google`}>๊ตฌ๊ธ€ ๋กœ๊ทธ์ธ</a>
30+
</div>
31+
)}
2532
<button onClick={() => push('PostPage', {})}>์ด๋™</button>
2633
</div>
2734
<Chip color="main">์ถ•๊ตฌ</Chip>

โ€Žsrc/pages/HomePage/style.css.tsโ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { css } from '@styled-system/css';
22

33
// ์ด๋Ÿฐ ์‹์œผ๋กœ CSS ํŒŒ์ผ ๋ถ„๋ฆฌํ•ด์„œ ์“ฐ๊ธฐ
44

5+
export const Wrapper = css({ display: 'flex', flexDirection: 'column', gap: '1rem' });
6+
57
export const Title = css({
68
color: 'main',
79
});

0 commit comments

Comments
ย (0)