1
- import React , { useState } from 'react' ;
1
+ import { useState } from 'react' ;
2
2
import { Activity , Clock , CheckCircle } from 'lucide-react' ;
3
3
4
4
const App = ( ) => {
@@ -364,10 +364,10 @@ const App = () => {
364
364
const HISTORY_CONFIGS = {
365
365
rest : { color : 'bg-slate-400' , label : 'Rest' , summary : 'Recovery day' } ,
366
366
deload : { color : 'bg-slate-400' , label : 'Deload' , summary : 'Light activity' } ,
367
- liss : { color : 'bg-green-500' , label : 'LISS' , getSummary : ( w ) => `${ w . activity } - ${ w . duration } ${ typeof w . duration === 'number' ? ' min' : '' } ` } ,
368
- hiit : { color : 'bg-yellow-500' , label : 'HIIT' , getSummary : ( w ) => `${ w . activity } - ${ w . duration } ${ typeof w . duration === 'number' ? ' min' : '' } ` } ,
369
- strength : { color : 'bg-red-500' , label : 'Strength' , getSummary : ( w ) => w . exercises ?. join ( ', ' ) || 'Strength training' } ,
370
- hypertrophy : { color : 'bg-blue-500' , label : 'Hypertrophy' , getSummary : ( w ) => w . exercises ?. slice ( 0 , 3 ) . join ( ', ' ) + ( w . exercises ?. length > 3 ? '...' : '' ) || 'Accessory work' }
367
+ liss : { color : 'bg-green-500' , label : 'LISS' , getSummary : ( w : any ) => `${ w . activity } - ${ w . duration } ${ typeof w . duration === 'number' ? ' min' : '' } ` } ,
368
+ hiit : { color : 'bg-yellow-500' , label : 'HIIT' , getSummary : ( w : any ) => `${ w . activity } - ${ w . duration } ${ typeof w . duration === 'number' ? ' min' : '' } ` } ,
369
+ strength : { color : 'bg-red-500' , label : 'Strength' , getSummary : ( w : any ) => w . exercises ?. join ( ', ' ) || 'Strength training' } ,
370
+ hypertrophy : { color : 'bg-blue-500' , label : 'Hypertrophy' , getSummary : ( w : any ) => w . exercises ?. slice ( 0 , 3 ) . join ( ', ' ) + ( w . exercises ?. length > 3 ? '...' : '' ) || 'Accessory work' }
371
371
} ;
372
372
373
373
const AVAILABLE_BLOCKS = {
@@ -381,7 +381,7 @@ const App = () => {
381
381
} ;
382
382
383
383
// Helper function to generate exercise key from name
384
- const getExerciseKey = ( exerciseName ) => {
384
+ const getExerciseKey = ( exerciseName : string ) => {
385
385
return exerciseName . toLowerCase ( ) . replace ( / \s + / g, '' ) . replace ( / [ ^ a - z 0 - 9 ] / g, '' ) ;
386
386
} ;
387
387
@@ -390,16 +390,16 @@ const App = () => {
390
390
const currentBlock = state . customPlan [ 0 ] ;
391
391
if ( ! currentBlock ) return { strengthExercises : [ ] , hypertrophyExercises : [ ] } ;
392
392
393
- const blockTemplate = blockTemplates [ currentBlock . type ] ;
393
+ const blockTemplate = blockTemplates [ currentBlock . type as keyof typeof blockTemplates ] ;
394
394
if ( ! blockTemplate ) return { strengthExercises : [ ] , hypertrophyExercises : [ ] } ;
395
395
396
396
const strengthExercises = new Set ( ) ;
397
397
const hypertrophyExercises = new Set ( ) ;
398
398
399
- blockTemplate . weeks . forEach ( week => {
400
- week . days . forEach ( day => {
399
+ blockTemplate . weeks . forEach ( ( week : any ) => {
400
+ week . days . forEach ( ( day : any ) => {
401
401
if ( day . exercises ) {
402
- day . exercises . forEach ( exercise => {
402
+ day . exercises . forEach ( ( exercise : string ) => {
403
403
if ( day . type === 'strength' ) {
404
404
strengthExercises . add ( exercise ) ;
405
405
} else if ( day . type === 'hypertrophy' ) {
@@ -444,14 +444,14 @@ const App = () => {
444
444
} ) ;
445
445
446
446
// Unified state update function
447
- const updateState = ( updates ) => setState ( prev => ( { ...prev , ...updates } ) ) ;
447
+ const updateState = ( updates : any ) => setState ( ( prev : any ) => ( { ...prev , ...updates } ) ) ;
448
448
449
449
// Consolidated utility functions
450
- const calculateWeight = ( exercise , percentage ) => {
450
+ const calculateWeight = ( exercise : string , percentage : number ) => {
451
451
const exerciseKey = getExerciseKey ( exercise ) ;
452
- if ( ! exerciseKey || ! state . maxes [ exerciseKey ] ) return 0 ;
452
+ if ( ! exerciseKey || ! ( state . maxes as any ) [ exerciseKey ] ) return 0 ;
453
453
454
- const calculatedWeight = state . maxes [ exerciseKey ] * ( percentage / 100 ) ;
454
+ const calculatedWeight = ( state . maxes as any ) [ exerciseKey ] * ( percentage / 100 ) ;
455
455
const barbellExercises = [ 'Bench Press' , 'Squat' , 'Deadlift' , 'Overhead Press' , 'Front Squat' , 'Trap Bar Deadlift' , 'Power Clean' , 'Romanian Deadlift' ] ;
456
456
457
457
if ( barbellExercises . includes ( exercise ) ) {
@@ -461,17 +461,17 @@ const App = () => {
461
461
return Math . round ( calculatedWeight ) ;
462
462
} ;
463
463
464
- const calculateHypertrophyWeight = ( exercise , percentage ) => {
464
+ const calculateHypertrophyWeight = ( exercise : string , percentage : number ) => {
465
465
const exerciseKey = getExerciseKey ( exercise ) ;
466
466
467
467
// Convert 10RM input to estimated 1RM, then apply percentage
468
468
let estimatedOneRM ;
469
- if ( state . tenRMs [ exerciseKey ] ) {
469
+ if ( ( state . tenRMs as any ) [ exerciseKey ] ) {
470
470
// Convert 10RM to 1RM: 10RM / 0.75 = 1RM
471
- estimatedOneRM = state . tenRMs [ exerciseKey ] / 0.75 ;
472
- } else if ( state . maxes [ exerciseKey ] ) {
471
+ estimatedOneRM = ( state . tenRMs as any ) [ exerciseKey ] / 0.75 ;
472
+ } else if ( ( state . maxes as any ) [ exerciseKey ] ) {
473
473
// Fallback to actual 1RM if available
474
- estimatedOneRM = state . maxes [ exerciseKey ] ;
474
+ estimatedOneRM = ( state . maxes as any ) [ exerciseKey ] ;
475
475
} else {
476
476
return 0 ;
477
477
}
@@ -481,12 +481,12 @@ const App = () => {
481
481
return Math . round ( calculatedWeight ) ;
482
482
} ;
483
483
484
- const calculateWarmupSets = ( exercise , workingWeight ) => {
484
+ const calculateWarmupSets = ( _exercise : string , workingWeight : number ) => {
485
485
if ( ! workingWeight || workingWeight <= 0 ) return [ ] ;
486
486
487
487
const barbellWeight = state . weightUnit === 'kg' ? 20 : 45 ;
488
488
const plateIncrement = state . weightUnit === 'kg' ? 2.5 : 5 ;
489
- const roundToPlate = ( weight ) => Math . max ( Math . round ( weight / plateIncrement ) * plateIncrement , barbellWeight ) ;
489
+ const roundToPlate = ( weight : number ) => Math . max ( Math . round ( weight / plateIncrement ) * plateIncrement , barbellWeight ) ;
490
490
491
491
const warmupSets = [
492
492
{ weight : roundToPlate ( workingWeight * 0.5 ) , reps : 5 , type : 'warmup' } ,
@@ -500,7 +500,7 @@ const App = () => {
500
500
501
501
const getCurrentWorkout = ( ) => {
502
502
const block = state . customPlan [ 0 ] ;
503
- const blockTemplate = blockTemplates [ block . type ] ;
503
+ const blockTemplate = blockTemplates [ block . type as keyof typeof blockTemplates ] ;
504
504
if ( ! blockTemplate ) return null ;
505
505
506
506
const weekIndex = Math . min ( state . currentWeek - 1 , blockTemplate . weeks . length - 1 ) ;
@@ -509,7 +509,7 @@ const App = () => {
509
509
} ;
510
510
511
511
// Consolidated event handlers
512
- const handleDrag = ( action , data ) => {
512
+ const handleDrag = ( action : string , data : any ) => {
513
513
switch ( action ) {
514
514
case 'start' :
515
515
if ( data . index === 0 ) { data . e . preventDefault ( ) ; return ; }
@@ -592,17 +592,17 @@ const App = () => {
592
592
} ) ;
593
593
} ;
594
594
595
- const toggleSet = ( exerciseIndex , setIndex ) => {
595
+ const toggleSet = ( exerciseIndex : number | string , setIndex : number ) => {
596
596
const key = `${ exerciseIndex } -${ setIndex } ` ;
597
597
updateState ( {
598
- completedSets : { ...state . completedSets , [ key ] : ! state . completedSets [ key ] }
598
+ completedSets : { ...state . completedSets , [ key ] : ! ( state . completedSets as any ) [ key ] }
599
599
} ) ;
600
600
} ;
601
601
602
- const manageBlocks = ( action , data ) => {
602
+ const manageBlocks = ( action : string , data : any ) => {
603
603
switch ( action ) {
604
604
case 'add' : {
605
- const blockConfig = AVAILABLE_BLOCKS [ data . blockType ] ;
605
+ const blockConfig = AVAILABLE_BLOCKS [ data . blockType as keyof typeof AVAILABLE_BLOCKS ] ;
606
606
updateState ( {
607
607
customPlan : [ ...state . customPlan , {
608
608
name : blockConfig . name ,
@@ -649,13 +649,13 @@ const App = () => {
649
649
} ;
650
650
651
651
// Render functions using lookup tables
652
- const renderSimpleWorkout = ( type , workout ) => {
653
- const config = WORKOUT_CONFIGS [ type ] ;
652
+ const renderSimpleWorkout = ( type : string , workout : any ) => {
653
+ const config = WORKOUT_CONFIGS [ type as keyof typeof WORKOUT_CONFIGS ] ;
654
654
return (
655
655
< div >
656
656
< div className = { `bg-gradient-to-r ${ config . bg } text-white p-6 rounded-lg text-center` } >
657
- < h3 className = "text-2xl font-bold mb-2" > { config . title || workout . activity } </ h3 >
658
- { config . desc && < p className = "opacity-90" > { config . desc } </ p > }
657
+ < h3 className = "text-2xl font-bold mb-2" > { ( config as any ) . title || workout . activity } </ h3 >
658
+ { ( config as any ) . desc && < p className = "opacity-90" > { ( config as any ) . desc } </ p > }
659
659
{ workout . duration && (
660
660
< >
661
661
< div className = "text-4xl font-bold" > { workout . duration } </ div >
@@ -670,7 +670,7 @@ const App = () => {
670
670
) ;
671
671
} ;
672
672
673
- const renderExerciseSet = ( exercise , exerciseIndex , setScheme , schemeIndex , intensity , weight , workout ) => {
673
+ const renderExerciseSet = ( exercise : string , exerciseIndex : number , setScheme : string , schemeIndex : number , intensity : number , weight : number , workout : any ) => {
674
674
const [ sets , reps ] = setScheme . split ( 'x' ) ;
675
675
const warmupSets = workout . type === 'strength' && weight > 0 ? calculateWarmupSets ( exercise , weight ) : [ ] ;
676
676
@@ -695,11 +695,11 @@ const App = () => {
695
695
< button
696
696
onClick = { ( ) => toggleSet ( `warmup-${ exerciseIndex } -${ schemeIndex } -${ warmupIndex } ` , 0 ) }
697
697
className = { `w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all ${
698
- state . completedSets [ `warmup-${ exerciseIndex } -${ schemeIndex } -${ warmupIndex } -0` ]
698
+ ( state . completedSets as any ) [ `warmup-${ exerciseIndex } -${ schemeIndex } -${ warmupIndex } -0` ]
699
699
? 'bg-blue-500 border-blue-500 text-white' : 'border-blue-300 hover:border-blue-400 bg-white'
700
700
} `}
701
701
>
702
- { state . completedSets [ `warmup-${ exerciseIndex } -${ schemeIndex } -${ warmupIndex } -0` ] && < CheckCircle className = "w-4 h-4" /> }
702
+ { ( state . completedSets as any ) [ `warmup-${ exerciseIndex } -${ schemeIndex } -${ warmupIndex } -0` ] && < CheckCircle className = "w-4 h-4" /> }
703
703
</ button >
704
704
</ div >
705
705
) ) }
@@ -731,11 +731,11 @@ const App = () => {
731
731
< button
732
732
onClick = { ( ) => toggleSet ( `${ exerciseIndex } -${ schemeIndex } ` , setIndex ) }
733
733
className = { `w-8 h-8 rounded-full border-2 flex items-center justify-center transition-all ${
734
- state . completedSets [ `${ exerciseIndex } -${ schemeIndex } -${ setIndex } ` ]
734
+ ( state . completedSets as any ) [ `${ exerciseIndex } -${ schemeIndex } -${ setIndex } ` ]
735
735
? 'bg-green-500 border-green-500 text-white' : 'border-gray-300 hover:border-green-400 bg-white'
736
736
} `}
737
737
>
738
- { state . completedSets [ `${ exerciseIndex } -${ schemeIndex } -${ setIndex } ` ] && < CheckCircle className = "w-5 h-5" /> }
738
+ { ( state . completedSets as any ) [ `${ exerciseIndex } -${ schemeIndex } -${ setIndex } ` ] && < CheckCircle className = "w-5 h-5" /> }
739
739
</ button >
740
740
</ div >
741
741
</ div >
@@ -756,10 +756,10 @@ const App = () => {
756
756
if ( workout . type === 'strength' || workout . type === 'hypertrophy' ) {
757
757
return (
758
758
< div className = "space-y-4" >
759
- { workout . exercises . map ( ( exercise , exerciseIndex ) => {
760
- const setSchemes = workout . sets . split ( ',' ) ;
759
+ { ( workout . exercises || [ ] ) . map ( ( exercise : string , exerciseIndex : number ) => {
760
+ const setSchemes = ( workout . sets || '' ) . split ( ',' ) ;
761
761
const intensities = String ( workout . intensity ) . split ( ',' ) ;
762
- const shouldMapByIndex = setSchemes . length === workout . exercises . length ;
762
+ const shouldMapByIndex = setSchemes . length === ( workout . exercises || [ ] ) . length ;
763
763
const exerciseSetSchemes = shouldMapByIndex ? [ setSchemes [ exerciseIndex ] ] : setSchemes ;
764
764
765
765
return exerciseSetSchemes . map ( ( setScheme , schemeIndex ) => {
@@ -858,11 +858,11 @@ const App = () => {
858
858
</ div >
859
859
) : (
860
860
< div className = "space-y-4" >
861
- { state . completedWorkouts . slice ( - 10 ) . reverse ( ) . map ( ( workout , index ) => {
862
- const date = new Date ( workout . date ) ;
863
- const workoutType = workout . details ?. type || 'unknown' ;
864
- const config = HISTORY_CONFIGS [ workoutType ] || HISTORY_CONFIGS . rest ;
865
- const workoutSummary = config . getSummary ? config . getSummary ( workout . details ) : config . summary ;
861
+ { state . completedWorkouts . slice ( - 10 ) . reverse ( ) . map ( ( workout : any , index : number ) => {
862
+ const date = new Date ( ( workout as any ) . date ) ;
863
+ const workoutType = ( workout as any ) . details ?. type || 'unknown' ;
864
+ const config = HISTORY_CONFIGS [ workoutType as keyof typeof HISTORY_CONFIGS ] || HISTORY_CONFIGS . rest ;
865
+ const workoutSummary = ( config as any ) . getSummary ? ( config as any ) . getSummary ( ( workout as any ) . details ) : ( config as any ) . summary ;
866
866
867
867
return (
868
868
< div key = { index } className = "border-l-4 border-blue-500 pl-4 pb-3" >
@@ -874,12 +874,12 @@ const App = () => {
874
874
{ config . label }
875
875
</ span >
876
876
</ div >
877
- < div className = "font-semibold text-gray-900" > { workout . blockName || 'Unknown Block' } </ div >
878
- < div className = "text-sm text-gray-600" > Week { workout . week } , Day { workout . day } </ div >
877
+ < div className = "font-semibold text-gray-900" > { ( workout as any ) . blockName || 'Unknown Block' } </ div >
878
+ < div className = "text-sm text-gray-600" > Week { ( workout as any ) . week } , Day { ( workout as any ) . day } </ div >
879
879
{ workoutSummary && < div className = "text-sm text-gray-700 mt-1 font-medium" > { workoutSummary } </ div > }
880
- { workout . details ?. sets && (
880
+ { ( workout as any ) . details ?. sets && (
881
881
< div className = "text-xs text-gray-500 mt-1" >
882
- Sets: { workout . details . sets } { workout . details . intensity && ` @ ${ workout . details . intensity } %` }
882
+ Sets: { ( workout as any ) . details . sets } { ( workout as any ) . details . intensity && ` @ ${ ( workout as any ) . details . intensity } %` }
883
883
</ div >
884
884
) }
885
885
</ div >
@@ -983,15 +983,15 @@ const App = () => {
983
983
Strength Exercises (1RM - { state . weightUnit } )
984
984
</ h4 >
985
985
< div className = "space-y-3" >
986
- { strengthExercises . map ( ( exercise ) => {
987
- const exerciseKey = getExerciseKey ( exercise ) ;
986
+ { ( strengthExercises as string [ ] ) . map ( ( exercise : string ) => {
987
+ const exerciseKey = getExerciseKey ( exercise as string ) ;
988
988
989
989
return (
990
990
< div key = { exerciseKey } className = "flex items-center gap-3" >
991
- < label className = "flex-1 text-sm text-gray-700 font-medium" > { exercise } </ label >
991
+ < label className = "flex-1 text-sm text-gray-700 font-medium" > { exercise as string } </ label >
992
992
< input
993
993
type = "number"
994
- value = { state . maxes [ exerciseKey ] || '' }
994
+ value = { ( state . maxes as any ) [ exerciseKey ] || '' }
995
995
onChange = { ( e ) => updateState ( {
996
996
maxes : { ...state . maxes , [ exerciseKey ] : parseFloat ( e . target . value ) || 0 }
997
997
} ) }
@@ -1013,15 +1013,15 @@ const App = () => {
1013
1013
Hypertrophy Exercises (10RM - { state . weightUnit } )
1014
1014
</ h4 >
1015
1015
< div className = "space-y-3" >
1016
- { hypertrophyExercises . map ( ( exercise ) => {
1017
- const exerciseKey = getExerciseKey ( exercise ) ;
1016
+ { ( hypertrophyExercises as string [ ] ) . map ( ( exercise : string ) => {
1017
+ const exerciseKey = getExerciseKey ( exercise as string ) ;
1018
1018
1019
1019
return (
1020
1020
< div key = { exerciseKey } className = "flex items-center gap-3" >
1021
- < label className = "flex-1 text-sm text-gray-700 font-medium" > { exercise } </ label >
1021
+ < label className = "flex-1 text-sm text-gray-700 font-medium" > { exercise as string } </ label >
1022
1022
< input
1023
1023
type = "number"
1024
- value = { state . tenRMs [ exerciseKey ] || '' }
1024
+ value = { ( state . tenRMs as any ) [ exerciseKey ] || '' }
1025
1025
onChange = { ( e ) => updateState ( {
1026
1026
tenRMs : { ...state . tenRMs , [ exerciseKey ] : parseFloat ( e . target . value ) || 0 }
1027
1027
} ) }
0 commit comments