-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.js
52 lines (47 loc) · 1.26 KB
/
page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"use client";
import { useState, useEffect } from "react";
import styles from "./page.module.css";
import TaskRow from "./components/TaskRow/TaskRow";
import defaultTasks from "./testdata/tasks.js";
import Popover from "./components/Popover/Popover";
import AddCircleRoundedIcon from '@mui/icons-material/AddCircleRounded';
import AddTask from "./components/Tasks/AddTask";
export default function Home() {
const [tasks, setTasks] = useState(defaultTasks);
/*
const fetchTaskList = async () => {
try {
const response = await fetch(`http://localhost:5000/getTasks`);
if (!response.ok) {
throw new Error("Network response was not ok");
}
const data = await response.json();
console.log(data);
setTasks(data);
} catch (error) {
console.error("Error fetching user data:", error);
}
};
useEffect(() => {
fetchTaskList();
}, []);
*/
return (
<>
<Popover
trigger={
<div className={styles.addTaskIcon}>
<AddCircleRoundedIcon
className={styles.icon__add}
/>
</div>
}
>
<AddTask />
</Popover>
{tasks.map(({ name, id }) => {
return <TaskRow key={id} taskName={name} />;
})}
</>
);
}