Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked 2nd and 3rd levels #5

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;