fix(ui): replace native confirm()/alert() with shared dialogs and toasts

New app-confirm-dialog (wraps existing app-dialog + app-button) replaces
every native confirm() across media library bulk-delete, static pages
editor (delete/bulk-delete), builder save-bar (publish/reset-draft),
project-editor-page (reset-section), homepage/languages/widgets sections
(remove block/language/widget), and cart (clear-cart).

Cart's native alert() calls (delivery/terms validation, email send
success/failure) now route through the existing UserNotificationService
toast pipeline instead.

No native confirm()/alert()/prompt() remain in production UI.
This commit is contained in:
sdarbinyan
2026-07-26 00:08:00 +04:00
parent a670ca994f
commit 6c6fa00ccf
23 changed files with 251 additions and 41 deletions

View File

@@ -293,4 +293,13 @@
<app-telegram-login />
<app-confirm-dialog
[open]="clearCartConfirmOpen()"
[titleText]="'cart.confirmClear' | translate"
[message]="'cart.confirmClear' | translate"
[destructive]="true"
(confirmed)="confirmClearCart()"
(cancelled)="clearCartConfirmOpen.set(false)"
/>

View File

@@ -19,6 +19,8 @@ import { EmptyStateComponent } from '../../shared/ui/empty-state/empty-state.com
import { ButtonComponent } from '../../shared/ui/button/button.component';
import { ConfigService } from '../../core/config/config.service';
import { TenantResolverService } from '../../core/config/tenant-resolver.service';
import { UserNotificationService } from '../../features/website/user-experience/services/user-notification.service';
import { ConfirmDialogComponent } from '../../shared/ui/confirm-dialog/confirm-dialog.component';
type PaymentMethod = 'qr' | 'card';
@@ -27,7 +29,7 @@ const MODAL_FOCUSABLE_SELECTOR =
@Component({
selector: 'app-cart',
imports: [DecimalPipe, RouterLink, FormsModule, DeliverySelectorComponent, TelegramLoginComponent, LangRoutePipe, TranslatePipe, IconComponent, EmptyStateComponent, ButtonComponent],
imports: [DecimalPipe, RouterLink, FormsModule, DeliverySelectorComponent, TelegramLoginComponent, LangRoutePipe, TranslatePipe, IconComponent, EmptyStateComponent, ButtonComponent, ConfirmDialogComponent],
templateUrl: './cart.component.html',
styleUrls: ['./cart.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
@@ -44,6 +46,7 @@ export class CartComponent implements OnDestroy {
private i18n = inject(TranslateService);
private authService = inject(AuthService);
private notifications = inject(UserNotificationService);
isAuthenticated = this.authService.isAuthenticated;
@@ -240,10 +243,15 @@ export class CartComponent implements OnDestroy {
document.addEventListener('touchend', cleanup);
}
readonly clearCartConfirmOpen = signal(false);
clearCart(): void {
if (confirm(this.i18n.t('cart.confirmClear'))) {
this.cartService.clearCart();
}
this.clearCartConfirmOpen.set(true);
}
confirmClearCart(): void {
this.cartService.clearCart();
this.clearCartConfirmOpen.set(false);
}
readonly getMainImage = getMainImage;
@@ -262,12 +270,12 @@ export class CartComponent implements OnDestroy {
checkout(paymentMethod: PaymentMethod): void {
if (!this.allRequiredDeliveriesSelected()) {
alert(this.i18n.t('cart.deliveryRequired'));
this.notifications.show(this.i18n.t('cart.deliveryRequired'), 'warning');
return;
}
if (!this.termsAccepted) {
alert(this.i18n.t('cart.acceptTerms'));
this.notifications.show(this.i18n.t('cart.acceptTerms'), 'warning');
return;
}
this.openPaymentPopup(paymentMethod);
@@ -615,8 +623,7 @@ export class CartComponent implements OnDestroy {
this.apiService.submitPurchaseEmail(emailData).subscribe({
next: () => {
this.emailSubmitting.set(false);
// Show success message
alert(this.i18n.t('cart.emailSuccess'));
this.notifications.show(this.i18n.t('cart.emailSuccess'), 'success');
// Close popup and redirect to home page
setTimeout(() => {
this.closePaymentPopup();
@@ -627,7 +634,7 @@ export class CartComponent implements OnDestroy {
error: (err) => {
console.error('Error submitting email:', err);
this.emailSubmitting.set(false);
alert(this.i18n.t('cart.emailError'));
this.notifications.show(this.i18n.t('cart.emailError'), 'warning');
}
});
}