Skip to content

Commit aed8664

Browse files
authored
Merge pull request #2857 from SeedCompany/0509-add-partner-profile-basic-fields
2 parents 65eb578 + bb3d071 commit aed8664

9 files changed

+93
-1
lines changed

src/components/organization/dto/create-organization.dto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql';
22
import { Type } from 'class-transformer';
33
import { ValidateNested } from 'class-validator';
44
import { NameField } from '../../../common';
5+
import { OrganizationReach } from './organization-reach.dto';
6+
import { OrganizationType } from './organization-type.dto';
57
import { Organization } from './organization.dto';
68

79
@InputType()
@@ -14,6 +16,12 @@ export abstract class CreateOrganization {
1416

1517
@Field({ nullable: true })
1618
readonly address?: string;
19+
20+
@Field(() => [OrganizationType], { nullable: true })
21+
readonly types?: readonly OrganizationType[];
22+
23+
@Field(() => [OrganizationReach], { nullable: true })
24+
readonly reach?: readonly OrganizationReach[];
1725
}
1826

1927
@InputType()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ObjectType } from '@nestjs/graphql';
2+
import { EnumType, makeEnum, SecuredEnumList } from '~/common';
3+
4+
/**
5+
* The reach of the organization.
6+
*/
7+
export type OrganizationReach = EnumType<typeof OrganizationReach>;
8+
export const OrganizationReach = makeEnum({
9+
name: 'OrganizationReach',
10+
description: 'The reach of the organization',
11+
values: ['Local', 'Regional', 'National', 'Global'],
12+
});
13+
14+
@ObjectType({
15+
description: SecuredEnumList.descriptionFor('organization reach'),
16+
})
17+
export class SecuredOrganizationReach extends SecuredEnumList(
18+
OrganizationReach,
19+
) {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ObjectType } from '@nestjs/graphql';
2+
import { EnumType, makeEnum, SecuredEnumList } from '~/common';
3+
4+
/**
5+
* The type of organization.
6+
*/
7+
export type OrganizationType = EnumType<typeof OrganizationType>;
8+
export const OrganizationType = makeEnum({
9+
name: 'OrganizationType',
10+
description: 'The type of organization',
11+
values: [
12+
'Church',
13+
'Parachurch',
14+
'Mission',
15+
'TranslationOrganization',
16+
'Alliance',
17+
],
18+
});
19+
20+
@ObjectType({
21+
description: SecuredEnumList.descriptionFor('organization types'),
22+
})
23+
export class SecuredOrganizationTypes extends SecuredEnumList(
24+
OrganizationType,
25+
) {}

src/components/organization/dto/organization.dto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
SensitivityField,
1515
} from '../../../common';
1616
import { Location } from '../../location/dto';
17+
import { SecuredOrganizationReach } from './organization-reach.dto';
18+
import { SecuredOrganizationTypes } from './organization-type.dto';
1719

1820
@RegisterResource()
1921
@ObjectType({
@@ -41,6 +43,12 @@ export class Organization extends Resource {
4143
"Based on the projects' lowest sensitivity, and defaults to 'High' if no project is connected",
4244
})
4345
readonly sensitivity: Sensitivity;
46+
47+
@Field()
48+
readonly types: SecuredOrganizationTypes;
49+
50+
@Field()
51+
readonly reach: SecuredOrganizationReach;
4452
}
4553

4654
@ObjectType({

src/components/organization/dto/update-organization.dto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql';
22
import { Type } from 'class-transformer';
33
import { ValidateNested } from 'class-validator';
44
import { ID, IdField, NameField } from '../../../common';
5+
import { OrganizationReach } from './organization-reach.dto';
6+
import { OrganizationType } from './organization-type.dto';
57
import { Organization } from './organization.dto';
68

79
@InputType()
@@ -17,6 +19,12 @@ export abstract class UpdateOrganization {
1719

1820
@Field({ nullable: true })
1921
readonly address?: string;
22+
23+
@Field(() => [OrganizationType], { nullable: true })
24+
readonly types?: readonly OrganizationType[];
25+
26+
@Field(() => [OrganizationReach], { nullable: true })
27+
readonly reach?: readonly OrganizationReach[];
2028
}
2129

2230
@InputType()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { BaseMigration, Migration } from '~/core';
2+
import { Organization } from '../dto';
3+
4+
@Migration('2023-08-04T00:00:00')
5+
export class AddOrganizationReachMigration extends BaseMigration {
6+
async up() {
7+
await this.addProperty(Organization, 'reach', []);
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { BaseMigration, Migration } from '~/core';
2+
import { Organization } from '../dto';
3+
4+
@Migration('2023-08-04T00:00:00')
5+
export class AddOrganizationTypeMigration extends BaseMigration {
6+
async up() {
7+
await this.addProperty(Organization, 'types', []);
8+
}
9+
}

src/components/organization/organization.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { forwardRef, Module } from '@nestjs/common';
22
import { AuthorizationModule } from '../authorization/authorization.module';
33
import { LocationModule } from '../location/location.module';
4+
import { AddOrganizationReachMigration } from './migrations/add-reach.migration';
5+
import { AddOrganizationTypeMigration } from './migrations/add-type.migration';
46
import { OrganizationLoader } from './organization.loader';
57
import { OrganizationRepository } from './organization.repository';
68
import { OrganizationResolver } from './organization.resolver';
@@ -13,6 +15,8 @@ import { OrganizationService } from './organization.service';
1315
OrganizationService,
1416
OrganizationRepository,
1517
OrganizationLoader,
18+
AddOrganizationReachMigration,
19+
AddOrganizationTypeMigration,
1620
],
1721
exports: [OrganizationService],
1822
})

src/components/organization/organization.repository.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ export class OrganizationRepository extends DtoRepository<
2626
async create(input: CreateOrganization, session: Session) {
2727
const initialProps = {
2828
name: input.name,
29-
address: input.address,
3029
acronym: input.acronym,
30+
address: input.address,
31+
types: input.types ?? [],
32+
reach: input.reach ?? [],
3133
canDelete: true,
3234
};
3335

0 commit comments

Comments
 (0)