Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 60 additions & 23 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,79 @@
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 = <Splash />;
} else if (this.props.userStore.userStatus === USER_STATUS.GUEST) {
let view;
if (props.userStore.userStatus === USER_STATUS.READY) {
view = <Splash />;
} else if (props.userStore.userStatus === USER_STATUS.GUEST) {
if (accessToken != null) {
console.log(`accessToken2 : ${accessToken}`);
view = <Main />;
} else {
console.log(`accessToken2 : ${accessToken}`);
view = <Entrance />;
} 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 = <Main />;
} else {
console.log(`accessToken2 : ${accessToken}`);
view = <Entrance />;
}
return <View style={styles.body}>{view}</View>;
}
}
return <View style={styles.body}>{view}</View>;
};

const styles = StyleSheet.create({
body: {
flex: 1,
},
});

export default App;
export default inject('userStore', 'friendListStore')(observer(App));
7 changes: 7 additions & 0 deletions app/src/dto/AuthDto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default class AuthDto {
accessToken;

constructor(data = {}) {
Object.assign(this, data);
}
}
18 changes: 8 additions & 10 deletions app/src/dto/GroupingCreationDto.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
8 changes: 4 additions & 4 deletions app/src/repository/GroupCreationRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
})
Expand Down
11 changes: 7 additions & 4 deletions app/src/repository/SignRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -150,6 +152,7 @@ export default class SignRepository {
return;
}

return new GroupingUserDto(commonResponse.data);
await new AuthDto(commonResponse.data);
await new GroupingUserDto(commonResponse.data);
}
}
4 changes: 3 additions & 1 deletion app/src/store/GroupingCreationMainStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = '';
Expand All @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions app/src/table/AuthTable.js
Original file line number Diff line number Diff line change
@@ -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?',
},
};
38 changes: 18 additions & 20 deletions app/src/table/GroupTable.js
Original file line number Diff line number Diff line change
@@ -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,
});
});
};
Expand All @@ -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',
},
};
3 changes: 1 addition & 2 deletions app/src/table/UserTable.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const NewGroupMoreInfoView = (props) => {
return (
<View
style={{
backgroundColor: COLORS.WHITE,
flex: 1,
paddingLeft: 30 * WINDOW_SIZE.WIDTH_WEIGHT,
paddingTop: 30 * WINDOW_SIZE.HEIGHT_WEIGHT,
Expand Down
2 changes: 1 addition & 1 deletion app/src/view/sign/components/PhoneCodeInputTextView.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PhoneCodeInputTextView extends React.Component {
textContentType="creditCardNumber"
onFocus={this.handleFocus}
blurOnSubmit
placeholder="숫자6자리"
placeholder="인증번호 입력"
/>
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion app/src/view/sign/signUp/SignUpPhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const SignUpPhone = (props) => {
<View style={styles.inner}>
<ScrollView style={styles.contentContainer}>
<View style={styles.textArea}>
<Text style={styles.title}>휴대폰 번호를 입력해주세요</Text>
<Text style={styles.title}>휴대폰 번호를 입력해주세요.</Text>
<Text
style={{
fontSize: 12 * WINDOW_SIZE.HEIGHT_WEIGHT,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^10.3.1",
"react-native-wheel-picker-android": "^2.0.6",
"realm": "^6.0.2",
"realm": "^6.1.5",
"rn-swipeable-panel": "^1.2.0"
},
"devDependencies": {
Expand Down