From a627b98a3b0a9ac21768b87b8fb9da27fcea5d65 Mon Sep 17 00:00:00 2001 From: JohanGrims Date: Fri, 18 Oct 2024 19:10:53 +0200 Subject: [PATCH] different fixes and features --- src/admin/Students.tsx | 2 +- src/admin/index.jsx | 2 +- src/admin/navigation/DrawerList.jsx | 2 +- src/admin/navigation/VoteDrawer.jsx | 16 ++- src/admin/vote/Answers.jsx | 18 ++- src/admin/vote/Match.tsx | 192 +++++++++++++++++++--------- src/admin/vote/index.jsx | 59 +++------ src/main.jsx | 2 +- 8 files changed, 181 insertions(+), 112 deletions(-) diff --git a/src/admin/Students.tsx b/src/admin/Students.tsx index 4200947..b6db4b7 100644 --- a/src/admin/Students.tsx +++ b/src/admin/Students.tsx @@ -281,7 +281,7 @@ export default function Students() { onClick={() => { navigate(`/admin/students/${classId}/true`); }} - >{" "} + > classId && removeClass(classId)} diff --git a/src/admin/index.jsx b/src/admin/index.jsx index 0578068..03da91d 100644 --- a/src/admin/index.jsx +++ b/src/admin/index.jsx @@ -13,7 +13,7 @@ export default function Admin(props) { const [authUser, setAuthUser] = React.useState(false); const [loading, setLoading] = React.useState(true); - const [open, setOpen] = React.useState(true); + const [open, setOpen] = React.useState(window.innerWidth > 1024); React.useEffect(() => { const listen = onAuthStateChanged(auth, (user) => { diff --git a/src/admin/navigation/DrawerList.jsx b/src/admin/navigation/DrawerList.jsx index 7ca8852..7013301 100644 --- a/src/admin/navigation/DrawerList.jsx +++ b/src/admin/navigation/DrawerList.jsx @@ -219,7 +219,7 @@ export default function DrawerList() { active={active === "students"} title={"SchülerInnen"} icon={"people"} - onCLick={() => navigate("/admin/students")} + onCLick={() => navigate("/admin/students/add")} />
diff --git a/src/admin/navigation/VoteDrawer.jsx b/src/admin/navigation/VoteDrawer.jsx index 61b844e..d6b8f24 100644 --- a/src/admin/navigation/VoteDrawer.jsx +++ b/src/admin/navigation/VoteDrawer.jsx @@ -69,11 +69,17 @@ export default function VoteDrawer({}) { flexDirection: "column", }} > - navigate("/admin")} - /> + + navigate("/admin")} + /> +
answer.grade))]; + const navigate = useNavigate(); + React.useEffect(() => { if (search) { const query = search.toLowerCase(); @@ -38,7 +41,18 @@ export default function Answers() { return (
-

Antworten

+
+

Antworten

+ navigate("../match")}> + Mit Klassenlisten abgleichen + +
+
setMode("by-option")}> Nach Erstwahl @@ -50,6 +64,8 @@ export default function Answers() { Nach Name +
+

{mode === "by-option" && ( a.grade - b.grade); + return (

Abgleichen

- - {sortedClasses.map((c) => ( - - Klasse {c.grade} - {c.students.length} - - ))} -

- {sortedClasses.map((c) => ( - -

-
- - - - - - - - - - {c.students.map((s) => ( + + setMode("database")}> + Datenbank + + setMode("answers")}> + Antworten + + + + {mode === "database" && ( + + {sortedClasses.map((c) => ( + + Klasse {c.grade} + {c.students.length} + + ))} +

+ {sortedClasses.map((c) => ( + +

+
+
Name#Name
+ - - - + + + - ))} - -
{s.name}{s.listIndex} - - choice.listIndex === s.listIndex.toString() && - choice.grade === c.grade.toString() - )[0]?.id - }`} - > - { - choices.filter( - (choice) => - choice.listIndex === s.listIndex.toString() && - choice.grade === c.grade.toString() - )[0]?.name - } - - {choices.filter( - (choice) => - choice.listIndex === s.listIndex.toString() && - choice.grade === c.grade.toString() - ).length > 1 && - " + " + - (choices.filter( - (choice) => - choice.listIndex === s.listIndex.toString() && - choice.grade === c.grade.toString() - ).length - - 1) + - " weitere"}{" "} - Name#Name
+ + + {c.students.map((s) => ( + + {s.name} + {s.listIndex} + + + choice.listIndex === + s.listIndex.toString() && + choice.grade === c.grade.toString() + )[0]?.id + }`} + > + { + choices.filter( + (choice) => + choice.listIndex === + s.listIndex.toString() && + choice.grade === c.grade.toString() + )[0]?.name + } + + {choices.filter( + (choice) => + choice.listIndex === s.listIndex.toString() && + choice.grade === c.grade.toString() + ).length > 1 && + " + " + + (choices.filter( + (choice) => + choice.listIndex === + s.listIndex.toString() && + choice.grade === c.grade.toString() + ).length - + 1) + + " weitere"}{" "} + + + ))} + + +
-
- - ))} - + + ))} + + )} + + {mode === "answers" && ( +
+
+ + + + + + + + + + + {choices + .sort((a, b) => { + if (a.grade === b.grade) { + return a.listIndex - b.listIndex; + } + return a.grade - b.grade; + }) + .map((choice) => ( + + + + + + + ))} + +
Name#KlasseName
+ + {choice.name} + + {choice.listIndex}{choice.grade} + { + sortedClasses + .find( + (c) => Number(c.grade) === Number(choice.grade) + ) + ?.students.find( + (s) => + Number(s.listIndex) === Number(choice.listIndex) + )?.name + } +
+
+
+ )}
); } diff --git a/src/admin/vote/index.jsx b/src/admin/vote/index.jsx index ca9828f..3eff8ae 100644 --- a/src/admin/vote/index.jsx +++ b/src/admin/vote/index.jsx @@ -11,27 +11,23 @@ export default function AdminVote() {

{vote.title}

- Date.now() - ? vote.startTime.seconds * 1000 < Date.now() - ? "aktiv" - : "geplant" - : "beendet" - }.`} - > - Date.now() - ? vote.startTime.seconds * 1000 < Date.now() - ? "event_available" - : "event" - : "done_all" - } - > - + navigate("./schedule")}> + {!vote.active + ? "Nicht aktiv" + : `${new Date(vote.startTime.seconds * 1000).toLocaleString([], { + hour: "2-digit", + minute: "2-digit", + day: "2-digit", + month: "2-digit", + year: "numeric", + })} - ${new Date(vote.endTime.seconds * 1000).toLocaleString([], { + hour: "2-digit", + minute: "2-digit", + day: "2-digit", + month: "2-digit", + year: "numeric", + })}`} +

navigate(`/admin/${vote.id}/schedule`)} + onClick={() => navigate(`/admin/${vote.id}/match`)} > -

- {vote.active && vote.endTime.seconds * 1000 > Date.now() - ? vote.startTime.seconds * 1000 < Date.now() - ? "Beenden" - : "Planen" - : "Starten"} -

+

Abgleichen

- Date.now() - ? vote.startTime.seconds * 1000 < Date.now() - ? "pause" - : "scheduled" - : "play_arrow" - } - style={{ fontSize: "50px" }} - /> +

, }, { - path: "students/:classId?/:edit?", + path: "students/:classId/:edit?", element: , loader: studentsLoader, },