From a78e909b3e675d3de7c6f934b7b0133e290d03fa Mon Sep 17 00:00:00 2001
From: Ahammed Irfan Ali <69192055+irfanpa005@users.noreply.github.com>
Date: Thu, 2 Nov 2023 00:32:39 +0530
Subject: [PATCH 1/4] refactor(APIs): Removed all APIs.
---
src/App.js | 38 -----------
.../Bootcamps/IGBootcamps/IGBootcamp.jsx | 26 -------
src/Pages/LearningCircles/Create/Create.jsx | 56 ---------------
.../GettingStarted/GettingStarted.jsx | 26 -------
src/Pages/LearningCircles/Home/Home.jsx | 41 -----------
src/Pages/LearningCircles/Join/Join.jsx | 68 -------------------
.../ChallengeType/ChallengeForm.jsx | 7 +-
.../TypingMastery/TypingMastery.jsx | 15 +---
src/Pages/Practice/OpenSource/OpenSource.jsx | 14 +---
.../MentorDirectory/MentorDirectory.jsx | 17 +----
src/Pages/Search/Search/Search.jsx | 42 ------------
src/Utils/SheetAPI.js | 10 +--
12 files changed, 8 insertions(+), 352 deletions(-)
diff --git a/src/App.js b/src/App.js
index 12a17cd9..cdc8197f 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
-import axios from "axios";
//LearningCirlces Section
import Home from "./Pages/LearningCircles/Home/Home";
@@ -123,43 +122,6 @@ function App() {
phone: "",
});
- useEffect(() => {
- if (!districts) {
- axios
- .get(`${process.env.REACT_APP_BACKEND_URL}/districts`)
- .then(function (response) {
- setDistricts(response.data.data);
- })
- .catch(function (error) {
- console.log(error);
- setBackenderr(true);
- });
- }
-
- if (!interests) {
- axios
- .get(`${process.env.REACT_APP_BACKEND_URL}/interests`)
- .then(function (response) {
- setInterests(response.data.data);
- })
- .catch(function (error) {
- console.log(error);
- });
- }
-
- if (district) {
- axios
- .get(`${process.env.REACT_APP_BACKEND_URL}/colleges/${district}`)
- .then(function (response) {
- setColleges(response.data.data);
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [district, college]);
-
return (
diff --git a/src/Pages/Bootcamps/IGBootcamps/IGBootcamp.jsx b/src/Pages/Bootcamps/IGBootcamps/IGBootcamp.jsx
index 3e01ae58..2ce5bd82 100644
--- a/src/Pages/Bootcamps/IGBootcamps/IGBootcamp.jsx
+++ b/src/Pages/Bootcamps/IGBootcamps/IGBootcamp.jsx
@@ -6,7 +6,6 @@ import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { useParams } from "react-router-dom";
-import axios from "axios";
const IGBootcamp = () => {
const { id } = useParams();
@@ -19,31 +18,6 @@ const IGBootcamp = () => {
// return ;
// };
- useEffect(() => {
- axios
- .get(
- `https://opensheet.elk.sh/15EurXumruFeT9D9s7aJSR8r1Zv9a9-iQnA5CGPbx0Xg/${id}`
- )
- .then((response) => {
- setData(response.data);
- })
- .catch((error) => {
- console.log(error);
- });
-
- axios
- .get(
- "https://opensheet.elk.sh/15EurXumruFeT9D9s7aJSR8r1Zv9a9-iQnA5CGPbx0Xg/commondata"
- )
- .then((response) => {
- const commonData = response.data.filter((item) => item.ig === id);
- setCommonData(commonData[0]);
- })
- .catch((error) => {
- console.log(error);
- });
- }, [id]);
-
return (
<>
diff --git a/src/Pages/LearningCircles/Create/Create.jsx b/src/Pages/LearningCircles/Create/Create.jsx
index 9ee69b17..fb4d768f 100644
--- a/src/Pages/LearningCircles/Create/Create.jsx
+++ b/src/Pages/LearningCircles/Create/Create.jsx
@@ -12,7 +12,6 @@ import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select";
import Button from "@mui/material/Button";
-import axios from "axios";
import ReCAPTCHA from "react-google-recaptcha";
import CustomizedSnackbars from "../../../Components/SnackBar/SnackBar";
@@ -81,61 +80,6 @@ const Create = ({
setVerify(false);
const baseURL = `${process.env.REACT_APP_BACKEND_URL}/create`;
- axios
- .post(baseURL, {
- code: create.code,
- lead: {
- name: create.lead.name,
- email: create.lead.email,
- // discord_id: create.lead.discord_id,
- // karma: create.lead.karma,
- },
- passcode: create.passcode,
- college: create.college || college,
- phone: create.phone,
- recaptcha: token,
- interest: create.interest || interest,
- meet_place: create.meet_place,
- meet_time: create.meet_time,
- })
- .then((response) => {
- console.log(response);
- if (response.data.status === "success") {
- // setCreate({
- // code: "",
- // lead: {
- // name: "",
- // email: "",
- // },
- // passcode: "",
- // college: college,
- // phone: "",
- // interest: interest,
- // meet_place: "",
- // meet_time: "",
- // });
- setErrors("");
- setCompleted(true);
- setWLink(response.data.wa_url);
- confetti();
- }
- })
- .catch((error) => {
- if (error.response.status === 400) {
- if (error.response.data.detail) {
- setErrors(error.response.data.detail.errors);
- }
- setSnackError(error.response.data.message);
- } else if (
- error.response.status === 401 ||
- error.response.status === 500
- ) {
- setErrors(error.response.status);
- setSnackError(error.response.data.message);
- } else {
- setErrors("");
- }
- });
}
};
diff --git a/src/Pages/LearningCircles/GettingStarted/GettingStarted.jsx b/src/Pages/LearningCircles/GettingStarted/GettingStarted.jsx
index 5d7aa122..263aa975 100644
--- a/src/Pages/LearningCircles/GettingStarted/GettingStarted.jsx
+++ b/src/Pages/LearningCircles/GettingStarted/GettingStarted.jsx
@@ -4,8 +4,6 @@ import styles from "./GettingStarted.module.css";
import Navbar from "../../../Components/Navbar/Navbar";
import Footer from "../../../Components/Footer/Footer";
-
-import axios from "axios";
import InterestGroups from "../Home/data";
import { Box } from "@mui/system";
import Preloader from "../../../Components/Preloader/Preloader";
@@ -16,30 +14,6 @@ const GettingStarted = ({ create, wlink, join }) => {
const [redirect, setRedirect] = useState(false);
const [buttontext, setButtonText] = useState("Copy Joining Link");
const [resources, setResources] = useState();
- useEffect(() => {
- axios
- .get(
- `${process.env.REACT_APP_BACKEND_URL}/team/${
- join.code || create.code || id
- }`
- )
- .then(function (response) {
- setCircleData(response.data.data);
- console.log(response.data.data);
- setRedirect(false);
-
- setResources(
- InterestGroups.filter(function (interestgroups) {
- return interestgroups.id === response.data.data.interest;
- })
- );
- })
- .catch(function (error) {
- console.log(error);
- setRedirect(true);
- setCircleData(true);
- });
- }, [id, create, join]);
if (!redirect && circledata) {
return (
diff --git a/src/Pages/LearningCircles/Home/Home.jsx b/src/Pages/LearningCircles/Home/Home.jsx
index 91853b01..6e019ffd 100644
--- a/src/Pages/LearningCircles/Home/Home.jsx
+++ b/src/Pages/LearningCircles/Home/Home.jsx
@@ -12,7 +12,6 @@ import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select";
import Typography from "@mui/material/Typography";
-import axios from "axios";
import { Link } from "react-router-dom";
import Modal from "@mui/material/Modal";
@@ -68,47 +67,7 @@ const Home = ({
window.scrollTo(0, 0);
}, []);
- useEffect(() => {
- if (code) {
- axios
- .get(`${process.env.REACT_APP_BACKEND_URL}/team/${code}`)
- .then(function (response) {
- setMembers(response.data.data.members);
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- }, [code]);
-
- useEffect(() => {
- if (colleges) {
- setOptions(
- colleges.map((option) => {
- const firstLetter = option.name[0].toUpperCase();
- return {
- firstLetter: /[0-9]/.test(firstLetter) ? "0-9" : firstLetter,
- ...option,
- };
- })
- );
- }
- }, [colleges]);
- useEffect(() => {
- if (college && interest) {
- axios
- .get(
- `${process.env.REACT_APP_BACKEND_URL}/teams/${college}/${interest}`
- )
- .then(function (response) {
- setTeams(response.data.data);
- })
- .catch(function (error) {
- // console.log(error);
- });
- }
- }, [college, interest]);
const [summary, setSummary] = useState([])
useEffect(() => {
diff --git a/src/Pages/LearningCircles/Join/Join.jsx b/src/Pages/LearningCircles/Join/Join.jsx
index b3fbb0ae..d8f4fe10 100644
--- a/src/Pages/LearningCircles/Join/Join.jsx
+++ b/src/Pages/LearningCircles/Join/Join.jsx
@@ -7,7 +7,6 @@ import styles from "./Join.module.css";
import TextField from "@mui/material/TextField";
import Button from "@mui/material/Button";
-import axios from "axios";
import ReCAPTCHA from "react-google-recaptcha";
import CustomizedSnackbars from "../../../Components/SnackBar/SnackBar";
import CheckIcon from "@mui/icons-material/Check";
@@ -43,26 +42,6 @@ const Join = ({
}));
};
- useEffect(() => {
- const delayDebounceFn = setTimeout(() => {
- axios
- .get(
- `${process.env.REACT_APP_BACKEND_URL}/team/${join.code || code || id}`
- )
- .then(function (response) {
- setCollege(response.data.data.college.name);
- setMembers(response.data.data.members);
- setValid(true);
- })
- .catch(function (error) {
- setCollege();
- setMembers();
- setValid(false);
- });
- }, 3000);
-
- return () => clearTimeout(delayDebounceFn);
- }, [join.code, setCollege, setMembers, setValid, code, id]);
useEffect(() => {
window.scrollTo(0, 0);
@@ -79,54 +58,7 @@ const Join = ({
setToken();
setVerify(false);
const baseURL = `${process.env.REACT_APP_BACKEND_URL}/join`;
- axios
- .post(
- baseURL,
- {
- code: join.code || code,
- name: join.name,
- email: join.email,
- // discord_id: join.discord_id,
- // karma: join.karma,
- college: join.college,
- phone: join.phone,
- recaptcha: token,
- },
- {
- headers: {
- Authorization: pass,
- },
- }
- )
- .then((response) => {
- if (response.data.status === "success") {
- // setJoin({
- // code: "",
- // name: "",
- // email: "",
- // college: "",
- // phone: "",
- // });
- setErrors("");
- setCompleted(true);
- setWLink(response.data.wa_url);
- setPass("");
- confetti();
- }
- })
- .catch((error) => {
- if (error.response.status === 400) {
- if (error.response.data.detail) {
- setErrors(error.response.data.detail.errors);
- }
- setSnackError(error.response.data.message);
- } else if (error.response.status === 401) {
- setErrors(error.response.status);
- } else {
- setErrors("");
- }
- });
}
};
diff --git a/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx b/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx
index 45bff4d8..35a2e859 100644
--- a/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx
+++ b/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx
@@ -1,21 +1,18 @@
import React, { useEffect, useState } from 'react'
import "../TypingChallenge.module.css"
-import axios from 'axios'
import styles from "./Challenge.module.css"
import Rules from './Rules'
const ChallengeForm = ({ exportGoogleSheetData, getNumberOfDays, getCollege, setView }) => {
const [spreadsheetId, setSpreadsheetId] = useState("")
const [sheet, setSheet] = useState("")
const [update, setUpdate] = useState(false)
- const API = "https://opensheet.elk.sh/"
+
useEffect(() => {
// 83 is the length of spreadsheetId
if (spreadsheetId.length >= 83) {
try {
- axios.get(`${API + spreadsheetId.split("/")[5]}/${sheet}`)
- .then(res => res.data)
- .then(result => exportGoogleSheetData(result))
+
}
catch (err) {
// exportGoogleSheetData([])
diff --git a/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx b/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx
index c3ba57e3..5313d604 100644
--- a/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx
+++ b/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx
@@ -2,8 +2,6 @@ import React, { useEffect, useState } from "react"
import styles from "./TypingMastery.module.css"
import Navbar from "../../../../../Components/Navbar/Navbar"
import Footer from "../../../../../Components/Footer/Footer"
-import axios from "axios"
-
import { styled } from "@mui/material/styles"
import Table from "@mui/material/Table"
import TableBody from "@mui/material/TableBody"
@@ -37,18 +35,7 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
const TypingMastery = () => {
const [data, setData] = useState([])
- useEffect(() => {
- axios
- .get(
- "https://opensheet.elk.sh/1TeGv6a8jsIRX_7wRyokic_EatIbJ8a0TwMcziYDdp84/LeaderboardSheet"
- )
- .then((response) => {
- setData(response.data)
- })
- .catch((error) => {
- console.error(error)
- })
- }, [])
+
// Sort the data by number of days and last day participants
const sortedData = data.sort((a, b) => {
diff --git a/src/Pages/Practice/OpenSource/OpenSource.jsx b/src/Pages/Practice/OpenSource/OpenSource.jsx
index e5e4d098..f83e8990 100644
--- a/src/Pages/Practice/OpenSource/OpenSource.jsx
+++ b/src/Pages/Practice/OpenSource/OpenSource.jsx
@@ -4,24 +4,12 @@ import styles from "./OpenSource.module.css";
import Navbar from "../../../Components/Navbar/Navbar";
import Footer from "../../../Components/Footer/Footer";
import OpenSourceCard from "../../../Components/OpenSourceCard/OpenSourceCard";
-import axios from "axios";
const OpenSource = () => {
const projects = require("./data.json");
const [fossprojects, setFossProjects] = useState([]);
- useEffect(() => {
- axios
- .get(
- "https://opensheet.elk.sh/1r5Pav8TlUEao_9GuMcFasKUEPSDIJOPB9PXKbt4KlTQ/fossprojects"
- )
- .then((response) => {
- setFossProjects(response.data);
- })
- .catch((error) => {
- console.log(error);
- });
- }, []);
+
return (
<>
diff --git a/src/Pages/Search/MentorDirectory/MentorDirectory.jsx b/src/Pages/Search/MentorDirectory/MentorDirectory.jsx
index 2600fc0c..fb8cac44 100644
--- a/src/Pages/Search/MentorDirectory/MentorDirectory.jsx
+++ b/src/Pages/Search/MentorDirectory/MentorDirectory.jsx
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from "react";
-import axios from "axios";
import Footer from "../../../Components/Footer/Footer";
import Navbar from "../../../Components/Navbar/Navbar";
import styles from "./MentorDirectory.module.css";
@@ -10,21 +9,7 @@ import MentorCard from "../../../Components/MentorCard/MentorCard";
const MentorDirectory = () => {
const [mentorData, setMentorData] = useState([]);
// const [error, setError] = useState();
- useEffect(() => {
- axios
- .get(
- "https://opensheet.elk.sh/1r5Pav8TlUEao_9GuMcFasKUEPSDIJOPB9PXKbt4KlTQ/mentordata"
- )
- .then((response) => {
- setMentorData(response.data);
- })
- .catch((error) => {
- console.log(error);
- // setError(
- // "We are currently facing some difficulties in fetching the data at the moment, will be back soon."
- // );
- });
- }, []);
+
return (
<>
diff --git a/src/Pages/Search/Search/Search.jsx b/src/Pages/Search/Search/Search.jsx
index ca160364..e58ab087 100644
--- a/src/Pages/Search/Search/Search.jsx
+++ b/src/Pages/Search/Search/Search.jsx
@@ -13,7 +13,6 @@ import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select";
import Typography from "@mui/material/Typography";
-import axios from "axios";
import { Link } from "react-router-dom";
import { Modal } from "@mui/material";
@@ -72,47 +71,6 @@ const Search = ({
}
}, [colleges]);
- useEffect(() => {
- if (code) {
- axios
- .get(`${process.env.REACT_APP_BACKEND_URL}/team/${code}`)
- .then(function (response) {
- setMembers(response.data.data.members);
- })
- .catch(function (error) {
- // console.log(error);
- });
- }
- }, [code]);
-
- useEffect(() => {
- if (college && interest) {
- axios
- .get(
- `${process.env.REACT_APP_BACKEND_URL}/teams/${college}/${interest}`
- )
- .then(function (response) {
- setTeams(response.data.data);
- })
- .catch(function (error) {
- // console.log(error);
- });
- }
- }, [college, interest]);
-
- useEffect(() => {
- if (code) {
- axios
- .get(`${process.env.REACT_APP_BACKEND_URL}/team/${code}`)
- .then(function (response) {
- setMembers(response.data.data.members);
- })
- .catch(function (error) {
- // console.log(error);
- });
- }
- }, [code]);
-
return (
<>
diff --git a/src/Utils/SheetAPI.js b/src/Utils/SheetAPI.js
index 6c97b870..c74ea31b 100644
--- a/src/Utils/SheetAPI.js
+++ b/src/Utils/SheetAPI.js
@@ -1,17 +1,13 @@
-import axios from "axios"
+
function SheetAPI(spreadsheetId, sheetName, setData) {
if (spreadsheetId === undefined || sheetName === undefined) {
return undefined
}
- const API = "https://opensheet.elk.sh/"
+
if (spreadsheetId?.length >= 83) {
try {
- axios.get(`${API + spreadsheetId.split("/")[5]}/${sheetName}`)
- .then(res => res.data)
- .then(result => {
- setData(result)
- })
+
}
catch (err) {
console.error(err)
From 3d96e308877727c37818239b091955db3b9a3c28 Mon Sep 17 00:00:00 2001
From: Ahammed Irfan Ali <69192055+irfanpa005@users.noreply.github.com>
Date: Thu, 2 Nov 2023 00:42:26 +0530
Subject: [PATCH 2/4] "fix(content): changed karma points in 'intro-to-html'
from 100 to 200."
---
src/Pages/Practice/Challenges/IntroToHtml/IntroToHtml.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Pages/Practice/Challenges/IntroToHtml/IntroToHtml.jsx b/src/Pages/Practice/Challenges/IntroToHtml/IntroToHtml.jsx
index fd59c3db..9bae6a00 100644
--- a/src/Pages/Practice/Challenges/IntroToHtml/IntroToHtml.jsx
+++ b/src/Pages/Practice/Challenges/IntroToHtml/IntroToHtml.jsx
@@ -24,7 +24,7 @@ const IntroToHtml = () => {
building your own cat photo app.
- On Completion Earn 100 Karma Points
+ On Completion Earn 200 Karma Points
From 2f5e03173b2a67ae36ea6324bfe3b71684a484f4 Mon Sep 17 00:00:00 2001
From: Ahammed Irfan Ali <69192055+irfanpa005@users.noreply.github.com>
Date: Thu, 2 Nov 2023 00:47:18 +0530
Subject: [PATCH 3/4] "fix(page removal): removed the page
'challenge/defensivedriving' "
---
src/App.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/App.js b/src/App.js
index cdc8197f..67165bd0 100644
--- a/src/App.js
+++ b/src/App.js
@@ -257,10 +257,10 @@ function App() {
path="/challenge/traffic-light-simulation"
element={}
/>
- }
- />
+ /> */}
} />
Date: Thu, 2 Nov 2023 20:59:52 +0530
Subject: [PATCH 4/4] refactor(APIs): reverted some Removed APIs.
---
.../ChallengeType/ChallengeForm.jsx | 7 ++++++-
.../TypingMastery/TypingMastery.jsx | 13 +++++++++++++
src/Pages/Practice/OpenSource/OpenSource.jsx | 14 ++++++++++++++
.../Search/MentorDirectory/MentorDirectory.jsx | 16 ++++++++++++++++
src/Utils/SheetAPI.js | 8 +++++++-
5 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx b/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx
index 35a2e859..d1b1b1bd 100644
--- a/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx
+++ b/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx
@@ -1,18 +1,23 @@
import React, { useEffect, useState } from 'react'
import "../TypingChallenge.module.css"
+import axios from 'axios'
import styles from "./Challenge.module.css"
import Rules from './Rules'
const ChallengeForm = ({ exportGoogleSheetData, getNumberOfDays, getCollege, setView }) => {
const [spreadsheetId, setSpreadsheetId] = useState("")
const [sheet, setSheet] = useState("")
const [update, setUpdate] = useState(false)
+ const API = "https://opensheet.elk.sh/"
useEffect(() => {
// 83 is the length of spreadsheetId
if (spreadsheetId.length >= 83) {
try {
-
+ axios.get(`${API + spreadsheetId.split("/")[5]}/${sheet}`)
+ .then(res => res.data)
+ .then(result => exportGoogleSheetData(result))
+
}
catch (err) {
// exportGoogleSheetData([])
diff --git a/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx b/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx
index 5313d604..b79258e0 100644
--- a/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx
+++ b/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react"
import styles from "./TypingMastery.module.css"
import Navbar from "../../../../../Components/Navbar/Navbar"
import Footer from "../../../../../Components/Footer/Footer"
+import axios from "axios"
import { styled } from "@mui/material/styles"
import Table from "@mui/material/Table"
import TableBody from "@mui/material/TableBody"
@@ -35,6 +36,18 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
const TypingMastery = () => {
const [data, setData] = useState([])
+ useEffect(() => {
+ axios
+ .get(
+ "https://opensheet.elk.sh/1TeGv6a8jsIRX_7wRyokic_EatIbJ8a0TwMcziYDdp84/LeaderboardSheet"
+ )
+ .then((response) => {
+ setData(response.data)
+ })
+ .catch((error) => {
+ console.error(error)
+ })
+ }, [])
// Sort the data by number of days and last day participants
diff --git a/src/Pages/Practice/OpenSource/OpenSource.jsx b/src/Pages/Practice/OpenSource/OpenSource.jsx
index f83e8990..33a0c589 100644
--- a/src/Pages/Practice/OpenSource/OpenSource.jsx
+++ b/src/Pages/Practice/OpenSource/OpenSource.jsx
@@ -4,11 +4,25 @@ import styles from "./OpenSource.module.css";
import Navbar from "../../../Components/Navbar/Navbar";
import Footer from "../../../Components/Footer/Footer";
import OpenSourceCard from "../../../Components/OpenSourceCard/OpenSourceCard";
+import axios from "axios";
const OpenSource = () => {
const projects = require("./data.json");
const [fossprojects, setFossProjects] = useState([]);
+ useEffect(() => {
+ axios
+ .get(
+ "https://opensheet.elk.sh/1r5Pav8TlUEao_9GuMcFasKUEPSDIJOPB9PXKbt4KlTQ/fossprojects"
+ )
+ .then((response) => {
+ setFossProjects(response.data);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ }, []);
+
return (
<>
diff --git a/src/Pages/Search/MentorDirectory/MentorDirectory.jsx b/src/Pages/Search/MentorDirectory/MentorDirectory.jsx
index fb8cac44..33063d14 100644
--- a/src/Pages/Search/MentorDirectory/MentorDirectory.jsx
+++ b/src/Pages/Search/MentorDirectory/MentorDirectory.jsx
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react";
+import axios from "axios";
import Footer from "../../../Components/Footer/Footer";
import Navbar from "../../../Components/Navbar/Navbar";
import styles from "./MentorDirectory.module.css";
@@ -9,6 +10,21 @@ import MentorCard from "../../../Components/MentorCard/MentorCard";
const MentorDirectory = () => {
const [mentorData, setMentorData] = useState([]);
// const [error, setError] = useState();
+ useEffect(() => {
+ axios
+ .get(
+ "https://opensheet.elk.sh/1r5Pav8TlUEao_9GuMcFasKUEPSDIJOPB9PXKbt4KlTQ/mentordata"
+ )
+ .then((response) => {
+ setMentorData(response.data);
+ })
+ .catch((error) => {
+ console.log(error);
+ // setError(
+ // "We are currently facing some difficulties in fetching the data at the moment, will be back soon."
+ // );
+ });
+ }, []);
return (
<>
diff --git a/src/Utils/SheetAPI.js b/src/Utils/SheetAPI.js
index c74ea31b..6bafe9f4 100644
--- a/src/Utils/SheetAPI.js
+++ b/src/Utils/SheetAPI.js
@@ -1,12 +1,18 @@
-
+import axios from "axios"
function SheetAPI(spreadsheetId, sheetName, setData) {
if (spreadsheetId === undefined || sheetName === undefined) {
return undefined
}
+ const API = "https://opensheet.elk.sh/"
if (spreadsheetId?.length >= 83) {
try {
+ axios.get(`${API + spreadsheetId.split("/")[5]}/${sheetName}`)
+ .then(res => res.data)
+ .then(result => {
+ setData(result)
+ })
}
catch (err) {