import { QuestionFragment } from "../../fragments.generated"; type QualityIndicator = QuestionFragment["qualityIndicators"]; type IndicatorName = keyof QualityIndicator; // this duplication can probably be simplified with typescript magic, but this is good enough for now type UsedIndicatorName = | "volume" | "numForecasters" | "spread" | "sharesVolume" | "liquidity" | "tradeVolume" | "openInterest"; const qualityIndicatorLabels: { [k in UsedIndicatorName]: string } = { // numForecasts: null, // stars: null, // yesBid: "Yes bid", // yesAsk: "Yes ask", volume: "Volume", numForecasters: "Forecasters", spread: "Spread", sharesVolume: "Shares vol.", liquidity: "Liquidity", tradeVolume: "Volume", openInterest: "Interest", }; const formatNumber = (num) => { if (Number(num) < 1000) { return Number(num).toFixed(0); } else if (num < 10000) { return (Number(num) / 1000).toFixed(1) + "k"; } else { return (Number(num) / 1000).toFixed(0) + "k"; } }; /* Display functions*/ const getPercentageSymbolIfNeeded = ({ indicator, platform, }: { indicator: UsedIndicatorName; platform: string; }) => { let indicatorsWhichNeedPercentageSymbol: IndicatorName[] = ["spread"]; if (indicatorsWhichNeedPercentageSymbol.includes(indicator)) { return "%"; } else { return ""; } }; const getCurrencySymbolIfNeeded = ({ indicator, platform, }: { indicator: UsedIndicatorName; platform: string; }) => { const indicatorsWhichNeedCurrencySymbol: IndicatorName[] = [ "volume", "tradeVolume", "openInterest", "liquidity", ]; let dollarPlatforms = ["predictit", "kalshi", "polymarket"]; if (indicatorsWhichNeedCurrencySymbol.includes(indicator)) { if (dollarPlatforms.includes(platform)) { return "$"; } else { return "£"; } } else { return ""; } }; const FirstQualityIndicator: React.FC<{ question: QuestionFragment; }> = ({ question }) => { if (question.qualityIndicators.numForecasts) { return (