Skip to content

Commit

Permalink
Merge pull request #5 from ShivangNagta/Shlok
Browse files Browse the repository at this point in the history
Linked 2nd and 3rd levels
  • Loading branch information
shlok923 authored Jul 10, 2024
2 parents f9afa58 + b90feb1 commit 7b3fe39
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
Empty file removed app/react-simple-chatbot.d.ts
Empty file.
8 changes: 7 additions & 1 deletion app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ import Noncense from './components/blockchain/Noncense.jsx';
import Intro2 from './components/blockchain/intro2.jsx';
import Window from './components/Window.jsx';
import Result from './components/Result.jsx';
import HelpBot from './components/HelpBot.jsx';

function App(){
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Login />} />
<Route path="/" element={
<>
<Window />
<HelpBot
level={2}/>
</>} />
{/* <Route path="/Level-1(1)" element={<Mandelbrot />} />
<Route path="/Level-1(2)" element={<MandelbrotFractal />} />
<Route path="/intro1" element={<Rain />} />
Expand Down
37 changes: 32 additions & 5 deletions app/src/components/HelpBot.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import ChatBot from "react-simple-chatbot";
import alluArjun from "../assets/alluArjun.png";
import ohMyGoddo from "../assets/ohMyGoddo.png";
import { useNavigate } from 'react-router-dom';

const HelpBot = ({ level = 1 }) => {

const navigate = useNavigate();

const getInitialSteps = (level) => {
if (level === 1) {
return [
Expand Down Expand Up @@ -100,17 +104,27 @@ const HelpBot = ({ level = 1 }) => {
id: "hacker-input",
user: true,
trigger: (inputValue) => {
if (inputValue === 'bad munda') {
return 'next-level';
console.log(inputValue.value);
console.log(inputValue.value === 'bad');
if (inputValue.value === 'bad') {
console.log('correct');
return 'congo-msg';
} else {
return 'wrong-ans';
}
},
},
{
id: "congo-msg",
message: "Correct answer! You found the hacker!",
trigger: 'next-level',
},
{
id: "next-level",
message: "Congrats, you found the hacker! Let's move on to blockchain now.",
trigger: 2,
component: (
<RedirectComponent navigate={navigate} />
),
end: true,
},
{
id: "wrong-ans",
Expand Down Expand Up @@ -177,4 +191,17 @@ const HelpBot = ({ level = 1 }) => {
);
};


const RedirectComponent = ({ navigate }) => {
useEffect(() => {
const timer = setTimeout(() => {
navigate('/intro2');
}, 2000);

return () => clearTimeout(timer);
}, [navigate]);

return <div>Redirecting to the next level...</div>;
};

export default HelpBot;

0 comments on commit 7b3fe39

Please sign in to comment.