39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { DashboardResponce } from '@interfaces';
|
|
import { createReducer, createSlice } from '@reduxjs/toolkit';
|
|
import { getDashboard } from './thunk';
|
|
|
|
export interface OnBoardingCompleteState {
|
|
dashboardResponce: DashboardResponce | null;
|
|
isKycApproved: boolean | null;
|
|
isLoading: boolean;
|
|
error: string | null;
|
|
}
|
|
|
|
const initialState: OnBoardingCompleteState = {
|
|
dashboardResponce: null,
|
|
isKycApproved: null,
|
|
isLoading: false,
|
|
error: null,
|
|
};
|
|
|
|
export const onBoardingCompleteReducer = createReducer(
|
|
initialState,
|
|
builder => {
|
|
builder
|
|
.addCase(getDashboard.pending, state => {
|
|
state.isLoading = true;
|
|
state.error = null;
|
|
})
|
|
.addCase(getDashboard.fulfilled, (state, action) => {
|
|
state.isLoading = false;
|
|
state.isKycApproved = true;
|
|
state.dashboardResponce = action.payload;
|
|
})
|
|
.addCase(getDashboard.rejected, (state, action) => {
|
|
state.isLoading = false;
|
|
state.isKycApproved = false;
|
|
state.error = (action.payload as string) || 'Failed to get dashboard';
|
|
});
|
|
},
|
|
);
|