From 20065f26e3d545471153ca65c9f98cf3d08a803b Mon Sep 17 00:00:00 2001 From: Nishant Kaushal <101548649+nishant0708@users.noreply.github.com> Date: Sun, 27 Oct 2024 00:16:19 +0530 Subject: [PATCH] updated --- .eslintrc.json | 45 ++++++++++--------- src/App.js | 2 +- src/Body/Body.jsx | 2 +- src/CompletedBody/CompletedBody.jsx | 2 +- src/CompletedEditor/CompletedEditor.jsx | 6 +-- src/CompletedNavbar/CompletedNavbar.jsx | 12 ++--- .../CompletedPaperDashboard.jsx | 4 +- .../CompletedPaperStudentDashboard.jsx | 12 ++--- src/Create_paper/Createpaper.jsx | 2 +- src/Edit_paper/Editpaper.jsx | 2 +- src/Forgot_Password/Forgot_Password.jsx | 2 +- src/Login/Login.jsx | 6 +-- src/Navbar/Navbar.jsx | 4 +- src/Profile/profile.jsx | 8 ++-- .../QuestionPaperDashboard.jsx | 12 ++--- .../ReadyPaperDashboard.jsx | 6 +-- .../ReadyQuestionPaperDashboard.jsx | 4 +- src/Reset_Password/Reset_Password.jsx | 2 +- src/Sign_up/SignUp.jsx | 2 +- src/Sign_up/VerifyOtp.jsx | 2 +- src/edit_question/EditQuestion.jsx | 6 +-- src/edit_ready_question/EditReadyQuestion.jsx | 6 +-- src/index.js | 1 + src/papers/papers.jsx | 6 +-- src/question/question.jsx | 6 +-- 25 files changed, 83 insertions(+), 79 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3621bd8..4caf9f2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,23 +1,24 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:react-hooks/recommended" - ], - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module", - "ecmaFeatures": { - "jsx": true - } - }, - "plugins": ["react", "react-hooks"], - "rules": { - "react/react-in-jsx-scope": "off" - } - } +{ + "env": { + "browser": true, + "node": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended" + ], + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "plugins": ["react", "react-hooks"], + "rules": { + "react/react-in-jsx-scope": "off" + } + } \ No newline at end of file diff --git a/src/App.js b/src/App.js index 8d730b0..8fb9396 100644 --- a/src/App.js +++ b/src/App.js @@ -40,7 +40,7 @@ const App = () => { if (sessionId) { axios - .post("iipsonlineexambackend-production.up.railway.app/teacher/verify-session", { sessionId }) + .post(`${process.env.REACT_APP_BACKEND_URL}/teacher/verify-session`, { sessionId }) .then((response) => { if (response.data.valid) { setIsAuthenticated(true); diff --git a/src/Body/Body.jsx b/src/Body/Body.jsx index 96ecc7a..dce79dd 100644 --- a/src/Body/Body.jsx +++ b/src/Body/Body.jsx @@ -17,7 +17,7 @@ const Body = () => { const {questionId} = useParams(); const [question,setQuestion] = useState(""); const location=useLocation(); - const url=location.state?.url || "iipsonlineexambackend-production.up.railway.app/student/getQuestionById"; + const url=location.state?.url || `${process.env.REACT_APP_BACKEND_URL}/student/getQuestionById`; // useEffect to observe the width of body-contents useEffect(() => { diff --git a/src/CompletedBody/CompletedBody.jsx b/src/CompletedBody/CompletedBody.jsx index a08afa8..0b3b26c 100644 --- a/src/CompletedBody/CompletedBody.jsx +++ b/src/CompletedBody/CompletedBody.jsx @@ -19,7 +19,7 @@ const CompletedBody = () => { const location = useLocation(); const questionUrl = - location.state?.url || "iipsonlineexambackend-production.up.railway.app/paper/getCompletedQuestion"; + location.state?.url || `${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedQuestion`; const studentId = localStorage.getItem("studentId") || ""; console.log(studentId); diff --git a/src/CompletedEditor/CompletedEditor.jsx b/src/CompletedEditor/CompletedEditor.jsx index 1bc356a..6269f06 100644 --- a/src/CompletedEditor/CompletedEditor.jsx +++ b/src/CompletedEditor/CompletedEditor.jsx @@ -21,7 +21,7 @@ const CompletedEditor = ({ question, onOutput, studentId }) => { const [runList, setRunList] = useState([]); // const studentId = localStorage.getItem("studentId") || ""; const paperId = localStorage.getItem("paperId") || ""; - const responseUrl = "iipsonlineexambackend-production.up.railway.app/student/getResponse"; + const responseUrl = `${process.env.REACT_APP_BACKEND_URL}/student/getResponse`; useEffect(() => { console.log("Student ID:", studentId); @@ -127,7 +127,7 @@ const CompletedEditor = ({ question, onOutput, studentId }) => { setLoading(true); try { - const res = await axios.post(`iipsonlineexambackend-production.up.railway.app/student/compile`, { + const res = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/student/compile`, { code: code, language: question?.compilerReq, input: input || "", @@ -152,7 +152,7 @@ const CompletedEditor = ({ question, onOutput, studentId }) => { const executeCode = async (inputValue) => { setLoading(true); try { - const res = await axios.post(`iipsonlineexambackend-production.up.railway.app/student/compile`, { + const res = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/student/compile`, { code: userCode, language: question?.compilerReq, input: inputValue || "", diff --git a/src/CompletedNavbar/CompletedNavbar.jsx b/src/CompletedNavbar/CompletedNavbar.jsx index f7cd8be..63ca19b 100644 --- a/src/CompletedNavbar/CompletedNavbar.jsx +++ b/src/CompletedNavbar/CompletedNavbar.jsx @@ -38,7 +38,7 @@ const CompletedNavbar = () => { const handleQuestionNavigation = async (direction) => { try { const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/student/getCompletedQuestionNavigation", + `${process.env.REACT_APP_BACKEND_URL}/student/getCompletedQuestionNavigation`, { questionId, direction } ); if (response.status === 200) { @@ -79,7 +79,7 @@ const CompletedNavbar = () => { const handleAllotMarks = async () => { try { const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/student/allocateMarks", + `${process.env.REACT_APP_BACKEND_URL}/student/allocateMarks`, { paperId, studentId, @@ -107,7 +107,7 @@ const CompletedNavbar = () => { try { // Check if a next question exists const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/student/getCompletedQuestionNavigation", + `${process.env.REACT_APP_BACKEND_URL}/student/getCompletedQuestionNavigation`, { questionId, direction: "next" } ); const nextQuestion = response.data?.question; @@ -145,7 +145,7 @@ const CompletedNavbar = () => { useEffect(() => { if (studentId) { axios - .post("iipsonlineexambackend-production.up.railway.app/student/getStudentDetailsByStudentId", { + .post(`${process.env.REACT_APP_BACKEND_URL}/student/getStudentDetailsByStudentId`, { studentId, }) .then((res) => { @@ -160,7 +160,7 @@ const CompletedNavbar = () => { useEffect(() => { if (paperId && studentId) { axios - .post("iipsonlineexambackend-production.up.railway.app/student/getResponse", { + .post(`${process.env.REACT_APP_BACKEND_URL}/student/getResponse`, { paperId, studentId, }) @@ -192,7 +192,7 @@ const CompletedNavbar = () => { useEffect(() => { if (questionId) { axios - .post("iipsonlineexambackend-production.up.railway.app/paper/getCompletedQuestion", { + .post(`${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedQuestion`, { questionId, }) .then((res) => { diff --git a/src/CompletedPaperDashboard/CompletedPaperDashboard.jsx b/src/CompletedPaperDashboard/CompletedPaperDashboard.jsx index 576fe4c..b3ff4de 100644 --- a/src/CompletedPaperDashboard/CompletedPaperDashboard.jsx +++ b/src/CompletedPaperDashboard/CompletedPaperDashboard.jsx @@ -41,7 +41,7 @@ const CompletedPaperDashboard = () => { try { // Map over completedPapers to create an array of evaluation status requests const evaluationPromises = completedPapers.map((paper) => - axios.post(`iipsonlineexambackend-production.up.railway.app/paper/paper_evaluate_status`, { paperId: paper._id }) + axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/paper_evaluate_status`, { paperId: paper._id }) ); // Wait for all requests to complete @@ -62,7 +62,7 @@ const CompletedPaperDashboard = () => { const fetchCompletedPapers = async () => { try { const response = await axios.post( - `iipsonlineexambackend-production.up.railway.app/paper/getCompletedPapersByTeacherId`, + `${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedPapersByTeacherId`, { teacherId } ); setCompletedPapers(response.data); diff --git a/src/CompletedPaperStudentDashboard/CompletedPaperStudentDashboard.jsx b/src/CompletedPaperStudentDashboard/CompletedPaperStudentDashboard.jsx index cd8a813..fd28137 100644 --- a/src/CompletedPaperStudentDashboard/CompletedPaperStudentDashboard.jsx +++ b/src/CompletedPaperStudentDashboard/CompletedPaperStudentDashboard.jsx @@ -33,7 +33,7 @@ const CompletedPaperStudentDashboard = () => { useEffect(() => { axios - .post("iipsonlineexambackend-production.up.railway.app/student/getStudentByPaperId", { paperId }) + .post(`${process.env.REACT_APP_BACKEND_URL}/student/getStudentByPaperId`, { paperId }) .then((res) => { const sortedStudents = res.data.students.sort((a, b) => a.fullName.localeCompare(b.fullName) @@ -50,7 +50,7 @@ const CompletedPaperStudentDashboard = () => { }); axios - .post("iipsonlineexambackend-production.up.railway.app/student/getFirstCompletedQuestionByPaperId", { + .post(`${process.env.REACT_APP_BACKEND_URL}/student/getFirstCompletedQuestionByPaperId`, { paperId, }) .then((res) => { @@ -61,7 +61,7 @@ const CompletedPaperStudentDashboard = () => { }); axios - .post("iipsonlineexambackend-production.up.railway.app/paper/getCompletedPaperByPaperId", { + .post(`${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedPaperByPaperId`, { paperId, }) .then((res) => { @@ -72,7 +72,7 @@ const CompletedPaperStudentDashboard = () => { console.error(err); }); - axios.post("http://localhost:5000/paper/getEmailSent",{ + axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/getEmailSent`,{ paperId, }) .then((res)=>{setEmailIsSent(res.data.emailSent)}) @@ -83,7 +83,7 @@ const CompletedPaperStudentDashboard = () => { useEffect(() => { students.forEach((student) => { axios - .post("iipsonlineexambackend-production.up.railway.app/paper/evaluate_status", { + .post(`${process.env.REACT_APP_BACKEND_URL}/paper/evaluate_status`, { studentId: student._id, paperId: paperId, }) @@ -150,7 +150,7 @@ const CompletedPaperStudentDashboard = () => { const sendMailToStudents = () => { setSendingEmails(true); // Start loading state axios - .post("iipsonlineexambackend-production.up.railway.app/paper/sendmailtostudent", { + .post(`${process.env.REACT_APP_BACKEND_URL}/paper/sendmailtostudent`, { paperId, students, evaluationStatus, diff --git a/src/Create_paper/Createpaper.jsx b/src/Create_paper/Createpaper.jsx index c11d78f..ff4d1a4 100644 --- a/src/Create_paper/Createpaper.jsx +++ b/src/Create_paper/Createpaper.jsx @@ -72,7 +72,7 @@ const Createpaper = () => { }; try { - const response = await axios.post('iipsonlineexambackend-production.up.railway.app/paper/create', paperData); + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/create`, paperData); console.log('Paper created successfully:', response.data); setModalMessage('Paper created successfully!'); diff --git a/src/Edit_paper/Editpaper.jsx b/src/Edit_paper/Editpaper.jsx index 89b538a..f8cfc7b 100644 --- a/src/Edit_paper/Editpaper.jsx +++ b/src/Edit_paper/Editpaper.jsx @@ -69,7 +69,7 @@ const Editpaper = () => { }; try { - await axios.post('iipsonlineexambackend-production.up.railway.app/paper/edit-paper', paperData); + await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/edit-paper`, paperData); setModalMessage('Paper edited successfully!'); setIsError(false); diff --git a/src/Forgot_Password/Forgot_Password.jsx b/src/Forgot_Password/Forgot_Password.jsx index 3ad2334..368a89f 100644 --- a/src/Forgot_Password/Forgot_Password.jsx +++ b/src/Forgot_Password/Forgot_Password.jsx @@ -22,7 +22,7 @@ const ForgotPassword = () => { const handleSubmit = async (e) => { e.preventDefault(); try { - const response = await axios.post("iipsonlineexambackend-production.up.railway.app/teacher/forgot-password", { email }); + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/forgot-password`, { email }); setMessage(response.data.message); setIsError(false); setModalIsOpen(true); diff --git a/src/Login/Login.jsx b/src/Login/Login.jsx index aa7d0c9..00f1472 100644 --- a/src/Login/Login.jsx +++ b/src/Login/Login.jsx @@ -27,7 +27,7 @@ function Login() { if (sessionId) { // Verify the session ID with the backend axios - .post("iipsonlineexambackend-production.up.railway.app/teacher/verify-session", { sessionId }) + .post(`${process.env.REACT_APP_BACKEND_URL}/teacher/verify-session`, { sessionId }) .then((response) => { if (response.data.valid) { navigate("/teacherDashboard"); // Navigate to dashboard if session is valid @@ -44,7 +44,7 @@ function Login() { setIsLoading(true); axios - .post("iipsonlineexambackend-production.up.railway.app/teacher/login", { email, password }) + .post(`${process.env.REACT_APP_BACKEND_URL}/teacher/login`, { email, password }) .then((response) => { console.log(response.data.message); setShowOtp(true); @@ -68,7 +68,7 @@ function Login() { setIsLoading(true); // Start loading axios - .post("iipsonlineexambackend-production.up.railway.app/teacher/verify-otp", { email, otp }) + .post(`${process.env.REACT_APP_BACKEND_URL}/teacher/verify-otp`, { email, otp }) .then((response) => { const { sessionId, message, teacherId, name, email, mobileNumber,photo } = response.data; diff --git a/src/Navbar/Navbar.jsx b/src/Navbar/Navbar.jsx index e87523b..7948138 100644 --- a/src/Navbar/Navbar.jsx +++ b/src/Navbar/Navbar.jsx @@ -8,6 +8,8 @@ const Navbar = () => { const [open, setOpen] = useState(false); const navigate = useNavigate(); const location = useLocation(); + const photo = localStorage.getItem("photo") || defaultPhoto; + const responsive = () => { const sidebar = document.getElementsByClassName("navbar-sidebar")[0]; if (!open) { @@ -33,7 +35,7 @@ const Navbar = () => { Image { useEffect(() => { const fetchTeacherDetails = async () => { try { - const response = await axios.post('iipsonlineexambackend-production.up.railway.app/teacher/getteacherDetails', { + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/getteacherDetails`, { teacherId: localStorage.getItem("teacherId"), }); @@ -107,7 +107,7 @@ const Profile = () => { } // Merging /edit API call - axios.post('iipsonlineexambackend-production.up.railway.app/teacher/edit', { + axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/edit`, { teacherId: localStorage.getItem("teacherId"), ...newProfileData, }) @@ -152,14 +152,14 @@ const Profile = () => { try { - const uploadResponse = await axios.post("iipsonlineexambackend-production.up.railway.app/paper/upload", formData); + const uploadResponse = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData); const imageUrl = uploadResponse.data.url; const teacherId = localStorage.getItem("teacherId"); - await axios.post("iipsonlineexambackend-production.up.railway.app/teacher/set-photo", { + await axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/set-photo`, { teacherId: teacherId, photo: imageUrl }); diff --git a/src/QuestionPaperDashboard/QuestionPaperDashboard.jsx b/src/QuestionPaperDashboard/QuestionPaperDashboard.jsx index 2ad1087..399cbf6 100644 --- a/src/QuestionPaperDashboard/QuestionPaperDashboard.jsx +++ b/src/QuestionPaperDashboard/QuestionPaperDashboard.jsx @@ -34,7 +34,7 @@ const QuestionPaperDashboard = () => { const fetchQuestions = async () => { try { const res = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/questionsbyid", + `${process.env.REACT_APP_BACKEND_URL}/paper/questionsbyid`, { paperId } ); setQuestions(res.data); @@ -49,7 +49,7 @@ const QuestionPaperDashboard = () => { const fetchpaperdetails = async () => { try { const res = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/getPapersdetails", + `${process.env.REACT_APP_BACKEND_URL}/paper/getPapersdetails`, { paperId } ); setpaperdetails(res.data[0]); @@ -81,7 +81,7 @@ const QuestionPaperDashboard = () => { const deleteQuestion = async (question) => { try { const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/delete-question", + `${process.env.REACT_APP_BACKEND_URL}/paper/delete-question`, { _id: question._id } ); setQuestions((prevQuestions) => @@ -111,7 +111,7 @@ const QuestionPaperDashboard = () => { const duplicateQuestion = async (question) => { console.log(question); const response = await axios.post( - `iipsonlineexambackend-production.up.railway.app/paper/duplicate-question`, + `${process.env.REACT_APP_BACKEND_URL}/paper/duplicate-question`, { question } ); if (response.status === 201) { @@ -138,7 +138,7 @@ const QuestionPaperDashboard = () => { const handleSubmit = async () => { try { const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/submitpaper", + `${process.env.REACT_APP_BACKEND_URL}/paper/submitpaper`, { paperId } ); @@ -205,7 +205,7 @@ const QuestionPaperDashboard = () => { navigate(`/preview/${question._id}`, {state: { - url: "iipsonlineexambackend-production.up.railway.app/paper/getQuestionsDetailsByQuestionId" + url: `${process.env.REACT_APP_BACKEND_URL}/paper/getQuestionsDetailsByQuestionId` } } ); diff --git a/src/ReadyPaperDashboard/ReadyPaperDashboard.jsx b/src/ReadyPaperDashboard/ReadyPaperDashboard.jsx index 2989b80..a8fb65f 100644 --- a/src/ReadyPaperDashboard/ReadyPaperDashboard.jsx +++ b/src/ReadyPaperDashboard/ReadyPaperDashboard.jsx @@ -48,7 +48,7 @@ const ReadyPaperDashboard = () => { const fetchPapers = async () => { try { const response = await axios.post( - `iipsonlineexambackend-production.up.railway.app/paper/getReadyPapersByTeacherId`, + `${process.env.REACT_APP_BACKEND_URL}/paper/getReadyPapersByTeacherId`, { teacherId } ); setExams(response.data); @@ -76,7 +76,7 @@ const ReadyPaperDashboard = () => { const deleteReadyPaper = async (paper) => { try { - const response = await axios.post(`iipsonlineexambackend-production.up.railway.app/paper/delete-ready-paper`, { paper }); + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/delete-ready-paper`, { paper }); setExams((prevQuestions) => prevQuestions.filter((q) => q._id !== paper._id)); if (exams.length === 1) { setExams([]); @@ -96,7 +96,7 @@ const ReadyPaperDashboard = () => { const moveToDashboard = async (paper) => { try { - const response = await axios.post("iipsonlineexambackend-production.up.railway.app/paper/move-to-dashboard", paper); + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/move-to-dashboard`, paper); setExams((prevQuestions) => prevQuestions.filter((q) => q._id !== paper._id)); if (exams.length === 1) { setExams([]); diff --git a/src/ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard.jsx b/src/ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard.jsx index bd9f046..04613b6 100644 --- a/src/ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard.jsx +++ b/src/ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard.jsx @@ -26,7 +26,7 @@ const ReadyQuestionPaperDashboard = () => { const fetchQuestions = async () => { try { const res = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/getReadyQuestionPapersByTeacherId", + `${process.env.REACT_APP_BACKEND_URL}/paper/getReadyQuestionPapersByTeacherId`, { paperId } ); setQuestions(res.data); @@ -41,7 +41,7 @@ const ReadyQuestionPaperDashboard = () => { const fetchpaperdetails = async () => { try { const res = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/getReadyPaperDetailsByPaperId", + `${process.env.REACT_APP_BACKEND_URL}/paper/getReadyPaperDetailsByPaperId`, { paperId } ); setpaperdetails(res.data[0]); diff --git a/src/Reset_Password/Reset_Password.jsx b/src/Reset_Password/Reset_Password.jsx index 45a5c75..ccb7d51 100644 --- a/src/Reset_Password/Reset_Password.jsx +++ b/src/Reset_Password/Reset_Password.jsx @@ -40,7 +40,7 @@ const Reset_Password = () => { try { const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/teacher/reset-password", + `${process.env.REACT_APP_BACKEND_URL}/teacher/reset-password`, { token, email, diff --git a/src/Sign_up/SignUp.jsx b/src/Sign_up/SignUp.jsx index 6cca75c..3269ccd 100644 --- a/src/Sign_up/SignUp.jsx +++ b/src/Sign_up/SignUp.jsx @@ -41,7 +41,7 @@ const SignUp = () => { const handleSignUp = async () => { setLoading(true); // Set loading state try { - const response = await fetch("iipsonlineexambackend-production.up.railway.app/teacher/signup", { + const response = await fetch(`${process.env.REACT_APP_BACKEND_URL}/teacher/signup`, { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/Sign_up/VerifyOtp.jsx b/src/Sign_up/VerifyOtp.jsx index 27e9c1a..cc59e32 100644 --- a/src/Sign_up/VerifyOtp.jsx +++ b/src/Sign_up/VerifyOtp.jsx @@ -20,7 +20,7 @@ const VerifyOtp = () => { e.preventDefault(); try { - const response = await fetch("iipsonlineexambackend-production.up.railway.app/teacher/verifypasscode", { + const response = await fetch(`${process.env.REACT_APP_BACKEND_URL}/teacher/verifypasscode`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, otp }), diff --git a/src/edit_question/EditQuestion.jsx b/src/edit_question/EditQuestion.jsx index bcb6e53..9f7d661 100644 --- a/src/edit_question/EditQuestion.jsx +++ b/src/edit_question/EditQuestion.jsx @@ -69,7 +69,7 @@ const EditQuestion = () => { formData.append("upload_preset", "question"); const uploadResponse = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/upload", + `${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData, { headers: { "Content-Type": "multipart/form-data" }, @@ -92,7 +92,7 @@ const EditQuestion = () => { const editQuestion = async (imageUrl) => { try { const response = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/edit-question", + `${process.env.REACT_APP_BACKEND_URL}/paper/edit-question`, { _id: location.state._id, paperId, @@ -158,7 +158,7 @@ const EditQuestion = () => { try { const uploadResponse = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/upload", + `${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData, { headers: { "Content-Type": "multipart/form-data" }, diff --git a/src/edit_ready_question/EditReadyQuestion.jsx b/src/edit_ready_question/EditReadyQuestion.jsx index 1077c35..72f6699 100644 --- a/src/edit_ready_question/EditReadyQuestion.jsx +++ b/src/edit_ready_question/EditReadyQuestion.jsx @@ -49,7 +49,7 @@ const EditReadyQuestion = () => { try { const uploadResponse = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/upload", + `${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData, { headers: { "Content-Type": "multipart/form-data" }, @@ -100,7 +100,7 @@ const EditReadyQuestion = () => { formData.append("upload_preset", "question"); const uploadResponse = await axios.post( - "iipsonlineexambackend-production.up.railway.app/paper/upload", + `${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData, { headers: { "Content-Type": "multipart/form-data" }, @@ -122,7 +122,7 @@ const EditReadyQuestion = () => { const editQuestion = async (imageUrl) => { - const response = await axios.post('iipsonlineexambackend-production.up.railway.app/paper/edit-ready-question', { + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/edit-ready-question`, { _id: location.state._id, paperId, questionheading, diff --git a/src/index.js b/src/index.js index 5b3ddef..6e3c1ed 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; + const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/src/papers/papers.jsx b/src/papers/papers.jsx index 25a97d6..40083de 100644 --- a/src/papers/papers.jsx +++ b/src/papers/papers.jsx @@ -29,7 +29,7 @@ function Papers() { const fetchPapers = async () => { try { const response = await axios.post( - `iipsonlineexambackend-production.up.railway.app/paper/getPapersByTeacherId`, + `${process.env.REACT_APP_BACKEND_URL}/paper/getPapersByTeacherId`, { teacherId } ); setExams(response.data); @@ -61,7 +61,7 @@ function Papers() { const deleteConfirm= async (paper) => { try { - await axios.post("iipsonlineexambackend-production.up.railway.app/paper/delete-paper", { _id: paper._id }); + await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/delete-paper`, { _id: paper._id }); setExams((prevQuestions) => prevQuestions.filter((q) => q._id !== paper._id)); setReload((prev) => !prev); setModalMessage("Paper deleted successfully."); @@ -77,7 +77,7 @@ function Papers() { const duplicatePaper = async (paper) => { try { - await axios.post("iipsonlineexambackend-production.up.railway.app/paper/duplicate-paper", paper); + await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/duplicate-paper`, paper); setReload((prev) => !prev); setModalMessage("Paper duplicated successfully."); setIsError(false); diff --git a/src/question/question.jsx b/src/question/question.jsx index de1f0f8..cea97b2 100644 --- a/src/question/question.jsx +++ b/src/question/question.jsx @@ -49,7 +49,7 @@ const Question = () => { formData.append('file', image); formData.append('upload_preset', 'question'); - const uploadResponse = await axios.post('iipsonlineexambackend-production.up.railway.app/paper/upload', formData, { + const uploadResponse = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData, { headers: { 'Content-Type': 'multipart/form-data' }, }); @@ -67,7 +67,7 @@ const Question = () => { }; const submitQuestion = async (imageUrl) => { - const response = await axios.post('iipsonlineexambackend-production.up.railway.app/paper/add-question', { + const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/add-question`, { paperId, questionheading, questionDescription, @@ -125,7 +125,7 @@ const Question = () => { setQuestionDescription((prev) => prev + '\nUploading image...'); try { - const uploadResponse = await axios.post('iipsonlineexambackend-production.up.railway.app/paper/upload', formData, { + const uploadResponse = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData, { headers: { 'Content-Type': 'multipart/form-data' }, });