Skip to content

Commit

Permalink
Add approvedPrograms to Partner object
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjnelson committed Dec 19, 2024
1 parent 4f17e7c commit 69c7c96
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions dbschema/partner.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module default {
address: str;
multi types: Partner::Type;
multi financialReportingTypes: Partnership::FinancialReportingType;
multi approvedPrograms: Project::Type;

pointOfContact: User;
languageOfWiderCommunication: Language;
Expand Down
5 changes: 5 additions & 0 deletions src/components/partner/dto/create-partner.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NameField,
} from '~/common';
import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type.enum';
import { ProjectType } from '../../project/dto';
import { PartnerType } from './partner-type.enum';
import { Partner } from './partner.dto';

Expand Down Expand Up @@ -64,6 +65,10 @@ export abstract class CreatePartner {

@DateField({ nullable: true })
readonly startDate?: CalendarDate;

@Field(() => [ProjectType], { nullable: true })
@Transform(({ value }) => uniq(value))
readonly approvedPrograms?: ProjectType[];
}

@InputType()
Expand Down
5 changes: 4 additions & 1 deletion src/components/partner/dto/partner.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Commentable } from '../../comments/dto';
import { SecuredFinancialReportingTypes } from '../../partnership/dto';
import { Pinnable } from '../../pin/dto';
import { Postable } from '../../post/dto';
import { IProject } from '../../project/dto';
import { IProject, SecuredProjectTypes } from '../../project/dto';
import { SecuredPartnerTypes } from './partner-type.enum';

const Interfaces = IntersectTypes(Resource, Pinnable, Postable, Commentable);
Expand Down Expand Up @@ -84,6 +84,9 @@ export class Partner extends Interfaces {
description: "Based on the project's sensitivity",
})
readonly sensitivity: Sensitivity;

@Field()
readonly approvedPrograms: SecuredProjectTypes;
}

@ObjectType({
Expand Down
5 changes: 5 additions & 0 deletions src/components/partner/dto/update-partner.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NameField,
} from '~/common';
import { FinancialReportingType } from '../../partnership/dto';
import { ProjectType } from '../../project/dto';
import { PartnerType } from './partner-type.enum';
import { Partner } from './partner.dto';

Expand Down Expand Up @@ -64,6 +65,10 @@ export abstract class UpdatePartner {

@DateField({ nullable: true })
readonly startDate?: CalendarDate | null;

@Field(() => [ProjectType], { nullable: true })
@Transform(({ value }) => uniq(value))
readonly approvedPrograms?: ProjectType[];
}

@InputType()
Expand Down
1 change: 1 addition & 0 deletions src/components/partner/partner.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class PartnerRepository extends DtoRepository<
address: input.address,
modifiedAt: DateTime.local(),
canDelete: true,
approvedPrograms: input.approvedPrograms,
};
const result = await this.db
.query()
Expand Down
10 changes: 9 additions & 1 deletion src/components/project/dto/project-type.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EnumType, makeEnum } from '~/common';
import { ObjectType } from '@nestjs/graphql';
import { EnumType, makeEnum, SecuredEnum, SecuredEnumList } from '~/common';

export type ProjectType = EnumType<typeof ProjectType>;
export const ProjectType = makeEnum({
Expand All @@ -10,3 +11,10 @@ export const ProjectType = makeEnum({
],
exposeOrder: true,
});

@ObjectType({
description: SecuredEnum.descriptionFor('project types'),
})
export abstract class SecuredProjectTypes extends SecuredEnumList(
ProjectType,
) {}

0 comments on commit 69c7c96

Please sign in to comment.