diff --git a/components/crowdfunding/CampaignStatusBanner.tsx b/components/crowdfunding/CampaignStatusBanner.tsx index ac7dd356..b90cd2c3 100644 --- a/components/crowdfunding/CampaignStatusBanner.tsx +++ b/components/crowdfunding/CampaignStatusBanner.tsx @@ -16,6 +16,7 @@ import { } from 'lucide-react'; import { cn } from '@/lib/utils'; import { toast } from 'sonner'; +import { extractApiErrorMessage } from '@/lib/api/api'; import { useWithdrawSubmission, usePublishCampaign, @@ -193,11 +194,9 @@ export function CampaignStatusBanner({ campaign, onStatusChange }: Props) { setLaunchOpen(false); onStatusChange?.(); }, - onError: err => + onError: (err: unknown) => toast.error( - err instanceof Error - ? err.message - : 'Failed to launch. Please try again.' + extractApiErrorMessage(err, 'Failed to launch. Please try again.') ), }); }; @@ -286,8 +285,13 @@ export function CampaignStatusBanner({ campaign, onStatusChange }: Props) { toast.success('Submission withdrawn.'); onStatusChange?.(); }, - onError: () => - toast.error('Something went wrong. Please try again.'), + onError: (err: unknown) => + toast.error( + extractApiErrorMessage( + err, + 'Something went wrong. Please try again.' + ) + ), }) } className='text-zinc-400 hover:text-white' diff --git a/components/crowdfunding/ContributeSheet.tsx b/components/crowdfunding/ContributeSheet.tsx index 2af235fb..1558d9fb 100644 --- a/components/crowdfunding/ContributeSheet.tsx +++ b/components/crowdfunding/ContributeSheet.tsx @@ -16,6 +16,7 @@ import { Switch } from '@/components/ui/switch'; import { Loader2, Wallet, Zap, CheckCircle2 } from 'lucide-react'; import { cn } from '@/lib/utils'; import { toast } from 'sonner'; +import { extractApiErrorMessage } from '@/lib/api/api'; import { useQueryClient } from '@tanstack/react-query'; import { contributeV2, @@ -118,9 +119,7 @@ export function ContributeSheet({ setDone(true); } catch (err) { toast.error( - err instanceof Error - ? err.message - : 'Contribution failed. Please try again.' + extractApiErrorMessage(err, 'Contribution failed. Please try again.') ); } finally { setSubmitting(false); diff --git a/components/crowdfunding/VotePanel.tsx b/components/crowdfunding/VotePanel.tsx index 92ea7446..177c7fac 100644 --- a/components/crowdfunding/VotePanel.tsx +++ b/components/crowdfunding/VotePanel.tsx @@ -2,6 +2,7 @@ import { ThumbsUp, ThumbsDown } from 'lucide-react'; import { toast } from 'sonner'; +import { extractApiErrorMessage } from '@/lib/api/api'; import { useCastVote, useMyVote } from '@/features/crowdfunding'; import type { Crowdfunding } from '@/features/projects/types'; @@ -31,11 +32,12 @@ export function VotePanel({ campaign }: { campaign: Crowdfunding }) { toast.success( choice === 'UP' ? 'Thanks, your vote is in.' : 'Your vote is in.' ), - onError: err => + onError: (err: unknown) => toast.error( - err instanceof Error - ? err.message - : 'Could not record your vote. Make sure you are signed in.' + extractApiErrorMessage( + err, + 'Could not record your vote. Make sure you are signed in.' + ) ), } ); diff --git a/components/crowdfunding/new/NewCampaignSidebar.tsx b/components/crowdfunding/new/NewCampaignSidebar.tsx index d16db567..54faf52a 100644 --- a/components/crowdfunding/new/NewCampaignSidebar.tsx +++ b/components/crowdfunding/new/NewCampaignSidebar.tsx @@ -12,14 +12,20 @@ interface NewCampaignSidebarProps { activeStep: number; completedSteps: Set; campaignId?: string; + onStepClick?: (step: number) => void; } interface SidebarContentProps { activeStep: number; completedSteps: Set; + onStepClick?: (step: number) => void; } -function SidebarContent({ activeStep, completedSteps }: SidebarContentProps) { +function SidebarContent({ + activeStep, + completedSteps, + onStepClick, +}: SidebarContentProps) { return (