Files
orangecat/docs/implementation-plan-profile-editing.md
T
Your NameandClaude e22c0ca82c feat(profile): Implement mobile-first in-place profile editing in Info tab
## What Changed
- Add edit mode to ProfileInfoTab with ModernProfileEditor integration
- Remove broken Edit Profile button from header (was looping to /profiles/me)
- Update 'My Info' sidebar link to open Info tab directly (?tab=info)
- Move SimpleChatbot from bottom-right to bottom-left (mobile UX fix)

## Technical Improvements
- Use router.refresh() instead of window.location.reload() for smooth updates
- Add proper error handling - keeps user in edit mode on save failure
- Fix location field to prefer location_search over deprecated location field
- Add guard conditions to prevent Edit button showing without required props

## User Flow
1. Click "My Info" → Opens profile with Info tab active
2. Click "Edit Profile" button → ModernProfileEditor appears inline
3. Edit fields → Save → Smooth refresh without full page reload
4. If save fails → Stay in edit mode to retry

## Files Modified
- ProfileInfoTab.tsx: Added edit mode state and error handling
- PublicProfileClient.tsx: Removed broken button, added save handler
- navigationConfig.ts: Fixed "My Info" href
- SimpleChatbot.tsx: Moved to bottom-left

## Documentation
- Added findings-profile-editing-system.md (investigation)
- Added implementation-plan-profile-editing.md (full plan)

Mobile-first design, DRY principles, no duplicate code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 17:39:17 +01:00

14 KiB

Profile Editing Implementation Plan - Mobile-First, DRY, Maintainable

Date: 2025-11-19 Focus: User experience, mobile-first, code quality, intuitive workflow

Executive Summary

Decision: REUSE ModernProfileEditor.tsx with minimal modifications Approach: In-place editing within Info tab (mobile-optimized) Why: Matches user mental model, excellent existing component, minimal code changes

Investigation Findings

1. Database Schema ✅ CLEAN

// Current Profile fields (from Profile type)
id: string;
username: string | null;
name: string | null;
bio: string | null;

// Location (structured for search)
location_country: string | null; // ISO code
location_city: string | null;
location_zip: string | null;
location_search: string | null; // Display field
latitude: number | null;
longitude: number | null;

// Visual
avatar_url: string | null;
banner_url: string | null;

// Contact & Social
website: string | null;
email: string | null; // From auth.users

// Bitcoin
bitcoin_address: string | null;
lightning_address: string | null;

// Meta
created_at: string;
updated_at: string;
verification_status: string | null;
status: string | null;

Schema Status: ✅ Well-structured, no changes needed

2. Current Navigation Structure

Sidebar (Left Panel)

Main:
  ├─ Dashboard
  ├─ My Info          → /profile (redirects to /profiles/me)
  ├─ My Projects      → /dashboard/projects
  ├─ My People        → /dashboard/people
  ├─ My Wallets       → /dashboard/wallets

Explore:
  ├─ Discover
  └─ Community

Bottom:
  ├─ Profile          → /profile
  └─ Settings         → /settings

Public Profile Tabs

