Skip to content

Commit

Permalink
Added sort order key
Browse files Browse the repository at this point in the history
  • Loading branch information
hv2308 committed Jan 14, 2025
1 parent 021644f commit b7c5501
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion backend/api/models/Training.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""<Training : {self.name}
\n name: {self.name}
\n url: {self.url}
\n description: {self.description}
\n date_submitted: {self.date_submitted}>"""
\n date_submitted: {self.date_submitted}
\n sort_order: {self.sort_order}>"""
4 changes: 2 additions & 2 deletions frontend/src/components/TrainingList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b7c5501

Please sign in to comment.