diff --git a/src/App.js b/src/App.js index 12a17cd9..67165bd0 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 (
@@ -295,10 +257,10 @@ function App() { path="/challenge/traffic-light-simulation" element={} /> - } - /> + /> */} } /> { 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/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

diff --git a/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx b/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx index 45bff4d8..d1b1b1bd 100644 --- a/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx +++ b/src/Pages/Practice/Challenges/TypingChallenge/ChallengeType/ChallengeForm.jsx @@ -9,13 +9,15 @@ const ChallengeForm = ({ exportGoogleSheetData, getNumberOfDays, getCollege, set 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)) + .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..b79258e0 100644 --- a/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx +++ b/src/Pages/Practice/Challenges/TypingChallenge/TypingMastery/TypingMastery.jsx @@ -3,7 +3,6 @@ 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" @@ -50,6 +49,7 @@ const TypingMastery = () => { }) }, []) + // Sort the data by number of days and last day participants const sortedData = data.sort((a, b) => { const aDays = Object.keys(a).filter((key) => key.startsWith("day")).length diff --git a/src/Pages/Practice/OpenSource/OpenSource.jsx b/src/Pages/Practice/OpenSource/OpenSource.jsx index e5e4d098..33a0c589 100644 --- a/src/Pages/Practice/OpenSource/OpenSource.jsx +++ b/src/Pages/Practice/OpenSource/OpenSource.jsx @@ -22,6 +22,8 @@ const OpenSource = () => { console.log(error); }); }, []); + + return ( <> diff --git a/src/Pages/Search/MentorDirectory/MentorDirectory.jsx b/src/Pages/Search/MentorDirectory/MentorDirectory.jsx index 2600fc0c..33063d14 100644 --- a/src/Pages/Search/MentorDirectory/MentorDirectory.jsx +++ b/src/Pages/Search/MentorDirectory/MentorDirectory.jsx @@ -25,6 +25,7 @@ const MentorDirectory = () => { // ); }); }, []); + 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..6bafe9f4 100644 --- a/src/Utils/SheetAPI.js +++ b/src/Utils/SheetAPI.js @@ -5,13 +5,15 @@ function SheetAPI(spreadsheetId, sheetName, setData) { 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) - }) + .then(res => res.data) + .then(result => { + setData(result) + }) + } catch (err) { console.error(err)