|
@@ -1,5 +1,7 @@
|
1
|
1
|
import React, { useEffect, useState } from 'react';
|
2
|
2
|
import { ActivityIndicator, Button, FlatList, Text, View } from 'react-native';
|
|
3
|
+import { CryptoJS } from "crypto-js/aes";
|
|
4
|
+import { globalStyles } from '../styles/global';
|
3
|
5
|
|
4
|
6
|
export default App = ({ navigation }) => {
|
5
|
7
|
const [mocion, setMocion] = useState(null);
|
|
@@ -10,7 +12,7 @@ export default App = ({ navigation }) => {
|
10
|
12
|
// this connects us to the API and fetches the json file with the mociones
|
11
|
13
|
const getMociones = async () => {
|
12
|
14
|
try {
|
13
|
|
- const response = await fetch(`http://10.0.0.65:5000/send?PIN=${navigation.state.params.Pin}`); // connection to the website
|
|
15
|
+ const response = await fetch(`http://10.190.1.140:5000/send?PIN=${navigation.state.params.Pin}`); // connection to the website
|
14
|
16
|
const json = await response.json();
|
15
|
17
|
setMocion(json.Mocion);
|
16
|
18
|
setDescription(json.Description);
|
|
@@ -31,10 +33,17 @@ export default App = ({ navigation }) => {
|
31
|
33
|
|
32
|
34
|
//sending to the API
|
33
|
35
|
const PIN = pin;
|
34
|
|
- const Token = 'abc123';
|
|
36
|
+ const message = 'abc123';
|
35
|
37
|
const votos = value;
|
36
|
38
|
|
37
|
|
- const url = `http://10.190.1.140:5000/vote?PIN=${PIN}&Token=${Token}&votos=${votos}`;
|
|
39
|
+ // this is for encrypting the message
|
|
40
|
+ var CryptoJS = require('crypto-js');
|
|
41
|
+ const privKey = "MOCIONES_IUPI";
|
|
42
|
+
|
|
43
|
+ const Token = CryptoJS.AES.encrypt(message,privKey);
|
|
44
|
+ const privKey_encrypt = CryptoJS.AES.encrypt(privKey, privKey);
|
|
45
|
+
|
|
46
|
+ const url = `http://10.190.1.140:5000/vote?PIN=${PIN}&Token=${Token}&votos=${votos}&privKey_encrypt=${privKey_encrypt}`;
|
38
|
47
|
|
39
|
48
|
//connecting to API
|
40
|
49
|
fetch(url);
|
|
@@ -49,16 +58,11 @@ export default App = ({ navigation }) => {
|
49
|
58
|
<Text>{mocion}</Text>
|
50
|
59
|
<Text>{description}</Text>
|
51
|
60
|
|
52
|
|
- {/* container for the look of the buttons */}
|
53
|
|
- <View>
|
54
|
|
-
|
55
|
|
- <Button title='A favor' onPress={() => sendVotes('A Favor')} />
|
|
61
|
+ <Button title='A favor' onPress={() => sendVotes('A Favor')}/>
|
56
|
62
|
<Button title='En Contra'onPress={() => sendVotes('En Contra')} />
|
57
|
63
|
<Button title='Abstenido/a' onPress={() => sendVotes('Abstenido/a')} />
|
58
|
64
|
|
59
|
65
|
|
60
|
|
- </View>
|
61
|
|
-
|
62
|
66
|
</View>
|
63
|
67
|
);
|
64
|
68
|
};
|