Skip to content

Commit

Permalink
built action creator and reducer for header and update header type
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxnelson997 committed Jun 16, 2018
1 parent f245ce8 commit baf8c93
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/actions/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { UPDATE_HEADER } from './types';

export function updateHeader(title, subtitle, hideBar) {
return {
type: UPDATE_HEADER,
payload: {title, subtitle, hideBar}
}
}
7 changes: 6 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {
changeStatus
} from './requests';

import {
updateHeader
} from './header';

export {
signUp,
signIn,
Expand All @@ -27,5 +31,6 @@ export {
fetchRequests,
changeStatus,
createNewNewsletter,
editNewsletter
editNewsletter,
updateHeader
};
5 changes: 4 additions & 1 deletion src/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export const FETCH_NEWSLETTER_ID = 'FETCH_NEWSLETTER_ID';

// REQUESTS ACTIONS
export const CHANGE_SELECTED_REQUEST_TYPE = 'CHANGE_SELECTED_REQUEST_TYPE';
export const SET_REQUESTS = 'SET_REQUESTS';
export const SET_REQUESTS = 'SET_REQUESTS';

// HEADER
export const UPDATE_HEADER = 'UPDATE_HEADER';
25 changes: 25 additions & 0 deletions src/reducers/headerReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { UPDATE_HEADER } from '../actions/types';

const INITIAL_STATE = {
title: '',
subtitle: '',
hideBar: false
}

export default function(state = INITIAL_STATE, action) {
switch (key) {
case UPDATE_HEADER:
const { title, subtitle, hideBar } = action.payload;
return {
...state,
title,
subtitle,
hideBar
}
// return {
// ...state,
// ...action.payload
// }
default: return state;
}
}

0 comments on commit baf8c93

Please sign in to comment.