From c94abb233b82f409b4787e9922abcff4bb00a3e4 Mon Sep 17 00:00:00 2001 From: g-but <41178744+g-but@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:58:48 +0100 Subject: [PATCH] refactor(dashboard): consolidate guided actions into TasksSection SSOT - Remove duplicate guidedSuggestions from DashboardJourney (~130 lines) - DashboardJourney now delegates to TasksSection as thin wrapper - Remove unused props and memoized variables from dashboard page - TasksSection is now SSOT for all recommendations (useRecommendations hook) DRY violation fixed: recommendations were previously defined in both DashboardJourney (guidedSuggestions) and TasksSection (TASK_DEFINITIONS). Co-Authored-By: Claude Opus 4.5 --- src/app/(authenticated)/dashboard/page.tsx | 34 +--- .../dashboard/sections/DashboardJourney.tsx | 158 ++---------------- 2 files changed, 15 insertions(+), 177 deletions(-) diff --git a/src/app/(authenticated)/dashboard/page.tsx b/src/app/(authenticated)/dashboard/page.tsx index 7dc86e688..11676905f 100644 --- a/src/app/(authenticated)/dashboard/page.tsx +++ b/src/app/(authenticated)/dashboard/page.tsx @@ -239,27 +239,8 @@ export default function DashboardPage() { [safeProjects] ); - // Profile completion - const profileCompletion = useMemo(() => { - const hasUsername = !!profile?.username; - const hasBio = !!profile?.bio; - const hasBitcoinAddress = !!profile?.bitcoin_address; - const profileFields = [hasUsername, hasBio, hasBitcoinAddress]; - return Math.round((profileFields.filter(Boolean).length / profileFields.length) * 100); - }, [profile?.username, profile?.bio, profile?.bitcoin_address]); - - const hasBitcoinAddress = useMemo(() => !!profile?.bitcoin_address, [profile?.bitcoin_address]); + // Derived state (profile completion now handled by TasksSection SSOT) const hasProjects = useMemo(() => safeProjects.length > 0, [safeProjects]); - const hasAnyDraft = useMemo(() => safeDrafts.length > 0, [safeDrafts]); - - const hasTimelineActivity = useMemo(() => { - const feed = timelineFeed as unknown as { - events?: unknown[]; - items?: unknown[]; - data?: unknown[]; - }; - return Boolean(feed?.events?.length || feed?.items?.length || feed?.data?.length); - }, [timelineFeed]); // Loading states if (!hydrated || localLoading) { @@ -319,17 +300,8 @@ export default function DashboardPage() { /> )} - {/* Getting Started Section (only if incomplete) */} - {(profileCompletion < 100 || !hasBitcoinAddress || !hasProjects || hasAnyDraft) && ( - - )} + {/* Recommended Next Steps - TasksSection handles its own visibility */} + {/* Primary Content: Economic Activity */}
diff --git a/src/components/dashboard/sections/DashboardJourney.tsx b/src/components/dashboard/sections/DashboardJourney.tsx index deb1a6d38..b3af90395 100644 --- a/src/components/dashboard/sections/DashboardJourney.tsx +++ b/src/components/dashboard/sections/DashboardJourney.tsx @@ -1,155 +1,21 @@ 'use client'; -import { useMemo } from 'react'; -import Link from 'next/link'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/Card'; -import { Wallet, Plus, Target, MessageCircle, Eye } from 'lucide-react'; -import { ENTITY_REGISTRY } from '@/config/entity-registry'; import TasksSection from '@/components/dashboard/TasksSection'; -interface GuidedSuggestion { - title: string; - description: string; - href: string; - icon: React.ReactNode; - priority: number; - reason: string; -} - -interface DashboardJourneyProps { - profileCompletion: number; - hasBitcoinAddress: boolean; - hasProjects: boolean; - hasAnyDraft: boolean; - totalDrafts: number; - hasTimelineActivity: boolean; -} - /** - * DashboardJourney - Profile completion and guided suggestions - * Uses ENTITY_REGISTRY for entity-related routes + * DashboardJourney - Recommended next steps for users + * + * DRY: All task/recommendation logic is in TasksSection (SSOT: useRecommendations hook) + * This component is a thin wrapper that can be extended for journey-specific UI if needed. + * + * TasksSection handles: + * - Profile completion tracking + * - Task recommendations + * - Celebration state when complete + * - Loading/error states */ -export function DashboardJourney({ - profileCompletion, - hasBitcoinAddress, - hasProjects, - hasAnyDraft, - totalDrafts, - hasTimelineActivity, -}: DashboardJourneyProps) { - // PRIORITIZED guided suggestions - most important actions first - const guidedSuggestions = useMemo(() => { - const suggestions: GuidedSuggestion[] = []; - - // Priority 1: Bitcoin address is critical for receiving funds - if (!hasBitcoinAddress) { - suggestions.push({ - title: 'Add your Bitcoin address', - description: 'Required to receive funds from supporters.', - href: ENTITY_REGISTRY.wallet.basePath, - icon: , - priority: 1, - reason: 'unlock-payments', - }); - } - - // Priority 2: First project is the main value prop - if (!hasProjects) { - suggestions.push({ - title: 'Create your first project', - description: 'Launch a Bitcoin crowdfunding campaign in minutes.', - href: ENTITY_REGISTRY.project.createPath, - icon: , - priority: 2, - reason: 'core-feature', - }); - } - - // Priority 3: Complete drafts (they're already started) - if (hasAnyDraft) { - suggestions.push({ - title: 'Finish your draft', - description: `Complete ${totalDrafts} pending project${totalDrafts > 1 ? 's' : ''}.`, - href: ENTITY_REGISTRY.project.basePath, - icon: , - priority: 3, - reason: 'continue-work', - }); - } - - // Priority 4: Engage with community - if (!hasTimelineActivity) { - suggestions.push({ - title: 'Post an update', - description: 'Share with the community and build your audience.', - href: '/timeline', - icon: , - priority: 4, - reason: 'community', - }); - } - - // Priority 5: Explore what others are doing - if (hasProjects && hasBitcoinAddress) { - suggestions.push({ - title: 'Discover projects', - description: 'See what others are building and get inspired.', - href: '/discover', - icon: , - priority: 5, - reason: 'explore', - }); - } - - // Sort by priority and return top 4 - return suggestions.sort((a, b) => a.priority - b.priority).slice(0, 4); - }, [hasAnyDraft, hasBitcoinAddress, hasTimelineActivity, hasProjects, totalDrafts]); - - return ( -
- - - Your OrangeCat journey - Stay on track with clear next steps. - - -
-
- Profile completion - {profileCompletion}% -
-
-
-
-

- Complete your profile to build trust and unlock suggestions tailored to you. -

-
- -
- {guidedSuggestions.map(suggestion => ( - -
-
{suggestion.icon}
-
-

{suggestion.title}

-

{suggestion.description}

-
-
- - ))} -
- - - -
- -
-
- ); +export function DashboardJourney() { + return ; } export default DashboardJourney;