Skip to content

Commit 65eb578

Browse files
authored
Allow null for Partner.pointOfContact to clear it (#2909)
1 parent f746ade commit 65eb578

File tree

4 files changed

+9
-35
lines changed

4 files changed

+9
-35
lines changed

src/components/partner/dto/partner.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class Partner extends Interfaces {
5555

5656
readonly organization: Secured<ID>;
5757

58-
readonly pointOfContact: Secured<ID>;
58+
readonly pointOfContact: Secured<ID | null>;
5959

6060
@Field()
6161
readonly types: SecuredPartnerTypes;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export abstract class UpdatePartner {
1515
readonly id: ID;
1616

1717
@IdField({ nullable: true })
18-
readonly pointOfContactId?: ID;
18+
readonly pointOfContactId?: ID | null;
1919

2020
@Field(() => [PartnerType], { nullable: true })
2121
@Transform(({ value }) => uniq(value))

src/components/partner/partner.repository.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -143,37 +143,6 @@ export class PartnerRepository extends DtoRepository<
143143
);
144144
}
145145

146-
async updatePointOfContact(id: ID, user: ID, session: Session) {
147-
const createdAt = DateTime.local();
148-
await this.db
149-
.query()
150-
.apply(matchRequestingUser(session))
151-
.matchNode('partner', 'Partner', { id })
152-
.matchNode('newPointOfContact', 'User', {
153-
id: user,
154-
})
155-
.optionalMatch([
156-
node('org'),
157-
relation('out', 'oldPointOfContactRel', 'pointOfContact', {
158-
active: true,
159-
}),
160-
node('pointOfContact', 'User'),
161-
])
162-
.setValues({
163-
'oldPointOfContactRel.active': false,
164-
})
165-
.with('*')
166-
.create([
167-
node('partner'),
168-
relation('out', '', 'pointOfContact', {
169-
active: true,
170-
createdAt,
171-
}),
172-
node('newPointOfContact'),
173-
])
174-
.run();
175-
}
176-
177146
async list({ filter, ...input }: PartnerListInput, session: Session) {
178147
const result = await this.db
179148
.query()

src/components/partner/partner.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,13 @@ export class PartnerService {
130130

131131
await this.repo.updateProperties(partner, simpleChanges);
132132

133-
if (pointOfContactId) {
134-
await this.repo.updatePointOfContact(input.id, pointOfContactId, session);
133+
if (pointOfContactId !== undefined) {
134+
await this.repo.updateRelation(
135+
'pointOfContact',
136+
'User',
137+
input.id,
138+
pointOfContactId,
139+
);
135140
}
136141

137142
if (languageOfWiderCommunicationId) {

0 commit comments

Comments
 (0)