/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { ONBOARDING_STORE_NAME } from '@woocommerce/data';
/**
* Internal dependencies
*/
import '../tasks/tasks.scss';
import './style.scss';
import TaskList from './task-list';
import TaskListPlaceholder from './placeholder';
import { Task } from '../tasks/task';
const TaskDashboard = ( { query, twoColumns } ) => {
const { task } = query;
const { isResolving, taskLists } = useSelect( ( select ) => {
return {
taskLists: select( ONBOARDING_STORE_NAME ).getTaskListsByIds( [
'setup_two_column',
'extended_two_column',
] ),
isResolving: select( ONBOARDING_STORE_NAME ).isResolving(
'getTaskListsByIds'
),
};
} );
const getCurrentTask = () => {
if ( ! task ) {
return null;
}
const tasks = taskLists.reduce(
( acc, taskList ) => [ ...acc, ...taskList.tasks ],
[]
);
const currentTask = tasks.find( ( t ) => t.id === task );
if ( ! currentTask ) {
return null;
}
return currentTask;
};
const currentTask = getCurrentTask();
if ( task && ! currentTask ) {
return null;
}
if ( isResolving || ! taskLists[ 0 ] ) {
return