diff --git a/mpwo_api/mpwo_api/activities/activities.py b/mpwo_api/mpwo_api/activities/activities.py index c8c2bf20..ca893ffd 100644 --- a/mpwo_api/mpwo_api/activities/activities.py +++ b/mpwo_api/mpwo_api/activities/activities.py @@ -18,7 +18,8 @@ activities_blueprint = Blueprint('activities', __name__) @authenticate def get_activities(auth_user_id): """Get all activities for authenticated user""" - activities = Activity.query.filter_by(user_id=auth_user_id).all() + activities = Activity.query.filter_by(user_id=auth_user_id)\ + .order_by(Activity.activity_date.desc()).all() activities_list = [] for activity in activities: activities_list.append(activity.serialize()) diff --git a/mpwo_api/mpwo_api/tests/test_activities.py b/mpwo_api/mpwo_api/tests/test_activities.py index 0995d8b0..e883bd75 100644 --- a/mpwo_api/mpwo_api/tests/test_activities.py +++ b/mpwo_api/mpwo_api/tests/test_activities.py @@ -51,18 +51,18 @@ def test_get_all_activities_for_authenticated_user(app): assert len(data['data']['activities']) == 2 assert 'creation_date' in data['data']['activities'][0] - assert 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] # noqa + assert 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] # noqa assert 1 == data['data']['activities'][0]['user_id'] - assert 2 == data['data']['activities'][0]['sport_id'] - assert '0:17:04' == data['data']['activities'][0]['duration'] + assert 1 == data['data']['activities'][0]['sport_id'] + assert '1:40:00' == data['data']['activities'][0]['duration'] assert data['data']['activities'][0]['with_gpx'] is False assert 'creation_date' in data['data']['activities'][1] - assert 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] # noqa + assert 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] # noqa assert 1 == data['data']['activities'][1]['user_id'] - assert 1 == data['data']['activities'][1]['sport_id'] - assert '1:40:00' == data['data']['activities'][1]['duration'] - assert data['data']['activities'][0]['with_gpx'] is False + assert 2 == data['data']['activities'][1]['sport_id'] + assert '0:17:04' == data['data']['activities'][1]['duration'] + assert data['data']['activities'][1]['with_gpx'] is False def test_get_activities_for_authenticated_user_no_activity(app): diff --git a/mpwo_client/src/components/App.css b/mpwo_client/src/components/App.css index de639768..d69bdd1f 100644 --- a/mpwo_client/src/components/App.css +++ b/mpwo_client/src/components/App.css @@ -57,6 +57,10 @@ input, textarea { text-align: center; } +.activity-card { + margin-bottom: 15px; +} + .add-activity { margin-top: 50px; } diff --git a/mpwo_client/src/components/Dashboard/ActivityCard.jsx b/mpwo_client/src/components/Dashboard/ActivityCard.jsx new file mode 100644 index 00000000..f76d67a9 --- /dev/null +++ b/mpwo_client/src/components/Dashboard/ActivityCard.jsx @@ -0,0 +1,30 @@ +import React from 'react' +import { Link } from 'react-router-dom' + +export default function ActivityCard (props) { + const { activity, sports } = props + + return ( +
+ {' '} + Start at {activity.activity_date} +
++ {' '} + Duration: {activity.duration} -{' '} + {' '} + Distance: {activity.distance} km +
+