diff --git a/App.js b/App.js index efa7a04..cfd69e0 100644 --- a/App.js +++ b/App.js @@ -1,37 +1,74 @@ -import { StyleSheet, Text, View } from 'react-native'; -import React, { Component } from 'react'; -import { inject, observer, Provider } from 'mobx-react'; +import { StyleSheet, View } from 'react-native'; +import React, { useEffect } from 'react'; +import { inject, observer } from 'mobx-react'; +import Realm from 'realm'; +import AuthTable from './app/src/table/AuthTable'; import Splash from './app/src/view/Splash'; import { USER_STATUS } from './app/src/constant/UserStatus'; import Main from './app/src/view/main/Main'; import Entrance from './app/src/view/entrance/Entrance'; -import { WINDOW_SIZE } from './app/src/constant/WindowSize'; -import SignUpPhone from './app/src/view/sign/signUp/SignUpPhone'; - -@inject('userStore', 'friendListStore') -@observer -class App extends Component { - // 컴포넌트가 만들어지고 첫 렌더링을 다 마친 후 실행되는 메소드입니다. - // 이 안에서 다른 JavaScript 프레임워크를 연동하거나, - // setTimeout, setInterval 및 AJAX 처리 등을 넣습니다. - async componentDidMount() { + +const App = (props) => { + let accessToken = null; + + const getAccessToken = async () => { + await Realm.open({ schema: [AuthTable] }) + .then((realm) => { + return realm.objects('Auth').sorted('accessToken'); + }) + .catch(() => { + console.log('can not open table'); + }); + return null; + }; + + useEffect(() => { + const testAccessToken = async (testToken: String) => { + console.log(`input value : ${testToken}`); + await Realm.open({ schema: [AuthTable] }) + .then((realm) => { + realm.write(() => { + realm.create('Auth', { accessToken: testToken }); + accessToken = getAccessToken(); + console.log(accessToken); + }); + }) + .catch(() => { + console.log('can not write table'); + }); + }; + + testAccessToken('nothing').then(); + }, []); + + /* async componentDidMount() { // eslint-disable-next-line react/prop-types,react/destructuring-assignment // await this.props.userStore.ready(); // await this.props.friendListStore.ready(); - } + } */ - render() { - let view; - if (this.props.userStore.userStatus === USER_STATUS.READY) { - view = ; - } else if (this.props.userStore.userStatus === USER_STATUS.GUEST) { + let view; + if (props.userStore.userStatus === USER_STATUS.READY) { + view = ; + } else if (props.userStore.userStatus === USER_STATUS.GUEST) { + if (accessToken != null) { + console.log(`accessToken2 : ${accessToken}`); + view =
; + } else { + console.log(`accessToken2 : ${accessToken}`); view = ; - } else if (this.props.userStore.userStatus === USER_STATUS.USER) { + } + } else if (props.userStore.userStatus === USER_STATUS.USER) { + if (accessToken != null) { + console.log(`accessToken2 : ${accessToken}`); view =
; + } else { + console.log(`accessToken2 : ${accessToken}`); + view = ; } - return {view}; } -} + return {view}; +}; const styles = StyleSheet.create({ body: { @@ -39,4 +76,4 @@ const styles = StyleSheet.create({ }, }); -export default App; +export default inject('userStore', 'friendListStore')(observer(App)); diff --git a/app/src/dto/AuthDto.js b/app/src/dto/AuthDto.js new file mode 100644 index 0000000..99a13d6 --- /dev/null +++ b/app/src/dto/AuthDto.js @@ -0,0 +1,7 @@ +export default class AuthDto { + accessToken; + + constructor(data = {}) { + Object.assign(this, data); + } +} diff --git a/app/src/dto/GroupingCreationDto.js b/app/src/dto/GroupingCreationDto.js index de0a284..37a20a5 100644 --- a/app/src/dto/GroupingCreationDto.js +++ b/app/src/dto/GroupingCreationDto.js @@ -1,27 +1,25 @@ export default class GroupingCreationDto { - title; + availableGender; - isHidden; + description; - minUserAge; + hashtagList; + + isHidden; maxUserAge; - availableGender; + minUserAge; - description; + pointDescription; pointX; pointY; - pointDescription; - representGroupingUserId; - hashtagList = []; - - representGroupImage; + title; constructor(data = {}) { Object.assign(this, data); diff --git a/app/src/repository/GroupCreationRepository.js b/app/src/repository/GroupCreationRepository.js index 055f679..51db5b6 100644 --- a/app/src/repository/GroupCreationRepository.js +++ b/app/src/repository/GroupCreationRepository.js @@ -7,9 +7,9 @@ import GroupingCreationDto from '../dto/GroupingCreationDto'; const TARGET_URL = `${GROUP_URL}`; export default class GroupCreationRepository { - async completeGroupCreation(groupingCreationDto, failedCallback) { + async completeGroupCreation(requestDto, failedCallback) { const response = await axios - .post(`${TARGET_URL}`, groupingCreationDto) + .post(`${TARGET_URL}`, requestDto) .then(() => { console.log('group creation complete'); console.log(response); @@ -24,11 +24,11 @@ export default class GroupCreationRepository { return new GroupingCreationDto(commonResponse.data); } - async completeGroupRepresentImgUpload(groupingUserId, uri, failedCallback) { + async completeGroupRepresentImgUpload(groupId, uri, failedCallback) { const imageFile = new FormData(); imageFile.append('imageFile', uri.content); const response = await axios - .post(`${TARGET_URL}/image`, groupingUserId, imageFile) + .post(`${TARGET_URL}/image`, groupId, imageFile) .then(() => { console.log('group represent img upload complete'); }) diff --git a/app/src/repository/SignRepository.js b/app/src/repository/SignRepository.js index 50e078c..b969b47 100644 --- a/app/src/repository/SignRepository.js +++ b/app/src/repository/SignRepository.js @@ -5,6 +5,7 @@ import CheckEmailResponseDto from '../dto/CheckEmailResponseDto'; import CheckPhoneNumberResponseDto from '../dto/CheckPhoneNumberResponseDto'; import { ResponseCode } from '../constant/ResponseCode'; import GroupingUserDto from '../dto/GroupingUserDto'; +import AuthDto from '../dto/AuthDto'; const TARGET_URL = `${SIGN_URL}`; @@ -115,12 +116,12 @@ export default class SignRepository { const commonResponse = new CommonResponse(response.data); if (commonResponse.code !== ResponseCode.SUCCEED) { - commonResponse.data; failedCallback(commonResponse.code); return; } - return new GroupingUserDto(commonResponse.data); + await new AuthDto(commonResponse.data); + await new GroupingUserDto(commonResponse.data); } async signInWithEmail(email, password, failedCallback) { @@ -135,7 +136,8 @@ export default class SignRepository { return; } - return new GroupingUserDto(commonResponse.data); + await new AuthDto(commonResponse.data); + await new GroupingUserDto(commonResponse.data); } async signInWithPhone(phoneNumber, password, failedCallback) { @@ -150,6 +152,7 @@ export default class SignRepository { return; } - return new GroupingUserDto(commonResponse.data); + await new AuthDto(commonResponse.data); + await new GroupingUserDto(commonResponse.data); } } diff --git a/app/src/store/GroupingCreationMainStore.js b/app/src/store/GroupingCreationMainStore.js index 35acd30..3c2477b 100644 --- a/app/src/store/GroupingCreationMainStore.js +++ b/app/src/store/GroupingCreationMainStore.js @@ -224,6 +224,7 @@ export default class GroupingCreationMainStore { } ); console.log(`response : ${response.data.code}`); + console.log(`groupingUserId : ${this.groupingUserId}`); await this.groupCreationRepository.completeGroupRepresentImgUpload( this.groupingUserId, this.getBackgroundImageURI, @@ -301,6 +302,7 @@ export default class GroupingCreationMainStore { @action initialize() { this.groupingUserId = new GroupingUserDto().groupingUserId; + console.log(`initialize create new group progress : groupingUserId : ${this.groupingUserId}`); this.groupingTitle = ''; this.groupingKeyword = ''; this.groupingDescription = ''; @@ -312,7 +314,7 @@ export default class GroupingCreationMainStore { this.groupingDescriptionCompleted = false; this.groupingAddressCompleted = false; this.groupingCreationDto = new GroupingCreationDto(); - this.groupingCreationDto.representGroupingUserId = new GroupingUserDto().groupingUserId; + this.groupingCreationDto.representGroupingUserId = this.groupingUserId; this.groupingCreationDto.isHidden = false; this.groupingCreationDto.pointX = 100; this.groupingCreationDto.pointY = 100; diff --git a/app/src/table/AuthTable.js b/app/src/table/AuthTable.js new file mode 100644 index 0000000..f85c49d --- /dev/null +++ b/app/src/table/AuthTable.js @@ -0,0 +1,19 @@ +import Realm from 'realm'; +import AuthDto from '../dto/AuthDto'; + +export default class AuthTable { + create = async (authDto: AuthDto) => { + await Realm.open({ schema: [AuthTable] }).then((realm) => { + return realm.create('Auth', { + accessToken: authDto.accessToken, + }); + }); + }; +} + +AuthTable.schema = { + name: 'Auth', + properties: { + accessToken: 'string?', + }, +}; diff --git a/app/src/table/GroupTable.js b/app/src/table/GroupTable.js index d7a3e35..a791589 100644 --- a/app/src/table/GroupTable.js +++ b/app/src/table/GroupTable.js @@ -1,22 +1,21 @@ +import Realm from 'realm'; import GroupingCreationDto from '../dto/GroupingCreationDto'; -const Realm = require('realm'); - export default class GroupTable { create = async (groupingCreationDto: GroupingCreationDto) => { await Realm.open({ schema: [GroupTable] }).then((realm) => { return realm.create('Group', { title: groupingCreationDto.title, + description: groupingCreationDto.description, + pointDescription: groupingCreationDto.pointDescription, isHidden: groupingCreationDto.isHidden, - minAge: groupingCreationDto.minAge, - maxAge: groupingCreationDto.maxAge, - gender: groupingCreationDto.gender, + minUserAge: groupingCreationDto.minUserAge, + maxUserAge: groupingCreationDto.maxUserAge, + availableGender: groupingCreationDto.availableGender, pointX: groupingCreationDto.pointX, pointY: groupingCreationDto.pointY, - address: groupingCreationDto.address, - backgroundImageURI: groupingCreationDto.backgroundImageURI, - keyword: groupingCreationDto.keyword, - groupLeaderDto: groupingCreationDto.groupLeaderDto, + hashtagList: groupingCreationDto.hashtagList, + representGroupingUserId: groupingCreationDto.representGroupingUserId, }); }); }; @@ -25,17 +24,16 @@ export default class GroupTable { GroupTable.schema = { name: 'Group', properties: { - title: 'string', - isHidden: 'boolean', - minAge: 'int', - maxAge: 'int', - gender: 'string', + availableGender: 'MALE', description: 'string', - pointX: 'long', - pointY: 'long', - address: 'string', - backgroundImageURI: 'string?', - keyword: 'keyword', - groupLeaderDto: '', + hashtagList: ['string'], + isHidden: true, + maxUserAge: 0, + minUserAge: 0, + pointDescription: 'string', + pointX: 0, + pointY: 0, + representGroupingUserId: 'string', + title: 'string', }, }; diff --git a/app/src/table/UserTable.js b/app/src/table/UserTable.js index 9f487c4..a1c9043 100644 --- a/app/src/table/UserTable.js +++ b/app/src/table/UserTable.js @@ -1,7 +1,6 @@ +import Realm from 'realm'; import GroupingUserDto from '../dto/GroupingUserDto'; -const Realm = require('realm'); - export default class UserTable { create = async (groupingUserDto: GroupingUserDto) => { await Realm.open({ schema: [UserTable] }).then((realm) => { diff --git a/app/src/view/main/home/components/creation/NewGroupMoreInfoView.js b/app/src/view/main/home/components/creation/NewGroupMoreInfoView.js index a3809f4..a4072d0 100644 --- a/app/src/view/main/home/components/creation/NewGroupMoreInfoView.js +++ b/app/src/view/main/home/components/creation/NewGroupMoreInfoView.js @@ -121,6 +121,7 @@ const NewGroupMoreInfoView = (props) => { return ( ); diff --git a/app/src/view/sign/signUp/SignUpPhone.js b/app/src/view/sign/signUp/SignUpPhone.js index 300d8fc..58ef45b 100644 --- a/app/src/view/sign/signUp/SignUpPhone.js +++ b/app/src/view/sign/signUp/SignUpPhone.js @@ -103,7 +103,7 @@ const SignUpPhone = (props) => { - 휴대폰 번호를 입력해주세요 + 휴대폰 번호를 입력해주세요.