Developer Assessment Test: Product Filtering, Admin Reporting, and Prisma Model Extension #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(This PR description is the same as added at the beggining of
README.mdfile)This project implements all three parts of the technical challenge using Next.js, Prisma, Tailwind CSS, shadcn/ui, and React best practices.
🚧 Setting things up
To make sure project runs as expected a few steps first:
Create your own .env files in both admin and storefront projects. (Some variables won't be used here)
Install dependencies in both admin and storefront projects.
Setup a project in Supabase (recommended) or PostgreSQL database of your choice
After setting up your DATABASE_URL in .env file run this command to create tables in database.
Note: I took some time trying to make SMTP and JWT variables to work, but then realized they weren't necessary to this accessment. As for part 2 in admin report page, tested whole page without permission control, then added it to
middleware.tsmatcher list.1️⃣ Rebuild product filters on the storefront page
cmdkand shadcn'sCommandItemstyle.category.title IN [...]).next/navigationhooks (useSearchParams,useRouter,usePathname) to synchronize filters with the URL query string.AvailableTogglejust because I thought it was a nice filter.2️⃣ Build an admin reports page with charts or tables
ReportsPageunder the admin app.orderItems.productanduser.createdAt DESC.Calendarfor that.date-fnsto ensure the end date (to) includes the full day (i.e.,endOfDay(to)).3️⃣ Extend the Product model for cross-sell recommendations
Productmodel.seed.tsso after running migration and database commands products are randomly given crossSell relations. Tested field in Supabase pannel.toastnotification usingshadcn/ui. Chose that one because it was already installed in project and I'm used to work with it.try/catcherror when adding/removing items from cart.🚀 Final Touches
DateRange).fromdate selected).