react-code-dataset / wp-calypso /client /launchpad /hooks /use-complete-launchpad-task-with-notice-on-load.ts
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
import { useEffect } from 'react';
import { useCompleteLaunchpadTasksWithNotice } from './use-complete-launchpad-tasks-with-notice';
interface TaskCompleteNoticeOptions {
taskSlug: string;
enabled: boolean;
noticeId: string;
noticeText: string;
noticeDuration?: number;
}
export const useCompleteLaunchpadTaskWithNoticeOnLoad = ( {
taskSlug,
enabled,
noticeId,
noticeText,
noticeDuration,
}: TaskCompleteNoticeOptions ) => {
const completeTasks = useCompleteLaunchpadTasksWithNotice( { notifyIfNothingChanged: false } );
useEffect( () => {
if ( enabled ) {
completeTasks( [ taskSlug ], noticeText, {
id: noticeId,
duration: noticeDuration,
} );
}
}, [ completeTasks, enabled, taskSlug, noticeId, noticeText, noticeDuration ] );
};
export const CompleteLaunchpadTaskWithNoticeOnLoad = ( props: TaskCompleteNoticeOptions ) => {
useCompleteLaunchpadTaskWithNoticeOnLoad( props );
return null;
};