From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Format utility functions - Next.js Tutorial
From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
Format utility functions
Okay, so we want to continue on with our order details page, but there's a couple things that I want to do before we jump back in. So we're going to need some utility functions because we're using them on this page. We need one to shorten the ID, so this right here, because we're going to output it, but I don't want to output the whole thing. That's simple. Then we have a date time formatting utility where we can get a nicely formatted date and time, just the date, and just the time. And we'll use that here as well. Now, before we get to that, there's one thing that I want to do, and that is in the DB Prisma TS file. Now, if you remember, we extended the client so that when we deal with the product model and we deal with the price, we are just returning that as a string rather than a Prisma decimal type. And we did that with price and rating on the product model. Now, we also want to do that on the cart in order model when it comes to the items price, the shipping, the tax, and the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Section intro1m 31s
-
(Locked)
Payment method and Zod schemas9m 27s
-
(Locked)
Payment method page8m 1s
-
(Locked)
Payment method form and update13m 9s
-
(Locked)
Order and OrderItem Prisma models11m 7s
-
(Locked)
Order Zod schemas and types8m 16s
-
(Locked)
Place order page18m 5s
-
(Locked)
Create order action14m 15s
-
(Locked)
Place order form7m 37s
-
(Locked)
Order page and action8m 27s
-
(Locked)
Format utility functions8m 20s
-
(Locked)
Order details table14m 5s
-
(Locked)
-
-
-
-
-
-
-
-
-
-