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
2 changes: 2 additions & 0 deletions app/src/component/AgeValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const MAX_AVAILABLE_AGE = 99;
export const MIN_AVAILABLE_AGE = 1;
export default class AgeValidator {
validateAge = (minAge: Number, maxAge: Number) => {

console.log("minAge", minAge, maxAge);
return (
minAge >= MIN_AVAILABLE_AGE &&
minAge <= MAX_AVAILABLE_AGE &&
Expand Down
3 changes: 2 additions & 1 deletion app/src/constant/HttpProperty.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const BASE_URL = 'http://ec2-18-219-75-164.us-east-2.compute.amazonaws.com';
// const BASE_URL = 'http://ec2-18-219-75-164.us-east-2.compute.amazonaws.com';
const BASE_URL = 'http://10.0.2.2:10753'; // for local emulator and local server;
const VERSION = '/v1';

export const SERVER_URL = BASE_URL + VERSION;
Expand Down
7 changes: 7 additions & 0 deletions app/src/dto/AccessTokenDto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default class AccessTokenDto{
accessToken;

constructor(data = {}) {
Object.assign(this, data);
}
}
1 change: 0 additions & 1 deletion app/src/repository/FirebaseRepository.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import auth from '@react-native-firebase/auth';
import { SERVER_URL } from '../constant/HttpProperty';

Expand Down
12 changes: 9 additions & 3 deletions app/src/repository/GroupCreationRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ export default class GroupCreationRepository {
return new GroupingCreationDto(commonResponse.data);
}

async completeGroupRepresentImgUpload(groupingUserId, uri, failedCallback) {
async completeGroupRepresentImgUpload(groupingUserId, uri, fileName, fileType, failedCallback) {
const imageFile = new FormData();
imageFile.append('imageFile', uri.content);
imageFile.append('imageFile', {
name: fileName,
type: fileType,
uri: Platform.OS === 'android' ? uri : uri.replace('file://', ''),
});
const response = await axios
.post(`${TARGET_URL}/image`, groupingUserId, imageFile)
.post(`${TARGET_URL}/image`, groupingUserId, imageFile, {
headers: { 'Content-Type': 'multipart/form-data',}
})
.then(() => {
console.log('group represent img upload complete');
})
Expand Down
18 changes: 10 additions & 8 deletions app/src/repository/SignRepository.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import axios from 'axios';
import { SIGN_URL } from '../constant/HttpProperty';
import {SIGN_URL} from '../constant/HttpProperty';
import CommonResponse from '../dto/CommonResponse';
import CheckEmailResponseDto from '../dto/CheckEmailResponseDto';
import CheckPhoneNumberResponseDto from '../dto/CheckPhoneNumberResponseDto';
import { ResponseCode } from '../constant/ResponseCode';
import {ResponseCode} from '../constant/ResponseCode';
import GroupingUserDto from '../dto/GroupingUserDto';
import AccessTokenDto from '../dto/AccessTokenDto';

const TARGET_URL = `${SIGN_URL}`;

export default class SignRepository {
async checkEmail(email, failedCallback) {
const response = await axios.get(`${TARGET_URL}/email`, {
params: { email },
params: {email},
});
const commonResponse = new CommonResponse(response.data);

Expand All @@ -24,7 +25,7 @@ export default class SignRepository {
}

async enrollEmail(email, failedCallback) {
const response = await axios.post(`${TARGET_URL}/email`, { email });
const response = await axios.post(`${TARGET_URL}/email`, {email});
const commonResponse = new CommonResponse(response.data);

if (commonResponse.code !== ResponseCode.SUCCEED) {
Expand All @@ -35,9 +36,9 @@ export default class SignRepository {
}

async checkPhoneNumber(phoneNumber, failedCallback) {
console.log('checkPhoneNumber1');
console.log('checkPhoneNumber1', TARGET_URL);
const response = await axios.get(`${TARGET_URL}/phone-number`, {
params: { 'phone-number': phoneNumber },
params: {'phone-number': phoneNumber},
});

const commonResponse = new CommonResponse(response.data);
Expand All @@ -51,6 +52,7 @@ export default class SignRepository {
return new CheckPhoneNumberResponseDto(commonResponse.data);
}

// deprecated
async enrollPhoneNumber(phoneNumber, failedCallback) {
console.log('enrollPhoneNumber1');
const response = await axios.post(`${TARGET_URL}/phone-number`, {
Expand Down Expand Up @@ -115,12 +117,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);
console.log("accessToken : "+ commonResponse.data);
return new AccessTokenDto(commonResponse.data);
}

async signInWithEmail(email, password, failedCallback) {
Expand Down
21 changes: 20 additions & 1 deletion app/src/repository/UserRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ import { USER_URL } from '../constant/HttpProperty';
import CommonResponse from '../dto/CommonResponse';
import { ResponseCode } from '../constant/ResponseCode';
import GroupingUserDto from '../dto/GroupingUserDto';

import getRealm from '../table/realm';
const TARGET_URL = `${USER_URL}`;

export default class UserRepository {

async setAccessToken(accessToken) {
const realm = await getRealm();
console.log("realm path : "+ realm.path);

realm.write(()=>{
realm.create('User', {accessToken: accessToken}, 'modified')
});
}

async getUser() {
const realm = await getRealm();
console.log("realm path : "+ realm.path);
let data = realm.objects('User');
console.log("realm result : " + data);
return data;
}


initialize = async () => {
axios
.post(`${TARGET_URL}/auth`, {})
Expand Down
44 changes: 37 additions & 7 deletions app/src/store/GroupingCreationMainStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default class GroupingCreationMainStore {

ageValidator = new AgeValidator();

userStore = new UserStore();

@observable groupingCreationViewStatus = GROUPING_CREATION_VIEW_STATUS.NAME;

@observable groupingCreationDto = new GroupingCreationDto();
Expand Down Expand Up @@ -64,9 +66,11 @@ export default class GroupingCreationMainStore {

// @observable groupingBackgroundImageURI = require('../assets/default_group_image.jpg');
@observable groupingBackgroundImageURI = '';
@observable groupingBackgroundImageType = '';
@observable groupingBackgroundImageName = '';

constructor(groupingStore: GroupingStore) {
this.groupingStore = groupingStore;
constructor(userStore: UserStore) {
this.userStore = userStore;
}

@action groupingInitializeGender = () => {
Expand Down Expand Up @@ -150,13 +154,16 @@ export default class GroupingCreationMainStore {
this.availableAgeChanged = true;
};

@action groupingBackgroundImageChanged = ({ uri }) => {
@action groupingBackgroundImageChanged = ( uri, type, fileName ) => {
console.log("hohoiho", uri, type, fileName);
if (Platform.OS === 'ios') {
const askPermission = async () => {
try {
const result = await request(PERMISSIONS.IOS.PHOTO_LIBRARY);
if (result === RESULTS.GRANTED) {
this.groupingBackgroundImageURI = { uri };
this.groupingBackgroundImageURI = uri;
this.groupingBackgroundImageName = fileName;
this.groupingBackgroundImageType = type;
console.log('background image changed IOS');
console.log(`IOS${this.groupingBackgroundImageURI}`);
}
Expand All @@ -166,7 +173,7 @@ export default class GroupingCreationMainStore {
};
askPermission().then();
}
this.groupingBackgroundImageURI = { uri };
this.groupingBackgroundImageURI = uri ;
console.log('background image changed');
console.log(this.groupingBackgroundImageURI);
};
Expand Down Expand Up @@ -217,16 +224,29 @@ export default class GroupingCreationMainStore {
}

@action groupCreation = async () => {
console.log("groupingCreationDto : ", this.groupingCreationDto.minUserAge, this.groupingCreationDto.maxUserAge);
this.groupingCreationDto.representGroupingUserId
const response = await this.groupCreationRepository.completeGroupCreation(
this.groupingCreationDto,
(responseCode) => {
console.log(`responseCode : ${responseCode}`);
}
);
console.log(`response : ${response.data.code}`);

const representImage = {
uri: this.getBackgroundImageURI,
type: this.getBackgroundImageType,
name: this.getBackgroundImageName,
};

console.log("file of photo : ", representImage);


await this.groupCreationRepository.completeGroupRepresentImgUpload(
this.groupingUserId,
this.getBackgroundImageURI,
this.getBackgroundImageName,
this.getBackgroundImageType,
(responseCode) => {
console.log(`responseCode : ${responseCode}`);
}
Expand Down Expand Up @@ -263,6 +283,14 @@ export default class GroupingCreationMainStore {
return this.groupingBackgroundImageURI;
}

@computed get getBackgroundImageType() {
return this.groupingBackgroundImageType;
}

@computed get getBackgroundImageName() {
return this.groupingBackgroundImageName;
}

@computed get selectedGenderLimitMessage() {
if (this.genderChanged === false) {
return '성별 제한 추가';
Expand Down Expand Up @@ -312,12 +340,14 @@ export default class GroupingCreationMainStore {
this.groupingDescriptionCompleted = false;
this.groupingAddressCompleted = false;
this.groupingCreationDto = new GroupingCreationDto();
this.groupingCreationDto.representGroupingUserId = new GroupingUserDto().groupingUserId;
this.groupingCreationDto.representGroupingUserId = this.userStore.getUserId;
this.groupingCreationDto.isHidden = false;
this.groupingCreationDto.pointX = 100;
this.groupingCreationDto.pointY = 100;
this.groupingCreationDto.hashtagList = [];
this.selectedGender = '';
this.groupingBackgroundImageURI = '';
this.groupingBackgroundImageName = '';
this.groupingBackgroundImageType = '';
}
}
2 changes: 1 addition & 1 deletion app/src/store/GroupingStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class GroupingStore {

groupTable = new GroupTable();

groupingCreation: GroupingCreationDto;
groupingCreation = new GroupingCreationDto();

constructor(mainStore: MainStore) {
this.mainStore = mainStore;
Expand Down
3 changes: 1 addition & 2 deletions app/src/store/ResetPasswordStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class res {
isSucceed = true;
console.log(isSucceed);
} catch (e) {
console.log('인증번호 요청 에러');
console.log('인증번호 요청 에러!');
this.phoneValidationViewStatus = SIGN_UP_PHONE_VIEW_STATUS.PHONE_CODE_SEND_ERROR;
}
if (isSucceed) {
Expand Down Expand Up @@ -181,7 +181,6 @@ export default class res {
return;
}
this.phoneValidationStatus = INPUT_PHONE_STATUS.PHONE_CODE_NOT_FORMATTED;
console.log(phoneCode.toString());
};

@action phoneCodeFocused = (index) => {
Expand Down
8 changes: 6 additions & 2 deletions app/src/store/SignInStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ export default class SignInStore {
};

@action inputTextChanged = (inputText) => {
console.log("phone?", inputText);
this.inputText = inputText;
this.phoneNumberChanged(inputText);
// 입력된 값 이메일 형태일 때
if (this.emailValidator.validateEmail(inputText)) {
this.emailTextChanged(inputText);
} else if (this.phoneValidator.validatePhoneNumber(this.formattedPhoneNumber))
// 입력된 값 핸드폰번호 형태일 때
this.phoneNumberTextChanged(inputText);
this.phoneNumberTextChanged(this.formattedPhoneNumber);

if (
this.emailStatus === INPUT_EMAIL_STATUS.SUCCEED ||
Expand Down Expand Up @@ -141,13 +142,14 @@ export default class SignInStore {
};

@action phoneNumberTextChanged = (text) => {
console.log("isPhone?", text)
if (String(text).length === 0) {
this.phoneStatus = INPUT_PHONE_STATUS.NONE;
this.phoneNumberText = text;
return;
}

if (!this.phoneValidator.validatePhoneNumber(this.formattedPhoneNumber)) {
if (!this.phoneValidator.validatePhoneNumber(text)) {
this.phoneStatus = INPUT_PHONE_STATUS.NOT_FORMATTED;
this.phoneNumberText = text;
return;
Expand Down Expand Up @@ -189,6 +191,7 @@ export default class SignInStore {
}

@action signIn = async () => {
console.log("signIn?", this.inputText, this.passwordText);
if (this.emailStatus === INPUT_EMAIL_STATUS.SUCCEED) {
this.groupingUserDto = await this.signRepository.signInWithEmail(
this.inputText,
Expand All @@ -205,6 +208,7 @@ export default class SignInStore {
}
);
} else if (this.phoneStatus === INPUT_PHONE_STATUS.SUCCEED) {
console.log("signInWithPhone?", this.phoneNumberText, this.passwordText);
this.groupingUserDto = await this.signRepository.signInWithPhone(
this.phoneNumberText,
this.passwordText,
Expand Down
16 changes: 8 additions & 8 deletions app/src/store/SignProcessStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export default class SignProcessStore {
};

@action emailCompleted = async (email) => {
const isSucceed = await this.signRepository.enrollEmail(email, (responseCode) => {});
if (isSucceed) {
// const isSucceed = await this.signRepository.enrollEmail(email, (responseCode) => {});
// if (isSucceed) {
this.groupingUserDto.email = email;
this.signViewStatus = SIGN_VIEW_STATUS.EMAIL_COMPLETED;
}
// }
};

@action passwordCompleted = (password) => {
Expand All @@ -68,20 +68,20 @@ export default class SignProcessStore {
@action birthdayCompleted = async (birthday) => {
this.signViewStatus = SIGN_VIEW_STATUS.BIRTHDAY_COMPLETED;
this.groupingUserDto.birthday = birthday;
const groupingUserDto = await this.signRepository.completeSignUp(
const accessTokenDto = await this.signRepository.completeSignUp(
this.groupingUserDto,
(responseCode) => {}
);
this.userStore.signUpCompleted(groupingUserDto);
this.userStore.signUpCompleted(accessTokenDto);
};

@action phoneCompleted = async (phoneNumber) => {
const isSucceed = await this.signRepository.enrollPhoneNumber(phoneNumber, () => {});
// const isSucceed = await this.signRepository.enrollPhoneNumber(phoneNumber, () => {});

if (isSucceed === true) {
// if (isSucceed === true) {
this.signViewStatus = SIGN_VIEW_STATUS.PHONE_COMPLETED;
this.groupingUserDto.phoneNumber = phoneNumber;
}
// }
};

@action termsAgreementCompleted = async () => {};
Expand Down
Loading