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

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…

Contents