import { useState, useEffect } from "react"; import { Link } from "react-router-dom"; import todoApi from "../../apis/todo.api"; import { useAuth } from "../../utils/context.js"; import catchErrors from "../../utils/catchErrors"; import moment from "moment"; import styles from "./menu.module.scss"; const Menu = () => { const { user, logout } = useAuth(); const [todoList, setTodoList] = useState({ percent: 0, list: [] }) const [error, setError] = useState(""); useEffect(() => { todayTodo() }, []) async function todayTodo() { try { setError("") const result = await todoApi.getTodopercent(user.id, moment().format("YYYY-MM-DD")) console.log("client resList",result) setTodoList({...todoList, ...result}) } catch (error) { catchErrors(error, setError) } } return ( <> ) } export default Menu