From d01e028dc1966a7027937b4027c123d01f021ed6 Mon Sep 17 00:00:00 2001 From: amirrezaghabeli Date: Thu, 20 Nov 2025 17:33:30 +0330 Subject: [PATCH] Refactor profile data handling and update UI components - Changed references from companyProfileData to profileData across multiple profile page views for consistency. - Updated UI elements to display user-specific information such as username, email, role, department, and position. - Modified the profile screen to fetch user profile data instead of company profile data. - Added new string constants for user-related fields in ProfileStrings. --- .gitignore | 2 + lib/views/profile/pages/d_profile_page.dart | 38 +++++++------- lib/views/profile/pages/m_profile_page.dart | 28 +++++------ lib/views/profile/pages/profile_screen.dart | 5 +- lib/views/profile/pages/t_profile_page.dart | 50 +++++++++++++------ .../profile/strings/profile_strings.dart | 5 ++ 6 files changed, 76 insertions(+), 52 deletions(-) diff --git a/.gitignore b/.gitignore index 40703f4..a1bdb5c 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ app.*.map.json # FVM Version Cache .fvm/ +.fvmrc +.vscode/ # Firebase Configuration (sensitive files - should not be in version control) **/android/app/google-services.json diff --git a/lib/views/profile/pages/d_profile_page.dart b/lib/views/profile/pages/d_profile_page.dart index 379a350..d8a4f64 100644 --- a/lib/views/profile/pages/d_profile_page.dart +++ b/lib/views/profile/pages/d_profile_page.dart @@ -73,7 +73,7 @@ class _DesktopProfilePageState extends State { ); } - if (viewModel.companyProfileData == null) { + if (viewModel.profileData == null) { return const Expanded( child: Center(child: Text(CommonStrings.noData)), ); @@ -89,29 +89,27 @@ class _DesktopProfilePageState extends State { children: [ SizedBox(height: 36.0.h()), TitleDescription( - title: ProfileStrings.companyName, - description: viewModel.companyProfileData!.name!, - ), - TitleDescription( - title: ProfileStrings.nationalId, - description: viewModel.companyProfileData!.id!, - ), - TitleDescription( - title: ProfileStrings.registrationNumber, + title: ProfileStrings.username, description: - viewModel - .companyProfileData! - .registrationNumber!, - ), - const TitleDescription( - title: ProfileStrings.businessType, - description: '-', + viewModel.profileData!.username ?? '', ), TitleDescription( - title: ProfileStrings.founded, + title: ProfileStrings.email, + description: viewModel.profileData!.email ?? '', + ), + TitleDescription( + title: ProfileStrings.role, + description: viewModel.profileData!.role ?? '', + ), + TitleDescription( + title: ProfileStrings.department, description: - viewModel.companyProfileData!.foundedYear! - .toString(), + viewModel.profileData!.department ?? '', + ), + TitleDescription( + title: ProfileStrings.position, + description: + viewModel.profileData!.position ?? '', ), SizedBox(height: 24.0.h()), // Theme Toggle diff --git a/lib/views/profile/pages/m_profile_page.dart b/lib/views/profile/pages/m_profile_page.dart index cb81837..e789b5d 100644 --- a/lib/views/profile/pages/m_profile_page.dart +++ b/lib/views/profile/pages/m_profile_page.dart @@ -65,7 +65,7 @@ class _MobileProfilePageState extends State { return Center(child: Text(viewModel.errorMessage!)); } - if (viewModel.companyProfileData == null) { + if (viewModel.profileData == null) { return const Center(child: Text(CommonStrings.noData)); } @@ -92,26 +92,24 @@ class _MobileProfilePageState extends State { SizedBox(height: 24.0.h()), TitleDescription( - title: ProfileStrings.companyName, - description: viewModel.companyProfileData!.name!, + title: ProfileStrings.username, + description: viewModel.profileData!.username ?? '', ), TitleDescription( - title: ProfileStrings.nationalId, - description: viewModel.companyProfileData!.id!, + title: ProfileStrings.email, + description: viewModel.profileData!.email ?? '', ), TitleDescription( - title: ProfileStrings.registrationNumber, - description: - viewModel.companyProfileData!.registrationNumber!, - ), - const TitleDescription( - title: ProfileStrings.businessType, - description: '-', + title: ProfileStrings.role, + description: viewModel.profileData!.role ?? '', ), TitleDescription( - title: ProfileStrings.founded, - description: - viewModel.companyProfileData!.foundedYear!.toString(), + title: ProfileStrings.department, + description: viewModel.profileData!.department ?? '', + ), + TitleDescription( + title: ProfileStrings.position, + description: viewModel.profileData!.position ?? '', ), SizedBox(height: 32.0.h()), Align( diff --git a/lib/views/profile/pages/profile_screen.dart b/lib/views/profile/pages/profile_screen.dart index be042eb..2db6856 100644 --- a/lib/views/profile/pages/profile_screen.dart +++ b/lib/views/profile/pages/profile_screen.dart @@ -28,7 +28,8 @@ class _ProfileScreenState extends State { _tabService.addListener(_onTabChanged); WidgetsBinding.instance.addPostFrameCallback((_) { - _viewModel.getCompanyProfile(); + // _viewModel.getCompanyProfile(); + _viewModel.getProfile(); }); } @@ -41,7 +42,7 @@ class _ProfileScreenState extends State { void _onTabChanged() { // Tab index 2 is Profile if (_tabService.currentTabIndex == 2 && mounted) { - _viewModel.getCompanyProfile(); + _viewModel.getProfile(); } } diff --git a/lib/views/profile/pages/t_profile_page.dart b/lib/views/profile/pages/t_profile_page.dart index c6a21ec..75dedf5 100644 --- a/lib/views/profile/pages/t_profile_page.dart +++ b/lib/views/profile/pages/t_profile_page.dart @@ -62,7 +62,7 @@ class _TabletProfilePageState extends State { return Center(child: Text(viewModel.errorMessage!)); } - if (viewModel.companyProfileData == null) { + if (viewModel.profileData == null) { return const Center(child: Text(CommonStrings.noData)); } @@ -86,27 +86,47 @@ class _TabletProfilePageState extends State { children: [ SizedBox(height: 128.0.h()), TitleDescription( - title: ProfileStrings.companyName, - description: viewModel.companyProfileData!.name!, + title: ProfileStrings.username, + description: viewModel.profileData!.username ?? '', ), TitleDescription( - title: ProfileStrings.nationalId, - description: viewModel.companyProfileData!.id!, + title: ProfileStrings.email, + description: viewModel.profileData!.email ?? '', ), TitleDescription( - title: ProfileStrings.registrationNumber, - description: - viewModel.companyProfileData!.registrationNumber!, - ), - const TitleDescription( - title: ProfileStrings.businessType, - description: '-', + title: ProfileStrings.role, + description: viewModel.profileData!.role ?? '', ), TitleDescription( - title: ProfileStrings.founded, - description: - viewModel.companyProfileData!.foundedYear!.toString(), + title: ProfileStrings.department, + description: viewModel.profileData!.department ?? '', ), + TitleDescription( + title: ProfileStrings.position, + description: viewModel.profileData!.position ?? '', + ), + // TitleDescription( + // title: ProfileStrings.companyName, + // description: viewModel.companyProfileData!.name!, + // ), + // TitleDescription( + // title: ProfileStrings.nationalId, + // description: viewModel.companyProfileData!.id!, + // ), + // TitleDescription( + // title: ProfileStrings.registrationNumber, + // description: + // viewModel.companyProfileData!.registrationNumber!, + // ), + // const TitleDescription( + // title: ProfileStrings.businessType, + // description: '-', + // ), + // TitleDescription( + // title: ProfileStrings.founded, + // description: + // viewModel.companyProfileData!.foundedYear!.toString(), + // ), SizedBox(height: 24.0.h()), // Theme Toggle Align( diff --git a/lib/views/profile/strings/profile_strings.dart b/lib/views/profile/strings/profile_strings.dart index c447325..ea156e6 100644 --- a/lib/views/profile/strings/profile_strings.dart +++ b/lib/views/profile/strings/profile_strings.dart @@ -13,4 +13,9 @@ class ProfileStrings { static const String logout = 'Log out'; static const String contracts = 'Contracts'; static const String notifications = 'Notifications'; + static const String username = 'User Name'; + static const String email = 'email'; + static const String role = 'role'; + static const String department = 'department'; + static const String position = 'position'; }