import { Article } from "article/domain/articleEntity";
import type { ArticleStore } from "../domain/articleStore";

const getArticleUseCase = async (
  getArticle: ArticleStore["getArticle"],
  setArticle: ArticleStore["setArticle"],
  id: Article["id"]
): Promise<Article | null> => {
  const article = await getArticle(id);
  if (article) {
    await setArticle(article);
  }
  return article;
};

export { getArticleUseCase };
