diff --git a/client/src/api/studentAPI.jsx b/client/src/api/studentAPI.jsx
index 05b7faa..ce3a448 100644
--- a/client/src/api/studentAPI.jsx
+++ b/client/src/api/studentAPI.jsx
@@ -11,3 +11,5 @@ export const updateVerificationStatus = (id, isVerified) => axiosInstance.put(`/
export const updateUserRole = (id, role) => axiosInstance.put(`/users/role/${id}`, { role });
export const deleteStudent = (id) => axiosInstance.delete(`/users/delete/${id}`);
+
+export const updateStudentCompany = (id, companyId) => axiosInstance.put(`/users/company/${id}`, { companyId });
diff --git a/client/src/components/Student/StudentTable.css b/client/src/components/Student/StudentTable.css
index fa1746a..89060c8 100644
--- a/client/src/components/Student/StudentTable.css
+++ b/client/src/components/Student/StudentTable.css
@@ -30,7 +30,7 @@
color: var(--color-bg);
}
-.role-dropdown {
+.render-dropdown {
display: flex;
align-items: center;
justify-content: center;
@@ -47,15 +47,15 @@
box-shadow: 0 0 0 0.5px var(--color-white);
}
-.role-dropdown:hover {
+.render-dropdown:hover {
background-color: var(--color-bg);
}
-.role-dropdown:focus {
+.render-dropdown:focus {
background-color: var(--color-bg);
}
-.role-dropdown option {
+.render-dropdown option {
background-color: var(--color-bg);
color: var(--color-white);
margin: 0.5rem 0;
@@ -66,6 +66,6 @@
transition: all 0.3s ease-in-out;
}
-.role-dropdown option:hover {
+.render-dropdown option:hover {
background-color: var(--color-bg);
}
diff --git a/client/src/components/Student/StudentTable.jsx b/client/src/components/Student/StudentTable.jsx
index b569256..d32450f 100644
--- a/client/src/components/Student/StudentTable.jsx
+++ b/client/src/components/Student/StudentTable.jsx
@@ -1,8 +1,9 @@
-import { useCallback, useState } from 'react';
+import { useCallback, useEffect, useState } from 'react';
import { GrValidate } from 'react-icons/gr';
import { MdDelete } from 'react-icons/md';
import { toast } from 'react-toastify';
-import { deleteStudent, getStudents, updateUserRole, updateVerificationStatus } from '../../api/studentAPI.jsx';
+import { getCompanies } from '../../api/companyApi.jsx';
+import { deleteStudent, getStudents, updateStudentCompany, updateUserRole, updateVerificationStatus } from '../../api/studentApi.jsx';
import getUser from '../../utils/user.js';
import AgGridTable from '../AgGridTable/AgGridTable.jsx';
import Modal from '../Modal/Modal.jsx';
@@ -14,8 +15,24 @@ const StudentTable = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedStudent, setSelectedStudent] = useState(null);
const [selectedStudentDelete, setSelectedStudentDelete] = useState(null);
+ const [companies, setCompanies] = useState([]);
const user = getUser();
+ useEffect(() => {
+ const fetchCompanies = async () => {
+ try {
+ const res = await getCompanies();
+ res.data.forEach((company) => {
+ company.id = company._id;
+ });
+ setCompanies(res.data);
+ } catch (error) {
+ console.error('Error fetching companies:', error);
+ }
+ };
+ fetchCompanies();
+ }, []);
+
const closeModal = () => {
setIsModalOpen(false);
setSelectedStudent(null);
@@ -66,6 +83,16 @@ const StudentTable = () => {
}
};
+ const handleCompanyChange = async (event, params) => {
+ try {
+ const res = await updateStudentCompany(params.id, event.target.value);
+ toast.success();
+ fetchData();
+ } catch (error) {
+ toast.error();
+ }
+ };
+
const verifyButtonRenderer = (params) => {
return (