{"size": 1313, "ext": "js", "max_stars_repo_path": "reactjs/src/components/categories/DeleteCategory.js", "max_stars_repo_name": "khakobyan/blog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reactjs/src/components/categories/DeleteCategory.js", "max_issues_repo_name": "khakobyan/blog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reactjs/src/components/categories/DeleteCategory.js", "max_forks_repo_name": "khakobyan/blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.0243902439, "max_line_length": 109, "alphanum_fraction": 0.5422696116}
import React, { Component } from 'react';
import axios from 'axios';
import {Redirect} from 'react-router';
import { HashRouter, Route, Link } from 'react-router-dom';
import DeleteCategoryButton from '../modals/DeleteCategoryButton';
import PropTypes from 'prop-types';

export default class DeleteCategory extends Component {
    constructor(props) {
        super(props);
        this.state = {
            name: '',
            data_target: '#'+this.props.id+'delete'
        }
        this.deleteCategory = this.deleteCategory.bind(this); 
    }
    deleteCategory() {
        axios.delete('/api/me/categories/' + this.props.id)
        .then((response) => {
            this.props.deleteCategory(this.props.id);
        }).catch((error) => {

        })
    }
    render() {
        return (
            <div>
                <div className="row">
                    <div className="deleteCategory" data-toggle="modal" data-target={this.state.data_target}>
                        <button type="button" className="btn btn-danger center-block">Delete</button>
                    </div>
                </div>
                <DeleteCategoryButton
                    modal_id={this.props.id} 
                    deleteCategory={this.deleteCategory}
                />
            </div>
        )
    }
}
