Skip to content

Commit

Permalink
feat: last update
Browse files Browse the repository at this point in the history
  • Loading branch information
amrsalama committed Feb 11, 2020
1 parent 1057cfa commit 1b1938a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
14 changes: 11 additions & 3 deletions src/Components/Board/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ class Board extends React.Component {
)
.then(response => response.json())
.then(data => {
const { trainees, sheets, submissions } = data;
this.setState({ trainees, sheets, submissions, loading: false });
const { trainees, sheets, submissions, metadata } = data;
this.setState({
trainees,
sheets,
submissions,
metadata,
loading: false
});
})
.catch(_ => this.setState({ loading: false }));
}
Expand All @@ -59,6 +65,7 @@ class Board extends React.Component {
trainees,
sheets,
submissions,
metadata,
hoveredTraineeIndex,
hoveredProblemIndex,
hoveredSheetIndex
Expand All @@ -68,7 +75,7 @@ class Board extends React.Component {
return <Loading />;
}

if (!trainees || !sheets || !submissions) {
if (!trainees || !sheets || !submissions || !metadata) {
return <Invalid />;
}

Expand All @@ -85,6 +92,7 @@ class Board extends React.Component {
<TraineeList
trainees={trainees}
problemsCount={problemsCount}
lastUpdate={metadata.lastUpdate}
hoveredTraineeIndex={hoveredTraineeIndex}
onTraineeHover={() => ({})}
// index => this.setState({ hoveredTraineeIndex: index })
Expand Down
16 changes: 10 additions & 6 deletions src/Components/TraineeList/TraineeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TraineeList extends React.Component {
const {
trainees,
problemsCount,
lastUpdate,
hoveredTraineeIndex,
onTraineeHover
} = this.props;
Expand All @@ -27,12 +28,14 @@ class TraineeList extends React.Component {
style={{ height: sheetNameHeight + sheetProblemIdHeight }}
>
<div className="title">Newcomers Training Board</div>
<div className="last-update">
<span role="img" aria-label="">
🕐
</span>{' '}
Last update: 3 days ago
</div>
{lastUpdate && (
<div className="last-update">
<span role="img" aria-label="">
🕐
</span>{' '}
Last update: {lastUpdate}
</div>
)}
<div className="list-desc">
<div>Trainee</div>
<div style={{ width: progressWidth }}>Progress</div>
Expand Down Expand Up @@ -97,6 +100,7 @@ class TraineeList extends React.Component {
TraineeList.propTypes = {
trainees: PropTypes.array.isRequired,
problemsCount: PropTypes.number.isRequired,
lastUpdate: PropTypes.string.isRequired,
hoveredTraineeIndex: PropTypes.number.isRequired,
onTraineeHover: PropTypes.func.isRequired
};
Expand Down

0 comments on commit 1b1938a

Please sign in to comment.