Newer
Older
CrypticOreWallet / src / layout / sidebar / SidebarTotalBalance.tsx
@Drew Lemmy Drew Lemmy on 22 Feb 2021 877 bytes chore: update file headers
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
import React from "react";
import { useTranslation } from "react-i18next";

import { useSelector, shallowEqual } from "react-redux";
import { RootState } from "../../store";

import { KristValue } from "../../components/KristValue";

export function SidebarTotalBalance(): JSX.Element {
  const { t } = useTranslation();

  const { wallets } = useSelector((s: RootState) => s.wallets, shallowEqual);
  const balance = Object.values(wallets)
    .filter(w => w.balance !== undefined)
    .reduce((acc, w) => acc + w.balance!, 0);

  return (
    <div className="site-sidebar-header site-sidebar-total-balance">
      <h5>{t("sidebar.totalBalance")}</h5>
      <KristValue value={balance} long />
    </div>
  );
}