-
Notifications
You must be signed in to change notification settings - Fork 0
/
Watchlist.js
111 lines (100 loc) · 2.77 KB
/
Watchlist.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
101
102
103
104
105
106
107
108
109
110
111
import React, {useState, useEffect} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
TextInput,
TouchableOpacity,
Dimensions,
Button,
Image,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import axios from 'axios';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {createDrawerNavigator} from '@react-navigation/drawer';
import 'react-native-gesture-handler';
//import {DrawerNavigation} from './Main';
import {withSafeAreaInsets} from 'react-native-safe-area-context';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {WatchlistCard} from './components/Explore/WatchlistCard';
const {width, height} = Dimensions.get('window');
export const Watchlist = (props) => {
const [watchlistData, setWatchlistData] = useState([]);
useEffect(() => {
const fetchDataPopS = async () => {
try {
const responseWatchlist = await axios.post(
'http://143.110.173.215:3000/api/watchlist',
{
uid: await AsyncStorage.getItem('id'),
},
);
setWatchlistData(
responseWatchlist.data.map((g) => ({
name: g[0].original_title,
runtime: g[0].runtime,
pic: g[0].poster_path,
date: g[0].release_date,
status: g[0].status,
stars: g[0].vote_average,
tagline: g[0].tagline,
voteCount: g[0].vote_count,
id: g[0].id,
watched: g[1],
})),
);
} catch (e) {
console.log(e);
}
};
fetchDataPopS();
}, []);
return (
<View>
<StatusBar barStyle="dark-content" />
<SafeAreaView style={{height: height, backgroundColor: '#1C1C1C'}}>
<ScrollView>
<Text style={styles.textWatch}>Watchlist</Text>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
{watchlistData.map((w) => (
<WatchlistCard
image={w.pic}
title={w.name}
tag={w.tagline}
rating={w.stars / 2}
amountRated={w.voteCount}
status={w.status}
year={w.date.split('-')}
time={w.runtime}
key={w.id}
id={w.id}
watched={w.watched}
/>
))}
</View>
</ScrollView>
</SafeAreaView>
</View>
);
};
const styles = StyleSheet.create({
textWatch: {
color: 'white',
fontSize: 28,
fontWeight: 'bold',
marginTop: 40,
marginLeft: 20,
marginBottom: 10,
},
});