Skip to content

Scheduling infrastructure for absolutely everyone.

fix: routing form endpoints date filters validation (#20715)

Morgan43a6663230d5
diff --git a/apps/api/v2/src/modules/organizations/routing-forms/controllers/organizations-routing-forms-responses.controller.e2e-spec.ts b/apps/api/v2/src/modules/organizations/routing-forms/controllers/organizations-routing-forms-responses.controller.e2e-spec.ts
index c0061033ced..30014330250 100644
--- a/apps/api/v2/src/modules/organizations/routing-forms/controllers/organizations-routing-forms-responses.controller.e2e-spec.ts
+++ b/apps/api/v2/src/modules/organizations/routing-forms/controllers/organizations-routing-forms-responses.controller.e2e-spec.ts
@@ -178,9 +178,12 @@ describe("OrganizationsRoutingFormsResponsesController", () => {
});
it("should get routing form responses", async () => {
+ const createdAt = new Date(routingFormResponse.createdAt);
+ createdAt.setHours(createdAt.getHours() - 1);
+ const isoStringCreatedAt = createdAt.toISOString();
return request(app.getHttpServer())
.get(
- `/v2/organizations/${org.id}/routing-forms/${routingForm.id}/responses?skip=0&take=2&sortUpdatedAt=asc&sortCreatedAt=desc`
+ `/v2/organizations/${org.id}/routing-forms/${routingForm.id}/responses?skip=0&take=2&sortUpdatedAt=asc&sortCreatedAt=desc&afterCreatedAt=${isoStringCreatedAt}`
)
.set({ Authorization: `Bearer cal_test_${apiKeyString}` })
.expect(200)
diff --git a/apps/api/v2/src/modules/organizations/routing-forms/inputs/get-routing-form-responses-params.input.ts b/apps/api/v2/src/modules/organizations/routing-forms/inputs/get-routing-form-responses-params.input.ts
index 48edda884df..3b210e0659b 100644
--- a/apps/api/v2/src/modules/organizations/routing-forms/inputs/get-routing-form-responses-params.input.ts
+++ b/apps/api/v2/src/modules/organizations/routing-forms/inputs/get-routing-form-responses-params.input.ts
@@ -1,15 +1,6 @@
import { ApiPropertyOptional } from "@nestjs/swagger";
import { Transform } from "class-transformer";
-import {
- IsOptional,
- IsString,
- IsEnum,
- IsISO8601,
- IsDate,
- IsNumber,
- IsArray,
- ArrayMinSize,
-} from "class-validator";
+import { IsOptional, IsString, IsEnum, IsISO8601, IsNumber, IsArray, ArrayMinSize } from "class-validator";
enum SortOrder {
ASC = "asc",
@@ -44,9 +35,7 @@ export class GetRoutingFormResponsesParams {
})
@IsOptional()
@IsISO8601()
- @Transform(({ value }) => value && new Date(value))
- @IsDate()
- afterCreatedAt?: Date;
+ afterCreatedAt?: string;
@ApiPropertyOptional({
type: String,
@@ -55,9 +44,7 @@ export class GetRoutingFormResponsesParams {
})
@IsOptional()
@IsISO8601()
- @Transform(({ value }) => value && new Date(value))
- @IsDate()
- beforeCreatedAt?: Date;
+ beforeCreatedAt?: string;
@ApiPropertyOptional({
type: String,
@@ -66,9 +53,7 @@ export class GetRoutingFormResponsesParams {
})
@IsOptional()
@IsISO8601()
- @Transform(({ value }) => value && new Date(value))
- @IsDate()
- afterUpdatedAt?: Date;
+ afterUpdatedAt?: string;
@ApiPropertyOptional({
type: String,
@@ -77,9 +62,7 @@ export class GetRoutingFormResponsesParams {
})
@IsOptional()
@IsISO8601()
- @Transform(({ value }) => value && new Date(value))
- @IsDate()
- beforeUpdatedAt?: Date;
+ beforeUpdatedAt?: string;
@ApiPropertyOptional({ type: String, description: "Filter by responses routed to a specific booking" })
@IsOptional()
diff --git a/apps/api/v2/src/modules/organizations/routing-forms/organizations-routing-forms.repository.ts b/apps/api/v2/src/modules/organizations/routing-forms/organizations-routing-forms.repository.ts
index 251cc341a54..66fe05d83f0 100644
--- a/apps/api/v2/src/modules/organizations/routing-forms/organizations-routing-forms.repository.ts
+++ b/apps/api/v2/src/modules/organizations/routing-forms/organizations-routing-forms.repository.ts
@@ -15,10 +15,10 @@ export class OrganizationsRoutingFormsRepository {
name?: string;
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
teamIds?: number[];
}
) {
@@ -61,10 +61,10 @@ export class OrganizationsRoutingFormsRepository {
options?: {
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
routedToBookingUid?: string;
}
) {
diff --git a/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms-responses.service.ts b/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms-responses.service.ts
index a4a668fa17e..33a612604e9 100644
--- a/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms-responses.service.ts
+++ b/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms-responses.service.ts
@@ -17,10 +17,10 @@ export class OrganizationsRoutingFormsResponsesService {
options?: {
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
routedToBookingUid?: string;
}
) {
diff --git a/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms.service.ts b/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms.service.ts
index eab3330261d..97e178d8a5b 100644
--- a/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms.service.ts
+++ b/apps/api/v2/src/modules/organizations/routing-forms/services/organizations-routing-forms.service.ts
@@ -14,10 +14,10 @@ export class OrganizationsRoutingFormsService {
name?: string;
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
teamIds?: number[];
}
) {
diff --git a/apps/api/v2/src/modules/organizations/teams/routing-forms/organizations-teams-routing-forms.module.ts b/apps/api/v2/src/modules/organizations/teams/routing-forms/organizations-teams-routing-forms.module.ts
index e6b5ac672e7..be2bb9c2f28 100644
--- a/apps/api/v2/src/modules/organizations/teams/routing-forms/organizations-teams-routing-forms.module.ts
+++ b/apps/api/v2/src/modules/organizations/teams/routing-forms/organizations-teams-routing-forms.module.ts
@@ -5,7 +5,6 @@ import { OrganizationsRoutingFormsResponsesService } from "@/modules/organizatio
import { OrganizationsTeamsRepository } from "@/modules/organizations/teams/index/organizations-teams.repository";
import { PrismaModule } from "@/modules/prisma/prisma.module";
import { RedisModule } from "@/modules/redis/redis.module";
-import { RedisService } from "@/modules/redis/redis.service";
import { RoutingFormsModule } from "@/modules/routing-forms/routing-forms.module";
import { StripeModule } from "@/modules/stripe/stripe.module";
import { Module } from "@nestjs/common";
diff --git a/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms-responses.repository.ts b/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms-responses.repository.ts
index 8b466e7b736..ac288fa9032 100644
--- a/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms-responses.repository.ts
+++ b/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms-responses.repository.ts
@@ -13,8 +13,8 @@ export class OrganizationsTeamsRoutingFormsResponsesRepository {
take: number,
options?: {
sortCreatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
routedToBookingUid?: string;
}
) {
diff --git a/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms.repository.ts b/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms.repository.ts
index 7645ff04eb7..13861732225 100644
--- a/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms.repository.ts
+++ b/apps/api/v2/src/modules/organizations/teams/routing-forms/repositories/organizations-teams-routing-forms.repository.ts
@@ -15,10 +15,10 @@ export class OrganizationsTeamsRoutingFormsRepository {
name?: string;
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
}
) {
const {
diff --git a/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms-responses.service.ts b/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms-responses.service.ts
index 9bca5f1d0f4..aa57d287baa 100644
--- a/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms-responses.service.ts
+++ b/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms-responses.service.ts
@@ -18,10 +18,10 @@ export class OrganizationsTeamsRoutingFormsResponsesService {
options?: {
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
routedToBookingUid?: string;
}
) {
diff --git a/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms.service.ts b/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms.service.ts
index 5eae2716542..920ec28946a 100644
--- a/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms.service.ts
+++ b/apps/api/v2/src/modules/organizations/teams/routing-forms/services/organizations-teams-routing-forms.service.ts
@@ -15,10 +15,10 @@ export class OrganizationsTeamsRoutingFormsService {
name?: string;
sortCreatedAt?: "asc" | "desc";
sortUpdatedAt?: "asc" | "desc";
- afterCreatedAt?: Date;
- beforeCreatedAt?: Date;
- afterUpdatedAt?: Date;
- beforeUpdatedAt?: Date;
+ afterCreatedAt?: string;
+ beforeCreatedAt?: string;
+ afterUpdatedAt?: string;
+ beforeUpdatedAt?: string;
}
) {
return this.routingFormsRepository.getTeamRoutingForms(teamId, skip, take, options);