diff --git a/apps/admin/src/pages/SpeakerPage.tsx b/apps/admin/src/pages/SpeakerPage.tsx index 71bf8c10..14eaa5a2 100644 --- a/apps/admin/src/pages/SpeakerPage.tsx +++ b/apps/admin/src/pages/SpeakerPage.tsx @@ -51,7 +51,7 @@ const SpeakerPage = () => { speaker.id === speakerToEditId) - ?.photo + ?.photo?.mainPhotoUrl } handleUpload={handleUpload} handleRemove={handleRemove} diff --git a/apps/api/db/migrations/meta/_journal.json b/apps/api/db/migrations/meta/_journal.json index 77e16193..a1d3dbe3 100644 --- a/apps/api/db/migrations/meta/_journal.json +++ b/apps/api/db/migrations/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1734719722899, "tag": "0000_cold_the_stranger", "breakpoints": true + }, + { + "idx": 1, + "version": "5", + "when": 1734903647949, + "tag": "0001_rich_veda", + "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/apps/api/db/schema.ts b/apps/api/db/schema.ts index 91defea0..e999e6ce 100644 --- a/apps/api/db/schema.ts +++ b/apps/api/db/schema.ts @@ -1,8 +1,10 @@ +import { SpeakerPhoto } from '@ddays-app/types'; import { relations } from 'drizzle-orm'; import { boolean, integer, json, + jsonb, pgEnum, pgTable, primaryKey, @@ -410,7 +412,7 @@ export const speaker = pgTable('speaker', { lastName: text('lastName').notNull(), title: text('title').notNull(), companyId: integer('company_id').references(() => company.id), - photo: json('photo'), + photo: jsonb('photo').$type(), instagram: text('instagram'), linkedin: text('linkedin'), description: text('description'), diff --git a/apps/api/src/event/event.service.ts b/apps/api/src/event/event.service.ts index 8fb4dd96..33e6c9c2 100644 --- a/apps/api/src/event/event.service.ts +++ b/apps/api/src/event/event.service.ts @@ -3,6 +3,7 @@ import { EventDto, EventModifyDto, EventWithSpeakerDto, + SpeakerPhoto, } from '@ddays-app/types'; import { Injectable } from '@nestjs/common'; import { db } from 'db'; @@ -102,7 +103,7 @@ export class EventService { lastName: speaker.lastName, title: speaker.title, companyId: speaker.companyId, - photo: speaker.photo, + photo: speaker.photo as SpeakerPhoto, instagram: speaker.instagram, linkedin: speaker.linkedin, description: speaker.description, diff --git a/apps/api/src/speaker/speaker.service.ts b/apps/api/src/speaker/speaker.service.ts index 45ef3a5a..8abd4d74 100644 --- a/apps/api/src/speaker/speaker.service.ts +++ b/apps/api/src/speaker/speaker.service.ts @@ -1,6 +1,7 @@ import { SpeakerDto, SpeakerModifyDto, + SpeakerPhoto, SpeakerWithCompanyDto, } from '@ddays-app/types'; import { Injectable } from '@nestjs/common'; @@ -115,12 +116,17 @@ export class SpeakerService { id: number, file: Express.Multer.File, ): Promise { - const photo = await this.blobService.upload( + const uploadedPhoto = await this.blobService.upload( 'speaker-photo', file.buffer, file.mimetype, ); + const photo: SpeakerPhoto = { + mainPhotoUrl: uploadedPhoto, + thumbnailUrl: uploadedPhoto, + }; + const [updatedSpeaker] = await db .update(speaker) .set({ diff --git a/packages/types/src/dto/speaker.ts b/packages/types/src/dto/speaker.ts index 279d6148..7b1ee8b5 100644 --- a/packages/types/src/dto/speaker.ts +++ b/packages/types/src/dto/speaker.ts @@ -1,13 +1,18 @@ import { IsNumber, IsOptional, IsString } from 'class-validator'; import { CompanyPublicDto } from './company'; +export type SpeakerPhoto = { + mainPhotoUrl: string; + thumbnailUrl: string; +}; + export type SpeakerDto = { id: number; firstName: string; lastName: string; title: string; companyId?: number; - photo?: unknown; + photo?: SpeakerPhoto; instagram?: string; linkedin?: string; description?: string; @@ -46,7 +51,7 @@ export type SpeakerWithCompanyDto = { lastName: string; title: string; companyId?: number; - photo?: unknown; + photo?: SpeakerPhoto; instagram?: string; linkedin?: string; description?: string;