import React from 'react';
import superagent from 'superagent';
import {Button, Header, Label, Table, Image} from 'semantic-ui-react';
import EventsWrapper from './EventsWrapper.jsx';
import { DEFAULT_TIMEZONE } from '../CloudApi/Constants.js';
export default class TopicRow extends React.Component {
constructor(props) {
super(props);
}
async componentDidMount() {
}
render() {
if (!this.props.topic) {
return
;
}
const createdAt = formatInTimeZone(fromUnixTime(this.props.topic.createdAt._seconds), DEFAULT_TIMEZONE, 'PPPp z');
const subscriptionsColor = this.props.topic.subscriptionsCount === 0 ? "orange" : "green";
return (
{this.props.topic.title}
{this.props.topic.description}
{this.props.topic.name}
{this.props.topic.subscriptionsCount}
{this.props.topic.status}
{this.props.topic.id}
{createdAt}
)
}
}
class Topics extends React.Component {
constructor(props) {
super(props);
this.state = {
topics: [],
loading: false
};
}
async componentDidMount() {
this.setState({ loading: true });
const res = await superagent.get(`/api/admin/topics`).accept('json');
console.log(res.body);
this.setState({ loading: false, topics: res.body});
}
render() {
return (
Title
Description
Name
Subscribers
Status
Topic ID
Created At
{this.state.topics.map(topic => {
return (
);
})}
);
}
}