Skip to content

Commit

Permalink
Refactor getReservations function to use Prisma model and add type an…
Browse files Browse the repository at this point in the history
…notations
  • Loading branch information
GithmiHashara committed Sep 22, 2024
1 parent a839e7a commit 3761010
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/actions/getReservations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

import prisma from '@/app/libs/prismadb'

// src/types.ts or app/types.ts

export interface Reservation {
listing: any;
id: string;
createdAt: Date;
startDate: Date;
endDate: Date;
// Add other fields you
}

interface IParams {
listingId?: string
userId?: string
Expand Down Expand Up @@ -39,7 +50,7 @@ export default async function getReservations(
}
})

const safeReservations = reservations.map((reservation) => ({
const safeReservations = reservations.map((reservation: Reservation) => ({
...reservation,
createdAt: reservation.createdAt.toISOString(),
startDate: reservation.startDate.toISOString(),
Expand Down

0 comments on commit 3761010

Please sign in to comment.