Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaric99 committed Dec 22, 2024
1 parent 7cdb364 commit 8983277
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/admin/src/pages/SpeakerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const SpeakerPage = () => {
<FileUpload
src={
speakers.data?.find((speaker) => speaker.id === speakerToEditId)
?.photo
?.photo?.mainPhotoUrl
}
handleUpload={handleUpload}
handleRemove={handleRemove}
Expand Down
9 changes: 8 additions & 1 deletion apps/api/db/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
}
4 changes: 3 additions & 1 deletion apps/api/db/schema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { SpeakerPhoto } from '@ddays-app/types';
import { relations } from 'drizzle-orm';
import {
boolean,
integer,
json,
jsonb,
pgEnum,
pgTable,
primaryKey,
Expand Down Expand Up @@ -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<SpeakerPhoto>(),
instagram: text('instagram'),
linkedin: text('linkedin'),
description: text('description'),
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
EventDto,
EventModifyDto,
EventWithSpeakerDto,
SpeakerPhoto,
} from '@ddays-app/types';
import { Injectable } from '@nestjs/common';
import { db } from 'db';
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion apps/api/src/speaker/speaker.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
SpeakerDto,
SpeakerModifyDto,
SpeakerPhoto,
SpeakerWithCompanyDto,
} from '@ddays-app/types';
import { Injectable } from '@nestjs/common';
Expand Down Expand Up @@ -115,12 +116,17 @@ export class SpeakerService {
id: number,
file: Express.Multer.File,
): Promise<SpeakerDto> {
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({
Expand Down
9 changes: 7 additions & 2 deletions packages/types/src/dto/speaker.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -46,7 +51,7 @@ export type SpeakerWithCompanyDto = {
lastName: string;
title: string;
companyId?: number;
photo?: unknown;
photo?: SpeakerPhoto;
instagram?: string;
linkedin?: string;
description?: string;
Expand Down

0 comments on commit 8983277

Please sign in to comment.