-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSocialGoogle.tsx
More file actions
81 lines (74 loc) · 1.92 KB
/
SocialGoogle.tsx
File metadata and controls
81 lines (74 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, { Suspense, useEffect, useState } from 'react';
import Image from 'next/image';
import styled from 'styled-components';
import { useSearchParams } from 'next/navigation';
import { setLetterUrl } from '@/utils/storage';
import Loader, { LoaderContainer } from '../common/Loader';
const SocialGoogle = () => {
const searchParams = useSearchParams();
const url = searchParams.get('url');
const REST_API_KEY = process.env.NEXT_PUBLIC_REST_API_KEY;
const GOOGLE_URL = '/login/google';
const [absoluteUrl, setabsoluteUrl] = useState('');
useEffect(() => {
if (typeof window !== 'undefined') {
setabsoluteUrl(
window.location.protocol + '//' + window.location.host + '/login/kakao'
);
}
}, []);
const handleLogin = () => {
//이때 localStorage에 저장된 accessToken이 만료되었는지 확인해야함.
// if (accessToken) {
// if (url) {
// router.push(`/verify?url=${url}`);
// } else {
// router.push("/");
// }
// setAccessToken(accessToken);
// } else {
//받은 편지를 통해 들어올 경우 url를 저장한다.
if (url) {
setLetterUrl(url);
}
window.location.href = GOOGLE_URL;
};
return (
<SocialLoginBox onClick={handleLogin}>
<StyledImage
src="/assets/icons/ic_google.svg"
width={33}
height={33}
alt="google"
/>
</SocialLoginBox>
);
};
export default function SocialGooglePaging() {
return (
<Suspense
fallback={
<LoaderContainer>
<Loader />
</LoaderContainer>
}
>
<SocialGoogle />
</Suspense>
);
}
const SocialLoginBox = styled.div`
display: flex;
box-sizing: border-box;
width: 100%;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
`;
const StyledImage = styled(Image)`
width: 100%;
height: 100%;
padding: 0 16px;
object-fit: contain;
`;