From 180e47fa0a68d5a8d50c098c82b04f4a33480daf Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Mon, 17 Feb 2025 14:07:00 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Fix=20hooks=20in=20the=20T?= =?UTF-8?q?abOverview=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Screens/Settings/Tabs/TabOverview.js | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Settings/Tabs/TabOverview.js b/modules/ppcp-settings/resources/js/Components/Screens/Settings/Tabs/TabOverview.js index de1c16971..238cc1c68 100644 --- a/modules/ppcp-settings/resources/js/Components/Screens/Settings/Tabs/TabOverview.js +++ b/modules/ppcp-settings/resources/js/Components/Screens/Settings/Tabs/TabOverview.js @@ -12,11 +12,12 @@ import { import { Content, ContentWrapper } from '../../../ReusableComponents/Elements'; import SettingsCard from '../../../ReusableComponents/SettingsCard'; import { TITLE_BADGE_POSITIVE } from '../../../ReusableComponents/TitleBadge'; -import { useTodos } from '../../../../data/todos/hooks'; -import { useMerchantInfo } from '../../../../data/common/hooks'; -import { STORE_NAME as COMMON_STORE_NAME } from '../../../../data/common'; -import { STORE_NAME as TODOS_STORE_NAME } from '../../../../data/todos'; -import { CommonHooks, TodosHooks } from '../../../../data'; +import { + CommonStoreName, + TodosStoreName, + CommonHooks, + TodosHooks, +} from '../../../../data'; import { getFeatures } from '../Components/Overview/features-config'; @@ -27,9 +28,13 @@ import { import SpinnerOverlay from '../../../ReusableComponents/SpinnerOverlay'; const TabOverview = () => { - const { isReady: areTodosReady } = TodosHooks.useTodos(); + const { isReady: areTodosReady } = TodosHooks.useStore(); const { isReady: merchantIsReady } = CommonHooks.useStore(); + // TODO: Workaround before we implement the standard "persistentData" resolver. + // Calling this hook ensures that todos are loaded from the REST API at this point. + const {} = TodosHooks.useTodos(); + if ( ! areTodosReady || ! merchantIsReady ) { return ; } @@ -47,11 +52,12 @@ export default TabOverview; const OverviewTodos = () => { const [ isResetting, setIsResetting ] = useState( false ); - const { todos, isReady: areTodosReady, dismissTodo } = useTodos(); + const { todos, dismissTodo } = TodosHooks.useTodos(); + const { isReady: areTodosReady } = TodosHooks.useStore(); const { setActiveModal, setActiveHighlight } = - useDispatch( COMMON_STORE_NAME ); + useDispatch( CommonStoreName ); const { resetDismissedTodos, setDismissedTodos } = - useDispatch( TODOS_STORE_NAME ); + useDispatch( TodosStoreName ); const { createSuccessNotice } = useDispatch( noticesStore ); const showTodos = areTodosReady && todos.length > 0; @@ -118,9 +124,10 @@ const OverviewTodos = () => { const OverviewFeatures = () => { const [ isRefreshing, setIsRefreshing ] = useState( false ); - const { merchant, features: merchantFeatures } = useMerchantInfo(); + const { merchant, features: merchantFeatures } = + CommonHooks.useMerchantInfo(); const { refreshFeatureStatuses, setActiveModal } = - useDispatch( COMMON_STORE_NAME ); + useDispatch( CommonStoreName ); const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore );