Skip to content

Commit

Permalink
fix: formatt rmc units in landing page slot feed
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder committed Apr 22, 2024
1 parent 3da9332 commit c7b3de0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client/src/app/components/nova/PageDataRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export interface IPageDataRow {
tokenInfo?: BaseTokenResponse;
}
const PageDataRow = ({ label, value, truncatedId, highlight, tokenInfo }: IPageDataRow): React.JSX.Element => {
const [isFormatBalance, setIsFormatBalance] = useState(false);
const [isFormatBalance, setIsFormatBalance] = useState(true);

const renderValue = () => {
if (truncatedId) {
return <TruncatedId id={truncatedId.id} link={truncatedId.link} showCopyButton={truncatedId.showCopyButton} />;
} else if (tokenInfo && value && Number.parseInt(value.toString(), 10)) {
} else if (tokenInfo && value) {
return (
<span onClick={() => setIsFormatBalance(!isFormatBalance)} className="pointer margin-r-5">
{formatAmount(value ?? 0, tokenInfo, isFormatBalance)}
Expand Down
11 changes: 7 additions & 4 deletions client/src/helpers/nova/hooks/useGenerateSlotsTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ITableRow } from "~/app/components/Table";
import { TableCellType, type TTableData } from "~/app/components/nova/TableCell";
import { SlotStatus } from "~app/lib/enums";
import { SlotTableHeadings } from "~/app/lib/ui/enums";
import { Utils } from "@iota/sdk-wasm-nova/web";
import { BaseTokenResponse, Utils } from "@iota/sdk-wasm-nova/web";
import useSlotsFeed from "./useSlotsFeed";
import { useNovaTimeConvert } from "./useNovaTimeConvert";
import { useNetworkInfoNova } from "../networkInfo";
Expand Down Expand Up @@ -93,6 +93,7 @@ function getSlotCommitmentTableRow(
slotIndex: number,
commitmentWrapper: ISlotCommitmentWrapper | null,
slotTimeRange: SlotTimeRange,
tokenInfo: BaseTokenResponse,
): ITableRow<TTableData> {
const data: TTableData[] = [];

Expand Down Expand Up @@ -120,8 +121,10 @@ function getSlotCommitmentTableRow(
break;
case SlotTableHeadings.ReferenceManaCost:
tableData = {
type: TableCellType.Text,
type: TableCellType.Formatted,
data: referenceManaCost,
tokenInfo,
isFormatted: true,
};
break;
case SlotTableHeadings.Blocks:
Expand Down Expand Up @@ -170,7 +173,7 @@ function getSlotCommitmentTableRow(
}

export function useGenerateSlotsTable(): ITableRow<TTableData>[] {
const { name: network } = useNetworkInfoNova((s) => s.networkInfo);
const { name: network, manaInfo } = useNetworkInfoNova((s) => s.networkInfo);
const { slotIndexToUnixTimeRange } = useNovaTimeConvert();
const { currentSlotIndex, currentSlotTimeRange, latestSlotCommitments, latestSlotIndexes } = useSlotsFeed();

Expand All @@ -185,7 +188,7 @@ export function useGenerateSlotsTable(): ITableRow<TTableData>[] {
latestSlotIndexes?.map((slotIndex) => {
const commitmentWrapper = latestSlotCommitments?.find((commitment) => commitment.slotCommitment.slot === slotIndex) ?? null;
const slotTimeRange = slotIndexToUnixTimeRange?.(slotIndex) ?? null;
const row = getSlotCommitmentTableRow(network, slotIndex, commitmentWrapper, slotTimeRange);
const row = getSlotCommitmentTableRow(network, slotIndex, commitmentWrapper, slotTimeRange, manaInfo);
rows.push(row);
});
}
Expand Down

0 comments on commit c7b3de0

Please sign in to comment.