#51 try to optimize mmyTasks, no result

parent 61f618b6
...@@ -58,20 +58,18 @@ function stableSort(array, comparator) { ...@@ -58,20 +58,18 @@ function stableSort(array, comparator) {
export default function EnhancedTable() { export default function EnhancedTable() {
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchAllTasks());
dispatch(fetch)
}, [dispatch]);
const tasks = useSelector((state) => state.tasks.tasks); const tasks = useSelector((state) => state.tasks.tasks);
console.log(tasks) console.log(tasks)
const [recievedTasks, setRecievedTasks] = useState([]); const [recievedTasks, setRecievedTasks] = useState([]);
const [projects,setProjects]=useState([]) const [projects,setProjects]=useState(['1','2'])
// const projects=[
// "project1", useEffect(() => {
// "project2", dispatch(fetchAllTasks());
// "project3" }, [dispatch]);
// ]
const [order, setOrder] = React.useState("asc"); const [order, setOrder] = React.useState("asc");
const [orderBy, setOrderBy] = React.useState("id"); const [orderBy, setOrderBy] = React.useState("id");
...@@ -257,6 +255,7 @@ console.log(tasks) ...@@ -257,6 +255,7 @@ console.log(tasks)
onClick={() => { onClick={() => {
addTask(); addTask();
}} }}
projects={projects} projects={projects}
onClose={onClose} onClose={onClose}
projectName={projectName} projectName={projectName}
......
...@@ -156,7 +156,7 @@ export const fetchTasksByProject = (projects) => { ...@@ -156,7 +156,7 @@ export const fetchTasksByProject = (projects) => {
return async (dispatch) => { return async (dispatch) => {
dispatch(fetchTasksByProjectRequest()); dispatch(fetchTasksByProjectRequest());
try { try {
await axios.post("/tasks/project", projects); const response =await axios.post("/tasks/project", projects);
dispatch(fetchTasksByProjectSuccess(response.data.tasks)) dispatch(fetchTasksByProjectSuccess(response.data.tasks))
} catch (error) { } catch (error) {
dispatch(fetchTasksByProjectFailure(error.response.data)); dispatch(fetchTasksByProjectFailure(error.response.data));
......
...@@ -13,6 +13,9 @@ import { ...@@ -13,6 +13,9 @@ import {
DELETE_TASK_FAILURE, DELETE_TASK_FAILURE,
FETCH_ALL_TASKS_SUCCESS, FETCH_ALL_TASKS_SUCCESS,
EDIT_CALENDAR_TASK, EDIT_CALENDAR_TASK,
FETCH_TASKS_BY_PROJECT_REQUEST,
FETCH_TASKS_BY_PROJECT_SUCCESS,
FETCH_TASKS_BY_PROJECT_FAILURE
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
const initialState = { const initialState = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment