import React from 'react';
import superagent from 'superagent';
import { formatDistanceToNowStrict, formatDuration } from "date-fns";
import { formatInTimeZone } from 'date-fns-tz';
import { Table, Button, Label, Segment, Header, Image, Icon } from 'semantic-ui-react'
import { DEFAULT_TIMEZONE } from '../CloudApi/Constants.js';
export default class AccountSearchResultsTable extends React.Component {
renderRow(account, index) {
let verificationControl = account.isVerified ? (
) : (
);
let accountStatus = account.status == "Banned" ? (
) : (
)
let avatarUrl = "/images/avatar_b.jpg";
if (account.oculusProfile && account.oculusProfile.oculusImageURL) {
avatarUrl = account.oculusProfile.oculusImageURL;
} else if (account.steamProfile && account.steamProfile.avatarfull) {
avatarUrl = account.steamProfile.avatarfull;
}
let accessPolicyLabels = account.accessPolicies.map((policy) => {
return (
)
});
let oculusLabel = account.oculusProfile && ;
let steamLabel = account.steamProfile && ;
const createdAt = formatInTimeZone(new Date(account.createdAt), DEFAULT_TIMEZONE, 'PPPp z');
const accountAge = formatDistanceToNowStrict(new Date(account.createdAt), { unit: "day" });
return (
{accountStatus}
{account.username}
Account Id: {account.id}
{createdAt}
{accountAge} ago
{oculusLabel} {steamLabel}
{accessPolicyLabels} {verificationControl}
);
}
render() {
// Sort results by createdAt ascending
if (this.props.results) {
let results = this.props.results;
if (results) {
results = results.sort((a, b) => {
return new Date(b.createdAt) - new Date(a.createdAt);
});
}
return (
Status
Username
Created
Attached Accounts
Info
{results.map((account, index) => this.renderRow(account, index))}
);
}
}
}