diff --git a/backend/config.conf b/backend/config.conf index 069dcec..159d3c5 100644 --- a/backend/config.conf +++ b/backend/config.conf @@ -1,3 +1,11 @@ +<<<<<<< Updated upstream NGROK = https://b1c3-2401-4900-376e-7dc4-4461-d4cd-f827-2764.ngrok-free.app +======= +# <<<<<<< Updated upstream +# NGROK = https://ec58-2406-7400-98-c555-00-104.ngrok-free.app +# ======= +NGROK = https://1500-117-198-99-29.ngrok-free.app +# >>>>>>> Stashed changes +>>>>>>> Stashed changes FLUTTER_WEB = http://localhost:53916 REACT_WEB = http://localhost:3000 \ No newline at end of file diff --git a/frontend/setupProxy.js b/frontend/setupProxy.js index 0dd2cd6..6baacaf 100644 --- a/frontend/setupProxy.js +++ b/frontend/setupProxy.js @@ -4,7 +4,7 @@ module.exports = function(app) { app.use( '/api', createProxyMiddleware({ - target: 'https://4583-117-198-99-29.ngrok-free.app', + target: ' https://1500-117-198-99-29.ngrok-free.app', changeOrigin: true, }) ); diff --git a/frontend/src/Approval.css b/frontend/src/Approval.css index cd10ac5..12bc547 100644 --- a/frontend/src/Approval.css +++ b/frontend/src/Approval.css @@ -37,14 +37,16 @@ margin-bottom: 20px; } - .extra-events-table { + .extra-events-table, + .project-approvals-table { width: 100%; border-collapse: collapse; } .declaration-table caption, .club-events-table caption, - .extra-events-table caption { + .extra-events-table caption, + .project-approvals-table caption { font-weight: bold; font-size: 1.2rem; margin-bottom: 10px; @@ -55,7 +57,9 @@ .club-events-table th, .club-events-table td, .extra-events-table th, - .extra-events-table td { + .extra-events-table td, + .project-approvals-table th, + .project-approvals-table td { color: #fff; padding: 10px; text-align: left; @@ -63,7 +67,8 @@ .declaration-table th, .club-events-table th, - .extra-events-table th { + .extra-events-table th, + .project-approvals-table th { color: black; background-color: #f5f5f5; } diff --git a/frontend/src/Approval.js b/frontend/src/Approval.js index 39935f4..a6cca89 100644 --- a/frontend/src/Approval.js +++ b/frontend/src/Approval.js @@ -1,203 +1,314 @@ -import React, { useEffect, useState } from 'react'; -import axios from 'axios'; -import { TARGET_URL } from './Config'; -import './Approval.css'; -import { useHistory } from 'react-router-dom/cjs/react-router-dom.min'; - -const Approval = () => { - const [clubEvents, setClubEvents] = useState([]); - const [extraEvents, setExtraEvents] = useState([]); - const [selectedImage, setSelectedImage] = useState(null); - - useEffect(() => { - const fetchData = async () => { - const data = { - cookies: document.cookie, + import React, { useEffect, useState } from 'react'; + import axios from 'axios'; + import { TARGET_URL } from './Config'; + import './Approval.css'; + import { useHistory } from 'react-router-dom/cjs/react-router-dom.min'; + + const Approval = () => { + const [clubEvents, setClubEvents] = useState([]); + const [extraEvents, setExtraEvents] = useState([]); + const [selectedImage, setSelectedImage] = useState(null); + const [projectApprovals, setProjectApprovals] = useState([]); + + useEffect(() => { + const fetchData = async () => { + const data = { + cookies: document.cookie, + }; + + try { + const response = await axios.post(TARGET_URL + '/events/approvals/get/', data, { + headers: { + 'Content-Type': 'application/json', + }, + }); + + console.log('Response:', response); + setClubEvents(response.data['clubEvents']); + setExtraEvents(response.data['extraEvents']); + } catch (error) { + console.log('Error:', error); + } + + // try { + // const response = await axios.post(TARGET_URL + '/project/approval/list/', { + // cookies:document.cookie, + // }, { + // headers: { + // 'Content-Type': 'application/json', + // }, + // }); + + // console.log('Response:', response); + // setClubEvents(response.data['clubEvents']); + // setExtraEvents(response.data['extraEvents']); + // } catch (error) { + // console.log('Error:', error); + // } }; + const fetchProjectApprovals = async () => { + try { + const response = await axios.post(TARGET_URL + '/project/approval/list/', { + cookies: document.cookie, + }); + console.log('Project Approval Response:', response); + // Handle the response and update the state as needed + setProjectApprovals(response.data['projects']); + } catch (error) { + console.log('Error fetching project approvals:', error); + } + }; + + // Fetch project approvals data on component mount + fetchProjectApprovals(); + fetchData(); + }, []); + + const handleImageClick = (image) => { + setSelectedImage(image); + }; + + const handleBack = () => { + setSelectedImage(null); + }; + + const history = useHistory(); + + const handleEventDetails = (event) => { + history.push('/EventDetails', { event }); + window.location.reload(); + }; + + const handleClubname = (event, clubId) => { + history.push('/ClubEventList', { club: { id: event.clubId, name: event.clubName } }); + window.location.reload(); + }; + + const handleStudentName = (srn) => { + history.push({ + pathname: './StudentDetails', + state: { srn: srn }, + }); + window.location.reload(); + }; + + const handleEventApproval = async (eventId, approved) => { try { - const response = await axios.post(TARGET_URL + '/events/approvals/get/', data, { - headers: { - 'Content-Type': 'application/json', + const response = await axios.post( + TARGET_URL + '/events/approval/', + { + cookies: document.cookie, + eventid: eventId, + result: approved, + + cookies: document.cookie, + //id: + approval:approved, + //completion:True/False/None }, - }); + { + headers: { + 'Content-Type': 'application/json', + }, + } + ); - console.log('Response:', response); - setClubEvents(response.data['clubEvents']); - setExtraEvents(response.data['extraEvents']); + console.log('POST request successful:', response); + // Handle the response as needed + window.location.reload(); } catch (error) { console.log('Error:', error); } + }; + const handleProjectConfirmation = async (project, approved) => { try { - const response = await axios.post(TARGET_URL + '/project/approval/list/', { - cookies: document.cookie, - }, { - headers: { - 'Content-Type': 'application/json', + const response = await axios.post( + TARGET_URL + '/project/approval/', + { + cookies: document.cookie, + id: project.id, + approval: approved, + completion: project.completion, }, - }); - - console.log('Response:', response); - setClubEvents(response.data['clubEvents']); - setExtraEvents(response.data['extraEvents']); + { + headers: { + 'Content-Type': 'application/json', + }, + } + ); + + console.log('Project Confirmation Response:', response); + // Handle the response as needed + window.location.reload(); // You can remove this if you want to handle the UI update without page reload } catch (error) { - console.log('Error:', error); + console.log('Error confirming project:', error); } }; - fetchData(); - }, []); - - const handleImageClick = (image) => { - setSelectedImage(image); - }; - - const handleBack = () => { - setSelectedImage(null); - }; - - const history = useHistory(); - - const handleEventDetails = (event) => { - history.push('/EventDetails', { event }); - window.location.reload(); - }; + - const handleClubname = (event, clubId) => { - history.push('/ClubEventList', { club: { id: event.clubId, name: event.clubName } }); - window.location.reload(); - }; - - const handleStudentName = (srn) => { - history.push({ - pathname: './StudentDetails', - state: { srn: srn }, - }); - window.location.reload(); - }; - - const handleEventApproval = async (eventId, approved) => { - try { - const response = await axios.post( - TARGET_URL + '/project/approval/', - { - cookies: document.cookie, - eventid: eventId, - result: approved, - - cookies: document.cookie, - //id: - approval:approved, - //completion:True/False/None - }, - { - headers: { - 'Content-Type': 'application/json', - }, - } - ); + return ( +
+

