import React from 'react'; import superagent from 'superagent'; import { fromUnixTime } from "date-fns"; import { formatInTimeZone } from 'date-fns-tz' import { Table, Segment, Button, Modal, Header, Message, Icon } from 'semantic-ui-react' import { DEFAULT_TIMEZONE } from '../../CloudApi/Constants.js'; export default class SocialFriendsList extends React.Component { constructor(props) { super(props); this.state = { friends: [], pendingGraphItemId: null, showDialog: false }; } async componentDidMount() { return this.reload(); } async reload() { this.setState({ loading: true }); try { this.setState({ friends: [] }); const res = await superagent.get(`/cloud/admin/account/${this.props.account.id}/social/graph/friends`).accept('json'); console.log(res.body); this.setState({ friends: res.body.items }); } catch (e) { console.log(e); } this.setState({ loading: false }); } onShowDialog(pendingGraphItemId, e) { e.preventDefault(); this.setState({showDialog: true, pendingGraphItemId }); } closeDialog(e) { this.setState({showDialog: false, pendingGraphItemId: null }); } async onConfirmDeleteBlockEntry(e) { e.preventDefault(); try { const result = await superagent.delete(`/cloud/admin/social/graph/${this.state.pendingGraphItemId}`).accept('json'); this.setState({ showDialog: false, pendingGraphItemId: null }); await this.reload(); } catch (e) { this.setState({ showDialog: false, pendingGraphItemId: null }); console.log(e); } } render() { if (this.state.loading) { return   } if (this.state.friends) { const friends = _.orderBy(this.state.friends, ["createdAt"], ["desc"]); return (
Date Target Account {friends.map(friend => { return ( {formatInTimeZone(fromUnixTime(friend.createdAt / 1000), DEFAULT_TIMEZONE, 'yyyy-MM-dd HH:mm:ss zzz')} {friend.targetSocialProfileSnapshot.username} ) })}
); } else { return null; } } }