import { diffLines, formatLines } from "unidiff"; import { parseDiff, Diff, Hunk } from "react-diff-view"; import "react-diff-view/style/index.css"; import { Box, Typography } from "@mui/material"; import "./react-diff-view.overrides.css"; import { useTranslation } from "../../contexts/I18nContext"; type Props = { oldJson?: JSON | Record | null; newJson?: JSON | Record | null; }; export const GovernanceActionDetailsDiffView = ({ oldJson, newJson, }: Props) => { const { t } = useTranslation(); const diffText = formatLines( diffLines( JSON.stringify(oldJson, null, 2), JSON.stringify(newJson, null, 2) ) ); const [diff] = parseDiff(diffText, {}); if (!oldJson && !newJson) return; return ( {t("outcome.existing")} {t("outcome.proposed")} {(hunks) => hunks.map((hunk) => ( // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error {hunk.content} )) } ); };