{"size": 1405, "ext": "js", "max_stars_repo_path": "client/src/modules/admin.js", "max_stars_repo_name": "tes/kubernaut", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/modules/admin.js", "max_issues_repo_name": "tes/kubernaut", "max_issues_repo_issues_event_min_datetime": "2021-05-13T16:48:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-16T07:15:22.000Z", "max_forks_repo_path": "client/src/modules/admin.js", "max_forks_repo_name": "tes/kubernaut", "max_forks_repo_forks_event_min_datetime": "2021-03-09T14:59:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T17:07:41.000Z"}
{"max_stars_count": null, "max_issues_count": 10, "max_forks_count": 3, "avg_line_length": 23.0327868852, "max_line_length": 92, "alphanum_fraction": 0.6007117438}
import { createAction, handleActions } from 'redux-actions';

const actionsPrefix = 'KUBERNAUT/ADMIN';
export const initAdminPage = createAction(`${actionsPrefix}/INIT`);

export const fetchReleases = createAction(`${actionsPrefix}/FETCH_RELEASES`);
export const FETCH_SUMMARY_REQUEST = createAction(`${actionsPrefix}/FETCH_SUMMARY_REQUEST`);
export const FETCH_SUMMARY_SUCCESS = createAction(`${actionsPrefix}/FETCH_SUMMARY_SUCCESS`);
export const FETCH_SUMMARY_ERROR = createAction(`${actionsPrefix}/FETCH_SUMMARY_ERROR`);

const defaultState = {
  summary: {
    data: {
      accounts: 0,
      clusters: 0,
      deployments: 0,
      jobs: 0,
      namespaces: 0,
      registries: 0,
      releases: 0,
      services: 0,
      teams: 0,
    },
    meta: {
      loading: false,
    },
  },
};

export default handleActions({
  [FETCH_SUMMARY_REQUEST]: (state) => ({
    ...state,
    summary: {
      ...state.summary,
      data: defaultState.summary.data,
      meta: {
        loading: true,
      }
    },
  }),
  [FETCH_SUMMARY_SUCCESS]: (state, { payload }) => ({
    ...state,
    summary: {
      ...state.summary,
      data: payload.data,
      meta: {
        loading: false,
      }
    },
  }),
  [FETCH_SUMMARY_ERROR]: (state, { payload }) => ({
    ...state,
    summary: {
      ...state.summary,
      meta: {
        error: payload.error,
      },
    },
  }),
}, defaultState);
