import { debounce } from "lodash";
import NotificationI from "ui/domain/uiNotificationEntity";
import { UIStore } from "ui/domain/uiStore";

type NotificationRemoveUIStore = Pick<UIStore, "removeNotification">

const debouncedTask = debounce((task) => Promise.resolve(task()), 200);

const removeNotificationUseCase = (store: NotificationRemoveUIStore, payload: NotificationI['uid']) => {
  return debouncedTask(() => store.removeNotification(payload));
}

export {removeNotificationUseCase};