{"size": 1504, "ext": "js", "max_stars_repo_path": "react-task-tracker/src/components/AddTask.js", "max_stars_repo_name": "alexandrupetrut/Multiple-Task-Trackers", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "react-task-tracker/src/components/AddTask.js", "max_issues_repo_name": "alexandrupetrut/Multiple-Task-Trackers", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "react-task-tracker/src/components/AddTask.js", "max_forks_repo_name": "alexandrupetrut/Multiple-Task-Trackers", "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": 30.693877551, "max_line_length": 98, "alphanum_fraction": 0.5179521277}
import {useState} from 'react'

const AddTask = ({onAdd}) => {

    const [description, setDescription] = useState('')
    const [date, setDate] = useState('')
    const [reminder, setReminder] = useState(false)

    const onSubmit = (e) => {
        e.preventDefault()

        if (!description) {
            alert('Please enter a description') 
            return
        }

        onAdd ({description, date, reminder})

        setDescription('')
        setDate('')
        setReminder(false)
    }

    return (
        <form className='add-form' onSubmit={onSubmit}>

            <div className='form-control'>
                <label> Task </label>
                <input type='text' placeholder='Add Task' 
                    value={description} onChange = { (e) => setDescription (e.target.value)} />
            </div>
            <div className='form-control'>
                <label> Day & Time </label>
                <input type='text' placeholder='Add Day & Time' 
                    value={date} onChange = { (e) => setDate (e.target.value)} />
            </div>
            <div className='form-control form-control-check'>
                <label> Set Reminder </label>
                <input type='checkbox' checked={reminder}
                    value={reminder} onChange = { (e) => setReminder (e.currentTarget.checked)} />
            </div>

            <input type='submit' value='Save Task' className='btn btn-block'/>
        
        </form>
    )
}

export default AddTask