From 16612177091feb5bb4b0651ab805a2aab5c2d9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Wed, 24 Apr 2024 16:48:04 +0200 Subject: [PATCH] change mocked data --- .../GovernanceActionDetailsCardLinks.tsx | 104 +++++++++--------- .../DashboardGovernanceActionDetails.tsx | 1 + .../organisms/GovernanceActionDetailsCard.tsx | 23 ++-- .../GovernanceActionDetailsCardData.tsx | 44 ++++---- .../src/services/requests/getProposal.ts | 6 +- 5 files changed, 93 insertions(+), 85 deletions(-) diff --git a/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx b/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx index 6d08028a6..9dcd48dfe 100644 --- a/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx +++ b/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx @@ -1,66 +1,64 @@ import { Box } from "@mui/material"; import { Typography } from "@atoms"; +import { ICONS } from "@consts"; +import { useModal } from "@context"; import { useScreenDimension, useTranslation } from "@hooks"; import { LinkWithIcon } from "@molecules"; -import { ICONS } from "@/consts"; -import { useModal } from "@/context"; -// TODO: When BE is ready, pass links as props -const LINKS = [ - "https://docs.sanchogov.tools/support/get-help-in-discord", - "https://docs.sanchogov.tools/how-to-use-the-govtool/prerequsites", - "https://docs.sanchogov.tools/faqs", - "https://docs.sanchogov.tools/", -]; - -export const GovernanceActionDetailsCardLinks = () => { +export const GovernanceActionDetailsCardLinks = ({ + links, +}: { + links?: string[]; +}) => { const { isMobile } = useScreenDimension(); const { t } = useTranslation(); const { openModal } = useModal(); return ( - <> - - {t("govActions.supportingLinks")} - - - {LINKS.map((link) => ( - { - openModal({ - type: "externalLink", - state: { - externalLink: link, - }, - }); - }} - icon={link} - cutWithEllipsis - /> - ))} - - + links && ( + <> + + {t("govActions.supportingLinks")} + + + {links.map((link) => ( + { + openModal({ + type: "externalLink", + state: { + externalLink: link, + }, + }); + }} + icon={link} + cutWithEllipsis + /> + ))} + + + ) ); }; diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActionDetails.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActionDetails.tsx index 426ad82b4..ee9729745 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActionDetails.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActionDetails.tsx @@ -132,6 +132,7 @@ export const DashboardGovernanceActionDetails = () => { details={state ? state.details : data.proposal.details} url={state ? state.url : data.proposal.url} title={state ? state.title : data.proposal.title} + links={state ? state.references : data.proposal.references} about={state ? state.about : data.proposal.about} motivation={state ? state.motivation : data.proposal.motivation} rationale={state ? state.rationale : data.proposal.rationale} diff --git a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx index d66a05a1c..7cc4656ee 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx @@ -24,6 +24,7 @@ type GovernanceActionDetailsCardProps = { motivation?: string; rationale?: string; yesVotes: number; + links?: string[]; govActionId: string; isDataMissing: boolean | MetadataValidationStatus; isDashboard?: boolean; @@ -46,6 +47,7 @@ export const GovernanceActionDetailsCard = ({ details, url, title, + links, about, motivation, rationale, @@ -91,23 +93,24 @@ export const GovernanceActionDetailsCard = ({ /> )} { const { t } = useTranslation(); const { screenWidth } = useScreenDimension(); @@ -121,7 +123,7 @@ export const GovernanceActionDetailsCardData = ({ {details && Object.keys(details).length !== 0 && ( )} - + ); }; diff --git a/govtool/frontend/src/services/requests/getProposal.ts b/govtool/frontend/src/services/requests/getProposal.ts index 16b89fd81..d366476bb 100644 --- a/govtool/frontend/src/services/requests/getProposal.ts +++ b/govtool/frontend/src/services/requests/getProposal.ts @@ -13,5 +13,9 @@ export const getProposal = async (proposalId: string, drepId?: string) => { url: data?.proposal.url, }); // workaround for the missing data in db-sync - return { ...data, ...metadata, isDataMissing: status || false }; + return { + ...data, + proposal: { ...data.proposal, ...metadata }, + isDataMissing: status || false, + }; };