diff --git a/src/src/pages/PF/Home.js b/src/src/pages/PF/Home.js
index 87d2b72..6910ae3 100644
--- a/src/src/pages/PF/Home.js
+++ b/src/src/pages/PF/Home.js
@@ -14,6 +14,7 @@ function HomePF() {
const [Email,] = useState(Cookies.get('Email'));
const [courses, setCourses] = useState(null);
+ const [classes, setClasses] = useState(null);
const [expanded, setExpanded] = useState(false);
const [ready, setReady] = useState(null);
const [expandedYear, setExpandedYear] = useState(null);
@@ -46,9 +47,24 @@ function HomePF() {
}
});
const data = await response.json();
- const sortedCourses = Object.fromEntries(Object.entries(data).sort((a, b) => b[0].localeCompare(a[0])));
-
+ var sortedCourses = Object.fromEntries(Object.entries(data).sort((a, b) => b[0].localeCompare(a[0])));
+
setCourses(sortedCourses);
+ if(Object.keys(sortedCourses).length > 0) setExpandedYear(Object.keys(sortedCourses)[0])
+
+ const classResponse = await fetch(`${host}/ST/class/classes`, {
+ method: "GET",
+ credentials: "include",
+ headers: {
+ "Content-type": "application/json; charset=UTF-8",
+ "Access-Control-Allow-Origin": "*",
+ "X-CSRF-TOKEN": Cookies.get("csrf_token")
+ }
+ });
+ const classData = await classResponse.json();
+ sortedCourses = Object.fromEntries(Object.entries(classData).sort((a, b) => b[0].localeCompare(a[0])));
+ setClasses(sortedCourses);
+
} catch (error) {
console.error('Error fetching class data:', error);
}
@@ -205,7 +221,38 @@ function HomePF() {
) : (
"")}
+
+ {(classes && Object.keys(classes).length > 0) && ready ? (
+
+
+ {/* วนลูปเพื่อแสดง container แยกตามปีการศึกษา */}
+ {Object.entries(classes).map(([year, classes], i) => (
+
+
toggleYear(year)} style={{ cursor: 'pointer' }}>
+ {expandedYear === year ? : } {year} (Student view)
+
+ {expandedYear === year && (
+
+ {/* วนลูปเพื่อแสดงข้อมูลคอร์สในแต่ละปีการศึกษา */}
+ {classes.map((course) => (
+
+

+
+
{course.ClassName}
+
ID: {course.ClassID}
+
+
+
+ ))}
+
+ )}
+
+ ))}
+
+ ) : (null)}
)
}
diff --git a/src/src/pages/PF/StudentList.js b/src/src/pages/PF/StudentList.js
index 7b51de5..1a9c3bc 100644
--- a/src/src/pages/PF/StudentList.js
+++ b/src/src/pages/PF/StudentList.js
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import Navbar from '../../components/Navbar';
import { useNavigate } from 'react-router-dom';
import Cookies from 'js-cookie';
+// import {PencilSquare} from 'react-bootstrap-icons'
const host = `${process.env.REACT_APP_HOST}`
@@ -16,7 +17,9 @@ function StudentList() {
const [ClassInfo, setClassInfo] = useState({});
-
+ const [showModal, setShowModal] = useState(false);
+ const [isEdit, setIsEdit] = useState(false);
+
// const [Email,] = useState(sessionStorage.getItem("Email"));
const [classId,] = useState(sessionStorage.getItem("classId"));
@@ -125,6 +128,32 @@ function StudentList() {
}
}
+ const handleEditStudent = async (toEdit) => {
+ setShowModal(true);
+ setIsEdit(true);
+ }
+
+ const handleAddStudent = async () => {
+ setShowModal(true);
+ setIsEdit(false)
+ }
+
+ const UpdateStudent = async () => {
+
+ }
+
+ const RemoveStudent = async () => {
+
+ }
+
+ const AddStudent = async () => {
+
+ }
+
+ const handleCloseModal = () => {
+ setShowModal(false);
+ };
+
return (
@@ -137,23 +166,39 @@ function StudentList() {
{ClassInfo['ClassID']} {ClassInfo['ClassName']} {ClassInfo['ClassYear']}
Instructor: {ClassInfo['Instructor']}
-