merge master (remote) > master (local)

This commit is contained in:
Filipe Pinho 2019-03-07 23:18:09 +00:00
commit ea8398cd13
61 changed files with 4247 additions and 544 deletions

3
.gitignore vendored
View File

@ -84,4 +84,5 @@ typings/
bin/
obj/
.vscode/
.vscode/
*.cache

View File

@ -149,6 +149,7 @@ android {
}
dependencies {
compile project(':react-native-device-info')
compile project(':react-native-material-shadows')
compile project(':react-native-linear-gradient')
compile project(':react-native-camera')

View File

@ -3,6 +3,7 @@ package com.app;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import ui.materialshadows.RNMaterialShadowsPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import org.reactnative.camera.RNCameraPackage;
@ -28,6 +29,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNDeviceInfo(),
new RNMaterialShadowsPackage(),
new LinearGradientPackage(),
new RNCameraPackage(),

View File

@ -1,4 +1,6 @@
rootProject.name = 'app'
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-material-shadows'
project(':react-native-material-shadows').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-material-shadows/android')
include ':react-native-linear-gradient'

View File

@ -40,12 +40,16 @@ const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
import Swiper from 'react-native-swiper';
var TimerMixin = require('react-timer-mixin');
function handleConnectivityChange() {
console.log("asdasd");
}
class App extends Component {
handleConnectivityChange = isConnected => {
this.setState({ isConnected });
}
_activate=()=>{
this.setState({ isModalVisible: !this.state.isModalVisible});
@ -84,8 +88,9 @@ class App extends Component {
username:'QR code',
failedAttempt: false,
push:4,
UI_loginScannerActive:false
UI_loginScannerActive:false,
userDetails:{username:'', password:''},
isConnected: true
};
}
@ -102,19 +107,19 @@ class App extends Component {
componentDidMount() {
NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
this.props.hold();
NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
this.setState({isModalVisible: false})
//verifica se o utilizador tem token guardado
this.props.checkUser();
this.props.checkUser(this.props.userDetails);
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
}
componentWillUnmount() {
NetInfo.isConnected.removeEventListener('connectionChange', this.handleConnectivityChange);
NetInfo.isConnected.removeEventListener('connectionChange', this.handleConnectivityChange);
}
_keyboardDidShow () {
@ -130,9 +135,9 @@ class App extends Component {
}
onSuccess = (e) => {
// this.setState({ isModalVisible: !this.state.isModalVisible });
// this.props.login(e.data, 'f8908cc0');
this.props.closeLoginQRScan();
// this.setState({ isModalVisible: !this.state.isModalVisible });
// this.props.login(e.data, 'f8908cc0');
this.props.closeLoginQRScan();
this.setState({username:e.data})
console.log("QR code lido");
@ -142,8 +147,14 @@ class App extends Component {
};
render() {
if (!this.props.logged) {
if (!this.state.isConnected) {
return (
<View>
<Text>cenas da vida</Text>
</View>
);
}
if (!this.props.logged && this.props.onHold) {
return (
@ -530,7 +541,8 @@ mapStateToProps = (state, props) => {
onHold: state.apiReducer.onHold,
logged: state.apiReducer.logged,
failedAttempt:state.apiReducer.failedAttempt,
UI_loginScannerActive: state.uiReducer.UI_loginScannerActive
UI_loginScannerActive: state.uiReducer.UI_loginScannerActive,
userDetails: state.apiReducer.userDetails,
}
};

View File

@ -2,7 +2,8 @@ import React from 'react';
import {
TouchableOpacity,
Text,
View
View,
Image
} from 'react-native';
import {
createStackNavigator,
@ -17,7 +18,7 @@ import AuthLoadingScreen from './screens/AuthLoading'
import Eventos from './screens/Eventos'
import Social from './screens/Social'
import Jogo from './screens/Jogo'
import Scan from './screens/Scan'
import Calendar from './screens/Calendar'
@ -37,7 +38,7 @@ import calendarDetail from './screens/calendarDetail';
const AppStack = createBottomTabNavigator(
{
Calendar: {
Calendário: {
screen: Calendar,
navigationOptions: {
@ -48,13 +49,14 @@ const AppStack = createBottomTabNavigator(
},
},
Social: {
screen: Social,
'Jogo do...': {
screen: Jogo,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="ios-mail" color={tintColor} size={30}/>
<Image style={{width:30, height:30}}source={require('./assets/img/logo2.png')}></Image>
)
},
},
@ -100,7 +102,7 @@ const AppStack = createBottomTabNavigator(
tabBarOptions: {
showLabel: true, // hide labels
activeTintColor: '#CC1A17', // active icon color
inactiveTintColor: '#d8d6c9', // inactive icon color
inactiveTintColor: 'black', // inactive icon color
style: {
backgroundColor: '#fff' // TabBar background
}
@ -127,7 +129,25 @@ const Stack = createStackNavigator({
)
}
}
else if(navigation.state.routes[index].routeName == 'Calendar'){
else if(navigation.state.routes[index].routeName == 'Calendário'){
return {
headerTitle: 'Calendário',
headerRight: (
<View style={{flex:1, flexDirection:'row'}}>
<TouchableOpacity style={{marginRight: 20, flex:1, flexDirection:'row'}} onPress={() => navigation.navigate('Edit')}>
<Text>FAQ</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginRight: 20, flex:1, flexDirection:'row'}} onPress={() => navigation.navigate('choosePath')}>
<Text>Escolher</Text>
<IconFA name="user-edit" size={22}/>
</TouchableOpacity></View>
)
}
}
else if(navigation.state.routes[index].routeName == 'choosePath'){
return {
headerTitle: 'Calendário',
headerRight: (
@ -145,7 +165,6 @@ const Stack = createStackNavigator({
)
}
}
else {
return {
header: null

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

BIN
App/app/assets/altice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
App/app/assets/img/bg-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="1130px" height="350px" viewBox="0 0 1130 350" enable-background="new 0 0 1130 350" xml:space="preserve">
<g>
<path d="M234.08,65.945c-14.86-48.87-72.639-65.136-124.304-49.464c-51.652,15.67-77.705,65.582-62.822,114.453
c9.492,31.225,43.003,56.425,78.502,64.342l-11.714,78.736l-65.354-85.776H20.08v139.327h30.276v-88.576l67.899,99.774
l36.408-11.387l3.704-130.144c8.84-1.008,17.395-3.239,25.242-7.168C239.878,161.901,248.935,114.823,234.08,65.945z
M151.49,169.298c-37.983,0-76.66-30.117-76.66-65.855c0-35.754,24.019-69.244,61.993-69.244c37.978,0,67.65,28.148,75.54,69.244
C219.094,138.548,189.469,169.298,151.49,169.298z"/>
<path fill="#FF0000" d="M185.817,102.266c-9.019,24.76-31.073,42.792-54.108,42.792c-23.049,0-36.071-19.144-29.307-42.792
c6.488-22.723,19.313-37.402,41.701-42.783C172.28,52.743,193.908,80.071,185.817,102.266"/>
<g>
<g>
<path fill="#FF0000" d="M662.173,323.944l2.399-3.375c3.442,2.574,7.238,4.051,10.988,4.051c3.816,0,6.571-1.964,6.571-5.035
v-0.127c0-3.188-3.749-4.414-7.927-5.582c-4.973-1.411-10.499-3.133-10.499-8.967v-0.123c0-5.461,4.552-9.08,10.809-9.08
c3.868,0,8.171,1.346,11.415,3.497l-2.139,3.563c-2.947-1.908-6.323-3.076-9.388-3.076c-3.75,0-6.146,1.964-6.146,4.607v0.123
c0,3.009,3.928,4.173,8.166,5.461c4.907,1.477,10.189,3.384,10.189,9.089v0.122c0,6.02-4.974,9.517-11.296,9.517
C670.766,328.609,665.745,326.831,662.173,323.944z"/>
<path fill="#FF0000" d="M690.266,284.094h5.399v5.219h-5.399V284.094z M690.561,296.25h4.726v31.744h-4.726V296.25z"/>
<path fill="#FF0000" d="M701.062,296.25h4.724v5.35c2.092-3.136,4.909-6.024,10.243-6.024c5.165,0,8.474,2.766,10.19,6.329
c2.282-3.502,5.658-6.329,11.186-6.329c7.302,0,11.783,4.917,11.783,12.773v19.646h-4.725V309.46c0-6.15-3.066-9.581-8.235-9.581
c-4.778,0-8.706,3.554-8.706,9.825v18.29h-4.729v-18.661c0-5.957-3.131-9.454-8.166-9.454c-5.04,0-8.842,4.177-8.842,10.003
v18.112h-4.724V296.25z"/>
<path fill="#FF0000" d="M754.148,296.25h4.725v6.394c2.579-3.806,6.309-7.068,12.146-7.068c7.617,0,15.165,6.024,15.165,16.459
v0.121c0,10.378-7.481,16.519-15.165,16.519c-5.884,0-9.698-3.196-12.146-6.76v15.905h-4.725V296.25z M781.34,312.212v-0.123
c0-7.481-5.166-12.276-11.186-12.276c-5.887,0-11.474,4.974-11.474,12.222v0.121c0,7.369,5.587,12.276,11.474,12.276
C776.3,324.431,781.34,319.893,781.34,312.212z"/>
<path fill="#FF0000" d="M790.064,283.177h4.729v44.817h-4.729V283.177z"/>
<path fill="#FF0000" d="M798.59,312.212v-0.123c0-9.144,6.44-16.514,15.211-16.514c9.408,0,14.804,7.491,14.804,16.768
c0,0.614,0,0.979-0.066,1.533h-25.172c0.685,6.871,5.527,10.744,11.185,10.744c4.354,0,7.421-1.786,9.993-4.481l2.953,2.639
c-3.195,3.562-7.059,5.953-13.078,5.953C805.697,328.73,798.59,322.036,798.59,312.212z M823.815,310.379
c-0.494-5.771-3.804-10.81-10.125-10.81c-5.527,0-9.705,4.607-10.323,10.81H823.815z"/>
<path fill="#FF0000" d="M831.637,296.25h4.729v8.293c2.329-5.283,6.929-9.089,12.942-8.837v5.096h-0.374
c-6.93,0-12.568,4.968-12.568,14.551v12.642h-4.729V296.25z"/>
<path fill="#FF0000" d="M889.485,321.914c-3.932,4.239-8.479,6.695-14.057,6.695c-7.744,0-13.514-4.853-13.514-12.034v-0.121
c0-5.711,3.815-9.826,10.387-12.398c-2.953-3.44-4.308-6.084-4.308-9.46v-0.121c0-5.648,4.552-10.191,11.366-10.191
c6.015,0,10.437,4.354,10.437,9.704v0.121c0,5.461-3.868,8.958-10.145,11.166l9.833,10.012c1.909-2.76,3.62-6.015,5.152-9.576
l3.994,1.843c-1.907,4.049-3.861,7.733-6.196,10.808l7.486,7.67l-3.685,2.821L889.485,321.914z M886.532,318.905l-11.479-11.845
c-5.705,2.085-8.232,5.587-8.232,9.21v0.122c0,4.599,3.686,8.104,8.968,8.104C879.849,324.497,883.401,322.344,886.532,318.905z
M885.243,294.351v-0.122c0-3.439-2.572-5.957-6.079-5.957c-3.863,0-6.507,2.705-6.507,6.202v0.121
c0,2.522,1.046,4.42,4.308,7.927C882.426,300.679,885.243,298.036,885.243,294.351z"/>
<path fill="#FF0000" d="M915.079,283.177h4.73v18.601c2.086-3.437,5.395-6.202,10.855-6.202c7.684,0,12.165,5.161,12.165,12.707
v19.712h-4.73V309.46c0-5.896-3.192-9.581-8.784-9.581c-5.466,0-9.506,3.989-9.506,9.946v18.169h-4.73V283.177z"/>
<path fill="#FF0000" d="M945.244,318.783v-0.121c0-6.694,5.525-10.247,13.565-10.247c4.041,0,6.928,0.548,9.765,1.344v-1.101
c0-5.713-3.507-8.658-9.455-8.658c-3.75,0-6.703,0.979-9.638,2.335l-1.415-3.871c3.502-1.59,6.928-2.636,11.54-2.636
c4.486,0,7.921,1.167,10.256,3.497c2.151,2.151,3.245,5.218,3.245,9.269v19.4h-4.533v-4.786
c-2.219,2.889-5.901,5.466-11.495,5.466C951.198,328.674,945.244,325.3,945.244,318.783z M968.626,316.332v-3.066
c-2.335-0.68-5.466-1.354-9.329-1.354c-5.953,0-9.276,2.579-9.276,6.572v0.122c0,3.984,3.685,6.318,7.987,6.318
C963.843,324.924,968.626,321.365,968.626,316.332z"/>
<path fill="#FF0000" d="M977.915,296.25h4.731v6.394c2.572-3.806,6.323-7.068,12.158-7.068c7.617,0,15.165,6.024,15.165,16.459
v0.121c0,10.378-7.501,16.519-15.165,16.519c-5.901,0-9.698-3.196-12.158-6.76v15.905h-4.731V296.25z M1005.113,312.212v-0.123
c0-7.481-5.151-12.276-11.169-12.276c-5.903,0-11.476,4.974-11.476,12.222v0.121c0,7.369,5.572,12.276,11.476,12.276
C1000.074,324.431,1005.113,319.893,1005.113,312.212z"/>
<path fill="#FF0000" d="M1013.41,296.25h4.729v6.394c2.574-3.806,6.324-7.068,12.16-7.068c7.617,0,15.164,6.024,15.164,16.459
v0.121c0,10.378-7.5,16.519-15.164,16.519c-5.901,0-9.699-3.196-12.16-6.76v15.905h-4.729V296.25z M1040.608,312.212v-0.123
c0-7.481-5.156-12.276-11.171-12.276c-5.901,0-11.48,4.974-11.48,12.222v0.121c0,7.369,5.579,12.276,11.48,12.276
C1035.568,324.431,1040.608,319.893,1040.608,312.212z"/>
<path fill="#FF0000" d="M1049.035,284.094h5.395v5.219h-5.395V284.094z M1049.345,296.25h4.729v31.744h-4.729V296.25z"/>
<path fill="#FF0000" d="M1057.858,312.212v-0.123c0-9.144,6.436-16.514,15.225-16.514c9.389,0,14.79,7.491,14.79,16.768
c0,0.614,0,0.979-0.052,1.533h-25.172c0.665,6.871,5.525,10.744,11.166,10.744c4.372,0,7.434-1.786,10.012-4.481l2.953,2.639
c-3.198,3.562-7.06,5.953-13.078,5.953C1064.978,328.73,1057.858,322.036,1057.858,312.212z M1083.094,310.379
c-0.492-5.771-3.814-10.81-10.143-10.81c-5.508,0-9.699,4.607-10.303,10.81H1083.094z"/>
<path fill="#FF0000" d="M1090.905,296.25h4.726v8.293c2.333-5.283,6.945-9.089,12.96-8.837v5.096h-0.374
c-6.942,0-12.586,4.968-12.586,14.551v12.642h-4.726V296.25z"/>
</g>
<polygon points="377.608,138.481 395.687,138.481 395.687,242.92 380.299,242.92 322.628,168.622 322.628,242.92 304.552,242.92
304.552,138.481 321.577,138.481 377.608,210.698 "/>
<g>
<path d="M465.826,153.552c-20.77,0-35.25,16.566-35.25,37.004c0,20.442,14.79,37.299,35.555,37.299
c20.757,0,35.25-16.561,35.25-36.993C501.381,170.413,486.596,153.552,465.826,153.552 M465.826,244.711
c-32.119,0-54.525-24.31-54.525-53.85c0-29.551,22.698-54.17,54.83-54.17c32.124,0,54.525,24.329,54.525,53.864
C520.656,220.101,497.96,244.711,465.826,244.711"/>
</g>
<polygon points="603.297,138.481 623.174,138.481 579.687,243.661 563.557,243.661 520.075,138.481 540.392,138.481
571.91,218.756 "/>
<path d="M663.509,159.67l-17.93,41.775h35.996L663.509,159.67z M718.329,242.92h-19.425l-10.603-25.209h-49.453l-10.763,25.209
h-18.821l46.028-105.183h17.023L718.329,242.92z"/>
<g>
<path d="M797.169,212.188c0-8.953-7.021-14.175-21.515-14.175h-29.139v28.65H777
C789.552,226.664,797.169,221.732,797.169,212.188 M791.334,168.173c0-8.503-6.568-13.43-18.357-13.43h-26.461v27.764h25.103
C783.42,182.507,791.334,177.885,791.334,168.173 M809.718,165.196c0,12.825-7.167,19.388-14.948,23.419
c12.271,4.177,20.784,11.199,20.784,25.515c0,18.797-15.397,28.79-38.7,28.79h-48.412V138.481h46.922
C796.424,138.481,809.718,148.78,809.718,165.196"/>
</g>
<path d="M872.385,159.67l-17.934,41.775h36.015L872.385,159.67z M927.205,242.92h-19.409l-10.618-25.209h-49.453l-10.748,25.209
h-18.826l46.014-105.183h17.038L927.205,242.92z"/>
<g>
<path d="M978.412,182.348c22.117,5.367,33.615,13.279,33.615,30.731c0,19.696-15.391,31.326-37.354,31.326
c-15.989,0-31.083-5.513-43.632-16.692l11.058-13.144c10.017,8.662,20.021,13.584,33.009,13.584
c11.367,0,18.549-5.221,18.549-13.279c0-7.604-4.187-11.635-23.605-16.115c-22.262-5.368-34.825-11.93-34.825-31.327
c0-18.197,14.931-30.441,35.715-30.441c15.239,0,27.339,4.622,37.941,13.135l-9.858,13.871
c-9.408-7.008-18.82-10.74-28.387-10.74c-10.754,0-17.025,5.518-17.025,12.53C953.612,173.999,958.377,177.571,978.412,182.348"
/>
</g>
<polygon points="1104.559,154.897 1045.398,154.897 1045.398,182.052 1097.832,182.052 1097.832,198.459 1045.398,198.459
1045.398,226.514 1105.319,226.514 1105.319,242.92 1027.028,242.92 1027.028,138.491 1104.559,138.491 "/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -11,7 +11,8 @@ import {
StyleSheet,
Image,
ImageBackground,
NetInfo
NetInfo,
AppState
} from 'react-native';
import {Shadow} from 'react-native-shadow'
@ -38,10 +39,14 @@ const SCREEN_WIDTH = Dimensions.get("window").width;
import {Card, Divider} from 'react-native-elements'
import RNMaterialShadows from 'react-native-material-shadows';
class Home extends Component {
_handleConnectionChange = (isConnected) => {
// this.props.dispatch(connectionState({ status: isConnected }));
console.log("fck that")
};
_refresh() {
return new Promise((resolve) => {
setTimeout(()=>{resolve()}, 2000)
@ -60,21 +65,27 @@ class Home extends Component {
token: {valid: false},
logged: true,
onHold: true,
user: {Name: ''}
user: {Name: ''},
userDetails:{},
appState: AppState.currentState,
};
}
handleConnectivityChange = () => {
handleConnectivityChange = () => {
console.log("asdasdasdasdasd");
}
componentDidMount() {
NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
this.props.hold();
componentDidMount() {
// NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
// this.props.hold();
console.log("hold"+ this.props.onHold)
//this.props.logoutUser();
//console.log(this.props.token);
this.props.getUserInfo(this.props.token);
this.props.getUserInfo(this.props.userDetails.token);
//console.log('logged:'+this.props.logged);
@ -85,7 +96,7 @@ class Home extends Component {
}
componentWillUnmount() {
NetInfo.isConnected.removeEventListener('connectionChange', this.handleConnectivityChange);
}
bClick() {
@ -101,8 +112,8 @@ class Home extends Component {
//var navigate = this.props.navigation.navigate
}
_update=()=>{
if(this.props.token!= undefined)
this.props.getUserInfo(this.props.token);
this.props.getUserInfo(this.props.userDetails.token);
}
@ -173,36 +184,6 @@ _update=()=>{
<View style={styles.userBio}>
<View style={styles.userBioRow}>
<Icon name="ios-laptop" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Job}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-mail" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Email}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-phone-portrait" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Mobile}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-map" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Address}, {this.props.user.City}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-person" style={styles.userBioLogo} size={25}/>
<TouchableOpacity><Text style={styles.userCurriculum}>O meu Curriculo</Text></TouchableOpacity>
</View>
</View>
@ -342,7 +323,9 @@ function mapStateToProps(state, props) {
token: state.apiReducer.token,
user: state.apiReducer.user,
logged: state.apiReducer.logged
logged: state.apiReducer.logged,
userDetails: state.apiReducer.userDetails,
onHold: state.apiReducer.onHold
}
}

722
App/app/screens/Jogo.js Normal file
View File

@ -0,0 +1,722 @@
import React from 'react';
import {
StyleSheet,
Text,
View,
ImageBackground,
Dimensions,
Button,
TouchableOpacity
} from 'react-native';
import ProgressBarAnimated from 'react-native-progress-bar-animated';
import Modal from "react-native-modal";
import IconF from "react-native-vector-icons/Foundation"
import IconFA from "react-native-vector-icons/FontAwesome5"
import { ScrollView, ViewPagerAndroid } from 'react-native-gesture-handler';
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
import FitImage from 'react-native-fit-image';
export default class Jogo extends React.Component {
state = {
progress: 20,
progressWithOnComplete: 0,
progressCustomized: 0,
isModalVisible: false,
} ;
increase = (key, value) => {
this.setState({
[key]: this.state[key] + value,
});
}
_toggleModal = () =>{
this.setState({ isModalVisible: !this.state.isModalVisible });
console.log("assd")
}
render() {
const { navigate } = this.props.navigation;
const progressCustomStyles = {
backgroundColor: 'red',
borderRadius: 0,
borderColor: 'orange',
};
const barWidth = Dimensions.get('screen').width - 30;
return (
<View style={styles.container}>
<Modal
isVisible={this.state.isModalVisible}
animationInTiming={1000}
animationOutTiming={800}
>
<View style={{
flex:1,
alignContent:'center',
margin :SCREEN_WIDTH*0.1,
backgroundColor:'white',
marginBottom:SCREEN_HEIGHT*0.1,
marginTop:SCREEN_HEIGHT*0.1,
maxHeight:400
}}>
<ImageBackground
opacity={0.5}
source={require('../assets/img/bg_3.jpg')}
style={{
width:'96%',
height:'97.5%',
margin:10
}}
>
<View style={{width:'100%' ,margin:-10}}>
<View style={{width:30}}><Button
onPress={this._toggleModal}
title="X"
color="#CC1A17"
accessibilityLabel="Learn more about this purple button"
/>
</View>
</View>
<View style={{flex:1, alignContent:'center', width:'96%', alignItems:'center'}}>
<View style={{paddingTop:25,width:'40%',}}>
<FitImage
source={{ uri: 'https://upload.wikimedia.org/wikipedia/commons/8/8a/CSW_Gradiente_rgb.png' }}
style={styles.fitImage}
/>
</View>
<View style={{backgroundColor:'rgba(255,255,255,0.6)', width:'100%', marginTop:35}}>
<Text style={{padding:10}}>A CRITICAL Software fornece sistemas e serviços de software para segurança e
aplicações essenciais aos negócios, ajudando a garantir que os clientes atendam aos requisitos mais exigentes de qualidade - padrões de segurança, desempenho e fiabilidade</Text>
</View>
<View style={{width:'100%', marginTop:10}}><TouchableOpacity><Text style={{textAlign:'center', fontWeight:'bold', fontSize:18, color:'#CC1A17'}}>website</Text></TouchableOpacity></View>
</View>
</ImageBackground>
</View>
</Modal>
<View style={styles.header}>
<View style={styles.titleContainer}>
<Text style={styles.title}>Jogo do ENEI'19</Text>
</View>
</View>
<View style={{ height:50, backgroundColor:'white'}}>
<View style={{flex:1, justifyContent:'space-around', flexDirection:'row'}}>
<View style={{width:SCREEN_WIDTH*0.7, flex:1, flexDirection:'row',margin:10, marginLeft:SCREEN_WIDTH*0.10}}>
<IconFA name="trophy" size={30}/>
<Text style={{fontWeight:'bold', fontSize:20,marginLeft:10}}>45</Text>
<Text style={{margin:5}}>pontos</Text>
</View>
<View style={{width:SCREEN_WIDTH*0.3, marginTop:8, marginRight:SCREEN_WIDTH*0.1}}>
<Button
onPress={this._toggleModal}
title="Prémios"
color="#CC1A17"
accessibilityLabel="Learn more about this purple button"
/>
</View>
</View>
</View>
<View style={styles.progress}>
<View style={{ alignItems:'center'}}>
</View>
<View style={{backgroundColor:'#FDFDFD', shadowColor:"#000", shadowOffset:{height:2, width:0, shadowRadius:1}, elevation:3,}}>
<View style={{flex:1,margin: 20, alignItems:'center',flexDirection:'row', justifyContent: 'space-around',}}>
<Text style={{fontWeight:'bold'}} > 1 </Text>
<ProgressBarAnimated
width={barWidth*0.7}
value={this.state.progress}
backgroundColorOnComplete="#CC2A17"
/>
<Text style={{fontWeight:'bold'}}> 2 </Text>
</View>
</View>
</View>
<ScrollView style={{backgroundColor:'#eeeeee',marginTop:10}} horizontal={true}>
<ScrollView>
<View style={styles.cromosContainer}>
<TouchableOpacity onPress={this._toggleModal}>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/critical.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>0</Text>
</ImageBackground>
</View>
</TouchableOpacity>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/novabase.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>1</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>2</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>3</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>4</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>5</Text>
</ImageBackground>
</View>
</View>
<View style={styles.cromosContainer}>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>6</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/ubiwhere.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>7</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>8</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>9</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>10</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>11</Text>
</ImageBackground>
</View>
</View>
<View style={styles.cromosContainer}>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>12</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>13</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>14</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>15</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>16</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>17</Text>
</ImageBackground>
</View>
</View>
<View style={styles.cromosContainer}>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>18</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>19</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>20</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>21</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>22</Text>
</ImageBackground>
</View>
<View style={styles.cromo}>
<ImageBackground
source={require('../assets/img/jogo/enei_black_2.png')}
style={styles.imageBg}
>
<View style={[styles.triangle, this.props.style]} />
<Text style={styles.points}>15</Text>
<View style={[styles.triangleNumber, this.props.style]} />
<Text style={styles.number}>23</Text>
</ImageBackground>
</View>
</View>
</ScrollView>
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
fitImage:{
},
points:{
marginTop:-25,
marginLeft:10,
fontWeight:'bold',
color:'#CC1A17'
},
cromosContainer:{
flex:1,
flexDirection:'row',
flexWrap: 'wrap',
justifyContent: 'space-around',
marginLeft:10,
marginRight:10,
},
cromo:
{
backgroundColor:'white',
margin:3,
height:200,
width:130,
borderRadius:0}
,
imageBg:{
height:190,
margin:5
},
label:{
margin:10
},
progress:{
backgroundColor:'#eeeeee',
shadowColor:'#000',
shadowOffset:{width:0, height:2},
shadowRadius:1,
elevation:1,
},
title:{
fontWeight:'bold',
fontSize:25,
color:'white',
textAlign:'center'
},
titleContainer:{
margin:10,
},
header:{
backgroundColor:'#CC2A17',
//alignItems:'center',
shadowColor:'#000',
shadowOffset:{width:0, height:2},
shadowRadius:1,
elevation:5,
},
container: {
flex: 1,
backgroundColor: '#eeeeee',
// alignItems: 'center',
//justifyContent: 'space-around',
},
triangle: {
width: 0,
height: 0,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderLeftWidth:67,
borderRightWidth: 0,
borderBottomWidth: 20,
transform: [{ rotate: '180deg'}],
borderLeftColor: 'transparent',
borderRightColor: 'transparent',
borderBottomColor: 'white'
},
triangleNumber: {
width: 0,
height: 0,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderLeftWidth:67,
borderRightWidth: 0,
borderBottomWidth: 20,
transform: [{ rotate: '0deg'}],
borderLeftColor: 'transparent',
borderRightColor: 'transparent',
borderBottomColor: 'white',
marginLeft:54,
marginTop:156
},
number:{
marginTop:-18,
marginLeft:103,
textAlign: 'center'
}
});

View File

@ -1,155 +1,374 @@
import React, {Component} from 'react'
import {Card, Divider} from 'react-native-elements'
import {
Image,
ImageBackground,
Linking,
ListView,
Platform,
ScrollView,
StyleSheet,
Text,
View,
TouchableOpacity,
Dimensions,
TextInput,
Button
} from 'react-native'
import PropTypes from 'prop-types';
import {connect, Provider} from "react-redux";
import {bindActionCreators} from "redux";
import * as Actions from "../store/actions";
import {createStore} from 'redux';
import Email from '../components/Email';
import Separator from '../components/Separator';
import Tel from '../components/Telephone';
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
import Icon from "react-native-vector-icons/Ionicons"
class Profile extends Component {
constructor(props) {
super(props);
this.state = {
token: false,
tokenData: '',
loggedIn: false,
onHold: true,
user: {},
cenas:{Name:'as'},
text:'',
};
}
_logout = () => {
// this.props.navigation.navigate('scan');
// this.props.logout();
this.props.logoutUser();
}
render() {
return (
<ScrollView>
<View style={styles.container}>
<View style={styles.userBio}>
<View style={styles.userBioRow}>
<Icon name="ios-laptop" style={styles.userBioLogo} size={25}/>
<TextInput
onFocus={this._print}
maxLength={50}
blurOnSubmit ={true}
onChangeText={(text) => this.setState({text})}
value={this.props.user.Job}
/>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-mail" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Email}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-phone-portrait" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Mobile}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-map" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Address}, {this.props.user.City}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-person" style={styles.userBioLogo} size={25}/>
<TouchableOpacity><Text style={styles.userCurriculum}>O meu Curriculo</Text></TouchableOpacity>
</View>
<Button onPress={this._logout} title="LOGOUT"/>
</View>
</View>
</ScrollView>
)
}
}
const styles = StyleSheet.create({
container:{
},
userBioRow:{
flex:1,
flexDirection:'row',
padding:10,
},
userBioText:{
},
userBioLogo:{
marginLeft: SCREEN_WIDTH*0.05,
width: SCREEN_WIDTH*0.15,
},
});
mapStateToProps = (state, props) => {
return {
token: state.apiReducer.token,
user: state.apiReducer.user
}
};
function mapDispatchToProps(dispatch) {
return bindActionCreators(Actions, dispatch);
}
import React, {Component} from 'react'
import {Card, Divider,} from 'react-native-elements'
import {
Image,
ImageBackground,
Linking,
ListView,
Platform,
ScrollView,
StyleSheet,
Text,
View,
TouchableOpacity,
Dimensions,
TextInput,
Button,
} from 'react-native'
import PropTypes from 'prop-types';
import {connect, Provider} from "react-redux";
import {bindActionCreators} from "redux";
import * as Actions from "../store/actions";
import {Validate} from '../Helpers/Validation'
import {RkTextInput} from 'react-native-ui-kitten';
import {createStore} from 'redux';
import Email from '../components/Email';
import Separator from '../components/Separator';
import Tel from '../components/Telephone';
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
import Icon from "react-native-vector-icons/Ionicons"
class Profile extends Component {
constructor(props) {
super(props);
this.state = {
name:this.props.user.Name,
userDetails:{},
token: false,
tokenData: '',
loggedIn: false,
onHold: true,
user: {},
cenas: {Name: 'as'},
text: '',
formValid: true,
jobs: this.props.user.Company,
jobsError: false,
jobsErrorMessage: '',
email: this.props.user.Email,
emailError: false,
emailErrorMessage: '',
phone: this.props.user.Mobile,
phoneError: false,
phoneErrorMessage: '',
address: this.props.user.Address,
addressError: false,
addressErrorMessage: '',
city: this.props.user.City,
cityError: false,
cityErrorMessage: '',
};
}
_logout = () => {
this.props.logoutUser();
};
_validateData = (name,jobs, email, phone, address, city) => {
let valid = null;
v = Validate('name',name );
let v = Validate('email', email);
this.setState({emailError: v[0], emailErrorMessage: v[1]});
v = Validate('jobs', jobs);
// setState is asynchronous and so trying to work with state directly after a setState
// call won't work as the update won't necessarily have run. Instead you can use the second argument to setState which is a callback
this.setState({jobsError: v[0], jobsErrorMessage: v[1]}, () => {
console.log('email error: ' + this.state.emailError + ' job Error: ' + this.state.jobsError);
});
v = Validate('city', city);
// setState is asynchronous and so trying to work with state directly after a setState
// call won't work as the update won't necessarily have run. Instead you can use the second argument to setState which is a callback
this.setState({cityError: v[0], cityErrorMessage: v[1]})
v = Validate('address', address);
// setState is asynchronous and so trying to work with state directly after a setState
// call won't work as the update won't necessarily have run. Instead you can use the second argument to setState which is a callback
this.setState({addressError: v[0], addressErrorMessage: v[1]});
v = Validate('city', city);
// setState is asynchronous and so trying to work with state directly after a setState
// call won't work as the update won't necessarily have run. Instead you can use the second argument to setState which is a callback
this.setState({cityError: v[0], cityErrorMessage: v[1]}, () => {
console.log(this.state.cityError + ' Error: ' + this.state.addressError);
if (this.state.emailError || this.state.jobsError || this.state.phoneError || this.state.addressError || this.state.cityError)
this.setState({formValid: false});
});
};
saveData() {
const {name,jobs, email, phone, address, city, formValid} = this.state;
this._validateData(name,jobs, email, phone, address, city);
console.log(formValid);
if (formValid){
console.log("data valid");
this.props.updateUser(this.props.userDetails.token,{
Name: this.state.name,
// LastName: "Último",
Company: jobs,
// Job: jobs,
Address: address,
City: city,
// PostalCode: "3000-010",
Mobile: phone,
Avatar: "base64"
} ); this.props.getUserInfo(this.props.userDetails.token);
}
else
console.log("data not valid");
}
render() {
return (
<View style={{flex: 1}}>
<ScrollView style={{backgroundColor: '#eee'}}>
<View style={styles.container}>
<View style={styles.userBioRowHeader}>
<View style={styles.userBioRowTitle}>
<Text style={{color: '#CC1A17', fontWeight: 'bold', fontSize: 20}}>User Bio</Text>
</View>
<View>
<TouchableOpacity onPress={() => this.saveData()}>
<Icon name="ios-save" size={30}/><Text>Save</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.userBio}>
<View style={styles.userBioRow}>
<Icon name="ios-person" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(n) => {
this.setState({name:n })
}}
value={this.state.name}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-laptop" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(job) => {
this.setState({jobs: job})
}}
value={this.state.jobs}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-phone-portrait" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(phone) => {
this.setState({phone: phone})
}}
value={this.state.phone}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-map" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(add) => {
this.setState({address: add})
}}
value={this.state.address}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-map" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(city) => {
this.setState({city: city})
}}
value={this.state.city}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-person" style={styles.userBioLogo} size={25}/>
<TouchableOpacity>
<Text style={styles.userCurriculum}>O meu Curriculo</Text>
</TouchableOpacity>
</View>
</View>
</View>
{/*PassWord Edit*/}
<View style={styles.container}>
<View style={styles.userBioRowHeader}>
<View style={styles.userBioRowTitle}>
<Text style={{color: '#CC1A17', fontWeight: 'bold', fontSize: 20}}>Nova Password:</Text>
</View>
</View>
<View style={styles.userBio}>
<View style={styles.userBioRow}>
<Text style={styles.userPassText} size={25}>
Old Password:
</Text>
<TextInput style={styles.userBioText}
placeholder='Antiga Password' secureTextEntry={true}
/>
</View>
<View style={styles.userBioRow}>
<Text style={styles.userPassText} size={25}>
Nova Password:
</Text>
<TextInput style={styles.userBioText}
placeholder='Nova Password' secureTextEntry={true}
/>
</View>
<View style={styles.userBioRow}>
<Text style={styles.userPassText} size={25}>
Repetir Password:
</Text>
<TextInput style={styles.userBioText}
placeholder='Repetir Password' secureTextEntry={true}
/>
</View>
</View>
</View>
</ScrollView>
<TouchableOpacity onPress={this._logout} style={{ height: 50, justifyContent: 'center', alignItems: 'center', backgroundColor: '#CC1A17'}}>
<Text style={{color:"#fff", fontWeight: 'bold'}}>Logout</Text>
</TouchableOpacity>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 10,
margin: 20,
backgroundColor: 'white',
borderRadius: 5,
},
userBioRowHeader: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
userBioRowTitle: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-start',
padding: 10,
},
userBioRow: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-start',
padding: 10
},
userBioText: {
width: SCREEN_WIDTH * 0.50,
},
userPassText: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-start',
},
userBioLogo: {
marginLeft: SCREEN_WIDTH * 0.05,
width: SCREEN_WIDTH * 0.15,
},
bottomLogOut: {
height: 20,
},
});
mapStateToProps = (state, props) => {
return {
token: state.apiReducer.token,
user: state.apiReducer.user,
userDetails: state.apiReducer.userDetails,
}
};
function mapDispatchToProps(dispatch) {
return bindActionCreators(Actions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(Profile);

View File

@ -1,22 +0,0 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class Social extends React.Component {
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Text style={styles.title}>Social</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'space-around',
}
});

View File

@ -7,7 +7,12 @@ import {
ScrollView,
Text,
Button,
TouchableOpacity
TouchableOpacity,
Picker,
CheckBox,
ActivityIndicator,
SectionList,
FlatList
} from 'react-native';
import {TabView, TabBar, SceneMap} from 'react-native-tab-view';
@ -32,6 +37,10 @@ const SCREEN_WIDTH = Dimensions.get("window").width;
import FitImage from 'react-native-fit-image';
import { Dropdown } from 'react-native-material-dropdown';
import {Card, Divider} from 'react-native-elements'
import IconF from "react-native-vector-icons/Foundation"
import LinearGradient from 'react-native-linear-gradient';
const formatObj = (obj) => {
@ -46,15 +55,28 @@ const formatObj = (obj) => {
class choosePath extends React.Component {
state = {
static navigationOptions = ({ navigation }) => ({
headerTitleStyle : {textAlign: 'center',alignSelf:'center'},
headerStyle:{
backgroundColor:'rgba(0,0,0,0)',
shadowRadius:0,
elevation:0
},
});
state = {
calendar:{},
guest:'9'
};
componentDidMount() {
this.props.getEvents(this.props.user);
// this.props.getEvents(this.props.user);
this.props.getAvailableGuestlists(this.props.userDetails.token)
console.log('didMount');
console.log(this.props.events);
}
@ -79,97 +101,302 @@ class choosePath extends React.Component {
]
}
getCareerPaths=()=>{
this.props.getAvailableGuestlists(this.props.userDetails.token)
console.log(this.props.calendar)
}
_keyExtractor = (item, index) => item.id;
_renderItem = ({item}) => (
<MyListItem
id={item.id}
onPressItem={this._onPressItem}
selected={!!this.state.selected.get(item.id)}
title={item.title}
/>
);
_onPressItem = (id) => {
// updater functions are preferred for transactional updates
this.setState((state) => {
// copy the map rather than modifying state.
const selected = new Map(state.selected);
selected.set(id, !selected.get(id)); // toggle
return {selected};
});
};
render() {
let data = [{
value: 'Desenvolvimento Web',
}, {
value: 'Inteligencia artificial',
}, {
value: 'Redes e segurança',
}];
return (
<View style={{width:SCREEN_WIDTH*0.7}}>
<Dropdown
label='Career Path'
data={data}
/>
</View>
<ScrollView style={styles.page}>
{this.state.guest=='9' && <LinearGradient colors={[ '#D95856', '#CC1A17']} style={styles.linearGradient}>
<Text style={{margin:15,marginBottom:0, fontWeight:'bold', color:'white'}}> Empresa responsável: </Text>
<View style={styles.companyContainer}>
<View style={styles.companyDescription}>
<Text style={{fontSize:16, fontWeight:'bold', margin:6, color:'white'}}>Critical Software</Text>
<Text style={{margin:6, marginTop:0, color:'white'}}>A CRITICAL Software fornece sistemas e serviços de software para segurança e
aplicações essenciais aos negócios.</Text>
</View>
<View style={styles.companyLogo}>
<FitImage
source={{ uri: 'https://upload.wikimedia.org/wikipedia/commons/8/8a/CSW_Gradiente_rgb.png' }}
style={styles.fitImage}
/>
</View>
</View>
</LinearGradient>}
{this.state.guest=='10' && <LinearGradient colors={[ '#5887FF', '#715AFF']} style={styles.linearGradient}>
<Text style={{margin:15,marginBottom:0, fontWeight:'bold', color:'white'}}> Empresa responsável: </Text>
<View style={styles.companyContainer}>
<View style={styles.companyDescription}>
<Text style={{fontSize:16, fontWeight:'bold', margin:6, color:'white'}}>Altice</Text>
<Text style={{margin:6, marginTop:0, color:'white'}}>Altice é uma multinacional neerlandesa de telecomunicações, conteúdos, media, entretenimento e publicidade.</Text>
</View>
<View style={styles.companyLogo}>
<FitImage
source={{ uri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTuIfl0Km4mTbCGdJSr4bWn_ApFHnOrjYsmJ4VlBL1OkaIlb93t' }}
style={styles.fitImage}
/>
</View>
</View>
</LinearGradient>}
<View style={{flex:1,width:SCREEN_WIDTH*0.7, alignContent:'center'}}>
<View style={styles.pickerCareer}>
<Picker
selectedValue={this.state.guest}
style={{width:'100%'}}
onValueChange={(itemValue, itemIndex) =>{
this.setState({guest: itemValue})
this.props.waitChangeGuest();
this.props.changeGuestList(this.props.userDetails.token,itemValue)
this.props.waitChangeGuest();
this.props.getAvailableSessions(this.props.userDetails.token);
}
}>
<Picker.Item label="Inteligência Artificial" value="9" />
<Picker.Item label="Redes e Segurança" value="10" />
<Picker.Item label="Data Science" value="15" />
<Picker.Item label="Desenvolvimento Web" value="14" />
<Picker.Item label="Internet das Coisas" value="12" />
<Picker.Item label="Desenvolvimento Mobile" value="11" />
</Picker>
</View>
<FlatList
data={this.state.data}
renderItem={({ item }) => (
<ListItem
title={`${item.name.first} ${item.name.last}`}
subtitle={item.email}
avatar={{ uri: item.picture.thumbnail }}
containerStyle={{ borderBottomWidth: 0 }}
/>
)}
keyExtractor={item => item.email}
/>
</View >
{ !this.props.changingGuest &&
<View style={styles.block}>
<View style={styles.time}>
<Text style={
{
margin:10,
fontSize:25,
color:'#CC1A17',
marginBottom:0
}
}>
9:00</Text>
<Text style={{marginLeft:20}}>até</Text>
<Text style={
{
margin:10,
fontSize:25,
color:'#CC1A17',
marginTop:5
}
}>
9:30</Text>
</View>
<View style={styles.sessions}>
<View style={styles.session}>
<CheckBox
style={{margin:10}}
value={this.state.checkbox1}
onChange={() => this.setState({ checkbox1: !this.state.checkbox1 })}
/>
<TouchableOpacity><View style={styles.sessionInfo}>
<Text style={styles.sessionTitle}>Nome da palestra</Text>
<Text style={{marginTop:10, marginBottom:5}}>12 Lugares disponíveis</Text>
<Progress.Bar color={'#000000'} progress={0.3} unfilledColor={'white'} width={150}/>
</View></TouchableOpacity>
</View>
<Divider style={{ backgroundColor: '#eeeeee' }} />
<View style={styles.session}>
<CheckBox
style={{margin:10}}
value={this.state.checkbox1}
onChange={() => this.setState({ checkbox1: !this.state.checkbox1 })}
/>
<TouchableOpacity><View style={styles.sessionInfo}>
<Text style={styles.sessionTitle}>Nome da palestra</Text>
<Text style={{marginTop:10, marginBottom:5}}>12 Lugares disponíveis</Text>
<Progress.Bar color={'#000000'} progress={0.3} unfilledColor={'white'} width={150}/>
</View></TouchableOpacity>
</View>
<Divider style={{ backgroundColor: '#eeeeee' }} />
<View style={styles.session}>
<CheckBox
style={{margin:10}}
value={this.state.checkbox1}
onChange={() => this.setState({ checkbox1: !this.state.checkbox1 })}
/>
<TouchableOpacity><View style={styles.sessionInfo}>
<Text style={styles.sessionTitle}>Nome da palestra</Text>
<Text style={{marginTop:10, marginBottom:5}}>12 Lugares disponíveis</Text>
<Progress.Bar color={'#000000'} progress={0.3} unfilledColor={'white'} width={150}/>
</View></TouchableOpacity>
</View>
<Divider style={{ backgroundColor: '#eeeeee' }} />
</View>
</View>
}
{this.props.changingGuest &&
<ActivityIndicator size="large" color="red"/>
}
</ScrollView>
);
}
}
const styles = StyleSheet.create({
carreerPathContainer:{
backgroundColor:'#CC1A17',
height:50,
flex:1,
alignItems:'center',
justifyContent:'center',
paddingTop:15,
companyLogo:{
backgroundColor:'white',
margin:20,
width:SCREEN_WIDTH*0.35,
borderRadius:3,
padding:5
},
carreerPathText:{
height:50,
color:'white',
fontWeight:'bold',
companyDescription:{
// backgroundColor:'white',
margin:20,
marginRight:0,
width:SCREEN_WIDTH*0.5,
borderRadius:3,
},
sessionInfo:{
margin:5
},
sessionTitle:{
fontSize:15,
fontWeight:'bold'
},
day:{
margin:10
},
dayText:{
fontSize:20,
},
companyHeader:{
backgroundColor:'#dddddd',
// height:150,
borderRadius:5,
margin:10,
padding:10
},
companyTitle:{
paddingBottom:5,
fontWeight:'bold',
color:'#777777',
fontSize:17,
// padding:20
},
companyLogo: {
borderRadius: 20,
},
wrapper: {
color: '#CC1A17',
textAlign: 'center',
},
company:{
time:{
alignContent:'center',
width:SCREEN_WIDTH*0.20,
backgroundColor:'white'
},
block:{
flex:1,
flexDirection:'row',
// backgroundColor:'red',
color:'black'
},
companyLogoContainer:{
flex:1,
justifyContent: 'center',
width:'60%',
// backgroundColor:'white',
margin:20,
backgroundColor:'red',
margin:10,
borderRadius:5
},
aboutCompany:{
width:SCREEN_WIDTH,
flex:1,
justifyContent: 'center',
alignItems: 'center',
}
companyContainer:{
flex:1,
// backgroundColor:'blue',
flexDirection:'row',
marginTop:0
},
sessions:{
flex:1,
flexDirection:'column',
backgroundColor:'white',
},
page:{
backgroundColor:'#eeeeee',
},
pickerCareer:{
paddingLeft:30,
paddingRight:30,
backgroundColor:'white',
width:SCREEN_WIDTH,
},
session:{
margin:10,
flex:1,
flexDirection:'row',
}
});
@ -179,10 +406,15 @@ function mapStateToProps(state, props) {
return {
token: state.apiReducer.token,
// token: state.apiReducer.token,
user: state.apiReducer.user,
logged: state.apiReducer.logged,
events: state.apiReducer.events
events: state.apiReducer.events,
userDetails: state.apiReducer.userDetails,
calendar : state.apiReducer.calendar,
changingGuest : state.apiReducer.changingGuest,
sessions:state.apiReducer.sessions,
}
}

View File

@ -11,7 +11,12 @@ export const HOLD='HOLD'
export const GET_EVENTS='GET_EVENTS'
//API BLUETREND CALENDÁRIO
export const GET_CAREERS='GET_CAREERS' //GET GEST LISTS
export const CHANGE_GUEST = 'CHANGE_GUEST'
export const GET_SESSIONS= 'GET_SESSIONS'
export const SIGN_SESSION= 'SIGN_SESSION'
export const WAIT_CHANGE='WAIT_CHANGE'
//UI

View File

@ -1,48 +1,202 @@
import { AsyncStorage } from 'react-native';
const axios = require('axios');
import { NetInfo } from 'react-native';
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 { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD, GET_EVENTS, GET_CAREERS, GET_SESSIONS, CHANGE_GUEST, WAIT_CHANGE } from "./actionTypes" //Import the actions types constant we defined in our actions
import moment from 'moment'
import { compose } from 'redux';
const axios = require('axios');
axios.defaults.baseURL = 'http://enei2019.uingress.com/internal/api'
//http://enei2019.uingress.com/internal/api/Attendee/Edit
export function updateUser(token, user){
axios.defaults.headers.common = {'Authorization': `bearer ${token.access_token}`}
console.log("asdasdasdasd")
return (dispatch)=>{
axios.post('/Attendee/Edit', user).then(a=>{
console.log(a);
alert("guardado com sucesso")
dispatch({
type: UPDATE_USER
// guests: response.data
});
}).catch(b=>{
alert("Erro a guardar os dados")
});
}
}
export const waitChangeGuest= ()=>{
return (dispatch)=>{
dispatch({
type: WAIT_CHANGE,
});
}
}
export const connectionState = (status) => {
console.log(status);
return { type: 'CHANGE_CONNECTION_STATUS', isConnected: status };
};
export function getEvents(user){
///Attendee/AvailableGuestlists
export function getAvailableGuestlists(token){
axios.defaults.headers.common = {'Authorization': `bearer ${token.access_token}`}
return (dispatch)=>{
axios.get('/Attendee/AvailableGuestlists')
.then(function (response) {
// handle success
console.log(response);
dispatch({
type: GET_CAREERS,
guests: response.data
});
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
}
}
/*
8 - group
9 - IA
10 - NET
11 - MOB
12 - IOT
14 - WB
15 - DS
*/
export function changeGuestList(token, guestID){
//http://enei2019.uingress.com/internal/api/Attendee/ChangeGuestlist/
axios.defaults.headers.common = {'Authorization': `bearer ${token.access_token}`}
return (dispatch)=>{
var full= `/Attendee/ChangeGuestlist/${guestID}`
console.log(full)
axios.get(full)
.then(function (response) {
// handle success
console.log(response);
dispatch({
type: CHANGE_GUEST,
//guests: response.data
});
})
.catch(function (error) {
// handle error
console.log(response);
console.log(error);
})
.then(function () {
// always executed
});
}
}
export function getAvailableSessions(token){
//http://enei2019.uingress.com/internal/api/Attendee/AvailableSessions
axios.defaults.baseURL = 'http://enei2019.uingress.com/internal/api'
axios.defaults.headers.common = {'Authorization': `bearer ${token.access_token}`}
return (dispatch)=>{
axios.get('/Attendee/AvailableSessions')
.then(function (response) {
// handle success
console.log(response);
dispatch({
type: GET_SESSIONS,
sessions: response.data
});
})
.catch(function (error) {
alert("Error a obter sessões disponíveis!!");
console.log(error);
})
.then(function () {
// always executed
});
}
}
export function getEvents(user){
return (dispatch)=>{
let events = [];
console.log("chegou aqui")
for(let key in user.Sessions){
for(let key in user.Sessions){
events.push({
time: moment(user.Sessions[key].SessionStart).format('h:mm'),
timeEnd: moment(user.Sessions[key].SessionEnd).format('h:mm'),
//lineColor:'#009688',
imageUrl: 'https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/Vjkyj2hBg/welcome-white-sign-with-falling-colorful-confetti-animation-on-white-background_sglmmh3qm__F0013.png',
description:user.Sessions[key].Description,
name:user.Sessions[key].Name,
Enrolled:user.Sessions[key].Enrolled,
MaxAttendees:user.Sessions[key].MaxAttendees
events.push({
time: moment(user.Sessions[key].SessionStart).format('h:mm'),
timeEnd: moment(user.Sessions[key].SessionEnd).format('h:mm'),
//lineColor:'#009688',
imageUrl: 'https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/Vjkyj2hBg/welcome-white-sign-with-falling-colorful-confetti-animation-on-white-background_sglmmh3qm__F0013.png',
description:user.Sessions[key].Description,
name:user.Sessions[key].Name,
Enrolled:user.Sessions[key].Enrolled,
MaxAttendees:user.Sessions[key].MaxAttendees
})
}
}
dispatch({
dispatch({
type: GET_EVENTS,
events: events
});
});
}
}
}
const saveToken = async token => {
@ -78,17 +232,17 @@ const saveToken = async token => {
obj.access_token = await AsyncStorage.getItem('userToken') || 'none';
obj.expirationDateToken = await AsyncStorage.getItem('expirationDateToken') || 'none';
obj.refreshToken = await AsyncStorage.getItem('refreshToken') || 'none';
} catch (error) {
// Error retrieving data
console.log(error.message);
}
return obj;
}
}
const deleteToken = async () => {
try {
await AsyncStorage.removeItem('userToken');
await AsyncStorage.removeItem('expirationDateToken');
@ -101,12 +255,8 @@ const deleteToken = async () => {
const renewToken=(refresh)=>{
}
export function login(user, pass){
return (dispatch)=>{
@ -123,17 +273,17 @@ export function login(user, pass){
for (var property in details) {
var encodedKey = encodeURIComponent(property);
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(details[property]);
var encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
fetch('http://enei2019.uingress.com/internal/api/token', {
fetch('https://tickets.enei.pt/internal/api/token', {
method: 'POST',
@ -147,6 +297,7 @@ export function login(user, pass){
}).catch(err=>{
console.log(err);
alert("Erro no login!!");
alert("error");
co
@ -156,9 +307,6 @@ export function login(user, pass){
failedAttempt:true,
tokenData:'error'
});
}).then(res=>res.json()).then(parsed=>{
if(parsed.error_description=="Provided username and password is incorrect"){
@ -166,7 +314,8 @@ export function login(user, pass){
type: API_LOGIN,
logged:false,
failedAttempt:true,
token: obj
token: obj,
user:{Name:'Henrique'}
});
}
@ -176,46 +325,22 @@ export function login(user, pass){
refreshToken:parsed.refresh_token,
valid:true
};
var details={
username:user,
password:pass
}
dispatch({
type: API_LOGIN,
logged:true,
failedAttempt:false,
token:obj,
user:{Name:'Henrique'},
userDetails: details
// deviceStorage.saveItem(parsed.access_token);
saveToken(obj).then(a=>{
obj.valid=true;
dispatch({
type: API_LOGIN,
logged:true,
failedAttempt:false,
token: obj
});
}).catch(a=>{
console.log('error saving')
obj.valid=false;
dispatch({
type: API_LOGIN,
logged:false,
failedAttempt:true,
token: obj
});
})
}
)
});
}
)
}
}
export function hold(){
@ -232,13 +357,14 @@ export function hold(){
export function getUserInfo(token){
return (dispatch)=>{
//TODO: verificar validade do token
console.log('Chamada "getUserInfo"');
var obj = {
method: 'GET',
@ -261,6 +387,7 @@ export function getUserInfo(token){
console.log("erro")
// dispatch({ type: USER_INFO,onHold:false});
alert("Erro a obter a informação pessoal.")
})
@ -290,124 +417,256 @@ export function logoutUser(){
}
//
function refreshToken(){
export function checkUser(){
refresh=a.refreshToken
//chamar funçao para renovar
console.log("expirou")
var details = {
return (dispatch)=>{
'grant_type': 'refresh_token',
'refresh_token':refresh
};
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'
},
getToken().then(a=>{
body: formBody
}).then(res=>res.json()).then(parsed=>{
console.log(parsed);
if(parsed.error=='invalid_grant'){
console.log(formBody);
dispatch({type: CHECK_USER, token:'', logged:false, onHold:false});
}else{
var obj={
access_token:parsed.access_token,
expirationDateToken:Math.round(new Date().getTime()/1000) + 3598,
refreshToken:parsed.refresh_token,
valid:true
if(a.access_token=='none'){
a.valid=false;
console.log('token não existe em memória')
dispatch({type: CHECK_USER,token:a,logged:false, onHold:false});
}
else{
a.valid=true;
};
// deleteToken();
saveToken(obj).then(a=>{
console.log("Token guardado" )
console.log(obj)
dispatch({type: CHECK_USER, token:obj, logged:true, onHold:false});
console.log('Existe Token em memória :'+ a.refreshToken )
//se expirar
if(Math.round(new Date().getTime()/1000) >= a.expirationDateToken){
refresh=a.refreshToken
//chamar funçao para renovar
console.log("expirou")
var details = {
})
}
'grant_type': 'refresh_token',
'refresh_token':refresh
};
}).catch(a=>{
console.log("erro na api")
dispatch({type: CHECK_USER, token:'', logged:false, onHold:false});
})
var formBody = [];
}
refreshLogin= async (user, pass)=>{
console.log("login")
console.log('user: ' +user + ' password: '+pass );
var details = {
'username': user,
'password': pass,
'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=>{
if(parsed.error_description=="Provided username and password is incorrect"){
console.error("cenas da vida")
}
else{
console.log(parsed)
var obj={
access_token:parsed.access_token,
expirationDateToken:Math.round(new Date().getTime()/1000) + 3598,
refreshToken:parsed.refresh_token,
valid:true
};
go();
return obj;
}
}
)
}
go=(t)=>{
dispatch({type: CHECK_USER, logged:true, onHold:false, user:{Name:'Henrique'}, token:t});
}
export function checkUser(userDetails){
var u= userDetails;
return (dispatch)=>{
//verifica se existe utilizador em memória
if(
userDetails.username != undefined &&
userDetails.username != '' &&
userDetails.password != undefined &&
userDetails.password != ''
){
//verifica a validade do token
if(Math.round(new Date().getTime()/1000) >= userDetails.token.expirationDateToken){
for (var property in details) {
var details = {
'username': userDetails.username,
'password': userDetails.password,
'grant_type': 'password'
};
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
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=>{
alert("Erro a validar o utilizador");
}).then(res=>res.json()).then(parsed=>{
if(parsed.error_description=="Provided username and password is incorrect"){
alert("Ups, password ou utilizador errada");
}
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
}).then(res=>res.json()).then(parsed=>{
console.log(parsed);
if(parsed.error=='invalid_grant'){
console.log(formBody);
dispatch({type: CHECK_USER, token:'', logged:false, onHold:false});
}else{
else{
console.log(parsed)
var obj={
access_token:parsed.access_token,
expirationDateToken:Math.round(new Date().getTime()/1000) + 3598,
refreshToken:parsed.refresh_token,
valid:true
};
// deleteToken();
saveToken(obj).then(a=>{
console.log("Token guardado" )
console.log(obj)
dispatch({type: CHECK_USER, token:obj, logged:true, onHold:false});
})
}
}).catch(a=>{
console.log("erro na api")
dispatch({type: CHECK_USER, token:'', logged:false, onHold:false});
})
}else{
console.log("Tempo restante token: "+ Math.round((a.expirationDateToken-Math.round(new Date().getTime()/1000) )/60) +" Minutos");
dispatch({type: CHECK_USER, logged:true, onHold:false, userDetails:u,token:obj});
}
}
)
}else{
console.log("Tempo restante token: "+ Math.round((userDetails.token.expirationDateToken-Math.round(new Date().getTime()/1000) )/60) +" Minutos");
//fazer validação da data e renovar o token
dispatch({type: CHECK_USER, token:a, logged:true, onHold:false, user:{Name:'Henrique'}});
}
//dispatch home
dispatch({type: CHECK_USER, logged:true, onHold:false, user:{Name:'Henrique'},userDetails:u});
}
}).catch(a=>{
console.log('erro a ler o token'+ a);
dispatch({type: CHECK_USER,token:false, logged:false, user:''});
})
}
}
}
//utilizador não existe em memória
else{
dispatch({type: CHECK_USER,logged:false, onHold:false,userDetails:u});
//dispatch menu de login
}
}}

View File

@ -1,5 +1,18 @@
export {checkUser, login,getEvents, hold, getUserInfo,logoutUser} from "./api"
export {openScannerLogin,closeLoginQRScan}from "./ui"
export {checkUser,
login,getEvents,
hold, getUserInfo,
logoutUser,
getAvailableGuestlists,
changeGuestList,
waitChangeGuest,
getAvailableSessions,
updateUser,
} from "./api"
export {
openScannerLogin,
closeLoginQRScan
}from "./ui"

View File

@ -1,45 +1,113 @@
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
import { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD, GET_EVENTS, GET_CAREERS, CHANGE_GUEST, WAIT_CHANGE, GET_SESSIONS } from "../actions/actionTypes" //Import the actions types constant we defined in our actions
import { REHYDRATE } from 'redux-persist';
let apiState= { isConnected:false, token:{valid:false}, tokenData:'error', logged:false, onHold:true,user:{}, events:[], failedAttempt:false}
let apiState= {
isConnected:false,
logged:false,
onHold:true,user:{},
events:[],
failedAttempt:false,
userDetails:{
username:'',
password:'',
token:{
expirationDateToken:0,
access_token:''
}
},
calendar:{
},
changingGuest:false,
sessions:{}
}
const apiReducer = (state = apiState, action) => {
switch(action.type){
case REHYDRATE:
console.log( action.payload)
return {
// ...state,
// logged:false,
//onHold:true,
user: action.payload.apiReducer.user
console.log(action)
if(action.payload!=undefined){
console.log( action.payload)
var expirationDateTokenA=0;
var access_tokenA='';
if(action.payload.apiReducer.userDetails.token!=undefined){
if(action.payload.apiReducer.userDetails.token.expirationDateToken!= undefined){
expirationDateTokenA= action.payload.apiReducer.userDetails.token.expirationDateToken;
}
if((action.payload.apiReducer.userDetails.token.access_token!= undefined)){
access_tokenA= action.payload.apiReducer.userDetails.token.access_token;
}
}
return {
// token: action.payload.apiReducer.token,
user: action.payload.apiReducer.user,
userDetails:{
token:{
expirationDateToken: expirationDateTokenA,
access_token:access_tokenA,
},
username:action.payload.apiReducer.userDetails.username,
password:action.payload.apiReducer.userDetails.password
}
};
}
case 'CHANGE_CONNECTION_STATUS':
return Object.assign({}, state, {
isConnected: action.isConnected,
});
case HOLD:
state=Object.assign({},state, { onHold:true });
return state;
case API_LOGIN:
state=Object.assign({},state, { logged:action.logged, token:action.token, failedAttempt: action.failedAttempt, user:user});
state=Object.assign({},state, {
logged:action.logged,
//token:action.token,
failedAttempt: action.failedAttempt,
user:action.user,
userDetails: {token:action.token, username:action.userDetails.username, password:action.userDetails.password},
});
return state;
case CHECK_USER:
state=Object.assign({},state, { token:action.token,logged:action.logged, onHold:action.onHold});
var u= action.userDetails;
if(action.token!=undefined)
u.token= action.token;
state=Object.assign({},state, {logged:action.logged, onHold:action.onHold, userDetails:u });
return state;
case LOGOUT_USER:
state=Object.assign({},state, { token:action.token, logged:false});
state=Object.assign({},state, { logged:false});
return state;
@ -54,9 +122,59 @@ const apiReducer = (state = apiState, action) => {
state=Object.assign({},state, { events: action.events});
return state;
case GET_CAREERS:
var c= {
guests:action.guests
}
state=Object.assign({},state, { calendar:c });
return state;
case CHANGE_GUEST:
state=Object.assign({},state, { changingGuest:false});
return state;
case WAIT_CHANGE:
state=Object.assign({},state, { changingGuest:true});
return state;
case GET_SESSIONS:
state=Object.assign({},state, { changingGuest:false, sessions:action.sessions});
return state;
default:
return state;
}

View File

@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -59,6 +58,8 @@
BE5EAB86221B7D5400E92E5B /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BE5EAB77221B7D5400E92E5B /* Zocial.ttf */; };
BE5EAC3A221B83CF00E92E5B /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BE302B75221B7C3B005626CF /* Ionicons.ttf */; };
BE5EAC41221B889900E92E5B /* libReactNativePermissions.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE5EAC40221B888C00E92E5B /* libReactNativePermissions.a */; };
4EBB88037B054A508BF35245 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F42241E0235464C91B24049 /* libRNDeviceInfo.a */; };
E677346A94D54E90817979B0 /* libRNDeviceInfo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4D43A092A4408B91B32E76 /* libRNDeviceInfo-tvOS.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -436,6 +437,9 @@
BE5EAC3B221B888C00E92E5B /* ReactNativePermissions.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativePermissions.xcodeproj; path = "../node_modules/react-native-permissions/ios/ReactNativePermissions.xcodeproj"; sourceTree = "<group>"; };
C00CE8A4E3B747F9816B91CF /* libBVLinearGradient.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libBVLinearGradient.a; sourceTree = "<group>"; };
EB0A5A258CBE4EEFAD3C358E /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = "<group>"; };
5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; name = "RNDeviceInfo.xcodeproj"; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
0F42241E0235464C91B24049 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo.a"; path = "libRNDeviceInfo.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
3C4D43A092A4408B91B32E76 /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo-tvOS.a"; path = "libRNDeviceInfo-tvOS.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -468,6 +472,7 @@
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
BE104176D74E47E9A369B15A /* libRNVectorIcons.a in Frameworks */,
69E1B84AE0DF486CB1B1D226 /* libBVLinearGradient.a in Frameworks */,
4EBB88037B054A508BF35245 /* libRNDeviceInfo.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -484,6 +489,7 @@
2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */,
2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */,
514DB1DF2E3B452F9EF272E3 /* libRNVectorIcons-tvOS.a in Frameworks */,
E677346A94D54E90817979B0 /* libRNDeviceInfo-tvOS.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -660,6 +666,7 @@
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
664970B9D10A41A18B44727F /* RNVectorIcons.xcodeproj */,
1908F5E093844AC5A143E888 /* BVLinearGradient.xcodeproj */,
5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
@ -1442,6 +1449,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = appTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@ -1451,6 +1459,8 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1471,6 +1481,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = appTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@ -1480,6 +1491,8 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1502,6 +1515,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1526,6 +1540,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1556,6 +1571,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = "app-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1564,6 +1580,8 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1593,6 +1611,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = "app-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1601,6 +1620,8 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1629,6 +1650,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = "app-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1637,6 +1659,8 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1665,6 +1689,7 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
);
INFOPLIST_FILE = "app-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1673,6 +1698,8 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",

167
App/package-lock.json generated
View File

@ -2329,6 +2329,11 @@
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
"integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg=="
},
"colors": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz",
"integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w="
},
"combined-stream": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
@ -2512,6 +2517,11 @@
"cssom": "0.3.x"
}
},
"cycle": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
"integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI="
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
@ -2573,6 +2583,11 @@
"resolved": "https://registry.npmjs.org/deep-diff/-/deep-diff-0.3.8.tgz",
"integrity": "sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ="
},
"deep-equal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz",
"integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU="
},
"deep-is": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
@ -3431,6 +3446,11 @@
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"dev": true
},
"eyes": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
},
"fancy-log": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz",
@ -4460,6 +4480,11 @@
"sshpk": "^1.7.0"
}
},
"i": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz",
"integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0="
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
@ -4868,8 +4893,7 @@
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
"dev": true
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"istanbul-api": {
"version": "1.3.7",
@ -7021,6 +7045,11 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
"ncp": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz",
"integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ="
},
"negotiator": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
@ -7477,6 +7506,11 @@
"find-up": "^2.1.0"
}
},
"pkginfo": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz",
"integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8="
},
"plist": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.1.tgz",
@ -7554,6 +7588,18 @@
"asap": "~2.0.3"
}
},
"prompt": {
"version": "0.2.14",
"resolved": "https://registry.npmjs.org/prompt/-/prompt-0.2.14.tgz",
"integrity": "sha1-V3VPZPVD/XsIRXB8gY7OYY8F/9w=",
"requires": {
"pkginfo": "0.x.x",
"read": "1.0.x",
"revalidator": "0.1.x",
"utile": "0.2.x",
"winston": "0.8.x"
}
},
"prompts": {
"version": "0.1.14",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-0.1.14.tgz",
@ -7807,6 +7853,25 @@
"prop-types": "^15.6.2"
}
},
"react-native-check-box": {
"version": "2.1.7",
"resolved": "https://registry.npmjs.org/react-native-check-box/-/react-native-check-box-2.1.7.tgz",
"integrity": "sha512-dPVOoz4jKs2je2HSHp7+XJXNyZFq8Kij7IHutigrQKzB550Dko6ZAQu/1mG1FzdUMFxxkZ2nX59KmbR0Co0T8Q==",
"requires": {
"prop-types": "^15.5.7"
}
},
"react-native-cli": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/react-native-cli/-/react-native-cli-2.0.1.tgz",
"integrity": "sha1-8s08eqG4OCjN+6Yw4t/YF992bVQ=",
"requires": {
"chalk": "^1.1.1",
"minimist": "^1.2.0",
"prompt": "^0.2.14",
"semver": "^5.0.3"
}
},
"react-native-confirmation-code-input": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/react-native-confirmation-code-input/-/react-native-confirmation-code-input-1.0.4.tgz",
@ -7816,6 +7881,11 @@
"prop-types": "^15.5.10"
}
},
"react-native-device-info": {
"version": "0.26.4",
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-0.26.4.tgz",
"integrity": "sha512-gQo/hSk26E/gK0W3QvkSv+mrBbceFszezxLfUriK3JbiUwvaOlXm6kru2jAu1XGJzfxo/JUO0Mc0lopqiPgw+A=="
},
"react-native-elements": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/react-native-elements/-/react-native-elements-1.0.0.tgz",
@ -7950,6 +8020,22 @@
"react-native-animatable": "^1.2.4"
}
},
"react-native-network-info": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/react-native-network-info/-/react-native-network-info-4.0.1.tgz",
"integrity": "sha512-ZeSkeBL/fHsFR6sAOVHMd4oMknCwsbEeL+Zewec1/3ielg8k9YcddK3wymXS7kvwV0mTB2ji4X5tI0b7XY0sDA=="
},
"react-native-offline": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/react-native-offline/-/react-native-offline-4.3.0.tgz",
"integrity": "sha512-hM+rNGHKpmagseFuhnok/c7uCrMqs70fHRzaqGBCKnTsio6ff3/wb7jomsuRjsR1Iy+DwBws+VUovcfpQAtuBQ==",
"requires": {
"lodash": "^4.17.11",
"react-redux": "^6.0.0",
"redux": "4.x",
"redux-saga": "^0.16.2"
}
},
"react-native-permissions": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-1.1.1.tgz",
@ -7963,6 +8049,14 @@
"prop-types": "^15.5.8"
}
},
"react-native-progress-bar-animated": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/react-native-progress-bar-animated/-/react-native-progress-bar-animated-1.0.6.tgz",
"integrity": "sha512-UPAAwxtBVV+sPwhgVd78SA7QybPshV5CydaV0GJyM+eZ89ikkZQSasAUAgIQwVVCW1Tj6XNrgizimXM9JdczeA==",
"requires": {
"prop-types": "^15.6.0"
}
},
"react-native-pull-to-refresh": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/react-native-pull-to-refresh/-/react-native-pull-to-refresh-2.1.3.tgz",
@ -8226,6 +8320,14 @@
"react-proxy": "^1.1.7"
}
},
"read": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
"integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=",
"requires": {
"mute-stream": "~0.0.4"
}
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
@ -8290,6 +8392,11 @@
"resolved": "https://registry.npmjs.org/redux-persist/-/redux-persist-5.10.0.tgz",
"integrity": "sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg=="
},
"redux-saga": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/redux-saga/-/redux-saga-0.16.2.tgz",
"integrity": "sha512-iIjKnRThI5sKPEASpUvySemjzwqwI13e3qP7oLub+FycCRDysLSAOwt958niZW6LhxfmS6Qm1BzbU70w/Koc4w=="
},
"redux-thunk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz",
@ -8536,6 +8643,11 @@
"resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
"integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg=="
},
"revalidator": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz",
"integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs="
},
"rimraf": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
@ -9311,6 +9423,11 @@
"tweetnacl": "~0.14.0"
}
},
"stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
},
"stack-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.2.tgz",
@ -9941,6 +10058,26 @@
"object.getownpropertydescriptors": "^2.0.3"
}
},
"utile": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/utile/-/utile-0.2.1.tgz",
"integrity": "sha1-kwyI6ZCY1iIINMNWy9mncFItkNc=",
"requires": {
"async": "~0.2.9",
"deep-equal": "*",
"i": "0.3.x",
"mkdirp": "0.x.x",
"ncp": "0.4.x",
"rimraf": "2.x.x"
},
"dependencies": {
"async": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E="
}
}
},
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
@ -10062,6 +10199,32 @@
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho="
},
"winston": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/winston/-/winston-0.8.3.tgz",
"integrity": "sha1-ZLar9M0Brcrv1QCTk7HY6L7BnbA=",
"requires": {
"async": "0.2.x",
"colors": "0.6.x",
"cycle": "1.0.x",
"eyes": "0.1.x",
"isstream": "0.1.x",
"pkginfo": "0.3.x",
"stack-trace": "0.0.x"
},
"dependencies": {
"async": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E="
},
"pkginfo": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz",
"integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE="
}
}
},
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",

