Skip to content

Commit

Permalink
定期更新の追加 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToYama170402 authored Sep 17, 2024
1 parent 5b4e76c commit 15718cf
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions frontend/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import {
useMediaQuery,
} from "@mui/material";
import { useTheme } from "@mui/material/styles";
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { fetchAll } from "../util/rishu";
import {
array2WeekTimeTable,
filters,
weekTimeTable,
weekTimeTable2Filters,
Expand Down Expand Up @@ -48,6 +50,16 @@ export default function Layout({
setHelpOpen(!isHelpOpen);
};

const [timeTableData, setTimeTableData] = useState(timeTable);

useEffect(() => {
setInterval(async () => {
const newTimeTable = await fetchAll();
newTimeTable.shift()?.shift();
setTimeTableData(array2WeekTimeTable(newTimeTable));
}, 50000);
}, []);

type isFilterOpen = {
filter: boolean;
category: boolean;
Expand Down Expand Up @@ -208,7 +220,7 @@ export default function Layout({
}}
>
<TimeTable
timeTable={timeTable}
timeTable={timeTableData}
filter={filters}
width={"100%"}
height={"100%"}
Expand Down

0 comments on commit 15718cf

Please sign in to comment.