Skip to content
Open
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
2 changes: 1 addition & 1 deletion .eslintcache

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/contexts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export const MenuContext = createContext();

export const ModalContext = createContext();

export const UtilityContext = createContext();
export const UtilityContext = createContext();

export const TutorialNotificationContext = createContext();
10 changes: 9 additions & 1 deletion src/hooks/alanAI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@ import programmingLanguageScraper from "./w3school_scrape/prorammingLanguageTuto
import allLinkScraper from "./w3school_scrape/allLinkScraper";
import oneLinkScraper from "./w3school_scrape/oneLinkScraper";
import { INTENTS } from "./intents";
import { useToastify } from "../providers/TutorialNotificationProvider.js";

// Use asynchronous to make the bot says before the alert popup
let key =
"16719338d8e08c6aff8745f74935071f2e956eca572e1d8b807a3e2338fdd0dc/stage";
export default function useAlan() {
const [alanInstance, setAlanInstance] = useState();

const { notification, setIsLoading } = useToastify();

// Give the answers
const showAllLinks = useCallback(() => {
alanInstance.playText("Links are");
allLinkScraper.scrape();
}, [alanInstance]);
const showNumberOfTutorial = useCallback(() => {
alanInstance.playText("These are number of tutorial that I know");

setIsLoading(true);

notification();

programmingLanguageScraper.scrape();
}, [alanInstance]);
}, [alanInstance, notification, setIsLoading]);
const showJavaInfo = useCallback(() => {
alanInstance.playText(
" If you want to learn more about Java please follow the link "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let programmingLanguageTutorialScraper = {
}
numberOfTutorial = resultList.length;

botSays("Number of tutorial that I know:" + numberOfTutorial);
// botSays("Number of tutorial that I know:" + numberOfTutorial);
}
});
},
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { logoutUser, getAuthUserData } from "./core/redux/actions/user.action";
import { getPostListDataTable } from "./core/redux/actions/post.action";
import { getAllCategories } from "./core/redux/actions/category.action";

// import { getNumberOfTutorial } from "./core/redux/actions/bot.action";

import { TutorialNotificationProvider } from "./providers/TutorialNotificationProvider.js";

// Styling
import "./assets/css/nucleo-icons.css";
Expand All @@ -38,7 +37,9 @@ store.dispatch(getAllCategories());

ReactDOM.render(
<Provider store={store}>
<App />
<TutorialNotificationProvider>
<App />
</TutorialNotificationProvider>
</Provider>,
document.getElementById("root")
);
Expand Down
36 changes: 36 additions & 0 deletions src/providers/TutorialNotificationProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useContext, useEffect, useState } from "react";
import { TutorialNotificationContext } from "../contexts/index.js";

export const useToastify = () => {
return useContext(TutorialNotificationContext);
};

export const Consumer = TutorialNotificationContext.Consumer;

export const TutorialNotificationProvider = ({ children, props }) => {
const [isLoading, setIsLoading] = useState(false);

const notification = () => {
if (isLoading) {
alert("SUCCESS");

setIsLoading(false);
}
};

useEffect(() => {
return () => {};
}, [isLoading]);

const value = {
notification,
isLoading,
setIsLoading,
};

return (
<TutorialNotificationContext.Provider value={value} {...props}>
{children}
</TutorialNotificationContext.Provider>
);
};
9 changes: 5 additions & 4 deletions src/variables/api.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import axios from "axios";
import { cookies, authorizationCookieName } from "./cookie.js";

let apiDomain =
process.env.NODE_ENV === "production"
? "https://developer-club-api.herokuapp.com/api"
: "http://localhost:5000/api";
// let apiDomain =
// process.env.NODE_ENV === "production"
// ? "https://developer-club-api.herokuapp.com/api"
// : "http://localhost:5000/api";
let apiDomain = "https://developer-club-api.herokuapp.com/api";

axios.defaults.baseURL = apiDomain;

Expand Down