diff --git a/backend/api/models/Training.py b/backend/api/models/Training.py index e9d7c293..9a990de0 100644 --- a/backend/api/models/Training.py +++ b/backend/api/models/Training.py @@ -27,10 +27,12 @@ class Training(Document, Mixin): partner_id = StringField(required=False) mentor_id = ListField(StringField(), required=False) mentee_id = ListField(StringField(), required=False) + sort_order = IntField(required=False, default=0) def __repr__(self): return f"""""" + \n date_submitted: {self.date_submitted} + \n sort_order: {self.sort_order}>""" \ No newline at end of file diff --git a/frontend/src/components/TrainingList.js b/frontend/src/components/TrainingList.js index f0eae06a..5bd627b2 100644 --- a/frontend/src/components/TrainingList.js +++ b/frontend/src/components/TrainingList.js @@ -203,9 +203,9 @@ const TrainingList = (props) => { } else { hub_user_id = user._id.$oid; } - setTrainingData(trains.filter((x) => x.hub_id == hub_user_id)); + setTrainingData(trains.sort((a, b)=> a.sort_order - b.sort_order).filter((x) => x.hub_id == hub_user_id)); } else { - setTrainingData(trains); + setTrainingData(trains.sort((a, b)=> a.sort_order - b.sort_order)); } setLoading(false); setFlag(!flag);