From efce89c5ca335edf31af8187a889b63190d1eb92 Mon Sep 17 00:00:00 2001 From: misrasamuelisiguzor-oss Date: Wed, 27 May 2026 22:14:18 +0000 Subject: [PATCH] feat: transaction status component, claim winnings hook, error pages, dark mode toggle --- frontend/src/app/create/page.tsx | 6 +- frontend/src/app/error.tsx | 29 ++++++ frontend/src/app/governance/[id]/page.tsx | 12 +-- frontend/src/app/governance/new/page.tsx | 6 +- frontend/src/app/layout.tsx | 10 +- frontend/src/app/not-found.tsx | 17 ++++ frontend/src/app/payer/page.tsx | 8 +- frontend/src/components/layout/Header.tsx | 4 +- .../src/components/layout/ThemeToggle.tsx | 49 ++++++++++ .../src/components/ui/TransactionStatus.tsx | 96 +++++++++++++++++++ frontend/src/components/ui/TxStatusToast.tsx | 11 ++- frontend/src/hooks/useBet.ts | 2 +- frontend/src/hooks/useClaimWinnings.ts | 63 ++++++++++++ frontend/src/hooks/useMarket.ts | 17 ++++ frontend/src/hooks/usePortfolio.ts | 9 +- frontend/src/services/wallet.ts | 73 ++++++++++++++ frontend/src/types/index.ts | 6 +- frontend/tailwind.config.ts | 1 + 18 files changed, 396 insertions(+), 23 deletions(-) create mode 100644 frontend/src/app/error.tsx create mode 100644 frontend/src/app/not-found.tsx create mode 100644 frontend/src/components/layout/ThemeToggle.tsx create mode 100644 frontend/src/components/ui/TransactionStatus.tsx create mode 100644 frontend/src/hooks/useClaimWinnings.ts diff --git a/frontend/src/app/create/page.tsx b/frontend/src/app/create/page.tsx index 9c257022..ccad2277 100644 --- a/frontend/src/app/create/page.tsx +++ b/frontend/src/app/create/page.tsx @@ -69,7 +69,7 @@ export default function CreateMarketPage() { return; } - setTxStatus({ hash: null, status: 'pending', error: null }); + setTxStatus({ hash: null, status: 'signing', error: null }); try { const hash = await createMarket({ @@ -169,10 +169,10 @@ export default function CreateMarketPage() { setTxStatus({ hash: null, status: 'idle', error: null })} /> diff --git a/frontend/src/app/error.tsx b/frontend/src/app/error.tsx new file mode 100644 index 00000000..af9d6ce9 --- /dev/null +++ b/frontend/src/app/error.tsx @@ -0,0 +1,29 @@ +'use client'; + +import { useEffect } from 'react'; + +interface ErrorPageProps { + error: Error & { digest?: string }; + reset: () => void; +} + +export default function ErrorPage({ error, reset }: ErrorPageProps): JSX.Element { + useEffect(() => { + // Log to error reporting service in production + console.error(error); + }, [error]); + + return ( +
+

⚠️

+

Something went wrong

+

An unexpected error occurred. Please try again.

+ +
+ ); +} diff --git a/frontend/src/app/governance/[id]/page.tsx b/frontend/src/app/governance/[id]/page.tsx index ff6426a8..f56a6e33 100644 --- a/frontend/src/app/governance/[id]/page.tsx +++ b/frontend/src/app/governance/[id]/page.tsx @@ -53,7 +53,7 @@ export default function ProposalDetail({ params }: { params: { id: string } }) { const handleVote = async (vote: VoteType) => { if (!connectedAddress) return; - setTxStatus({ hash: null, status: 'pending', error: null }); + setTxStatus({ hash: null, status: 'signing', error: null }); try { const hash = await voteProposal(proposal.id, vote); setTxStatus({ hash, status: 'success', error: null }); @@ -75,7 +75,7 @@ export default function ProposalDetail({ params }: { params: { id: string } }) { }; const handleExecute = async () => { - setTxStatus({ hash: null, status: 'pending', error: null }); + setTxStatus({ hash: null, status: 'signing', error: null }); try { const hash = await executeProposal(proposal.id); setTxStatus({ hash, status: 'success', error: null }); @@ -121,7 +121,7 @@ export default function ProposalDetail({ params }: { params: { id: string } }) { {proposal.status === 'Passed' && ( diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index ce982ace..0d2750f9 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -18,7 +18,15 @@ export const metadata: Metadata = { export default function RootLayout({ children }: { children: React.ReactNode }): JSX.Element { return ( - + {/* Inline script runs before paint to set dark/light class — prevents flash */} + +