@@ -35,6 +35,10 @@ export const fetchExerciseEntries = async (
3535 sets : ex . sets ? ex . sets : [ ] , // Parse sets if it's a JSON string
3636 exercise_snapshot : {
3737 ...ex . exercise_snapshot , // Use the existing snapshot
38+ id : ex . exercise_snapshot . id ?? '' ,
39+ name : ex . exercise_snapshot . name ?? '' ,
40+ calories_per_hour : ex . exercise_snapshot . calories_per_hour ?? 0 ,
41+ category : ex . exercise_snapshot . category ?? '' ,
3842 equipment : parseJsonArray ( ex . exercise_snapshot . equipment ) ,
3943 primary_muscles : parseJsonArray (
4044 ex . exercise_snapshot . primary_muscles
@@ -47,14 +51,14 @@ export const fetchExerciseEntries = async (
4751 } ,
4852 activity_details : ex . activity_details
4953 ? ex . activity_details . map ( ( detail ) => ( {
50- id : detail . id ,
51- key : detail . detail_type ,
54+ id : detail . id ?? '' ,
55+ key : detail . detail_type ?? '' ,
5256 value :
5357 typeof detail . detail_data === 'object'
5458 ? JSON . stringify ( detail . detail_data , null , 2 )
5559 : String ( detail . detail_data ) ,
5660 provider_name : detail . provider_name ,
57- detail_type : detail . detail_type ,
61+ detail_type : detail . detail_type ?? '' ,
5862 } ) )
5963 : [ ] ,
6064 } ) )
@@ -66,26 +70,30 @@ export const fetchExerciseEntries = async (
6670 sets : entry . sets ? entry . sets : [ ] , // Parse sets if it's a JSON string
6771 exercise_snapshot : {
6872 ...entry . exercise_snapshot , // Use the existing snapshot
69- equipment : parseJsonArray ( entry . exercise_snapshot . equipment ) ,
73+ id : entry . exercise_snapshot ?. id ?? '' ,
74+ name : entry . exercise_snapshot ?. name ?? '' ,
75+ category : entry . exercise_snapshot ?. category ?? '' ,
76+ calories_per_hour : entry . exercise_snapshot ?. calories_per_hour ?? 0 ,
77+ equipment : parseJsonArray ( entry . exercise_snapshot ?. equipment ) ,
7078 primary_muscles : parseJsonArray (
71- entry . exercise_snapshot . primary_muscles
79+ entry . exercise_snapshot ? .primary_muscles
7280 ) ,
7381 secondary_muscles : parseJsonArray (
74- entry . exercise_snapshot . secondary_muscles
82+ entry . exercise_snapshot ? .secondary_muscles
7583 ) ,
76- instructions : parseJsonArray ( entry . exercise_snapshot . instructions ) ,
77- images : parseJsonArray ( entry . exercise_snapshot . images ) ,
84+ instructions : parseJsonArray ( entry . exercise_snapshot ? .instructions ) ,
85+ images : parseJsonArray ( entry . exercise_snapshot ? .images ) ,
7886 } ,
7987 activity_details : entry . activity_details
8088 ? entry . activity_details . map ( ( detail ) => ( {
81- id : detail . id ,
82- key : detail . detail_type ,
89+ id : detail . id ?? '' ,
90+ key : detail . detail_type ?? '' ,
8391 value :
8492 typeof detail . detail_data === 'object'
8593 ? JSON . stringify ( detail . detail_data , null , 2 )
8694 : String ( detail . detail_data ) ,
8795 provider_name : detail . provider_name ,
88- detail_type : detail . detail_type ,
96+ detail_type : detail . detail_type ?? '' ,
8997 } ) )
9098 : [ ] ,
9199 } ;
@@ -107,8 +115,8 @@ export const createExerciseEntry = async (payload: {
107115 sets : WorkoutPresetSet [ ] ;
108116 image_url ?: string ;
109117 calories_burned ?: number ;
110- distance ?: number ;
111- avg_heart_rate ?: number ;
118+ distance ?: number | null ;
119+ avg_heart_rate ?: number | null ;
112120 imageFile ?: File | null ;
113121 activity_details ?: {
114122 provider_name ?: string ;
@@ -184,9 +192,9 @@ export interface UpdateExerciseEntryPayload {
184192 calories_burned ?: number ;
185193 notes ?: string ;
186194 sets ?: WorkoutPresetSet [ ] ;
187- image_url ?: string ;
188- distance ?: number ;
189- avg_heart_rate ?: number ;
195+ image_url ?: string | null ;
196+ distance ?: number | null ;
197+ avg_heart_rate ?: number | null ;
190198 imageFile ?: File | null ;
191199 activity_details ?: {
192200 id ?: string ;
0 commit comments