Skip to content

Commit fbf49ca

Browse files
committed
💄design(#163): 로그인 없이 편지 작성 버튼 추가
1 parent 47e2e63 commit fbf49ca

2 files changed

Lines changed: 96 additions & 7 deletions

File tree

src/app/login/page.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import SocialKakao from '@/components/signup/SocialKakao';
4+
import SocialGoogle from '@/components/signup/SocialGoogle';
45
import { theme } from '@/styles/theme';
56
import styled from 'styled-components';
67
import Image from 'next/image';
@@ -26,17 +27,13 @@ export default function Login() {
2627
/>
2728
</OauthButton>
2829
<OauthButton bgColor="#FFFFFF">
29-
<Image
30-
src="/assets/icons/ic_google.svg"
31-
alt="Google"
32-
width={33}
33-
height={33}
34-
/>
30+
<SocialGoogle />
3531
</OauthButton>
3632
<OauthButton bgColor="#FEE500">
3733
<SocialKakao />
3834
</OauthButton>
3935
</OauthWrapper>
36+
<LetterBtnText>로그인 없이 편지 작성해보기</LetterBtnText>
4037
</ImageWrapper>
4138
</Container>
4239
);
@@ -133,7 +130,7 @@ const OauthWrapper = styled.div`
133130
gap: 24px;
134131
display: flex;
135132
position: absolute;
136-
bottom: 60px;
133+
bottom: 123px;
137134
justify-content: center;
138135
`;
139136

@@ -150,3 +147,12 @@ const OauthButton = styled.button<OauthButtonProps>`
150147
cursor: pointer;
151148
transition: background-color 0.3s;
152149
`;
150+
151+
const LetterBtnText = styled.div`
152+
${(props) => props.theme.fonts.caption02};
153+
color: ${theme.colors.gray400};
154+
position: absolute;
155+
bottom: 69px;
156+
text-decoration-line: underline;
157+
cursor: pointer;
158+
`;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import React, { Suspense, useEffect, useState } from 'react';
2+
import Image from 'next/image';
3+
import styled from 'styled-components';
4+
import { useRouter, useSearchParams } from 'next/navigation';
5+
import { useRecoilState } from 'recoil';
6+
import { accessState } from '@/recoil/accessStore';
7+
import { getAccessToken, setLetterUrl } from '@/utils/storage';
8+
import Loader, { LoaderContainer } from '../common/Loader';
9+
10+
const SocialGoogle = () => {
11+
const searchParams = useSearchParams();
12+
const url = searchParams.get('url');
13+
const REST_API_KEY = process.env.NEXT_PUBLIC_REST_API_KEY;
14+
const GOOGLE_URL = '/login/google';
15+
const [absoluteUrl, setabsoluteUrl] = useState('');
16+
17+
useEffect(() => {
18+
if (typeof window !== 'undefined') {
19+
setabsoluteUrl(
20+
window.location.protocol + '//' + window.location.host + '/login/kakao'
21+
);
22+
}
23+
}, []);
24+
25+
const handleLogin = () => {
26+
//이때 localStorage에 저장된 accessToken이 만료되었는지 확인해야함.
27+
// if (accessToken) {
28+
// if (url) {
29+
// router.push(`/verify?url=${url}`);
30+
// } else {
31+
// router.push("/");
32+
// }
33+
// setAccessToken(accessToken);
34+
// } else {
35+
//받은 편지를 통해 들어올 경우 url를 저장한다.
36+
if (url) {
37+
setLetterUrl(url);
38+
}
39+
window.location.href = GOOGLE_URL;
40+
};
41+
42+
return (
43+
<SocialLoginBox onClick={handleLogin}>
44+
<StyledImage
45+
src="/assets/icons/ic_google.svg"
46+
width={33}
47+
height={33}
48+
alt="google"
49+
/>
50+
</SocialLoginBox>
51+
);
52+
};
53+
54+
export default function SocialGooglePaging() {
55+
return (
56+
<Suspense
57+
fallback={
58+
<LoaderContainer>
59+
<Loader />
60+
</LoaderContainer>
61+
}
62+
>
63+
<SocialGoogle />
64+
</Suspense>
65+
);
66+
}
67+
68+
const SocialLoginBox = styled.div`
69+
display: flex;
70+
box-sizing: border-box;
71+
width: 100%;
72+
cursor: pointer;
73+
display: flex;
74+
justify-content: center;
75+
align-items: center;
76+
`;
77+
78+
const StyledImage = styled(Image)`
79+
width: 100%;
80+
height: 100%;
81+
padding: 0 16px;
82+
object-fit: contain;
83+
`;

0 commit comments

Comments
 (0)