feat: client actions (delete) (#1073)

Fixes: #1072
This commit is contained in:
Karan Takalkar
2020-07-13 14:53:04 +05:30
committed by GitHub
parent 20c29569f8
commit 7bd79fb498
3 changed files with 25 additions and 8 deletions
@@ -45,6 +45,7 @@
<button mat-menu-item (click)="doAction('Close')">Close</button>
<button mat-menu-item (click)="doAction('Survey')"> Survey</button>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Reject')">Reject</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Delete')">Delete</button></span>
</mat-menu>
</mat-card-actions>
</mat-card-header>
@@ -6,6 +6,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 { ClientsService } from '../clients.service';
@@ -59,6 +60,8 @@ export class ClientsViewComponent implements OnInit {
case 'Unassign Staff':
this.unassignStaff();
break;
case 'Delete':
this.deleteClient();
}
}
@@ -74,7 +77,23 @@ export class ClientsViewComponent implements OnInit {
}
/**
* Unassign's the group's staff.
* Deletes the client
*/
private deleteClient() {
const deleteClientDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `client with id: ${this.clientViewData.id}` }
});
deleteClientDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.clientsService.deleteClient(this.clientViewData.id).subscribe(() => {
this.router.navigate(['/clients'], { relativeTo: this.route });
});
}
});
}
/**
* Unassign's the client's staff.
*/
private unassignStaff() {
const unAssignStaffDialogRef = this.dialog.open(UnassignStaffDialogComponent);
+4 -7
View File
@@ -45,6 +45,10 @@ export class ClientsService {
return this.http.get(`/clients/${clientId}`);
}
deleteClient(clientId: string) {
return this.http.delete(`/clients/${clientId}`);
}
getClientDataAndTemplate(clientId: string) {
const httpParams = new HttpParams()
.set('template', 'true')
@@ -86,18 +90,11 @@ export class ClientsService {
return this.http.get(`/clients/${clientId}/charges`, { params: httpParams });
}
/**
* @param chargeData Charge Data to be waived.
*/
waiveClientCharge(chargeData: any) {
const httpParams = new HttpParams().set('command', 'waive');
return this.http.post(`/clients/${chargeData.clientId}/charges/${chargeData.resourceType}`, chargeData, { params: httpParams });
}
/**
* Get All Client Cgarges.
* @param clientId Client Id of the user.
*/
getAllClientCharges(clientId: string) {
return this.http.get(`/clients/${clientId}/charges`);
}