import React, { useState } from "react"; import { useSelector, useDispatch } from "react-redux"; import { add_todo, change_done, remove_todo, edit_todo, set_sort_todo, sort_todo, select_todos, select_last_index, select_current_sorting, } from "./features/todo/reducer"; export function NewToDo() { const my_todos = useSelector(select_todos); const my_last_idx = useSelector(select_last_index); const dispatch = useDispatch(); const [new_text, set_new_text] = useState(""); const [new_due_date, set_new_due_date] = useState(""); const [new_done, set_new_done] = useState(false); const [new_priority, set_new_priority] = useState("Low"); function handle_exit_modal() { // https://stackoverflow.com/questions/27826381/clearing-form-input-fields-in-bootstrap $("form").get(0).reset(); // Reset form set_new_text(""); set_new_due_date(""); set_new_done(false); set_new_priority("Low"); } return ( <>
# | Name | { dispatch( set_sort_todo({ where_clicked: "priority", }) ), dispatch(sort_todo()); }} > {sort_table_header("Priority", my_sorting)} | { dispatch( set_sort_todo({ where_clicked: "due_date", }) ), dispatch(sort_todo()); }} > {sort_table_header("Due Date", my_sorting)} | Actions |
---|---|---|---|---|
dispatch(
change_done({
id: item.id,
done: e.target.checked,
})
)
}
>
|
{item.text} | {item.priority} | {item.due_date} |
|