Skip to content

Commit

Permalink
fix: MET-1963 fix show date time format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-TaiTruong committed Mar 29, 2024
1 parent f3bc663 commit e0f336e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/commons/resources/icons/repeatVote.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/commons/resources/index.ts
Expand Up @@ -227,6 +227,7 @@ import BlackWarningIcon from "./icons/warning-black.svg?react";
import BlackCircleIcon from "./icons/black-cirle-copy.svg?react";
import RepeatVotesIcon from "./icons/repeat-votes.svg?react";
import historyIcon from "./icons/history.svg?react";
import repeatVoteIcon from "./icons/repeatVote.svg?react";
// eslint-disable-next-line import/order
import TotalOutput from "./icons/totalOutput.svg?react";
export {
Expand Down Expand Up @@ -454,6 +455,7 @@ export {
ExpiryIcon,
AnchorTextIcon,
BlackWarningIcon,
repeatVoteIcon,
BlackCircleIcon,
RepeatVotesIcon
};
Expand Down
46 changes: 27 additions & 19 deletions src/components/GovernanceVotes/index.tsx
Expand Up @@ -455,8 +455,10 @@ const GovernanceVotesDetail: React.FC<{
</InfoTitle>
<InfoValue width={`${tab === "pool" ? "fit-content" : "100%"}`}>
{tab === "pool" ? (
<Box display={"flex"} alignItems={"center"} gap={1}>
<VoteStatus status={data?.voteType || ""} />
<Box display={"flex"} alignItems={"center"} gap={1} flexWrap={"wrap"}>
<Box>
<VoteStatus status={data?.voteType || ""} />
</Box>
{data?.historyVotes && data?.historyVotes.length > 1 && (
<Box
sx={{ cursor: "pointer" }}
Expand All @@ -467,7 +469,7 @@ const GovernanceVotesDetail: React.FC<{
<ChipContainer
Icon={historyIcon}
message={
<Box component={Typography} textTransform="uppercase" fontSize="12px" fontWeight={500}>
<Box component={Typography} textTransform="uppercase" fontSize="1px" fontWeight={500}>
History
</Box>
}
Expand Down Expand Up @@ -659,6 +661,7 @@ export interface GovernanceVote {
type: string;
vote: string;
votingPower: string;
isRepeatVote: boolean;
}

export interface GovernanceVoteDetail {
Expand Down Expand Up @@ -704,7 +707,7 @@ const VoteHistoryModal: React.FC<VoteHistoryProps> = ({ onClose, open, data }) =
</Typography>{" "}
<VoteStatus status={(data && data[0].vote) || ""} />
</Box>
<TableContainer sx={{ p: "0px 10px", background: theme.isDark ? "" : theme.palette.secondary[0] }}>
<TableContainer sx={{ p: "0px 10px", background: theme.isDark ? "" : theme.palette.secondary[0], width: "auto" }}>
<TableMui aria-label="simple table">
<TableHead>
<TableRow>
Expand Down Expand Up @@ -759,7 +762,7 @@ const VoteHistoryModal: React.FC<VoteHistoryProps> = ({ onClose, open, data }) =
sx={{ color: theme.isDark ? theme.palette.secondary.main : theme.palette.secondary.light }}
padding="none"
>
{row.timestamp}
{formatDateTime(row.timestamp)}
</TableCell>
</TableRow>
))}
Expand Down Expand Up @@ -806,26 +809,33 @@ const ActionMetadataModal: React.FC<ActionMetadataProps> = ({ onClose, open, dat
gap="24px"
mt="20px"
p="24px"
sx={{ background: theme.isDark ? "" : theme.palette.secondary[0], wordWrap: "break-word" }}
borderRadius={"10px"}
sx={{
background: theme.isDark ? theme.palette.secondary[100] : theme.palette.secondary[0],
wordWrap: "break-word"
}}
>
<Typography fontSize="16px" color={theme.palette.secondary.light}>
{anchorHash}
</Typography>
<Box
component={Typography}
fontSize="16px"
color="#0033AD !important"
fontWeight="700"
onClick={() => setOpenModal(true)}
sx={{ cursor: "pointer" }}
>
{anchorUrl}
<Box>
<Box
display={"inline"}
component={Typography}
fontSize="16px"
color={`${theme.palette.primary.main} !important`}
fontWeight="700"
onClick={() => setOpenModal(true)}
sx={{ cursor: "pointer" }}
>
{anchorUrl}
</Box>
<Box
ml={1}
sx={{ transform: "translateY(3px)" }}
component={CustomTooltip}
title={
<Box>
<Box textAlign={"left"}>
<Box fontWeight={"bold"} component={"span"}>
Disclaimer:{" "}
</Box>
Expand All @@ -845,9 +855,7 @@ const ActionMetadataModal: React.FC<ActionMetadataProps> = ({ onClose, open, dat
<Box
display="flex"
flexDirection="column"
gap="24px"
mt="20px"
p="24px"
mt={2}
sx={{ background: theme.isDark ? "" : theme.palette.secondary[0] }}
>
<ViewJson maxHeight={"70vh"}>
Expand Down
14 changes: 9 additions & 5 deletions src/components/commons/CardGovernanceVotes/index.tsx
Expand Up @@ -3,7 +3,7 @@ import { Box, Stack, Tooltip, Typography, useTheme } from "@mui/material";
import { useTranslation } from "react-i18next";
import { t } from "i18next";

import { VotesAbstainIcon, VotesNoIcon, VotesNoneIcon, VotesYesIcon } from "src/commons/resources";
import { VotesAbstainIcon, VotesNoIcon, VotesNoneIcon, VotesYesIcon, repeatVoteIcon } from "src/commons/resources";
import { ChipContainer } from "src/pages/NativeScriptsAndSC/Card";
import { POOLS_ACTION_TYPE, STATUS_VOTE } from "src/commons/utils/constants";
import { GovernanceVote } from "src/components/GovernanceVotes";
Expand All @@ -26,7 +26,7 @@ export const actionTypeListDrep = [
];

const CardGovernanceVotes: React.FC<ICardGovernanceVotes> = ({ data }) => {
const { status, txHash, type, vote, votingPower, index } = data;
const { status, txHash, type, vote, votingPower, index, isRepeatVote } = data;
const theme = useTheme();
const { t } = useTranslation();

Expand All @@ -48,7 +48,7 @@ const CardGovernanceVotes: React.FC<ICardGovernanceVotes> = ({ data }) => {
</Tooltip>
</Box>
<>
<VoteStatus status={vote} />
<VoteStatus status={vote} isRepeatVote={isRepeatVote} />
</>
</Box>
<Stack paddingTop="24px" spacing={"14px"}>
Expand Down Expand Up @@ -100,12 +100,16 @@ const CardGovernanceVotes: React.FC<ICardGovernanceVotes> = ({ data }) => {

export default CardGovernanceVotes;

export const VoteStatus: React.FC<{ status: string }> = ({ status }) => {
export const VoteStatus: React.FC<{ status: string; isRepeatVote?: boolean }> = ({ status, isRepeatVote = false }) => {
const { t } = useTranslation();
const renderStatus = (key: string) => {
switch (key) {
case STATUS_VOTE.YES:
return [VotesYesIcon, "success"];
if (isRepeatVote) {
return [repeatVoteIcon, "success"];
} else {
return [VotesYesIcon, "success"];
}
case STATUS_VOTE.NO:
return [VotesNoIcon, "error"];
case STATUS_VOTE.ABSTAIN:
Expand Down

0 comments on commit e0f336e

Please sign in to comment.