diff options
| author | Max Nanis | 2025-06-09 16:05:52 +0700 |
|---|---|---|
| committer | Max Nanis | 2025-06-09 16:05:52 +0700 |
| commit | 74890e251dee3e0f195583431cb48b9f3a58ecc9 (patch) | |
| tree | a27ceee03999f18fd3ef2e0d44ba7deb39f0b6c8 /src/models | |
| parent | a674d2e03de3bd048714d9c06e4bba9d9ecdb328 (diff) | |
| download | panel-ui-74890e251dee3e0f195583431cb48b9f3a58ecc9.tar.gz panel-ui-74890e251dee3e0f195583431cb48b9f3a58ecc9.zip | |
Cashout Methods page: adding walletSlice and cashoutmethodsSlice so they're in the stored state. Iterating with fix vs variable filters. Pulling old validators from old code and setting up the wallet fetch.
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/app.ts | 2 | ||||
| -rw-r--r-- | src/models/cashoutMethodSlice.ts | 78 | ||||
| -rw-r--r-- | src/models/walletSlice.ts | 23 |
3 files changed, 102 insertions, 1 deletions
diff --git a/src/models/app.ts b/src/models/app.ts index 62da7bb..25b2412 100644 --- a/src/models/app.ts +++ b/src/models/app.ts @@ -1,4 +1,4 @@ -export type Page = 'offerwall' | 'questions' | 'cashouts'; +export type Page = 'offerwall' | 'questions' | 'cashout_methods'; export interface App { targetId: string, diff --git a/src/models/cashoutMethodSlice.ts b/src/models/cashoutMethodSlice.ts new file mode 100644 index 0000000..a6d0211 --- /dev/null +++ b/src/models/cashoutMethodSlice.ts @@ -0,0 +1,78 @@ +import {createSlice, PayloadAction} from '@reduxjs/toolkit' +import type {RootState} from '@/store' +import {CashoutMethodOut} from "@/api"; + + +const initialState: CashoutMethodOut[] = [] + +const cashoutMethodSlice = createSlice({ + name: 'cashoutMethods', + initialState, + reducers: { + setCashoutMethods(state, action: PayloadAction<CashoutMethodOut[]>) { + return action.payload; + }, + redeem: { + // let res = {'status': false, 'msg': ''}; + // let cashout_method = this.collection.getCashoutMethod(); + // let req_amt = +this.ui.amount.val(); + // + // // Generic checks + // if (!cashout_method) { + // res['msg'] = "Cashout method not selected"; + // return res + // } + // + // if (isNaN(req_amt)) { + // res['msg'] = "Invalid amount (numbers only)"; + // return res; + // } + // + // if (!this.WALLET) { + // res['msg'] = "Unknown wallet balance"; + // return res + // } + // + // let balance: number = this.WALLET.get("redeemable_amount"); + // + // // Limit checks + // if (balance < cashout_method.get("min_value")) { + // res["msg"] = "Wallet balance not large enough"; + // return res; + // } + // + // let req_amount = this.getIntCentsValue() + // + // if (req_amount < cashout_method.get("min_value")) { + // res["msg"] = "Requested amount not large enough"; + // return res; + // } + // + // if (req_amount > cashout_method.get("max_value")) { + // res["msg"] = "Amount too large for payout method"; + // return res; + // } + // + // if (req_amount > balance) { + // res["msg"] = "Amount is more than wallet balance"; + // return res; + // } + // + // res["status"] = true; + // return res; + // }, + } + } +}) + +export const { + setCashoutMethods, +} = cashoutMethodSlice.actions; +export default cashoutMethodSlice.reducer + +export const selectCashoutMethods = (state: RootState) => state.cashoutMethods + +export const selectFixedCashoutMethods = (state: RootState) => + state.cashoutMethods.filter(cm => cm.data.value_type === "fixed") +export const selectVariableCashoutMethods = (state: RootState) => + state.cashoutMethods.filter(cm => cm.data.value_type === "variable") diff --git a/src/models/walletSlice.ts b/src/models/walletSlice.ts new file mode 100644 index 0000000..83eda62 --- /dev/null +++ b/src/models/walletSlice.ts @@ -0,0 +1,23 @@ +import {createSlice, PayloadAction} from '@reduxjs/toolkit' + +import {UserWalletBalance} from "@/api"; + + +const initialState: UserWalletBalance = {}; + + +const walletSlice = createSlice({ + name: 'wallet', + initialState, + reducers: { + setWallet(state, action: PayloadAction<UserWalletBalance>) { + return action.payload; + } + } +}) + +export const { + setWallet, +} = walletSlice.actions; +export default walletSlice.reducer + |
