import { WalletTransaction } from '@interfaces'; import { createReducer } from '@reduxjs/toolkit'; import { getAllWalletTransactions } from './thunk'; export interface walletState { walletTransactions: WalletTransaction[]; loading: boolean; error: string | null; } const initialState: walletState = { walletTransactions: [], loading: false, error: null, }; export const walletReducer = createReducer(initialState, builder => { builder.addCase(getAllWalletTransactions.pending, state => { state.loading = true; state.error = null; }); builder.addCase(getAllWalletTransactions.fulfilled, (state, action) => { state.loading = false; state.walletTransactions = action.payload; }); builder.addCase(getAllWalletTransactions.rejected, (state, action) => { state.loading = false; state.error = action.payload as string | null; }); });