import { Box, Table, TableBody, TableCell, TableHead, TableRow, styled, Fade, } from "@mui/material"; import { useState } from "react"; import { Typography } from "../Atoms/Typography"; import { useTranslation } from "../../contexts/I18nContext"; import { IconCheveronUp, IconCheveronDown, } from "@intersect.mbo/intersectmbo.org-icons-set"; import { theme } from "../../theme"; import { getRawAdaValue } from "../../lib/utils"; import { VoteMetric } from "./VoteSection"; const { palette: { primaryBlue }, shadows: { "7": bottomBoxShadow }, } = theme; type VoteMetricsTableProps = { collapsedMetrics: VoteMetric[]; expandedMetrics: VoteMetric[]; title: string; isCC?: boolean; defaultExpanded?: boolean; }; const ExpandButton = styled(Box, { shouldForwardProp: (prop) => prop !== "isVisible", })<{ isVisible?: boolean }>(({ isVisible = true }) => ({ display: isVisible ? "flex" : "none", justifyContent: "center", alignItems: "center", cursor: "pointer", color: primaryBlue, padding: "8px 0", fontWeight: 600, fontFamily: "Poppins", fontSize: 14, })); const VoteMetricsTable = ({ collapsedMetrics, expandedMetrics, title, isCC = false, defaultExpanded = false, }: VoteMetricsTableProps) => { const { t } = useTranslation(); const [expanded, setExpanded] = useState(defaultExpanded); const [transitioning, setTransitioning] = useState(false); const toggleExpand = () => { setTransitioning(true); setTimeout(() => { setExpanded(!expanded); setTimeout(() => { setTransitioning(false); }, 50); }, 150); }; const getIndentUnits = (value: number) => { if (!value) return "0px"; return `${value * 8}px`; }; const displayMetrics = expanded ? expandedMetrics : collapsedMetrics; return ( {t("outcome.votes.metric")} {t("outcome.votes.value")} {!isCC && " (₳)"} {displayMetrics.map((metric, index) => ( {metric.label} {isCC ? metric.value : getRawAdaValue(Number(metric.value)).toLocaleString()} ))}
{expanded ? ( {t("common.collapse")} ) : ( {t("common.expand")} )}
); }; export default VoteMetricsTable;