@@ -6,7 +6,6 @@ import { Challenge } from "../../../staticData/challenges"
66import { useTranslation } from "react-i18next"
77import { EndDialog } from "./EndChallengeDialog"
88import { useInterpreterRunner } from "./useInterpreterRunner"
9- import { useState } from "react"
109
1110type ExecuteButtonProps = {
1211 challenge : Challenge
@@ -20,34 +19,14 @@ export const ExecuteButton = ({ challenge, running, setRunning, interpreterVersi
2019
2120 const { isSmallScreen } = useThemeContext ( )
2221 const { t } = useTranslation ( 'challenge' )
23- const [ hasFinished , setHasFinished ] = useState ( false ) ;
2422
2523 const { run, showModal, setShowModal } = useInterpreterRunner ( challenge , setRunning , 'run' , interpreterVersion ) ;
2624
27- const handleRun = async ( ) => {
28- setHasFinished ( false ) ;
29- setRunning ! ( true ) ;
30- await run ( ) ;
31- // Marcar que terminó pero no cambiar running a false
32- setHasFinished ( true ) ;
33- } ;
34-
35- const handleRestart = ( ) => {
36- if ( onRestart ) {
37- onRestart ( ) ;
38- }
39- setHasFinished ( false ) ;
40- setRunning ! ( false ) ;
41- } ;
42-
43- // Determinar qué estado mostrar
44- const showRestartState = running || hasFinished ;
45-
4625 return < >
47- { showRestartState ? (
26+ { running ? (
4827 < Tooltip title = { t ( 'restart.tooltip' ) } >
4928 { isSmallScreen ?
50- < IconButton className = { styles [ 'icon-button' ] } onClick = { handleRestart }
29+ < IconButton className = { styles [ 'icon-button' ] } onClick = { onRestart }
5130 data-testid = 'execute-button' data-finishedexecution = { false } >
5231 < Stack >
5332 < Circle color = 'secondary' className = { styles [ 'circle-icon' ] } />
@@ -57,19 +36,19 @@ export const ExecuteButton = ({ challenge, running, setRunning, interpreterVersi
5736 :
5837 < Button className = { styles [ 'scene-button' ] }
5938 sx = { { color : '#fff' } }
60- startIcon = { < ReplayOutlined /> } variant = "contained" color = "secondary" onClick = { handleRestart } data-finishedexecution = { false } data-testid = 'execute-button' > { t ( "restart.label" ) } </ Button >
39+ startIcon = { < ReplayOutlined /> } variant = "contained" color = "secondary" onClick = { onRestart } data-finishedexecution = { false } data-testid = 'execute-button' > { t ( "restart.label" ) } </ Button >
6140 }
6241 </ Tooltip > ) : (
6342 < Tooltip title = { t ( 'run.tooltip' ) } >
6443 { isSmallScreen ?
65- < IconButton className = { styles [ 'icon-button' ] } onClick = { handleRun } data-testid = 'execute-button' data-finishedexecution = { true } >
44+ < IconButton className = { styles [ 'icon-button' ] } onClick = { run } data-testid = 'execute-button' data-finishedexecution = { true } >
6645 < Stack >
6746 < Circle color = 'success' className = { styles [ 'circle-icon' ] } />
6847 < PlayArrow className = { styles [ 'icon' ] } />
6948 </ Stack >
7049 </ IconButton >
7150 :
72- < Button className = { styles [ 'scene-button' ] } startIcon = { < PlayArrow /> } variant = "contained" color = "success" onClick = { handleRun } data-finishedexecution = { true } data-testid = 'execute-button' > { t ( "run.label" ) } </ Button >
51+ < Button className = { styles [ 'scene-button' ] } startIcon = { < PlayArrow /> } variant = "contained" color = "success" onClick = { run } data-finishedexecution = { true } data-testid = 'execute-button' > { t ( "run.label" ) } </ Button >
7352 }
7453 </ Tooltip >
7554 ) }
0 commit comments