diff --git a/frontend/src/System/ListSystems.js b/frontend/src/System/ListSystems.js index 0e46f36..757ad21 100644 --- a/frontend/src/System/ListSystems.js +++ b/frontend/src/System/ListSystems.js @@ -21,6 +21,7 @@ import { useGetSystemsQuery, } from '../features/api/apiSlice' import StateLinkList from "./StateLinkList"; import SystemsByState from "./SystemsByState"; import InternationList from "./InternationList"; +import TrendingList from "./TrendingList"; // ---------------------------------------------------- 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) => { setContactSystem(system); setContactVisible(true); @@ -54,6 +59,7 @@ const ListSystems = (props) => { const stateList = StateLinkList(states); const systemsByState = SystemsByState(states, handleContactClick); const international = InternationList(other, handleContactClick); + const trending = TrendingList(popularSystems, handleContactClick); return (
@@ -71,6 +77,7 @@ const ListSystems = (props) => { + {trending} {systemsByState} {international} diff --git a/frontend/src/System/TrendingList.js b/frontend/src/System/TrendingList.js new file mode 100644 index 0000000..116b325 --- /dev/null +++ b/frontend/src/System/TrendingList.js @@ -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(()) + trending.push(( + + {popularSystems && + popularSystems.map((system) => { + return navigate("/system/" + system.shortName)} onContactClick={onContactClick} /> + })} + + )) + return trending; +} + +export default TrendingList; \ No newline at end of file