add confirm modal when removing an entry from collection
This commit is contained in:
1 parent
c51a389519
commit
e991329e71
1 file changed
+19
-1
+19
-1
@@ -5,6 +5,7 @@ import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-userCollection-grid-card',
|
||||
@@ -80,20 +81,37 @@ export class UserCollectionGridCardComponent {
|
||||
}
|
||||
|
||||
removeEntryFromList() {
|
||||
// TODO: add confirm modal
|
||||
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||
width: '400px',
|
||||
data: {
|
||||
title: 'Confirmation',
|
||||
message: `Are you sure you want to remove ${this.entry.title} from this collection?`,
|
||||
type: 'danger',
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.confirmed != true) return;
|
||||
|
||||
this.userCollectionService
|
||||
.removeEntryFromCollection(this.listId, this.entry.id)
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
// TODO confirm notification
|
||||
|
||||
console.log('Entry successfully removed from list.', response);
|
||||
this.entry.id = 0;
|
||||
this.entry.isInLibrary = false;
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO error notification
|
||||
console.error('Error removing entry from list:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ? EVENTS
|
||||
cardClick() {
|
||||
|
||||
Reference in new issue
Block a user