/**
 * @Project iLinkWorld
 * @File PasswordValidationReducer.js
 * @Path redux/reducers
 * @Author BRICE ZELE
 * @Date 21/04/2022
 */
import * as WalletType from "../types/WalletType";

const initialState = {
    loading: false,
    result: null,
    error: null
};

export default (state = initialState, action) => {
    switch (action.type) {
        case WalletType.PASSWORD_VALIDATION_PENDING:
            return {
                ...state,
                loading: true
            }
        case WalletType.PASSWORD_VALIDATION_SUCCESS:
            return {
                ...state,
                loading: false,
                result: action.result.data,
                error: null
            }
        case WalletType.PASSWORD_VALIDATION_ERROR:
            return {
                ...state,
                loading: false,
                result: null,
                error: action.result.data.error
            }
        case WalletType.PASSWORD_VALIDATION_RESET:
            return initialState;

        default: {
            return state;
        }
    }
};