This commit is contained in:
henrydays 2019-03-21 19:56:31 +00:00
parent 9b505c172d
commit 5f3cce5f3a
8 changed files with 668 additions and 329 deletions

View File

@ -46,9 +46,12 @@ class Calendar extends React.Component {
};
componentDidMount() {
this.props.getEvents(this.props.user,this.props.careerPath);
this.props.getSessions(this.props.token);
// this.props.getSessions(this.props.token);
// this.props.getEvents(this.props.user,this.props.careerPath);
}
_openDetails = () => {
@ -65,22 +68,11 @@ class Calendar extends React.Component {
<View style={styles.event}>
<View style={styles.titleContainer}>
<Text style={[styles.title]}>{item.name}</Text>
<Text style={{ color: "black" }}>Local: 1</Text>
<Text style={{ color: "black" }}>{item.place}</Text>
</View>
<View>
<Text style={styles.description}>{item.description}</Text>
<View style={styles.details}>
<Progress.Bar
color={"#000000"}
progress={0}
unfilledColor={"white"}
width={210}
/>
<Text>
{item.Enrolled} / {item.MaxAttendees}
</Text>
</View>
</View>
</View>
</TouchableOpacity>
@ -142,7 +134,8 @@ class Calendar extends React.Component {
super();
}
_refresh=()=>{
this.props.getEvents(this.props.user,this.props.careerPath);
this.props.getEvents(this.props.user,this.props.careerPath, this.props.token);
}

View File

@ -9,7 +9,8 @@ import {
ScrollView,
Image,
TouchableOpacity,
FlatList
FlatList,
ActivityIndicator
} from "react-native";
import {TabView, TabBar, SceneMap} from "react-native-tab-view";
@ -55,6 +56,16 @@ _update=()=> {
<PTRView onRefresh={this._update}>
<View style={styles.container}>
<ScrollView styles={styles.scroll}>
{
this.props.eventsInternal==undefined &&
<View style={{height:SCREEN_HEIGHT, marginTop:SCREEN_HEIGHT*0.27, backgroundColor:'white'}}>
<Text style={{fontSize:12, margin:15, textAlign:'center'}}>Se estiver a demorar muito, arrasta para atualizar</Text>
<View style={{width:80, alignContent:'center', alignItems:'center'}}><Button onPress={this._update} title="Refresh" color="#CC1A17"
/></View>
<ActivityIndicator size="large" color="#CC1A17" /></View>
}
<FlatList
data={this.props.eventsInternal}
renderItem={({item}) =>
@ -116,7 +127,7 @@ const styles = StyleSheet.create({
},
container: {
backgroundColor: '#eee',
backgroundColor: 'white',
flex: 1,
flexGrow: 1,
flexDirection: 'column',

View File

@ -83,11 +83,8 @@ class Home extends Component {
this.props.getUserInfo(this.props.token);
console.log(this.props.internalToken)
this.props.getUserTeam(this.props.user, this.props.internalToken );
this.props.getEvents(this.props.user);
this.props.loginInternal(this.props.user, this.props.token);
this.props.getEvents(this.props.user,this.props.token);
}
componentWillUnmount() {}
@ -103,7 +100,7 @@ class Home extends Component {
}
_update = () => {
this.props.getUserInfo(this.props.token);
this.props.getEvents(this.props.user);
this.props.getEvents(this.props.user,this.props.token);
this.props.getUserTeam(this.props.user, this.props.internalToken )
};
onSuccess=e=>{
@ -162,7 +159,7 @@ _creatTeam=()=>{
if (this.props.logged) {
return (
<PTRView onRefresh={this._update}>
<ScrollView style={{ backgroundColor: "#eeeeee" }}>
<ScrollView style={{ backgroundColor: "#eeeeee" , height:SCREEN_HEIGHT}}>
<View>
<Modal
isVisible={this.state.addUser}

View File

@ -117,7 +117,7 @@ class Jogo extends React.Component {
onPress={()=>this.setState({isModalVisible:false})}
title="X"
color="#CC1A17"
accessibilityLabel="Learn more about this purple button"
accessibilityLabel=""
/>
</View>
</View>
@ -207,6 +207,7 @@ class Jogo extends React.Component {
</Modal>
<PTRView onRefresh={this._update}>
<View style={{ height: 50, backgroundColor: "#eeeeee" }}>
<View
style={{
@ -215,6 +216,7 @@ class Jogo extends React.Component {
flexDirection: "row"
}}
>
<View
style={{
width: SCREEN_WIDTH * 0.7,
@ -279,7 +281,7 @@ class Jogo extends React.Component {
</View>
</View>
</View>
<ScrollView
<ScrollView
style={{ backgroundColor: "#eeeeee", marginTop: 10 }}
horizontal={true}
>
@ -327,7 +329,7 @@ class Jogo extends React.Component {
</View>
</ScrollView>
</ScrollView>
</PTRView>
</PTRView>
</View>
);
}

View File

@ -64,11 +64,6 @@ class calendarDetail extends React.Component {
const { navigation } = this.props;
const info = navigation.getParam("info", "error");
this.props.getSessionDetails(this.props.token, info.Id);
var a = moment(info.SessionStart);
var b = moment(info.SessionEnd);
console.log(b.diff(a, "minutes")); // 44700
}
_update = () => {
@ -96,6 +91,7 @@ class calendarDetail extends React.Component {
}
return (
info!=undefined &&
<View style={styles.mainViewStyle}>
<ScrollView style={styles.scroll}>
<View style={styles.container}>
@ -142,13 +138,14 @@ class calendarDetail extends React.Component {
</View>
<View style={{ margin: 10 }}>
{this.props.sessionDetail.Enrolled!= 0 && this.props.sessionDetail.MaxAttendees!=0 &&
<Progress.Bar
color={"#000000"}
progress={this.props.sessionDetail.Enrolled / this.props.sessionDetail.MaxAttendees}
height={10}
unfilledColor={"white"}
width={210}
/>
/>}
<Text>
{this.props.sessionDetail.Enrolled} / {this.props.sessionDetail.MaxAttendees}
</Text>

View File

@ -9,14 +9,12 @@ import {
TouchableOpacity,
Picker,
ActivityIndicator,
FlatList
} from "react-native";
import moment from "moment";
import Modal from "react-native-modal";
import * as Progress from "react-native-progress";
import { connect } from "react-redux";
@ -24,18 +22,15 @@ import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as Actions from "../store/actions"; //Import your actionss
import AwesomeAlert from 'react-native-awesome-alerts';
import AwesomeAlert from "react-native-awesome-alerts";
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
import FitImage from "react-native-fit-image";
import { Divider } from "react-native-elements";
import LinearGradient from "react-native-linear-gradient";
import IconFA from "react-native-vector-icons/FontAwesome5";
@ -67,12 +62,10 @@ class choosePath extends React.Component {
var sessions = this.props.sessions;
for (let key in sessions) {
if (sessions[key].Name == "IA") {
this.setState({ guest: "9" });
}
//...
}
};
componentDidMount() {
@ -104,22 +97,19 @@ class choosePath extends React.Component {
constructor() {
super();
this.state = {
showAlert:true,
showAlert: true,
Blocks: [],
onHoldBlocks: true,
checked: true,
modalVisible: false,
isModalVisible: false,
isModalVisible: false
};
this.data = [];
}
onPress = () => {
};
onPress = () => {};
_s() {
this.props.signSession(this.props.token, item[index].Id);
}
getCareerPaths = () => {
@ -140,7 +130,6 @@ class choosePath extends React.Component {
_toggleModal = () =>
this.setState({ isModalVisible: !this.state.isModalVisible });
_onPressItem = id => {
// updater functions are preferred for transactional updates
this.setState(state => {
@ -158,261 +147,275 @@ class choosePath extends React.Component {
render() {
const { navigate } = this.props.navigation;
return (
<View>
<ScrollView style={styles.page}>
<View>
<ScrollView style={styles.page}>
{this._findPath("IA") && (
<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._findPath("NET") && (
<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>
)}
{this._findPath("IA") && (
<LinearGradient
colors={["#D95856", "#CC1A17"]}
style={styles.linearGradient}
<View
style={{
flex: 1,
width: SCREEN_WIDTH * 0.7,
alignContent: "center"
}}
>
<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 style={styles.pickerCareer}>
<Picker
selectedValue={this.state.guest}
style={{ width: "100%" }}
onValueChange={(itemValue, itemIndex) => {
this.setState({ guest: itemValue });
// this.props.timerChangeGuest();
this.props.waitChangeGuest();
this.props.changeGuestList(this.props.token, itemValue);
// this.props.waitChangeGuest();
// this.props.waitChangeGuest();
// this.props.getSessionBlocks(this.props.sessions)
}}
>
<Picker.Item label="Escolhe o teu career path!" value="0" />
<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>
</LinearGradient>
)}
{this._findPath("NET") && (
<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.timerChangeGuest();
this.props.waitChangeGuest();
this.props.changeGuestList(
this.props.token,
itemValue
);
// this.props.waitChangeGuest();
// this.props.waitChangeGuest();
// this.props.getSessionBlocks(this.props.sessions)
}}
>
<Picker.Item label="Escolhe o teu career path!" value="0" />
<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>
<View style={{ width: SCREEN_WIDTH }}>
{!this.props.changingGuest && (
<FlatList
data={this.props.Blocks}
renderItem={({ item, index }) => (
<View style={styles.block}>
<View style={styles.time}>
<Text
style={{
margin: 10,
fontSize: 25,
color: "#CC1A17",
marginBottom: 0
}}
>
{moment(item[0].SessionStart).format("HH:mm")}
</Text>
<Text style={{ marginLeft: 20 }}>às</Text>
<Text
style={{
margin: 10,
fontSize: 25,
color: "#CC1A17",
marginTop: 5
}}
>
{moment(item[0].SessionEnd).format("HH:mm")}
</Text>
</View>
<View style={styles.sessions}>
<FlatList
data={item}
renderItem={({ data, index }) => (
<View>
<View style={styles.session}>
{this._verifySession(item[index].Id) && (
<TouchableOpacity
onPress={() => {
this.props.removeSession(
this.props.user,
this.props.token,
item[index].Id
);
}}
style={{ flex: 1, alignSelf: "center" }}
>
<View>
<IconFA
name="check-square"
color={"#CC1A17"}
size={35}
/>
</View>
</TouchableOpacity>
)}
{!this._verifySession(item[index].Id) && (
<TouchableOpacity
onPress={() => {
//this.props.waitChangeGuest()
this.props.signSession(
this.props.user,
this.props.token,
item[index].Id
);
}}
style={{ flex: 1, alignSelf: "center" }}
>
<View>
<IconFA name="square" size={35} />
</View>
</TouchableOpacity>
)}
<TouchableOpacity
onPress={() =>
{ navigate("calendarDetail", { info: item[index] })}
}
>
<View style={styles.sessionInfo}>
<Text style={styles.sessionTitle}>
{item[index].Name}
</Text>
<Text
style={{ marginTop: 10, marginBottom: 5 }}
<View style={{ width: SCREEN_WIDTH }}>
{!this.props.changingGuest && (
<FlatList
data={this.props.Blocks}
renderItem={({ item, index }) => (
<View style={styles.block}>
<View style={styles.time}>
<Text
style={{
margin: 10,
fontSize: 25,
color: "#CC1A17",
marginBottom: 0
}}
>
{moment(item[0].SessionStart).format("HH:mm")}
</Text>
<Text style={{ marginLeft: 20 }}>às</Text>
<Text
style={{
margin: 10,
fontSize: 25,
color: "#CC1A17",
marginTop: 5
}}
>
{moment(item[0].SessionEnd).format("HH:mm")}
</Text>
</View>
<View style={styles.sessions}>
<FlatList
data={item}
renderItem={({ data, index }) => (
<View>
<View style={styles.session}>
{this._verifySession(item[index].Id) && (
<TouchableOpacity
onPress={() => {
this.props.removeSession(
this.props.user,
this.props.token,
item[index].Id
);
}}
style={{ flex: 1, alignSelf: "center" }}
>
{item[index].MaxAttendees -
item[index].Enrolled}{" "}
Lugares disponíveis
</Text>
<Progress.Bar
color={"#000000"}
progress={
item[index].Enrolled /
item[index].MaxAttendees
}
unfilledColor={"white"}
width={170}
/>
</View>
</TouchableOpacity>
<View>
<IconFA
name="check-square"
color={"#CC1A17"}
size={35}
/>
</View>
</TouchableOpacity>
)}
{!this._verifySession(item[index].Id) && (
<TouchableOpacity
onPress={() => {
//this.props.waitChangeGuest()
this.props.signSession(
this.props.user,
this.props.token,
item[index].Id
);
}}
style={{ flex: 1, alignSelf: "center" }}
>
<View>
<IconFA name="square" size={35} />
</View>
</TouchableOpacity>
)}
<TouchableOpacity
onPress={() => {
navigate("calendarDetail", {
info: item[index]
});
}}
>
<View style={styles.sessionInfo}>
<Text style={styles.sessionTitle}>
{item[index].Name}
</Text>
<Text
style={{ marginTop: 10, marginBottom: 5 }}
>
{item[index].MaxAttendees -
item[index].Enrolled}{" "}
Lugares disponíveis
</Text>
{item[index].Enrolled != 0 &&
item[index].MaxAttendees!=0 && (
<Progress.Bar
color={"#000000"}
progress={
item[index].Enrolled /
item[index].MaxAttendees
}
unfilledColor={"white"}
width={170}
/>
)}
</View>
</TouchableOpacity>
</View>
<Divider style={{ backgroundColor: "#eeeeee" }} />
</View>
<Divider style={{ backgroundColor: "#eeeeee" }} />
</View>
)}
/>
)}
/>
</View>
</View>
</View>
)}
/>
)}
)}
/>
)}
</View>
</View>
</View>
{(this.props.changingGuest || this.props.Blocks == true) && (
<View style={{ flex:1, height:SCREEN_HEIGHT*0.6, alignSelf:'center',}}>
<ActivityIndicator
size="large"
color="red"
style={{ alignContent: "center" , alignSelf:'center', marginTop:SCREEN_HEIGHT*0.2}}
/></View>
)}
</ScrollView>
{(this.props.changingGuest || this.props.Blocks == true) && (
<View
style={{
flex: 1,
height: SCREEN_HEIGHT * 0.6,
alignSelf: "center"
}}
>
<ActivityIndicator
size="large"
color="red"
style={{
alignContent: "center",
alignSelf: "center",
marginTop: SCREEN_HEIGHT * 0.2
}}
/>
</View>
)}
</ScrollView>
</View>
);
}

View File

@ -48,12 +48,12 @@ axios.defaults.baseURL = "https://api.enei.pt/internal/api";
const map = require("lodash/fp/map").convert({ cap: false });
export function scanQrCode(data,tokenInternal){
export function scanQrCode(data, tokenInternal) {
axios.defaults.baseURL = "https://api.enei.pt";
axios.defaults.headers.common = {
Authorization: `bearer ${tokenInternal}`
};
console.log(data)
console.log(data);
return dispatch => {
axios
.post("/api/Scan", data)
@ -71,7 +71,7 @@ console.log(data)
};
}
export function getEventLocsVisited(teamId, tokenInternal ) {
export function getEventLocsVisited(teamId, tokenInternal) {
axios.defaults.headers.common = {
Authorization: `bearer ${tokenInternal}`
};
@ -92,8 +92,6 @@ export function getEventLocsVisited(teamId, tokenInternal ) {
console.log(p);
Alert.alert("ERRO!", "erro a obter os locais visitados");
});
};
}
@ -188,7 +186,7 @@ export function getAllEvents(tokenInternal) {
})
.catch(p => {
console.log(p);
Alert.alert("ERRO!", "erro a obter os eventos");
// Alert.alert("ERRO!", "erro a obter os eventos");
});
dispatch({
@ -290,6 +288,202 @@ export function waitLogin() {
};
}
var getEAsync = function(user, careerPath, token) {
return new Promise(function(resolve, reject) {
console.log("career path: ");
var cenas = [];
let events = [];
var alimentacao = [];
var alojamento = [];
var acesso = [];
var i = 0;
console.log(user.Sessions);
checkAndRefresh(token)
.then(newToken => {
axios.defaults.baseURL = "https://tickets.enei.pt/internal/api";
axios.defaults.headers.common = {
Authorization: `bearer ${newToken.access_token}`
};
axios
.get("/Attendee/AvailableSessions")
.then(function(response) {
// handle success
console.log("available");
console.log(response);
console.log("available");
var cenas = [];
const result1 = flow(groupBy("SessionStart"))(response.data);
for (let key in result) {
cenas.push(result[key]);
console.log();
}
console.log("chegou aqui");
console.log(cenas);
for (let key in user.Sessions) {
//se forem sessões de bilhete, adiciona a outra lista
if (
user.Sessions[key].Id == 1 || //dia 12 de abril
user.Sessions[key].Id == 22 || //jantar 12 de abril
user.Sessions[key].Id == 23 || //almoço e jantar 13 de abril
user.Sessions[key].Id == 24 || //almoço e jantar 14 de abril
user.Sessions[key].Id == 25 || //almoço 15 de abril
user.Sessions[key].Id == 26 || //alojamento 12 de abril
user.Sessions[key].Id == 29 || //alojamento 13 de abril
user.Sessions[key].Id == 31 || //alojamento 14 de abril
user.Sessions[key].Id == 32 || //dia 13 de abril
user.Sessions[key].Id == 33 || //dia 14 de abril
user.Sessions[key].Id == 34 || //dia 15 de abril
user.Sessions[key].Id == 35 || //jantar dia 12 de abril
user.Sessions[key].Id == 36 || //jantar dia 13 de abril
user.Sessions[key].Id == 37 //jantar dia 14 de abril
) {
// bilhete.push( user.Sessions[key])
if (user.Sessions[key].Id == 1) {
acesso.push("dia 12");
}
if (user.Sessions[key].Id == 22) alimentacao.push("dia 12");
if (user.Sessions[key].Id == 23) alimentacao.push("dia 13");
if (user.Sessions[key].Id == 24) alimentacao.push("dia 14");
if (user.Sessions[key].Id == 25) alimentacao.push("dia 15");
if (user.Sessions[key].Id == 26) alojamento.push("dia 12");
if (user.Sessions[key].Id == 29) alojamento.push("dia 13");
if (user.Sessions[key].Id == 31) alojamento.push("dia 14");
if (user.Sessions[key].Id == 32) acesso.push("dia 13");
if (user.Sessions[key].Id == 33) acesso.push("dia 14");
if (user.Sessions[key].Id == 34) acesso.push("dia 15");
} else {
events.push({
key: i++,
Id: user.Sessions[key].Id,
time: moment(user.Sessions[key].SessionStart).format("HH:mm"),
timeEnd: moment(user.Sessions[key].SessionEnd).format(
"HH:mm"
),
//lineColor:'#009688',
imageUrl:
"https://tickets.enei.pt/adminpoint/Content/Images/Uploads/Sessions/" +
user.Sessions[key].Image,
description: user.Sessions[key].Description,
name: user.Sessions[key].Name,
Enrolled: user.Sessions[key].Enrolled,
MaxAttendees: user.Sessions[key].MaxAttendees,
day: moment(user.Sessions[key].SessionStart).format("DD")
});
}
}
const result = flow(groupBy("day"))(events);
var a = [],
b = [],
c = [],
d = [];
//MEU DEUS QUE É ISTO???
for (let key in result["12"]) {
a.push({
Id: result["12"][key].Id,
time: result["12"][key].time,
timeEnd: result["12"][key].timeEnd,
imageUrl: result["12"][key].imageUrl,
description: result["12"][key].description,
name: result["12"][key].name,
Enrolled: result["12"][key].Enrolled,
MaxAttendees: result["12"][key].MaxAttendees,
day: result["12"][key].day
});
}
for (let key in result["13"]) {
b.push({
Id: result["13"][key].Id,
time: result["13"][key].time,
timeEnd: result["13"][key].timeEnd,
imageUrl: result["13"][key].imageUrl,
description: result["13"][key].description,
name: result["13"][key].name,
Enrolled: result["13"][key].Enrolled,
MaxAttendees: result["13"][key].MaxAttendees,
day: result["13"][key].day
});
}
for (let key in result["14"]) {
c.push({
Id: result["14"][key].Id,
time: result["14"][key].time,
timeEnd: result["14"][key].timeEnd,
imageUrl: result["14"][key].imageUrl,
description: result["14"][key].description,
name: result["14"][key].name,
Enrolled: result["14"][key].Enrolled,
MaxAttendees: result["14"][key].MaxAttendees,
day: result["14"][key].day
});
}
for (let key in result["15"]) {
d.push({
Id: result["15"][key].Id,
time: result["15"][key].time,
timeEnd: result["15"][key].timeEnd,
imageUrl: result["15"][key].imageUrl,
description: result["15"][key].description,
name: result["15"][key].name,
Enrolled: result["15"][key].Enrolled,
MaxAttendees: result["15"][key].MaxAttendees,
day: result["15"][key].day
});
}
a = _.sortBy(a, function(o) {
return o.time;
});
b = _.sortBy(b, function(o) {
return o.time;
});
c = _.sortBy(c, function(o) {
return o.time;
});
d = _.sortBy(d, function(o) {
return o.time;
});
console.log(alimentacao);
console.log("career path");
console.log(careerPath);
console.log("career path");
return {
a,
b,
c,
d,
ab: alimentacao,
acc: acesso,
al: alojamento
};
})
.catch(function(error) {
alert("Error a obter sessões disponíveis!!");
console.log(error);
});
})
.catch(err => {
console.log(err);
});
});
};
var checkAndRefresh = function(token) {
return new Promise(function(resolve, reject) {
//verificar se já expirou a validade do token
@ -404,15 +598,15 @@ export function changePassword(token, old, new1, new2) {
.catch(err => {
Alert.alert(
"Token ERROR!",
"Parace que houve um erro com o teu token... Reinicia a App. Caso o problema se mantenha, volta e instalar"
"Parece que houve um erro com o teu token... Reinicia a App. Caso o problema se mantenha, volta e instalar"
);
});
};
}
//faz autenticação com API interna
export function loginInternal(user,t) {
export function loginInternal(user, t) {
axios.defaults.baseURL = "https://api.enei.pt";
console.log(user)
console.log(user);
return dispatch => {
axios
.post("/api/loginQR", {
@ -422,17 +616,20 @@ export function loginInternal(user,t) {
.then(a => {
dispatch({
type: LOGIN_INTERNAL,
internalToken:a.data.token
internalToken: a.data.token
});
})
.catch(p => {
console.log(p);
Alert.alert("Erro","Existiu um erro a obter o token... Contacta a comissão se vires esta mensagem de erro.")
Alert.alert(
"Erro",
"Existiu um erro a obter o token... Contacta a comissão se vires esta mensagem de erro."
);
});
dispatch({
type: LOGIN_INTERNAL,
internalToken:'error'
internalToken: "error"
});
};
}
@ -523,7 +720,7 @@ export function updateUser(token, user) {
.catch(err => {
Alert.alert(
"Token ERROR!",
"Parace que houve um erro com o teu token... Reinicia a App. Caso o problema se mantenha, volta e instalar"
"Parece que houve um erro com o teu token... Reinicia a App. Caso o problema se mantenha, volta e instalar"
);
});
};
@ -531,34 +728,41 @@ export function updateUser(token, user) {
function getCareerPath(sessions) {
careerPath = "Sem Career Path";
careerColor = "white";
code = "";
for (let key in sessions) {
if (sessions[key].Name == "IA") {
careerPath = "Artificial Inteligence";
careerPath = "Artificial Intelligence";
careerColor = "#CC1A17";
code = "IA";
}
if (sessions[key].Name == "IOT") {
careerPath = "Internet of Things";
careerColor = "green";
code = "IOT";
}
if (sessions[key].Name == "WEB") {
careerPath = "Web Development";
careerColor = "purple";
code = "WEB";
}
if (sessions[key].Name == "NET") {
careerPath = "Networking and Security";
careerColor = "blue";
code = "NET";
}
if (sessions[key].Name == "MOB") {
careerPath = "Mobile Development";
careerColor = "orange";
code = "MOB";
}
if (sessions[key].Name == "DS") {
careerPath = "Data Science";
careerColor = "yellow";
code = "DS";
}
}
return { name: careerPath, color: careerColor };
return { name: careerPath, color: careerColor, code: code };
}
export const waitChangeGuest = () => {
return dispatch => {
@ -640,7 +844,7 @@ export function removeSession(user, token, idSession) {
user: sucess.data,
token: newToken
});
getEvents(user, careerPath);
getEvents(user, careerPath, token);
});
})
.catch(function(error) {
@ -725,7 +929,7 @@ export function signSession(user, token, idSession) {
})
.then(sucess => {
console.log("aqui2");
var result = getE(user);
var result = getE(user, "", token);
dispatch({
type: SIGN_SESSION,
sessions: response.data,
@ -1004,15 +1208,14 @@ export function getAvailableSessions(token) {
//ESTA FUNÇÃO TEM MUITO CÓDIGO MAL FEITO...
function getE(user, careerPath) {
console.log("career path: ");
function getE(user, careerPath, token) {
var cenas = [];
let events = [];
var alimentacao = [];
var alojamento = [];
var acesso = [];
var i = 0;
console.log(user.Sessions);
for (let key in user.Sessions) {
//se forem sessões de bilhete, adiciona a outra lista
if (
@ -1078,7 +1281,80 @@ function getE(user, careerPath) {
d = [];
//MEU DEUS QUE É ISTO???
if (careerPath != undefined && careerPath.code =="IA") {
a.push({
Id: 22,
time: "19:00",
description: "Jantar para os career path's de IA",
day: "12",
name: "Jantar",
place: "Cantina do ISEC"
});
}
if (careerPath != undefined && careerPath.code =="IOT") {
a.push({
Id: 22,
time: "19:30",
description: "Jantar ",
day: "12",
place: "Cantina do ISEC"
});
}
if (careerPath != undefined && careerPath.code =="NET") {
a.push({
Id: 22,
time: "20:00",
description: "Jantar ",
day: "12",
place: "Cantina do ISEC"
});
}
a.push({
Id: 48,
time: "21:00",
description:
"Festarola do evento",
name: "Festarola",
Enrolled: 700,
MaxAttendees: 300,
day: "12",
place: "Pavilhão multiusos"
});
a.push({
Id: 47,
time: "14:00",
description:
"Boas vindas aos participantes. É nesta altura que os participantes fazem o check-in e recebem o seu kit para o evento",
name: "Boas vindas e Check-in",
Enrolled: 700,
MaxAttendees: 300,
day: "12",
place: "Dep. Física e Matemática"
});
a.push({
Id: 46,
time: "17:30",
description:
"Sessão de boas vindas ao ENEI'19. Esta sessão conta com a presença do grupo de fados",
name: "Sessão de Abertura",
Enrolled: 700,
MaxAttendees: 300,
day: "12",
place: "Auditório principal"
});
b.push({
Id: 49,
time: "8:00",
description:
"Pronto para começar o dia em grande? Vem tomar o pequeno-almoço!",
Enrolled: 700,
MaxAttendees: 300,
name: "Pequeno-Almoço",
day: "13",
place: "Cantina do ISEC"
});
for (let key in result["12"]) {
a.push({
Id: result["12"][key].Id,
@ -1089,7 +1365,8 @@ function getE(user, careerPath) {
name: result["12"][key].name,
Enrolled: result["12"][key].Enrolled,
MaxAttendees: result["12"][key].MaxAttendees,
day: result["12"][key].day
day: result["12"][key].day,
place:""
});
}
@ -1103,7 +1380,8 @@ function getE(user, careerPath) {
name: result["13"][key].name,
Enrolled: result["13"][key].Enrolled,
MaxAttendees: result["13"][key].MaxAttendees,
day: result["13"][key].day
day: result["13"][key].day,
place:""
});
}
for (let key in result["14"]) {
@ -1116,7 +1394,8 @@ function getE(user, careerPath) {
name: result["14"][key].name,
Enrolled: result["14"][key].Enrolled,
MaxAttendees: result["14"][key].MaxAttendees,
day: result["14"][key].day
day: result["14"][key].day,
place:""
});
}
@ -1130,7 +1409,8 @@ function getE(user, careerPath) {
name: result["15"][key].name,
Enrolled: result["15"][key].Enrolled,
MaxAttendees: result["15"][key].MaxAttendees,
day: result["15"][key].day
day: result["15"][key].day,
place: ""
});
}
a = _.sortBy(a, function(o) {
@ -1147,15 +1427,21 @@ function getE(user, careerPath) {
});
console.log(alimentacao);
console.log("career path");
console.log(careerPath);
console.log("career path");
return { a, b, c, d, ab: alimentacao, acc: acesso, al: alojamento };
}
export function getEvents(user, careerPath) {
var result = getE(user, careerPath);
console.log("putaaaaaaa");
console.log(result);
console.log("putaaaaaaa");
export function getEvents(user, careerPath, token) {
return dispatch => {
console.log("careerrrrrr");
console.log(careerPath);
var result = getE(user, careerPath, token);
console.log(result);
console.log("putaaaaaaa");
dispatch({
type: GET_EVENTS,
events: result.a,
@ -1220,7 +1506,6 @@ export function login(user, pass) {
})
.then(res => res.json())
.then(parsed => {
console.log(parsed);
if (
parsed.error_description ==
"Provided username and password is incorrect"
@ -1290,8 +1575,58 @@ export function getUserInfo(token) {
fetch("https://tickets.enei.pt/internal/api/Attendee/Detail", obj)
.then(function(res) {
console.log(res);
let obj = JSON.parse(res._bodyText);
console.log(obj);
axios.defaults.baseURL = "https://api.enei.pt";
axios
.post("/api/loginQR", {
Qrcode: obj.Code,
token: newToken.access_token
})
.then(a => {
dispatch({
type: LOGIN_INTERNAL,
internalToken: a.data.token
});
axios.defaults.headers.common = {
Authorization: `bearer ${a.data.token}`
};
axios.get(`/api/Teams/u/${obj.Code}`).then(a => {
console.log("sucesso!");
console.log(a);
dispatch({
type: GET_TEAM,
team: a.data
});
});
var result = getE(obj, "", token);
return dispatch => {
dispatch({
type: GET_EVENTS,
events: result.a,
day1: result.a,
day2: result.b,
day3: result.c,
day4: result.d,
alimentacao: result.ab,
acesso: result.acc,
alojamento: result.al
});
};
})
.catch(p => {
console.log(p);
Alert.alert(
"Erro",
"Existiu um erro a obter o token... Contacta a comissão se vires esta mensagem de erro."
);
});
dispatch({
type: LOGIN_INTERNAL,
internalToken: "error"
});
dispatch({
type: USER_INFO,

View File

@ -64,7 +64,7 @@ let apiState = {
alojamento: [],
sessionDetail:{},
team:undefined,
internalToken:"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIxIiwidW5pcXVlX25hbWUiOiJjZW5hIiwicm9sZSI6IkFkbWluIiwibmJmIjoxNTUyOTI4NTgyLCJleHAiOjE1NTMwMTQ5ODIsImlhdCI6MTU1MjkyODU4Mn0.Kwc-vu9lTGFDTKOAt7LKvBb0pnEnF6v30kF-4RjjU8swAwTJLF_oymF-MKOYtpY0a9IRaBK9yrED5b5Wkc2aoQ",
internalToken:"",
eventsInternal:[],
cromos:[],
locais:[],
@ -118,7 +118,8 @@ const apiReducer = (state = apiState, action) => {
acesso: action.payload.apiReducer.acesso,
alojamento: action.payload.apiReducer.alojamento,
internalToken:"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIxIiwidW5pcXVlX25hbWUiOiJjZW5hIiwicm9sZSI6IkFkbWluIiwibmJmIjoxNTUyODcwODcwLCJleHAiOjE1NTU0NTkyNzAsImlhdCI6MTU1Mjg3MDg3MH0.wkBk-CUDMCaU-K9jI0pTRJ794IGCl-C9md39dMfHqa5zTf-gNpD76xEYea3PhIbW2dnUVgo0m1fxR1sW7k9LMg",
cromos: action.payload.apiReducer.cromos
cromos: action.payload.apiReducer.cromos,
careerPath: action.payload.apiReducer.careerPath
};
}