View File

@ -18,7 +18,10 @@
"react-native-action-button": "^2.8.5",
"react-native-app-intro-slider": "^1.0.1",
"react-native-camera": "^1.9.2",
"react-native-check-box": "^2.1.7",
"react-native-cli": "^2.0.1",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-device-info": "^0.26.4",
"react-native-elements": "^1.0.0",
"react-native-fit-image": "^1.5.4",
"react-native-gesture-handler": "^1.0.15",
@ -30,8 +33,10 @@
"react-native-material-dropdown": "^0.11.1",
"react-native-material-shadows": "0.0.2",
"react-native-modal": "^7.0.2",
"react-native-network-info": "^4.0.1",
"react-native-offline": "^4.3.0",
"react-native-progress": "^3.5.0",
"react-native-progress-bar-animated": "^1.0.6",
"react-native-pull-to-refresh": "^2.1.3",
"react-native-qrcode-scanner": "^1.1.2",
"react-native-shadow": "^1.2.2",
@ -42,6 +47,7 @@
"react-native-vector-icons": "^6.1.0",
"react-navigation": "^3.0.9",
"react-redux": "^6.0.0",
"react-timer-mixin": "^0.13.4",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",

View File

@ -28,7 +28,6 @@ namespace api.Controllers
public UserManager<User> _userManager { get; }
public SignInManager<User> _signInManager { get; }
public IUsersRepository _repo { get; }
private readonly IMapper _mapper;
private readonly RoleManager<Role> _roleManager;

