aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Widget.tsx15
-rw-r--r--src/models/marketplaceAnswerSlice.ts24
-rw-r--r--src/models/upkAnswerSlice.ts23
-rw-r--r--src/models/upkQuestionSlice.ts27
-rw-r--r--src/models/walletSlice.ts2
-rw-r--r--src/pages/CashoutMethods.tsx10
-rw-r--r--src/store.ts7
7 files changed, 106 insertions, 2 deletions
diff --git a/src/Widget.tsx b/src/Widget.tsx
index f355194..dc24bea 100644
--- a/src/Widget.tsx
+++ b/src/Widget.tsx
@@ -6,12 +6,13 @@ import {Offerwall} from "@/pages/Offerwall.tsx"
import {QuestionsPage} from "@/pages/Questions.tsx";
import {useAppDispatch, useAppSelector} from "@/hooks.ts";
-import {CashoutMethodOut, OfferwallApi, ProfilingQuestionsApi, UserWalletBalance, WalletApi} from "@/api";
+import {CashoutMethodOut, OfferwallApi, ProfilingQuestionsApi, QuestionInfo, UserWalletBalance, WalletApi} from "@/api";
import {ProfileQuestion, setQuestions} from "@/models/questionSlice.ts";
import {setBuckets} from "@/models/bucketSlice.ts";
import {setCashoutMethods} from "@/models/cashoutMethodSlice.ts";
import {setWallet} from "@/models/walletSlice.ts"
import {CashoutMethodsPage} from "@/pages/CashoutMethods.tsx";
+import {setUpkQuestions} from "@/models/upkQuestionSlice.ts"
import {setAvailabilityCount, setOfferwallId} from "@/models/appSlice.ts"
import './index.css';
@@ -43,6 +44,18 @@ const Widget = () => {
})
.catch(err => console.log(err));
+ new ProfilingQuestionsApi().userProfileProductIdUserProfileGet(app.bpid, app.bpuid, "us")
+ .then(res => {
+ console.log("Marketplace Profile", res.data["user-profile"].marketplace_profile_knowledge)
+ console.log("UPK Profile", res.data["user-profile"].user_profile_knowledge)
+ }).catch(err => console.log(err))
+
+ new ProfilingQuestionsApi().profilingInfoProductIdProfilingInfoGet(app.bpid, "us")
+ .then(res => {
+ dispatch(setUpkQuestions(res.data["profiling-info"] as QuestionInfo[]))
+ })
+ .catch(err => console.log(err))
+
new WalletApi().getCashoutMethodsProductIdCashoutMethodsGet(app.bpid, app.bpuid)
.then(res => {
dispatch(setCashoutMethods(res.data.cashout_methods as CashoutMethodOut[]))
diff --git a/src/models/marketplaceAnswerSlice.ts b/src/models/marketplaceAnswerSlice.ts
new file mode 100644
index 0000000..a1db7f0
--- /dev/null
+++ b/src/models/marketplaceAnswerSlice.ts
@@ -0,0 +1,24 @@
+import {createSlice, PayloadAction} from "@reduxjs/toolkit";
+import {MarketProfileKnowledge} from "@/api";
+
+const marketplaceInitialState: MarketProfileKnowledge[] = []
+
+
+const marketplaceAnswerSlice = createSlice({
+ name: 'marketplaceAnswers',
+ marketplaceInitialState,
+ reducers: {
+ setMarketplaceAnswers(state, action: PayloadAction<MarketProfileKnowledge[]>) {
+ // TODO: Does this need question_id + source uniqueness?
+ const existingIds = new Set(state.map(q => q.question_id));
+ const newQuestions = action.payload.filter(q => !existingIds.has(q.question_id));
+ state.push(...newQuestions);
+ }
+ }
+})
+
+export const {
+ setMarketplaceAnswers,
+} = marketplaceAnswerSlice.actions;
+
+export default marketplaceAnswerSlice.reducer;
diff --git a/src/models/upkAnswerSlice.ts b/src/models/upkAnswerSlice.ts
new file mode 100644
index 0000000..7bd57f1
--- /dev/null
+++ b/src/models/upkAnswerSlice.ts
@@ -0,0 +1,23 @@
+import {createSlice, PayloadAction} from '@reduxjs/toolkit'
+import {UserProfileKnowledge} from "@/api";
+
+const upkInitialState: UserProfileKnowledge[] = []
+
+const upkAnswerSlice = createSlice({
+ name: 'upkAnswers',
+ upkInitialState,
+ reducers: {
+ setUpkAnswers(state, action: PayloadAction<UserProfileKnowledge[]>) {
+ const existingIds = new Set(state.map(q => q.property_id));
+ const newQuestions = action.payload.filter(q => !existingIds.has(q.property_id));
+ state.push(...newQuestions);
+ }
+ }
+})
+
+
+export const {
+ setUpkAnswers,
+} = upkAnswerSlice.actions;
+
+export default upkAnswerSlice.reducer; \ No newline at end of file
diff --git a/src/models/upkQuestionSlice.ts b/src/models/upkQuestionSlice.ts
new file mode 100644
index 0000000..b99f508
--- /dev/null
+++ b/src/models/upkQuestionSlice.ts
@@ -0,0 +1,27 @@
+import {createSlice, PayloadAction} from '@reduxjs/toolkit'
+import type {RootState} from '@/store'
+import {QuestionInfo} from "@/api";
+
+
+const initialState: QuestionInfo[] = []
+
+const upkQuestionSlice = createSlice({
+ name: 'upkQuestions',
+ initialState,
+ reducers: {
+ setUpkQuestions(state, action: PayloadAction<QuestionInfo[]>) {
+ const existingIds = new Set(state.map(q => q.question_id));
+ const newQuestions = action.payload.filter(q => !existingIds.has(q.property_id));
+ state.push(...newQuestions);
+ },
+ }
+})
+
+export const {
+ setUpkQuestions,
+} = upkQuestionSlice.actions;
+export default upkQuestionSlice.reducer
+
+// We need to fetch the next available Question that either doesn't have an Answer, or the Answer
+// isn't Answer.completed
+export const selectUpkQuestions = (state: RootState) => state.questions \ No newline at end of file
diff --git a/src/models/walletSlice.ts b/src/models/walletSlice.ts
index 83eda62..9a2dd0c 100644
--- a/src/models/walletSlice.ts
+++ b/src/models/walletSlice.ts
@@ -3,7 +3,7 @@ import {createSlice, PayloadAction} from '@reduxjs/toolkit'
import {UserWalletBalance} from "@/api";
-const initialState: UserWalletBalance = {};
+const initialState: UserWalletBalance = {} as UserWalletBalance;
const walletSlice = createSlice({
diff --git a/src/pages/CashoutMethods.tsx b/src/pages/CashoutMethods.tsx
index fca6af0..9cb0f20 100644
--- a/src/pages/CashoutMethods.tsx
+++ b/src/pages/CashoutMethods.tsx
@@ -3,6 +3,7 @@ import {Card, CardContent, CardHeader,} from "@/components/ui/card"
import {Tabs, TabsContent, TabsList, TabsTrigger,} from "@/components/ui/tabs"
import {Badge} from "@/components/ui/badge"
+import { Input } from "@/components/ui/input"
import {selectFixedCashoutMethods, selectVariableCashoutMethods} from "@/models/cashoutMethodSlice.ts";
import {CashoutMethodOut, UserWalletBalance} from "@/api"
import {formatCentsToUSD} from "@/lib/utils.ts";
@@ -47,6 +48,15 @@ const CashoutReview: React.FC<{ cashout_method: CashoutMethodOut }> = ({cashout_
)
}
+const CreateCashout = () => {
+
+ return (
+ <>
+ <Input type="email" placeholder="Email" />
+ </>
+ )
+}
+
const VariableCashoutMethodPreview: React.FC<{ cashout_method: CashoutMethodOut }> = ({cashout_method}) => {
return (
<>
diff --git a/src/store.ts b/src/store.ts
index cfa64ec..9600704 100644
--- a/src/store.ts
+++ b/src/store.ts
@@ -6,6 +6,9 @@ import appReducers from "@/models/appSlice.ts"
import answerReducers from "@/models/answerSlice.ts"
import cashoutMethodReducers from "@/models/cashoutMethodSlice.ts"
import walletReducers from "@/models/walletSlice.ts"
+import upkQuestionReducers from "@/models/upkQuestionSlice"
+import upkAnswerReducers from "@/models/upkAnswerSlice"
+import marketplaceReducers from "@/models/marketplaceAnswerSlice"
export const store = configureStore({
reducer: {
@@ -14,7 +17,11 @@ export const store = configureStore({
// - Read Only
// -- These act as API cache stores to allow background loading
buckets: bucketReducers,
+
questions: questionReducers,
+ upkQuestions: upkQuestionReducers,
+ upkAnswers: upkAnswerReducers,
+ marketplaceAnswers: marketplaceReducers,
// - Read Write
// -- This stores user engagement (eg: answering any questions)