import React, {useEffect, useState} from 'react'; import Button from '../component/Button'; import Input from '../component/Input'; import {Picker} from '@react-native-picker/picker'; import {View, StyleSheet, Text, ScrollView} from 'react-native'; import {HelperText} from 'react-native-paper'; import { container, ItemFlex, ItemFlex2, direction, pageTitleBox, pageTitle, textColor, } from '../resoureces/styles/GlobalStyles'; export default function JoinMembers({navigation}) { /* 퉥스트 입력 */ const [userId, setUserId] = useState(''); const [userPassword, setUserPassword] = useState(); const [userPasswordCked, setUserPasswordCked] = useState(); const [name, setName] = useState(); const [year, setYear] = useState(); const [month, setMonth] = useState(); const [day, setDay] = useState(); const [phone, setPhone] = useState(); const [email, setEmail] = useState(); const [selectedLanguage, setSelectedLanguage] = useState(); const [userSex, setUserSex] = useState(); const [idchecked, setIdChecked] = useState(false); const [pwChecked, setPwChecked] = useState(false); const joinFetchData = () => { fetch('http://192.168.0.138:80/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ id: userId, password: userPassword, email: email, user_sex: userSex, phone: phone, }), }) .then(response => response.json()) .then(data => { console.log(data); if (data.Authorization === userId) { alert('회원가입이 완료되었습니다.'); navigation.navigate('Login'); } else { alert('입력 정보를 확인해주세요.'); } }) .catch(err => { console.error(err); }); }; const validation = () => { fetch('http://192.168.0.138:80/auth/id', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ id: userId, }), }) .then(response => response.json()) .then(data => { if (data.message === 'Success') { setIdChecked(true); } else { setIdChecked(false); } }) .catch(err => { console.error(err); }); }; return ( 회원가입 아이디 { setUserId(userId); }} onBlur={validation()} /> {userId === '' ? ( '' ) : idchecked ? ( 사용 가능한 아이디 입니다. ) : ( 이미 사용중인 아이디 입니다. )} 비밀번호 { setUserPassword(userPassword); }} secureTextEntry={true} /> 비밀번호 확인 { setUserPasswordCked(userPasswordCked); }} secureTextEntry={true} /> {userPasswordCked === '' || userPasswordCked === userPassword ? ( '' ) : ( 비밀번호를 다시 확인해주세요. )} 이름 { setName(name); }} /> 생년월일 { setYear(year); }} /> { setMonth(month); }} /> { setDay(day); }} /> 성별 setUserSex(itemValue)}> 휴대전화 setSelectedLanguage(itemValue) }> { setPhone(phone); }} />