Skip to content

Commit

Permalink
Merge pull request #1038 from bcgov/bugfix/alcs-1163
Browse files Browse the repository at this point in the history
Bugfix/alcs 1163
  • Loading branch information
urmikgov authored Oct 6, 2023
2 parents 899d615 + 63cbf9d commit 118545c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ <h4 class="full-row" *ngIf="type.getRawValue() === OWNER_TYPE.ORGANIZATION">Orga
</div>
<div mat-dialog-actions class="actions">
<button mat-stroked-button (click)="onClose()">Cancel</button>
<button mat-flat-button color="primary" [disabled]="form.invalid" *ngIf="!isEdit" (click)="onCreate()">Add</button>
<button mat-flat-button color="primary" [disabled]="form.invalid" *ngIf="isEdit" (click)="onSave()">Save</button>
<button mat-flat-button color="primary" *ngIf="!isEdit" (click)="onCreate()">Add</button>
<button mat-flat-button color="primary" *ngIf="isEdit" (click)="onSave()">Save</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -98,46 +98,54 @@ export class OwnerDialogComponent {
}

async onCreate() {
if (!this.data.submissionUuid) {
console.error('ApplicationOwnerDialogComponent misconfigured, needs fileId for create');
return;
if (this.form.valid) {
if (!this.data.submissionUuid) {
console.error('ApplicationOwnerDialogComponent misconfigured, needs fileId for create');
return;
}

const documentUuid = await this.uploadPendingFile(this.pendingFile);
const createDto: ApplicationOwnerCreateDto & NoticeOfIntentOwnerCreateDto = {
organizationName: this.organizationName.getRawValue() || undefined,
firstName: this.firstName.getRawValue() || undefined,
lastName: this.lastName.getRawValue() || undefined,
corporateSummaryUuid: documentUuid?.uuid,
email: this.email.getRawValue()!,
phoneNumber: this.phoneNumber.getRawValue()!,
typeCode: this.type.getRawValue()!,
applicationSubmissionUuid: this.data.submissionUuid,
noticeOfIntentSubmissionUuid: this.data.submissionUuid,
};

const res = await this.data.ownerService.create(createDto);
this.dialogRef.close(res);
} else {
this.form.markAllAsTouched()
}

const documentUuid = await this.uploadPendingFile(this.pendingFile);
const createDto: ApplicationOwnerCreateDto & NoticeOfIntentOwnerCreateDto = {
organizationName: this.organizationName.getRawValue() || undefined,
firstName: this.firstName.getRawValue() || undefined,
lastName: this.lastName.getRawValue() || undefined,
corporateSummaryUuid: documentUuid?.uuid,
email: this.email.getRawValue()!,
phoneNumber: this.phoneNumber.getRawValue()!,
typeCode: this.type.getRawValue()!,
applicationSubmissionUuid: this.data.submissionUuid,
noticeOfIntentSubmissionUuid: this.data.submissionUuid,
};

const res = await this.data.ownerService.create(createDto);
this.dialogRef.close(res);
}

async onClose() {
this.dialogRef.close();
}

async onSave() {
const document = await this.uploadPendingFile(this.pendingFile);
const updateDto: ApplicationOwnerUpdateDto = {
organizationName: this.organizationName.getRawValue(),
firstName: this.firstName.getRawValue(),
lastName: this.lastName.getRawValue(),
corporateSummaryUuid: document?.uuid,
email: this.email.getRawValue()!,
phoneNumber: this.phoneNumber.getRawValue()!,
typeCode: this.type.getRawValue()!,
};
if (this.existingUuid) {
const res = await this.data.ownerService.update(this.existingUuid, updateDto);
this.dialogRef.close(res);
if (this.form.valid) {
const document = await this.uploadPendingFile(this.pendingFile);
const updateDto: ApplicationOwnerUpdateDto = {
organizationName: this.organizationName.getRawValue(),
firstName: this.firstName.getRawValue(),
lastName: this.lastName.getRawValue(),
corporateSummaryUuid: document?.uuid,
email: this.email.getRawValue()!,
phoneNumber: this.phoneNumber.getRawValue()!,
typeCode: this.type.getRawValue()!,
};
if (this.existingUuid) {
const res = await this.data.ownerService.update(this.existingUuid, updateDto);
this.dialogRef.close(res);
}
} else {
this.form.markAllAsTouched()
}
}

Expand Down

0 comments on commit 118545c

Please sign in to comment.