View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Data;
using api.Dtos;
using api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class EventLocsController : ControllerBase
{
private readonly DataContext context;
private readonly IEventLocsRepository _repo;
private readonly IMapper _mapper;
private readonly RoleManager<Role> _roleManager;
private readonly UserManager<User> _userManager;
public EventLocsController(DataContext context,IEventLocsRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
{
this.context = context;
_mapper = mapper;
_roleManager = roleManager;
_userManager = UserManager;
_repo = repo;
}
// GET api/EventLocs
// GET all EventLocs
[HttpGet]
public async Task<IActionResult> GetEventLocs()
{
var Teams = await _repo.GetEventLocs();
return Ok(Teams);
}
// GET api/EventLocs/[id]
[HttpGet("{id}")]
public async Task<IActionResult> GetEventLoc(int id)
{
var Teams = await _repo.GetEventLoc(id);
return Ok(Teams);
}
// GET api/EventLocs/[id]
[HttpGet("e/{id}")]
public async Task<IActionResult> GetEventLocEvent(int id)
{
var Teams = await _repo.GetEventLocEvent(id);
return Ok(Teams);
}
}
}

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Data;
using api.Dtos;
using api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class EventLocsVisitedController : ControllerBase
{
private readonly DataContext context;
private readonly IEventLocsVisitedRepository _repo;
private readonly IMapper _mapper;
private readonly RoleManager<Role> _roleManager;
private readonly UserManager<User> _userManager;
public EventLocsVisitedController(DataContext context,IEventLocsVisitedRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
{
this.context = context;
_mapper = mapper;
_roleManager = roleManager;
_userManager = UserManager;
_repo = repo;
}
// GET api/EventLocsVisited
// GET all EventLocsVisited
[HttpGet]
public async Task<IActionResult> GetEventLocsVisited()
{
var Locs = await _repo.GetEventLocsVisited();
return Ok(Locs);
}
// GET api/EventLocsVisited/t/[id]
//All locs visited by team id
[HttpGet("t/{id}")]
public async Task<IActionResult> GetEventLocsVisitedTeam(int id)
{
var Locs = await _repo.GetEventLocsVisitedTeam(id);
return Ok(Locs);
}
// GET api/EventLocsVisited/e/[id]
//All locs visited by event id
[HttpGet("e/{id}")]
public async Task<IActionResult> GetEventLocsVisitedEvent(int id)
{
var Locs = await _repo.GetEventLocsVisitedEvent(id);
return Ok(Locs);
}
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Data;
using api.Dtos;
using api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class EventsController : ControllerBase
{
private readonly DataContext context;
private readonly IEventsRepository _repo;
private readonly IMapper _mapper;
public EventsController(DataContext context,IEventsRepository repo, IMapper mapper)
{
this.context = context;
_mapper = mapper;
_repo = repo;
}
// GET api/events
// GET all events
[HttpGet]
public async Task<IActionResult> GetEvents()
{
var Events = await _repo.GetEvents();
return Ok(Events);
}
// GET api/events/[id]
// GET events id x
[HttpGet("{id}")]
public async Task<IActionResult> GetEvent(int id)
{
var Event = await _repo.GetEvent(id);
return Ok(Event);
}
}
}

View File

@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Data;
using api.Dtos;
using api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class TeamsController : ControllerBase
{
private readonly DataContext context;
private readonly ITeamsRepository _repo;
private readonly IMapper _mapper;
private readonly RoleManager<Role> _roleManager;
private readonly UserManager<User> _userManager;
public TeamsController(DataContext context,ITeamsRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
{
this.context = context;
_mapper = mapper;
_roleManager = roleManager;
_userManager = UserManager;
_repo = repo;
}
// GET api/teams
// GET all teams
[HttpGet]
public async Task<IActionResult> GetTeams()
{
var Teams = await _repo.GetTeams();
return Ok(Teams);
}
// GET api/teams/e/[id]
// GET all teams for event id
[HttpGet("e/{id}")]
public async Task<IActionResult> GetTeamsEvent(int id)
{
var Teams = await _repo.GetEventTeam(id);
return Ok(Teams);
}
// GET api/teams/e/[id]
// GET all teams for event id
[HttpGet("u/{QR}")]
public async Task<IActionResult> GetTeamsUser(String QR)
{
var Teams = await _repo.GetUserTeam(QR);
return Ok(Teams);
}
// POST api/teams/add
// create team
[HttpPost("add")]
public async Task<IActionResult> CreateTeam(TeamForAdd TeamAddDetails)
{
User tCap = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == TeamAddDetails.capQR);
List<User> memb = new List<User>();
memb.Add(tCap);
Team tAdd = new Team{EventId = TeamAddDetails.EventId, Nome = TeamAddDetails.Nome, Cap = tCap, Membros = memb, NMembros = 1, Pontos = 0};
await context.Teams.AddAsync(tAdd);
var result = context.SaveChanges();
if (result == 1)
{
return StatusCode(201);
}
return BadRequest();
}
// POST api/teams/add/member
// create team
[HttpPost("add/member")]
public async Task<IActionResult> AddTeamMember(TeamAddMember MemberToAdd)
{
User newMember = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == MemberToAdd.newQR);
Team tEdit = await context.Teams.Include(t=>t.Membros).FirstOrDefaultAsync(t=>t.Id == MemberToAdd.id);
tEdit.NMembros++;
tEdit.Membros.Add(newMember);
context.Update(tEdit);
var result = context.SaveChanges();
return StatusCode(201);
}
}
}

