Skip to content

Commit

Permalink
Update requestType.component.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jawanbdarni committed Dec 1, 2024
1 parent 887c0af commit 909aa1d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cloudapp/src/app/ILL/requestType/requestType.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CloudAppStoreService } from '@exlibris/exl-cloudapp-angular-lib';
})
export class RequestTypeComponent implements OnInit {
form: FormGroup;
selected: string = 'COPYO'; // Default value
selected: string = 'COPYO';

constructor(
private fb: FormBuilder,
Expand All @@ -25,22 +25,24 @@ export class RequestTypeComponent implements OnInit {

ngOnInit(): void {
this.storeService.get(SELECTED_REQUEST_TYPE).subscribe((value) => {
if (value === null || value === undefined) {
if (value === null || value === undefined || (value !== 'COPYO' && value !== 'LOANO')) {
this.selected = 'COPYO';
this.storeService.set(SELECTED_REQUEST_TYPE, this.selected).subscribe();
} else {
this.selected = value === 'LOANO' || value === 'COPYO' ? value : 'COPYO';
this.selected = value;
}

this.form.get('requestType')?.setValue(this.selected, { emitEvent: false });
});

this.form.get('requestType')?.valueChanges.subscribe((value) => {
this.selected = value;
this.storeService.set(SELECTED_REQUEST_TYPE, this.selected).subscribe();
if (value) {
this.selected = value;
this.storeService.set(SELECTED_REQUEST_TYPE, this.selected).subscribe();
}
});
}


goNext(): void {
this.router.navigate(['ILLBorrowingMain']);
}
Expand Down

0 comments on commit 909aa1d

Please sign in to comment.