This repository contains a frontend challenge based on a typical NextJS project at Ongrid Protocol.
This is a Next.js project bootstrapped with create-next-app
and configured with:
- ESLint and Prettier
- Git hooks set up with Husky
- NextJS and React specific folders
- TypeScript
- Tailwind CSS
You'll be building user profile cards that fetch and display user information, demonstrating your ability to work with React, TypeScript, and modern data fetching practices.
- Next.js
- TypeScript
- React Query (preferred) / any data fetching library
- shadcn/ui (preferred) / any UI component library
- Tailwind CSS
The app has the following structure:
src/
├── components/ # React components used across the app
├── pages/ # NextJS specific pages (page-specific logic only)
├── layouts/ # Presentation elements for pages
├── utils/ # Helper functions
│ ├── client/ # Client-side utils
│ ├── server/ # Server-side only
│ └── common/ # Shared types and utils
└── hooks/ # Custom React hooks
A NextJS API route is available to fetch user details:
- Endpoint:
api/user?person={Person.PersonA}
- Available users:
- Person A (responds in 1 second)
- Person B (responds in 3 seconds)
- Person C (always fails - use for error handling)
Response type:
type User = {
backgroundImageUrl: string;
profilePictureUrl: string;
name: string;
title: string;
followers: number;
following: number;
};
-
User Card Component
- Create a reusable card component that displays:
- Profile picture
- Background image
- Name
- Title
- Follower/Following counts
- Implement proper loading and error states
- Use shadcn/ui Card component or equivalent
- Create a reusable card component that displays:
-
Data Fetching
- Implement data fetching using React Query
- Create a custom
useUserProfile
hook - Handle loading and error states efficiently
-
User Selection
- Allow switching between users (A, B, C) using buttons
- Highlight currently selected user
- Handle loading states during user switches
-
Error Handling
- Display error state for Person C
- Add retry functionality
- Show appropriate error messages
-
Web3 Integration
- Implement wallet connection using wagmi/ethers.js
- Display connected wallet address
- Handle connection states (connecting/connected/disconnected)
- Support network switching
- Implement disconnect functionality
-
Enhanced User Experience
- Add loading skeletons
- Implement smooth transitions
- Add hover states on cards
-
Data Management
- Cache previously fetched user data
- Implement prefetching
- Handle concurrent requests
-
Smart Contract Integration
- Implement ERC20 token interactions using OpenZeppelin contract
- Read functions:
- Get token balance
- Get total supply
- Write functions:
- Transfer tokens
- Approve spending
- Handle transaction states
- Display transaction history
- Node.js installed
- npm or yarn
- Git
- Clone the repository:
git clone <repository-url>
cd <project-directory>
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Open http://localhost:3000 in your browser
If you're only doing the frontend tasks, you don't need these steps. However, if you want to work with the backend:
- Copy
.env.example
into.env
(Note: Prisma requires.env
specifically) - Install Docker Desktop
- Run services:
docker compose up
- Apply migrations:
prisma migrate dev
-
Code Quality
- TypeScript usage
- Component structure
- Custom hooks implementation
- Error handling
-
Functionality
- User card display
- Data fetching implementation
- Loading/error states
- User switching
-
Technical Implementation
- React Query usage
- Component reusability
- State management
- Type safety
- Create a new branch for your implementation
- Submit a pull request with:
- Implementation overview
- Technical decisions explanation
- Known limitations
- Setup instructions
- Focus on functionality over styling
- Use the provided UI library components
- Prioritize proper data fetching and error handling
- Document any assumptions made
- Add unit tests for custom hooks
- Implement SSR with React Query
- Add keyboard navigation between users
- Implement advanced error recovery strategies