diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69e2f4722..3abe3b590 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,8 @@ changes.
### Added
+- Add Proposal discussion context that manages username [Issue 3341](https://github.com/IntersectMBO/govtool/issues/3341)
+
### Fixed
- Fix scroll on a drawer on smaller resolution
diff --git a/govtool/frontend/src/context/contextProviders.tsx b/govtool/frontend/src/context/contextProviders.tsx
index d38fa0acc..b17e122be 100644
--- a/govtool/frontend/src/context/contextProviders.tsx
+++ b/govtool/frontend/src/context/contextProviders.tsx
@@ -6,6 +6,7 @@ import { DataActionsBarProvider } from "./dataActionsBar";
import { FeatureFlagProvider } from "./featureFlag";
import { GovernanceActionProvider } from "./governanceAction";
import { AdaHandleProvider } from "./adaHandle";
+import { ProposalDiscussionProvider } from "./proposalDiscussion";
interface Props {
children: React.ReactNode;
@@ -14,17 +15,19 @@ interface Props {
const ContextProviders = ({ children }: Props) => (
-
-
-
-
-
- {children}
-
-
-
-
-
+
+
+
+
+
+
+ {children}
+
+
+
+
+
+
);
diff --git a/govtool/frontend/src/context/index.ts b/govtool/frontend/src/context/index.ts
index 8bf7be85f..0ece5a1b5 100644
--- a/govtool/frontend/src/context/index.ts
+++ b/govtool/frontend/src/context/index.ts
@@ -8,3 +8,4 @@ export * from "./usersnapContext";
export * from "./wallet";
export * from "./featureFlag";
export * from "./governanceAction";
+export * from "./proposalDiscussion";
diff --git a/govtool/frontend/src/context/proposalDiscussion.tsx b/govtool/frontend/src/context/proposalDiscussion.tsx
new file mode 100644
index 000000000..6e1ee3b1f
--- /dev/null
+++ b/govtool/frontend/src/context/proposalDiscussion.tsx
@@ -0,0 +1,54 @@
+import {
+ PropsWithChildren,
+ useMemo,
+ createContext,
+ useContext,
+ useState,
+} from "react";
+
+type ProposalDiscussionContextType = {
+ username: string;
+ setUsername: (username: string) => void;
+} | null;
+
+const ProposalDiscussionContext =
+ createContext(null);
+
+/**
+ * Provides proposal discussion context to its children components.
+ *
+ * @param children - The child components to render.
+ */
+const ProposalDiscussionProvider = ({ children }: PropsWithChildren) => {
+ const [username, setUsername] = useState("");
+
+ const value = useMemo(
+ () => ({
+ username,
+ setUsername,
+ }),
+ [username],
+ );
+
+ return (
+
+ {children}
+
+ );
+};
+
+/**
+ * Custom hook to use the ProposalDiscussionContext.
+ * @returns The context value.
+ */
+const useProposalDiscussion = () => {
+ const context = useContext(ProposalDiscussionContext);
+ if (!context) {
+ throw new Error(
+ "useProposalDiscussion must be used within a ProposalDiscussionProvider",
+ );
+ }
+ return context;
+};
+
+export { ProposalDiscussionProvider, useProposalDiscussion };
diff --git a/govtool/frontend/src/pages/ProposalDiscussion.tsx b/govtool/frontend/src/pages/ProposalDiscussion.tsx
index 25d3c67bf..e0efe26d1 100644
--- a/govtool/frontend/src/pages/ProposalDiscussion.tsx
+++ b/govtool/frontend/src/pages/ProposalDiscussion.tsx
@@ -1,7 +1,11 @@
import React, { ComponentProps, Suspense } from "react";
import { Box, CircularProgress } from "@mui/material";
import "@intersect.mbo/pdf-ui/style";
-import { useCardano, useGovernanceActions } from "@/context";
+import {
+ useCardano,
+ useGovernanceActions,
+ useProposalDiscussion,
+} from "@/context";
import { useValidateMutation } from "@/hooks/mutations";
import { useScreenDimension } from "@/hooks/useScreenDimension";
import { Footer, TopNav } from "@/components/organisms";
@@ -18,6 +22,7 @@ export const ProposalDiscussionPillar = () => {
const { voter } = useGetVoterInfo();
const { createGovernanceActionJsonLD, createHash } = useGovernanceActions();
const { fetchDRepVotingPowerList } = useGetDRepVotingPowerList();
+ const { username, setUsername } = useProposalDiscussion();
return (
{
>["validateMetadata"]
}
fetchDRepVotingPowerList={fetchDRepVotingPowerList}
+ username={username}
+ setUsername={setUsername}
/>
diff --git a/govtool/frontend/src/types/@intersect.mbo.d.ts b/govtool/frontend/src/types/@intersect.mbo.d.ts
index 39af24c64..bef6e3b07 100644
--- a/govtool/frontend/src/types/@intersect.mbo.d.ts
+++ b/govtool/frontend/src/types/@intersect.mbo.d.ts
@@ -27,6 +27,8 @@ type ProposalDiscussionProps = {
fetchDRepVotingPowerList: (
identifiers: string[],
) => Promise;
+ username: string;
+ setUsername: (username: string) => void;
};
type GovernanceActionsOutcomesProps = {