Enhance the existing Next.js boilerplate by integrating the DummyJSON Products API into a data table. Implement full CRUD operations, pagination, sorting, form validation using Zod, routing with dynamic titles, and utilize TanStack Query for efficient data fetching and state management.
- Fetch product data from
https://dummyjson.com/productsusing TanStack Query. - Either use the existing DataTable component located in
src/components/table/data-table.tsxto display the data, or install tanstack table (https://tanstack.com/table) - You should only pass data and configuration (columns, rows, etc.) as props — do not modify the internal implementation of this component.
- Implement pagination using the API's
limitandskipquery parameters. - Allow users to navigate through different pages of products.
- Enable client-side sorting of products on the table based on fields like
title,price, andrating. - Implement both ascending and descending order sorting.
-
Add Product:
- Create a form to add a new product.
- Use Zod with
react-hook-formfor form validation. - Send a POST request to
https://dummyjson.com/products/add. - Upon successful addition, update the TanStack Query's cache to include the new product.
-
Update Product:
- Allow editing of existing product details.
- Use Zod for validating the updated data.
- Send a PUT request to
https://dummyjson.com/products/{id}. - Reflect the changes in the TanStack Query's cache upon successful update.
-
Delete Product:
- Implement a delete functionality for each product.
- Send a DELETE request to
https://dummyjson.com/products/{id}. - Remove the product from the TanStack Query's cache upon successful deletion.
- Clicking on a table row should navigate to a product view page at
/products/[id]. - Fetch the product using
GET https://dummyjson.com/products/{id}. - Display key information: title, price, description, brand, thumbnail, etc.
- Use the product name (or relevant context) as the document
<title>for each page.- Example:
/products: “All Products – MyShop”/products/12: “iPhone 9 – MyShop”
- Example:
If you complete the core functionality early and want to take your submission further, consider implementing one or more of the following enhancements:
- Search: Add a client-side debounced search feature to allow users to filter products by title or brand.
- Optimistic Updates: Use TanStack Query's
onMutateandonSuccesscallbacks to implement optimistic updates for create, update, or delete operations. - Skeleton Loaders: Display skeleton screens or shimmer effects while the data is being fetched, especially on slower networks.
- Extras: Feel free to use libraries such as zustand, shadCN These extras are not required, but they will help your submission stand out and demonstrate attention to detail.
Use zod and @hookform/resolvers/zod for schema validation. Example schema:
import { z } from 'zod';
export const productSchema = z.object({
username: z.string().min(1, { message: 'Username is required' }),
password: z.string().min(1, { message: 'Password is required' })
});Integrate this schema with react-hook-form to validate form inputs and display appropriate error messages.
- Functionality : Correct implementation of data fetching, pagination, sorting, CRUD operations, and routing.
- Code Quality : Clean, readable, and maintainable code.
- User Experience : Intuitive and responsive UI/UX.
- Validation : Effective use of Zod for form validation with appropriate error messages.
- State Management : Efficient use of TanStack Query for data fetching and state management.
- Error Handling : Proper handling of API errors and edge cases.
- Clone the base repository
URL:https://github.com/QarbonaAI/fe-task - Create a private GitHub repository under your own account.
- Add the following GitHub username(s) as collaborators:
aditansh,AchintyaQarbona,siddharth1825,abhitrueprogrammer
- Submit the private repository link as part of your application.
- Don't make the repository public at any time. This ensures fairness and prevents plagiarism.