Files
06d6c180d1 feat: report booking (#24324)
* feat: report booking

* refactor: improvements

* test: add unit test

* test: add unit test

* chore

* refactor: feedback

* refactor: feedback

* refactor: feedback

* fix: use string

* fix: schema

* chore: improvements

* refactor: create service

* fix: udate test

* fix: feedback

* fix: schema

* fix: type

* fix: type

* refactor: address feedback

* refactor: move to new file

* refactor: move to new file

* chor: remove

* fix UserRepository import

* fix type of bookingUid

* fix: import path

* fix: remove cancellation

* chore: duplicate

* fix: tests

* refactor: feedback

* chore: remove table from here

* fix: types

* fix: types

---------

Co-authored-by: CarinaWolli <[email protected]>
2025-10-14 09:23:31 +01:00

44 lines
1.2 KiB
TypeScript

import type { PrismaClient } from "@calcom/prisma";
import type {
IBookingReportRepository,
CreateBookingReportInput,
BookingReportSummary,
} from "./bookingReport.interface";
export class PrismaBookingReportRepository implements IBookingReportRepository {
constructor(private readonly prismaClient: PrismaClient) {}
async createReport(input: CreateBookingReportInput): Promise<{ id: string }> {
const report = await this.prismaClient.bookingReport.create({
data: {
bookingUid: input.bookingUid,
bookerEmail: input.bookerEmail,
reportedById: input.reportedById,
reason: input.reason,
description: input.description,
cancelled: input.cancelled,
organizationId: input.organizationId,
},
select: { id: true },
});
return report;
}
async findAllReportedBookings(params: { skip?: number; take?: number }): Promise<BookingReportSummary[]> {
const reports = await this.prismaClient.bookingReport.findMany({
skip: params.skip,
take: params.take,
select: {
id: true,
reportedById: true,
reason: true,
description: true,
createdAt: true,
},
orderBy: { createdAt: "desc" },
});
return reports;
}
}