import type { LearningContent } from "@/types";
import { assertUnreachable, getAssignmentTypeTitle } from "@/utils/utils";
import { useTranslation } from "i18next-vue";

export interface LearningContentIdentifier {
  title: string;
  icon: string;
}

export function learningContentTypeData(
  lc: LearningContent
): LearningContentIdentifier {
  const { t } = useTranslation();
  switch (lc.content_type) {
    case "learnpath.LearningContentAssignment": {
      return {
        title: getAssignmentTypeTitle(lc.assignment_type),
        icon: "it-icon-lc-assignment",
      };
    }
    case "learnpath.LearningContentAttendanceCourse":
      return {
        title: t("learningContentTypes.attendanceCourse"),
        icon: "it-icon-lc-training",
      };
    case "learnpath.LearningContentDocumentList":
      return {
        title: t("learningContentTypes.documents"),
        icon: "it-icon-lc-document",
      };
    case "learnpath.LearningContentLearningModule":
      return {
        title: t("learningContentTypes.learningModule"),
        icon: "it-icon-lc-learning-module",
      };
    case "learnpath.LearningContentKnowledgeAssessment":
      return {
        title: t("learningContentTypes.knowledgeAssessment"),
        icon: "it-icon-lc-test",
      };
    case "learnpath.LearningContentMediaLibrary":
      return { title: t("a.Mediathek"), icon: "it-icon-lc-media-library" };
    case "learnpath.LearningContentVideo":
      return { title: t("learningContentTypes.video"), icon: "it-icon-lc-video" };
    case "learnpath.LearningContentEdoniqTest":
      return { title: t("learningContentTypes.test"), icon: "it-icon-lc-test" };
    case "learnpath.LearningContentRichText":
      return { title: t("learningContentTypes.text"), icon: "it-icon-lc-resource" };
    case "learnpath.LearningContentFeedbackUK":
    case "learnpath.LearningContentFeedbackVV":
      return { title: t("learningContentTypes.feedback"), icon: "it-icon-lc-feedback" };
    case "learnpath.LearningContentPlaceholder":
      return {
        title: t("learningContentTypes.placeholder"),
        icon: "it-icon-lc-document",
      };
  }

  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  return assertUnreachable(`did not handle ${lc.content_type}`);
}
