@@ -161,7 +161,11 @@ export default function TrackWorkout({ params, template } : { params?: { workout
161
161
162
162
const finishWorkout = ( ) => {
163
163
if ( disableSubmit ) return ;
164
- if ( workout && workout . exercises . length > 0 ) {
164
+ if ( workout &&
165
+ ( workout . exercises . length > 0
166
+ && workout ?. exercises [ 0 ] . sets [ 0 ] . reps
167
+ && workout ?. exercises [ 0 ] . sets [ 0 ] . reps > 0 )
168
+ ) {
165
169
disableSubmit = true ;
166
170
if ( params ?. workoutid && ! template ) {
167
171
apiWithAuth ( getToken ( ) ) . put ( 'workouts/' + params . workoutid , workout ) . then ( response => {
@@ -180,7 +184,7 @@ export default function TrackWorkout({ params, template } : { params?: { workout
180
184
181
185
return (
182
186
< div className = "h-full flex flex-col relative" >
183
- < Header navigationTitle = "Voltar" actionTitle = "Finalizar" action = { ( e ) => { if ( workout ! . exercises . length > 0 && workout ?. exercises !== undefined ) { setModals ( { type : 'finishWorkout' } ) } } } />
187
+ < Header navigationTitle = "Voltar" actionTitle = "Finalizar" action = { ( e ) => { setModals ( { type : 'finishWorkout' } ) } } />
184
188
< Main >
185
189
< MainContent >
186
190
{
@@ -215,9 +219,9 @@ export default function TrackWorkout({ params, template } : { params?: { workout
215
219
}
216
220
</ select >
217
221
</ td >
218
- < td className = "w-4/12 text-right pb-2 text-white/50" > < input type = "number" min = { 0 } name = "weight" inputMode = "decimal" className = "text-sm text-right bg-white/10 text-white mr-2 py-1 px-2 w-12 inline align-middle" defaultValue = { weight } onChange = { ( e ) => updateSet ( indexExercise , indexSet , 'weight' , Number ( e . target . value ) ) } /> kg</ td >
222
+ < td className = "w-4/12 text-right pb-2 text-white/50" > < input type = "number" min = { 0 } max = { 999 } name = "weight" inputMode = "decimal" className = "text-sm text-right bg-white/10 text-white mr-2 py-1 px-2 w-12 inline align-middle" defaultValue = { weight } onChange = { ( e ) => updateSet ( indexExercise , indexSet , 'weight' , Number ( e . target . value ) ) } /> kg</ td >
219
223
< td className = "w-1/12 text-center pb-2 text-white/50" > X</ td >
220
- < td className = "w-4/12 text-center pb-2 text-white/50" > < input type = "number" min = { 0 } name = "reps" inputMode = "numeric" className = "text-sm bg-white/10 text-white mr-2 py-1 px-2 w-8 align-middle" defaultValue = { reps } onChange = { ( e ) => updateSet ( indexExercise , indexSet , 'reps' , Number ( e . target . value ) ) } /> reps</ td >
224
+ < td className = "w-4/12 text-center pb-2 text-white/50" > < input type = "number" min = { 0 } max = { 99 } name = "reps" inputMode = "numeric" className = "text-sm bg-white/10 text-white mr-2 py-1 px-2 w-8 align-middle" defaultValue = { reps } onChange = { ( e ) => updateSet ( indexExercise , indexSet , 'reps' , Number ( e . target . value ) ) } /> reps</ td >
221
225
< td className = "w-1/12 text-center pb-2 pl-2" > < RemoveIcon className = "h-4 w-auto fill-destructive/80" onClick = { ( ) => deleteSet ( indexExercise , indexSet ) } /> </ td >
222
226
</ tr >
223
227
)
@@ -240,7 +244,7 @@ export default function TrackWorkout({ params, template } : { params?: { workout
240
244
< div className = "modal-background absolute m-auto right-0 bottom-0 left-0 w-full h-full bg-black/80" >
241
245
{
242
246
( modals . type == "addExercise" ) &&
243
- < div className = "modal absolute flex flex-col m-auto right-0 bottom-0 left-0 w-full max-w-screen-md mx-auto h-3 /6 bg-secondary rounded-t-3xl" >
247
+ < div className = "modal absolute flex flex-col m-auto right-0 bottom-0 left-0 w-full max-w-screen-md mx-auto h-5 /6 bg-secondary rounded-t-3xl" >
244
248
< div className = "flex" >
245
249
< h2 className = "text-2xl font-bold m-6 mb-2 flex-1" > Selecionar exercício</ h2 >
246
250
< RemoveIcon className = "m-6 mb-2 fill-white" onClick = { ( ) => closeModal ( ) } />
@@ -350,6 +354,11 @@ export default function TrackWorkout({ params, template } : { params?: { workout
350
354
{
351
355
( modals . type == "finishWorkout" ) &&
352
356
< div className = "modal absolute flex flex-col m-auto right-0 bottom-0 left-0 w-full max-w-screen-md mx-auto h-3/6 bg-secondary rounded-t-3xl" >
357
+ {
358
+ ( workout && workout . exercises . length > 0
359
+ && workout ?. exercises [ 0 ] . sets [ 0 ] . reps
360
+ && workout ?. exercises [ 0 ] . sets [ 0 ] . reps > 0 ) ?
361
+ < >
353
362
< div className = "flex" >
354
363
< h2 className = "text-2xl font-bold m-6 mb-2 flex-1" > Dados do treino</ h2 >
355
364
< RemoveIcon className = "m-6 mb-2 fill-white" onClick = { ( ) => closeModal ( ) } />
@@ -365,6 +374,18 @@ export default function TrackWorkout({ params, template } : { params?: { workout
365
374
< textarea name = "workoutComment" className = "text-md px-2 py-1 rounded-lg bg-black/50 w-full h-24 resize-none" placeholder = "Comentário (opcional)" defaultValue = { workout ?. comment } onChange = { ( e ) => addMetaData ( "comment" , e . target . value ) } > </ textarea >
366
375
< Button link = "#" title = "Finalizar treino" action = { ( ) => finishWorkout ( ) } primary />
367
376
</ div >
377
+ </ >
378
+ :
379
+ < >
380
+ < div className = "flex" >
381
+ < h2 className = "text-2xl font-bold m-6 mb-2 flex-1" > Dados do treino</ h2 >
382
+ < RemoveIcon className = "m-6 mb-2 fill-white" onClick = { ( ) => closeModal ( ) } />
383
+ </ div >
384
+ < div className = "flex flex-col justify-center items-center h-full" >
385
+ < p className = "text-center text-white/25 align-middle" > Adicione pelo menos um set</ p >
386
+ </ div >
387
+ </ >
388
+ }
368
389
</ div >
369
390
}
370
391
</ div >
0 commit comments