: null}
> :
{this.state.loadedtags ?
this.state.loadedtags.map((m) => (
)) :
"loading"}
}
{this.state.popupvisible ?
{
this.setState({popupvisible: false});
this.loadTags();
}}/> :
null
}
>
);
}
loadTag = (tagname) => {
this.fetchVideoData(tagname);
};
fetchVideoData(tag) {
console.log(tag);
const updateRequest = new FormData();
updateRequest.append('action', 'getMovies');
updateRequest.append('tag', tag);
console.log("fetching data");
// fetch all videos available
fetch('/api/videoload.php', {method: 'POST', body: updateRequest})
.then((response) => response.json()
.then((result) => {
this.videodata = result;
this.setState({selected: null}); // needed to trigger the state reload correctly
this.setState({selected: tag});
}))
.catch(() => {
console.log("no connection to backend");
});
}
loadCategoryPageDefault = () => {
this.setState({selected: null});
this.loadTags();
};
/**
* load all available tags from db.
*/
loadTags() {
const updateRequest = new FormData();
updateRequest.append('action', 'getAllTags');
// fetch all videos available
fetch('/api/Tags.php', {method: 'POST', body: updateRequest})
.then((response) => response.json()
.then((result) => {
this.setState({loadedtags: result});
}))
.catch(() => {
console.log("no connection to backend");
});
}
}
export default CategoryPage;