33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import EmptyState from "~/components/ui/emptyState/EmptyState";
|
|
import type { KbCategoryDto } from "../../dtos/KbCategoryDto";
|
|
import type { KnowledgeBaseDto } from "../../dtos/KnowledgeBaseDto";
|
|
import KbArticles from "./KbArticles";
|
|
import KnowledgeBaseUtils from "../../utils/KnowledgeBaseUtils";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
export default function KbArticlesBySection({ kb, item }: { kb: KnowledgeBaseDto; item: KbCategoryDto }) {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<div>
|
|
{item.articles.length === 0 ? (
|
|
<EmptyState className="bg-background" captions={{ thereAreNo: t("knowledgeBase.article.empty") }} />
|
|
) : (
|
|
<div className="space-y-6">
|
|
{KnowledgeBaseUtils.getCategoryArticlesBySections({ kb, category: item }).map((item, idx) => {
|
|
return (
|
|
<div key={idx} className="space-y-3">
|
|
{item.section && (
|
|
<div className="flex items-center space-x-2">
|
|
<div className="text-xl font-bold">{item.section.title}</div>
|
|
</div>
|
|
)}
|
|
<KbArticles kb={kb} items={item.articles} />
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|