<commit_before>import * as React from "react";
import * as classNames from 'classnames';

import { Todo } from './../todo.interface.ts';

export default class TodoItem extends React.Component<TodoItemProps, TodoComponentState> {

    constructor(props) {
        super(props);
        this.state = {
            isEdited: false
        };
    }

    setDescription(event) {
        this.setState({valid: true, description: event.target.value});
    }

    editTodo() {
        this.setState({
            isEdited: true,
            valid: true,
            description: this.props.description
        });
    }

    cancelEditTodo() {
        this.setState({
            isEdited: false,
            valid: true
        });
    }

    saveTodo() {
        if (!this.state.description.length || this.state.description.length > 50) {
            this.props.editTodo(this.state.description);
            this.setState({ valid: false });
        } else {
            this.props.editTodo(this.state.description);
            this.setState({
                isEdited: false,
                valid: true,
                description: ''
            });
        }
    }

    render() {
        let inputClass = classNames('form-group', {
            'form-group': true,
            'has-error': !this.state.valid
        });
        let deleteButtonStyle = {
            color: '#ff0000',
            marginLeft: 5
        }
        let descriptionStyle = {
            paddingTop: 4,
            cursor: 'pointer'
        }
        return(
            <div className="panel panel-default">
                <div className="panel-body">
                    <div className="row"><commit_msg>fix(todo): don't save invalid todo<commit_after>import * as React from "react";
import * as classNames from 'classnames';

import { Todo } from './../todo.interface.ts';

export default class TodoItem extends React.Component<TodoItemProps, TodoComponentState> {

    constructor(props) {
        super(props);
        this.state = {
            isEdited: false
        };
    }

    setDescription(event) {
        this.setState({valid: true, description: event.target.value});
    }

    editTodo() {
        this.setState({
            isEdited: true,
            valid: true,
            description: this.props.description
        });
    }

    cancelEditTodo() {
        this.setState({
            isEdited: false,
            valid: true
        });
    }

    saveTodo() {
        if (!this.state.description.length || this.state.description.length > 50) {
            this.setState({ valid: false });
        } else {
            this.props.editTodo(this.state.description);
            this.setState({
                isEdited: false,
                valid: true,
                description: ''
            });
        }
    }

    render() {
        let inputClass = classNames('form-group', {
            'form-group': true,
            'has-error': !this.state.valid
        });
        let deleteButtonStyle = {
            color: '#ff0000',
            marginLeft: 5
        };
        let descriptionStyle = {
            paddingTop: 4,
            cursor: 'pointer'
        };
        return(
            <div className="panel panel-default">
                <div className="panel-body">
                    <div className="row">
{'fraction_non_alphanumeric': 0.11981981981981982, 'fraction_numerical': 0.004804804804804805, 'mean_word_length': 1.535007610350076, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6928108', 'n_tokens_mistral': 914, 'n_tokens_neox': 886, 'n_words': 182}