@@ -7,6 +7,38 @@ import type { ExerciseEntry } from '@/types/diary';
77import type { GroupedExerciseEntry } from '@/types/exercises' ;
88import type { ExerciseProgressData } from '@/types/reports' ;
99
10+ interface RawActivityDetail {
11+ id ?: string ;
12+ detail_type : string ;
13+ detail_data : unknown ;
14+ provider_name ?: string ;
15+ }
16+
17+ interface RawExerciseSnapshot {
18+ equipment ?: string ;
19+ primary_muscles ?: string ;
20+ secondary_muscles ?: string ;
21+ instructions ?: string ;
22+ images ?: string ;
23+ [ key : string ] : unknown ;
24+ }
25+
26+ interface RawExercise {
27+ sets ?: string | unknown [ ] ;
28+ exercise_snapshot ?: RawExerciseSnapshot ;
29+ activity_details ?: RawActivityDetail [ ] ;
30+ [ key : string ] : unknown ;
31+ }
32+
33+ interface RawGroupedEntry {
34+ type ?: string ;
35+ exercises ?: RawExercise [ ] ;
36+ sets ?: string | unknown [ ] ;
37+ exercise_snapshot ?: RawExerciseSnapshot ;
38+ activity_details ?: RawActivityDetail [ ] ;
39+ [ key : string ] : unknown ;
40+ }
41+
1042export const getExerciseEntriesForDate = async (
1143 date : string
1244) : Promise < GroupedExerciseEntry [ ] > => {
@@ -24,16 +56,14 @@ export const fetchExerciseEntries = async (
2456 const loggingLevel = getUserLoggingLevel ( ) ;
2557 const response = await getExerciseEntriesForDate ( selectedDate ) ;
2658
27- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28- const parsedEntries : GroupedExerciseEntry [ ] = response . map ( ( entry : any ) => {
59+ const parsedEntries : GroupedExerciseEntry [ ] = response . map ( ( entry ) => {
2960 if ( entry . type === 'preset' ) {
3061 return {
31- ...entry ,
62+ ...( entry as unknown as GroupedExerciseEntry ) ,
3263 exercises : entry . exercises
33- ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
34- entry . exercises . map ( ( ex : any ) => ( {
64+ ? entry . exercises . map ( ( ex ) => ( {
3565 ...ex ,
36- sets : ex . sets ? parseJsonArray ( ex . sets ) : [ ] , // Parse sets if it's a JSON string
66+ sets : ex . sets ? ex . sets : [ ] , // Parse sets if it's a JSON string
3767 exercise_snapshot : {
3868 ...ex . exercise_snapshot , // Use the existing snapshot
3969 equipment : parseJsonArray ( ex . exercise_snapshot . equipment ) ,
@@ -47,8 +77,7 @@ export const fetchExerciseEntries = async (
4777 images : parseJsonArray ( ex . exercise_snapshot . images ) ,
4878 } ,
4979 activity_details : ex . activity_details
50- ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
51- ex . activity_details . map ( ( detail : any ) => ( {
80+ ? ex . activity_details . map ( ( detail ) => ( {
5281 id : detail . id ,
5382 key : detail . detail_type ,
5483 value :
@@ -65,7 +94,7 @@ export const fetchExerciseEntries = async (
6594 } else {
6695 return {
6796 ...entry ,
68- sets : entry . sets ? parseJsonArray ( entry . sets ) : [ ] , // Parse sets if it's a JSON string
97+ sets : entry . sets ? entry . sets : [ ] , // Parse sets if it's a JSON string
6998 exercise_snapshot : {
7099 ...entry . exercise_snapshot , // Use the existing snapshot
71100 equipment : parseJsonArray ( entry . exercise_snapshot . equipment ) ,
@@ -79,8 +108,7 @@ export const fetchExerciseEntries = async (
79108 images : parseJsonArray ( entry . exercise_snapshot . images ) ,
80109 } ,
81110 activity_details : entry . activity_details
82- ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
83- entry . activity_details . map ( ( detail : any ) => ( {
111+ ? entry . activity_details . map ( ( detail ) => ( {
84112 id : detail . id ,
85113 key : detail . detail_type ,
86114 value :
@@ -127,8 +155,7 @@ export const createExerciseEntry = async (payload: {
127155
128156 // Append other data from the payload to formData
129157 Object . keys ( entryData ) . forEach ( ( key ) => {
130- // eslint-disable-next-line @typescript-eslint/no-explicit-any
131- const value = ( entryData as any ) [ key ] ;
158+ const value = entryData [ key ] ;
132159 if ( value !== undefined && value !== null ) {
133160 if ( key === 'sets' && Array . isArray ( value ) ) {
134161 // The backend expects 'sets' to be a JSON string if it's part of FormData
@@ -215,8 +242,7 @@ export const updateExerciseEntry = async (
215242 formData . append ( 'image' , imageFile ) ;
216243
217244 Object . keys ( entryData ) . forEach ( ( key ) => {
218- // eslint-disable-next-line @typescript-eslint/no-explicit-any
219- const value = ( entryData as any ) [ key ] ;
245+ const value = entryData [ key ] ;
220246 if ( value !== undefined && value !== null ) {
221247 if ( key === 'sets' && Array . isArray ( value ) ) {
222248 formData . append ( key , JSON . stringify ( value ) ) ;
@@ -298,8 +324,41 @@ export const fetchExerciseDetails = async (
298324
299325export interface ActivityDetailsResponse {
300326 id ?: string ;
301- // eslint-disable-next-line @typescript-eslint/no-explicit-any
302- [ key : string ] : any ;
327+ activity ?: {
328+ details ?: {
329+ metricDescriptors ?: unknown [ ] ;
330+ activityDetailMetrics ?: unknown [ ] ;
331+ geoPolylineDTO ?: {
332+ polyline : { lat : number ; lon : number } [ ] ;
333+ } ;
334+ [ key : string ] : unknown ;
335+ } ;
336+ hr_in_timezones ?: unknown [ ] ;
337+ splits ?: {
338+ lapDTOs : unknown [ ] ;
339+ [ key : string ] : unknown ;
340+ } ;
341+ activity ?: {
342+ duration ?: number ;
343+ calories ?: number ;
344+ totalAscent ?: number ;
345+ averageHR ?: number ;
346+ averageRunCadence ?: number ;
347+ distance ?: number ;
348+ averagePace ?: number ;
349+ activityName ?: string ;
350+ eventType ?: unknown ;
351+ course ?: unknown ;
352+ gear ?: unknown ;
353+ [ key : string ] : unknown ;
354+ } ;
355+ [ key : string ] : unknown ;
356+ } ;
357+ workout ?: {
358+ workoutName : string ;
359+ [ key : string ] : unknown ;
360+ } ;
361+ [ key : string ] : unknown ;
303362}
304363
305364export const getActivityDetails = async (
0 commit comments