import { selectTab, TAB_IDS } from '../../../utils/tabSelector'; import { useEffect, useState } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { STORE_NAME as TODOS_STORE_NAME } from '../../../data/todos'; const TodoSettingsBlock = ( { todosData, className = '', setActiveModal, setActiveHighlight, onDismissTodo, } ) => { const [ dismissingIds, setDismissingIds ] = useState( new Set() ); const { completedTodos, dismissedTodos } = useSelect( ( select ) => ( { completedTodos: select( TODOS_STORE_NAME ).getCompletedTodos() || [], dismissedTodos: select( TODOS_STORE_NAME ).getDismissedTodos() || [], } ), [] ); useEffect( () => { if ( dismissedTodos.length === 0 ) { setDismissingIds( new Set() ); } }, [ dismissedTodos ] ); if ( todosData.length === 0 ) { return null; } const handleDismiss = ( todoId, e ) => { e.preventDefault(); e.stopPropagation(); setDismissingIds( ( prev ) => new Set( [ ...prev, todoId ] ) ); setTimeout( () => { onDismissTodo( todoId ); }, 300 ); }; // Filter out dismissed todos for display const visibleTodos = todosData.filter( ( todo ) => ! dismissedTodos.includes( todo.id ) ); return (