-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ActoKids/erik_feature
Erik feature In components/layout/SignedInLinks.js & SignedOutLinks I changed Log In and Log Out to Sign In and Sign Out
- Loading branch information
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import fetch from 'cross-fetch' | ||
|
||
export const REQUEST_EVENT = 'REQUEST_EVENT' | ||
export const RECEIVE_POST = 'RECEIVE_POST' | ||
export const SELECT_POST = 'SELECT_POST' | ||
|
||
export function requestEvent(event) { | ||
return { | ||
type: REQUEST_EVENT, | ||
event | ||
} | ||
} | ||
|
||
export function receiveEvent(event) { | ||
return { | ||
type: RECEIVE_EVENT, | ||
event, | ||
events: json.data.children.map(child => child.data), | ||
receivedAt: Date.now() | ||
} | ||
} | ||
|
||
export function selectEvent(event) { | ||
return { | ||
type: SELECT_EVENT, | ||
event | ||
} | ||
} | ||
|
||
function fetchEvents(event) { | ||
return dispatch => { | ||
dispatch(requestEvent(event)) | ||
return fetch('https://my.api.mockaroo.com/events.json?key=ab42ca00') | ||
.then(response => response.json()) | ||
.then(json => dispatch(receiveEvent(event, json))) | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { combineReducers } from 'redux' | ||
import { | ||
SELECT_EVENT, REQUEST_EVENT, RECEIVE_EVENT | ||
} from '../actions/actions' | ||
|
||
function selectedEvent(state = 'reactjs', action) { | ||
switch (action.type) { | ||
case SELECT_EVENT: | ||
return action.event | ||
default: | ||
return state | ||
} | ||
} | ||
|
||
function events( | ||
state = { | ||
isFetching: false, | ||
error: null, | ||
events: [] | ||
}, | ||
action | ||
) { | ||
switch (action.type) { | ||
case REQUEST_EVENT: | ||
return Object.assign({}, state, { | ||
isFetching: true, | ||
}) | ||
case RECEIVE_EVENT: | ||
return Object.assign({}, state, { | ||
isFetching: false, | ||
events: action.events | ||
}) | ||
default: | ||
return state | ||
|
||
} | ||
} |