Migrate from Vue2 to React with modern tech stack
- Replace Vue2 + Vue CLI with Vite + React 18 + TypeScript - Add Tailwind CSS for efficient styling - Implement clean component architecture: - Split 1000+ line Vue component into focused React components - Add proper type safety with TypeScript - Use React Query for efficient data fetching - Update GitHub Actions for React build pipeline - Maintain existing functionality and design - Support Node.js 23 with .nvmrc 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
50
src/components/pages/UserPage.tsx
Normal file
50
src/components/pages/UserPage.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import Navigation from '../common/Navigation';
|
||||
import CardGrid from '../card/CardGrid';
|
||||
import UserProfile from '../user/UserProfile';
|
||||
import { fetchUsers, fetchUserCards } from '../../utils/api';
|
||||
|
||||
export default function UserPage() {
|
||||
const { username } = useParams<{ username: string }>();
|
||||
|
||||
const { data: users } = useQuery({
|
||||
queryKey: ['users'],
|
||||
queryFn: () => fetchUsers(),
|
||||
});
|
||||
|
||||
const user = users?.data.find(u => u.username === username);
|
||||
|
||||
const { data: cards, isLoading: cardsLoading } = useQuery({
|
||||
queryKey: ['userCards', user?.id],
|
||||
queryFn: () => fetchUserCards(user!.id),
|
||||
enabled: !!user?.id,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
return (
|
||||
<div className="min-h-screen">
|
||||
<Navigation />
|
||||
<div className="max-w-6xl mx-auto px-4 py-8">
|
||||
<div className="text-center text-xl">User not found</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen">
|
||||
<Navigation username={username} />
|
||||
|
||||
<div className="max-w-6xl mx-auto px-4">
|
||||
<UserProfile user={user} cards={cards?.data || []} />
|
||||
|
||||
{cardsLoading ? (
|
||||
<div className="text-center py-8">Loading cards...</div>
|
||||
) : (
|
||||
<CardGrid cards={cards?.data || []} user={user} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user