website refactor
This commit is contained in:
@@ -2,23 +2,21 @@
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { ProfileTemplate, type ProfileTab } from '@/templates/ProfileTemplate';
|
||||
import { ProfileTemplate } from '@/templates/ProfileTemplate';
|
||||
import { type ProfileTab } from '@/components/profile/ProfileNavTabs';
|
||||
import type { ProfileViewData } from '@/lib/view-data/ProfileViewData';
|
||||
import type { Result } from '@/lib/contracts/Result';
|
||||
|
||||
interface ProfilePageClientProps {
|
||||
viewData: ProfileViewData;
|
||||
mode: 'profile-exists' | 'needs-profile';
|
||||
onSaveSettings: (updates: { bio?: string; country?: string }) => Promise<Result<void, string>>;
|
||||
}
|
||||
|
||||
export function ProfilePageClient({ viewData, mode, onSaveSettings }: ProfilePageClientProps) {
|
||||
export function ProfilePageClient({ viewData, mode }: ProfilePageClientProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const tabParam = searchParams.get('tab') as ProfileTab | null;
|
||||
|
||||
const [activeTab, setActiveTab] = useState<ProfileTab>(tabParam || 'overview');
|
||||
const [editMode, setEditMode] = useState(false);
|
||||
const [friendRequestSent, setFriendRequestSent] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -49,19 +47,8 @@ export function ProfilePageClient({ viewData, mode, onSaveSettings }: ProfilePag
|
||||
mode={mode}
|
||||
activeTab={activeTab}
|
||||
onTabChange={setActiveTab}
|
||||
editMode={editMode}
|
||||
onEditModeChange={setEditMode}
|
||||
friendRequestSent={friendRequestSent}
|
||||
onFriendRequestSend={() => setFriendRequestSent(true)}
|
||||
onSaveSettings={async (updates) => {
|
||||
const result = await onSaveSettings(updates);
|
||||
if (result.isErr()) {
|
||||
// In a real app, we'd show a toast or error message.
|
||||
// For now, we just throw to let the UI handle it if needed,
|
||||
// or we could add an error state to this client component.
|
||||
throw new Error(result.getError());
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user