From 140bcf50ca78abc3751754f5947649ae4470fad7 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 Jul 2024 15:54:29 +0300 Subject: [PATCH] bugfix: [#279] Include volunteerProfileId in organization-volunteer presenter (#295) --- .../presenters/organization-volunteer.presenter.ts | 7 +++++++ .../models/organization-volunteer.models.ts | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/src/api/_mobile/organization/presenters/organization-volunteer.presenter.ts b/backend/src/api/_mobile/organization/presenters/organization-volunteer.presenter.ts index 79bf60675..45fcaca35 100644 --- a/backend/src/api/_mobile/organization/presenters/organization-volunteer.presenter.ts +++ b/backend/src/api/_mobile/organization/presenters/organization-volunteer.presenter.ts @@ -8,6 +8,7 @@ export class OrganizationVolunteerPresenter { this.name = organization.name; this.logo = organization.logo; this.volunteerId = organization.volunteerId; + this.volunteerProfileId = organization.volunteerProfileId; } @Expose() @@ -35,4 +36,10 @@ export class OrganizationVolunteerPresenter { description: 'The volunteer id for this organization', }) volunteerId: string; + + @Expose() + @ApiProperty({ + description: 'The volunteer profile id for this organization', + }) + volunteerProfileId: string; } diff --git a/backend/src/modules/organization/models/organization-volunteer.models.ts b/backend/src/modules/organization/models/organization-volunteer.models.ts index f0316665f..b32e64868 100644 --- a/backend/src/modules/organization/models/organization-volunteer.models.ts +++ b/backend/src/modules/organization/models/organization-volunteer.models.ts @@ -3,6 +3,7 @@ import { IOrganizationModel } from './organization.model'; export interface IOrganizationVolunteerModel extends IOrganizationModel { volunteerId: string; + volunteerProfileId: string; } export class OrganizationVolunteerTransformer { @@ -11,6 +12,11 @@ export class OrganizationVolunteerTransformer { userId: string, ): IOrganizationVolunteerModel { if (!organizationEntity) return null; + + const volunteer = organizationEntity.volunteers.find( + (v) => v.userId === userId, + ); + return { id: organizationEntity.id, name: organizationEntity.name, @@ -20,9 +26,8 @@ export class OrganizationVolunteerTransformer { activityArea: organizationEntity.activityArea, logo: organizationEntity.logo, description: organizationEntity.description, - volunteerId: organizationEntity.volunteers.find( - (v) => v.userId === userId, - )?.id, + volunteerId: volunteer?.id, + volunteerProfileId: volunteer?.volunteerProfileId, }; } }