HyeonJun Jeon

[Fix] Day/week/month button

import { useContext } from "react";
import { useNavigate } from "react-router-dom";
import { CalendarStateContext } from "../pages/Calendar";
import "../styles/Header.css";
const Header = () => {
const [state, setState] = useContext(CalendarStateContext);
const handleChangeState = (e) => {
const navigate = useNavigate();
const setScope = (e) => {
setState({
...state,
[e.target.name]: e.target.value,
});
navigate("/calendar/" + e.target.value);
};
const gotoToday = () => {
......@@ -78,7 +81,7 @@ const Header = () => {
<div className="hrd">
<button
disabled={state.scope === "day"}
onClick={handleChangeState}
onClick={setScope}
name="scope"
value="day"
>
......@@ -86,7 +89,7 @@ const Header = () => {
</button>
<button
disabled={state.scope === "week"}
onClick={handleChangeState}
onClick={setScope}
name="scope"
value="week"
>
......@@ -94,7 +97,7 @@ const Header = () => {
</button>
<button
disabled={state.scope === "month"}
onClick={handleChangeState}
onClick={setScope}
name="scope"
value="month"
>
......