@@ -7,7 +7,11 @@ import Editor, { Monaco } from "@monaco-editor/react";
77import { Flex , useColorMode } from "@chakra-ui/react" ;
88import { useEffect , useState , useRef } from "react" ;
99import MyBtn from "../MyBtn" ;
10- import { tryFormattingCode , validateCode } from "@/lib/client-functions" ;
10+ import {
11+ isTheTourCompleted ,
12+ tryFormattingCode ,
13+ validateCode ,
14+ } from "@/lib/client-functions" ;
1115import FiChevronRight from "@/app/styles/icons/HiChevronRightGreen" ;
1216import { useRouter } from "next/navigation" ;
1317import { useUserSolutionStore , useEditorStore } from "@/lib/stores" ;
@@ -109,6 +113,11 @@ const EditorControls = ({
109113 outputResult : OutputResult ;
110114} ) => {
111115 const router = useRouter ( ) ;
116+ const [ isTheTourCompletedState , setIsTheTourCompletedState ] =
117+ useState ( isTheTourCompleted ( ) ) ;
118+ useEffect ( ( ) => {
119+ setIsTheTourCompletedState ( isTheTourCompleted ( ) ) ;
120+ } , [ isTheTourCompleted ( ) ] ) ;
112121
113122 return (
114123 < div className = { styles . buttonsWrapper } >
@@ -128,27 +137,27 @@ const EditorControls = ({
128137 Reset
129138 </ MyBtn >
130139 </ Flex >
131- { nextStepPath ? (
140+ { ! nextStepPath || isTheTourCompletedState ? (
132141 < >
133- < MyBtn
134- onClick = { ( ) => router . push ( "/" + nextStepPath ) }
135- variant = {
136- outputResult . validityStatus === "valid" ? "default" : "success"
137- }
138- size = { outputResult . validityStatus === "valid" ? "sm" : "xs" }
139- >
140- Next < span style = { { marginLeft : "4px" } } > </ span >
141- < FiChevronRight
142- color = {
143- outputResult . validityStatus === "valid"
144- ? "white"
145- : "hsl(var(--success))"
146- }
147- />
148- </ MyBtn >
142+ < CertificateButton />
149143 </ >
150144 ) : (
151- < CertificateButton />
145+ < MyBtn
146+ onClick = { ( ) => router . push ( "/" + nextStepPath ) }
147+ variant = {
148+ outputResult . validityStatus === "valid" ? "default" : "success"
149+ }
150+ size = { outputResult . validityStatus === "valid" ? "sm" : "xs" }
151+ >
152+ Next < span style = { { marginLeft : "4px" } } > </ span >
153+ < FiChevronRight
154+ color = {
155+ outputResult . validityStatus === "valid"
156+ ? "white"
157+ : "hsl(var(--success))"
158+ }
159+ />
160+ </ MyBtn >
152161 ) }
153162 </ div >
154163 ) ;
0 commit comments