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

Function ResolutionBanner

src/components/MarketDetailPanel.tsx:789–824  ·  view source on GitHub ↗
({ markets }: { markets: ProcessedMarket["markets"] })

Source from the content-addressed store, hash-verified

787});
788
789function ResolutionBanner({ markets }: { markets: ProcessedMarket["markets"] }) {
790 const { t } = useI18n();
791 const resolved: { question: string; winner: string }[] = [];
792 for (const m of markets) {
793 try {
794 const raw = m.outcomePrices
795 ? Array.isArray(m.outcomePrices) ? m.outcomePrices : JSON.parse(m.outcomePrices)
796 : null;
797 if (!raw) continue;
798 const prices = raw.map((p: string) => parseFloat(p));
799 let labels: string[];
800 if (Array.isArray(m.outcomes)) labels = m.outcomes;
801 else if (typeof m.outcomes === "string") {
802 try { labels = JSON.parse(m.outcomes); } catch { labels = []; }
803 } else {
804 labels = prices.length === 2 ? ["Yes", "No"] : [];
805 }
806 const winIdx = prices.findIndex((p: number) => p >= 0.99);
807 if (winIdx >= 0 && labels[winIdx]) {
808 resolved.push({ question: m.question || "", winner: labels[winIdx] });
809 }
810 } catch { /* skip */ }
811 }
812 if (resolved.length === 0) return null;
813 return (
814 <div className="px-3 py-2 border border-[#22c55e]/20 bg-[#22c55e]/5 rounded-sm text-[11px] space-y-1">
815 {resolved.map((r, i) => (
816 <div key={i}>
817 <span className="uppercase tracking-[0.1em] text-[var(--text-faint)]">{t("detail.resolved")}</span>
818 <span className="text-[#22c55e] font-bold">{r.winner}</span>
819 {r.question && <span className="text-[var(--text-dim)] ml-1">({r.question})</span>}
820 </div>
821 ))}
822 </div>
823 );
824}
825
826function ResolutionMonitorBadge({ eventId }: { eventId: string }) {
827 const { t } = useI18n();

Callers

nothing calls this directly

Calls 1

useI18nFunction · 0.90

Tested by

no test coverage detected