Skip to content

Commit f155e9b

Browse files
author
David Silva
committed
created a submission list component
1 parent 951e507 commit f155e9b

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/components/submit/list.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { SubmitType } from '../../types';
4+
import { Link } from 'react-router-dom';
5+
import Moment from '../misc/moment';
6+
7+
class SubmitList extends Component {
8+
static propTypes = {
9+
submits: PropTypes.arrayOf(SubmitType),
10+
}
11+
12+
render() {
13+
const { submits } = this.props;
14+
15+
return(
16+
<div>
17+
{submits.map((s) => (
18+
s && s.attributes &&
19+
<div key={ s.id }>
20+
<p>Submission for: <strong> {s.attributes.challenge.number }&nbsp;</strong>
21+
<Link to={`/challenge/${s.attributes.challenge.number}/${ s.attributes.challenge.title }`}>{ s.attributes.challenge.title } </Link>
22+
</p>
23+
<p><strong>Description:</strong> { s.attributes.description }</p>
24+
<p>Submitted: <Moment date={ s.attributes.createdAt } /></p>
25+
<p>
26+
<Link to={`/submit/${ s.id }`} className="btn btn-primary">View Details</Link>
27+
</p>
28+
</div>
29+
))}
30+
</div>
31+
);
32+
}
33+
}
34+
35+
export default SubmitList;

src/containers/submit/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class ChallengeContainer extends Component {
2626
render() {
2727
const { challenge, submission, user } = this.props;
2828
return (
29-
<div>
29+
<div style={{ margin: '30px auto' }} >
3030
{submission && challenge && <Helmet>
3131
<title>{ `codecorgi | submission for: ${ challenge.title }` }</title>
3232
<meta property="og:title" content={ `codecorgi | submission for: ${ challenge.title }` } />
3333
<meta property="og:url" content={ `${PROD_URL}/${ challenge.url }` } />
3434
<meta name="twitter:title" content={ `codecorgi | submission for: ${ challenge.title }` } />
3535
</Helmet>}
36-
{submission && challenge &&
36+
{submission && challenge && user._id &&
3737
<SubmitDetails submission={ submission } challenge={ challenge } user={ user } />
3838
}
3939
</div>

0 commit comments

Comments
 (0)