* Add queued booking response table * Create `RoutingFormResponseRepository` * Pass `queueFormResponse` param * Queue up form response if param is passed * Forward queued form response parma to booker * Pass `queuedFormResponse` from booker to `handleNewBooking` * Write queued routing form response * Type fixes * Clean up * Allow dry run to work which wont have any QueuedFormResponse or FormResponse * Support passing the time when the modal was actually shown to the user and consider that time as the time of form submission * fix ts error * Queue -> Response through separate endpoint that would be triggered by embed * Make queueResponseId a non-guessable uid * Change queueFormResponse query param * fix ts error * Support useQueuedResponse to record new response data * revert handleNewBooking * Remove dead code formResponse * Refactor use repository * Unify migration files * refactor: moved api endpoint to app dir Signed-off-by: Omar López <zomars@me.com> * Update formResponse.ts * Refactor use-queued-response for test * Add tests * Fix ts error and unit test. recordFormResponse cant return nullish response * fix schema * feat: Support full reuse of preloaded iframe (#21803) * feat: support updating cal video settings in API v2 (#21784) * feat: support updating cal video settings in API v2 * chore: update descriptio * feat: support create event type * test: add test for updating event type * test: add test for create event type * chore: undo openapi * chore: bump libraries * Revert "chore: bump libraries" This reverts commit bdf36d09b021fc531497a7b7ea66ab9c52b7d136. * chore: bump libraries --------- Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com> Co-authored-by: supalarry <laurisskraucis@gmail.com> * fix tests and ts * Fix tests * wip-useQueuedResponseEndpoint * Add one more test * Change queueFormResponse query param * wip * Support useQueuedResponse to record new response data * Use the update useQueuedResponse endpoint * self-review addressed * Use queuedResponse if available in slots/utils * Add documentation * Remove use-queued-response from critical-path --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com> Co-authored-by: supalarry <laurisskraucis@gmail.com> * Update schema.prisma * refactor: renamed to avoid react hooks confusion Signed-off-by: Omar López <zomars@me.com> --------- Signed-off-by: Omar López <zomars@me.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com> Co-authored-by: supalarry <laurisskraucis@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
127 lines
3.1 KiB
TypeScript
127 lines
3.1 KiB
TypeScript
import prisma from "@calcom/prisma";
|
|
import type { Prisma } from "@calcom/prisma/client";
|
|
|
|
interface RecordFormResponseInput {
|
|
formId: string;
|
|
response: Record<string, any> | Prisma.JsonValue;
|
|
chosenRouteId: string | null;
|
|
}
|
|
|
|
export class RoutingFormResponseRepository {
|
|
private static generateCreateFormResponseData(
|
|
input: RecordFormResponseInput & { queuedFormResponseId?: string | null }
|
|
) {
|
|
return {
|
|
formId: input.formId,
|
|
response: input.response as Prisma.InputJsonValue,
|
|
chosenRouteId: input.chosenRouteId,
|
|
...(input.queuedFormResponseId
|
|
? {
|
|
queuedFormResponse: {
|
|
connect: {
|
|
id: input.queuedFormResponseId,
|
|
},
|
|
},
|
|
}
|
|
: {}),
|
|
};
|
|
}
|
|
|
|
static async recordFormResponse(
|
|
input: RecordFormResponseInput & {
|
|
queuedFormResponseId?: string | null;
|
|
}
|
|
) {
|
|
return await prisma.app_RoutingForms_FormResponse.create({
|
|
data: this.generateCreateFormResponseData(input),
|
|
});
|
|
}
|
|
|
|
static async recordQueuedFormResponse(input: RecordFormResponseInput) {
|
|
return await prisma.app_RoutingForms_QueuedFormResponse.create({
|
|
data: this.generateCreateFormResponseData(input),
|
|
});
|
|
}
|
|
|
|
static async findFormResponseIncludeForm({ routingFormResponseId }: { routingFormResponseId: number }) {
|
|
return await prisma.app_RoutingForms_FormResponse.findUnique({
|
|
where: {
|
|
id: routingFormResponseId,
|
|
},
|
|
select: {
|
|
response: true,
|
|
form: {
|
|
select: {
|
|
routes: true,
|
|
fields: true,
|
|
},
|
|
},
|
|
chosenRouteId: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
static async findQueuedFormResponseIncludeForm({ queuedFormResponseId }: { queuedFormResponseId: string }) {
|
|
return await prisma.app_RoutingForms_QueuedFormResponse.findUnique({
|
|
where: {
|
|
id: queuedFormResponseId,
|
|
},
|
|
select: {
|
|
response: true,
|
|
form: {
|
|
select: {
|
|
routes: true,
|
|
fields: true,
|
|
},
|
|
},
|
|
chosenRouteId: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
static async getQueuedFormResponseFromId(id: string) {
|
|
return await prisma.app_RoutingForms_QueuedFormResponse.findUnique({
|
|
where: {
|
|
id,
|
|
},
|
|
select: {
|
|
id: true,
|
|
formId: true,
|
|
response: true,
|
|
chosenRouteId: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
actualResponseId: true,
|
|
form: {
|
|
select: {
|
|
team: {
|
|
select: {
|
|
parentId: true,
|
|
},
|
|
},
|
|
user: {
|
|
select: {
|
|
id: true,
|
|
email: true,
|
|
},
|
|
},
|
|
id: true,
|
|
description: true,
|
|
position: true,
|
|
routes: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
name: true,
|
|
fields: true,
|
|
updatedById: true,
|
|
userId: true,
|
|
teamId: true,
|
|
disabled: true,
|
|
settings: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|
|
}
|