From 1bbfb7d12c42e3336ed248948e26f897f49dd83f Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Mon, 7 Dec 2020 12:10:07 +0100 Subject: [PATCH 1/2] fix updateProvider not possible to update provider so it can have both private person and organisation at the same time --- src/datasources/db/providerAPI.ts | 8 ++++++++ src/model/Provider.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/datasources/db/providerAPI.ts b/src/datasources/db/providerAPI.ts index dacece9..a72266c 100644 --- a/src/datasources/db/providerAPI.ts +++ b/src/datasources/db/providerAPI.ts @@ -145,6 +145,14 @@ export class ProviderAPI extends DataSource { } async updateProvider (provider: any, userId: number) { + // make sure that a provider cannot have both organisation and person at the same time + if (provider.privatePersonId && provider.organisationId) { return new UserInputError('Provider must have either privatePersonId or organisationId'); } + if (provider.privatePersonId) { + provider.organisationId = null; + } else if (provider.organisationId) { + provider.privatePersonId = null; + } + const keepLock = provider.keepLock; delete provider.keepLock; const cargoBikes = provider.cargoBikeIds; diff --git a/src/model/Provider.ts b/src/model/Provider.ts index c366be8..11e9b6e 100644 --- a/src/model/Provider.ts +++ b/src/model/Provider.ts @@ -52,7 +52,7 @@ export class Provider implements Lockable { id: number; @Column({ - nullable: false + nullable: true }) formName: String; From f4ae5839420dd3c993f729989abd87fc4a7b02e2 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Mon, 7 Dec 2020 12:16:17 +0100 Subject: [PATCH 2/2] set distributedActiveBikeParte to always false --- src/resolvers/participantResolvers.ts | 3 +++ src/schema/type-defs.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/src/resolvers/participantResolvers.ts b/src/resolvers/participantResolvers.ts index 456ee12..f79b572 100644 --- a/src/resolvers/participantResolvers.ts +++ b/src/resolvers/participantResolvers.ts @@ -88,6 +88,9 @@ export default { throw new PermissionError(); } }, + distributedActiveBikeParte: () => { + return false; + }, isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }), isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req }) }, diff --git a/src/schema/type-defs.ts b/src/schema/type-defs.ts index 768b457..535fb61 100644 --- a/src/schema/type-defs.ts +++ b/src/schema/type-defs.ts @@ -422,6 +422,7 @@ export default gql` This value is calculated form other values. It is true, if the person is not on the black list and not retired and is either Mentor dt. Pate or Partner Mentor dt. Partnerpate for at least one bike. + Note: this will always be false for the moment. """ distributedActiveBikeParte: Boolean! engagement: [Engagement]