diff --git a/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx b/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx index 5844caf52..dd32f0658 100644 --- a/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx +++ b/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx @@ -9,9 +9,9 @@ import { import { Typography } from "@atoms"; import { ICONS } from "@consts"; import { PendingTransaction } from "@context"; -import { useTranslation } from "@hooks"; +import { useGetNetworkMetrics, useTranslation } from "@hooks"; import { AutomatedVotingCard } from "@molecules"; -import { openInNewTab } from "@/utils"; +import { correctAdaFormat, openInNewTab } from "@/utils"; import { AutomatedVotingOptionCurrentDelegation, AutomatedVotingOptionDelegationId, @@ -42,6 +42,8 @@ export const AutomatedVotingOptions = ({ const [isOpen, setIsOpen] = useState(false); + const { networkMetrics } = useGetNetworkMetrics(); + // TODO: Change to certain automated voted option if available const onClickInfo = () => openInNewTab("https://docs.sanchogov.tools/"); @@ -117,7 +119,11 @@ export const AutomatedVotingOptions = ({ }) : t("dRepDirectory.abstainCardDefaultTitle") } - votingPower={votingPower} + votingPower={ + networkMetrics + ? correctAdaFormat(networkMetrics?.alwaysAbstainVotingPower) + : "" + } transactionId={ pendingTransaction?.delegate?.resourceId === AutomatedVotingOptionDelegationId.abstain @@ -148,7 +154,13 @@ export const AutomatedVotingOptions = ({ }) : t("dRepDirectory.noConfidenceDefaultTitle") } - votingPower={votingPower} + votingPower={ + networkMetrics + ? correctAdaFormat( + networkMetrics?.alwaysNoConfidenceVotingPower, + ) + : "" + } transactionId={ pendingTransaction?.delegate?.resourceId === AutomatedVotingOptionDelegationId.no_confidence diff --git a/govtool/frontend/src/consts/queryKeys.ts b/govtool/frontend/src/consts/queryKeys.ts index ccfdffe3f..0a8c7fdf1 100644 --- a/govtool/frontend/src/consts/queryKeys.ts +++ b/govtool/frontend/src/consts/queryKeys.ts @@ -4,6 +4,7 @@ export const QUERY_KEYS = { useGetDRepListInfiniteKey: "useGetDRepListInfiniteKey", useGetDRepVotesKey: "useGetDRepVotesKey", useGetDRepVotingPowerKey: "useGetDRepVotingPowerKey", + useGetNetworkMetricsKey: "useGetNetworkMetricsKey", useGetProposalKey: "useGetProposalKey", useGetProposalsKey: "useGetProposalsKey", useGetProposalsInfiniteKey: "useGetProposalsInfiniteKey", diff --git a/govtool/frontend/src/hooks/queries/index.ts b/govtool/frontend/src/hooks/queries/index.ts index f088d04fb..2b888a14b 100644 --- a/govtool/frontend/src/hooks/queries/index.ts +++ b/govtool/frontend/src/hooks/queries/index.ts @@ -4,6 +4,7 @@ export * from "./useGetVoterInfoQuery"; export * from "./useGetDRepListQuery"; export * from "./useGetDRepVotesQuery"; export * from "./useGetDRepVotingPowerQuery"; +export * from "./useGetNetworkMetrics"; export * from "./useGetProposalQuery"; export * from "./useGetProposalsQuery"; export * from "./useGetProposalsInfiniteQuery"; diff --git a/govtool/frontend/src/hooks/queries/useGetNetworkMetrics.ts b/govtool/frontend/src/hooks/queries/useGetNetworkMetrics.ts new file mode 100644 index 000000000..f83b5646f --- /dev/null +++ b/govtool/frontend/src/hooks/queries/useGetNetworkMetrics.ts @@ -0,0 +1,17 @@ +import { useQuery } from "react-query"; + +import { getNetworkMetrics } from "@services"; +import { QUERY_KEYS } from "@consts"; +import { useCardano } from "@/context"; + +export const useGetNetworkMetrics = () => { + const { isEnabled } = useCardano(); + + const { data } = useQuery({ + queryKey: QUERY_KEYS.useGetNetworkMetricsKey, + queryFn: () => getNetworkMetrics(), + enabled: isEnabled, + }); + + return { networkMetrics: data }; +}; diff --git a/govtool/frontend/src/services/requests/getNetworkMetrics.ts b/govtool/frontend/src/services/requests/getNetworkMetrics.ts new file mode 100644 index 000000000..59fd0c674 --- /dev/null +++ b/govtool/frontend/src/services/requests/getNetworkMetrics.ts @@ -0,0 +1,7 @@ +import { API } from "../API"; + +export const getNetworkMetrics = async () => { + const response = await API.get("/network/metrics"); + + return response.data; +}; diff --git a/govtool/frontend/src/services/requests/index.ts b/govtool/frontend/src/services/requests/index.ts index 3121e4c5c..f6721175a 100644 --- a/govtool/frontend/src/services/requests/index.ts +++ b/govtool/frontend/src/services/requests/index.ts @@ -18,3 +18,4 @@ export * from "./postDRepRemoveVote"; export * from "./postDRepRetire"; export * from "./postDRepVote"; export * from "./metadataValidation"; +export * from "./getNetworkMetrics";