-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Landing team section #109
Open
RamyAlshurafa
wants to merge
16
commits into
master
Choose a base branch
from
landing-team-section
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Landing team section #109
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
88fe83e
fix: move redux store to a seperated file
RamyAlshurafa fc26b22
feat: add Team section in landing page
RamyAlshurafa 1179766
feat: change Team component into statefull function
RamyAlshurafa 62cb090
chore: install redux-thunk module
RamyAlshurafa a2e96dc
chore: install axios module
RamyAlshurafa f5ea1b1
feat: add redux-thunk as middleware
RamyAlshurafa ecb097f
feat: create fech team members action and team reducer
RamyAlshurafa eda0ca9
feat: update the teams reducer
RamyAlshurafa 5d253d9
fix: add api route to fetching member data
RamyAlshurafa 0890753
feat: add prop types validation
RamyAlshurafa 4a3d726
chore: install testing packages
RamyAlshurafa d8d4979
chore: installe enzyme-adapter dependencies
RamyAlshurafa 405cc71
test: test Team section
RamyAlshurafa 4336856
style: remove commented lines
RamyAlshurafa 03a4c93
fix: undo changes on LandingPage index file
RamyAlshurafa 6688958
fix: spread the `currentTeam` object to not change the whole object
ashatat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 @@ | ||
import axios from 'axios'; | ||
import { GET_TEAM_MEMBERS } from '../constants/actionTypes'; | ||
|
||
export default teamId => dispatch => { | ||
axios.get(`/api/teams/${teamId}/members`).then(({ data }) => | ||
dispatch({ | ||
type: GET_TEAM_MEMBERS, | ||
data, | ||
}) | ||
); | ||
}; |
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,22 @@ | ||
import React from 'react'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
import { shallow, configure } from 'enzyme'; | ||
|
||
import { Provider } from 'react-redux'; | ||
import Team from './index'; | ||
import store from '../../../store'; | ||
|
||
// set enzyme Adapture configuration | ||
configure({ adapter: new Adapter() }); | ||
|
||
test('Testing for Team section', () => { | ||
const wrapper = shallow( | ||
<Provider store={store}> | ||
<Team /> | ||
</Provider> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
expect(wrapper.find(Team).length).toEqual(1); | ||
}); |
153 changes: 153 additions & 0 deletions
153
client/src/components/LandingPage/Team/__snapshots__/Team.test.js.snap
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,153 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing for Team section 1`] = ` | ||
ShallowWrapper { | ||
Symbol(enzyme.__root__): [Circular], | ||
Symbol(enzyme.__unrendered__): <Provider | ||
store={ | ||
Object { | ||
"dispatch": [Function], | ||
"getState": [Function], | ||
"replaceReducer": [Function], | ||
"subscribe": [Function], | ||
Symbol(observable): [Function], | ||
} | ||
} | ||
> | ||
<Connect(Team) /> | ||
</Provider>, | ||
Symbol(enzyme.__renderer__): Object { | ||
"batchedUpdates": [Function], | ||
"getNode": [Function], | ||
"render": [Function], | ||
"simulateError": [Function], | ||
"simulateEvent": [Function], | ||
"unmount": [Function], | ||
}, | ||
Symbol(enzyme.__node__): Object { | ||
"instance": null, | ||
"key": undefined, | ||
"nodeType": "function", | ||
"props": Object { | ||
"children": <Connect(Team) />, | ||
"value": Object { | ||
"store": Object { | ||
"dispatch": [Function], | ||
"getState": [Function], | ||
"replaceReducer": [Function], | ||
"subscribe": [Function], | ||
Symbol(observable): [Function], | ||
}, | ||
"storeState": Object { | ||
"teams": Object { | ||
"currentTeam": Object { | ||
"members": Array [], | ||
}, | ||
}, | ||
"users": Array [], | ||
}, | ||
}, | ||
}, | ||
"ref": null, | ||
"rendered": Object { | ||
"instance": null, | ||
"key": undefined, | ||
"nodeType": "class", | ||
"props": Object {}, | ||
"ref": null, | ||
"rendered": null, | ||
"type": [Function], | ||
}, | ||
"type": Object { | ||
"$$typeof": Symbol(react.provider), | ||
"_context": Object { | ||
"$$typeof": Symbol(react.context), | ||
"Consumer": Object { | ||
"$$typeof": Symbol(react.context), | ||
"_calculateChangedBits": null, | ||
"_context": [Circular], | ||
}, | ||
"Provider": [Circular], | ||
"_calculateChangedBits": null, | ||
"_currentRenderer": null, | ||
"_currentRenderer2": null, | ||
"_currentValue": null, | ||
"_currentValue2": null, | ||
"_threadCount": 0, | ||
}, | ||
}, | ||
}, | ||
Symbol(enzyme.__nodes__): Array [ | ||
Object { | ||
"instance": null, | ||
"key": undefined, | ||
"nodeType": "function", | ||
"props": Object { | ||
"children": <Connect(Team) />, | ||
"value": Object { | ||
"store": Object { | ||
"dispatch": [Function], | ||
"getState": [Function], | ||
"replaceReducer": [Function], | ||
"subscribe": [Function], | ||
Symbol(observable): [Function], | ||
}, | ||
"storeState": Object { | ||
"teams": Object { | ||
"currentTeam": Object { | ||
"members": Array [], | ||
}, | ||
}, | ||
"users": Array [], | ||
}, | ||
}, | ||
}, | ||
"ref": null, | ||
"rendered": Object { | ||
"instance": null, | ||
"key": undefined, | ||
"nodeType": "class", | ||
"props": Object {}, | ||
"ref": null, | ||
"rendered": null, | ||
"type": [Function], | ||
}, | ||
"type": Object { | ||
"$$typeof": Symbol(react.provider), | ||
"_context": Object { | ||
"$$typeof": Symbol(react.context), | ||
"Consumer": Object { | ||
"$$typeof": Symbol(react.context), | ||
"_calculateChangedBits": null, | ||
"_context": [Circular], | ||
}, | ||
"Provider": [Circular], | ||
"_calculateChangedBits": null, | ||
"_currentRenderer": null, | ||
"_currentRenderer2": null, | ||
"_currentValue": null, | ||
"_currentValue2": null, | ||
"_threadCount": 0, | ||
}, | ||
}, | ||
}, | ||
], | ||
Symbol(enzyme.__options__): Object { | ||
"adapter": ReactSixteenAdapter { | ||
"options": Object { | ||
"enableComponentDidUpdateOnSetState": true, | ||
"lifecycles": Object { | ||
"componentDidUpdate": Object { | ||
"onSetState": true, | ||
}, | ||
"getDerivedStateFromProps": true, | ||
"getSnapshotBeforeUpdate": true, | ||
"setState": Object { | ||
"skipsComponentDidUpdateOnNullish": true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
`; |
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,81 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import fetchTeamMembersAction from '../../../actions/fetch_team_members'; | ||
|
||
import TeamCard from './TeamCard'; | ||
|
||
import { | ||
TeamWrapper, | ||
Header, | ||
TeamCardsWrapper, | ||
HeaderImage, | ||
Heading, | ||
} from './StyledCompnents'; | ||
|
||
import TeamHeaderImage from './team_header.png'; | ||
|
||
class Team extends Component { | ||
state = { | ||
teamMembers: [], | ||
}; | ||
|
||
static propTypes = { | ||
fetchTeamMembers: PropTypes.func.isRequired, | ||
teamId: PropTypes.string.isRequired, | ||
teamMembers: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
githubHandler: PropTypes.string, | ||
email: PropTypes.string, | ||
role: PropTypes.string, | ||
profileImage: PropTypes.string, | ||
team: PropTypes.string, | ||
specialty: PropTypes.string, | ||
}).isRequired | ||
).isRequired, | ||
}; | ||
|
||
componentDidMount() { | ||
const { fetchTeamMembers, teamId } = this.props; | ||
fetchTeamMembers(teamId); | ||
} | ||
|
||
componentDidUpdate = prevProps => { | ||
const { teamMembers } = this.props; | ||
const { teamMembers: oldTeamMembers } = this.state; | ||
if (prevProps.teamMembers !== oldTeamMembers) { | ||
this.setState({ teamMembers }); | ||
} | ||
}; | ||
|
||
render() { | ||
const { teamMembers } = this.state; | ||
return ( | ||
<TeamWrapper> | ||
<Header> | ||
<HeaderImage src={TeamHeaderImage} /> | ||
<Heading>Who We Are</Heading> | ||
</Header> | ||
<TeamCardsWrapper> | ||
{teamMembers.map(member => ( | ||
<TeamCard | ||
key={member.id} | ||
name={member.name} | ||
profileImage={member.profileImage} | ||
specialty={member.specialty} | ||
/> | ||
))} | ||
</TeamCardsWrapper> | ||
</TeamWrapper> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = state => ({ teamMembers: state.teams.members }); | ||
const mapDispatchToProps = { fetchTeamMembers: fetchTeamMembersAction }; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(Team); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
export const GET_TEAM_MEMBERS = 'GET_TEAM_MEMBERS'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need axios? I don't know how useful it is to be honest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check this https://medium.com/@sahilkkrazy/fetch-vs-axios-http-request-c9afa43f804e. please