Skip to content

Commit

Permalink
backend url added
Browse files Browse the repository at this point in the history
  • Loading branch information
Luxshan2000 committed Oct 27, 2023
1 parent 966d8de commit 8807679
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion backend/src/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const signup = async (req, res, isWeb) => {



const { email, password, name } = req.body;
let { email, password, name } = req.body;
email = email.toLowerCase()
const isAdmin = false

Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/FacebookLoginButton.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import FacebookLogin from '@greatsumini/react-facebook-login';
import axios from 'axios';
import { BACKEND_URL } from '../utils/constants';
const FacebookLoginButton = () => {
const responseMessage = (response) => {
console.log(response)
axios.post('http://localhost:5000/api/auth/facebookLogin', { token: response.accessToken , userID : response.userID })
axios.post(`${BACKEND_URL}/api/auth/facebookLogin`, { token: response.accessToken , userID : response.userID })
.then(response => {
// Handle the successful response here
console.log(response.data);
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/GoogleLoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { GoogleLogin, useGoogleLogin } from '@react-oauth/google';
import axios from 'axios';
import Button from 'react-bootstrap/Button';
import { useNavigate } from 'react-router-dom';
import { BACKEND_URL } from '../utils/constants';


function GoogleLoginButton() {
const navigate = useNavigate()
const responseMessage = (response) => {
axios.defaults.withCredentials = true
axios.post('http://localhost:5000/api/auth/googleLogin', { token: response.access_token })
axios.post(`${BACKEND_URL}/api/auth/googleLogin`, { token: response.access_token })
.then(response => {
// Handle the successful response here
console.log(response.data);
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/components/PasswordVerify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Col from 'react-bootstrap/Col';
import { getSessionCookie } from "../utils/cookie";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import { BACKEND_URL } from "../utils/constants";

export default function PasswordVerify() {
const navigate = useNavigate()
Expand All @@ -25,7 +26,7 @@ export default function PasswordVerify() {
//18.61.20.118
axios.defaults.withCredentials = true
const otp = digit1+""+ digit2 + "" + digit3 + "" + digit4
axios.post('http://localhost:5000/api/auth/verifyotp', {token: getSessionCookie('token'), otp: otp})
axios.post(`${BACKEND_URL}/api/auth/verifyotp`, {token: getSessionCookie('token'), otp: otp})
.then(response => {
// Handle the successful response here
console.log('Verification successful!', response.data);
Expand All @@ -49,7 +50,7 @@ export default function PasswordVerify() {

const resendRequest= ()=>{
axios.defaults.withCredentials = true
axios.post('http://localhost:5000/api/auth/resend')
axios.post(`${BACKEND_URL}/api/auth/resend`)
.then(res=>{
console.log("Sent!")
}).catch(err=>{
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/PracticeExamView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import Card from 'react-bootstrap/Card'
import FrameComponent from '../components/FrameComponent'
import { Link } from 'react-router-dom'
import axios from 'axios'
import { BACKEND_URL } from '../utils/constants'
function PracticeExamView() {
const [tests,setTests] = useState([])
useEffect(() => {
axios.defaults.withCredentials = true
axios.get('http://localhost:5000/api/practiceQuizzes/getPracticeQuizPapers')
axios.get(`${BACKEND_URL}/api/practiceQuizzes/getPracticeQuizPapers`)
.then(response => {
// Handle the successful response here
//[{quizNumber : 1,time : 20,questions : [],user_quiz : [{id : 1,grade : '10'}]},{quizNumber : 1,time : 20,questions : []},{quizNumber : 1,time : 20,questions : []},]
Expand Down
1 change: 1 addition & 0 deletions webapp/src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const BACKEND_URL = "http://localhost:5000";
3 changes: 2 additions & 1 deletion webapp/src/utils/logout.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react'
import axios from 'axios';
import { BACKEND_URL } from './constants';

export const logout = () => {
axios.defaults.withCredentials = true
console.log("clciked")
// Add logout functionality here
axios.post("http://localhost:5000/api/auth/logout")
axios.post(`${BACKEND_URL}/api/auth/logout`)
.then((res)=>{
window.location.reload(true);
window.location.href = "/";
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/ContentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FrameComponent from '../components/FrameComponent'
import ScriptComponent from '../components/ScriptComponent'
import VideoComponent from '../components/VideoComponent'
import axios from 'axios'
import { BACKEND_URL } from '../utils/constants'

function ContentView() {
const { id } = useParams()
Expand All @@ -13,7 +14,7 @@ function ContentView() {

useEffect(()=>{
axios.defaults.withCredentials = true
axios.get(`http://localhost:5000/api/material/topic/${id}`)
axios.get(`${BACKEND_URL}/api/material/topic/${id}`)
.then(response => {
// Handle the successful response here
setHeading(response.data)
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/CourseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import OutFrame from '../components/OutFrame'
import FrameComponent from '../components/FrameComponent'
import axios from 'axios';
import Spinner from 'react-bootstrap/Spinner';
import { BACKEND_URL } from "../utils/constants";



Expand All @@ -15,7 +16,7 @@ function CourseView() {

useEffect(()=>{
axios.defaults.withCredentials = true
axios.get('http://localhost:5000/api/material/topics')
axios.get(`${BACKEND_URL}/api/material/topics`)
.then(response => {
// Handle the successful response here

Expand Down
7 changes: 4 additions & 3 deletions webapp/src/views/Exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QuestionComponent from '../components/QuestionComponent'
import axios from 'axios'
import Counter from '../components/Counter'
import { useNavigate, useParams } from 'react-router-dom';
import { BACKEND_URL } from '../utils/constants'

function Exam() {
const [question, setQuestion] = useState([])
Expand Down Expand Up @@ -45,7 +46,7 @@ function Exam() {
console.log(answers);

axios.defaults.withCredentials = true
axios.post(`http://localhost:5000/api/material/topic/quiz/answer/${id}`,answers)
axios.post(`${BACKEND_URL}/api/material/topic/quiz/answer/${id}`,answers)
.then(res=>{
console.log(res.data)
navigate(`/dashboard/quiz/view/${id}`, {replace:true})
Expand Down Expand Up @@ -78,7 +79,7 @@ function Exam() {


axios.defaults.withCredentials = true
axios.post(`http://localhost:5000/api/material/topic/quiz/answer/${id}`,answersTemp)
axios.post(`${BACKEND_URL}/api/material/topic/quiz/answer/${id}`,answersTemp)
.then(res=>{
console.log(res.data)
navigate(`/dashboard/quiz/view/${id}`, {replace:true})
Expand All @@ -92,7 +93,7 @@ function Exam() {

useEffect(()=>{
axios.defaults.withCredentials = true
axios.get(`http://localhost:5000/api/material/topic/quiz/${id}`)
axios.get(`${BACKEND_URL}/api/material/topic/quiz/${id}`)
.then(response => {
// Handle the successful response here
setQuestion(response.data.array.questions)
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import axios from 'axios';
import { getSessionCookie } from "../utils/cookie";
import jwt_decode from 'jwt-decode'
import GoogleLoginButton from "../components/GoogleLoginButton";
import { BACKEND_URL } from "../utils/constants";

export default function Login() {
const navigate = useNavigate()
Expand Down Expand Up @@ -52,7 +53,7 @@ export default function Login() {
setValidated(true)

axios.defaults.withCredentials = true
axios.post('http://localhost:5000/api/auth/login', {email:email, password:password})
axios.post(`${BACKEND_URL}/api/auth/login`, {email:email, password:password})
.then(response => {
// Handle the successful response here

Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/PracticeQuizView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import FrameComponent from '../components/FrameComponent'
import axios from 'axios'
import PracticeQuizComponent from '../components/PracticeQuizComponent'
import { Link, useLocation, useNavigate } from 'react-router-dom'
import { BACKEND_URL } from '../utils/constants'

function PracticeQuizView() {
let { state } = useLocation();
Expand Down Expand Up @@ -30,7 +31,7 @@ function PracticeQuizView() {
console.log("clicked")
console.log({ answers })
axios.defaults.withCredentials = true
axios.post('http://localhost:5000/api/practiceQuizzes/submitPracticeQuiz',
axios.post(`${BACKEND_URL}/api/practiceQuizzes/submitPracticeQuiz`,
{
userPracticePaper : answers,
quizNumber : quizNum,
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/ProgressView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from "rec
import '../assets/CSS/progressStyle.css';
import FrameComponent from '../components/FrameComponent';
import axios from 'axios';
import { BACKEND_URL } from "../utils/constants";

const BarRechartComponent = () => {
const [data, setData] = useState([]);

useEffect(() => {
axios.defaults.withCredentials = true;
axios.get('http://localhost:5000/api/material/getMarks')
axios.get(`${BACKEND_URL}/api/material/getMarks`)
.then(res => {
// Process the data to get maximum marks for each quiz
const processedData = processQuizData(res.data);
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/QuizView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link, useParams } from 'react-router-dom'
import FrameComponent from '../components/FrameComponent'
import { useModal } from '../context/ModalContext'
import axios from 'axios'
import { BACKEND_URL } from '../utils/constants'

function QuizView() {
const {setModal} = useModal()
Expand All @@ -25,7 +26,7 @@ function QuizView() {

useEffect(()=>{
axios.defaults.withCredentials = true
axios.get(`http://localhost:5000/api/material/topic/quiz/review/${id}`)
axios.get(`${BACKEND_URL}/api/material/topic/quiz/review/${id}`)
.then(res=>{
setReview(res.data.review)
setConti(res.data.continue)
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/Review.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QuestionComponent from '../components/QuestionComponent'
import axios from 'axios'
import Counter from '../components/Counter'
import { useNavigate, useParams } from 'react-router-dom';
import { BACKEND_URL } from '../utils/constants'

function Review() {

Expand Down Expand Up @@ -34,7 +35,7 @@ function Review() {
useEffect(()=>{
axios.defaults.withCredentials = true
// axios.get(`http://localhost:5000/api/material/topic/quiz/${id}`)
axios.get(`http://localhost:5000/api/material/topic/quiz/get/review/${rid}`)
axios.get(`${BACKEND_URL}/api/material/topic/quiz/get/review/${rid}`)
.then(response => {
// Handle the successful response here

Expand Down
3 changes: 2 additions & 1 deletion webapp/src/views/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import axios from 'axios';
import GoogleLoginButton from "../components/GoogleLoginButton";
import FacebookLoginButton from "../components/FacebookLoginButton";
import Spinner from 'react-bootstrap/Spinner';
import { BACKEND_URL } from "../utils/constants";


export default function SignUp() {
Expand Down Expand Up @@ -50,7 +51,7 @@ export default function SignUp() {
}
//18.61.20.118
axios.defaults.withCredentials = true
axios.post('http://localhost:5000/api/auth/signup', {email:email, password:password, name:userName})
axios.post(`${BACKEND_URL}/api/auth/signup`, {email:email, password:password, name:userName})
.then(response => {
// Handle the successful response here

Expand Down

0 comments on commit 8807679

Please sign in to comment.