@@ -11,10 +11,30 @@ import {
1111 Alert ,
1212} from 'react-native' ;
1313import { router } from 'expo-router' ;
14- import { apiService , WorkoutResponse } from '@/services/api' ;
14+ import { apiService } from '@/services/api' ;
1515import { useAuth } from '@/contexts/AuthContext' ;
1616import axios from 'axios' ;
1717
18+ export type Exercise = {
19+ id : string ;
20+ name : string ;
21+ sets ?: number ;
22+ reps ?: number ;
23+ weight ?: number ;
24+ category : string ;
25+ } ;
26+
27+ export type WorkoutResponse = {
28+ id : string ;
29+ name : string ;
30+ description ?: string ;
31+ is_completed : boolean ;
32+ created_at : string ;
33+ completed_date ?: string ;
34+ duration_minutes ?: number ;
35+ exercises : Exercise [ ] ; // <-- include this
36+ } ;
37+
1838const WorkoutHistoryScreen = ( ) => {
1939 const { user } = useAuth ( ) ;
2040 const [ workouts , setWorkouts ] = useState < WorkoutResponse [ ] > ( [ ] ) ;
@@ -34,7 +54,7 @@ const WorkoutHistoryScreen = () => {
3454
3555 //const workoutData = await apiService.getWorkouts(); - Uses old api.ts, idk
3656
37- const response = await axios . get ( 'http://localhost:8000/api/v1/workouts/' , {
57+ const response = await axios . get ( 'http://localhost:8000/api/v1/workouts/exercises/ ' , {
3858 headers : {
3959 Authorization : `Bearer ${ token } ` ,
4060 } ,
@@ -95,54 +115,66 @@ const WorkoutHistoryScreen = () => {
95115 return workout . is_completed ? '#4CAF50' : '#FF9800' ;
96116 } ;
97117
98- const handleWorkoutPress = ( workout : WorkoutResponse ) => {
118+ /* const handleWorkoutPress = (workout: WorkoutResponse) => {
99119 // Navigate to the detailed workout view
100120 router.push({
101121 pathname: '/workout-detail',
102122 params: { workoutId: workout.id }
103123 });
104- } ;
124+ }; Not needed */
105125
106126 const renderWorkoutItem = ( workout : WorkoutResponse ) => (
107- < TouchableOpacity
108- key = { workout . id }
109- style = { styles . workoutCard }
110- onPress = { ( ) => handleWorkoutPress ( workout ) }
111- >
127+ < View key = { workout . id } style = { styles . workoutCard } >
128+ { /* Workout Header */ }
112129 < View style = { styles . workoutHeader } >
113130 < Text style = { styles . workoutName } > { workout . name } </ Text >
114131 < View style = { [ styles . statusBadge , { backgroundColor : getStatusColor ( workout ) } ] } >
115132 < Text style = { styles . statusText } > { getCompletionStatus ( workout ) } </ Text >
116133 </ View >
117134 </ View >
118-
135+
136+ { /* Workout Date */ }
119137 < Text style = { styles . workoutDate } >
120138 { formatDate ( workout . completed_date || workout . created_at ) }
121139 </ Text >
122-
140+
141+ { /* Workout Metadata */ }
123142 < View style = { styles . workoutDetails } >
124143 < View style = { styles . detailItem } >
125144 < Text style = { styles . detailLabel } > Duration</ Text >
126145 < Text style = { styles . detailValue } > { formatDuration ( workout . duration_minutes ) } </ Text >
127146 </ View >
128-
147+
129148 < View style = { styles . detailItem } >
130149 < Text style = { styles . detailLabel } > Exercises</ Text >
131- < Text style = { styles . detailValue } > { workout . exercise_count || 0 } </ Text >
150+ < Text style = { styles . detailValue } > { workout . exercises ?. length || 0 } </ Text >
132151 </ View >
133152 </ View >
134-
153+
154+ { /* Workout Description */ }
135155 { workout . description && (
136156 < Text style = { styles . workoutDescription } numberOfLines = { 2 } >
137157 { workout . description }
138158 </ Text >
139159 ) }
140-
141- < View style = { styles . viewDetailsContainer } >
142- < Text style = { styles . viewDetailsText } > Tap to view exercises →</ Text >
143- </ View >
144- </ TouchableOpacity >
160+
161+ { /* Exercise List */ }
162+ { workout . exercises ?. length > 0 && (
163+ < View style = { { marginTop : 12 } } >
164+ < Text style = { { fontWeight : '600' , color : '#444' , marginBottom : 4 } } > Exercises:</ Text >
165+ { workout . exercises . map ( ( ex ) => (
166+ < View key = { ex . id } style = { { marginBottom : 6 , paddingLeft : 8 } } >
167+ < Text style = { { color : '#333' } } >
168+ • { ex . name } — { ex . sets || 0 } × { ex . reps || 0 } @ { ex . weight || 0 } lbs
169+ </ Text >
170+ </ View >
171+ ) ) }
172+ </ View >
173+ ) }
174+ </ View >
145175 ) ;
176+
177+
146178
147179 const renderEmptyState = ( ) => (
148180 < View style = { styles . emptyState } >
0 commit comments