Extract AIModelSelector to own file; add CapabilityToggleCard local
component to eliminate duplicated Vision/FunctionCalling toggle cards.
Remove JSDoc block and section-header comments.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract HeaderCreateButton to its own file; export CREATE_OPTIONS and
shouldShowDivider for shared use. Update Header.tsx import path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove JSDoc block; move all state, balance fetching, and interaction
handlers into useNostrConnectionCard hook.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Decompose 364-line god component: move all state, effects, and handlers
into useProjectDonation hook; hoist SUGGESTED_AMOUNTS_SATS to module level.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracted EntityCardImage (~84 lines) with its own imageError/imageLoaded
state, ImagePlaceholder/ImageLoader helpers, and Link wrapper.
Removed JSDoc block and inline comments. Main card is pure layout/slots.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracted useGroupDetail hook (~103 lines) for data loading and
computed config values. Extracted GroupDetailSidebar (~146 lines) for
the info/bitcoin/stats cards. Extracted GroupDetailTabs (~136 lines)
for the tabbed main content. Removed 10-line JSDoc block.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracted useNotificationCenter hook (~119 lines) for all state and
handlers. Extracted NotificationItem component (~124 lines) for the
per-notification row with icon logic. Hoisted FILTER_TABS config to
module level. Main component is pure orchestration + layout.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moved all state, useCallback handlers, and useMemo computations
into useTimelineView.ts (~156 lines). Removed two JSDoc blocks.
Component now owns only rendering logic across the 5 display states.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracted AIKeyCard (~92 lines) for per-key row rendering and
AIKeyAddForm (~170 lines) with self-contained form state.
Main component now owns only isAdding/keyToDelete state + delete dialog.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracted SocialLinkCard (~46 lines) and SocialLinkForm (~193 lines)
into their own files. Main editor now only owns list-management state
(isAdding, editingIndex) and orchestration logic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract full-screen close/post header into PostComposerFullScreenHeader,
inline action bar + loading/hint into PostComposerInlineControls.
Hoist lazy import to module level. Remove stale JSDoc.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract state/effects/memos/handlers into useCollateralSelector hook.
Consolidate coverage bar conditional logic. Remove stale JSDoc.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract state/handlers into useProofUploadForm hook and drag-drop
image upload zone into ProofImageUpload component. Remove stale JSDoc.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract send logic into useMessageComposer hook and actor
dropdown UI into MessageActorSelector component.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract all state + handlers into usePostCardActions hook.
PostCard now owns only JSX; hook owns router, repost delegation,
reply flow, edit/delete flow, and selection logic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract route content config (icons, titles, actions per path) to
contextual-loader-config.ts as a typed ROUTE_CONFIGS array. Component
becomes a thin 71-line renderer. Also fixes missing Lightbulb import
(was an inline SVG workaround) by importing directly from lucide-react.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract ConversationListItem with all helper functions (buildProfileHref,
getConversationDisplayName, getConversationAvatar, etc.) into own file.
Parent becomes a pure list manager with filter/selection/delete logic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract useMFASetup hook (state + handlers) and MFAStatus into own
files; MFASetup.tsx re-exports MFAStatus for API compat. Also removes
any type (factors now typed) and JSDoc comment block.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract RecommendedWalletCard (131 lines) with its Wallet type, and
WalletRecommendationFilterBar (98 lines) with ACTIVE/INACTIVE_CLASS constants.
Parent retains only state/filter logic + layout — all JSDoc comments removed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract WizardProgressBar (82 lines) and WizardTemplateOnlyView (50 lines).
Promote WIZARD_THEMES and WIZARD_STEP_VARIANTS to module-level constants,
inline buildWizardSteps into useMemo, and remove the 27-line doc comment block.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracted three standalone pieces to bring the god component under the 300-line limit:
- AnimatedGrid<T>: generic motion grid with no external dependencies
- DiscoverLoadingState: skeleton rendering keyed on activeTab + viewMode
- DiscoverAllTab: builds allSections from genericTabs + 4 typed specials
and renders them through ResultsSection
In DiscoverResults itself the 4 identical typed-tab if-blocks (investments /
loans / projects / profiles) are collapsed into a single renderTabContent
helper, saving ~40 lines.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EntityForm/index.tsx was 500 lines — reduced to 232 by pulling out two
self-contained pieces:
- useEntityFormSubmit: owns the 152-line handleSubmit callback and the
wallet pre-population useEffect (existingWalletLinkIdRef lives here).
Also fixes a latent bug: setSubmitting(false) now runs in a finally
block so the spinner always resets on both success and error paths.
- FormFieldGroups: renders the visibleFieldGroups.map loop (82 lines)
as a generic component parameterised over T.
WizardMode is now exported from index.tsx so consumers can import from
the barrel rather than duplicating the interface.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sub-modules (rates.ts, conversion.ts, formatting.ts, validation.ts, types.ts)
already contained correct implementations. index.ts was duplicating all of
them, creating two independent rate caches that could silently diverge.
Replace with a 111-line barrel: type re-exports + named re-exports +
currencyService convenience bundle. No consumer changes required — all
exported symbols are preserved at the same import path.
786 → 111 lines (-675). Resolves SSOT violation (dual rate cache).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- post/[id]/page.tsx: 317 → 195 lines (god file resolved). Extracted all
data-fetching, tree utilities, and state into usePostThread hook. Defined
pageHeader const to eliminate 3× header duplication.
- post/[id]/usePostThread.ts: new hook containing mainPost/parentPosts/replies
state, updateReplyTree/appendReplyToTree, fetchPost + useEffect, and all
three update handlers.
- tasks/[id]/page.tsx: 304 → 299 lines. Collapsed 3 modal boolean states
(showCompleteModal, showRequestModal, showAttentionModal) into single
activeModal: 'complete' | 'request' | 'attention' | null state.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 'all' tab had 13 copy-paste {count > 0 && <ResultsSection>...} blocks
(~287 lines). The 9 generic types are now derived from the existing
genericTabs config (already used by individual tabs). The 4 special types
(projects, investments, loans, profiles) are defined as inline entries.
A single .filter + .map renders all sections.
669 → 475 lines (-194).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EntityDashboardPage, investments/page, useLoanList, useProjectList
all implemented the same bulk-delete state machine (isDeleting,
bulkDeleteConfirm, handleBulkDelete, executeBulkDelete). Extracted
to src/hooks/useBulkDelete.ts; onSuccess callback covers the
projects case that also needs setShowSelection(false).
Net: -153 lines / +107 lines = -46 lines total.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
entityCrudHandler: PUT and DELETE shared identical 14-line ownership check
blocks; extracted to defaultOwnershipCheck() helper. Also renamed
existingData2 → existingData in DELETE handler.
EntityForm: toast.success called with identical content in two branches;
extracted to showSuccessToast() local constant.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ENTITY_COUNT_CONFIG drives a single Promise.all loop instead of 7
near-identical repeated queries, eliminating 35 lines and 7 named
intermediate variables. entityCounts map flows directly to the component.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces per-tab isEmpty conditions with a single
Partial<Record<DiscoverTabType, unknown[]>> map — adding a new tab
type now only requires one line instead of two conditions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the DiscoverTabs fix: replaced productCount/serviceCount/causeCount/
eventCount/loanCount/assetCount/aiAssistantCount with a single
entityCounts: Partial<Record<EntityType, number>>.
Also removes statsKey from PROFILE_ENTITY_TABS (now EntityType[]) since
the map key is the EntityType itself.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace 4 near-identical XxxGrid components (ResultsGrid/LoansGrid/
InvestmentsGrid/GenericGrid) with a single AnimatedGrid<T> generic
- Replace 9 identical individual-tab if-blocks with a genericTabs config
array + single dispatch (genericTabs.find)
- Fix copy-paste icon bug: products/services/events/groups/causes were
all showing <Users> icon in the 'all' tab; now use correct icons
(Package, Briefcase, Calendar, Building2, Heart)
- displayedCount simplified via genericTabs.reduce instead of 9 manual
array length additions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DiscoverTabsProps went from 13 scalar xxxCount props to a single
Partial<Record<DiscoverTabType, number>> — removes prop explosion,
makes adding new entity types a one-line change instead of 3.
Eliminates TabCounts intermediate type and per-tab getCount functions.
DiscoverTabs.tsx: 281 → 142 lines.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
loans/[id]/page.tsx drops from 318 → 186 lines. Added three optional config
fields to EntityDetailConfig: visibilityFilter (replaces hardcoded
status=active filter), renderSidebarExtra (Quick Stats + Contact CTA),
and showPaymentSection (opt-out for non-transactional entity types).
All 12 public entity detail pages now use the generic component.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Four files each defined a local formatCurrency that either wrapped or
duplicated src/services/currency's formatCurrency:
- ProjectSummaryRail: pure passthrough wrapper deleted, import renamed
- ProjectPageClient: null-guard wrapper deleted, call sites use ?? 0
- loans/[id]/page.tsx (public): local BTC+fiat implementation deleted,
replaced with service import; currency null-coalesced to 'USD'
- dashboard/loans/[id]/page.tsx: same; also removes the nested function
that was duplicating the public page's logic
The service's formatCurrency handles USD/EUR/CHF/BTC/SATS properly,
including edge currencies the local Intl.NumberFormat fallback missed
(e.g. GBP fell through to USD). BTC amounts now render as ₿0.001
instead of 0.00100000 BTC — stricter format, easier to read.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DiscoverHero: "Active Projects" and "People" stat cards now link to
/discover?type=projects and /discover?type=profiles respectively, with
hover effects. Finance stat stays unlinked (composite of 3 entity types).
loans/[id]/page.tsx + dashboard/loans/[id]/page.tsx: remove unreachable
second `if (currency === 'BTC')` branch that was copy-pasted from prior
version — first branch already returns, so the second was dead code.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>