/profiles/[username]:
  ├─ Overview    (bio, stats, quick info)
  ├─ Info        (detailed profile) ← EDIT HERE
  ├─ Projects    (user's projects)
  ├─ People      (followers/following)
  └─ Wallets     (Bitcoin wallets)

Insight: "My Info" in sidebar should map to "Info" tab in profile

3. Mobile UX Issues Identified

Issue A: SimpleChatbot Covers Bottom UI

Location: src/components/ui/SimpleChatbot.tsx Problem: Fixed position bottom-6 right-6 z-50 Impact: Covers bottom-right buttons on mobile Solution: Move chatbot to bottom-left OR add bottom padding to pages

Issue B: Info Tab Currently Read-Only

Location: src/components/profile/ProfileInfoTab.tsx Problem: Only displays data, no editing Impact: No way to edit profile from natural location

Issue C: ModernProfileEditor Orphaned

Location: src/components/profile/ModernProfileEditor.tsx Status: ✅ EXCELLENT component (~600 lines) Features:

  • Clean, modular code
  • Avatar/banner uploads
  • LocationAutocomplete integration
  • WalletManager integration
  • Form validation (Zod)
  • Mobile-responsive Problem: Not connected to any route

4. User Mental Model Analysis

When Users Want to Edit Profile:

  1. Primary: "My Info" in sidebar

    • Expected: Opens profile info
    • Reality: Shows public view, no edit option
  2. Secondary: Viewing own profile → Info tab

    • Expected: Can edit here
    • Reality: Read-only display
  3. Tertiary: "Edit Profile" button on profile header

    • Expected: Opens editing interface
    • Reality: Loops to same page

User Journey (Current - Broken):

User: "I want to update my bio"
├─ Clicks "My Info" → Sees read-only profile
├─ Clicks "Edit Profile" button → Same page loads
└─ ❌ STUCK - No way to edit

User Journey (Ideal - Mobile-First):

User: "I want to update my bio"
├─ Clicks "My Info" → Info tab active
├─ Sees "Edit" button OR form is already there
├─ Updates bio inline
├─ Clicks "Save"
└─ ✅ DONE - Still on same page, sees changes

5. ModernProfileEditor Analysis

Code Quality: ⭐⭐⭐⭐⭐ EXCELLENT

Strengths:

  • ✅ DRY: Reusable FormField components
  • ✅ Modular: Separated sections (images, fields, wallets)
  • ✅ Maintainable: Clear structure, good comments
  • ✅ Type-safe: Full TypeScript with Zod validation
  • ✅ Mobile-responsive: Form designed for mobile
  • ✅ Accessible: ARIA labels, keyboard navigation
  • ✅ Professional: Loading states, error handling

Fields Covered:

  • ✅ Avatar & banner uploads (with preview)
  • ✅ Name
  • ✅ Bio (textarea)
  • ✅ Location (smart autocomplete)
  • ✅ Website
  • ✅ Username (required)
  • ✅ Bitcoin wallets (WalletManager)

Missing Fields:

  • ❌ Email (handled in Settings - keep it there)
  • ❌ Extended fields (background, inspiration_statement)

Decision: REUSE THIS COMPONENT - It's too good to replace!

Why This Approach?

  1. Matches User Mental Model

    • "Info" tab = information
    • Editing information should happen IN the info tab
    • No context switch, no navigation
  2. Mobile-Optimal

    • No page navigation (saves bandwidth)
    • Stays in context
    • Single tap to edit
    • Smooth transition
  3. Consistent with Tabs Pattern

    • Overview = Read-only summary
    • Info = Editable detailed info
    • Projects = Manage projects
    • People = Social connections
    • Wallets = Manage wallets
  4. Code Reuse

    • ModernProfileEditor is already perfect
    • Just needs integration into tab
    • Minimal new code

Implementation Plan

Phase 1: Make Info Tab Editable (Priority: HIGH)

Step 1: Modify ProfileInfoTab to support edit mode

// src/components/profile/ProfileInfoTab.tsx
interface ProfileInfoTabProps {
  profile: Profile;
  isOwnProfile?: boolean;
  onSave?: (data: ProfileFormData) => Promise<void>;
}

// State: 'view' | 'edit'
const [mode, setMode] = useState<'view' | 'edit'>('view');

Step 2: Integrate ModernProfileEditor into Info tab

Info Tab Structure:
├─ if (mode === 'view')
│   └─ Current read-only display
│       └─ "Edit Profile" button (isOwnProfile only)
├─ if (mode === 'edit')
│   └─ ModernProfileEditor
│       ├─ onSave → save + setMode('view')
│       └─ onCancel → setMode('view')

Step 3: Update PublicProfileClient

// Pass onSave handler to Info tab
<ProfileInfoTab
  profile={profile}
  isOwnProfile={isOwnProfile}
  onSave={handleProfileSave}
/>

Files to Modify:

  1. src/components/profile/ProfileInfoTab.tsx - Add edit mode
  2. src/components/profile/PublicProfileClient.tsx - Add save handler
  3. src/config/navigationConfig.ts - Update "My Info" href

Files NOT to Touch:

  • ✅ ModernProfileEditor.tsx (perfect as-is)
  • ✅ ProfilePeopleTab.tsx (recently fixed)
  • ✅ ProfileWalletsTab.tsx (working)
  • ✅ ProfileProjectsTab.tsx (working)

Phase 2: Fix Navigation (Priority: HIGH)

Change 1: Sidebar "My Info" → Opens profile with Info tab active

// navigationConfig.ts
{
  name: 'My Info',
  href: '/profiles/me?tab=info',  // Auto-open Info tab
  icon: Info,
}

Change 2: Remove broken "Edit Profile" button from header

// PublicProfileClient.tsx line 228-238
// DELETE this button - editing happens in Info tab

Change 3: Add "Edit" button IN the Info tab (view mode)

// ProfileInfoTab.tsx
{isOwnProfile && mode === 'view' && (
  <Button onClick={() => setMode('edit')}>
    <Edit className="w-4 h-4 mr-2" />
    Edit Profile
  </Button>
)}

Phase 3: Mobile UX Polish (Priority: MEDIUM)

Fix 1: Chatbot Position

Option A: Move to bottom-left

// SimpleChatbot.tsx line 96
className = 'fixed bottom-6 left-6 z-50...'; // Changed from right-6

Option B: Add safe area to pages

// Add to layout or pages with bottom buttons
<div className="pb-24">  // Safe zone for chatbot

Recommended: Option A (move chatbot left)

Fix 2: Tab Navigation on Mobile

// PublicProfileClient.tsx - make tabs scrollable on mobile
<div className="flex gap-4 overflow-x-auto">
  {tabs.map(tab => ...)}
</div>

Fix 3: Form Optimization for Mobile

Already done in ModernProfileEditor:

  • ✅ Proper input sizes
  • ✅ Touch-friendly buttons
  • ✅ Scroll-friendly layout
  • ✅ No fixed positioning issues

User Flow After Implementation

User opens app on mobile
├─ Taps "My Info" in sidebar
├─ Sees profile with Info tab active
├─ Info tab shows profile details + "Edit Profile" button
├─ Taps "Edit Profile"
├─ Form appears inline (smooth transition)
├─ Updates bio/location/etc
├─ Taps "Save"
├─ Form saves, shows toast notification
├─ Returns to view mode with updated data
└─ ✅ DONE - Intuitive, fast, mobile-friendly

Comparison: Approaches

Approach Code Changes Mobile UX User Flow Reusability
In-Place Tab Editing ⭐ Minimal ⭐⭐⭐⭐⭐ Intuitive High
Dedicated /profile/edit Medium ⭐⭐⭐ Navigation Medium
Modal/Drawer High ⭐⭐⭐⭐ Modern Medium
Separate page per field High ⭐⭐ Too fragmented Low

Winner: In-Place Tab Editing

Files Summary

Create New: ❌ NONE

Modify Existing (3 files):

  1. src/components/profile/ProfileInfoTab.tsx

    • Add edit mode state
    • Integrate ModernProfileEditor
    • Add "Edit Profile" button
    • Lines: ~200 → ~300
  2. src/components/profile/PublicProfileClient.tsx

    • Add handleProfileSave
    • Remove header "Edit Profile" button
    • Pass onSave to ProfileInfoTab
    • Lines: ~333 → ~340
  3. src/config/navigationConfig.ts

    • Update "My Info" href
    • Line 99: /profile → /profiles/me?tab=info

Optional (Mobile Polish):

  1. src/components/ui/SimpleChatbot.tsx
    • Move chatbot to left
    • Line 96: right-6 → left-6

Code Quality Standards

DRY ✅

  • Reuse ModernProfileEditor (don't duplicate)
  • Reuse existing form components
  • Single source of truth for profile fields

Modular ✅

  • Info tab handles its own edit state
  • ModernProfileEditor remains standalone
  • Clear separation of concerns

Maintainable ✅

  • No duplicate code
  • Clear file structure
  • Consistent patterns
  • Well-commented

Mobile-First ✅

  • Touch-friendly buttons
  • Responsive layout
  • Smooth transitions
  • No layout shifts

Testing Checklist

Desktop

  • Click "My Info" → Info tab active
  • Click "Edit Profile" in Info tab → Form appears
  • Edit fields → Save → Changes persist
  • Cancel editing → Returns to view mode
  • All tabs still work (Overview, Projects, People, Wallets)

Mobile

  • Tap "My Info" → Info tab active
  • Tap "Edit Profile" → Form appears
  • Form fields are touch-friendly
  • Keyboard doesn't cover inputs
  • Chatbot doesn't cover buttons
  • Tabs scroll horizontally if needed
  • Save/Cancel buttons accessible

Edge Cases

  • Save with validation errors → Show errors
  • Save with network error → Show retry
  • Cancel with unsaved changes → Confirm dialog
  • Edit while not authenticated → Redirect to auth
  • View others' profiles → No Edit button

Migration Path

Current State:
- ModernProfileEditor exists but unused
- Info tab is read-only
- "Edit Profile" button broken
- "My Info" shows public view

After Phase 1:
- Info tab has edit mode
- ModernProfileEditor integrated
- Can edit profile inline
- ✅ MAIN PROBLEM SOLVED

After Phase 2:
- Navigation fixed
- "My Info" opens Info tab
- Header button removed
- Clean user flow

After Phase 3:
- Chatbot repositioned
- Mobile UX polished
- Tab navigation smooth
- ✅ PROFESSIONAL RESULT

Why NOT Other Approaches?

❌ Why not /profile/edit page?

  • Requires navigation (slower on mobile)
  • Context switch (user loses place)
  • Duplicate work (have to manage state in 2 places)
  • More code to maintain

❌ Why not Modal/Drawer?

  • Limited space for long form
  • Complex on mobile (full-screen modal)
  • More state management
  • Accessibility challenges

❌ Why not rebuild ModernProfileEditor?

  • Current one is excellent
  • Well-tested
  • Mobile-responsive
  • No reason to rebuild

Estimated Timeline

  • Phase 1 (Main fix): 1-2 hours

    • Modify ProfileInfoTab: 45 min
    • Update PublicProfileClient: 30 min
    • Testing: 30 min
  • Phase 2 (Navigation): 30 min

    • Update navigationConfig: 5 min
    • Remove header button: 5 min
    • Testing: 20 min
  • Phase 3 (Mobile polish): 30 min

    • Move chatbot: 5 min
    • Test on mobile: 25 min

Total: 2-3 hours for complete, polished solution

Risk Assessment

Low Risk ✅

  • Reusing existing, working component
  • Minimal code changes
  • No schema changes
  • No API changes
  • Clear rollback path

Potential Issues

  1. State management: Modal vs inline

    • Mitigation: Use React state in parent
  2. Form validation: Errors on cancel

    • Mitigation: Reset form on cancel
  3. Unsaved changes: User navigates away

    • Mitigation: Add beforeunload warning (Phase 2+)
  4. Mobile keyboard: Covers form

    • Mitigation: Already handled by browser scroll

Success Metrics

Must Have ✅

  • User can edit profile from "My Info"
  • Edit happens in Info tab (no navigation)
  • Form saves successfully
  • Works on mobile
  • No duplicate code

Nice to Have

  • Smooth animations
  • Auto-save drafts
  • Unsaved changes warning
  • Real-time validation
  • Progress indicator

Conclusion

Decision: In-place editing in Info tab using existing ModernProfileEditor

Why:

  • ✅ Best user experience (especially mobile)
  • ✅ Minimal code changes (reuse existing)
  • ✅ Maintains DRY, modular, maintainable standards
  • ✅ Intuitive user flow
  • ✅ No duplicate files or code
  • ✅ Low risk, high reward

Next Step: Get approval, then implement Phase 1


Ready for implementation when approved!