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

Function ResolutionMonitorBadge

src/components/MarketDetailPanel.tsx:826–858  ·  view source on GitHub ↗
({ eventId }: { eventId: string })

Source from the content-addressed store, hash-verified

824}
825
826function ResolutionMonitorBadge({ eventId }: { eventId: string }) {
827 const { t } = useI18n();
828 const [status, setStatus] = useState<{ sourceType: string; lastCheckedAt: string | null } | null>(null);
829 const [renderNow] = useState(() => Date.now());
830
831 useEffect(() => {
832 fetch(`/api/resolution-alerts?marketId=${eventId}`)
833 .then((r) => r.json())
834 .then((data) => { if (data.monitor) setStatus(data.monitor); })
835 .catch(() => {});
836 }, [eventId]);
837
838 if (!status) return null;
839
840 const isMonitored = ["known_feed", "price_feed", "sports_feed"].includes(status.sourceType);
841 if (isMonitored) {
842 const ago = status.lastCheckedAt
843 ? `${Math.round((renderNow - new Date(status.lastCheckedAt).getTime()) / 60_000)}m ago`
844 : "pending";
845 const monitorKey = status.sourceType === "price_feed" ? "detail.priceMonitored" : status.sourceType === "sports_feed" ? "detail.sportsMonitored" : "detail.rssMonitored";
846 return (
847 <span className="ml-2 text-[10px] text-[#22c55e]/70">
848 {t(monitorKey, { ago })}
849 </span>
850 );
851 }
852
853 return (
854 <span className="ml-2 text-[10px] text-[var(--text-ghost)]">
855 {t("detail.notMonitorable")}
856 </span>
857 );
858}

Callers

nothing calls this directly

Calls 1

useI18nFunction · 0.90

Tested by

no test coverage detected