Skip to content

Commit

Permalink
Fix vote value display
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Apr 23, 2024
1 parent 51779d5 commit 52f0ce4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/components/collator-select-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Image from "next/image";
import { useAccount } from "wagmi";
import Table, { ColumnType } from "./table";
import Jazzicon from "./jazzicon";
import { formatBlanace } from "@/utils";
import { formatBlanace, prettyNumber } from "@/utils";
import { notification } from "./notification";
import DisplayAccountName from "./display-account-name";
import { useStaking } from "@/hooks";
import { useDip6, useStaking } from "@/hooks";
import Tooltip from "./tooltip";

type TabKey = "active" | "waiting";
Expand All @@ -22,7 +22,7 @@ interface DataSource {
sessionKey: string | undefined;
}

function getColumns(activeTab: TabKey) {
function getColumns(activeTab: TabKey, isDip6Implemented: boolean) {
const columns: ColumnType<DataSource>[] = [
{
key: "collator",
Expand Down Expand Up @@ -87,7 +87,12 @@ function getColumns(activeTab: TabKey) {
)}
</div>
),
render: (row) => <span>{formatBlanace(row.power, 18, { keepZero: false })}</span>,
render: (row) => {
if (activeTab === "active" && !isDip6Implemented) {
return <span>{prettyNumber(row.power)}</span>;
}
return <span>{formatBlanace(row.power, 18, { keepZero: false, precision: 0 })}</span>;
},
},
{
key: "commission",
Expand Down Expand Up @@ -183,6 +188,8 @@ export default function CollatorSelectModal({
}
}, [address, nominatorCollators, isOpen]);

const { isDip6Implemented } = useDip6();

return (
<Modal
title="Select A Collator"
Expand Down Expand Up @@ -212,7 +219,7 @@ export default function CollatorSelectModal({
</div>
<Table
dataSource={dataSource}
columns={getColumns(activeKey)}
columns={getColumns(activeKey, isDip6Implemented)}
styles={{ minWidth: 560 }}
contentClassName="h-[22vh] lg:h-[28vh]"
selectedItem={selectedCollator}
Expand All @@ -230,7 +237,7 @@ export default function CollatorSelectModal({
<SearchInput onChange={setKeyword} />
<Table
dataSource={dataSource}
columns={getColumns(activeKey)}
columns={getColumns(activeKey, isDip6Implemented)}
styles={{ minWidth: 560 }}
contentClassName="h-[28vh]"
selectedItem={selectedCollator}
Expand Down

0 comments on commit 52f0ce4

Please sign in to comment.