Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Commit

Permalink
#50 Fix conflict with develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidborredom committed Jun 2, 2018
2 parents a2cc26c + 43b4a4c commit 5008958
Show file tree
Hide file tree
Showing 62 changed files with 3,765 additions and 582 deletions.
14 changes: 9 additions & 5 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
rootProject.name = 'LearningTest2'

include ':react-native-facebook-login'
project(':react-native-facebook-login').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-facebook-login/android')

include ':react-native-localization', ':app'
project(':react-native-localization').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localization/android')

include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')

include ':react-native-image-resizer'
project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')

include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')

include ':react-native-localization', ':app'
project(':react-native-localization').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localization/android')

include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')

include ':react-native-facebook-login'
project(':react-native-facebook-login').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-facebook-login/android')

include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
Expand Down
4 changes: 2 additions & 2 deletions app/actions/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export function startLearn(studyType, startLearn, studyID){
}

export function endLearn(postValue){

return (dispatch) => {
fetch('http://www.mocky.io/v2/5af163c63100002a0096c946',{
fetch('https://e-learning-backend.herokuapp.com/api/v1/finishStudy',{
method: 'POST',
headers: {
'Authorization' : 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJJZCI6IjViMGI0ZWYzMjMwZjJmMjMyNjI3NjI4YSIsInJvbGUiOiJVU0VSIn0sImlhdCI6MTUyNzcyNjMwNywiZXhwIjoxNjg1NDI2MzA3fQ.jRQSMxc1AezfuTUFoHitSjQ74sDzUngArzQr8yTlhDM',
'Accept': 'application/json',
'Content-Type': 'application/json',
},
Expand Down
43 changes: 40 additions & 3 deletions app/actions/summary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import { SUMMARY_HOME } from '../lib/constants';
import { SUMMARY_HOME , SUMMARY_TEST , SUMMARY_QUIZ } from '../lib/constants';

//================================ API FETCH ===================================

export function getSummaryRecord(type, topicId, categoryId, studyId){
return (dispatch) => {
fetch('https://e-learning-backend.herokuapp.com/api/v1/lastReview?type=' + type + '&topicId=' + topicId + '&categoryId='+ categoryId +'&studyId='+ studyId,{
method: 'GET',
headers: {
'Authorization' : 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJJZCI6IjViMGI0ZWYzMjMwZjJmMjMyNjI3NjI4YSIsInJvbGUiOiJVU0VSIn0sImlhdCI6MTUyNzcyNjMwNywiZXhwIjoxNjg1NDI2MzA3fQ.jRQSMxc1AezfuTUFoHitSjQ74sDzUngArzQr8yTlhDM',
'Accept': 'application/json',
'Content-Type': 'application/json',
},
}).then(data => data.json())
.then(json => {
if(type == 'QUIZ'){
dispatch(summaryRecordQuizDispatch(json, type))
}else{
dispatch(summaryRecordTestDispatch(json, type))
}
})
.catch(err => dispatch(failedSummary(err)))
};
}

export function getHomeSummary(studentID){
return (dispatch) => {
fetch('http://www.mocky.io/v2/5b06d14d2f00002b00c61f1b')
Expand All @@ -15,10 +36,26 @@ export function getHomeSummary(studentID){

// ===================================== ACTION SENDING DATA TO REDUCER =================================================
export function setHomeSummary(homeData){
console.log(homeData);
return {
type: SUMMARY_HOME,
data : homeData.data,
}

}
}
export function summaryRecordTestDispatch(data, type){
return {
type: SUMMARY_TEST,
data : data.data,
}

}
export function summaryRecordQuizDispatch(data, type){
return {
type: SUMMARY_QUIZ,
data : data.data,
}


}
export function failedSummary(err){
}
135 changes: 117 additions & 18 deletions app/actions/user.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
import {FETCH_USER , FETCH_USER_SUCCESS , FETCH_USER_FAILED, USER_REMOVE } from '../lib/constants';
import {FETCH_USER , FETCH_USER_SUCCESS , FETCH_USER_FAILED, USER_REMOVE} from '../lib/constants';
import { USER_LOGIN_SUCCESS, USER_LOGIN_FAILED, USER_UPDATE_SUCCESS} from '../lib/constants';
import { AsyncStorage } from 'react-native';


saveJWT = async (token) => {
try {
await AsyncStorage.setItem('jwtToken', token);
} catch (error) {
console.log("Error saving data" + error);
}
}

getJWT = async (callback) => {
const value = await AsyncStorage.getItem('jwtToken').then( data => {
callback(data);
});
}
//================================ API FETCH ===================================
export function createUser(userValue){
return (dispatch) => {
fetch('http://www.mocky.io/v2/5af163c63100002a0096c946',{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(userValue)
}).then(data => data.json())
.then(json => {
dispatch(fetchDataSuccess(userValue));
})
.catch(err => dispatch(fetchDataFailed(err)))
};
return (dispatch) => {
// fetch('http://www.mocky.io/v2/5af163c63100002a0096c946',{
fetch('http://www.mocky.io/v2/5b0c41a53300002600b3ffae',{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(userValue)
}).then(data => data.json())
.then(json => {
dispatch(fetchDataSuccess(json));
})
.catch(err => dispatch(fetchDataFailed(err)))
};
}

export function updateUser(userValue){
Expand All @@ -27,14 +44,38 @@ export function updateUser(userValue){
'Content-Type': 'application/json',
},
body: JSON.stringify(userValue)
}).then(data => data.json())
})
.then(data => data.json())
.then(json => {
dispatch(fetchDataSuccess(json));
})
.catch(err => dispatch(fetchDataFailed(err)))
};
}

export function login(userValue,callback){
return (dispatch) => {
fetch('https://e-learning-backend.herokuapp.com/api/v1/login',{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(userValue)
}).then(data => {
saveJWT(data.headers.map.authorization[0]);
data.json()
.then( json =>{
callback(json);
dispatch(fetchDataSuccess(json));

}
)
})
.catch(err => dispatch(userLoginFailed(err)))
};
}

export function deleteUserState(){
return (dispatch) => {
dispatch(deleteUserStateDispatch())
Expand All @@ -43,10 +84,38 @@ export function deleteUserState(){

export function updateProfile(userVal){
return (dispatch) => {
dispatch(updateProfileDispatch(userVal))
dispatch(updateProfileSuccess(userVal))
};
}

export function getUserProfile(){
return(dispatch) => {
fetch('http://www.mocky.io/v2/5b06bf5c2f0000b118c61ed7')
.then(data => data.json())
.then(json => {
dispatch(fetchDataSuccess(json));
})
.catch(err => dispatch(fetchDataFailed(err)))
};
}

export function updateUserProfile(userValue){
return(dispatch) => {
fetch('',{
method: 'PUT',
headers:{
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(uservalue)
}).then(data => data.json())
.then(json => {
dispatch(fetchDataSuccess(json));
})
.catch(err => dispatch(fetchDataFailed(err)))
};
}

// ===================================== ACTION SENDING DATA TO REDUCER =================================================
export function fetchData() {
return {
Expand All @@ -57,10 +126,11 @@ export function fetchData() {
export function fetchDataSuccess(data) {
return {
type: FETCH_USER_SUCCESS,
data: data
data: data.data
}
}
export function fetchDataFailed(error) {
console.log(error, 'errr');
return {
type: FETCH_USER_FAILED,
error: error
Expand All @@ -78,4 +148,33 @@ export function updateProfileDispatch(userVal) {
type: "UpdateProfile",
data: userVal,
}
}

export function userLoginSuccess(data){
console.log(data.success,"kimakn kau");
if(data.success){
return{
type: USER_LOGIN_SUCCESS,
data: data,
}
}else{
return{
type: USER_LOGIN_FAILED,
error: error,
}
}
}

export function updateProfileSuccess(userVal) {
return {
type: USER_UPDATE_SUCCESS,
data: userVal,
}
}

export function userLoginFailed(error){
return{
type: USER_LOGIN_FAILED,
error: error,
}
}
Binary file added app/assets/img/topic/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/14.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/15.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/character exp dissapoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/character exp happy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/topic/character exp normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions app/component/flashButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { Component } from 'react';
import { TouchableOpacity, View, Text, StyleSheet, Dimensions } from 'react-native';
import PropTypes from 'prop-types';
import { Icon } from 'react-native-elements';

/**
Flashcard Button
**/
class FlashButton extends Component {
static propTypes = {
iconName: PropTypes.string,
textName: PropTypes.number,
btnType: PropTypes.string.isRequired,
}

_renderIconButton(){
return (
<TouchableOpacity
disabled={this.props.disabled}
style={studyStyles.roundButton}
onPress={() => this.props.onPress()}
>
<Icon name={ this.props.iconName } color='#fff' size={40}/>
</TouchableOpacity>
);
}

_renderTextButton(){
return (
<TouchableOpacity
style={studyStyles.roundButtonText}
onPress={() => this.props.onPress()}
>
<Text style={[studyStyles.textLg, studyStyles.textCenter, studyStyles.textWhite]}>
&nbsp;{ this.props.textName }x&nbsp;
</Text>
</TouchableOpacity>
);
}

render() {
const autoHeight = {
height: (Dimensions.get('window').width) * 0.2
}
let type;
if(this.props.btnType === 'icon') {
type = this._renderIconButton();
} else {
type = this._renderTextButton();
}
return (
<View style={[studyStyles.boxButton, autoHeight]}>
{ type }
</View>
);
}
}


export default FlashButton;

const studyStyles = require('../styles/study');
Loading

0 comments on commit 5008958

Please sign in to comment.