mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 17:27:37 -05:00
Merge pull request #164 from noquinn/trending-systems
Add "trending" category for systems with the most listeners
This commit is contained in:
@@ -21,6 +21,7 @@ import { useGetSystemsQuery, } from '../features/api/apiSlice'
|
|||||||
import StateLinkList from "./StateLinkList";
|
import StateLinkList from "./StateLinkList";
|
||||||
import SystemsByState from "./SystemsByState";
|
import SystemsByState from "./SystemsByState";
|
||||||
import InternationList from "./InternationList";
|
import InternationList from "./InternationList";
|
||||||
|
import TrendingList from "./TrendingList";
|
||||||
// ----------------------------------------------------
|
// ----------------------------------------------------
|
||||||
|
|
||||||
const ListSystems = (props) => {
|
const ListSystems = (props) => {
|
||||||
@@ -46,6 +47,10 @@ const ListSystems = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let popularSystems = [];
|
||||||
|
if (isSuccess && systems.systems)
|
||||||
|
popularSystems = systems.systems.sort((a, b) => b.clientCount - a.clientCount).slice(0, 4);
|
||||||
|
|
||||||
const handleContactClick = (system) => {
|
const handleContactClick = (system) => {
|
||||||
setContactSystem(system);
|
setContactSystem(system);
|
||||||
setContactVisible(true);
|
setContactVisible(true);
|
||||||
@@ -54,6 +59,7 @@ const ListSystems = (props) => {
|
|||||||
const stateList = StateLinkList(states);
|
const stateList = StateLinkList(states);
|
||||||
const systemsByState = SystemsByState(states, handleContactClick);
|
const systemsByState = SystemsByState(states, handleContactClick);
|
||||||
const international = InternationList(other, handleContactClick);
|
const international = InternationList(other, handleContactClick);
|
||||||
|
const trending = TrendingList(popularSystems, handleContactClick);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={contextRef}>
|
<div ref={contextRef}>
|
||||||
@@ -71,6 +77,7 @@ const ListSystems = (props) => {
|
|||||||
</List.Content>
|
</List.Content>
|
||||||
</List.Item>
|
</List.Item>
|
||||||
</List>
|
</List>
|
||||||
|
{trending}
|
||||||
{systemsByState}
|
{systemsByState}
|
||||||
{international}
|
{international}
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
|
|||||||
25
frontend/src/System/TrendingList.js
Normal file
25
frontend/src/System/TrendingList.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import {
|
||||||
|
Card,
|
||||||
|
Header
|
||||||
|
} from "semantic-ui-react";
|
||||||
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
import SystemCard from "./SystemCard";
|
||||||
|
|
||||||
|
|
||||||
|
const TrendingList = (popularSystems, onContactClick) => {
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
let trending = [];
|
||||||
|
trending.push((<Header as="h2" id="trending">Trending</Header>))
|
||||||
|
trending.push((
|
||||||
|
<Card.Group itemsPerRow={4} stackable={true}>
|
||||||
|
{popularSystems &&
|
||||||
|
popularSystems.map((system) => {
|
||||||
|
return <SystemCard system={system} key={system.shortName} onClick={(e) => navigate("/system/" + system.shortName)} onContactClick={onContactClick} />
|
||||||
|
})}
|
||||||
|
</Card.Group>
|
||||||
|
))
|
||||||
|
return trending;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TrendingList;
|
||||||
Reference in New Issue
Block a user