diff --git a/src/App.js b/src/App.js index 0077d92..154a90e 100644 --- a/src/App.js +++ b/src/App.js @@ -22,6 +22,7 @@ import DetailRoomEducation from "./_screens/home/detail-room-education"; import EducationDepartmentHome from "./_screens/home/education-department"; import { Alert } from "./_components/Alert"; import OutstandingTeacher from "./_screens/home/outstanding-teacher"; +import { TYPE_DISPATCH } from "./_constants/common"; function App() { const dispatch = useDispatch(); @@ -44,7 +45,14 @@ function App() { dispatch(alertActions?.clear()); }); }, []); - // console.log("authen: ", authentication); + + useEffect(() => { + if(authentication?.user?.role === "student"||authentication?.user?.role === "parent") + dispatch({ + type: TYPE_DISPATCH.RESET_AUTHENTICATION, + }); + }, []) + return (
{authentication?.user?.fullname}
+{fullName}
Không có lớp nào @@ -208,6 +277,10 @@ export default function DetailGrade() { ); })}
Không có giáo viên nào diff --git a/src/_screens/home/teacher/index.js b/src/_screens/home/teacher/index.js index a3ffe54..1306247 100644 --- a/src/_screens/home/teacher/index.js +++ b/src/_screens/home/teacher/index.js @@ -15,7 +15,7 @@ import { listAlphabet, PRIMARY_COLOR, } from "../../../_constants/common"; -import { useEffect, useState } from "react"; +import { useEffect, useState,useRef } from "react"; import { apiCaller, history } from "../../../_helpers"; import { configConstants } from "../../../_constants"; import { exportExcel } from "../../../_helpers/utils"; @@ -39,12 +39,23 @@ export default function TeacherHome() { const [limitOnline] = useState(10); const [offsetOnline, setOffsetOnline] = useState(0); const [isEndOnlineClasses, setIsEndOnlineClasses] = useState(false); + const [totalClass, setTotalClass] = useState(0) + const [totalAssign, settotalAssign] = useState(0) + const listRef = useRef(null) const teacherName = !!teacherId ? !!teacher_name ? decodeURIComponent(teacher_name) : '' : authentication?.user?.fullname; const id = !!teacherId ? teacherId : authentication?.user?.id; + const scrollToTop = () => { + if (listRef.current) { + listRef.current.scrollTo({ + top: 0, + behavior: 'smooth', + }); + } + }; const getData = async () => { try { setIsLoading(true); @@ -60,6 +71,8 @@ export default function TeacherHome() { const res = await apiCaller(endPoint, "GET"); if (res?.status) { + setTotalClass(res?.total_class); + settotalAssign(res?.total_assign); setCriteria(res?.criteria_teacher); setListClass(res?.data); } @@ -84,6 +97,11 @@ export default function TeacherHome() { }; const handleFilter = () => { + scrollToTop() + setOffsetOnline(0) + setLoadMoreOnline(true) + setIsEndOnlineClasses(false) + setListClass([]) getData(); }; @@ -96,9 +114,9 @@ export default function TeacherHome() { "Tiêu chí giao bài", "Tỷ lệ học sinh làm bài", "Tiêu chí tỷ lệ học sinh làm bài", - // "Trường", - // "Huyện", - // "Tỉnh", + "Trường", + "Huyện", + "Tỉnh", "Tháng", "học kỳ", "Niên khóa", @@ -111,9 +129,9 @@ export default function TeacherHome() { item?.assign_number_level || 0, `${item?.student_done_per || 0}%`, item?.student_done_per_level || 0, - // "Trường", - // "Huyện", - // "Tỉnh", + item?.organization_name || '', + item?.organization_district ||'', + item?.organization_province ||'', !!month?.value ? month.value : getListMonthBySemester(semester.value) @@ -156,7 +174,6 @@ export default function TeacherHome() { try { if (!isEndOnlineClasses) { let queryParams = [] - if(!!semester?.value){ queryParams.push(`&semester=${semester?.value}`) } @@ -164,10 +181,12 @@ export default function TeacherHome() { queryParams.push(`month=${month?.value}`) } const endPoint = - `/api_exercise_report/teacher_report_summary?teacher_id=${id}&year=${schoolYear?.value}${queryParams.length ? `${queryParams.join("&")}` : ""} - &limit=${limitOnline}&offset=${offsetOnlineMore}`; + `/api_exercise_report/teacher_report_summary?teacher_id=${id}&year=${schoolYear?.value.trim()}&limit=${limitOnline}&offset=${offsetOnlineMore}` + + (queryParams.length > 0 ? `&${queryParams.join("&")}` : ""); const res = await apiCaller(endPoint, "GET"); - if (res?.status) { + if (!res){ + setIsEndOnlineClasses(true); + } else { concatListSide = res?.data; setOffsetOnline(offsetOnline + limitOnline); if (res?.data?.length < limitOnline) { @@ -224,13 +243,13 @@ export default function TeacherHome() {