feat(dialogs): polished success + error modals replace bare snackbar/dialog

Add reusable SuccessDialogComponent (green check, gradient hero, pop-in
animation) and redesign ErrorDialogComponent to match (red exclamation,
clear title, centered OK). Wire edit-user submit flow to the new dialogs:
success defers navigation until the user confirms, errors surface the
backend message in the styled modal instead of a grey snackbar.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aditya
2026-05-12 14:24:47 +05:30
co-authored by Claude Opus 4.7
parent 09fab88451
commit 1631cd3383
7 changed files with 261 additions and 28 deletions
+24 -17
View File
@@ -10,13 +10,15 @@
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { MatDialog } from '@angular/material/dialog';
/** Custom Services */
import { UsersService } from '../users.service';
import { MatCheckbox } from '@angular/material/checkbox';
import { MatIcon } from '@angular/material/icon';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { SuccessDialogComponent } from 'app/shared/success-dialog/success-dialog.component';
import { ErrorDialogComponent } from 'app/shared/error-dialog/error-dialog.component';
/**
* Edit User Component.
@@ -28,8 +30,7 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
imports: [
...STANDALONE_SHARED_IMPORTS,
MatCheckbox,
MatIcon,
MatSnackBarModule
MatIcon
]
})
export class EditUserComponent implements OnInit {
@@ -37,7 +38,7 @@ export class EditUserComponent implements OnInit {
private usersService = inject(UsersService);
private route = inject(ActivatedRoute);
private router = inject(Router);
private snackBar = inject(MatSnackBar);
private dialog = inject(MatDialog);
/** User Data */
userData: any;
@@ -144,23 +145,29 @@ export class EditUserComponent implements OnInit {
// Fineract sometimes omits resourceId in PUT responses — fall back to
// the user id we're editing so navigation never silently no-ops.
const targetId = response?.resourceId ?? this.userData.id;
this.snackBar.open('User updated successfully', 'OK', {
duration: 3000,
panelClass: ['success-snackbar']
const dialogRef = this.dialog.open(SuccessDialogComponent, {
data: {
title: 'User updated',
message: `Changes to ${this.userData.username} have been saved successfully.`,
buttonLabel: 'View user'
},
panelClass: 'sd-panel',
disableClose: true
});
dialogRef.afterClosed().subscribe(() => {
this.router.navigate(
[
'../../',
targetId
],
{ relativeTo: this.route }
);
});
this.router.navigate(
[
'../../',
targetId
],
{ relativeTo: this.route }
);
},
error: (err) => {
console.error('[EditUser] update failed', err);
this.snackBar.open('Failed to update user', 'Close', {
duration: 4000,
panelClass: ['error-snackbar']
this.dialog.open(ErrorDialogComponent, {
data: err?.error?.defaultUserMessage || err?.error?.message || 'Failed to update user.'
});
}
});