diff --git a/dapp/src/components/page/proposal/ProposalDetail.tsx b/dapp/src/components/page/proposal/ProposalDetail.tsx new file mode 100644 index 0000000..e69de29 diff --git a/dapp/src/components/page/proposal/ProposalPage.tsx b/dapp/src/components/page/proposal/ProposalPage.tsx new file mode 100644 index 0000000..ba0c4cf --- /dev/null +++ b/dapp/src/components/page/proposal/ProposalPage.tsx @@ -0,0 +1,22 @@ +import React from "react"; +import ProposalPageTitle from "./ProposalPageTitle"; +import ProposalStatusSection from "./ProposalStatusSection"; +import { useStore } from "@nanostores/react"; +import { proposalId } from "utils/store"; + +const ProposalPage: React.FC = () => { + const id = useStore(proposalId); + + return ( +
+ {}} + /> + +
+ ); +}; + +export default ProposalPage; diff --git a/dapp/src/components/page/proposal/ProposalPageTitle.tsx b/dapp/src/components/page/proposal/ProposalPageTitle.tsx new file mode 100644 index 0000000..8f0b429 --- /dev/null +++ b/dapp/src/components/page/proposal/ProposalPageTitle.tsx @@ -0,0 +1,42 @@ +import React from "react"; +import { useState, useEffect } from "react"; +interface Props { + id: string; + title: string; + submitVote: (id: string) => void; +} + +const ProposalPageTitle: React.FC = ({ id, title, submitVote }) => { + const [projectId, setProjectId] = useState(id); + + useEffect(() => { + if (id) { + setProjectId(id); + } + }, [id]); + + return ( +
+
+ + {projectId} + +

+ {title} +

+
+
+ +
+
+ ); +}; + +export default ProposalPageTitle; diff --git a/dapp/src/components/page/proposal/ProposalStatusDiv.tsx b/dapp/src/components/page/proposal/ProposalStatusDiv.tsx new file mode 100644 index 0000000..06daba6 --- /dev/null +++ b/dapp/src/components/page/proposal/ProposalStatusDiv.tsx @@ -0,0 +1,45 @@ +import React from "react"; +import type { ProposalStatus } from "types/proposal"; + +interface ProposalStatusDivProps { + proposalStatus: ProposalStatus; +} + +const ProposalStatusDiv: React.FC = ({ + proposalStatus, +}) => { + let title; + let backgroundColorClass; + + switch (proposalStatus) { + case "active": + title = "Active"; + backgroundColorClass = "bg-green"; + break; + case "rejected": + title = "Rejected"; + backgroundColorClass = "bg-red"; + break; + case "cancelled": + title = "Cancelled"; + backgroundColorClass = "bg-gray"; + break; + case "approved": + title = "Approved"; + backgroundColorClass = "bg-violet-600"; + break; + default: + title = "Unknown"; + backgroundColorClass = "bg-gray"; + } + + return ( +
+

{title}

+
+ ); +}; + +export default ProposalStatusDiv; diff --git a/dapp/src/components/page/proposal/ProposalStatusSection.tsx b/dapp/src/components/page/proposal/ProposalStatusSection.tsx new file mode 100644 index 0000000..9a00185 --- /dev/null +++ b/dapp/src/components/page/proposal/ProposalStatusSection.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { calculateDateDifference } from "../../../utils/formatTimeFunctions"; +import ProposalStatusDiv from "./ProposalStatusDiv"; +import type { ProposalStatus } from "types/proposal"; + +interface Props { + status: ProposalStatus; + endDate: string | null; +} + +const ProposalStatusSection: React.FC = ({ status, endDate }) => { + return ( +
+
+ +
+
+ {status === "active" && endDate && ( +
+ Ends in {calculateDateDifference(endDate)} +
+ )} +
+
+ ); +}; + +export default ProposalStatusSection; diff --git a/dapp/src/components/page/proposal/ProposalVotingStatus.tsx b/dapp/src/components/page/proposal/ProposalVotingStatus.tsx new file mode 100644 index 0000000..e69de29 diff --git a/dapp/src/pages/proposal/index.astro b/dapp/src/pages/proposal/index.astro new file mode 100644 index 0000000..a4784a0 --- /dev/null +++ b/dapp/src/pages/proposal/index.astro @@ -0,0 +1,30 @@ +--- +import Layout from "../../layouts/Layout.astro"; +import Container from "../../components/layout/Container.astro"; +import ProposalPage from "../../components/page/proposal/ProposalPage.tsx"; +--- + + + + +
+ + + +
+
+ + diff --git a/dapp/src/utils/store.js b/dapp/src/utils/store.js index 56d5d05..f3cf23a 100644 --- a/dapp/src/utils/store.js +++ b/dapp/src/utils/store.js @@ -4,3 +4,4 @@ export const projectInfoLoaded = atom(false); export const latestCommit = atom(""); export const projectCardModalOpen = atom(false); export const projectNameForGovernance = atom(""); +export const proposalId = atom("");