add report page
This commit is contained in:
@@ -62,7 +62,7 @@ const Timetable = ({ user }) => {
|
|||||||
// revert conflict changed input
|
// revert conflict changed input
|
||||||
for (const { input, disable } of changedInputs) {
|
for (const { input, disable } of changedInputs) {
|
||||||
if (disable) {
|
if (disable) {
|
||||||
input.addAttribute("disabled", "true");
|
input.setAttribute("disabled", "true");
|
||||||
} else {
|
} else {
|
||||||
input.removeAttribute("disabled");
|
input.removeAttribute("disabled");
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ const Timetable = ({ user }) => {
|
|||||||
// after checked, find conflicts input
|
// after checked, find conflicts input
|
||||||
if (includes) {
|
if (includes) {
|
||||||
for (const input of conflicts[index]) {
|
for (const input of conflicts[index]) {
|
||||||
console.log("conflict", input);
|
if (input.name === index) continue;
|
||||||
input.setAttribute("disabled", "true");
|
input.setAttribute("disabled", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
pages/report.tsx
Normal file
50
pages/report.tsx
Normal file
@@ -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<string, string> = 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 (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>Create Next App</title>
|
||||||
|
<meta name="description" content="Generated by create next app" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
</Head>
|
||||||
|
<main>
|
||||||
|
<button onClick={async () => getReport()}>Refresh</button>
|
||||||
|
<div
|
||||||
|
ref={ref}
|
||||||
|
onInput={(event) => {
|
||||||
|
console.log(event.currentTarget.innerHTML);
|
||||||
|
}}
|
||||||
|
contentEditable="true"
|
||||||
|
></div>
|
||||||
|
</main>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReportPage;
|
||||||
Reference in New Issue
Block a user