{"size": 1157, "ext": "js", "max_stars_repo_path": "src/redux/reducers.js", "max_stars_repo_name": "sprect8/settle", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/redux/reducers.js", "max_issues_repo_name": "sprect8/settle", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/redux/reducers.js", "max_forks_repo_name": "sprect8/settle", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.0294117647, "max_line_length": 113, "alphanum_fraction": 0.5972342264}
import types from "./actionTypes";

const initialState = {
    validating: false,
    validated: false,
    registered: false,
    context: [],
    owners: {},
};

const reducer = (state = initialState, action) => {
    console.log("Reducer", state, action);
    state.error = null;
    switch (action.type) {
        case types.USER_REGISTERED_CHECKING:
            return { ...state, validating: true, validated: false };
        case types.USER_REGISTERED:
            return {
                ...state, validating: false,
                companyName: action.payload.name,
                companyRole: action.payload.role,
                registered: action.payload.registered,
                address: action.payload.address,
                balance: action.payload.balance,
                validated: true
            };
        case types.GET_BALANCE:
            return { ...state, balanceRetrieved: false, balanceRetrieving: true, balanceLoaded: null };
        case types.BALANCE_RETRIEVED:
            return { ...state, balanceRetrieved: true, balanceRetrieving: false, balanceLoaded: action.payload };
    }
};

export { reducer, initialState };