/**
 * 用户主页 UserScreen
 * 威友 - 查看其他用户资料
 * 使用统一的 UserProfileScreen 组件，mode='other'
 */

import React from 'react';
import { useLocalSearchParams, useRouter } from 'expo-router';
import { SafeAreaView } from 'react-native-safe-area-context';
import UserProfileScreen from './UserProfileScreen';
import { useCurrentUser } from '../../stores/auth';
import { SimpleHeader } from '../../components/common';

export const UserScreen: React.FC = () => {
  const { userId: userIdParam } = useLocalSearchParams<{ userId?: string }>();
  const router = useRouter();
  const userId = userIdParam || '';
  const currentUser = useCurrentUser();
  const isSelfProfile = !!currentUser?.id && currentUser.id === userId;

  return (
    <SafeAreaView style={{ flex: 1 }} edges={['top', 'bottom']}>
      <SimpleHeader title="用户主页" onBack={() => router.back()} />
      <UserProfileScreen
        mode={isSelfProfile ? 'self' : 'other'}
        userId={isSelfProfile ? undefined : userId}
        hasHeader={false}
      />
    </SafeAreaView>
  );
};

export default UserScreen;
