diff --git a/web/src/domain/useCase/useAdminHomePage.ts b/web/src/domain/useCase/useAdminHomePage.ts index e50539fccc5331dcd49eb303b49207cf9ac60a4a..c0f8ccd0d2d7b507d6186b71016329044ee0e7d9 100644 --- a/web/src/domain/useCase/useAdminHomePage.ts +++ b/web/src/domain/useCase/useAdminHomePage.ts @@ -47,7 +47,7 @@ export const useAdminHomePage = () => { setIsLoading(false); }; checkAdminRole(); - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, [user]); // Update town information diff --git a/web/src/domain/useCase/useAdminTownInfo.ts b/web/src/domain/useCase/useAdminTownInfo.ts index 5b1fed5160670da71237391c3ca20c8d1fd60278..1547ccb17af13a9c94647a907be5f29633f5182c 100644 --- a/web/src/domain/useCase/useAdminTownInfo.ts +++ b/web/src/domain/useCase/useAdminTownInfo.ts @@ -3,31 +3,28 @@ import { useEffect, useState } from "react"; import { useGetStatesList } from "./useGetStatesList"; // Custom hook for managing town information in admin panel -export const useAdminTownInfo = (updateTown: ()=>void) => { +export const useAdminTownInfo = (updateTown: () => void) => { const [isEnglish, setIsEnglish] = useState(false); - const [isLoading, setIsLoading] = useState(true); const [renderCount, setRenderCount] = useState(0); - const {getStates, statesList} = useGetStatesList(); + const { getStates, statesList } = useGetStatesList(); // Function to force re-render the list - const forceRenderList = () =>{ + const forceRenderList = () => { updateTown(); - setRenderCount(prevCount => prevCount + 1); - } + setRenderCount((prevCount) => prevCount + 1); + }; // Fetch states on component mount - useEffect(()=> { + useEffect(() => { getStates(); - // eslint-disable-next-line react-hooks/exhaustive-deps - },[]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return { isEnglish, - isLoading, setIsEnglish, - setIsLoading, forceRenderList, renderCount, statesList, - } -} \ No newline at end of file + }; +}; diff --git a/web/src/presentation/admin/admin_town_info/admin_town_info.tsx b/web/src/presentation/admin/admin_town_info/admin_town_info.tsx index 5ca208e3312abae56b099fcf5f542a406517ee73..c3609171eb236dac1f31b530431cad158a796d14 100644 --- a/web/src/presentation/admin/admin_town_info/admin_town_info.tsx +++ b/web/src/presentation/admin/admin_town_info/admin_town_info.tsx @@ -13,6 +13,7 @@ interface props { setIsWindowActive: Dispatch>; town: Town | undefined; updateTown: () => Promise; + isLoading: boolean; } // Main component function @@ -21,17 +22,11 @@ export const AdminTownInfo = ({ isWindowActive, setIsWindowActive, town, + isLoading, }: props) => { // Destructure values from the custom hook - const { - isEnglish, - isLoading, - setIsEnglish, - setIsLoading, - renderCount, - forceRenderList, - statesList, - } = useAdminTownInfo(updateTown); + const { isEnglish, setIsEnglish, renderCount, forceRenderList, statesList } = + useAdminTownInfo(updateTown); // State to manage the visibility of the town register window const [isTownRegisterWindowActive, setIsTownRegisterWindowActive] = @@ -59,6 +54,8 @@ export const AdminTownInfo = ({ ); } + if (isLoading) return ; + // Main render of the component return (
@@ -73,29 +70,12 @@ export const AdminTownInfo = ({ /> )}
- {isLoading && ( -
- -
- )} -

{town?.name}

- setIsLoading(false)} - alt="" - /> +
diff --git a/web/src/presentation/admin/panel/admin_home_page.tsx b/web/src/presentation/admin/panel/admin_home_page.tsx index 13e47c8934e68b9e1c311f55a07a8af77f43e62b..4fdff7817ea5b8b084bdb9ff97a37fd6a2a0bd25 100644 --- a/web/src/presentation/admin/panel/admin_home_page.tsx +++ b/web/src/presentation/admin/panel/admin_home_page.tsx @@ -114,6 +114,7 @@ export const AdminHomePage = () => { setIsWindowActive={setIsWindowActive} isWindowActive={isWindowActive} town={town} + isLoading={isLoading} /> ); case AdminSelectedPanel.PLACES: