store
This commit is contained in:
parent
2fb5044993
commit
5a286dd1eb
|
@ -22,4 +22,4 @@ android.enableAapt2=false
|
|||
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
|
||||
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
|
||||
MYAPP_RELEASE_STORE_PASSWORD=aspire98H
|
||||
MYAPP_RELEASE_KEY_PASSWORD=aspire98H
|
||||
MYAPP_RELEASE_KEY_PASSWORD=encontroINFORMATICA2019
|
|
@ -1,12 +1,27 @@
|
|||
import React, {Component} from 'react';
|
||||
import {Platform, StyleSheet, Text, View, StatusBar, Dimensions, Image, ActivityIndicator, Button, TouchableHighlight} from 'react-native';
|
||||
import {
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
StatusBar,
|
||||
Dimensions,
|
||||
Image,
|
||||
ActivityIndicator,
|
||||
Button,
|
||||
TouchableHighlight,
|
||||
Keyboard
|
||||
|
||||
} from 'react-native';
|
||||
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import QRCodeScanner from 'react-native-qrcode-scanner';
|
||||
import {UtilStyles} from './assets/styles'
|
||||
import * as Actions from './actions'; //Import your actions
|
||||
|
||||
import * as Actions from './store/actions'; //Import your actions
|
||||
|
||||
import {RkButton, RkTheme, RkText, RkTextInput} from 'react-native-ui-kitten';
|
||||
|
||||
import Modal from "react-native-modal";
|
||||
|
@ -53,12 +68,16 @@ class App extends Component {
|
|||
isModalVisible: false,
|
||||
state : {text: ''},
|
||||
username:'',
|
||||
failedAttempt: false
|
||||
failedAttempt: false,
|
||||
push:4
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
_print=()=>{
|
||||
console.log("hello")
|
||||
this.setState({push:0})
|
||||
}
|
||||
checkValue=(e)=>{
|
||||
console.log("check"+e)
|
||||
}
|
||||
|
@ -66,9 +85,22 @@ class App extends Component {
|
|||
this.setState({isModalVisible: false})
|
||||
//verifica se o utilizador tem token guardado
|
||||
this.props.checkUser();
|
||||
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
|
||||
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
|
||||
|
||||
|
||||
}
|
||||
_keyboardDidShow () {
|
||||
//alert('Keyboard Shown');
|
||||
// this.setState({push:0})
|
||||
|
||||
}
|
||||
|
||||
_keyboardDidHide () {
|
||||
|
||||
//this.setState({push:4})
|
||||
|
||||
}
|
||||
onSuccess = (e) => {
|
||||
|
||||
this.setState({ isModalVisible: !this.state.isModalVisible });
|
||||
|
@ -130,7 +162,7 @@ class App extends Component {
|
|||
{
|
||||
backgroundColor:'#E8E8E8',
|
||||
borderRadius:10,
|
||||
// marginTop:SCREEN_HEIGHT/6,
|
||||
marginTop:SCREEN_HEIGHT /this.state.push,
|
||||
height:SCREEN_HEIGHT/2
|
||||
|
||||
}
|
||||
|
@ -143,7 +175,18 @@ class App extends Component {
|
|||
<Text></Text>
|
||||
<Text> Introduza a password</Text>
|
||||
|
||||
<RkTextInput secureTextEntry={true} rkType='rounded' onSubmitEditing={this.checkValue()} onChangeText={(text) => this.setState({text})} clearButtonMode='always' value={this.state.text}/>
|
||||
<RkTextInput
|
||||
onFocus={this._print}
|
||||
maxLength={10}
|
||||
blurOnSubmit ={true}
|
||||
secureTextEntry={true}
|
||||
rkType='rounded'
|
||||
onChangeText={(text) => this.setState({text})}
|
||||
clearButtonMode='always'
|
||||
value={this.state.text}
|
||||
clearTextOnFocus={true}
|
||||
onSubmitEditing={Keyboard.dismiss}
|
||||
/>
|
||||
|
||||
<Button onPress={this._tryLogin} title="Login" color="#841584" />
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
createBottomTabNavigator
|
||||
} from 'react-navigation';
|
||||
import * as Screens from './screens';
|
||||
import Login from './screens/Login'
|
||||
|
||||
|
||||
import AuthLoadingScreen from './screens/AuthLoading'
|
||||
|
||||
|
@ -18,7 +18,7 @@ import Scan from './screens/Scan'
|
|||
|
||||
import Calendar from './screens/Calendar'
|
||||
import Home from './screens/Home'
|
||||
import logout from './screens/logout'
|
||||
|
||||
|
||||
|
||||
/*Icons*/
|
||||
|
@ -100,20 +100,6 @@ const AppStack = createBottomTabNavigator(
|
|||
}
|
||||
);
|
||||
|
||||
const AuthStack = createStackNavigator(
|
||||
{
|
||||
Login: {
|
||||
screen: Login,
|
||||
},
|
||||
},
|
||||
/*{
|
||||
headerMode: 'none',
|
||||
navigationOptions: {
|
||||
headerVisible: false,
|
||||
}
|
||||
}*/
|
||||
);
|
||||
|
||||
const Stack = createStackNavigator({
|
||||
tabs: {
|
||||
screen: AppStack,
|
||||
|
@ -147,7 +133,7 @@ export default createAppContainer(createSwitchNavigator(
|
|||
{
|
||||
AuthLoading: AuthLoadingScreen,
|
||||
App: Stack,
|
||||
Auth: AuthStack,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ import {connect} from 'react-redux';
|
|||
|
||||
import {bindActionCreators} from 'redux';
|
||||
|
||||
import * as Actions from '../actions'; //Import your actionss
|
||||
import * as Actions from '../store/actions'; //Import your actionss
|
||||
|
||||
|
||||
const formatObj = (obj) => {
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Button, View, Text , TouchableOpacity} from 'react-native';
|
||||
import {RkButton,
|
||||
RkTheme } from 'react-native-ui-kitten';
|
||||
|
||||
import deviceStorage from '../services/deviceStorage';
|
||||
import AuthLoadingScreen from './AuthLoading';
|
||||
import api from '../services/api';
|
||||
|
||||
|
||||
import {connect} from 'react-redux'
|
||||
|
||||
class Counter extends Component {
|
||||
|
||||
static navigationOptions = {
|
||||
title: 'Home'
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
|
||||
return (
|
||||
|
||||
<View style={{flex:1, alignItems: 'center', alignContent: 'center'}}>
|
||||
|
||||
<View style={{flexDirection:'row', margin:50}}>
|
||||
<TouchableOpacity onPress={()=>this.props.increaseCounter()}>
|
||||
<Text style={{fontSize:30}}>Increase</Text>
|
||||
</TouchableOpacity>
|
||||
<Text>{this.props.counter}</Text>
|
||||
<TouchableOpacity onPress={()=>this.props.decreaseCounter()}>
|
||||
<Text style={{fontSize:30}}> Decrease</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
|
||||
</View>
|
||||
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state){
|
||||
return {
|
||||
counter:state.counter
|
||||
}
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch){
|
||||
return {
|
||||
increaseCounter:()=> dispatch({type:'INCREASE_COUNTER' }),
|
||||
decreaseCounter:()=> dispatch({type:'DECREASE_COUNTER' }),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Counter)
|
|
@ -13,9 +13,8 @@ import {connect} from 'react-redux';
|
|||
|
||||
import {bindActionCreators} from 'redux';
|
||||
|
||||
import * as Actions from '../actions'; //Import your actionss
|
||||
import * as Actions from '../store/actions'; //Import your actionss
|
||||
|
||||
import Counter from './Counter'
|
||||
|
||||
import {createStore} from 'redux';
|
||||
|
||||
|
|
|
@ -1,186 +0,0 @@
|
|||
import React, {Component, Fragment} from 'react'
|
||||
import {View, Image, Vibration, Dimensions,Text ,Button} from 'react-native'
|
||||
import Icon from "react-native-vector-icons/Ionicons";
|
||||
import {UtilStyles} from '../assets/styles'
|
||||
import { AsyncStorage } from 'react-native';
|
||||
import axios from 'axios';
|
||||
import deviceStorage from '../services/deviceStorage';
|
||||
|
||||
|
||||
import {cenas} from '../services/auth';
|
||||
import QRCodeScanner from 'react-native-qrcode-scanner';
|
||||
|
||||
import CodeInput from 'react-native-confirmation-code-input';
|
||||
const SCREEN_HEIGHT = Dimensions.get("window").height;
|
||||
const SCREEN_WIDTH = Dimensions.get("window").width;
|
||||
|
||||
|
||||
import {RkButton,
|
||||
RkTheme , RkText} from 'react-native-ui-kitten';
|
||||
|
||||
|
||||
export default class Login extends Component {
|
||||
|
||||
static navigationOptions = {
|
||||
header: null,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
|
||||
onSuccess = (e) => {
|
||||
|
||||
// console.log(e.data);
|
||||
|
||||
|
||||
deviceStorage.Login(e);
|
||||
|
||||
this.props.navigation.navigate('Home');
|
||||
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
deviceStorage.isLogged().then(a=>{
|
||||
console.log(a);
|
||||
|
||||
if(a)
|
||||
this.props.navigation.navigate('Home');
|
||||
|
||||
|
||||
})
|
||||
// console.log(AsyncStorage.getItem('userToken'))
|
||||
|
||||
// if(AsyncStorage.getItem('userToken')){
|
||||
|
||||
// this.props.navigation.navigate('Home');
|
||||
|
||||
// }
|
||||
|
||||
|
||||
return (
|
||||
|
||||
|
||||
<QRCodeScanner
|
||||
showMarker
|
||||
|
||||
reactivate={true}
|
||||
onRead={this.onSuccess.bind(this)}
|
||||
cameraStyle={{ height: SCREEN_HEIGHT }}
|
||||
|
||||
customMarker={
|
||||
|
||||
<View style={styles.rectangleContainer}>
|
||||
<View style={styles.logo}>
|
||||
<Image style={UtilStyles.loginImage}
|
||||
source={require('../assets/img/logo.png')}
|
||||
/>
|
||||
</View>
|
||||
|
||||
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
<View style={styles.leftAndRightOverlay}>
|
||||
</View>
|
||||
|
||||
<View style={styles.rectangle}>
|
||||
|
||||
</View>
|
||||
|
||||
|
||||
<View style={styles.leftAndRightOverlay}>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={styles.bottomOverlay}>
|
||||
|
||||
<View style={{flex:1, alignItems: 'center', alignContent: 'center'}}>
|
||||
|
||||
<RkText rkType='primary' style={styles.recover}>Recuperar pin de acesso</RkText>
|
||||
<RkButton rkType='dark' style={styles.manual}>lols</RkButton>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RkTheme.setType('RkButton', 'dark', {
|
||||
container: {
|
||||
paddingTop:10,
|
||||
backgroundColor: 'gray',
|
||||
|
||||
borderRadius: 90,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const rectDimensions = SCREEN_WIDTH * 0.85; // this is equivalent to 255 from a 393 device width
|
||||
|
||||
const overlayColor = 'rgba(0,0,0,0.30)';
|
||||
|
||||
const styles = {
|
||||
|
||||
recover:{
|
||||
paddingTop:10,
|
||||
color: "red",
|
||||
paddingBottom:10
|
||||
},
|
||||
manual:{
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
logo:{
|
||||
|
||||
height:SCREEN_HEIGHT*0.35,
|
||||
width:SCREEN_WIDTH,
|
||||
backgroundColor: overlayColor,
|
||||
},
|
||||
rectangleContainer: {
|
||||
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "transparent",
|
||||
|
||||
},
|
||||
|
||||
rectangle: {
|
||||
|
||||
height: rectDimensions,
|
||||
width: rectDimensions,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "transparent"
|
||||
},
|
||||
|
||||
topOverlay: {
|
||||
flex: 1,
|
||||
backgroundColor: overlayColor,
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
},
|
||||
|
||||
bottomOverlay: {
|
||||
flex: 1,
|
||||
height: SCREEN_HEIGHT,
|
||||
width: SCREEN_WIDTH,
|
||||
backgroundColor: overlayColor,
|
||||
paddingBottom: SCREEN_WIDTH * 0.2
|
||||
},
|
||||
|
||||
leftAndRightOverlay: {
|
||||
height: rectDimensions,
|
||||
width: SCREEN_WIDTH,
|
||||
backgroundColor: overlayColor
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -16,7 +16,8 @@ import PropTypes from 'prop-types';
|
|||
|
||||
import {connect, Provider} from "react-redux";
|
||||
import {bindActionCreators} from "redux";
|
||||
import * as Actions from "../actions";
|
||||
|
||||
import * as Actions from "../store/actions";
|
||||
|
||||
import {createStore} from 'redux';
|
||||
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Button, View, Text , TouchableOpacity, FlatList, ActivityIndicator} from 'react-native';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import * as Actions from '../actions'; //Import your actionss
|
||||
|
||||
|
||||
class logout extends Component {
|
||||
|
||||
constructor(props) {
|
||||
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
token:false,
|
||||
tokenData:'',
|
||||
loggedIn:false,
|
||||
onHold:true
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
console.log('logout')
|
||||
this.props.logoutUser();
|
||||
|
||||
//this.props.navigation.navigate('Home');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<View >
|
||||
|
||||
<Text>LOGGED OUT</Text>
|
||||
|
||||
</View>
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function mapStateToProps(state, props) {
|
||||
|
||||
return {
|
||||
|
||||
|
||||
token: state.apiReducer.token,
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
|
||||
return bindActionCreators(Actions, dispatch);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(logout);
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
const api={
|
||||
|
||||
_retrieveData (){
|
||||
try {
|
||||
const value = AsyncStorage.getItem('token');
|
||||
if (value !== null) {
|
||||
// We have data!!
|
||||
return value;
|
||||
}
|
||||
} catch (error) {
|
||||
// Error retrieving data
|
||||
}
|
||||
},
|
||||
getPersonalInfo(){
|
||||
|
||||
|
||||
var obj = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization':"Bearer "+ api._retrieveData(),
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
return fetch('http://enei2019.uingress.com/internal/api/Attendee/Detail', obj)
|
||||
.then(function(res) {
|
||||
|
||||
console.log(res);
|
||||
return res.json();
|
||||
})
|
||||
.then(function(resJson) {
|
||||
return resJson;
|
||||
})
|
||||
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
export default api;
|
|
@ -1,47 +0,0 @@
|
|||
import {AsyncStorage} from 'react-native';
|
||||
import Login from '../screens/Login';
|
||||
|
||||
cenas={
|
||||
|
||||
|
||||
|
||||
|
||||
loginAPI(user, pass){
|
||||
var details = {
|
||||
'username': user,
|
||||
'password': '80f3b6e5',
|
||||
'grant_type': 'password'
|
||||
};
|
||||
|
||||
var formBody = [];
|
||||
for (var property in details) {
|
||||
var encodedKey = encodeURIComponent(property);
|
||||
var encodedValue = encodeURIComponent(details[property]);
|
||||
formBody.push(encodedKey + "=" + encodedValue);
|
||||
}
|
||||
formBody = formBody.join("&");
|
||||
|
||||
fetch('http://enei2019.uingress.com/internal/api/token', {
|
||||
|
||||
method: 'POST',
|
||||
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
},
|
||||
body: formBody
|
||||
|
||||
}).catch(err=>{
|
||||
console.log(err);
|
||||
alert("error");
|
||||
|
||||
}).then(res=>res.json()).then(parsed=>{console.log(parsed)
|
||||
deviceStorage.saveItem(parsed.access_token);},
|
||||
this.setState(previousState => (
|
||||
{ loggedIn: true }
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
export default cenas;
|
|
@ -1,95 +0,0 @@
|
|||
import { AsyncStorage } from 'react-native';
|
||||
import Login from '../screens/Login';
|
||||
|
||||
const deviceStorage = {
|
||||
|
||||
Login(){
|
||||
var details = {
|
||||
'username': 'TC2MT8QFJT',
|
||||
'password': '80f3b6e5',
|
||||
'grant_type': 'password'
|
||||
};
|
||||
|
||||
var formBody = [];
|
||||
for (var property in details) {
|
||||
var encodedKey = encodeURIComponent(property);
|
||||
var encodedValue = encodeURIComponent(details[property]);
|
||||
formBody.push(encodedKey + "=" + encodedValue);
|
||||
}
|
||||
formBody = formBody.join("&");
|
||||
|
||||
fetch('http://enei2019.uingress.com/internal/api/token', {
|
||||
|
||||
method: 'POST',
|
||||
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
},
|
||||
body: formBody
|
||||
|
||||
}).catch(err=>{
|
||||
console.log(err);
|
||||
alert("error");
|
||||
|
||||
}).then(res=>res.json()).then(parsed=>{
|
||||
|
||||
AsyncStorage.setItem('token', parsed.access_token);
|
||||
AsyncStorage.setItem('nome',"henrique");
|
||||
|
||||
}
|
||||
|
||||
)
|
||||
},
|
||||
|
||||
async isLogged(){
|
||||
|
||||
const value = AsyncStorage.getItem('token');
|
||||
return value;
|
||||
|
||||
},
|
||||
|
||||
async saveItem(key, value) {
|
||||
try {
|
||||
await AsyncStorage.setItem(key, value);
|
||||
console.log('saved')
|
||||
} catch (error) {
|
||||
console.log(`Erro a guardar! \n${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
//Carregar token
|
||||
async loadJWT() {
|
||||
try {
|
||||
const value = await AsyncStorage.getItem('userToken');
|
||||
if (value !== null) {
|
||||
this.setState({
|
||||
jwt: value,
|
||||
loading: false
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`Erro a ler token \n${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//Apagar Token
|
||||
async deleteJWT() {
|
||||
try {
|
||||
console.log("apaga");
|
||||
await AsyncStorage.removeItem('token');
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(`Erro a ler token \n${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default deviceStorage;
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
|
||||
//API BLUETREND
|
||||
|
||||
export const DATA_AVAILABLE = 'DATA_AVAILABLE';
|
||||
export const API_LOGIN = 'API_LOGIN';
|
||||
export const CHECK_USER='CHECK_USER';
|
||||
export const LOGOUT_USER= 'LOGOUT_USER';
|
||||
export const USER_INFO= 'USER_INFO'
|
||||
export const HOLD='HOLD'
|
||||
export const GET_EVENTS='GET_EVENTS'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//UI
|
||||
|
||||
//LOGIN
|
||||
export const UI_LOGIN_RESET_PASSWORD= 'UI_LOGIN_RESET_PASSWORD'
|
||||
export const UI_LOGIN_HELP_LOGIN='UI_LOGIN_HELP_LOGIN'
|
||||
export const UI_LOGIN_PASSWORD_INPUT='UI_LOGIN_PASSWORD_INPUT'
|
||||
export const UI_LOGIN_PASSWORD_INPUT_LOADING='UI_LOGIN_PASSWORD_INPUT_LOADING'
|
||||
export const UI_LOGIN_PASSWORD_INPUT_INVALID='UI_LOGIN_PASSWORD_INPUT_INVALID'
|
||||
export const UI_LOGIN_NOINTERNET='UI_LOGIN_NOINTERNET'
|
||||
|
||||
|
||||
//HOME
|
|
@ -1,35 +1,9 @@
|
|||
export const DATA_AVAILABLE = 'DATA_AVAILABLE';
|
||||
export const API_LOGIN = 'API_LOGIN';
|
||||
export const CHECK_USER='CHECK_USER';
|
||||
export const LOGOUT_USER= 'LOGOUT_USER';
|
||||
|
||||
export const USER_INFO= 'USER_INFO'
|
||||
export const HOLD='HOLD'
|
||||
export const GET_EVENTS='GET_EVENTS'
|
||||
|
||||
import { AsyncStorage } from 'react-native';
|
||||
|
||||
|
||||
//Import the sample data
|
||||
import Data from '../intructions.json';
|
||||
import Login from '../screens/Login.js';
|
||||
|
||||
import { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD, GET_EVENTS } from "./actionTypes" //Import the actions types constant we defined in our actions
|
||||
import moment from 'moment'
|
||||
|
||||
export function getData(){
|
||||
return (dispatch) => {
|
||||
|
||||
//Make API Call
|
||||
//For this example, I will be using the sample data in the json file
|
||||
//delay the retrieval [Sample reasons only]
|
||||
setTimeout(() => {
|
||||
const data = Data.instructions;
|
||||
dispatch({type: DATA_AVAILABLE, data:data});
|
||||
}, 2000);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
export function getEvents(user){
|
||||
return (dispatch)=>{
|
||||
let events = [];
|
||||
|
@ -408,6 +382,4 @@ export function checkUser(){
|
|||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
export {checkUser, login,getEvents, hold, getUserInfo,logoutUser} from "./api"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,20 +1,6 @@
|
|||
import { combineReducers } from 'redux';
|
||||
|
||||
import { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD, GET_EVENTS } from "../actions/" //Import the actions types constant we defined in our actions
|
||||
import { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD, GET_EVENTS } from "../actions/actionTypes" //Import the actions types constant we defined in our actions
|
||||
|
||||
|
||||
let dataState = { data: [], loading:true ,token:true, failAttempt:false};
|
||||
|
||||
const dataReducer = (state = dataState, action) => {
|
||||
switch (action.type) {
|
||||
case DATA_AVAILABLE:
|
||||
state = Object.assign({}, state, { data: action.data, loading:false });
|
||||
return state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
let apiState= { token:{valid:false}, tokenData:'error', logged:false, onHold:true, user:{}, events:[], failedAttempt:false}
|
||||
|
||||
const apiReducer = (state = apiState, action) => {
|
||||
|
@ -61,13 +47,4 @@ const apiReducer = (state = apiState, action) => {
|
|||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Combine all the reducers
|
||||
const rootReducer = combineReducers({
|
||||
dataReducer, apiReducer
|
||||
// ,[ANOTHER REDUCER], [ANOTHER REDUCER] ....
|
||||
})
|
||||
|
||||
export default rootReducer;
|
||||
export default apiReducer;
|
|
@ -0,0 +1,13 @@
|
|||
import { combineReducers } from 'redux';
|
||||
|
||||
import uiReducer from "./ui";
|
||||
import apiReducer from "./api";
|
||||
|
||||
|
||||
// Combine all the reducers
|
||||
const rootReducer = combineReducers({
|
||||
apiReducer, uiReducer
|
||||
// ,[ANOTHER REDUCER], [ANOTHER REDUCER] ....
|
||||
})
|
||||
|
||||
export default rootReducer;
|
|
@ -0,0 +1,19 @@
|
|||
import { } from "../actions/actionTypes" //Import the actions types constant we defined in our actions
|
||||
|
||||
|
||||
let uiState= { }
|
||||
|
||||
const uiReducer = (state = apiState, action) => {
|
||||
|
||||
switch(action.type){
|
||||
|
||||
case HOLD:
|
||||
|
||||
state=Object.assign({},state, { onHold:true });
|
||||
return state;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
export default uiReducer;
|
|
@ -5,7 +5,7 @@ import {Provider} from 'react-redux';
|
|||
|
||||
import {name as appName} from './app.json';
|
||||
|
||||
import store from './app/store'; //Import the store
|
||||
import store from './app/store/store'; //Import the store
|
||||
|
||||
|
||||
import App from './app/App' //Import the component file
|
||||
|
|
Loading…
Reference in New Issue