Skip to content

Commit

Permalink
feat: introduced priority in event guest
Browse files Browse the repository at this point in the history
  • Loading branch information
navneethkrish committed Oct 23, 2024
1 parent 7f25921 commit cda4f01
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
16 changes: 16 additions & 0 deletions .forestadmin-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions apps/web-api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions apps/web-api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}`,
Expand Down
6 changes: 4 additions & 2 deletions apps/web-api/src/pl-events/pl-event-guests.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ export class PLEventGuestsService {
isFeatured: true,
team: {
select: {
name: true,
uid: true,
name: true
}
},
member: {
Expand All @@ -271,7 +272,8 @@ export class PLEventGuestsService {
}
}
}
}
},
orderBy: query.orderBy
});
return pLEventGuests;
} catch(err) {
Expand Down
8 changes: 5 additions & 3 deletions libs/contracts/src/schema/pl-event-guest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cda4f01

Please sign in to comment.