Skip to content

Commit

Permalink
fix: change function pool name
Browse files Browse the repository at this point in the history
  • Loading branch information
DinhTran committed Mar 28, 2024
1 parent f02a529 commit a4ca194
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
5 changes: 4 additions & 1 deletion src/commons/utils/constants.ts
Expand Up @@ -299,7 +299,10 @@ export enum POOLS_ACTION_TYPE {
UPDATE_COMMITTEE = "UPDATE_COMMITTEE",
HARD_FORK_INITIATION_ACTION = "HARD_FORK_INITIATION_ACTION",
NO_CONFIDENCE = "NO_CONFIDENCE",
INFO_ACTION = "INFO_ACTION"
INFO_ACTION = "INFO_ACTION",
NEW_CONSTITUTION = "NEW_CONSTITUTION",
TREASURY_WITHDRAWALS_ACTION = "TREASURY_WITHDRAWALS_ACTION",
PARAMETER_CHANGE_ACTION = "PARAMETER_CHANGE_ACTION"
}

export enum VOTE_TYPE {
Expand Down
4 changes: 4 additions & 0 deletions src/commons/utils/helper.ts
Expand Up @@ -204,6 +204,10 @@ export const formatDateTimeLocal = (date: string) => {
return moment(moment(`${date} GMT+0000`).local(true)).format("MM/DD/YYYY HH:mm:ss");
};

export const formatDate = (date: string) => {
return moment(date).format("DD/MM/YYYY");
};

export const getEpochSlotNo = (data: IDataEpoch) => {
if (data.status === "FINISHED") {
return MAX_SLOT_EPOCH;
Expand Down
6 changes: 3 additions & 3 deletions src/components/GovernanceVotes/index.tsx
Expand Up @@ -56,7 +56,7 @@ import {
} from "src/commons/resources";
import { API } from "src/commons/utils/api";
import { POOLS_ACTION_TYPE, VOTE_TYPE, STATUS_VOTE } from "src/commons/utils/constants";
import { getShortHash, getShortNumber } from "src/commons/utils/helper";
import { formatDate, formatDateTime, getShortHash, getShortNumber } from "src/commons/utils/helper";
import CardGovernanceVotes, { GovernanceStatus, VoteStatus } from "src/components/commons/CardGovernanceVotes";
import CopyButton from "src/components/commons/CopyButton";
import CustomIcon from "src/components/commons/CustomIcon";
Expand Down Expand Up @@ -487,14 +487,14 @@ const GovernanceVotesDetail: React.FC<{
<InfoTitle paddingBottom="3px">
<StyledTitle>{t("pool.submission")}</StyledTitle>
</InfoTitle>
<InfoValue>{moment(data?.submissionDate).format("MM/DD/YYYY HH:mm:ss")}</InfoValue>
<InfoValue>{formatDateTime(data?.submissionDate || "")}</InfoValue>
</Item>
<Item item xs={6} md={3}>
<CustomIcon fill={theme.palette.secondary.light} height={27} icon={SubmissionDateIcon} />
<InfoTitle paddingBottom="3px">
<StyledTitle>{t("pool.expiryDate")}</StyledTitle>
</InfoTitle>
<InfoValue>{moment(data?.expiryDate).format("DD/MM/YYYY")}</InfoValue>
<InfoValue>{formatDate(data?.expiryDate || "")}</InfoValue>
</Item>
<Item item xs={6} md={3}>
<CustomIcon fill={theme.palette.secondary.light} height={25} icon={AnchorTextIcon} />
Expand Down
32 changes: 15 additions & 17 deletions src/components/commons/CardGovernanceVotes/index.tsx
@@ -1,6 +1,7 @@
import { Box, Stack, Tooltip, Typography, useTheme } from "@mui/material";
import React from "react";
import { useTranslation } from "react-i18next";
import { t } from "i18next";

import { VotesAbstainIcon, VotesNoIcon, VotesNoneIcon, VotesYesIcon } from "src/commons/resources";
import { ChipContainer } from "src/pages/NativeScriptsAndSC/Card";
Expand All @@ -13,25 +14,22 @@ interface ICardGovernanceVotes {
data: GovernanceVote;
}

export const actionTypeListDrep = [
{ value: POOLS_ACTION_TYPE.ALL, text: t("pool.any") },
{ value: POOLS_ACTION_TYPE.NO_CONFIDENCE, text: t("pool.typeMotion") },
{ value: POOLS_ACTION_TYPE.UPDATE_COMMITTEE, text: t("pool.typeConstitutional") },
{ value: POOLS_ACTION_TYPE.NEW_CONSTITUTION, text: t("drep.updateConstitution") },
{ value: POOLS_ACTION_TYPE.HARD_FORK_INITIATION_ACTION, text: t("pool.typeHardFork") },
{ value: POOLS_ACTION_TYPE.PARAMETER_CHANGE_ACTION, text: t("drep.protocolChange") },
{ value: POOLS_ACTION_TYPE.TREASURY_WITHDRAWALS_ACTION, text: t("drep.treasuryWithdrawals") },
{ value: POOLS_ACTION_TYPE.INFO_ACTION, text: t("pool.typeInfo") }
];

const CardGovernanceVotes: React.FC<ICardGovernanceVotes> = ({ data }) => {
const { index, status, txHash, type, vote, votingPower } = data;
const { status, txHash, type, vote, votingPower } = data;
const theme = useTheme();
const { t } = useTranslation();
const actionType = (type: string) => {
switch (type) {
case POOLS_ACTION_TYPE.UPDATE_COMMITTEE:
return t("pool.normalState");
case POOLS_ACTION_TYPE.HARD_FORK_INITIATION_ACTION:
return t("pool.harkFork");
case POOLS_ACTION_TYPE.NO_CONFIDENCE:
return t("pool.typeMotion");
case POOLS_ACTION_TYPE.INFO_ACTION:
return t("pool.Infor");

default:
break;
}
};
return (
<CardGovernanceVote>
<Box p={2}>
Expand All @@ -45,7 +43,7 @@ const CardGovernanceVotes: React.FC<ICardGovernanceVotes> = ({ data }) => {
lineHeight="28px"
color={theme.isDark ? theme.palette.secondary.main : theme.palette.secondary.main}
>
{actionType(type)} #{index}
{actionTypeListDrep.find((action) => action.value === type)?.text}
</Typography>
</Tooltip>
</Box>
Expand All @@ -65,7 +63,7 @@ const CardGovernanceVotes: React.FC<ICardGovernanceVotes> = ({ data }) => {
{t("pool.actionType")}:
</Typography>
<Typography fontWeight={400} fontSize="16px" lineHeight="18.75px" color={theme.palette.secondary.light}>
{actionType(type)}
{actionTypeListDrep.find((action) => action.value === type)?.text}
</Typography>
</Box>
<Box display="flex" alignItems="center">
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/translation.json
Expand Up @@ -1018,6 +1018,7 @@
"pool.typeUpdate": "Update to the Constitutional or proposal policy",
"pool.typeHardFork": "Hard-Fork Initiation",
"pool.typeProtocol": "Protocol Parameter Changes",

"pool.typeTreasury": "Treasury Withdrawals",
"pool.typeInfo": "Info",
"pool.dateRange": "Date Range",
Expand Down Expand Up @@ -1060,6 +1061,9 @@
"bolnisi.verifyErrorTooltipTryAgain": "Please, refresh the page to try again.",
"bolnisi.verifyError": "Verification Unavailable",
"account.myProfile": "My Profile",
"drep.updateConstitution": "Update to the Constitution",
"drep.protocolChange": "Protocol Parameter Changes",
"drep.treasuryWithdrawals": "Treasury Withdrawals",
"drep.des": "DRep Metadata",
"drep.activeVoteStake": "Active Voting Stake",
"drep.liveStake": "Live Stake",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DelegationDetail/index.tsx
Expand Up @@ -176,7 +176,7 @@ const DelegationDetail: React.FC = () => {
key: "governanceVotes",
component: (
<div ref={tableRef}>
<DelegationGovernanceVotes hash={data?.hashView || ""} type={VOTE_TYPE.STAKING_POOL_KEY_HASH} />
<DelegationGovernanceVotes hash={poolId || ""} type={VOTE_TYPE.STAKING_POOL_KEY_HASH} />
</div>
)
}
Expand Down

0 comments on commit a4ca194

Please sign in to comment.