From 6ba5d2a9184626c0727933f62aa78914ce434c96 Mon Sep 17 00:00:00 2001 From: Ravindra <42912207+KR-Ravindra@users.noreply.github.com> Date: Fri, 27 Oct 2023 20:43:19 -0700 Subject: [PATCH] Handling Errors like today --- src/api/keyword.js | 1 + src/api/multiAlgo.js | 2 + src/api/recommendation.js | 1 + src/api/scraperText.js | 3 + src/components/homePage/index.js | 96 ++++++++++++++++++++++++++------ 5 files changed, 86 insertions(+), 17 deletions(-) diff --git a/src/api/keyword.js b/src/api/keyword.js index 425f150..2098d83 100644 --- a/src/api/keyword.js +++ b/src/api/keyword.js @@ -21,6 +21,7 @@ async function keywordList(payload) { return final_response; } catch (error) { console.error("Error fetching scraper text:", error); + window.location.reload(); return []; } } diff --git a/src/api/multiAlgo.js b/src/api/multiAlgo.js index 617d598..cea4290 100644 --- a/src/api/multiAlgo.js +++ b/src/api/multiAlgo.js @@ -16,11 +16,13 @@ async function multialgoComparision(payload) { .then(data => { console.log('API response:', data); final_response = data + return data }) return final_response; } catch (error) { console.error("Error fetching scraper text:", error); + window.location.reload(); return []; } } diff --git a/src/api/recommendation.js b/src/api/recommendation.js index 05ae51b..616ee96 100644 --- a/src/api/recommendation.js +++ b/src/api/recommendation.js @@ -21,6 +21,7 @@ async function RecommendationList(payload) { return final_response; } catch (error) { console.error("Error fetching scraper text:", error); + window.location.reload(); return []; } } diff --git a/src/api/scraperText.js b/src/api/scraperText.js index ca470f1..8988383 100644 --- a/src/api/scraperText.js +++ b/src/api/scraperText.js @@ -18,6 +18,9 @@ .then(data => { console.log('API response:', data); final_response = data + if (data == null || data.length == 0) { + window.location.reload(); + } return data }) return final_response; diff --git a/src/components/homePage/index.js b/src/components/homePage/index.js index e7fb39f..2bf6c22 100644 --- a/src/components/homePage/index.js +++ b/src/components/homePage/index.js @@ -16,7 +16,7 @@ import WordCloud from "./wordCloud"; function HomePage() { const [urlInput, setUrlInput] = useState(""); - const [selectedAlgorithm, setSelectedAlgorithm] = useState("rabin_karp"); + const [selectedAlgorithm, setSelectedAlgorithm] = useState("suffix_array"); const [loading, setLoading] = useState(false); const [scraperData, setScraperData] = useState(""); const [keywordListData, setKeywordListData] = useState(""); @@ -26,6 +26,7 @@ function HomePage() { const [scrollPosition, setScrollPosition] = useState(0); const [scrollUp, setScrollUp] = useState(false); const [resetScroll, setResetScroll] = useState(false); + const [started, setStarted] = useState(false); useEffect(() => { const container = document.getElementById("pdf-container"); @@ -65,6 +66,7 @@ function HomePage() { }; const handleSubmit = () => { + setStarted(true); setScraperData(""); setKeywordListData(""); setMultialgo(""); @@ -106,7 +108,19 @@ function HomePage() { const keywordListData = keywordList(payload); keywordListData - .then((response) => setKeywordListData(response)) + .then((response) => { + setKeywordListData(response) + + const multialgoComparision = MultiAlgoComparision(payload); + multialgoComparision + .then((response) => setMultialgo(response)) + .catch((error) => { + console.error("API error:", error); + }) + .finally(() => { + setLoading(false); + }); + }) .catch((error) => { console.error("API error:", error); }) @@ -123,15 +137,7 @@ function HomePage() { console.log("Finalised"); }); - const multialgoComparision = MultiAlgoComparision(payload); - multialgoComparision - .then((response) => setMultialgo(response)) - .catch((error) => { - console.error("API error:", error); - }) - .finally(() => { - setLoading(false); - }); + const urlAnalyzerData = AnalyzerList(payload); urlAnalyzerData @@ -205,10 +211,47 @@ function HomePage() { analyzerData={analyzerData} /> )} + + + { started && !keywordListData && ( + +
+
+
+
+
+
+
+
+
+
+
+
+ + )} + {scraperData && keywordListData && ( )} + + { started && !recommendationListData && ( + +
+
+
+
+
+
+
+
+
+
+
+
+ + )} + {scraperData && keywordListData && recommendationListData && (
)} + { scraperData && keywordListData && recommendationListData && analyzerData && (
- {scraperData && keywordListData && recommendationListData && ( + - )} +
- {scraperData && analyzerData && recommendationListData && ( + - )} +
- {scraperData && analyzerData && recommendationListData && ( + - )} +
+ )} + { started && !keywordListData && !multialgo && ( + +
+
+
+
+
+
+
+
+
+
+
+
+ + )} + {scraperData && keywordListData && multialgo &&