A modern, feature-rich React application built with Vite, TypeScript, and cutting-edge technologies for managing and displaying user and product data.
- β React 19 with TypeScript for type-safe development
- β Vite 7 for lightning-fast development and building
- β React Router DOM 7 for client-side routing
- β Axios for HTTP requests with request/response interceptors
- β Context API for global state management
- β Tailwind CSS v4 for modern utility-first styling
- β Ant Design 5 for professional UI components
- β
Reusable DataTable Component with advanced features:
- Server-side pagination
- Dynamic page size selection (5, 10, 20, 50)
- Server-side filtering (key-value pairs)
- Client-side search functionality
- Custom color scheme
- β Tab Navigation for categorized product views
- β Field Selection via query parameters for optimized API responses
- β Responsive design with custom styling
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher recommended)
- npm (v9 or higher) or yarn
git clone <repository-url>
cd astudio-tasknpm installThis will install all required dependencies including:
- React, React DOM, React Router DOM
- Axios for API calls
- Ant Design for UI components
- Tailwind CSS v4 for styling
- TypeScript and all type definitions
npm run devThe application will start at http://localhost:5173/
npm run buildnpm run previewastudio-task/
βββ src/
β βββ api/
β β βββ axios.ts # Axios instance with interceptors
β β βββ userService.ts # User API service with filters & select fields
β β βββ productService.ts # Product API service with category support
β βββ components/
β β βββ DataTable.tsx # Reusable table with pagination, filters, search
β β βββ DataTable.css # Custom table styling
β β βββ TabComponent.tsx # Reusable tab wrapper component
β β βββ TabComponent.css # Tab styling
β β βββ Navbar.tsx # Navigation bar
β βββ context/
β β βββ AppContext.tsx # Global state management with Context API
β βββ pages/
β β βββ Home.tsx # Landing page
β β βββ Users.tsx # Users table with 9 columns
β β βββ Products.tsx # Products with tabs (All/Laptops)
β βββ App.tsx # Main app with routing configuration
β βββ App.css # App-level styles
β βββ main.tsx # Application entry point
β βββ index.css # Global styles with Tailwind imports
βββ public/ # Static assets
βββ index.html # HTML template
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ postcss.config.js # PostCSS configuration for Tailwind v4
βββ vite.config.ts # Vite configuration
The project uses DummyJSON API for data:
- Base URL:
https://dummyjson.com/users - Features: Pagination, filtering, field selection
- Example:
https://dummyjson.com/users?limit=10&skip=0&select=firstName,lastName,age,gender,email,username,bloodGroup,eyeColor,maidenName
- All Products:
https://dummyjson.com/products - Category Products:
https://dummyjson.com/products/category/laptops - Features: Pagination, filtering, field selection, category filtering
- Example:
https://dummyjson.com/products?limit=10&skip=0&select=title,brand,category
- β Automatic request/response interceptors
- β Error handling
- β Dynamic query parameter building
- β Server-side filtering with key-value pairs
- β Field selection for optimized responses
- β Category-based product fetching
Displays a table with 9 columns:
- First Name
- Last Name
- Maiden Name
- Age
- Gender
- Username
- Blood Group
- Eye Color
Features:
- Server-side pagination (10 items per page default)
- Adjustable page size (5, 10, 20, 50)
- Filters: firstName, age, gender
- Client-side search across all fields
- Custom color scheme
Displays products with tabbed navigation:
Tabs:
- All: Shows all products from
/products - Laptops: Shows only laptops from
/products/category/laptops
Columns:
- Title
- Brand
- Category
Features:
- Server-side pagination (10 items per page default)
- Adjustable page size (5, 10, 20, 50)
- Filters: title, brand, category
- Client-side search across all fields
- Tab switching resets pagination
- Filters work independently in each tab
- Black:
#322625 - Grey:
#ebebeb - Blue:
#c0e3e5 - Yellow:
#fdc936
A highly reusable table component with props:
data: Array of items to displaycolumns: Column definitionsloading: Loading statetotal: Total number of items for paginationpageSize: Current page sizecurrentPage: Current page numberonPageChange: Page change handleronPageSizeChange: Page size change handleronSearch: Search handleronFilterChange: Filter change handlerfilters: Array of filter field definitions
A reusable tab wrapper with props:
items: Array of tab items (key, label, children)activeKey: Currently active tab keyonChange: Tab change handlerdefaultActiveKey: Default tab (optional)
| Command | Description |
|---|---|
npm run dev |
Start development server at http://localhost:5173 |
npm run build |
Build for production (outputs to dist/) |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint to check code quality |
Configured for strict type checking and React development.
- Content paths configured for all
.tsxand.tsfiles - Extensible theme configuration
- Tailwind CSS v4 with PostCSS plugin
- React plugin enabled
- Fast refresh for development
- Optimized build output
- Visit
http://localhost:5173/ - You should see the home page with navigation links
- Click "Users" in the navbar
- Verify the table loads with 10 users
- Try changing page size (5, 10, 20, 50)
- Test pagination by navigating pages
- Apply a filter (e.g., firstName = "Emily")
- Use the search feature to find specific users
- Verify all 9 columns display correctly
- Click "Products" in the navbar
- Verify "All" tab is active by default
- Check that products load correctly
- Switch to "Laptops" tab
- Verify only laptops are displayed
- Test pagination in both tabs
- Apply filters (e.g., brand = "Apple")
- Use search to find products
- Change page size and verify it works
- Use the navbar to switch between pages
- Verify routing works without page reload
- Check that state persists appropriately
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
npm run dev- Ensure
@import "tailwindcss";is insrc/index.css - Check that PostCSS config includes
@tailwindcss/postcss - Restart dev server
- Check network connection
- Verify DummyJSON API is accessible: https://dummyjson.com/
- Check browser console for error messages
- Ensure axios interceptors are properly configured
# Check TypeScript compilation
npm run build
# Or run type checking
npx tsc --noEmitreact(^19.1.1) - UI libraryreact-dom(^19.1.1) - React DOM renderingreact-router-dom(^7.9.4) - Routingaxios(^1.12.2) - HTTP clientantd(^5.27.4) - UI component library
vite(^7.1.7) - Build tooltypescript(~5.9.3) - Type safetytailwindcss(^4.1.14) - CSS framework@tailwindcss/postcss(^4.1.14) - Tailwind PostCSS plugin@vitejs/plugin-react(^5.0.4) - React plugin for Vite- ESLint and related plugins for code quality
- Optimized API Calls: Uses
selectparameter to fetch only needed fields - Server-Side Filtering: Filters applied at API level for better performance
- Reusable Components: DataTable and TabComponent can be used across the app
- Type Safety: Full TypeScript coverage for all components and services
- Modern Stack: Latest versions of React, Vite, and other libraries
- Professional UI: Ant Design components with custom styling
- Responsive Design: Works on desktop and mobile devices
- Clean Architecture: Separated concerns (API, components, pages, context)
MIT
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
For issues or questions, please open an issue in the repository.
Happy Coding! π