diff --git a/src/app/groups/groups-view/groups-view.component.html b/src/app/groups/groups-view/groups-view.component.html
index 755a68c78..a9e756ada 100644
--- a/src/app/groups/groups-view/groups-view.component.html
+++ b/src/app/groups/groups-view/groups-view.component.html
@@ -86,7 +86,7 @@
-
+
diff --git a/src/app/groups/groups-view/groups-view.component.ts b/src/app/groups/groups-view/groups-view.component.ts
index 0168d1c1b..1ae2d09e1 100644
--- a/src/app/groups/groups-view/groups-view.component.ts
+++ b/src/app/groups/groups-view/groups-view.component.ts
@@ -5,6 +5,7 @@ import { MatDialog } from '@angular/material';
/** Custom Dialogs */
import { UnassignStaffDialogComponent } from './custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
+import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/** Custom Services */
import { GroupsService } from '../groups.service';
@@ -52,6 +53,9 @@ export class GroupsViewComponent {
case 'Unassign Staff':
this.unassignStaff();
break;
+ case 'Delete':
+ this.deleteGroup();
+ break;
}
}
@@ -80,4 +84,20 @@ export class GroupsViewComponent {
});
}
+ /**
+ * Deletes the group
+ */
+ private deleteGroup() {
+ const deleteGroupDialogRef = this.dialog.open(DeleteDialogComponent, {
+ data: { deleteContext: `group with id: ${this.groupViewData.id}` }
+ });
+ deleteGroupDialogRef.afterClosed().subscribe((response: any) => {
+ if (response.delete) {
+ this.groupsService.deleteGroup(this.groupViewData.id).subscribe(() => {
+ this.router.navigate(['/groups'], { relativeTo: this.route });
+ });
+ }
+ });
+ }
+
}
diff --git a/src/app/groups/groups.service.ts b/src/app/groups/groups.service.ts
index e1ca115f8..19e984123 100644
--- a/src/app/groups/groups.service.ts
+++ b/src/app/groups/groups.service.ts
@@ -52,6 +52,14 @@ export class GroupsService {
return this.http.get('/groups', { params: httpParams } );
}
+ /**
+ * @param {string} groupId shares account Id
+ * @returns {Observable}
+ */
+ deleteGroup(groupId: string): Observable {
+ return this.http.delete(`/groups/${groupId}`);
+ }
+
/**
* @param groupId Group Id of group to get data for.
* @returns {Observable} Group data.