aboutsummaryrefslogtreecommitdiff
path: root/jb-ui/src/pages/Work.tsx
diff options
context:
space:
mode:
authorMax Nanis2026-09-11 23:06:59 -0700
committerMax Nanis2026-09-11 23:06:59 -0700
commitf82ac61b6a044467ab37c0645c3fe99b40bedfc5 (patch)
treee55d6879f4cfaf683e4bee1b6f0221ddc3baf799 /jb-ui/src/pages/Work.tsx
parent11d63b171501b9c29398133b795c3bcc1ae85a1b (diff)
downloadamt-jb-f82ac61b6a044467ab37c0645c3fe99b40bedfc5.tar.gz
amt-jb-f82ac61b6a044467ab37c0645c3fe99b40bedfc5.zip
replace references to bpuid with logged in user
Diffstat (limited to 'jb-ui/src/pages/Work.tsx')
-rw-r--r--jb-ui/src/pages/Work.tsx71
1 files changed, 17 insertions, 54 deletions
diff --git a/jb-ui/src/pages/Work.tsx b/jb-ui/src/pages/Work.tsx
index e33328e..84cb946 100644
--- a/jb-ui/src/pages/Work.tsx
+++ b/jb-ui/src/pages/Work.tsx
@@ -51,8 +51,7 @@ import Markdown from "react-markdown";
const Report = ({ onClose }: { onClose: () => void }) => {
const [showComplete, setShowComplete] = useState(false);
const [selectedValues, setSelectedValues] = useState<ReportValue[]>([]);
-
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
const ts = useAppSelector((state) => state.app.taskStatus);
const handleCheckboxChange = (value: ReportValue, checked: boolean) => {
@@ -62,12 +61,12 @@ const Report = ({ onClose }: { onClose: () => void }) => {
};
const clicked_submit = () => {
- if (!bpuid) return;
+ if (!user?.product_user_id) return;
// ReportValue.NUMBER_0
console.log("selectedValues:", selectedValues);
const rt: ReportTask = {
- bpuid: bpuid,
+ bpuid: user.product_user_id,
reasons: selectedValues,
notes: "",
};
@@ -122,9 +121,10 @@ const Report = ({ onClose }: { onClose: () => void }) => {
return <p>Please finish a Task to report its status.</p>;
}
- if (showComplete) {
- return <SubimtAMT />;
- }
+ // TODO! What do we do here, redirect back to / with a thank you + wallet refresh?
+ // if (showComplete) {
+ // return <SubimtAMT />;
+ // }
return (
<div className="border-2 border-rose-200 rounded">
@@ -189,43 +189,6 @@ const Report = ({ onClose }: { onClose: () => void }) => {
);
};
-const SubimtAMT = () => {
- const bpuid = useAppSelector((state) => state.app.bpuid);
- const assignment_id = useAppSelector((state) => state.app.assignment_id);
- const ts = useAppSelector((state) => state.app.taskStatus);
- const turkSubmitTo = useAppSelector((state) => state.app.turkSubmitTo);
-
- const formRef = useRef<HTMLFormElement>(null);
-
- useEffect(() => {
- if (!ts) return;
- if (!bpuid) return;
- if (!assignment_id) return;
- if (!turkSubmitTo) return;
-
- if (formRef.current) {
- formRef.current.submit();
- }
- }, [ts?.tsid, bpuid, assignment_id, turkSubmitTo]);
-
- return (
- <>
- <form
- ref={formRef}
- action={`${turkSubmitTo}/mturk/externalSubmit`}
- method="POST"
- style={{ display: "none" }}
- >
- <input type="hidden" name="assignmentId" value={assignment_id} />
- <input type="hidden" name="tsid" value={ts?.tsid} />
- <input type="hidden" name="amt_assignment_id" value={assignment_id} />
- <input type="hidden" name="amt_worker_id" value={bpuid} />
- <button type="submit">Submit HIT</button>
- </form>
- </>
- );
-};
-
const SurveyMonitor = () => {
const dispatch = useAppDispatch();
@@ -235,7 +198,7 @@ const SurveyMonitor = () => {
const [showComplete, setShowComplete] = useState(false);
const [showReport, setShowReport] = useState(false);
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
const entered = useAppSelector((state) => state.app.currentBucketEntered);
const isLow = useAppSelector((state) => isLowBalance(state));
@@ -263,7 +226,7 @@ const SurveyMonitor = () => {
// }, [ts]);
useEffect(() => {
- if (!bpuid) return;
+ if (!user?.product_user_id) return;
if (!entered) return;
if (!isPolling) return;
@@ -271,7 +234,7 @@ const SurveyMonitor = () => {
new StatusApi()
.listTaskStatusesProductIdStatusGet(
bpid, // productId
- bpuid, // Worker ID
+ user.product_user_id, // Worker ID
entered, // startedAfter
moment.utc().unix(), // startedBefore
)
@@ -418,8 +381,9 @@ const SurveyMonitor = () => {
Report Survey
</button>
</div>
-
- {showComplete && <SubimtAMT />}
+ {/* TODO! What do we do here, redirect back to / with wallet */}
+ {/* TODO! refresh? The confetti is on a different page. */}
+ {/* {showComplete && <SubimtAMT />} */}
{showReport && <Report onClose={() => setShowReport(false)} />}
</>
) : (
@@ -731,7 +695,7 @@ const BucketDetails = () => {
const SurveyEnter = () => {
const dispatch = useAppDispatch();
const loi = useAppSelector((state) => state.app.loi);
- const bpuid = useAppSelector((state) => state.app.bpuid);
+ const { data: user, isLoading, isError } = useGetMeQuery();
const available_cnt = useAppSelector((state) => getAvailabilityCount(state));
const buckets = useAppSelector((state) => state.app.currentBuckets);
@@ -739,12 +703,12 @@ const SurveyEnter = () => {
const isLow = useAppSelector((state) => isLowBalance(state));
useEffect(() => {
- if (!bpuid) return;
+ if (!user?.product_user_id) return;
new OfferwallApi()
.topNPlusBlockOfferwallProductIdOfferwallD48cce47Get(
bpid, // productId
- bpuid, // bpuid
+ user.product_user_id,
undefined, // ip
undefined, // countryIso
undefined, // languages
@@ -766,7 +730,7 @@ const SurveyEnter = () => {
dispatch(setCurrentBuckets(top_n_res.buckets));
dispatch(setOfferwallReasons(top_n_res.offerwall_reasons ?? []));
});
- }, [loi, bpuid]);
+ }, [loi, user?.product_user_id]);
const start_survey = () => {
if (!bucket?.uri) return;
@@ -834,7 +798,6 @@ type RequestState = "idle" | "working" | "sent" | "failed";
const Login = () => {
const [email, setEmail] = useState("");
const [state, setState] = useState<RequestState>("idle");
- const bpuid = useAppSelector((state) => state.app.bpuid);
// const dispatch = useAppDispatch();
const submit = async (event: FormEvent<HTMLFormElement>) => {