Skip to content

Commit 5038129

Browse files
committed
Use new enum features
1 parent 0b3e85a commit 5038129

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@seedcompany/cache": "^3.0.2",
5151
"@seedcompany/common": ">=0.19.1 <1",
5252
"@seedcompany/data-loader": "^2.0.1",
53-
"@seedcompany/nest": "^1.6.1",
53+
"@seedcompany/nest": "^1.8.0",
5454
"@seedcompany/nestjs-email": "^4.1.1",
5555
"@seedcompany/scripture": ">=0.8.0",
5656
"argon2": "^0.43.0",

src/components/engagement/internship-position.resolver.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ export class InternshipPositionResolver {
4949
domain(
5050
@Parent() { value: position }: SecuredInternPosition,
5151
): InternshipDomain | null {
52-
const domain = InternshipPosition.entries.find(
53-
(entry) => position === entry.value,
54-
)?.domain;
55-
return position && domain ? domain : null;
52+
if (!position) return null;
53+
const { domain } = InternshipPosition.entry(position);
54+
return domain ?? null;
5655
}
5756

5857
@ResolveField(() => InternshipProgram, {
@@ -63,9 +62,8 @@ export class InternshipPositionResolver {
6362
program(
6463
@Parent() { value: position }: SecuredInternPosition,
6564
): InternshipProgram | null {
66-
const program = InternshipPosition.entries.find(
67-
(entry) => position === entry.value,
68-
)?.program;
69-
return position && program ? program : null;
65+
if (!position) return null;
66+
const { program } = InternshipPosition.entry(position);
67+
return program ?? null;
7068
}
7169
}

src/components/project/handlers/set-department-id.handler.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {
2020
} from '~/core/database/query';
2121
import {
2222
type Project,
23-
ProjectStatus,
24-
ProjectStep,
2523
resolveProjectType,
24+
ProjectStatus as Status,
25+
ProjectStep as Step,
2626
stepToStatus,
2727
} from '../dto';
2828
import { ProjectTransitionedEvent } from '../workflow/events/project-transitioned.event';
@@ -47,14 +47,8 @@ export class SetDepartmentId implements IEventHandler<SubscribedEvent> {
4747

4848
const shouldSetDepartmentId =
4949
!event.project.departmentId &&
50-
ProjectStatus.entries.findIndex((s) => s.value === status) <=
51-
ProjectStatus.entries.findIndex(
52-
(s) => s.value === ProjectStatus.Active,
53-
) &&
54-
ProjectStep.entries.findIndex((s) => s.value === step) >=
55-
ProjectStep.entries.findIndex(
56-
(s) => s.value === ProjectStep.PendingFinanceConfirmation,
57-
);
50+
Status.indexOf(status) <= Status.indexOf('Active') &&
51+
Step.indexOf(step) >= Step.indexOf('PendingFinanceConfirmation');
5852
if (!shouldSetDepartmentId) {
5953
return;
6054
}

src/components/workflow/workflow.flowchart.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ export const WorkflowFlowchart = <W extends Workflow>(workflow: () => W) => {
5656
cmpBy((t) => {
5757
const endState =
5858
typeof t.to === 'string' ? t.to : t.to.relatedStates?.[0];
59-
return this.workflow.states.entries.findIndex(
60-
(e) => e.value === endState,
61-
);
59+
return this.workflow.states.indexOf(endState!);
6260
}),
6361
)
6462
.map((t) => {

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,16 +3084,16 @@ __metadata:
30843084
linkType: hard
30853085

30863086
"@seedcompany/common@npm:>0.3 <1, @seedcompany/common@npm:>=0.17 <1, @seedcompany/common@npm:>=0.17 <1.0.0, @seedcompany/common@npm:>=0.19.1 <1, @seedcompany/common@npm:>=0.3.0 <1.0.0":
3087-
version: 0.19.1
3088-
resolution: "@seedcompany/common@npm:0.19.1"
3087+
version: 0.19.2
3088+
resolution: "@seedcompany/common@npm:0.19.2"
30893089
dependencies:
30903090
type-fest: "npm:^4.37.0"
30913091
peerDependencies:
30923092
luxon: ^3.3.0
30933093
peerDependenciesMeta:
30943094
luxon:
30953095
optional: true
3096-
checksum: 10c0/d34e8591273ee4be08201b7a43c66240677027b155902e2558c8ed6d80274306d785b3675d3ecd68b6da2aa8adc831c23c71f62caa947e267573844abc3f92d8
3096+
checksum: 10c0/a66e92ba97d3912b7bf77d7f131d3ae1c07d167d19eff8553e60985663faa7ac46fa681e4b4f73587e04277e63ab96239b95789ed4e5a35452f3d7afdb1d6bf1
30973097
languageName: node
30983098
linkType: hard
30993099

@@ -3148,9 +3148,9 @@ __metadata:
31483148
languageName: node
31493149
linkType: hard
31503150

3151-
"@seedcompany/nest@npm:^1.6.1":
3152-
version: 1.6.1
3153-
resolution: "@seedcompany/nest@npm:1.6.1"
3151+
"@seedcompany/nest@npm:^1.8.0":
3152+
version: 1.8.0
3153+
resolution: "@seedcompany/nest@npm:1.8.0"
31543154
dependencies:
31553155
"@nestjs/common": "npm:^10 || ^11"
31563156
"@nestjs/core": "npm:^10 || ^11"
@@ -3167,7 +3167,7 @@ __metadata:
31673167
"@nestjs/graphql": ^12 || ^13
31683168
class-transformer: ^0.5.1
31693169
reflect-metadata: ^0.1.12 || ^0.2.0
3170-
checksum: 10c0/ea820ab6a0fb245f36a6bc50f9c80f675488d1c46e4151ec38eb6cc10574e3a10bc8844c410ee9169fb5aae1e4ed3a95779c20404ae341f0f0c41ae5a4f20cdf
3170+
checksum: 10c0/89869ca09f16602d920bc1c2303e479116d87f04da61034042ddcf1d6a5b456d7e824b393fb752693cf04a73f87bf707f371da14cdf5134b9075aacb9154b3b5
31713171
languageName: node
31723172
linkType: hard
31733173

@@ -5841,7 +5841,7 @@ __metadata:
58415841
"@seedcompany/common": "npm:>=0.19.1 <1"
58425842
"@seedcompany/data-loader": "npm:^2.0.1"
58435843
"@seedcompany/eslint-plugin": "npm:^3.4.1"
5844-
"@seedcompany/nest": "npm:^1.6.1"
5844+
"@seedcompany/nest": "npm:^1.8.0"
58455845
"@seedcompany/nestjs-email": "npm:^4.1.1"
58465846
"@seedcompany/scripture": "npm:>=0.8.0"
58475847
"@tsconfig/strictest": "npm:^2.0.2"

0 commit comments

Comments
 (0)