|
|
@@ -1,48 +1,89 @@
|
|
|
-import { Col, Layout, Progress, Row, Space } from "antd";
|
|
|
+import { Col, Layout, Progress, Row, Space, Tabs } from "antd";
|
|
|
import { Typography } from "antd";
|
|
|
import { LikeOutlined, EyeOutlined } from "@ant-design/icons";
|
|
|
import { ChannelInfoProps } from "../api/Channel";
|
|
|
import ChannelListItem from "../channel/ChannelListItem";
|
|
|
import TimeShow from "../utilities/TimeShow";
|
|
|
+import { useIntl } from "react-intl";
|
|
|
+import { Link } from "react-router-dom";
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
export interface IChapterChannelData {
|
|
|
- channel: ChannelInfoProps;
|
|
|
- progress: number;
|
|
|
- hit: number;
|
|
|
- like: number;
|
|
|
- updatedAt: string;
|
|
|
+ channel: ChannelInfoProps;
|
|
|
+
|
|
|
+ progress: number;
|
|
|
+ hit: number;
|
|
|
+ like: number;
|
|
|
+ updatedAt: string;
|
|
|
}
|
|
|
interface IWidgetChapterInChannel {
|
|
|
- data: IChapterChannelData[];
|
|
|
+ data: IChapterChannelData[];
|
|
|
+ book: number;
|
|
|
+ para: number;
|
|
|
}
|
|
|
-const Widget = (prop: IWidgetChapterInChannel) => {
|
|
|
- const view = prop.data.map((item, id) => {
|
|
|
- return (
|
|
|
- <Layout key={id}>
|
|
|
- <Row>
|
|
|
- <Col span={5}>
|
|
|
- <ChannelListItem data={item.channel} />
|
|
|
- </Col>
|
|
|
- <Col span={5}>
|
|
|
- <Progress percent={item.progress} size="small" />
|
|
|
- </Col>
|
|
|
- <Col span={8}></Col>
|
|
|
- </Row>
|
|
|
+const Widget = ({ data, book, para }: IWidgetChapterInChannel) => {
|
|
|
+ const intl = useIntl(); //i18n
|
|
|
+ function getTab(type: string): JSX.Element[] {
|
|
|
+ const output = data.map((item, id) => {
|
|
|
+ if (item.channel.channelType === type) {
|
|
|
+ return (
|
|
|
+ <div key={id}>
|
|
|
+ <Row>
|
|
|
+ <Col span={5}>
|
|
|
+ <Link
|
|
|
+ to={`/article/chapter/${book}-${para}_${item.channel.channelId}`}
|
|
|
+ target="_blank"
|
|
|
+ >
|
|
|
+ <ChannelListItem data={item.channel} />
|
|
|
+ </Link>
|
|
|
+ </Col>
|
|
|
+ <Col span={5}>
|
|
|
+ <Progress percent={item.progress} size="small" />
|
|
|
+ </Col>
|
|
|
+ <Col span={8}></Col>
|
|
|
+ </Row>
|
|
|
+
|
|
|
+ <Text type="secondary">
|
|
|
+ <Space style={{ paddingLeft: "2em" }}>
|
|
|
+ <EyeOutlined />
|
|
|
+ {item.hit} | <LikeOutlined />
|
|
|
+ {item.like} |
|
|
|
+ <TimeShow time={item.updatedAt} title={item.updatedAt} />
|
|
|
+ </Space>
|
|
|
+ </Text>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return <></>;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return output;
|
|
|
+ }
|
|
|
|
|
|
- <Text type="secondary">
|
|
|
- <Space style={{ paddingLeft: "2em" }}>
|
|
|
- <EyeOutlined />
|
|
|
- {item.hit} | <LikeOutlined />
|
|
|
- {item.like} |
|
|
|
- <TimeShow time={item.updatedAt} title={item.updatedAt} />
|
|
|
- </Space>
|
|
|
- </Text>
|
|
|
- </Layout>
|
|
|
- );
|
|
|
- });
|
|
|
- return <>{view}</>;
|
|
|
+ const items = [
|
|
|
+ {
|
|
|
+ label: intl.formatMessage({ id: "channel.type.translation.label" }),
|
|
|
+ key: "translation",
|
|
|
+ children: getTab("translation"),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: intl.formatMessage({ id: "channel.type.nissaya.label" }),
|
|
|
+ key: "nissaya",
|
|
|
+ children: getTab("nissaya"),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: intl.formatMessage({ id: "channel.type.commentary.label" }),
|
|
|
+ key: "commentary",
|
|
|
+ children: getTab("commentary"),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: intl.formatMessage({ id: "channel.type.original.label" }),
|
|
|
+ key: "original",
|
|
|
+ children: getTab("original"),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ return <Tabs items={items} />;
|
|
|
};
|
|
|
|
|
|
export default Widget;
|