import React from 'react'; import superagent from 'superagent'; import { fromUnixTime } from "date-fns"; import { formatInTimeZone } from 'date-fns-tz' import { Table, Segment } from 'semantic-ui-react' import { DEFAULT_TIMEZONE } from '../../CloudApi/Constants.js'; export default class SocialRoomHistory extends React.Component { constructor(props) { super(props); this.state = { roomHistory: [], }; } async componentDidMount() { this.setState({ loading: true }); try { this.setState({ roomHistory: [] }); const res = await superagent.get(`/cloud/admin/account/${this.props.account.id}/social/history/room`).accept('json'); const historyItems = res.body.items; const roomHistory = _.orderBy(historyItems, ["createdAt"], ["desc"]); this.setState({ roomHistory }); } catch (e) { console.log(e); } this.setState({ loading: false }); } render() { if (this.state.loading) { return   } if (this.state.roomHistory) { return ( Date Room Type Visibility {this.state.roomHistory.map(historyItem => { return ( {formatInTimeZone(fromUnixTime(historyItem.createdAt / 1000), DEFAULT_TIMEZONE, 'yyyy-MM-dd HH:mm:ss zzz')} {historyItem.roomData ? historyItem.roomData.name : ""} {historyItem.room ? historyItem.room.name : ""} {historyItem.room.roomType} {historyItem.room.visibility} ) })}
); } else { return null; } } }