Approval Page

+ {/* Removed the "Attendance Request" button */} + + + + + + + + + + + + + + + {clubEvents.map((event) => ( + + - console.log('POST request successful:', response); - // Handle the response as needed - window.location.reload(); - } catch (error) { - console.log('Error:', error); - } - }; + + + + + + + + ))} + +
Club Event Approvals
Event NameClub NameClub IDDateDetailsEvent IDAction
+ + + + {event.clubId}{event.date}{event.details}{event.id} + + +
- return ( -
-

Approval Page

- {/* Removed the "Attendance Request" button */} - - - - - - - - - - - - - - - {clubEvents.map((event) => ( - - - - - - - - - +
Club Event Approvals
Event NameClub NameClub IDDateDetailsEvent IDAction
- - - - {event.clubId}{event.date}{event.details}{event.id} - - -
+ + + + + + + + + + - ))} - -
Extra Event Approvals
Event NameEvent IDDateStudent NameStudent SRNDetailsAction
+ + + {extraEvents.map((event) => ( + + + + + {event.id} + {event.date} + + + + {event.srn} + {event.details} + + + + + + ))} + + - - +
capstone Event Approvals
+ - - - - - + + + + - + + + + + {/* */} + - {extraEvents.map((event) => ( - - - - - - - - + {projectApprovals && projectApprovals.length > 0 ? ( + projectApprovals.map((project) => ( + + + + + + + + + + + + + )) + ) : ( + + - ))} + )}
Project Approvals
Event NameEvent IDDateStudent NameStudent SRNApprovalCategoryCompletionDepartment DetailsActionGuideHackathonIDLinkApprovalConfirmation
- - {event.id}{event.date} - - {event.srn}{event.details} - - -
{project.approval}{project.category}{project.completion}{project.department}{project.details}{project.guide}{project.hackathon}{project.id} + {project.link ? ( + + {project.link} + + ) : ( + 'N/A' + )} + + + +
Loading project approvals...
-
- ); -}; +
+ ); + }; -export default Approval; + export default Approval; diff --git a/frontend/src/ClubEventList.js b/frontend/src/ClubEventList.js index 1c9d2ec..cf792a3 100644 --- a/frontend/src/ClubEventList.js +++ b/frontend/src/ClubEventList.js @@ -92,7 +92,7 @@ const ClubEventList = () => { if (status === 0) { return 'Pending'; } else if (status === -1) { - return 'Disapproved'; + return 'Report needed '; } else if (status === 1) { return 'Approved'; } else { diff --git a/frontend/src/Config.js b/frontend/src/Config.js index 645e3e3..ee49899 100644 --- a/frontend/src/Config.js +++ b/frontend/src/Config.js @@ -1,5 +1,5 @@ // config.js -export const TARGET_URL = 'https://2df2-2401-4900-376e-7dc4-d86-ebdf-dc07-586a.ngrok-free.app'; +export const TARGET_URL = 'https://38dc-2401-4900-61b6-f721-d857-ca53-c049-89b.ngrok-free.app'; diff --git a/frontend/src/Project.js b/frontend/src/Project.js index cf11abd..03f40a3 100644 --- a/frontend/src/Project.js +++ b/frontend/src/Project.js @@ -6,6 +6,9 @@ import { TARGET_URL } from './Config'; const Project = () => { const [searchTerm, setSearchTerm] = useState(''); const [projectData, setProjectData] = useState([]); + const [showJoinForm, setShowJoinForm] = useState(false); + const [joinProjectID, setJoinProjectID] = useState(''); + const handleSearch = (e) => { setSearchTerm(e.target.value); @@ -99,6 +102,7 @@ const Project = () => { cookies: document.cookie, }); console.log(response); + setProjectData(response.data.projects); } catch (error) { console.log('Error:', error); } @@ -107,6 +111,36 @@ const Project = () => { fetchData(); }, []); + + const handleJoinProject = () => { + setShowJoinForm(true); + }; + + const handleJoinFormInputChange = (e) => { + setJoinProjectID(e.target.value); + }; + + const handleJoinFormSubmit = async (e) => { + e.preventDefault(); + + // Send the post request to the example link with the entered project ID + try { + const response = await axios.post(TARGET_URL + '/project/student/', { + project: joinProjectID, + cookies: document.cookie, + }); + + // Optionally, you can handle the response here + console.log('Response:', response.data); + + // Close the join form after submission + setShowJoinForm(false); + } catch (error) { + console.error('Error:', error); + } + }; + + return (

Projects

@@ -122,6 +156,23 @@ const Project = () => { {/* "Add Project" button */} + + + {showJoinForm && ( +
+ + +
+ )} + {/* Form for adding a new project */} {showForm && (
@@ -176,29 +227,32 @@ const Project = () => {
)} - - - + + - - + - {filteredProjects.map((project, index) => ( - - + {projectData.map((project) => ( + + - - + + + ))}
Project titleAbstractProject NameDetails Created By StatusGit Hub Repo LinkActions
{project.projectName}
{project.title} {project.details}{project.createdBy}{project.status}{project.guide}{project.approval === 1 ? 'Semi-Approved' : 'Not Approved'} + {/* Here you can add any action buttons related to the project */} +
+ +
); };