From ab92b00a74183266fed07eb75684c2a9460516bd Mon Sep 17 00:00:00 2001 From: Georgy Butaev <41178744+g-but@users.noreply.github.com> Date: Tue, 23 Jun 2026 20:49:51 +0200 Subject: [PATCH] =?UTF-8?q?feat(profile):=20explore-&-fund=20hub=20?= =?UTF-8?q?=E2=80=94=20surface=20projects=20with=20one-tap=20Support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A shared profile opened on the Overview showing only a bio + counts; to see someone's work a visitor had to find a separate tab, and there was no way to back a project from the listing. Now the Overview surfaces the owner's actual projects as cards (cover image + funding progress) with a "Support" button that deep-links straight to the project's donate panel (/projects/:id#pay), so a shared link is immediately "see what I do → explore → fund any project". - New ProfileProjectCard (shared): card body links to the project; a separate Support button jumps to #pay. Reused in the Projects tab too (removed the duplicated inline card markup — one source now). - Overview renders the top 3 projects + "View all" → Projects tab. - Threaded the already-server-fetched projects into the Overview; added cover_image_url to the profile project query. - Added id="pay" (scroll-mt) to the project page so the Support deep-link lands on the donate panel. Per-project vs shared wallet is unchanged (still resolves per the existing entity-wallet → profile-wallet fallback); shared-wallet-by- default remains the path. Verified on live data: 2 project cards render on /profiles/mao with Support → /projects/:id#pay landing on the pay panel; tsc 0 errors, ESLint clean, 0 console errors. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app/profiles/[username]/page.tsx | 1 + src/components/profile/ProfileLayout.tsx | 3 +- src/components/profile/ProfileOverviewTab.tsx | 71 +++++++- src/components/profile/ProfileProjectCard.tsx | 164 ++++++++++++++++++ src/components/profile/ProfileProjectsTab.tsx | 162 +++-------------- src/components/project/ProjectPageClient.tsx | 32 ++-- 6 files changed, 275 insertions(+), 158 deletions(-) create mode 100644 src/components/profile/ProfileProjectCard.tsx diff --git a/src/app/profiles/[username]/page.tsx b/src/app/profiles/[username]/page.tsx index 9e288b388..b44f8dd21 100644 --- a/src/app/profiles/[username]/page.tsx +++ b/src/app/profiles/[username]/page.tsx @@ -175,6 +175,7 @@ export default async function PublicProfilePage({ params }: PageProps) { goal_amount, currency, raised_amount, + cover_image_url, created_at, updated_at ` diff --git a/src/components/profile/ProfileLayout.tsx b/src/components/profile/ProfileLayout.tsx index a916270de..a6eb238e4 100644 --- a/src/components/profile/ProfileLayout.tsx +++ b/src/components/profile/ProfileLayout.tsx @@ -56,7 +56,7 @@ interface ProfileLayoutProps { export default function ProfileLayout({ profile, - projects: _projects, + projects, stats, mode: _mode = 'view', onSave, @@ -86,6 +86,7 @@ export default function ProfileLayout({ content: ( + {/* Projects — explore the owner's work and back any of it without leaving. */} + {visibleProjects.length > 0 && ( +
+
+

+ + {ENTITY_REGISTRY.project.namePlural} +

+ {(projects?.length ?? 0) > PROJECTS_PREVIEW && ( + + View all {projects?.length} + + + )} +
+
+ {visibleProjects.map(p => ( + + ))} +
+
+ )} + {/* Stats Grid */} diff --git a/src/components/profile/ProfileProjectCard.tsx b/src/components/profile/ProfileProjectCard.tsx new file mode 100644 index 000000000..224e9f052 --- /dev/null +++ b/src/components/profile/ProfileProjectCard.tsx @@ -0,0 +1,164 @@ +'use client'; + +/** + * ProfileProjectCard — one project as an explore-and-fund card. + * + * Shared by the profile Overview's "Projects" section and the Projects tab so + * a shared profile shows the owner's actual work (not just a count) and lets a + * visitor jump straight to funding any project. The card body links to the + * project; a separate "Support" button deep-links to the project's donate + * panel (#pay) so backing something is one tap from the listing. + */ + +import Link from 'next/link'; +import Image from 'next/image'; +import { Target, Bitcoin } from 'lucide-react'; +import Button from '@/components/ui/Button'; +import { ROUTES } from '@/config/routes'; +import { CurrencyDisplay } from '@/components/ui/CurrencyDisplay'; +import { formatBitcoinDisplay } from '@/services/currency/formatting'; +import { PLATFORM_DEFAULT_CURRENCY } from '@/config/currencies'; +import { formatRelativeTimeCompact } from '@/utils/dates'; +import { getStatusInfo } from '@/config/status-config'; +import { PROJECT_STATUS } from '@/config/project-statuses'; + +/** Normalized shape — callers map their own row type (server Project / tab item) to this. */ +export interface ProfileProjectCardData { + id: string; + title: string; + description?: string | null; + imageUrl?: string | null; + goalAmount?: number | null; + /** Legacy fiat "raised" total, used when there's no on-chain balance. */ + raisedAmount?: number; + /** On-chain balance in BTC, preferred when present. */ + balanceBtc?: number; + currency?: string; + category?: string | null; + status?: string | null; + hasWallet?: boolean; + createdAt: string; +} + +export default function ProfileProjectCard({ project }: { project: ProfileProjectCardData }) { + const currency = project.currency || PLATFORM_DEFAULT_CURRENCY; + const balanceBTC = project.balanceBtc || 0; + const goalAmount = project.goalAmount || 0; + const raisedAmount = project.raisedAmount || 0; + const currentAmount = balanceBTC > 0 ? balanceBTC : raisedAmount; + const progress = goalAmount > 0 ? Math.min((currentAmount / goalAmount) * 100, 100) : 0; + const statusInfo = getStatusInfo(project.status || PROJECT_STATUS.ACTIVE); + const showStatusBadge = + project.status && + !([PROJECT_STATUS.ACTIVE, PROJECT_STATUS.DRAFT] as string[]).includes( + project.status.toLowerCase() + ); + const viewHref = ROUTES.PROJECTS.VIEW(project.id); + + return ( +
+ +
+ {/* Thumbnail */} +
+ {project.imageUrl ? ( + {project.title} + ) : ( +
+ +
+ )} + {project.category && ( +
+ + {project.category} + +
+ )} + {showStatusBadge && ( +
+ + {statusInfo.label} + +
+ )} +
+ + {/* Content */} +
+
+

+ {project.title} +

+ {project.description && ( +

{project.description}

+ )} +
+ + {/* Progress / balance */} + {goalAmount > 0 ? ( +
+
+ Progress + {progress.toFixed(1)}% +
+
+
+
+
+ + + + + of + +
+
+ ) : ( +
+ + + {balanceBTC > 0 ? ( + formatBitcoinDisplay(balanceBTC) + ) : raisedAmount > 0 ? ( + + ) : ( + 'No funds yet' + )} + +
+ )} +
+
+ + + {/* Footer — meta + a one-tap Support that jumps to the donate panel */} +
+
+ {formatRelativeTimeCompact(project.createdAt)} + {project.hasWallet && ( + + + Wallet + + )} +
+ +
+
+ ); +} diff --git a/src/components/profile/ProfileProjectsTab.tsx b/src/components/profile/ProfileProjectsTab.tsx index 5fa8be6c3..86a5ca5af 100644 --- a/src/components/profile/ProfileProjectsTab.tsx +++ b/src/components/profile/ProfileProjectsTab.tsx @@ -3,17 +3,12 @@ import { logger } from '@/utils/logger'; import { useState, useEffect } from 'react'; import Link from 'next/link'; -import Image from 'next/image'; -import { Target, Bitcoin, ArrowRight } from 'lucide-react'; +import { Target, ArrowRight } from 'lucide-react'; import type { ScalableProfile } from '@/services/profile/types'; import Button from '@/components/ui/Button'; +import ProfileProjectCard from '@/components/profile/ProfileProjectCard'; import { ROUTES } from '@/config/routes'; import { API_ROUTES } from '@/config/api-routes'; -import { CurrencyDisplay } from '@/components/ui/CurrencyDisplay'; -import { formatBitcoinDisplay } from '@/services/currency/formatting'; -import { PLATFORM_DEFAULT_CURRENCY } from '@/config/currencies'; -import { formatRelativeTimeCompact } from '@/utils/dates'; -import { getStatusInfo } from '@/config/status-config'; import { PROJECT_STATUS } from '@/config/project-statuses'; import { ENTITY_REGISTRY } from '@/config/entity-registry'; @@ -142,140 +137,25 @@ export default function ProfileProjectsTab({ profile, isOwnProfile }: ProfilePro {/* Projects Grid */}
- {publicProjects.map(project => { - const statusInfo = getStatusInfo(project.status || PROJECT_STATUS.ACTIVE); - const balanceBTC = project.bitcoin_balance_btc || 0; - const goalAmount = project.goal_amount || 0; - const raisedAmount = project.raised_amount || 0; - const currentAmount = balanceBTC > 0 ? balanceBTC : raisedAmount; - const progress = goalAmount > 0 ? Math.min((currentAmount / goalAmount) * 100, 100) : 0; - const showStatusBadge = - project.status && - !([PROJECT_STATUS.ACTIVE, PROJECT_STATUS.DRAFT] as string[]).includes( - project.status.toLowerCase() - ); - - return ( - -
- {/* Thumbnail */} -
- {project.thumbnail_url ? ( - {project.title} - ) : ( -
- -
- )} - {project.category && ( -
- - {project.category} - -
- )} - {showStatusBadge && ( -
- - {statusInfo.label} - -
- )} -
- - {/* Content */} -
-
-

- {project.title} -

- {project.description && ( -

- {project.description} -

- )} -
- - {/* Progress */} - {goalAmount > 0 ? ( -
-
- Progress - - {progress.toFixed(1)}% - -
-
-
-
-
- - - - - of{' '} - - -
-
- ) : ( -
-
- - - {balanceBTC > 0 ? ( - formatBitcoinDisplay(balanceBTC) - ) : raisedAmount > 0 ? ( - - ) : ( - 'No funds yet' - )} - -
-
- )} - - {/* Footer */} -
- {formatRelativeTimeCompact(project.created_at)} - {project.bitcoin_address && ( - - - Wallet - - )} -
-
-
- - ); - })} + {publicProjects.map(project => ( + + ))}
); diff --git a/src/components/project/ProjectPageClient.tsx b/src/components/project/ProjectPageClient.tsx index 7886867b7..06c113efd 100644 --- a/src/components/project/ProjectPageClient.tsx +++ b/src/components/project/ProjectPageClient.tsx @@ -154,21 +154,23 @@ export default function ProjectPageClient({ project }: ProjectPageClientProps) {
- +
+ +