diff --git a/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts b/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts index 8d7cfddfb..4ece64970 100644 --- a/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts +++ b/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts @@ -42,14 +42,16 @@ export class LibraryCreatorComponent implements OnInit { ngOnInit(): void { - this.mode = this.dynamicDialogConfig.data.mode; - if (this.mode === 'edit') { - this.library = this.libraryService.findLibraryById(this.dynamicDialogConfig.data.libraryId); + const data = this.dynamicDialogConfig?.data; + if (data?.mode === 'edit') { + this.mode = data.mode; + this.library = this.libraryService.findLibraryById(data.libraryId); if (this.library) { - this.chosenLibraryName = this.library.name; - this.editModeLibraryName = this.library.name; - this.selectedIcon = 'pi pi-' + this.library.icon; - this.folders = this.library.paths.map(path => path.path); + const { name, icon, paths } = this.library; + this.chosenLibraryName = name; + this.editModeLibraryName = name; + this.selectedIcon = `pi pi-${icon}`; + this.folders = paths.map(path => path.path); } } } diff --git a/booklore-ui/src/app/dashboard/components/main-dashboard/main-dashboard.component.ts b/booklore-ui/src/app/dashboard/components/main-dashboard/main-dashboard.component.ts index 613e3ca8c..06e335d30 100644 --- a/booklore-ui/src/app/dashboard/components/main-dashboard/main-dashboard.component.ts +++ b/booklore-ui/src/app/dashboard/components/main-dashboard/main-dashboard.component.ts @@ -25,6 +25,7 @@ export class MainDashboardComponent implements OnInit { ref: DynamicDialogRef | undefined; private bookService = inject(BookService); + private dialogService = inject(DialogService); ngOnInit(): void { this.bookService.loadBooks(); @@ -35,7 +36,7 @@ export class MainDashboardComponent implements OnInit { ); createNewLibrary() { - this.ref = inject(DialogService).open(LibraryCreatorComponent, { + this.ref = this.dialogService.open(LibraryCreatorComponent, { header: 'Create New Library', modal: true, closable: true,