diff options
| author | Max Nanis | 2026-09-13 10:41:49 -0700 |
|---|---|---|
| committer | Max Nanis | 2026-09-13 10:41:49 -0700 |
| commit | 83821dff9984fb950e53f23baf99d7a74fb88abd (patch) | |
| tree | dc1246129c546e5519480db2e0500a01cd0f866f /jb-ui/src/models/cashoutMethodsSlice.ts | |
| parent | b2261f9101480afb31322cf620f028cdade0671c (diff) | |
| download | amt-jb-83821dff9984fb950e53f23baf99d7a74fb88abd.tar.gz amt-jb-83821dff9984fb950e53f23baf99d7a74fb88abd.zip | |
refrences to HIT removed. Still can't test. Basic CashoutMethod retrival until backup updated. use of the new Wallets endpoint.
Diffstat (limited to 'jb-ui/src/models/cashoutMethodsSlice.ts')
| -rw-r--r-- | jb-ui/src/models/cashoutMethodsSlice.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/jb-ui/src/models/cashoutMethodsSlice.ts b/jb-ui/src/models/cashoutMethodsSlice.ts new file mode 100644 index 0000000..92c03da --- /dev/null +++ b/jb-ui/src/models/cashoutMethodsSlice.ts @@ -0,0 +1,37 @@ +import { CashoutMethodOut } from "@/api_fsb"; +import type { RootState } from "@/store"; +import { createSlice, createEntityAdapter } from "@reduxjs/toolkit"; + +// Entity adapter for normalized storage +const cashoutMethodsAdapter = createEntityAdapter({ + selectId: (model: CashoutMethodOut) => model.id!, + sortComparer: (a, b) => { + return (b.min_value ?? 0) - (a.min_value ?? 0); + }, +}); + +const cashoutMethodsSlice = createSlice({ + name: "cashoutMethods", + initialState: cashoutMethodsAdapter.getInitialState(), + + reducers: { + addCashoutMethod: cashoutMethodsAdapter.addOne, + addCashoutMethods: cashoutMethodsAdapter.addMany, + upsertCashoutMethod: cashoutMethodsAdapter.upsertOne, // Add or Update + }, +}); + +export const { addCashoutMethod, addCashoutMethods, upsertCashoutMethod } = + cashoutMethodsSlice.actions; + +export const cashoutMethodsSelectors = cashoutMethodsAdapter.getSelectors( + (state: RootState) => state.cashoutMethods, +); + +export const selectAllCashoutMethods = ( + state: RootState, +): CashoutMethodOut[] => { + return cashoutMethodsSelectors.selectAll(state) ?? []; +}; + +export default cashoutMethodsSlice.reducer; |
