import { Badge, Card, List, Typography } from "antd"; import { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router"; import { get } from "../../request"; import type { IChapterData, IChapterListResponse } from "../../api/Corpus"; import StudioName from "../auth/Studio"; import type { ChapterData } from "../corpus/ChapterCard"; const { Title, Text, Paragraph } = Typography; const ChapterNewListWidget = () => { const [listData, setListData] = useState([]); const navigate = useNavigate(); useEffect(() => { get(`/v2/progress?view=chapter&limit=4&lang=zh`).then( (json) => { console.log("chapter list ajax", json); if (json.ok) { const newTree: ChapterData[] = json.data.rows.map( (item: IChapterData) => { return { title: item.title, paliTitle: item.toc, path: item.path, book: item.book, paragraph: item.para, summary: item.summary, tag: item.tags.map((item) => { return { title: item.name, key: item.name }; }), channel: { name: item.channel.name, id: item.channel_id, type: "translation", }, studio: item.studio, progress: Math.round(item.progress * 100), createdAt: item.created_at, updatedAt: item.updated_at, hit: item.view, like: item.like, channelInfo: "string", }; } ); setListData(newTree); } } ); }, []); return ( { const channel = item.channel.id ? `?channel=${item.channel.id}` : ""; return ( { navigate( `/article/chapter/${item.book}-${item.paragraph}${channel}` ); }} > <Link to={`/article/chapter/${item.book}-${item.paragraph}${channel}`} > {item.title ? item.title : item.paliTitle} </Link>
{item.paliTitle}
{item.summary}
); }} /> ); }; export default ChapterNewListWidget;