From ed201936813d9a720b51e6cb40a05267b94e7314 Mon Sep 17 00:00:00 2001
From: Max Nanis
Date: Thu, 10 Sep 2026 17:46:41 -0700
Subject: Typescript prettier
Committing seperate so it's easier to see actual changes.
---
jb-ui/src/models/app.ts | 58 +++++++++++++++++++++++++------------------------
1 file changed, 30 insertions(+), 28 deletions(-)
(limited to 'jb-ui/src/models/app.ts')
diff --git a/jb-ui/src/models/app.ts b/jb-ui/src/models/app.ts
index 95b4c11..4c3e69e 100644
--- a/jb-ui/src/models/app.ts
+++ b/jb-ui/src/models/app.ts
@@ -1,37 +1,39 @@
import {
- UserWalletBalance, TopNPlusBucket, TaskStatusResponse,
- UserLedgerTransactionTypesSummary,
- UserLedgerTransactionsResponseTransactionsInner,
- OfferwallReason
+ UserWalletBalance,
+ TopNPlusBucket,
+ TaskStatusResponse,
+ UserLedgerTransactionTypesSummary,
+ UserLedgerTransactionsResponseTransactionsInner,
+ OfferwallReason,
} from "@/api_fsb";
-import { PaginationState } from '@tanstack/react-table';
+import { PaginationState } from "@tanstack/react-table";
export interface App {
- // Global IDs needed by GRL + MTurk
- bpuid?: string;
- assignment_id?: string;
- turkSubmitTo?: string;
+ // Global IDs needed by GRL + MTurk
+ bpuid?: string;
+ assignment_id?: string;
+ turkSubmitTo?: string;
- // Global UI settings
- loi: number;
- availability_count?: number;
- attempted_live_eligible_count?: number;
- offerwall_reasons: OfferwallReason[];
+ // Global UI settings
+ loi: number;
+ availability_count?: number;
+ attempted_live_eligible_count?: number;
+ offerwall_reasons: OfferwallReason[];
- // The timestamp of when the currently requested bucket was requested. We want
- // to save this to prevent it from sitting for longer than 120 seconds.
- currentBucketRequested?: number; // Date.now() is a timestamp in ms
- currentBuckets?: TopNPlusBucket[];
- currentBucketEntered?: number; // Date.now() is a timestamp in ms
- taskStatus?: TaskStatusResponse;
+ // The timestamp of when the currently requested bucket was requested. We want
+ // to save this to prevent it from sitting for longer than 120 seconds.
+ currentBucketRequested?: number; // Date.now() is a timestamp in ms
+ currentBuckets?: TopNPlusBucket[];
+ currentBucketEntered?: number; // Date.now() is a timestamp in ms
+ taskStatus?: TaskStatusResponse;
- // Wallet stuff
- userWalletBalance?: UserWalletBalance;
- userLedgerSummary?: UserLedgerTransactionTypesSummary;
- userLedgerTxCount?: number;
- userLedgerTxs: UserLedgerTransactionsResponseTransactionsInner[];
+ // Wallet stuff
+ userWalletBalance?: UserWalletBalance;
+ userLedgerSummary?: UserLedgerTransactionTypesSummary;
+ userLedgerTxCount?: number;
+ userLedgerTxs: UserLedgerTransactionsResponseTransactionsInner[];
- txPagination: PaginationState;
- txTotalItems?: number;
- txTotalPages?: number;
+ txPagination: PaginationState;
+ txTotalItems?: number;
+ txTotalPages?: number;
}
--
cgit v1.2.3
From 83821dff9984fb950e53f23baf99d7a74fb88abd Mon Sep 17 00:00:00 2001
From: Max Nanis
Date: Sun, 13 Sep 2026 10:41:49 -0700
Subject: refrences to HIT removed. Still can't test. Basic CashoutMethod
retrival until backup updated. use of the new Wallets endpoint.
---
jb-ui/src/JBApp.tsx | 69 +++++++++++++++++++++++++++------
jb-ui/src/components/Redemption.tsx | 67 ++++++++++++++++++++++++++++++++
jb-ui/src/components/Wallet.tsx | 20 ++++++----
jb-ui/src/models/app.ts | 8 ++++
jb-ui/src/models/appSlice.ts | 30 ++++++++++++++
jb-ui/src/models/cashoutMethodsSlice.ts | 37 ++++++++++++++++++
jb-ui/src/pages/Preview.tsx | 8 ++--
jb-ui/src/pages/Result.tsx | 18 +++------
jb-ui/src/pages/Work.tsx | 33 +++++++---------
jb-ui/src/store.ts | 2 +
10 files changed, 239 insertions(+), 53 deletions(-)
create mode 100644 jb-ui/src/components/Redemption.tsx
create mode 100644 jb-ui/src/models/cashoutMethodsSlice.ts
(limited to 'jb-ui/src/models/app.ts')
diff --git a/jb-ui/src/JBApp.tsx b/jb-ui/src/JBApp.tsx
index 6c31164..4870e9b 100644
--- a/jb-ui/src/JBApp.tsx
+++ b/jb-ui/src/JBApp.tsx
@@ -11,7 +11,11 @@ import {
TaskStatusResponse,
UserWalletBalance,
UserWalletBalanceResponse,
+ UserLedgerWallets,
+ UserLedgerWalletAccountTypeEnum,
+ UserDisplayedWalletBalance,
WalletApi,
+ CashoutMethodsResponse,
} from "@/api_fsb";
import Footer from "@/components/Footer";
import { useAppDispatch } from "@/hooks";
@@ -20,8 +24,13 @@ import { useGetMeQuery } from "@/models/authAPI";
import {
setAssignmentID,
setProductUserID,
- setTurkSubmitTo,
+ setUserDisplayedWalletBalance,
+ setUserWallet,
+ setUserAttemptCreditWallet,
} from "@/models/appSlice";
+
+import { addCashoutMethods } from "@/models/cashoutMethodsSlice";
+
import { addEvent } from "@/models/grlEventsSlice";
import { addStatsData } from "@/models/grlStatsSlice";
import Home from "@/pages/Home";
@@ -50,6 +59,7 @@ import Wallet from "@/components/Wallet";
import "@/index.css";
import { setTaskStatus, setUserWalletBalance } from "@/models/appSlice";
import { Profiling } from "./components/Profiling";
+import Redemption from "./components/Redemption";
type Message =
| PingMessage
@@ -76,17 +86,16 @@ function QueryParamProcessor() {
const { data: user, isLoading, isError } = useGetMeQuery();
useEffect(() => {
- const assignment_id = searchParams.get("assignmentId");
- const tsid = searchParams.get("tsid");
- const worker_id = searchParams.get("workerId");
-
- if (worker_id) {
- dispatch(setProductUserID(worker_id));
- }
-
if (user?.product_user_id) {
dispatch(setProductUserID(user.product_user_id));
+ new WalletApi()
+ .getCashoutMethodsProductIdCashoutMethodsGet(bpid, user.product_user_id)
+ .then((res) => {
+ const response = res.data as CashoutMethodsResponse;
+ dispatch(addCashoutMethods(response.cashout_methods));
+ });
+
new WalletApi()
.getUserWalletBalanceProductIdWalletGet(
bpid, // productId
@@ -97,6 +106,43 @@ function QueryParamProcessor() {
const balance = response.wallet as UserWalletBalance;
dispatch(setUserWalletBalance(balance));
});
+
+ new WalletApi()
+ .getUserWalletsProductIdWalletsGet(bpid, user.product_user_id)
+ .then((res) => {
+ const response = res.data as UserLedgerWallets;
+
+ if (response.displayed_balances) {
+ setUserDisplayedWalletBalance(response.displayed_balances[0]);
+ }
+
+ const userWallet = response.wallets?.find(
+ (w) =>
+ w.account_type === UserLedgerWalletAccountTypeEnum.UserWallet,
+ );
+ if (userWallet) {
+ setUserWallet(userWallet);
+ }
+
+ const userAttemptCreditWallet = response.wallets?.find(
+ (w) =>
+ w.account_type ===
+ UserLedgerWalletAccountTypeEnum.UserAttemptCredit,
+ );
+ if (userAttemptCreditWallet) {
+ setUserAttemptCreditWallet(userAttemptCreditWallet);
+ }
+ });
+ }
+ }, [user]);
+
+ useEffect(() => {
+ const assignment_id = searchParams.get("assignmentId");
+ const tsid = searchParams.get("tsid");
+ const worker_id = searchParams.get("workerId");
+
+ if (worker_id) {
+ dispatch(setProductUserID(worker_id));
}
if (assignment_id) {
@@ -125,8 +171,8 @@ function QueryParamProcessor() {
const Layout = () => {
const location = useLocation();
- const isWork = useMatch("/work*");
- const isPreview = useMatch("/preview*");
+ const isWork = useMatch("/work/*");
+ const isPreview = useMatch("/preview/*");
const isSpecialSubview = Boolean(isWork || isPreview);
return (
@@ -152,6 +198,7 @@ const Layout = () => {
>
{ts?.user_payout_string}
-- You may close this tab and return to submit the HIT -
+You may close this tab
> ); }; @@ -35,9 +33,7 @@ export const Enter = () => {You're currently in the Survey
-- You may close this tab and return to submit the HIT -
+You may close this tab
> ); }; @@ -50,13 +46,11 @@ export const InComplete = () => { return ( <> -Survey terminated the attempt.
-- You may close this tab and return to submit the HIT -
+You may close this tab
> ); }; @@ -68,9 +62,7 @@ export const Unknown = () => {You're not currently eligible for any Surveys
-- You may close this tab and return to submit the HIT -
+You may close this tab
> ); }; diff --git a/jb-ui/src/pages/Work.tsx b/jb-ui/src/pages/Work.tsx index dbe3601..50ed930 100644 --- a/jb-ui/src/pages/Work.tsx +++ b/jb-ui/src/pages/Work.tsx @@ -1,4 +1,5 @@ import { useGetMeQuery } from "@/models/authAPI"; +import { Link } from "react-router-dom"; import { BucketTask, OfferwallApi, @@ -183,7 +184,7 @@ const Report = ({ onClose }: { onClose: () => void }) => { hover:cursor-pointer hover:bg-rose-400 hover:text-rose-50" onClick={clicked_submit} > - Submit and Complete HIT + Submit and Complete Attempt @@ -306,7 +307,7 @@ const SurveyMonitor = () => { } // This is if they have finished a survey complete and it resulted in a - // COMPLETE or a INCOMPLETE (doesn't matter). They can now submit the HIT. + // COMPLETE or a INCOMPLETE (doesn't matter). They can now submit the Attempt. // // 2 - INCOMPLETE, 3 - COMPLETE return ( @@ -326,7 +327,7 @@ const SurveyMonitor = () => { py-2 text-zinc-500 text-md font-medium text-center" > - You may now submit the HIT. + You may now submit the attempt. )} @@ -351,7 +352,9 @@ const SurveyMonitor = () => { pt-0 pb-4 text-red-950 text-sm font-semibold text-center" > - Please return the HIT to avoid having your assignment rejected. + + Click to Refresh and Try Again + > @@ -368,7 +371,7 @@ const SurveyMonitor = () => { hover:cursor-pointer hover:bg-emerald-400 hover:text-emerald-50" onClick={() => setShowComplete(true)} > - Submit HIT + Finish Attempt