Files
calendar/packages/lib/server/repository/PrismaRoutingFormResponseRepository.ts
T
Joe Au-YeungGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Alex van Andel
f85f226982 fix: Create RoutingFormResponseService to get field value from identifier (#22396)
* Make identifier required

* Fallback to null if identifier isn't present

* Type fix

* Type fixes

* Type fix

* Create `RoutingFormResponseRepository`

* Create `RoutingFormResponseService`

* Use repsotiories to find form value

* Delete console.logs

* Undo change in `ZResponseInputSchema` schema

* Type fix

* Undo changes

* fix: correct import path in RoutingFormResponseService to resolve runtime errors

- Change relative import path to use @calcom alias
- Prevents import resolution failures that cause app startup issues

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>

* Undo changes

* Update type

* Update typing

* Address feedback

* Address feedback

* chore: Provide a suggestion for pr 22396, new structure (#22491)

* chore: Provide a suggestion for pr 22396, new structure

* Refactor to create two create methods with bookingUid and id

* Use `createWithBookingUid`

* Extract routing form response parser to seperate util

* Added more and improved test cases

* Fix

---------

Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>

* Factory included wrong calls

* Fix test for findFieldValueByIdentifier

* Add tests

* Fix test

* Fix test

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-07-17 22:40:18 +01:00

39 lines
952 B
TypeScript

import type { PrismaClient } from "@calcom/prisma";
import prisma from "@calcom/prisma";
import type { RoutingFormResponseRepositoryInterface } from "./RoutingFormResponseRepository.interface";
export class PrismaRoutingFormResponseRepository implements RoutingFormResponseRepositoryInterface {
constructor(private readonly prismaClient: PrismaClient = prisma) {}
findByIdIncludeForm(id: number) {
return this.prismaClient.app_RoutingForms_FormResponse.findUnique({
where: {
id,
},
include: {
form: {
select: {
fields: true,
},
},
},
});
}
findByBookingUidIncludeForm(bookingUid: string) {
return this.prismaClient.app_RoutingForms_FormResponse.findUnique({
where: {
routedToBookingUid: bookingUid,
},
include: {
form: {
select: {
fields: true,
},
},
},
});
}
}