View File

@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore;
namespace api.Data
{
public class DataContext : IdentityDbContext<User,Role,int,IdentityUserClaim<int>,
UserRole,IdentityUserLogin<int>,IdentityRoleClaim<int>,IdentityUserToken<int>>
public class DataContext : IdentityDbContext<User,Role,int,IdentityUserClaim<int>,UserRole,IdentityUserLogin<int>,
IdentityRoleClaim<int>,IdentityUserToken<int>>
{
public DataContext(DbContextOptions<DataContext> options):base(options) { }
@ -24,31 +24,31 @@ namespace api.Data
public DbSet<Log>Logs{get;set;}
public DbSet<Product>Products{get;set;}
public DbSet<Product>Products{get;set;}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
//para o ef saber as relações
builder.Entity<UserRole>(userRole =>
{
userRole.HasKey(ur=> new {ur.UserId, ur.RoleId});
//para o ef saber as relações
builder.Entity<UserRole>(userRole =>
{
userRole.HasKey(ur=> new {ur.UserId, ur.RoleId});
userRole.HasOne( ur=>ur.Role)
.WithMany(r=>r.UserRoles)
.HasForeignKey(ur=> ur.RoleId)
.IsRequired();
userRole.HasOne( ur=>ur.Role)
.WithMany(r=>r.UserRoles)
.HasForeignKey(ur=> ur.RoleId)
.IsRequired();
userRole.HasOne( ur=>ur.User)
.WithMany(r=>r.UserRoles)
.HasForeignKey(ur=> ur.UserId)
.IsRequired();
});
}
userRole.HasOne( ur=>ur.User)
.WithMany(r=>r.UserRoles)
.HasForeignKey(ur=> ur.UserId)
.IsRequired();
});
}
}
}

