| 787 | }); |
| 788 | |
| 789 | function 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 | |
| 826 | function ResolutionMonitorBadge({ eventId }: { eventId: string }) { |
| 827 | const { t } = useI18n(); |