// Initial state
const initialState = {
  role: null,
};

// Action types
const SET_USER_ROLE = 'userRole/SET_USER_ROLE';

// Action creators
export const setUserRole = (role) => ({
  type: SET_USER_ROLE,
  payload: role,
});

// Selector to get user role
export const selectUserRole = (state) => state.userRole.role;

// Reducer
export default function userRoleReducer(state = initialState, action) {
  switch (action.type) {
    case SET_USER_ROLE:
      return {
        ...state,
        role: action.payload,
      };
    default:
      return state;
  }
}
