import React, { useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import {
change_done,
remove_todo,
edit_todo,
set_sort_todo,
select_todos,
select_current_filters,
select_current_sorting,
select_current_page,
} from "../features/todo/reducer";
import {
edit_todo_function,
remove_todo_function,
set_done_function,
set_undone_function,
} from "../api/axios_methods";
import { refresh_todos } from "../refreshToDos";
function sort_table_header(prefix, current_sorting) {
if (prefix.toLowerCase().startsWith(current_sorting.substr(0, 3))) {
switch (current_sorting.substr(-1)) {
case "^":
// Write Prefix and an arrow pointing up.
return (
<>
{prefix} ↑
>
);
case "v":
// Write Prefix and an arrow pointing down.
return (
<>
{prefix} ↓
>
);
}
} else {
// Write Prefix and four dots. No sorting.
return (
<>
{prefix} ⁛
>
);
}
}
function list_of_todos(edit_button, delete_button) {
const dispatch = useDispatch();
const my_todos = useSelector(select_todos);
const my_sorters = useSelector(select_current_sorting);
function handle_sort_todos(where_clicked) {
dispatch(
set_sort_todo({
where_clicked: where_clicked,
})
);
}
const set_done_api = set_done_function();
const set_undone_api = set_undone_function();
const date_options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
};
// Table contents
var table_head = (
);
var table_body = (
Done
Name
handle_sort_todos("priority")}>
{sort_table_header("Priority", my_sorters)}
{
handle_sort_todos("due_date");
}}
>
{sort_table_header("Due Date", my_sorters)}
Actions