We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 245ed7f commit 9a154bdCopy full SHA for 9a154bd
KonditionExpo/app/(tabs)/history.tsx
@@ -241,7 +241,19 @@ const WorkoutHistoryScreen = () => {
241
) : !Array.isArray(workouts) || workouts.length === 0 ? (
242
renderEmptyState()
243
) : (
244
- workouts.map(renderWorkoutItem)
+ [...workouts]
245
+ .sort((a, b) => {
246
+ // 1. Completed workouts first
247
+ if (a.is_completed !== b.is_completed) {
248
+ return b.is_completed ? 1 : -1;
249
+ }
250
+
251
+ // 2. Then sort by date (fallback to created_at if completed_date is missing)
252
+ const aDate = new Date(a.completed_date || a.created_at).getTime();
253
+ const bDate = new Date(b.completed_date || b.created_at).getTime();
254
+ return bDate - aDate;
255
+ })
256
+ .map(renderWorkoutItem)
257
)}
258
</ScrollView>
259
</SafeAreaView>
0 commit comments