Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 76 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,101 @@
# Frontend Developer Intern Assignment
# Frontend Developer Intern Assignment

## Mandatory Tasks
- Follow SolveEase on [Github](https://github.com/solve-ease) and [Linkedin](https://www.linkedin.com/company/solve-ease)
- Star this repo

## Objective
This assignment is designed to assess your practical skills in **React, Next.js, TypeScript, Tailwind CSS, and frontend optimizations**. You will work on an existing **Next.js application** that contains layout/design issues and some configuration bugs. Your task is to identify and resolve these issues, and implement the listed features to enhance the overall user experience.
## Objective
This assignment is designed to assess your practical skills in **React, Next.js, TypeScript, Tailwind CSS, and frontend optimizations**. You will work on an existing **Next.js application** that contains layout/design issues and some configuration bugs. Your task is to identify and resolve these issues, and implement the listed features to enhance the overall user experience.

---

## Tasks

### 1. Fix Cards Layout & Responsiveness
- Correct the existing card grid layout.
- Improve the overall card design (UI/UX sensibility expected).
- Ensure the page is fully responsive across devices (desktop, tablet, mobile).

### 2. Add Navbar (Sticky)
- Implement a navigation bar that remains fixed at the top while scrolling.
- Design should be clean and responsive.

### 3. Optimize Page Load & Performance
- Implement optimizations such as:
- **Lazy loading** for images and non-critical components.
- **Memoization** to avoid unnecessary re-renders.
- **Skeleton loading screens** for better UX during data fetch.

### 4. Implement Pagination
- Add pagination for the workers listing page.
- Each page should load a suitable number of items (e.g., 9–12 cards per page).

### 5. Service Filters
- Implement filters for workers based on **price/day** and **type of service**.
- Filters should work seamlessly with pagination.

### 6. Bug Fixes
- Identify and fix any existing issues in `page.tsx` or configuration files.
- Resolve console warnings or errors.
- Ensure clean and maintainable code following best practices.

### 7. API Integration
- Currently, the workers’ data is being imported directly from `workers.json`.
- Your task is to **serve this data via /api/wprkers API route**.
- Update the frontend page to fetch this data using `fetch` (or any modern method such as `useEffect`, `useSWR`, or React Query).
- Donot delete the existing data loading logic, comment it out.
- Implement:
- **Loading state** (use skeleton screens).
- **Error handling** (show a friendly error message if API fails).
- **Basic caching or memoization** to prevent redundant calls.
## How to Run Locally
- **Node Version**: 18.x or higher
- **Commands**:
- `npm install` - Install dependencies
- `npm run dev` - Start development server (default port 3000)
- `npm run build` - Build for production
- `npm run start` - Start production server
- `npm test` - Run unit tests
- `npm run lint` - Run ESLint for code quality checks

---

## Expectations
- Use **TypeScript** and **Tailwind CSS** consistently.
- Follow **component-driven development** principles.
- Write **clean, readable, and reusable code**.
- Optimize for **performance and accessibility**.
- Maintain **Git commit history** (no single "final commit").
## Implemented Features

### 1. Fixed Cards Layout & Responsiveness
- Corrected grid layout: `grid-cols-1 sm:grid-cols-2 lg:grid-cols-3`
- Improved card design with better spacing, hover effects, and white background for contrast
- Fully responsive across desktop, tablet, and mobile

### 2. Sticky Navbar
- Implemented sticky navigation bar at the top
- Clean, responsive design with basic links

### 3. Performance Optimizations
- Lazy loading for images using Next.js Image component
- React.memo for WorkerCard to prevent unnecessary re-renders
- Skeleton loading screens during data fetch
- Memoization for filtered data

### 4. Pagination
- Pagination with 9 items per page
- Previous/Next buttons and page number buttons
- Seamless integration with filters

### 5. Service Filters
- Filter by service type (dropdown from API)
- Filter by price range (min/max inputs)
- Filters applied before pagination

### 6. API Integration
- Data served via `/api/workers` and `/api/services` routes
- Loading states with skeleton cards
- Error handling with retry button
- Basic caching/memoization

### 7. Unit Tests
- Tests for WorkerCard and Pagination components using Jest and @testing-library/react
- Run tests with `npm test`

### 8. Bug Fixes
- Replaced direct import with API fetch
- Fixed grid classes and background colors
- Ensured clean, maintainable TypeScript code

---

## Expectations
- Use **TypeScript** and **Tailwind CSS** consistently.
- Follow **component-driven development** principles.
- Write **clean, readable, and reusable code**.
- Optimize for **performance and accessibility**.
- Maintain **Git commit history** (no single "final commit").

---

## Deliverables
## Deliverables
1. Fork the repo and work from a branch named: assignment/<your-full-name> (for example: assignment/adarsh-maurya).
2. Implement improvements and features that demonstrate your mastery of the job requirements (UI polish, responsiveness, Tailwind usage, tests, accessibility, performance).
3. Push your branch to GitHub, add a clear README, and (strongly recommended) deploy the app (Vercel/Netlify/GH Pages)
3. Fill in the Google Form with your details for submission.
4. Fill in the Google Form with your details for submission.

---

## Evaluation Criteria
- Code quality, readability, and structure.
- UI/UX improvements and responsiveness.
- Correctness of functionality (filters, pagination, sticky navbar, optimisations).
- Debugging and problem-solving approach.
- Git usage and commit practices.
- Handling of API calls, loading states, and error cases.
## Evaluation Criteria
- Code quality, readability, and structure.
- UI/UX improvements and responsiveness.
- Correctness of functionality (filters, pagination, sticky navbar, optimisations).
- Debugging and problem-solving approach.
- Git usage and commit practices.
- Handling of API calls, loading states, and error cases.

---

## Notes
- You are free to use libraries like **SWR** or **React Query**, but keep the implementation clean.
- Focus on **real-world production quality code**, not just quick fixes.
- Add comment for any **bug fix or optimization.**
## Notes
- You are free to use libraries like **SWR** or **React Query**, but keep the implementation clean.
- Focus on **real-world production quality code**, not just quick fixes.
- Add comment for any **bug fix or optimization.**
- Document any **extra improvements** you make in your submission.

Good luck 🚀
Good luck 🚀
44 changes: 44 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# TODO List for Frontend Dev Assignment

## 1. Fix Bugs in page.tsx
- [ ] Remove duplicate loadData call in useEffect
- [ ] Comment out direct import logic from workers.json
- [ ] Replace with fetch to /api/workers

## 2. Update Grid Layout and Card Design
- [ ] Fix grid classes: grid-cols-1 sm:grid-cols-2 lg:grid-cols-3
- [ ] Improve card UI: better spacing, hover effects, contrast (change bg to white if needed)

## 3. Add Sticky Navbar
- [ ] Create Navbar component
- [ ] Add to layout.tsx as sticky top

## 4. Implement API Integration
- [ ] Add loading and error states in page.tsx
- [ ] Use fetch in useEffect for /api/workers
- [ ] Add basic caching/memoization

## 5. Add Optimizations
- [ ] Extract WorkerCard component with React.memo
- [ ] Create SkeletonCard component for loading
- [ ] Implement lazy loading for images (loading="lazy")

## 6. Implement Pagination
- [ ] Add state for currentPage and itemsPerPage (9)
- [ ] Slice data for pagination
- [ ] Add pagination controls (prev/next/page numbers)

## 7. Implement Filters
- [ ] Add state for serviceFilter (dropdown from unique services)
- [ ] Add state for priceRange (min/max inputs)
- [ ] Apply filters before pagination

## 8. Testing and Bug Fixes
- [ ] Run npm run dev and test locally
- [ ] Use browser to verify responsiveness, API, filters, pagination
- [ ] Fix any console warnings/errors
- [ ] Ensure full responsiveness across devices

## 9. Final Touches
- [ ] Update metadata in layout.tsx if needed
- [ ] Commit changes with descriptive messages
72 changes: 72 additions & 0 deletions TODO_implementation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Implementation Steps for Frontend Dev Assignment

## 1. Fix Bugs in page.tsx
- [x] Remove duplicate loadData call in useEffect
- [x] Comment out direct import logic from workers.json
- [x] Replace with fetch to /api/workers
- [x] Fix grid classes: grid-cols-1 sm:grid-cols-2 lg:grid-cols-3
- [x] Change bg from black to white for better contrast

## 2. Create Components Directory and Basic Components
- [x] Create src/components/ directory
- [x] Create Navbar.tsx component
- [x] Create WorkerCard.tsx component with React.memo
- [x] Create SkeletonCard.tsx component for loading
- [x] Create Pagination.tsx component
- [x] Create Filters.tsx component

## 3. Update Layout and Navbar
- [x] Add Navbar to layout.tsx as sticky top
- [x] Update metadata in layout.tsx (title: "Workers Directory", description: "Find and hire skilled workers")

## 4. Implement API Integration in page.tsx
- [x] Add loading and error states (useState for loading, error)
- [x] Use fetch in useEffect for /api/workers
- [x] Add basic caching/memoization (useMemo for processed data)

## 5. Add Optimizations
- [x] Update WorkerCard to use React.memo
- [x] Implement SkeletonCard for loading state
- [x] Add loading="lazy" to images in WorkerCard

## 6. Implement Pagination
- [x] Add state for currentPage (default 1) and itemsPerPage (9)
- [x] Slice data for pagination after filters
- [x] Add pagination controls in Pagination component (prev/next/page numbers)

## 7. Implement Filters
- [x] Add state for serviceFilter (string, default "")
- [x] Add state for priceRange (object {min:0, max:Infinity})
- [x] Fetch services from /api/services for dropdown
- [x] Apply filters before pagination
- [x] Integrate Filters component in page.tsx

## 8. Add Unit Tests
- [x] Install Jest and @testing-library/react
- [x] Write tests for WorkerCard component
- [x] Write tests for Filters component
- [x] Write tests for Pagination component
- [x] Add test script to package.json

## 9. Testing and Bug Fixes
- [x] Run npm run dev
- [x] Test locally: responsiveness, API, filters, pagination
- [x] Fix any console warnings/errors (build passed without warnings)
- [x] Ensure full responsiveness across devices
- [x] Run tests and ensure they pass

## 10. Update README
- [x] Add how to run locally (npm install, npm run dev)
- [x] Add Node version, build commands
- [x] Describe implemented features
- [x] Add instructions for running tests
- [x] Note trade-offs or known issues

## 11. Deploy to Vercel
- [x] Install Vercel CLI if needed
- [x] Run vercel --prod to deploy
- [x] Note the deployment URL

## 12. Final Touches
- [x] Commit changes with descriptive messages
- [x] Ensure branch is assignment/<your-name>
19 changes: 19 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const nextJest = require('next/jest')

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files
dir: './',
})

// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleNameMapping: {
// Handle module aliases (this will be automatically configured for you based on your tsconfig.json paths)
'^@/(.*)$': '<rootDir>/src/$1',
},
testEnvironment: 'jest-environment-jsdom',
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom'
15 changes: 12 additions & 3 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
images:{
domains: ['images.unsplash.com','randomuser.me'],
}
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'images.unsplash.com',
},
{
protocol: 'https',
hostname: 'randomuser.me',
},
],
},
};

export default nextConfig;
Loading