TermsCheck.js
6.97 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import React, { Component } from 'react';
import { View, Text, StyleSheet,TouchableOpacity } from 'react-native';
import RNKakao from 'rn-kakao-login';
import CheckBox from '@react-native-community/checkbox'
import AsyncStorage from '@react-native-community/async-storage'
import {post } from 'axios'
import firebase from '@react-native-firebase/messaging';
import { SERVER } from '../../common/servername';
export default class AddTab extends Component {
static navigationOptions = {
headerShown: false
}
state= {
all:false,
SNS:false,
private_info:false,
profile_info:false,
fcmToken:""
}
constructor(props) {
super(props)
}
componentDidMount() {
}
kakaoLogin = async () => {
try {
await firebase().requestPermission();
const fcmToken = await firebase().getToken()
const result = await RNKakao.login();
console.log(result.accessToken)
post(`http://${SERVER}/auth/kakao/join`,{kakao_access_token:result.accessToken}).then(async res => {
if(res.data.success) {
AsyncStorage.setItem("user",JSON.stringify(result))
AsyncStorage.setItem("token",JSON.stringify(res.data.data.token.token))
AsyncStorage.setItem("refreshtoken",JSON.stringify(res.data.data.refresh_token))
post(`http://${SERVER}/auth/kakao/login`,{kakao_access_token:result.accessToken,fcm_token:fcmToken}).then(res => {
this.props.navigation.goBack(null)
})
this.props.navigation.navigate("Main_")
}
else {
const a = await RNKakao.logout()
alert("서버 오류입니다.")
}
console.log(res.data)
})
} catch (e) {
console.log(e)
alert("서버 내부 오류입니다. 다시 시도해주세요.")
}
}
onHandlecheckBox= (type) => {
if(type == "all") {
if(this.state.all == true) {
this.setState({
SNS:false,
all:false,
private_info:false,
profile_info:false
})
}
else {
this.setState({
SNS:true,
all:true,
private_info:true,
profile_info:true
})
}
}
else if(type == "SNS") {
if(this.state.SNS == true) {
this.setState({
SNS:false,
all:false,
})
}
else {
this.setState({
SNS:true
})
}
}
else if(type == "private_info") {
if(this.state.private_info == true) {
this.setState({
private_info:false,
all:false,
})
}
else {
this.setState({
private_info:true
})
}
}
else if(type == "profile_info") {
if(this.state.profile_info == true) {
this.setState({
profile_info:false,
all:false,
})
}
else {
this.setState({
profile_info:true
})
}
}
}
HandleNavigate = () => {
if(this.state.SNS === false || this.state.private_info === false) return alert("필수 약관에 모두 동의해주세요.")
this.kakaoLogin()
}
render() {
return (
<View style={{width:"100%",height:"100%"}}>
<View style={{top:"60%"}}>
<View style={{display:"flex",flexDirection:"row",borderBottomColor:"#615F5F",borderBottomWidth:2,marginLeft:16.4,marginRight:16.4,paddingBottom:16}}>
<CheckBox value={this.state.all} onChange={() => this.onHandlecheckBox("all")} tintColors={{true:'#f4cd37'}} style={{marginTop:-5}}/>
<TouchableOpacity onPress={() =>this.onHandlecheckBox("all")}>
<Text style={{color:"black",fontWeight:"bold",fontSize:14,marginLeft:10}}>
모두 동의
</Text>
</TouchableOpacity>
</View>
<View style={{display:"flex",flexDirection:"row",marginLeft:16.4,marginRight:16.4,marginTop:16}}>
<CheckBox onChange={() => this.onHandlecheckBox("SNS")} value={this.state.SNS} tintColors={{true:'#f4cd37'}} style={{marginTop:-5}}/>
<TouchableOpacity onPress={() => this.onHandlecheckBox("SNS")} >
<Text style={{color:"black",fontWeight:"200",fontSize:14,marginLeft:10}}>
[필수] 카카오계정 약관
</Text>
</TouchableOpacity>
</View>
<View style={{display:"flex",flexDirection:"row",marginLeft:16.4,marginRight:16.4,marginTop:16}}>
<CheckBox onChange={() => this.onHandlecheckBox("private_info")} value={this.state.private_info} tintColors={{true:'#f4cd37'}} style={{marginTop:-5}}/>
<TouchableOpacity onPress={() => this.onHandlecheckBox("private_info")}>
<Text style={{color:"black",fontWeight:"200",fontSize:14,marginLeft:10}}>
[필수] 개인정보 수집 및 이용 동의
</Text>
</TouchableOpacity>
</View>
<View style={{display:"flex",flexDirection:"row",marginLeft:16.4,marginRight:16.4,marginTop:16}}>
<CheckBox onChange={() => this.onHandlecheckBox("profile_info")} value={this.state.profile_info} tintColors={{true:'#f4cd37'}} style={{marginTop:-5}}/>
<TouchableOpacity onPress={() => this.onHandlecheckBox("profile_info")}>
<Text style={{color:"black",fontWeight:"200",fontSize:14,marginLeft:10}}>
[선택] 프로필 정보 추가 수집 동의
</Text>
</TouchableOpacity>
</View>
</View>
<TouchableOpacity onPress={() => this.HandleNavigate()} style={{position:"absolute",bottom:0,width:"100%",backgroundColor:"#FFD63A",paddingTop:21,paddingBottom:19}}>
<Text style={{textAlign:"center"}}>
확인
</Text>
</TouchableOpacity>
</View>
);
}
}
const style = StyleSheet.create({
container: {
}
});