From a839e7a3b0611c4857bc78eb864c969ed2629eb6 Mon Sep 17 00:00:00 2001 From: Githmi Hashara Date: Sun, 22 Sep 2024 18:54:09 +0530 Subject: [PATCH] Refactor getListings function to use Prisma model and add type annotations --- app/actions/getListings.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/actions/getListings.ts b/app/actions/getListings.ts index 0efd76d..2738a1e 100644 --- a/app/actions/getListings.ts +++ b/app/actions/getListings.ts @@ -1,5 +1,13 @@ import prisma from "@/app/libs/prismadb"; +// types.ts +export interface Listing { + id: string; + createdAt: Date; + // Add other fields you expect from the listing +} + + export interface IListingsParams { userId?: string; guestCount?: number; @@ -84,7 +92,7 @@ export default async function getListings( } }); - const safeListings = listings.map((listing) => ({ + const safeListings = listings.map((listing: Listing) => ({ ...listing, createdAt: listing.createdAt.toISOString(), }));