diff --git a/src/App.js b/src/App.js
index e4771a8..105a125 100644
--- a/src/App.js
+++ b/src/App.js
@@ -5,7 +5,7 @@ import { Row, Col } from 'react-bootstrap'; // eslint-disable-line no-unused-var
import VideoList from './VideoList'; // eslint-disable-line no-unused-vars
import TopBar from './TopBar'; // eslint-disable-line no-unused-vars
import VideoPlayer from './VideoPlayer'; // eslint-disable-line no-unused-vars
-import Test from './Test';
+import VideoInfo from './VideoInfo';
import './App.css';
class App extends React.Component {
@@ -24,10 +24,9 @@ class App extends React.Component {
-
+
-
);
diff --git a/src/Test.js b/src/Test.js
deleted file mode 100644
index 068f895..0000000
--- a/src/Test.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import React, { Component } from 'react';
-import wikijs from 'wikijs';
-//import PropTypes from 'prop-types';
-
-class Test extends Component {
- constructor(props) {
- super(props);
-
- }
-
- componentWillMount() {
-
- }
-
- componentDidMount() {
- wikijs.find('star wars').then(data => console.log(data.results.length));
- }
-
- componentWillReceiveProps(nextProps) {
-
- }
-
- shouldComponentUpdate(nextProps, nextState) {
-
- }
-
- componentWillUpdate(nextProps, nextState) {
-
- }
-
- componentDidUpdate(prevProps, prevState) {
-
- }
-
- componentWillUnmount() {
-
- }
-
- render() {
- return (
-
-
-
- );
- }
-}
-Test.propTypes = {
-
-};
-export default Test;
\ No newline at end of file
diff --git a/src/VideoInfo.js b/src/VideoInfo.js
index 4d27d24..13e4de8 100644
--- a/src/VideoInfo.js
+++ b/src/VideoInfo.js
@@ -1,47 +1,98 @@
import React, { Component } from 'react';
-import PropTypes from 'prop-types';
+// import PropTypes from 'prop-types';
+import Wikipedia from './Wikipedia';
+import { Col, Tabs, Tab } from 'react-bootstrap';
+import axios from 'axios';
class VideoInfo extends Component {
constructor(props) {
super(props);
+ this.state={
+ error: null,
+ isLoaded: false,
+ VideoDetails: {}
+ };
}
- componentWillMount() {
+ // componentWillMount() {
- }
+ // }
componentDidMount() {
-
+ axios.get('https://www.googleapis.com/youtube/v3/videos', {
+ params: {
+ 'part': 'snippet,contentDetails,statistics,topicDetails',
+ 'id': this.props.match.params.id,
+ 'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
+ }
+ }).then(response => {
+ this.setState({
+ VideoDetails: response.data.items[0],
+ isLoaded: true});
+ }, error => {
+ console.error(error);
+ this.setState({
+ isLoaded: true,
+ error
+ });
+ });
}
- componentWillReceiveProps(nextProps) {
+ // componentWillReceiveProps(nextProps) {
- }
+ // }
- shouldComponentUpdate(nextProps, nextState) {
+ // shouldComponentUpdate(nextProps, nextState) {
- }
+ // }
- componentWillUpdate(nextProps, nextState) {
+ // componentWillUpdate(nextProps, nextState) {
- }
+ // }
- componentDidUpdate(prevProps, prevState) {
+ // componentDidUpdate(prevProps, prevState) {
- }
+ // }
- componentWillUnmount() {
+ // componentWillUnmount() {
- }
+ // }
render() {
+ const { error, isLoaded, VideoDetails } = this.state;
+ if (error) {
+ return (
+
+ Error: {error.message} -- Cannot get {error.config.url}
+
+ );
+ } else if (!isLoaded) {
+ return Loading...;
+ } else {
return (
-
-
-
+
+
+ {/* codice per tabs reccomenders */}
+
+
+
+
+
+ B
+
+
+ C
+
+
+
+
+ 2
+
+
);
}
+ }
}
VideoInfo.propTypes = {
diff --git a/src/Wikipedia.js b/src/Wikipedia.js
new file mode 100644
index 0000000..bd3fe5e
--- /dev/null
+++ b/src/Wikipedia.js
@@ -0,0 +1,77 @@
+import React, { Component } from 'react';
+// import PropTypes from 'prop-types';
+import wikijs from 'wikijs';
+
+class Wikipedia extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data : {},
+ error: null,
+ isLoaded: false
+
+ };
+
+ }
+
+ // componentWillMount() {
+
+ // }
+
+ componentDidMount() {
+ wikijs().search(this.props.query,1).then(data => {
+ this.setState({
+ data,
+ isLoaded: true
+ });
+ console.log(data);
+ }, error => {
+ console.error(error);
+ this.setState({
+ isLoaded: true,
+ error
+ });
+ });
+ }
+
+ // componentWillReceiveProps(nextProps) {
+
+ // }
+
+ // shouldComponentUpdate(nextProps, nextState) {
+
+ // }
+
+ // componentWillUpdate(nextProps, nextState) {
+
+ // }
+
+ // componentDidUpdate(prevProps, prevState) {
+
+ // }
+
+ // componentWillUnmount() {
+
+ // }
+
+ render() {
+ const { data, error, isLoaded } = this.state;
+ if (error) {
+ return (
+
+ Error: {error.message} -- Cannot get {error.config.url}
+
+ );
+ } else if (!isLoaded) {
+ return Loading...;
+ } else {
+ return (
+
+
risultato ricerca wikipedia: { data.results[0] }
+
+ );
+ }
+ }
+}
+
+export default Wikipedia;
\ No newline at end of file