A better state and alerts
This commit is contained in:
@@ -8,6 +8,7 @@ import '../../providers/tickets_provider.dart';
|
||||
import '../../providers/user_offices_provider.dart';
|
||||
import '../../widgets/multi_select_picker.dart';
|
||||
import '../../widgets/responsive_body.dart';
|
||||
import '../../utils/snackbar.dart';
|
||||
|
||||
class ProfileScreen extends ConsumerStatefulWidget {
|
||||
const ProfileScreen({super.key});
|
||||
@@ -265,17 +266,13 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
fullName: _fullNameController.text.trim(),
|
||||
);
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('Profile updated.')));
|
||||
showSuccessSnackBar(context, 'Profile updated.');
|
||||
// Refresh providers so other UI picks up the change immediately
|
||||
ref.invalidate(currentProfileProvider);
|
||||
ref.invalidate(profilesProvider);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Update failed: $e')));
|
||||
showErrorSnackBar(context, 'Update failed: $e');
|
||||
} finally {
|
||||
if (mounted) setState(() => _savingDetails = false);
|
||||
}
|
||||
@@ -294,14 +291,10 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
_newPasswordController.clear();
|
||||
_confirmPasswordController.clear();
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('Password updated.')));
|
||||
showSuccessSnackBar(context, 'Password updated.');
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Password update failed: $e')));
|
||||
showErrorSnackBar(context, 'Password update failed: $e');
|
||||
} finally {
|
||||
if (mounted) setState(() => _changingPassword = false);
|
||||
}
|
||||
@@ -331,15 +324,11 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('Offices updated.')));
|
||||
showSuccessSnackBar(context, 'Offices updated.');
|
||||
ref.invalidate(userOfficesProvider);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Failed to save offices: $e')));
|
||||
showErrorSnackBar(context, 'Failed to save offices: $e');
|
||||
} finally {
|
||||
if (mounted) setState(() => _savingOffices = false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user