From cda4f011ca3fd46337c759d9e9142077f867e23b Mon Sep 17 00:00:00 2001 From: Navaneethakrishnan Date: Tue, 22 Oct 2024 18:36:28 +0530 Subject: [PATCH] feat: introduced priority in event guest --- .forestadmin-schema.json | 16 ++++++++++++++++ .../migration.sql | 3 ++- apps/web-api/prisma/schema.prisma | 1 + apps/web-api/src/auth/auth.service.ts | 6 +++--- .../src/pl-events/pl-event-guests.service.ts | 6 ++++-- libs/contracts/src/schema/pl-event-guest.ts | 8 +++++--- 6 files changed, 31 insertions(+), 9 deletions(-) rename apps/web-api/prisma/migrations/{20241021062407_event_guest_is_featured => 20241022124400_pl_event_guest_new_fields}/migration.sql (57%) diff --git a/.forestadmin-schema.json b/.forestadmin-schema.json index 8918f4e1b..98a04e886 100644 --- a/.forestadmin-schema.json +++ b/.forestadmin-schema.json @@ -4057,6 +4057,22 @@ "type": "String", "validations": [] }, + { + "defaultValue": null, + "enums": null, + "field": "priority", + "integration": null, + "inverseOf": null, + "isFilterable": true, + "isPrimaryKey": false, + "isReadOnly": false, + "isRequired": false, + "isSortable": true, + "isVirtual": false, + "reference": null, + "type": "Number", + "validations": [] + }, { "defaultValue": null, "enums": null, diff --git a/apps/web-api/prisma/migrations/20241021062407_event_guest_is_featured/migration.sql b/apps/web-api/prisma/migrations/20241022124400_pl_event_guest_new_fields/migration.sql similarity index 57% rename from apps/web-api/prisma/migrations/20241021062407_event_guest_is_featured/migration.sql rename to apps/web-api/prisma/migrations/20241022124400_pl_event_guest_new_fields/migration.sql index 509047ac0..0b2631bcd 100644 --- a/apps/web-api/prisma/migrations/20241021062407_event_guest_is_featured/migration.sql +++ b/apps/web-api/prisma/migrations/20241022124400_pl_event_guest_new_fields/migration.sql @@ -1,2 +1,3 @@ -- AlterTable -ALTER TABLE "PLEventGuest" ADD COLUMN "isFeatured" BOOLEAN NOT NULL DEFAULT false; +ALTER TABLE "PLEventGuest" ADD COLUMN "isFeatured" BOOLEAN NOT NULL DEFAULT false, +ADD COLUMN "priority" INTEGER; diff --git a/apps/web-api/prisma/schema.prisma b/apps/web-api/prisma/schema.prisma index 49b793e37..6db16c414 100644 --- a/apps/web-api/prisma/schema.prisma +++ b/apps/web-api/prisma/schema.prisma @@ -404,6 +404,7 @@ model PLEventGuest { event PLEvent @relation(fields: [eventUid], references: [uid], onDelete: Cascade) additionalInfo Json? topics String[] + priority Int? isHost Boolean @default(false) isSpeaker Boolean @default(false) isFeatured Boolean @default(false) diff --git a/apps/web-api/src/auth/auth.service.ts b/apps/web-api/src/auth/auth.service.ts index 3bd1e8a01..8bfbbb91a 100644 --- a/apps/web-api/src/auth/auth.service.ts +++ b/apps/web-api/src/auth/auth.service.ts @@ -142,7 +142,7 @@ export class AuthService implements OnModuleInit { } // Link account by email - const newTokens = await this.linkEmailWithAuthAccount(foundUser.email, idToken); + const newTokens = await this.linkEmailWithAuthAccount(foundUser?.email, idToken); // format userinfo const userInfo = this.memberToUserInfo(foundUser); @@ -231,13 +231,13 @@ export class AuthService implements OnModuleInit { return response.data.access_token; } - private async linkEmailWithAuthAccount(email: string, userIdToken: string) { + private async linkEmailWithAuthAccount(email: string | null, userIdToken: string) { const clientToken = await this.getAuthClientToken(); let linkResult; try { linkResult = await this.getAuthApi().put( `/admin/accounts`, - { token: userIdToken, email: email.toLowerCase().trim() }, + { token: userIdToken, email: email?.toLowerCase().trim() }, { headers: { Authorization: `Bearer ${clientToken}`, diff --git a/apps/web-api/src/pl-events/pl-event-guests.service.ts b/apps/web-api/src/pl-events/pl-event-guests.service.ts index 145e11dde..17bb40272 100644 --- a/apps/web-api/src/pl-events/pl-event-guests.service.ts +++ b/apps/web-api/src/pl-events/pl-event-guests.service.ts @@ -258,7 +258,8 @@ export class PLEventGuestsService { isFeatured: true, team: { select: { - name: true, + uid: true, + name: true } }, member: { @@ -271,7 +272,8 @@ export class PLEventGuestsService { } } } - } + }, + orderBy: query.orderBy }); return pLEventGuests; } catch(err) { diff --git a/libs/contracts/src/schema/pl-event-guest.ts b/libs/contracts/src/schema/pl-event-guest.ts index ff4a7ec02..84571d518 100644 --- a/libs/contracts/src/schema/pl-event-guest.ts +++ b/libs/contracts/src/schema/pl-event-guest.ts @@ -44,19 +44,21 @@ export const PLEventGuestSchema = z.object({ topics: z.array(z.string()).nullish(), isFeatured: z.boolean().nullish(), isHost: z.boolean().nullish(), - isSpeaker: z.boolean().nullish() + isSpeaker: z.boolean().nullish(), + priority: z.number().int().nullish() }); export const ResponsePLEventGuestSchema = PLEventGuestSchema.omit({ id: true }).strict(); export const ResponsePLEventGuestSchemaWithRelationsSchema = ResponsePLEventGuestSchema.extend({ member: ResponseMemberSchema.optional(), - team: ResponseTeamSchema.optional() + team: ResponseTeamSchema.optional(), }); export const PLEventGuestRelationalFields = ResponsePLEventGuestSchemaWithRelationsSchema.pick({ member: true, - team: true + team: true, + priority: true }).strip(); export const PLEventGuestQueryableFields = PLEventGuestRelationalFields.keyof();