View File

@ -0,0 +1,41 @@
using System;
using System.Threading.Tasks;
using api.Models;
using api.Data;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace api.Data
{
public class EventLocsRepository : IEventLocsRepository
{
public EventLocsRepository(DataContext context)
{
_context = context;
}
public DataContext _context { get; }
public async Task<EventLoc> GetEventLoc(int id)
{
var rEventLocs = await _context.EventLocs.FirstOrDefaultAsync(e=>e.Id == id);
return rEventLocs;
}
public async Task<EventLoc> GetEventLocEvent(int id)
{
var rEventLocs = await _context.EventLocs.FirstOrDefaultAsync(e=>e.EventId == id);
return rEventLocs;
}
public async Task<IEnumerable<EventLoc>> GetEventLocs()
{
var rEventLocs = await _context.EventLocs.ToListAsync();
return rEventLocs;
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Threading.Tasks;
using api.Models;
using api.Data;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace api.Data
{
public class EventLocsVisitedRepository : IEventLocsVisitedRepository
{
public EventLocsVisitedRepository(DataContext context)
{
_context = context;
}
public DataContext _context { get; }
public async Task<IEnumerable<EventLocVisited>> GetEventLocsVisited()
{
var rEventLocsVisitedList = await _context.EventLocsVisited.Include(e=>e.Team).Include(e=>e.Location).ToListAsync();
return rEventLocsVisitedList;
}
public async Task<List<EventLocVisited>> GetEventLocsVisitedTeam(int id)
{
List<EventLocVisited> allLocs = await _context.EventLocsVisited.Include(e=>e.Team).Include(e=>e.Location).ToListAsync();
List<EventLocVisited> rList = new List<EventLocVisited>();
for(var i=0;i<allLocs.Count;i++){
if(allLocs[i].Team.Id == id){
rList.Add(allLocs[i]);
}
}
return rList;
}
public async Task<List<EventLocVisited>> GetEventLocsVisitedEvent(int id)
{
List<EventLocVisited> allLocs = await _context.EventLocsVisited.Include(e=>e.Team).Include(e=>e.Location).ToListAsync();
List<EventLocVisited> rList = new List<EventLocVisited>();
for(var i=0;i<allLocs.Count;i++){
if(allLocs[i].Location.EventId == id){
rList.Add(allLocs[i]);
}
}
return rList;
}
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Threading.Tasks;
using api.Models;
using api.Data;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace api.Data
{
public class EventsRepository : IEventsRepository
{
public EventsRepository(DataContext context)
{
_context = context;
}
public DataContext _context { get; }
public async Task<Event> GetEvent(int id)
{
var Event = await _context.Events.FirstOrDefaultAsync(e=>e.Id == id);
return Event;
}
public async Task<IEnumerable<Event>> GetEvents()
{
var Events = await _context.Events.ToListAsync();
return Events;
}
}
}

View File

@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using api.Models;
namespace api.Data
{
public interface IEventLocsRepository
{
Task<IEnumerable<EventLoc>> GetEventLocs();
Task<EventLoc> GetEventLoc(int id);
Task<EventLoc> GetEventLocEvent(int id);
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using api.Models;
namespace api.Data
{
public interface IEventLocsVisitedRepository
{
Task<IEnumerable<EventLocVisited>> GetEventLocsVisited();
Task<List<EventLocVisited>> GetEventLocsVisitedTeam(int id);
Task<List<EventLocVisited>> GetEventLocsVisitedEvent(int id);
}
}

View File

@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using api.Models;
namespace api.Data
{
public interface IEventsRepository
{
Task<IEnumerable<Event>> GetEvents();
Task<Event> GetEvent(int id);
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using api.Models;
namespace api.Data
{
public interface ITeamsRepository
{
Task<IEnumerable<Team>> GetTeams();
Task<List<Team>> GetEventTeam(int id);
Task<List<Team>> GetUserTeam(String QR);
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Threading.Tasks;
using api.Models;
using api.Data;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace api.Data
{
public class TeamsRepository : ITeamsRepository
{
public TeamsRepository(DataContext context)
{
_context = context;
}
public DataContext _context { get; }
public async Task<List<Team>> GetEventTeam(int id)
{
List<Team> allTeams = await _context.Teams.Include(a=>a.Cap).Include(a=>a.Membros).ToListAsync();
List<Team> rTeam = new List<Team>();
allTeams.ForEach(delegate(Team t){
if(t.EventId == id){
rTeam.Add(t);
}
});
return rTeam;
}
public async Task<List<Team>> GetUserTeam(String QR)
{
List<Team> allTeams = await _context.Teams.Include(a=>a.Cap).Include(a=>a.Membros).ToListAsync();
List<Team> rTeam = new List<Team>();
allTeams.ForEach(delegate(Team t){
foreach (User u in t.Membros){
if(u.QRcode == QR){
rTeam.Add(t);
}
}
});
return rTeam;
}
public async Task<IEnumerable<Team>> GetTeams()
{
var rTeams = await _context.Teams.Include(a=>a.Cap).Include(a=>a.Membros).ToListAsync();
return rTeams;
}
}
}

16
api/Dtos/TeamAddMember.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using api.Models;
namespace api.Dtos
{
public class TeamAddMember
{
[Required]
public int id{get;set;} //equipa id
[Required]
public string newQR{get;set;} //novo membro
}
}

19
api/Dtos/TeamForAdd.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using api.Models;
namespace api.Dtos
{
public class TeamForAdd
{
[Required]
public int EventId{get;set;} //equipa para o evento ID
[Required]
public string Nome{get;set;} //Nome da equipa
[Required]
public string capQR{get;set;} //Capitao da equipa
}
}

View File

@ -0,0 +1,385 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using api.Data;
namespace api.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20190223232738_TeamsEvents")]
partial class TeamsEvents
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<int>("RoleId");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<int>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<int>("UserId");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("api.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Desc");
b.Property<string>("Nome");
b.HasKey("Id");
b.ToTable("Events");
});
modelBuilder.Entity("api.Models.EventLoc", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Desc");
b.Property<int>("EventId");
b.Property<int?>("ImgId");
b.Property<float>("Lat");
b.Property<float>("Long");
b.Property<string>("Nome");
b.HasKey("Id");
b.HasIndex("ImgId");
b.ToTable("EventLocs");
});
modelBuilder.Entity("api.Models.EventLocVisited", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("LocationId");
b.Property<int?>("TeamId");
b.Property<DateTime>("timestamp");
b.HasKey("Id");
b.HasIndex("LocationId");
b.HasIndex("TeamId");
b.ToTable("EventLocsVisited");
});
modelBuilder.Entity("api.Models.Photo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("DateAdded");
b.Property<string>("Description");
b.Property<bool>("IsMain");
b.Property<string>("Url");
b.Property<int>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Photos");
});
modelBuilder.Entity("api.Models.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("api.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("CapId");
b.Property<int>("EventId");
b.Property<int>("NMembros");
b.Property<string>("Nome");
b.Property<int>("Pontos");
b.Property<string>("QRcode");
b.HasKey("Id");
b.HasIndex("CapId");
b.ToTable("Teams");
});
modelBuilder.Entity("api.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("QRcode");
b.Property<string>("SecurityStamp");
b.Property<int?>("TeamId");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.HasIndex("TeamId");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("api.Models.UserRole", b =>
{
b.Property<int>("UserId");
b.Property<int>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("api.Models.Value", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("id");
b.ToTable("Values");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("api.Models.Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("api.Models.User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("api.Models.User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("api.Models.User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.EventLoc", b =>
{
b.HasOne("api.Models.Photo", "Img")
.WithMany()
.HasForeignKey("ImgId");
});
modelBuilder.Entity("api.Models.EventLocVisited", b =>
{
b.HasOne("api.Models.EventLoc", "Location")
.WithMany()
.HasForeignKey("LocationId");
b.HasOne("api.Models.Team", "Team")
.WithMany()
.HasForeignKey("TeamId");
});
modelBuilder.Entity("api.Models.Photo", b =>
{
b.HasOne("api.Models.User", "User")
.WithMany("Photos")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.Team", b =>
{
b.HasOne("api.Models.User", "Cap")
.WithMany()
.HasForeignKey("CapId");
});
modelBuilder.Entity("api.Models.User", b =>
{
b.HasOne("api.Models.Team")
.WithMany("Membros")
.HasForeignKey("TeamId");
});
modelBuilder.Entity("api.Models.UserRole", b =>
{
b.HasOne("api.Models.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("api.Models.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,417 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace api.Migrations
{
public partial class TeamsEvents : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Events",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Nome = table.Column<string>(nullable: true),
Desc = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Events", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Values",
columns: table => new
{
id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Values", x => x.id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<int>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<int>(nullable: false),
RoleId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<int>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(nullable: false),
ProviderKey = table.Column<string>(nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<int>(nullable: false),
LoginProvider = table.Column<string>(nullable: false),
Name = table.Column<string>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
});
migrationBuilder.CreateTable(
name: "Photos",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Url = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
DateAdded = table.Column<DateTime>(nullable: false),
IsMain = table.Column<bool>(nullable: false),
UserId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Photos", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EventLocs",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
EventId = table.Column<int>(nullable: false),
Lat = table.Column<float>(nullable: false),
Long = table.Column<float>(nullable: false),
Nome = table.Column<string>(nullable: true),
Desc = table.Column<string>(nullable: true),
ImgId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EventLocs", x => x.Id);
table.ForeignKey(
name: "FK_EventLocs_Photos_ImgId",
column: x => x.ImgId,
principalTable: "Photos",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
QRcode = table.Column<string>(nullable: true),
EventId = table.Column<int>(nullable: false),
Nome = table.Column<string>(nullable: true),
CapId = table.Column<int>(nullable: true),
NMembros = table.Column<int>(nullable: false),
Pontos = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
QRcode = table.Column<string>(nullable: true),
TeamId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUsers_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EventLocsVisited",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TeamId = table.Column<int>(nullable: true),
LocationId = table.Column<int>(nullable: true),
timestamp = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EventLocsVisited", x => x.Id);
table.ForeignKey(
name: "FK_EventLocsVisited_EventLocs_LocationId",
column: x => x.LocationId,
principalTable: "EventLocs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_EventLocsVisited_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUsers_TeamId",
table: "AspNetUsers",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_EventLocs_ImgId",
table: "EventLocs",
column: "ImgId");
migrationBuilder.CreateIndex(
name: "IX_EventLocsVisited_LocationId",
table: "EventLocsVisited",
column: "LocationId");
migrationBuilder.CreateIndex(
name: "IX_EventLocsVisited_TeamId",
table: "EventLocsVisited",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_Photos_UserId",
table: "Photos",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Teams_CapId",
table: "Teams",
column: "CapId");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
table: "AspNetUserTokens",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Photos_AspNetUsers_UserId",
table: "Photos",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Teams_AspNetUsers_CapId",
table: "Teams",
column: "CapId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_AspNetUsers_CapId",
table: "Teams");
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "EventLocsVisited");
migrationBuilder.DropTable(
name: "Events");
migrationBuilder.DropTable(
name: "Values");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "EventLocs");
migrationBuilder.DropTable(
name: "Photos");
migrationBuilder.DropTable(
name: "AspNetUsers");
migrationBuilder.DropTable(
name: "Teams");
}
}
}

View File

@ -0,0 +1,450 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using api.Data;
namespace api.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20190306210633_team_fix")]
partial class team_fix
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<int>("RoleId");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<int>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<int>("UserId");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("api.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Desc");
b.Property<string>("Nome");
b.HasKey("Id");
b.ToTable("Events");
});
modelBuilder.Entity("api.Models.EventLoc", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Desc");
b.Property<int>("EventId");
b.Property<int?>("ImgId");
b.Property<float>("Lat");
b.Property<float>("Long");
b.Property<string>("Nome");
b.HasKey("Id");
b.HasIndex("ImgId");
b.ToTable("EventLocs");
});
modelBuilder.Entity("api.Models.EventLocVisited", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("LocationId");
b.Property<int?>("TeamId");
b.Property<DateTime>("timestamp");
b.HasKey("Id");
b.HasIndex("LocationId");
b.HasIndex("TeamId");
b.ToTable("EventLocsVisited");
});
modelBuilder.Entity("api.Models.Log", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("UserId");
b.Property<int?>("UserId1");
b.Property<int>("amount");
b.Property<int>("available");
b.Property<string>("logType");
b.Property<int?>("productId");
b.Property<string>("transactionId");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("UserId1");
b.HasIndex("productId");
b.ToTable("Logs");
});
modelBuilder.Entity("api.Models.Photo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("DateAdded");
b.Property<string>("Description");
b.Property<bool>("IsMain");
b.Property<string>("Url");
b.Property<int>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Photos");
});
modelBuilder.Entity("api.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("basePrice");
b.Property<string>("name");
b.Property<float>("revenue");
b.Property<int>("sold");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("api.Models.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("api.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("CapId");
b.Property<int>("EventId");
b.Property<int>("NMembros");
b.Property<string>("Nome");
b.Property<int>("Pontos");
b.HasKey("Id");
b.HasIndex("CapId");
b.ToTable("Teams");
});
modelBuilder.Entity("api.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("QRcode");
b.Property<string>("SecurityStamp");
b.Property<int?>("TeamId");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.Property<int>("drinks");
b.Property<int>("food");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.HasIndex("TeamId");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("api.Models.UserRole", b =>
{
b.Property<int>("UserId");
b.Property<int>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("api.Models.Value", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("id");
b.ToTable("Values");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("api.Models.Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("api.Models.User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("api.Models.User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("api.Models.User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.EventLoc", b =>
{
b.HasOne("api.Models.Photo", "Img")
.WithMany()
.HasForeignKey("ImgId");
});
modelBuilder.Entity("api.Models.EventLocVisited", b =>
{
b.HasOne("api.Models.EventLoc", "Location")
.WithMany()
.HasForeignKey("LocationId");
b.HasOne("api.Models.Team", "Team")
.WithMany()
.HasForeignKey("TeamId");
});
modelBuilder.Entity("api.Models.Log", b =>
{
b.HasOne("api.Models.User")
.WithMany("logsFebrada")
.HasForeignKey("UserId");
b.HasOne("api.Models.User")
.WithMany("logsFestarola")
.HasForeignKey("UserId1");
b.HasOne("api.Models.Product", "product")
.WithMany()
.HasForeignKey("productId");
});
modelBuilder.Entity("api.Models.Photo", b =>
{
b.HasOne("api.Models.User", "User")
.WithMany("Photos")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.Team", b =>
{
b.HasOne("api.Models.User", "Cap")
.WithMany()
.HasForeignKey("CapId");
});
modelBuilder.Entity("api.Models.User", b =>
{
b.HasOne("api.Models.Team")
.WithMany("Membros")
.HasForeignKey("TeamId");
});
modelBuilder.Entity("api.Models.UserRole", b =>
{
b.HasOne("api.Models.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("api.Models.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace api.Migrations
{
public partial class team_fix : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "QRcode",
table: "Teams");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "QRcode",
table: "Teams",
nullable: true);
}
}
}

View File

@ -251,8 +251,6 @@ namespace api.Migrations
b.Property<int>("Pontos");
b.Property<string>("QRcode");
b.HasKey("Id");
b.HasIndex("CapId");

View File

@ -7,7 +7,7 @@ namespace api.Models
public class EventLocVisited
{
public int Id{get;set;} //id
public Team Team{get;set;} //teamQRID
public Team Team{get;set;} //team
public EventLoc Location{get;set;} //location
public DateTime timestamp{get;set;} //time
}

View File

@ -7,11 +7,10 @@ namespace api.Models
public class Team
{
public int Id{get;set;} //id
public string QRcode{get;set;} //QR ID code
public int EventId{get;set;} //equipa para o evento ID
public string Nome{get;set;} //Nome da equipa
public User Cap{get;set;} //Capitao da equipa
public ICollection<User> Membros {get;set;} //Membros da equipa
public List<User> Membros {get;set;} //Membros da equipa
public int NMembros {get;set;} //Numero de Membros na equipa
public int Pontos {get;set;} //Postos da equipa
}

View File

@ -45,6 +45,10 @@ namespace api
services.AddAutoMapper();
services.AddScoped<IUsersRepository, UsersRepository>();
services.AddScoped<IEventsRepository, EventsRepository>();
services.AddScoped<ITeamsRepository, TeamsRepository>();
services.AddScoped<IEventLocsRepository, EventLocsRepository>();
services.AddScoped<IEventLocsVisitedRepository, EventLocsVisitedRepository>();
//define a connection string indicada em appsettings.json
services.AddDbContext<DataContext>(x=>x.UseMySql(Configuration.GetConnectionString("DefaultConnection")));

BIN
api/obj/Debug/netcoreapp2.1/api.assets.cache Normal file → Executable file

Binary file not shown.

View File

@ -1,5 +1,5 @@
{
"ProjectFilePath": "/Users/henrique/ENEI2019/api/api.csproj",
"ProjectFilePath": "c:\\Users\\ZMiguel\\Desktop\\ENEI2019\\api\\api.csproj",
"TargetFramework": "netcoreapp2.1",
"TagHelpers": [],
"Configuration": {

0
website/Archive.zip Normal file → Executable file
View File

View File

@ -121,36 +121,36 @@
<h1>Preços</h1>
<hr>
<div class="price-block">
<div class="type">Early-Bird</div>
<div class="type">Normal</div>
<div>
<div class="individual-price">
<div class="price"><span></span>25</div>
<div class="label">Grupo</div>
<span class="options">*Alimentação e alojamento (pavilhão) incluídos</span>
<span class="options">*Alimentação [5€] e alojamento (pavilhão) [5€]</span>
</div>
</div>
<a href="https://tickets.enei.pt/group" title="Comprar" target="_blank"
class="buy-button">Comprar</a>
</div>
<div class="price-block">
<div class="type">Early-Bird</div>
<div class="type">Normal</div>
<div>
<div class="individual-price">
<div class="price"><span></span>30</div>
<div class="label">Individual</div>
<span class="options">*Alimentação e alojamento (pavilhão) incluídos</span>
<span class="options">*Alimentação [5€] e alojamento (pavilhão) [5€]</span>
</div>
</div>
<a href="https://tickets.enei.pt" title="Comprar" target="_blank" class="buy-button">Comprar</a>
</div>
<div class="price-block disable">
<div class="price-block">
<div class="type">Pontual</div>
<div class="individual-price">
<div class="price"><span></span>20</div>
<div class="label">Individual</div>
<span class="options">*Alimentação incluída</span>
</div>
<span class="buy-button">Brevemente</span>
<a href="#" title="Comprar" target="_blank" class="buy-button">Comprar</a>
</div>
</div>
</div>

0
website/regulamento_geral.pdf Normal file → Executable file
View File