Issue fixing + deletion of profile & logo
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { HttpEventType } from '@angular/common/http';
|
||||
import { ChangeDetectorRef, Component, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { faTrash } from '@fortawesome/free-solid-svg-icons';
|
||||
import { AngularCropperjsModule } from 'angular-cropperjs';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { ConfirmationService, MessageService } from 'primeng/api';
|
||||
import { ConfirmDialogModule } from 'primeng/confirmdialog';
|
||||
import { DialogModule } from 'primeng/dialog';
|
||||
import { DialogService, DynamicDialogModule, DynamicDialogRef } from 'primeng/dynamicdialog';
|
||||
import { EditorModule } from 'primeng/editor';
|
||||
@@ -24,8 +26,8 @@ import { TOOLBAR_OPTIONS } from '../../utils/defaults';
|
||||
@Component({
|
||||
selector: 'app-account',
|
||||
standalone: true,
|
||||
imports: [SharedModule, FileUploadModule, EditorModule, AngularCropperjsModule, DialogModule, SelectButtonModule, DynamicDialogModule],
|
||||
providers: [MessageService, DialogService],
|
||||
imports: [SharedModule, FileUploadModule, EditorModule, AngularCropperjsModule, DialogModule, SelectButtonModule, DynamicDialogModule, ConfirmDialogModule],
|
||||
providers: [MessageService, DialogService, ConfirmationService],
|
||||
templateUrl: './account.component.html',
|
||||
styleUrl: './account.component.scss',
|
||||
})
|
||||
@@ -44,6 +46,7 @@ export class AccountComponent {
|
||||
environment = environment;
|
||||
editorModules = TOOLBAR_OPTIONS;
|
||||
env = environment;
|
||||
faTrash = faTrash;
|
||||
constructor(
|
||||
public userService: UserService,
|
||||
private subscriptionService: SubscriptionsService,
|
||||
@@ -55,6 +58,8 @@ export class AccountComponent {
|
||||
private loadingService: LoadingService,
|
||||
private imageUploadService: ImageService,
|
||||
public dialogService: DialogService,
|
||||
private confirmationService: ConfirmationService,
|
||||
private imageService: ImageService,
|
||||
) {}
|
||||
async ngOnInit() {
|
||||
if (this.id) {
|
||||
@@ -157,4 +162,31 @@ export class AccountComponent {
|
||||
}
|
||||
});
|
||||
}
|
||||
deleteConfirm(type: 'profile' | 'logo') {
|
||||
this.confirmationService.confirm({
|
||||
target: event.target as EventTarget,
|
||||
message: `Do you want to delete your ${type === 'logo' ? 'Logo' : 'Profile'} image`,
|
||||
header: 'Delete Confirmation',
|
||||
icon: 'pi pi-info-circle',
|
||||
acceptButtonStyleClass: 'p-button-danger p-button-text',
|
||||
rejectButtonStyleClass: 'p-button-text p-button-text',
|
||||
acceptIcon: 'none',
|
||||
rejectIcon: 'none',
|
||||
|
||||
accept: async () => {
|
||||
if (type === 'profile') {
|
||||
this.user.hasProfile = false;
|
||||
await Promise.all([this.imageService.deleteProfileImagesById(this.user.id), this.userService.save(this.user)]);
|
||||
} else {
|
||||
this.user.hasCompanyLogo = false;
|
||||
await Promise.all([this.imageService.deleteLogoImagesById(this.user.id), this.userService.save(this.user)]);
|
||||
}
|
||||
this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'Image deleted' });
|
||||
this.user = await this.userService.getById(this.user.id);
|
||||
},
|
||||
reject: () => {
|
||||
console.log('deny');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user