fix updateProvider

not possible to update provider so it can have both private person and
organisation at the same time
pull/33/head
leonnicolas 4 years ago
parent 6aae32e0c8
commit 1bbfb7d12c
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -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;

@ -52,7 +52,7 @@ export class Provider implements Lockable {
id: number;
@Column({
nullable: false
nullable: true
})
formName: String;

Loading…
Cancel
Save