import React from "react"; import SideBar from "../elements/SideBar"; import Tag from "../elements/Tag"; import "../css/CategoryPage.css" import {TagPreview} from "../elements/Preview"; class CategoryPage extends React.Component { constructor(props, context) { super(props, context); this.props = props; this.state = { loadedtags: [], selected: false }; } componentDidMount() { this.loadTags(); } render() { return ( <>
Category Page {this.state.loadedtags ? this.state.loadedtags.length + " different Tags" : ""}
Default Tags:
All FullHd LowQuality HD
{!this.state.selected ? (this.state.loadedtags ? this.state.loadedtags.map((m) => ( )) : "loading") : this.selectionelements }
); } setPage = (element) => { this.selectionelements = element; this.setState({selected: true}); }; /** * 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;