File size: 930 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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;
};
|