FILE / Unmei/Frontend

src/pages/AdminPanel/News/APNews.tsx

Исходный файл и его история в репозитории.
FILE 5d4972145b0f0b453a339130ac1b21aca5ffcf0d
Files
Frontend/src/pages/AdminPanel/News/APNews.tsx
T
2020-06-24 18:56:24 +03:00

42 lines
1.0 KiB
TypeScript
Executable File

import React from "react";
import {fetchNews} from "../../../api/news";
import Group from "../../../ui/Group/Group";
import {Link} from "react-router-dom";
type Props = {
path: string
};
type State = {
news: PostType[]
};
class APNews extends React.Component<Props, State> {
state: State = {
news: []
}
componentDidMount() {
fetchNews().then(news => this.setState({ news }));
}
render() {
const { news } = this.state;
const { path } = this.props;
return (
<Group title={'Новости'}>
{news.map(post => (
<Link to={`${path}/${post.id}`} key={post.id}>
<div style={{ display: "flex" }}>
<div style={{ marginRight: '.5rem', fontWeight: 600 }}>{post.id}</div>
<div>{post.title}</div>
</div>
</Link>
))}
</Group>
)
}
}
export default APNews;