{"size": 782, "ext": "js", "max_stars_repo_path": "src/reducers/weatherReducer.js", "max_stars_repo_name": "yingray/logo-man", "max_stars_repo_stars_event_min_datetime": "2016-10-21T10:31:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-13T19:46:28.000Z", "max_issues_repo_path": "src/reducers/weatherReducer.js", "max_issues_repo_name": "yingray/logo-man", "max_issues_repo_issues_event_min_datetime": "2017-05-08T08:28:19.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-24T09:32:48.000Z", "max_forks_repo_path": "src/reducers/weatherReducer.js", "max_forks_repo_name": "yingray/logo-man", "max_forks_repo_forks_event_min_datetime": "2016-12-29T08:27:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-01T10:19:24.000Z"}
{"max_stars_count": 51, "max_issues_count": 2, "max_forks_count": 19, "avg_line_length": 23.696969697, "max_line_length": 76, "alphanum_fraction": 0.6368286445}
const initialState = {
  loading: false,
  city: 'Initial',
  date: 'Initial',
  temp: 'Initial',
  text: 'Initial'
}

const weatherReducer = (state = initialState, action) => {
  switch (action.type) {
    case 'WEATHER_SHOW_LOADING':
      return Object.assign({}, state, {
        loading: true
      })

    case 'WEATHER_SHOW_WEATHER':
      const location = action.response.query.results.channel.location
      const condition = action.response.query.results.channel.item.condition
      return Object.assign({}, state, {
        loading: false,
        city: location.city,
        date: condition.date,
        temp: condition.temp,
        text: condition.text
      })

    default:
      return Object.assign({}, state, initialState)
  }
}

export default weatherReducer
