♻️ Fix hooks in the TabOverview component

This commit is contained in:
Philipp Stracker 2025-02-17 14:07:00 +01:00
parent b9785d1705
commit 180e47fa0a
No known key found for this signature in database

View file

@ -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 <SpinnerOverlay asModal={ true } />;
}
@ -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 );