-
Notifications
You must be signed in to change notification settings - Fork 5
/
App.js
100 lines (92 loc) · 2.44 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// In App.js in a new project
import * as React from 'react';
import { View, Text, Button, TextInput, StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Login from './src/pages/Login';
import Signup from './src/pages/Signup';
//import styles from "./assets/styles.js";
import UserFeed from './src/pages/UserFeed';
const Stack = createStackNavigator();
// const dummyMatches = [
// {
// name: "Nick",
// id: 1,
// body: "Javascript extraordinaire",
// toLearn: "Python",
// toTeach: "Javascript",
// },
// {
// name: "Hideaki",
// id: 2,
// body: "Cool music cat",
// toLearn: "Javascript",
// toTeach: "C++",
// },
// {
// name: "Matt",
// id: 3,
// body: "Hacking is my life",
// toLearn: "C++",
// toTeach: "Python",
// },
// ];
const defUserObj = {
isLoggedIn : false,
userInfo : {
id : '',
username: '',
email: '',
toTeach: '',
toLearn: ''
}
};
const headerStyle = {
headerStyle: { backgroundColor: '#036bfc' },
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: '700',
},
};
function App() {
const [matches, setMatches] = React.useState([]);
const [fetching, setFetching] = React.useState(false);
const [userInfo, setUserInfo] = React.useState(defUserObj);
const getMatches = (id, toTeach, toLearn) => {
const body = {
"learn_tech_id": 2,
"teach_tech_id_array": [4,5]
};
const options = {
method: 'POST',
headers: {
'Content-Type' : 'application/json'
},
body: JSON.stringify(body)
}
fetch('http://192.168.1.6:3000/user/matches', options)
.then(res => res.json())
.then(data => {
console.log('just got back: ', data)
setMatches(data)
})
.catch(err => console.log(err))
};
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Log in">
<Stack.Screen name="Signup" component={Signup} options={headerStyle} />
<Stack.Screen name="Log in" options={headerStyle}>
{props => (<Login {...props} logIn={getMatches} />)}
</Stack.Screen>
<Stack.Screen
name="User Feed"
options={headerStyle}
>
{props => (<UserFeed {...props} matches={matches} />)}
</Stack.Screen>
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;