From 4d053c0ad9c812119ff0ce2b4f30d93dca2ffbb0 Mon Sep 17 00:00:00 2001 From: Quy_FE Date: Mon, 5 May 2025 09:33:00 +0700 Subject: [PATCH] Feat : async data chart --- .../home/detail-room-education/index.js | 28 +++++++++++----- .../home/education-department/index.js | 32 +++++++++++++------ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/_screens/home/detail-room-education/index.js b/src/_screens/home/detail-room-education/index.js index bb62427..8eb53b7 100644 --- a/src/_screens/home/detail-room-education/index.js +++ b/src/_screens/home/detail-room-education/index.js @@ -208,18 +208,30 @@ export default function DetailRoomEducation() { } useEffect(() => { - getDataStatisticCircle() - getListOrganization() - }, []) + const fetchData = async () => { + await getDataStatisticCircle(); + await getListOrganization(); + }; + + fetchData(); + }, []); useEffect(() => { - getDataStudentChart() - }, [dateStudentChart]) + const fetchStudentData = async () => { + await getDataStudentChart(); + }; + + fetchStudentData(); + }, [dateStudentChart]); useEffect(() => { - getDataTeacherChart() - }, [dateTeacherChart]) + const fetchTeacherData = async () => { + await getDataTeacherChart(); + }; + fetchTeacherData(); + }, [dateTeacherChart]); + useEffect(() => { if (isLoadingListOrganization || isLoadingStatisticCircle || isLoadingStudentChart || isLoadingTeacherChart) { $(".loading").removeClass("hide"); @@ -461,7 +473,7 @@ export default function DetailRoomEducation() {
goToDetailSchool(item)}>
- +
diff --git a/src/_screens/home/education-department/index.js b/src/_screens/home/education-department/index.js index ae7abdd..73bb546 100644 --- a/src/_screens/home/education-department/index.js +++ b/src/_screens/home/education-department/index.js @@ -95,18 +95,30 @@ export default function EducationDepartmentHome() { }); } - useEffect(async () => { - await getDataOrganization() - await getDataStatisticCircle() - }, []) + useEffect(() => { + const fetchData = async () => { + await getDataOrganization(); + await getDataStatisticCircle(); + }; + + fetchData(); + }, []); + + useEffect(() => { + const fetchStudentData = async () => { + await getDataStudentChart(); + }; - useEffect(async () => { - await getDataStudentChart() - }, [dateStudentChart]) + fetchStudentData(); + }, [dateStudentChart]); + + useEffect(() => { + const fetchTeacherData = async () => { + await getDataTeacherChart(); + }; - useEffect(async () => { - await getDataTeacherChart() - }, [dateTeacherChart]) + fetchTeacherData(); + }, [dateTeacherChart]); const getDataTeacher = async () => { try {