-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArtistConcerts.js
More file actions
93 lines (82 loc) · 2 KB
/
ArtistConcerts.js
File metadata and controls
93 lines (82 loc) · 2 KB
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
import React, { Component } from 'react';
import { StyleSheet,
Text,
View,
Button,
Image
} from 'react-native';
export default class ArtistConcerts extends Component {
constructor(props){
super(props);
this.state = {
id : null,
concert : null
};
}
apiConcertsByName(){
this.name = this.props.artistName;
return `https://api.songkick.com/api/3.0/search/artists.json?apikey=u7XCPTAHztwOPCRa&query=${this.props.artistName}`;
}
apiConcertsWithId(id){
return `https://api.songkick.com/api/3.0/artists/${id}/calendar.json?apikey=u7XCPTAHztwOPCRa&per_page=3`;
}
componentDidMount(){
fetch(this.apiConcertsByName())
.then(resp => resp.json())
.then(resp => {
if(Object.getOwnPropertyNames(resp.resultsPage.results).length !== 0){
const id = resp.resultsPage.results.artist[0].id;
this.setState({id});
fetch(this.apiConcertsWithId(id))
.then(resp => resp.json())
.then(resp => this.setState({concert : resp.resultsPage.results}))
}});
}
render() {
if(this.state.concert === null)
return <Text>Loading</Text>;
if(Object.getOwnPropertyNames(this.state.concert).length === 0){
return <Text style={{paddingTop: 10,}}>No upcoming concerts</Text>;
}
//console.log(this.state.concert)
return(
<View style={{paddingTop: 10,}}>
{this.state.concert.event.map(
(element, index) =>
<View key={index}>
<Text style={{paddingTop: 10,}} >{element.displayName.replace('at','-')}</Text>
<Text>{element.location.city}</Text>
</View>
)}
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
paddingLeft: 10,
paddingRight: 10,
},
contentContainer: {
paddingVertical: 20,
},
textH: {
fontSize: 40,
fontWeight: 'bold',
paddingVertical: 30,
},
textNameArtists: {
paddingVertical: 20,
fontSize: 20,
fontWeight: 'bold',
},
textTitle:{
paddingVertical: 20,
fontSize: 30,
fontWeight: 'bold',
},
});