aboutsummaryrefslogtreecommitdiff
path: root/jb-ui/src/pages/Work.tsx
diff options
context:
space:
mode:
authorMax Nanis2026-09-12 14:30:31 -0700
committerMax Nanis2026-09-12 14:30:31 -0700
commitb2261f9101480afb31322cf620f028cdade0671c (patch)
tree0bcba3696b0566138145d80a8fcb9230b172f2c5 /jb-ui/src/pages/Work.tsx
parentf82ac61b6a044467ab37c0645c3fe99b40bedfc5 (diff)
downloadamt-jb-b2261f9101480afb31322cf620f028cdade0671c.tar.gz
amt-jb-b2261f9101480afb31322cf620f028cdade0671c.zip
new landing page that combines leaderboard + login. fixing worker_id assignment, it'll still be needed until transfer is finished
Diffstat (limited to 'jb-ui/src/pages/Work.tsx')
-rw-r--r--jb-ui/src/pages/Work.tsx78
1 files changed, 2 insertions, 76 deletions
diff --git a/jb-ui/src/pages/Work.tsx b/jb-ui/src/pages/Work.tsx
index 84cb946..dbe3601 100644
--- a/jb-ui/src/pages/Work.tsx
+++ b/jb-ui/src/pages/Work.tsx
@@ -11,6 +11,7 @@ import {
TaskStatusResponse,
TopNPlusBlockOfferWall,
} from "@/api_fsb";
+import Preview from "@/pages/Preview";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
@@ -793,81 +794,6 @@ const SurveyEnter = () => {
);
};
-type RequestState = "idle" | "working" | "sent" | "failed";
-
-const Login = () => {
- const [email, setEmail] = useState("");
- const [state, setState] = useState<RequestState>("idle");
-
- // const dispatch = useAppDispatch();
- const submit = async (event: FormEvent<HTMLFormElement>) => {
- event.preventDefault();
- setState("working");
-
- try {
- const response = await fetch("/auth/magic-link/request", {
- method: "POST",
- credentials: "include",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({
- email: email,
- }),
- });
-
- if (!response.ok) throw new Error("Account-link request failed");
-
- const body = (await response.json()) as { magic_link?: string };
- console.log(body.magic_link ?? null);
- } catch {
- setState("failed");
- }
- };
-
- return (
- <div className="px-6 my-6">
- <h2
- className="
- bg-blue-700 rounded py-2
- text-white text-2xl font-semibold text-center"
- >
- Please Login
- </h2>
-
- <form onSubmit={submit}>
- <input
- className="w-full rounded-md border-3 border-slate-700 px-3 py-2 font-semibold my-5"
- type="email"
- autoComplete="email"
- required
- value={email}
- onChange={(event) => setEmail(event.target.value)}
- placeholder="hello@jamesbillings67.com"
- />
- <Button
- className="w-1/2 font-semibold bg-slate-600 cursor-pointer hover:bg-blue-950"
- type="submit"
- disabled={state === "working"}
- >
- {state === "working" ? "Sending…" : "Login"}
- </Button>
- </form>
-
- {state === "sent" && (
- <h4
- className="
- mt-2
- bg-slate-500 rounded py-2
- text-white text-l font-semibold text-center"
- >
- Check your email to login.
- </h4>
- )}
-
- {state === "failed" && <p>Unable to send the link. Please try again.</p>}
- </div>
- );
-};
-
const Work = () => {
const entered = useAppSelector((state) => state.app.currentBucketEntered);
// const assignment_id = useAppSelector((state) => state.app.assignment_id);
@@ -886,7 +812,7 @@ const Work = () => {
if (isLoading) return <div>Loading...</div>;
if (isError || !user) {
- return <Login />;
+ return <Preview />;
}
return <>{entered ? <SurveyMonitor /> : <SurveyEnter />}</>;