import React, { Component, useState } from "react";
import {
Card,
Icon,
Label,
Grid,
Segment,
Popup,
Button
} from "semantic-ui-react";
function SystemCard(props) {
const { system, keepShort, onClick, onContactClick } = props;
var location = "";
var clientCount = "";
var callAvg = "";
let description = system.description;
let statusMessage = "";
if (system.status && system.status.length > 0) {
statusMessage = system.status
if (statusMessage.length > 25) {
statusMessage = statusMessage.substring(0, 25) + "...";
}
}
const handleContactClick = (event) => {
event.stopPropagation();
onContactClick(system);
}
const onCardClick = (event) => {
onClick();
}
if (keepShort && (description.length > 100)) {
description = description.substring(0, 96) + "...";
}
if (keepShort) {
statusMessage = "";
}
if (system.callAvg) {
callAvg = Math.round(system.callAvg * 10) / 10 + "/min"
}
if (system.clientCount === 1) {
clientCount = "1 listener";
} else if (system.clientCount > 1) {
clientCount = system.clientCount + " listeners"
}
let status = (<>>)
if (system.active) {
status = (
{clientCount && {clientCount}
}
{callAvg && {callAvg}
}
)
} else {
const lastActive = new Date(system.lastActive);
status = (
Last Active {lastActive.toLocaleDateString()}
)
}
if (system) {
switch (system.systemType) {
case "state":
location = system.state;
break;
case "city":
location = system.city + ", " + system.state;
break;
case "county":
location = system.county + ", " + system.state;
break;
case "international":
location = system.country;
break;
default:
location = system.city + ", " + system.state;
}
}
return (
{system.name}
{location}
{system.screenName && }
{system.allowContact && }
{description}
{statusMessage &&
{statusMessage}} />
}
{status}
);
}
export default SystemCard;