-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ProjectList class to function component (#992)
- Loading branch information
Showing
1 changed file
with
18 additions
and
31 deletions.
There are no files selected for viewing
49 changes: 18 additions & 31 deletions
49
app/assets/javascripts/components/projects/ProjectList.jsx
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 |
---|---|---|
@@ -1,40 +1,27 @@ | ||
import React, { Fragment } from 'react'; | ||
import React from 'react'; | ||
import ProjectCard from 'components/projects/ProjectCard'; | ||
|
||
export default class ProjectList extends React.Component { | ||
cards() { | ||
const { user, projects, joined } = this.props; | ||
|
||
return projects.map(project => { | ||
return ( | ||
const ProjectList = ({ user, projects, joined, title }) => { | ||
return ( | ||
<> | ||
<div className="col-md-12 project-list-title"> | ||
<h4> | ||
<i className="mi md-20 heading-icon" data-testid="view-module-title"> | ||
view_module | ||
</i>{' '} | ||
{title} | {projects.length} | ||
</h4> | ||
</div> | ||
{projects.map(project => ( | ||
<ProjectCard | ||
key={project.get('slug')} | ||
project={project} | ||
user={user} | ||
joined={joined} | ||
/> | ||
); | ||
}); | ||
} | ||
|
||
render() { | ||
const { projects, title } = this.props; | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
return ( | ||
<Fragment> | ||
<div className="col-md-12 project-list-title"> | ||
<h4> | ||
<i | ||
className="mi md-20 heading-icon" | ||
data-testid="view-module-title" | ||
> | ||
view_module | ||
</i>{' '} | ||
{title} | {projects.length} | ||
</h4> | ||
</div> | ||
{this.cards()} | ||
</Fragment> | ||
); | ||
} | ||
} | ||
export default ProjectList; |