Skip to content

Commit

Permalink
feat: create fech team members action and team reducer
Browse files Browse the repository at this point in the history
Relates #43
  • Loading branch information
RamyAlshurafa committed Dec 31, 2018
1 parent f5ea1b1 commit ecb097f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
11 changes: 11 additions & 0 deletions client/src/actions/fetch_team_members.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import axios from 'axios';
import { GET_TEAM_MEMBERS } from '../constants/actionTypes';

export default teamId => dispatch => {
axios.get(`/teams/${teamId}/members`).then(({ data }) =>
dispatch({
type: GET_TEAM_MEMBERS,
data,
})
);
};
43 changes: 32 additions & 11 deletions client/src/components/LandingPage/Team/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import React, { Component } from 'react';
import { connect } from 'react-redux';

import fetchTeamMembers from '../../../actions/fetch_team_members';

import TeamCard from './TeamCard';
import TeamHeaderImage from './team_header.png';

import {
TeamWrapper,
Header,
Expand All @@ -10,12 +13,30 @@ import {
Heading,
} from './StyledCompnents';

export default () => (
<TeamWrapper>
<Header>
<HeaderImage src={TeamHeaderImage} />
<Heading>Who We Are</Heading>
</Header>
<TeamCardsWrapper />
</TeamWrapper>
);
import TeamHeaderImage from './team_header.png';

class Team extends Component {
componentDidMount() {
this.props.fetchTeamMembers(111);
}

render() {
return (
<TeamWrapper>
<Header>
<HeaderImage src={TeamHeaderImage} />
<Heading>Who We Are</Heading>
</Header>
<TeamCardsWrapper />
</TeamWrapper>
);
}
}

const mapStateToProps = state => ({ teamMembers: state.team.members });
const mapDispatchToProps = { fetchTeamMembers };

export default connect(
mapStateToProps,
mapDispatchToProps
)(Team);
1 change: 1 addition & 0 deletions client/src/constants/actionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const GET_TEAM_MEMBERS = 'GET_TEAM_MEMBERS';
2 changes: 2 additions & 0 deletions client/src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { combineReducers } from 'redux';

import userReducer from './users';
import teamReducer from './teams';

const appReducer = combineReducers({
users: userReducer,
team: teamReducer,
});

export default appReducer;
10 changes: 10 additions & 0 deletions client/src/reducers/teams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { GET_TEAM_MEMBERS } from '../constants/actionTypes';

const initialState = {
members: [],
};

const teamsReducer = (state = initialState, action) => {
return state;
};
export default teamsReducer;

0 comments on commit ecb097f

Please sign in to comment.