Skip to content

Commit

Permalink
[#1675] updated Proposal and DRep types to match data received from BE
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka committed Aug 6, 2024
1 parent 0ebafd5 commit 4d5811a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {

import { useScreenDimension, useTranslation } from "@hooks";
import {
formatDisplayDate,
getFullGovActionId,
getProposalTypeLabel,
getProposalTypeNoEmptySpaces,
Expand Down Expand Up @@ -104,8 +103,8 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
isSliderCard
/>
<GovernanceActionsDatesBox
createdDate={formatDisplayDate(createdDate)}
expiryDate={formatDisplayDate(expiryDate)}
createdDate={createdDate}
expiryDate={expiryDate}
expiryEpochNo={expiryEpochNo}
createdEpochNo={createdEpochNo}
isSliderCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { Trans } from "react-i18next";

import { Tooltip, Typography } from "@atoms";
import { useScreenDimension, useTranslation } from "@hooks";
import { formatDisplayDate } from "@/utils";

type GovernanceActionsDatesBoxProps = {
createdDate: string;
expiryDate: string;
expiryEpochNo: number;
expiryDate: string | undefined;
expiryEpochNo: number | undefined;
createdEpochNo: number;
isSliderCard?: boolean;
};
Expand Down Expand Up @@ -58,7 +59,10 @@ export const GovernanceActionsDatesBox = ({
>
<Trans
i18nKey="govActions.submittedDateWithEpoch"
values={{ date: createdDate, epoch: createdEpochNo }}
values={{
date: formatDisplayDate(createdDate),
epoch: createdEpochNo,
}}
components={[
<span style={{ fontWeight: 600 }} key="0" />,
<span style={{ fontWeight: 400 }} key="1" />,
Expand Down Expand Up @@ -100,7 +104,10 @@ export const GovernanceActionsDatesBox = ({
>
<Trans
i18nKey="govActions.expiresDateWithEpoch"
values={{ date: expiryDate, epoch: expiryEpochNo }}
values={{
date: expiryDate ? formatDisplayDate(expiryDate) : "-",
epoch: expiryEpochNo ?? "-",
}}
components={[
<span style={{ fontWeight: 600 }} key="0" />,
<span style={{ fontWeight: 400 }} key="1" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Button } from "@atoms";
import { PATHS } from "@consts";
import { useScreenDimension, useTranslation } from "@hooks";
import {
formatDisplayDate,
getFullGovActionId,
getProposalTypeLabel,
getProposalTypeNoEmptySpaces,
Expand Down Expand Up @@ -94,8 +93,8 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => {
isSliderCard
/>
<GovernanceActionsDatesBox
createdDate={formatDisplayDate(createdDate)}
expiryDate={formatDisplayDate(expiryDate)}
createdDate={createdDate}
expiryDate={expiryDate}
expiryEpochNo={expiryEpochNo}
createdEpochNo={createdEpochNo}
isSliderCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import {
useScreenDimension,
useTranslation,
} from "@hooks";
import {
formatDisplayDate,
getShortenedGovActionId,
getProposalTypeLabel,
} from "@utils";
import { getShortenedGovActionId, getProposalTypeLabel } from "@utils";
import { GovernanceActionDetailsCard } from "@organisms";
import { Breadcrumbs } from "@molecules";

Expand Down Expand Up @@ -104,22 +100,14 @@ export const DashboardGovernanceActionDetails = () => {
abstainVotes={
state ? state.abstainVotes : data.proposal.abstainVotes
}
createdDate={
state
? formatDisplayDate(state.createdDate)
: formatDisplayDate(data.proposal.createdDate)
}
createdDate={state ? state.createdDate : data.proposal.createdDate}
createdEpochNo={
state ? state.createdEpochNo : data.proposal.createdEpochNo
}
isDataMissing={
state ? state.metadataStatus : data?.proposal.metadataStatus
}
expiryDate={
state
? formatDisplayDate(state.expiryDate)
: formatDisplayDate(data?.proposal.expiryDate)
}
expiryDate={state ? state.expiryDate : data?.proposal.expiryDate}
expiryEpochNo={
state ? state.expiryEpochNo : data.proposal.expiryEpochNo
}
Expand Down
5 changes: 3 additions & 2 deletions govtool/frontend/src/models/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum DRepListSort {
export interface DrepDataDTO {
deposit: number;
drepId: string;
latestRegistrationDate: string;
latestTxHash?: string;
metadataHash?: string;
status: DRepStatus;
Expand Down Expand Up @@ -64,8 +65,8 @@ export type ProposalDataDTO = {
createdDate: string;
createdEpochNo: number;
details?: ActionDetailsType;
expiryDate: string;
expiryEpochNo: number;
expiryDate?: string;
expiryEpochNo?: number;
id: string;
index: number;
metadataHash: string;
Expand Down
9 changes: 2 additions & 7 deletions govtool/frontend/src/pages/GovernanceActionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from "@hooks";
import { Footer, TopNav, GovernanceActionDetailsCard } from "@organisms";
import {
formatDisplayDate,
getProposalTypeLabel,
WALLET_LS_KEY,
getItemFromLocalStorage,
Expand Down Expand Up @@ -131,9 +130,7 @@ export const GovernanceActionDetails = () => {
state ? state.abstainVotes : data.proposal.abstainVotes
}
createdDate={
state
? formatDisplayDate(state.createdDate)
: formatDisplayDate(data.proposal.createdDate)
state ? state.createdDate : data.proposal.createdDate
}
createdEpochNo={
state ? state.createdEpochNo : data.proposal.createdEpochNo
Expand All @@ -142,9 +139,7 @@ export const GovernanceActionDetails = () => {
state ? state.metadataStatus : data?.proposal.metadataStatus
}
expiryDate={
state
? formatDisplayDate(state.expiryDate)
: formatDisplayDate(data.proposal.expiryDate)
state ? state.expiryDate : data.proposal.expiryDate
}
expiryEpochNo={
state ? state.expiryEpochNo : data.proposal.expiryEpochNo
Expand Down
5 changes: 3 additions & 2 deletions govtool/frontend/src/utils/tests/dRep.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isSameDRep } from "..";

import { DRepStatus } from "@/models";
import { DRepData, DRepStatus } from "@/models";

type TDRepType = "DRep" | "SoleVoter";

const EXAMPLE_DREP = {
const EXAMPLE_DREP: DRepData = {
drepId: "drep123",
view: "view123",
url: "url",
Expand All @@ -19,6 +19,7 @@ const EXAMPLE_DREP = {
references: [],
metadataStatus: null,
metadataValid: true,
latestRegistrationDate: "2024-07-10",
};

describe("isSameDRep function", () => {
Expand Down

0 comments on commit 4d5811a

Please sign in to comment.