From 42b68e972e21c47036253114217f5010f97a51b5 Mon Sep 17 00:00:00 2001 From: Cooper Ransom Date: Fri, 8 Mar 2024 20:04:47 -0500 Subject: [PATCH] Make admin page even better --- src/pages/parts/admin/WorkerTestPart.tsx | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/pages/parts/admin/WorkerTestPart.tsx b/src/pages/parts/admin/WorkerTestPart.tsx index 274cbded..95118a8f 100644 --- a/src/pages/parts/admin/WorkerTestPart.tsx +++ b/src/pages/parts/admin/WorkerTestPart.tsx @@ -1,5 +1,5 @@ import classNames from "classnames"; -import { useEffect, useMemo, useState } from "react"; +import { useMemo, useState } from "react"; import { useAsyncFn } from "react-use"; import { singularProxiedFetch } from "@/backend/helpers/fetch"; @@ -54,7 +54,6 @@ export function WorkerTestPart() { const [buttonClicked, setButtonClicked] = useState(false); const [buttonDisabled, setButtonDisabled] = useState(false); - const [allWorkersPassed, setAllWorkersPassed] = useState(false); const [testState, runTests] = useAsyncFn(async () => { setButtonDisabled(true); @@ -90,7 +89,6 @@ export function WorkerTestPart() { status: "error", error: err as Error, }); - setAllWorkersPassed(false); // Set allWorkersPassed to false if a worker fails } }); @@ -98,12 +96,6 @@ export function WorkerTestPart() { setTimeout(() => setButtonDisabled(false), 5000); }, [workerList, setWorkerState]); - useEffect(() => { - setAllWorkersPassed( - workerState.every((worker) => worker.status === "success"), - ); - }, [workerState]); - return ( <> Worker tests @@ -128,18 +120,28 @@ export function WorkerTestPart() { })}
- {allWorkersPassed && buttonClicked ? ( -
-

All workers have passed the test! ٩(ˊᗜˋ*)و ♡

-
+ {buttonClicked ? ( + workerState.every((worker) => worker.status === "success") ? ( +

+ All workers have passed the test!{" "} + ٩(ˊᗜˋ*)و♡ +

+ ) : ( +

+ Some workers have failed the test...{" "} + (•᷄∩•᷅ ) +

+ ) ) : (