diff --git a/src/_components/Header/index.js b/src/_components/Header/index.js
index cd2a912..9216f79 100644
--- a/src/_components/Header/index.js
+++ b/src/_components/Header/index.js
@@ -4,6 +4,8 @@ import { configConstants } from "../../_constants";
export default function Header({ icon, title, subtitles = [] }) {
const authentication = useSelector((state) => state.authentication);
+
+ const fullName = authentication?.user?.role==="organization_admin"?`Hiệu trưởng ${authentication?.user?.fullname}`:authentication?.user?.fullname
return (
@@ -21,7 +23,7 @@ export default function Header({ icon, title, subtitles = [] }) {
-
{authentication?.user?.fullname}
+
{fullName}

{
- if(action.payload?.user?.role !=="student"){
+ if(action.payload?.user?.role !=="student"||action.payload?.user?.role !=="parent"){
switch (action.type) {
case TYPE_DISPATCH.LOGIN:
return {
diff --git a/src/_screens/home/headmaster/index.js b/src/_screens/home/headmaster/index.js
index 058f321..81d8b84 100644
--- a/src/_screens/home/headmaster/index.js
+++ b/src/_screens/home/headmaster/index.js
@@ -42,10 +42,14 @@ export default function HeadmasterHome() {
const [listTeacher, setListTeacher] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [criteriaSchool, setCriteriaSchool] = useState();
+ const [isLoadMoreOnline, setLoadMoreOnline] = useState(true);
+ const [limitOnline] = useState(10);
+ const [offsetOnline, setOffsetOnline] = useState(0);
+ const [isEndOnlineClasses, setIsEndOnlineClasses] = useState(false);
const schoolName = !!schoolId
? !!school_name ? decodeURIComponent(school_name) : ''
- : `Hiệu trưởng ${authentication?.user?.organization_name}`;
+ : `${authentication?.user?.organization_name}`;
const id = !!schoolId ? schoolId : authentication?.user?.organization_id;
const changeSemester = (item) => {
@@ -148,6 +152,48 @@ export default function HeadmasterHome() {
}
}
+ const handleScroll = (e) => {
+ if (
+ e.target.scrollHeight - e.target.scrollTop < e.target.clientHeight + 5 &&
+ isLoadMoreOnline &&
+ !isLoading
+ ) {
+ onLoadMoreClasses();
+ }
+ };
+
+ // Load More Classes for Teacher
+ const onLoadMoreClasses = async () => {
+ let offsetOnlineMore = offsetOnline + limitOnline;
+ let listNext = [];
+ setIsLoading(true);
+ try {
+ if (!isEndOnlineClasses) {
+ const endPoint = `/report/api_report/teacherByOrganizationId?organization_id=${id}&limit=${limitOnline}&offset=${offsetOnlineMore}`;
+ const res = await apiCaller(endPoint, "GET");
+
+ if (res?.status) {
+ listNext = res?.data;
+ setOffsetOnline(offsetOnline + limitOnline);
+ if (res?.data?.length < limitOnline) {
+ setLoadMoreOnline(false);
+ if (res?.data?.length == 0) setLoadMoreOnline(false);
+ setIsEndOnlineClasses(true);
+ }
+ }
+ } else {
+ setIsEndOnlineClasses(true);
+ }
+
+ let listPrev = listTeacher;
+ setListTeacher(listPrev?.concat(listNext));
+ } catch (e) {
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+
const getDataCriteriaSchool = async () => {
try {
setIsLoading(true);
@@ -292,7 +338,7 @@ export default function HeadmasterHome() {