import { type FormEvent, useState } from "react"; import { useSearchParams } from "react-router-dom"; import { useAppSelector } from "@/hooks"; import { Button } from "@/components/ui/button"; import max_lulu from "./max-and-lulu.jpg"; // const handleInputChange = ( // event: React.KeyboardEvent, // ) => {}; // const handleKeyPress = (event: KeyboardEvent) => {}; // const handleSubmit = (e) => { // e.preventDefault(); // console.log("Form submitted successfully!"); // }; const TransferComplete = function () { return (

Please check your email.

If you don't recieve anything, please check your spam folder, or try again shortly.

We will be assisting account transfers throughout the rest of the month. If you have any further questions or concerns, please email us directly with your desired account email and the AMT ID to associate with your worker history.

Max and Lulu
); }; type RequestState = "idle" | "working" | "sent" | "failed"; interface TransferSubmitProps { onSubmitSuccess: () => void; } const TransferSubmit = function ({ onSubmitSuccess }: TransferSubmitProps) { const [email, setEmail] = useState(""); const [state, setState] = useState("idle"); // const bpuid = useAppSelector((state) => state.app.bpuid); const [searchParams] = useSearchParams(); const workerId = searchParams.get("workerId"); const submit = async (event: FormEvent) => { event.preventDefault(); setState("working"); if (!workerId) throw new Error("Account-link request failed without workerId"); try { const response = await fetch("/auth/link-amt/request/", { method: "POST", credentials: "include", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: email, amt_worker_id: workerId, }), }); 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); onSubmitSuccess(); } catch { setState("failed"); } }; return (

Transfer Required

James Billings is no longer available on Amazon Mechanical Turk. Our dedicated platform will enable you to do the same work as always, paid directly to you.
Enter your email below to transfer your account history.
This will allow you to keep your full account history and wallet balance.

setEmail(event.target.value)} placeholder="you@example.com" />
{state === "sent" && (

Check your email to finish linking your account.

)} {state === "failed" &&

Unable to send the link. Please try again.

}
); }; const Transfer = function () { const bpuid = useAppSelector((state) => state.app.bpuid); const [submitted, setSubmitted] = useState(false); if (!bpuid) { return (

No Worker ID found. Please access this page through the Amazon Mechanical Turk platform.

); } return ( <> {submitted ? ( ) : ( setSubmitted(true)} /> )} ); }; export default Transfer;