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 SocialUserHistory extends React.Component { constructor(props) { super(props); this.state = { userHistory: [], }; } async componentDidMount() { this.setState({ loading: true }); try { this.setState({ userHistory: [] }); const res = await superagent.get(`/cloud/admin/account/${this.props.account.id}/social/history/user`).accept('json'); const historyItems = res.body.items; const userHistory = _.orderBy(historyItems, ["createdAt"], ["desc"]); this.setState({ userHistory }); } catch (e) { console.log(e); } this.setState({ loading: false }); } render() { if (this.state.loading) { return   } if (this.state.userHistory) { return ( Date User Profile Room {this.state.userHistory.map(historyItem => { console.log(historyItem); return ( {formatInTimeZone(fromUnixTime(historyItem.createdAt / 1000), DEFAULT_TIMEZONE, 'yyyy-MM-dd HH:mm:ss zzz')} {historyItem.socialProfileSnapshot.username} {historyItem.roomData ? {historyItem.roomData.name} : ""} {historyItem.room ? {historyItem.room.name} : ""} ) })}
); } else { return null; } } }