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

refactor(APIs): Removed all APIs. #126

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
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
42 changes: 2 additions & 40 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 (
<div className="App">
<Router>
Expand Down Expand Up @@ -295,10 +257,10 @@ function App() {
path="/challenge/traffic-light-simulation"
element={<TrafficLightSimulation />}
/>
<Route
{/* <Route
path="/challenge/defensivedriving"
element={<DefensiveDriving />}
/>
/> */}
<Route path="/challenge/marathon" element={<MarathonChallenge />} />
<Route
path="/challenge/googlesolution"
Expand Down
26 changes: 0 additions & 26 deletions src/Pages/Bootcamps/IGBootcamps/IGBootcamp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -19,31 +18,6 @@ const IGBootcamp = () => {
// return <div dangerouslySetInnerHTML={{ __html: boldText }} />;
// };

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 (
<>
<Navbar />
Expand Down
56 changes: 0 additions & 56 deletions src/Pages/LearningCircles/Create/Create.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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("");
}
});
}
};

Expand Down
26 changes: 0 additions & 26 deletions src/Pages/LearningCircles/GettingStarted/GettingStarted.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 (
Expand Down
41 changes: 0 additions & 41 deletions src/Pages/LearningCircles/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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(() => {
Expand Down
68 changes: 0 additions & 68 deletions src/Pages/LearningCircles/Join/Join.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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("");
}
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Practice/Challenges/IntroToHtml/IntroToHtml.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const IntroToHtml = () => {
building your own cat photo app.
</p>
<p className={styles.fv_content_karma}>
On Completion Earn 100 Karma Points
On Completion Earn 200 Karma Points
</p>
</div>

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this change

Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand Down
Loading