: null}
                        
                    > :
                    
                        {this.state.loadedtags ?
                            this.state.loadedtags.map((m) => (
                                
                            )) :
                            "loading"}
                    
                }
                {this.state.popupvisible ?
                     {
                                     this.setState({popupvisible: false});
                                     this.loadTags();
                                 }}/> :
                    null
                }
            >
        );
    }
    /**
     * load a specific tag into a new previewcontainer
     * @param tagname
     */
    loadTag = (tagname) => {
        this.fetchVideoData(tagname);
    };
    /**
     * fetch data for a specific tag from backend
     * @param tag 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/video.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");
            });
    }
    /**
     * go back to the default category overview
     */
    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;