Skip to content

Commit 2b9204e

Browse files
fixed build issues
1 parent 95eece5 commit 2b9204e

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/app/page.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Grid from "@mui/material/Grid2";
2626
import Divider from "@mui/material/Divider";
2727
import Dialog from "@mui/material/Dialog";
2828
import DialogTitle from "@mui/material/DialogTitle";
29-
import { format, formatDistance, formatRelative, subDays } from "date-fns";
29+
import { format } from "date-fns";
3030

3131
interface Task {
3232
_id: string;
@@ -43,7 +43,7 @@ export interface SimpleDialogProps {
4343
}
4444

4545
function AddTaskDialog(props: SimpleDialogProps) {
46-
const { onClose, selectedValue, open } = props;
46+
const { onClose, open } = props;
4747

4848
const newTaskProp = {
4949
title: "",
@@ -57,19 +57,14 @@ function AddTaskDialog(props: SimpleDialogProps) {
5757
onClose("");
5858
};
5959

60-
const handleListItemClick = (value: string) => {
61-
onClose(value);
62-
};
6360
const addTask = async () => {
6461
if (!newTask.title || !newTask.dueDate) {
6562
console.error("Validation error");
6663
return;
6764
}
6865
setLoadingState(true);
69-
const res = await axios.post<Task>("/api/tasks", newTask);
70-
// setTasks([...tasks, res.data]);
66+
await axios.post<Task>("/api/tasks", newTask);
7167
setNewTask(newTaskProp);
72-
// showSnackBar("Task added!");
7368
setLoadingState(false);
7469
onClose("Task added!");
7570
};
@@ -95,7 +90,7 @@ function AddTaskDialog(props: SimpleDialogProps) {
9590
size="small"
9691
value={newTask.dueDate}
9792
onChange={(e) =>
98-
setNewTask({ ...newTask, dueDate: e.target.value })
93+
setNewTask({ ...newTask, dueDate: new Date(e.target.value) })
9994
}
10095
sx={{ mt: 2 }}
10196
/>
@@ -128,9 +123,9 @@ function AddTaskDialog(props: SimpleDialogProps) {
128123
);
129124
}
130125

131-
export function TaskHeader(props) {
126+
function TaskHeader(props) {
132127
const [open, setOpen] = useState(false);
133-
const [selectedValue, setSelectedValue] = useState();
128+
const [selectedValue] = useState();
134129

135130
const handleClickOpen = () => {
136131
setOpen(true);
@@ -185,7 +180,7 @@ export default function Home() {
185180
setTasks(res.data);
186181
setInitialLoading(false); // Set initial loading to false after tasks are loaded
187182
});
188-
}
183+
};
189184

190185
useEffect(() => {
191186
loadList();
@@ -259,7 +254,10 @@ export default function Home() {
259254
onChange={() => toggleTask(task)}
260255
/>
261256
<ListItemText
262-
primary={`${task.title} (Due: ${format(task.dueDate ?? new Date(), "dd MMM")})`}
257+
primary={`${task.title} (Due: ${format(
258+
task.dueDate ?? new Date(),
259+
"dd MMM"
260+
)})`}
263261
secondary={`Priority: ${task.priority}`}
264262
sx={{
265263
textDecoration: task.completed ? "line-through" : "none",

0 commit comments

Comments
 (0)