From e092dc64b14d6c2b1dcc1845b4942be2178694e6 Mon Sep 17 00:00:00 2001 From: Quy_FE Date: Tue, 29 Apr 2025 09:27:33 +0700 Subject: [PATCH] Feat : fix back button --- src/_screens/home/detail-room-education/index.js | 6 ++++-- src/_screens/home/education-department/index.js | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/_screens/home/detail-room-education/index.js b/src/_screens/home/detail-room-education/index.js index a02623a..41e6376 100644 --- a/src/_screens/home/detail-room-education/index.js +++ b/src/_screens/home/detail-room-education/index.js @@ -13,10 +13,12 @@ import BoxDoughnutBarChart from "../../../_components/boxChart/BoxDoughnutBarCha import { apiCaller, history } from "../../../_helpers"; import { replacePathParams } from "../../../_helpers/utils"; import $ from "jquery"; -import { useParams } from "react-router-dom"; +import { useLocation, useParams } from "react-router-dom"; export default function DetailRoomEducation() { - const {idRoom,isBack} = useParams() + const {idRoom} = useParams() + const location = useLocation(); + const isBack = location.state?.isBack; const grade = useSelector((state) => state.grade); const authentication = useSelector((state) => state.authentication); const [dateStudentChart, setDateStudentChart] = useState(new Date()) diff --git a/src/_screens/home/education-department/index.js b/src/_screens/home/education-department/index.js index 60cf3a3..b0d262b 100644 --- a/src/_screens/home/education-department/index.js +++ b/src/_screens/home/education-department/index.js @@ -83,7 +83,13 @@ export default function EducationDepartmentHome() { } const goToDetailRoomEducation = (item) => { - history.push(replacePathParams(PATH.home.detailRoomEducation, {idRoom: item?.id, isBack: true})) + const idRoom = item?.id; + const detailPath = replacePathParams(PATH.home.detailRoomEducation, { idRoom }); + + history.push({ + pathname: detailPath, + state: { isBack: true }, + }); } useEffect(() => {