diff --git a/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.html b/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.html
index 4ff9f25..2d28a28 100644
--- a/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.html
+++ b/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.html
@@ -18,11 +18,18 @@
{{collection.name}}
-
+
Created - {{createdAt}} | Updated - {{updatedAt}}
diff --git a/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.ts b/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.ts
index 3a97d5b..f882d7a 100644
--- a/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.ts
+++ b/frontend/src/app/features/collections/user-collection-info/userCollection-info-page/userCollection-info-page.component.ts
@@ -1,11 +1,12 @@
import { Component, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { UserCollectionService } from '../../../../core/services/userCollection.service';
import { UserCollection } from '../../../../shared/models/userCollection.model';
import { DatePipe } from '@angular/common';
import { CollectionEntry } from '../../../../shared/models/dtos/collection-entry.dto';
import { CollectionEditModalComponent } from '../collection-edit-modal/collection-edit-modal.component';
import { MatDialog } from '@angular/material/dialog';
+import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
@Component({
selector: 'app-userCollection-info-page',
@@ -21,8 +22,9 @@ export class UserCollectionInfoPageComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private userCollectionService: UserCollectionService,
+ private datePipe: DatePipe,
public dialog: MatDialog,
- private datePipe: DatePipe
+ private router: Router
) {}
ngOnInit(): void {
@@ -107,30 +109,60 @@ export class UserCollectionInfoPageComponent implements OnInit {
},
});
- console.log('Edit dialog opened');
dialogRef.afterClosed().subscribe((result) => {
if (result) {
if (result.formData == null) return;
- console.log('Edit dialog closed with:', result);
this.userCollectionService
.updateCollection(this.collection.id, result.formData)
.subscribe({
next: (userCollection) => {
if (userCollection) {
- // TODO show confirm notification
+ // TODO confirm notification
console.log(`User Collection updated: `, userCollection);
this.collection = userCollection;
}
},
error: (error) => {
console.error('Error updating userCollection:', error);
- // TODO show notification
+ // TODO error notification
+ },
+ });
+ }
+ });
+ }
+
+ changeOrder() {}
+ deleteCollection() {
+ if (!this.collection) return;
+
+ const dialogRef = this.dialog.open(ConfirmModalComponent, {
+ width: '400px',
+ data: {
+ title: 'Confirmation',
+ message:
+ 'Are you sure you want to delete this collection? This action cannot be undone and you will be unable to recover any data.',
+ type: 'danger',
+ },
+ });
+
+ dialogRef.afterClosed().subscribe((result) => {
+ if (result) {
+ if (result.confirmed != true) return;
+
+ this.userCollectionService
+ .deleteCollection(this.collection.id)
+ .subscribe({
+ next: () => {
+ // TODO confirm notification
+ this.router.navigate(['/collections']);
+ },
+ error: (error) => {
+ console.error('Error updating userCollection:', error);
+ // TODO error notification
},
});
- } else {
- console.log('Edit dialog was cancelled');
}
});
}