aboutsummaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/appSlice.ts2
-rw-r--r--src/models/bucketSlice.ts4
-rw-r--r--src/models/cashoutMethodSlice.ts8
-rw-r--r--src/models/questionSlice.ts16
-rw-r--r--src/models/transactionHistorySlice.ts2
-rw-r--r--src/models/upkQuestionSlice.ts9
6 files changed, 20 insertions, 21 deletions
diff --git a/src/models/appSlice.ts b/src/models/appSlice.ts
index b8c41c6..f2e2535 100644
--- a/src/models/appSlice.ts
+++ b/src/models/appSlice.ts
@@ -2,7 +2,7 @@ import {createSlice, PayloadAction} from '@reduxjs/toolkit'
import {App, Page} from "@/models/app.ts"
-const initialState = {}
+const initialState: App = {} as App
const appSlice = createSlice({
name: 'app',
diff --git a/src/models/bucketSlice.ts b/src/models/bucketSlice.ts
index 1a15263..995c14a 100644
--- a/src/models/bucketSlice.ts
+++ b/src/models/bucketSlice.ts
@@ -21,9 +21,5 @@ const bucketSlice = createSlice({
export const {setBuckets, bucketAdded} = bucketSlice.actions;
export default bucketSlice.reducer
-export const selectBucketsStatus = (state: RootState) => state.buckets.status
-export const selectBucketsError = (state: RootState) => state.buckets.error
-export const selectAllBuckets = (state: RootState) => state.buckets
-
export const selectBucketById = (state: RootState, bucketId: string | null) =>
state.buckets.find(bucket => bucket.id === bucketId) \ No newline at end of file
diff --git a/src/models/cashoutMethodSlice.ts b/src/models/cashoutMethodSlice.ts
index a6d0211..8e3a957 100644
--- a/src/models/cashoutMethodSlice.ts
+++ b/src/models/cashoutMethodSlice.ts
@@ -12,7 +12,7 @@ const cashoutMethodSlice = createSlice({
setCashoutMethods(state, action: PayloadAction<CashoutMethodOut[]>) {
return action.payload;
},
- redeem: {
+ // redeemMethod: {
// let res = {'status': false, 'msg': ''};
// let cashout_method = this.collection.getCashoutMethod();
// let req_amt = +this.ui.amount.val();
@@ -61,7 +61,7 @@ const cashoutMethodSlice = createSlice({
// res["status"] = true;
// return res;
// },
- }
+ // }
}
})
@@ -73,6 +73,8 @@ export default cashoutMethodSlice.reducer
export const selectCashoutMethods = (state: RootState) => state.cashoutMethods
export const selectFixedCashoutMethods = (state: RootState) =>
+ // @ts-ignore
state.cashoutMethods.filter(cm => cm.data.value_type === "fixed")
export const selectVariableCashoutMethods = (state: RootState) =>
- state.cashoutMethods.filter(cm => cm.data.value_type === "variable")
+ // @ts-ignore
+ state.cashoutMethods.filter(cm => cm.data.value_type === "variable") \ No newline at end of file
diff --git a/src/models/questionSlice.ts b/src/models/questionSlice.ts
index 3ef2218..9cba93e 100644
--- a/src/models/questionSlice.ts
+++ b/src/models/questionSlice.ts
@@ -6,7 +6,7 @@ import {assert} from "@/lib/utils.ts"
import {Selector} from "react-redux";
export interface ProfileQuestion extends UpkQuestion {
- active: false
+ active: boolean
}
const initialState: ProfileQuestion[] = []
@@ -20,7 +20,11 @@ const questionSlice = createSlice({
// },
setQuestions(state, action: PayloadAction<ProfileQuestion[]>) {
const existingIds = new Set(state.map(q => q.question_id));
- const newQuestions = action.payload.filter(q => !existingIds.has(q.question_id));
+ const newQuestions = action.payload.filter(q => !existingIds.has(q.question_id)).map((q) => ({
+ ...q,
+ active: false,
+ }));
+
state.push(...newQuestions);
},
questionAdded(state, action: PayloadAction<ProfileQuestion>) {
@@ -72,9 +76,9 @@ export const makeSelectQuestionsByIds = (ids: string[]) =>
export const selectActiveQuestion = (state: RootState) => state.questions.find(i => i.active)
export const selectAnswers = (state: RootState) => state.answers
-export const selectFirstAvailableQuestion = createSelector(
+export const selectFirstAvailableQuestion: Selector<RootState, ProfileQuestion | null> = createSelector(
[selectQuestions, selectAnswers],
- (questions, answers): Selector<RootState, ProfileQuestion | null> => {
+ (questions, answers) => {
/* This is used when the app loads up the Questions page and we
need to find the first Question that we'll present to
the Respondent.
@@ -99,9 +103,9 @@ export const selectFirstAvailableQuestion = createSelector(
}
)
-export const selectNextAvailableQuestion = createSelector(
+export const selectNextAvailableQuestion: Selector<RootState, ProfileQuestion | null> = createSelector(
[selectQuestions, selectAnswers],
- (questions, answers): Selector<RootState, ProfileQuestion | null> => {
+ (questions, answers) => {
/* This takes the current active position and finds the next available
question to answer.
diff --git a/src/models/transactionHistorySlice.ts b/src/models/transactionHistorySlice.ts
index 71bbf0d..9d6a9a0 100644
--- a/src/models/transactionHistorySlice.ts
+++ b/src/models/transactionHistorySlice.ts
@@ -18,7 +18,7 @@ const transactionHistorySlice = createSlice({
}
})
-export const {setBuckets, bucketAdded} = transactionHistorySlice.actions;
+export const {setBuckets, transactionAdded} = transactionHistorySlice.actions;
export default transactionHistorySlice.reducer
export const selectTransactionHistory = (state: RootState) => state.transactionHistory
diff --git a/src/models/upkQuestionSlice.ts b/src/models/upkQuestionSlice.ts
index b99f508..79bef09 100644
--- a/src/models/upkQuestionSlice.ts
+++ b/src/models/upkQuestionSlice.ts
@@ -10,7 +10,8 @@ const upkQuestionSlice = createSlice({
initialState,
reducers: {
setUpkQuestions(state, action: PayloadAction<QuestionInfo[]>) {
- const existingIds = new Set(state.map(q => q.question_id));
+ console.log("setUpkQuestions:", state)
+ const existingIds = new Set(state.map(q => q.property_id));
const newQuestions = action.payload.filter(q => !existingIds.has(q.property_id));
state.push(...newQuestions);
},
@@ -20,8 +21,4 @@ const upkQuestionSlice = createSlice({
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
+export default upkQuestionSlice.reducer \ No newline at end of file