MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / SidePanel

Function SidePanel

src/components/SidePanel.tsx:18–141  ·  view source on GitHub ↗
({
  mapped,
  unmapped,
  activeCategories,
  onToggleCategory,
  onFlyTo,
}: SidePanelProps)

Source from the content-addressed store, hash-verified

16const NEW_THRESHOLD_MS = 6 * 60 * 60 * 1000; // 6 hours
17
18export default function SidePanel({
19 mapped,
20 unmapped,
21 activeCategories,
22 onToggleCategory,
23 onFlyTo,
24}: SidePanelProps) {
25 const [renderNow] = useState(() => Date.now());
26 const all = [...mapped, ...unmapped];
27 const filtered = all.filter((m) => activeCategories.has(m.category));
28
29 const newMarkets = filtered
30 .filter((m) => m.createdAt && renderNow - new Date(m.createdAt).getTime() < NEW_THRESHOLD_MS)
31 .sort((a, b) => new Date(b.createdAt!).getTime() - new Date(a.createdAt!).getTime())
32 .slice(0, 10);
33
34 const movers = filtered
35 .filter((i) => i.change !== null && !isNaN(i.change!))
36 .sort((a, b) => Math.abs(b.change!) - Math.abs(a.change!))
37 .slice(0, 10);
38
39 const trending = [...filtered]
40 .sort((a, b) => (b.volume24h || 0) - (a.volume24h || 0))
41 .slice(0, 10);
42
43 const global = [...unmapped]
44 .filter((m) => activeCategories.has(m.category))
45 .sort((a, b) => (b.volume24h || 0) - (a.volume24h || 0))
46 .slice(0, 8);
47
48 return (
49 <aside className="w-[370px] bg-[#0a0a0a] border-l border-[#1a1a1a] overflow-y-auto shrink-0 hidden md:block scrollbar-thin">
50 <CategoryFilter
51 active={activeCategories}
52 onToggle={onToggleCategory}
53 />
54
55 {newMarkets.length > 0 && (
56 <Section title="NEW_MARKETS">
57 {newMarkets.map((m) => (
58 <MarketCard
59 key={m.id}
60 market={m}
61 onClick={() =>
62 m.coords
63 ? onFlyTo(m.coords, m.id)
64 : window.open(
65 `https://polymarket.com/event/${encodeURIComponent(m.slug)}?r=0xaa`,
66 "_blank",
67 "noopener,noreferrer"
68 )
69 }
70 />
71 ))}
72 </Section>
73 )}
74
75 <Section title="MOVERS_24H">

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected