diff --git a/components/Timetable.tsx b/components/Timetable.tsx index e3024c6..b09774c 100644 --- a/components/Timetable.tsx +++ b/components/Timetable.tsx @@ -62,7 +62,7 @@ const Timetable = ({ user }) => { // revert conflict changed input for (const { input, disable } of changedInputs) { if (disable) { - input.addAttribute("disabled", "true"); + input.setAttribute("disabled", "true"); } else { input.removeAttribute("disabled"); } @@ -154,7 +154,7 @@ const Timetable = ({ user }) => { // after checked, find conflicts input if (includes) { for (const input of conflicts[index]) { - console.log("conflict", input); + if (input.name === index) continue; input.setAttribute("disabled", "true"); } } diff --git a/pages/report.tsx b/pages/report.tsx new file mode 100644 index 0000000..edf2dae --- /dev/null +++ b/pages/report.tsx @@ -0,0 +1,50 @@ +import React from "react"; +import Head from "next/head"; + +const ReportPage = () => { + const ref = React.useRef(); + const getReport = async () => { + const resp = await fetch("/api/html").then((resp) => resp.json()); + ref.current.innerHTML = resp.html; + const json: Record = await fetch("/api/admin").then( + (resp) => resp.json() + ); + const table = ref.current.children[0]; + const tbody = table.children[table.children.length - 1]; + for (const tr_index in tbody.children) { + const tr = tbody.children[tr_index]; + for (const td_index in tr.children) { + const td = tr.children[td_index]; + if (td.tagName !== "TD") continue; + const index = `${tr_index},${td_index}`; + if (json[index] === undefined) continue; + td.innerHTML = json[index]; + } + } + }; + React.useEffect(() => { + getReport(); + }, []); + return ( + <> + + Create Next App + + + + +
+ +
{ + console.log(event.currentTarget.innerHTML); + }} + contentEditable="true" + >
+
+ + ); +}; + +export default ReportPage; diff --git a/test.ts b/test.ts index 2cfe808..da4d0c8 100644 --- a/test.ts +++ b/test.ts @@ -11,3 +11,6 @@ const result = await fetch("http://localhost:3000/api/admin", { }).then(resp => resp.text()) console.log(result) + +// set begin +await fetch('http://localhost:3000/api/begin') \ No newline at end of file