diff --git a/lib/config/api_config.dart b/lib/config/api_config.dart index e8270fe5..997fb132 100644 --- a/lib/config/api_config.dart +++ b/lib/config/api_config.dart @@ -1,7 +1,5 @@ // api_config.dart // const String apiUrl = 'http://127.0.0.1:8090'; // const String apiUrl = 'https://pbdev.venbait.in/'; -const String apiUrl = 'https://pb.venbait.in/'; -// const String apiUrl = 'https://pocket.fcsc.gov.ae'; -// const String auth = 'kannan@sightspectrum.com'; -// const String authpw = '1DgZ_we3k5UuCZiF9wziwECQzQo1YNRQ'; +// const String apiUrl = 'https://pb.venbait.in/'; +const String apiUrl = 'https://pocket.fcsc.gov.ae/'; diff --git a/lib/config/sessionCheckScreen.dart b/lib/config/sessionCheckScreen.dart index 25eaa96c..558fb384 100644 --- a/lib/config/sessionCheckScreen.dart +++ b/lib/config/sessionCheckScreen.dart @@ -8,6 +8,7 @@ import 'package:uae_stat/config/theme/auth_provider.dart'; import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/domain/entities/session_entity.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -55,17 +56,17 @@ class _SessionCheckScreenState extends ConsumerState { // final String adminToken = adminAuth.token; final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); - print('adminToken: $adminToken'); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); + // print('adminToken: $adminToken'); // Fetch user details final userDetailsResponse = await pb.collection('users').getOne( userId!, headers: { - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, ); diff --git a/lib/config/theme/auth_provider.dart b/lib/config/theme/auth_provider.dart index a3ee4891..243236cb 100644 --- a/lib/config/theme/auth_provider.dart +++ b/lib/config/theme/auth_provider.dart @@ -1,4 +1,5 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; class AuthState { final String email; diff --git a/lib/config/theme/service.dart b/lib/config/theme/service.dart index a5675fd6..2a86e135 100644 --- a/lib/config/theme/service.dart +++ b/lib/config/theme/service.dart @@ -56,32 +56,32 @@ class ThemeBaseService { Future getUserTheme(String userId, WidgetRef ref) async { print('getUserTheme'); - final url = "${pb.baseUrl}/api/collections/users/records/$userId"; + final url = "${pb.baseUrl}api/collections/users/records/$userId"; // final adminAuth = await pb.admins.authWithPassword( // 'pb@venbainfotech.com', // 'pb@venbainfotech.com', // ); - final auth = ref.watch(authProvider); + // final auth = ref.watch(authProvider); - final adminAuth = await pb.admins.authWithPassword( - auth.email, - auth.password, - ); + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); // final adminAuth = await PocketBaseService.users.authWithPassword( // 'sangeethae9919@gmail.com', // 'Sang@123', // ); - final String adminToken = adminAuth.token; - print('adminToken: $adminToken'); + // final String adminToken = adminAuth.token; + // print('adminToken: $adminToken'); final response = await http.get( Uri.parse(url), headers: { 'Content-Type': 'application/json', - 'Authorization': 'Bearer $adminToken' + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}' }, ); @@ -104,7 +104,7 @@ class ThemeBaseService { String userId, String theme, WidgetRef ref) async { print('updateUserTheme'); // Authenticate admin d - final url = "${pb.baseUrl}/api/collections/users/records/$userId"; + final url = "${pb.baseUrl}api/collections/users/records/$userId"; // final adminAuth = await pb.admins.authWithPassword( // 'pb@venbainfotech.com', // 'pb@venbainfotech.com', @@ -112,18 +112,18 @@ class ThemeBaseService { final auth = ref.watch(authProvider); - final adminAuth = await pb.admins.authWithPassword( - auth.email, - auth.password, - ); - final String adminToken = adminAuth.token; - print('adminToken: $adminToken'); + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final String adminToken = adminAuth.token; + print('adminToken: ${PocketBaseService.authStore.token}'); final response = await http.patch( Uri.parse(url), headers: { 'Content-Type': 'application/json', - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, body: jsonEncode({ 'theme': theme, // light, dark, or system diff --git a/lib/presentation/Screens/auth_verification/registration.dart b/lib/presentation/Screens/auth_verification/registration.dart index 7456cf33..a2db0574 100644 --- a/lib/presentation/Screens/auth_verification/registration.dart +++ b/lib/presentation/Screens/auth_verification/registration.dart @@ -231,11 +231,9 @@ class _RegisterScreenState extends ConsumerState { isRegistering = true; // Disable the button }); try { - final adminAuth = await pb.admins - .authWithPassword('kannan@sightspectrum.com', '1DgZ_we3k5UuCZiF9wziwECQzQo1YNRQ'); - final adminToken = adminAuth.token; - print('adminTokenREgistration- ${adminToken}'); + // final adminToken = adminAuth.token; + // print('adminTokenREgistration- ${adminToken}'); var mailID = _emailController.text; var email = mailID.toLowerCase(); // Create user in PocketBase @@ -247,7 +245,7 @@ class _RegisterScreenState extends ConsumerState { 'status': 'Pending', 'role': 'user', }, headers: { - 'Authorization': adminToken + // 'Authorization': adminToken }); if (response.id != null) { userID = response.id; diff --git a/lib/presentation/Screens/charts/screens/chart_screen.dart b/lib/presentation/Screens/charts/screens/chart_screen.dart index 5c53c988..9451cb10 100644 --- a/lib/presentation/Screens/charts/screens/chart_screen.dart +++ b/lib/presentation/Screens/charts/screens/chart_screen.dart @@ -20,6 +20,7 @@ import 'package:uae_stat/config/toast_util.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/uae_numbers_asset_path.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/presentation/Screens/charts/services/api_service.dart'; import 'package:uae_stat/presentation/Screens/charts/widgets/chart_widget.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; @@ -157,15 +158,15 @@ class _ChartScreen1State extends ConsumerState { // final adminToken = adminAuth.token; final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final result = await _pb.collection('bookmark').getList( filter: "user_id = '${userID}' && dataset = '${widget.dataSets}'", headers: { - 'Authorization': adminToken, // Pass the admin token + 'Authorization': PocketBaseService.authStore.token, // Pass the admin token }, ); @@ -190,11 +191,11 @@ class _ChartScreen1State extends ConsumerState { final auth = ref.watch(authProvider); - final adminAuth = await pb.admins.authWithPassword( - auth.email, - auth.password, - ); - final adminToken = adminAuth.token; + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final adminToken = adminAuth.token; final response = await _pb.collection('bookmark').create(body: { 'user_id': userID, 'dataset': widget.dataSets, @@ -203,7 +204,7 @@ class _ChartScreen1State extends ConsumerState { 'title': widget.title, 'keyParam': widget.keyParam, }, headers: { - 'Authorization': adminToken + 'Authorization': PocketBaseService.authStore.token }); setState(() { @@ -250,12 +251,12 @@ class _ChartScreen1State extends ConsumerState { /// Remove bookmark from PocketBase Future removeBookmark() async { try { - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + // final adminToken = adminAuth.token; if (bookmarkId != null) { await _pb.collection('bookmark').delete(bookmarkId!, headers: { - 'Authorization': adminToken, + 'Authorization': PocketBaseService.authStore.token, }); setState(() { diff --git a/lib/presentation/Screens/charts/services/api_service.dart b/lib/presentation/Screens/charts/services/api_service.dart index c19fb933..f9a359e1 100644 --- a/lib/presentation/Screens/charts/services/api_service.dart +++ b/lib/presentation/Screens/charts/services/api_service.dart @@ -13,7 +13,7 @@ class ChartData { } class ApiService { - static const String baseUrl = '$apiUrl/api/getDataSet'; + static const String baseUrl = '${apiUrl}api/getDataSet'; Future> fetchChartData(String dataSets, locale, kpi, List> filterData, themeMode) async { diff --git a/lib/presentation/Screens/profilepage.dart b/lib/presentation/Screens/profilepage.dart index 930deba0..3fa6b5fc 100644 --- a/lib/presentation/Screens/profilepage.dart +++ b/lib/presentation/Screens/profilepage.dart @@ -22,6 +22,7 @@ import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/components/my_toggle.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; @@ -178,15 +179,15 @@ class _ProfileScreenState extends ConsumerState { // final adminToken = adminAuth.token; final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); - print('adminToken- ${adminToken}'); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); + // print('adminToken- ${adminToken}'); final userDetailsResponse = await _pb.collection('users').getOne( widget.userId, headers: { - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, ); print('userDetails: $userDetailsResponse'); @@ -375,7 +376,7 @@ class _ProfileScreenState extends ConsumerState { // Create a multipart request final uri = - Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID'); + Uri.parse('${_pb.baseUrl}api/collections/users/records/$userID'); final request = http.MultipartRequest('PATCH', uri); // Add other fields diff --git a/lib/presentation/routes/auth_routes/login_route.dart b/lib/presentation/routes/auth_routes/login_route.dart index 495737cb..3c0463ef 100644 --- a/lib/presentation/routes/auth_routes/login_route.dart +++ b/lib/presentation/routes/auth_routes/login_route.dart @@ -74,15 +74,15 @@ class LoginRoute extends HookConsumerWidget { // ); final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); // Fetch user details final userDetailsResponse = await pb.collection('users').getOne( userId, headers: { - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, ); @@ -186,7 +186,7 @@ class LoginRoute extends HookConsumerWidget { Future updateDeviceToken( String userId, String token, WidgetRef ref) async { - final url = "${pb.baseUrl}/api/collections/users/records/$userId"; + final url = "${pb.baseUrl}api/collections/users/records/$userId"; try { // Authenticate admin (Persist session globally instead) @@ -203,16 +203,16 @@ class LoginRoute extends HookConsumerWidget { // ); final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final response = await http.patch( Uri.parse(url), headers: { 'Content-Type': 'application/json', // Add this - 'Authorization': pb.authStore.token, // Correct way to send auth token + 'Authorization': PocketBaseService.authStore.token, // Correct way to send auth token }, body: jsonEncode({ "device_token": token, @@ -497,10 +497,10 @@ class LoginRoute extends HookConsumerWidget { // ); final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final userDetails = metaDetails['rawUser']; print('oauthDetails $userDetails'); @@ -508,7 +508,7 @@ class LoginRoute extends HookConsumerWidget { Uri.parse(url), headers: { 'Content-Type': 'application/json', // Add this - 'Authorization': pb.authStore.token, // Correct way to send auth token + 'Authorization': PocketBaseService.authStore.token, // Correct way to send auth token }, body: jsonEncode({ "user_mail_verify": true, diff --git a/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart b/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart index 6f22eb90..b308a859 100644 --- a/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart +++ b/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart @@ -114,7 +114,7 @@ class _UaenumberWidgetState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart b/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart index 0a12fe7a..fcd7dfcb 100644 --- a/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart +++ b/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart @@ -1017,7 +1017,7 @@ class EconomyStatsState extends ConsumerState { // } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getHomePageData'; + const baseUrl = '${apiUrl}api/getHomePageData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart index af5ce7b4..3253008a 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart @@ -71,7 +71,7 @@ class _BookMarkState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), @@ -128,7 +128,7 @@ class _BookMarkState extends ConsumerState { } final response = await Dio().get( - '$apiUrl/api/getUserBookmark', + '${apiUrl}api/getUserBookmark', queryParameters: { 'user_id': userID, 'language': locale, @@ -264,18 +264,18 @@ class _BookMarkState extends ConsumerState { // final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); - print('adminTokenETRE1- '); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); + // print('adminTokenETRE1- '); // final adminToken = adminAuth.token; - print('adminTokenETRE- $adminToken'); + // print('adminTokenETRE- $adminToken'); await _pb.collection('bookmark').delete(bookmarkId!, headers: { - 'Authorization': adminToken, + 'Authorization': PocketBaseService.authStore.token, }); // currentTheme = ref.read(themeProvider); diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart b/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart index bc5a59e2..980a6f53 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart @@ -51,7 +51,7 @@ class _ContactState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse( diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart index 42a0e87e..bafc8322 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart @@ -23,6 +23,7 @@ import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; @@ -197,15 +198,15 @@ class _EditProfileState extends ConsumerState { // final adminToken = adminAuth.token; final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); - print('adminToken- $adminToken'); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); + // print('adminToken- $adminToken'); final userDetailsResponse = await _pb.collection('users').getOne( userId, headers: { - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, ); @@ -449,7 +450,7 @@ class _EditProfileState extends ConsumerState { } // Add headers (e.g., authorization) - request.headers['Authorization'] = 'Bearer ${_pb.authStore.token}'; + request.headers['Authorization'] = 'Bearer ${PocketBaseService.authStore.token}'; // Send the request final response = await request.send(); diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart b/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart index c4cc77d0..77d08c47 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart @@ -147,7 +147,7 @@ class _FeedbackFormState extends ConsumerState } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), @@ -1018,13 +1018,13 @@ class _FeedbackFormState extends ConsumerState // final adminToken = adminAuth.token; final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final response = await _pb .collection('feedback') - .create(body: feedbackData, headers: {'Authorization': adminToken}); + .create(body: feedbackData, headers: {'Authorization': PocketBaseService.authStore.token}); if (response != null) { final createdTime = response.created; // Send email diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart index 557114c0..f038f009 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart @@ -71,10 +71,10 @@ class _ManageUserRouterState extends ConsumerState { // ); final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final result = await _pb.collection('users').getFullList( filter: 'role="user"', ); diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart index 015433f3..36a7163c 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart @@ -13,6 +13,7 @@ import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import '../../custom_drawer_routes.dart'; import 'package:http/http.dart' as http; @@ -73,7 +74,7 @@ class _NotificationPageState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), @@ -145,15 +146,15 @@ class _NotificationPageState extends ConsumerState { // final adminToken = adminAuth.token; final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); - print('adminToken- ${adminToken}'); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); + // print('adminToken- ${adminToken}'); final userDetailsResponse = await _pb.collection('users').getOne( fetchedUserId!, headers: { - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, ); print('userDetails: $userDetailsResponse'); @@ -195,7 +196,7 @@ class _NotificationPageState extends ConsumerState { } Future fetchNotifications(locale) async { - final baseUrl = apiUrl + '/api/getNotification'; + final baseUrl = apiUrl + 'api/getNotification'; try { final response = await http.get(Uri.parse('$baseUrl?language=$locale'), headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); @@ -653,10 +654,10 @@ Future readedNotification( // ); final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final url = "${pb.baseUrl}api/removeNotification?user_id=$userId¬ification_id=$notificationId"; @@ -666,7 +667,7 @@ Future readedNotification( Uri.parse(url), headers: { 'Content-Type': 'application/json', // Add this - 'Authorization': pb.authStore.token, // Correct way to send auth token + 'Authorization': PocketBaseService.authStore.token, // Correct way to send auth token 'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A' }, ); diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart index 3f038463..2498c377 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart @@ -86,7 +86,7 @@ class _NotificationDetailsState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), @@ -112,7 +112,7 @@ class _NotificationDetailsState extends ConsumerState { Future fetchNotifications(locale) async { notificationID = widget.id; - final baseUrl = apiUrl + '/api/getNotification'; + final baseUrl = apiUrl + 'api/getNotification'; try { final response = await http.get( Uri.parse('$baseUrl?language=$locale&id=$notificationID'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart index 3c202ec5..5ff2d900 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart @@ -47,7 +47,7 @@ class _aboutFCSCState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart index 00b3709d..fc561787 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart @@ -47,7 +47,7 @@ class _GetStartedState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart index e612784d..79e74b21 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart @@ -50,7 +50,7 @@ class _AppFeaturesState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart index b71284fd..240c440e 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart @@ -48,7 +48,7 @@ class _ChangeMyPasswordState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart index 7cf909ae..fa3cdf5c 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart @@ -48,7 +48,7 @@ class _EditMyProfileState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart index a8ee29c1..c3acc61a 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart @@ -49,7 +49,7 @@ class _HowUseTheAppState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart index bf6f21be..7f3cf606 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart @@ -51,7 +51,7 @@ class _PurposeState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart index 74b6c07a..0ee908b1 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart @@ -51,7 +51,7 @@ class _StayUpdateState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart index 6171d413..e4ff9a43 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart @@ -50,7 +50,7 @@ class _WhoUseTheAppState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart index 17ea4825..cd4ac9be 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart @@ -50,7 +50,7 @@ class _aboutTheAppState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart index d6fcb6b8..93417caf 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart @@ -48,7 +48,7 @@ class _FAQPageState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart index c903106d..16c3fbd6 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart @@ -51,7 +51,7 @@ class _UsingFeaturesState extends ConsumerState { } Future fetchData(locale, themeMode) async { - const baseUrl = '$apiUrl/api/getUAENumbersData'; + const baseUrl = '${apiUrl}api/getUAENumbersData'; try { final response = await http.get( Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), diff --git a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart index 50a585a7..f2d04081 100644 --- a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart +++ b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart @@ -24,6 +24,7 @@ import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/bottom_bar_asset_icon_path.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/drawer_asset_icon_path.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; @@ -714,14 +715,14 @@ class _BaseScaffoldState extends ConsumerState { //print('adminToken- ${adminToken}'); final themeService = ThemeBaseService(); - final adminToken = await themeService.getAdminToken( - email: auth.email, - password: auth.password, - ); + // final adminToken = await themeService.getAdminToken( + // email: auth.email, + // password: auth.password, + // ); final userDetailsResponse = await _pb.collection('users').getOne( userId!, headers: { - 'Authorization': 'Bearer $adminToken', + 'Authorization': 'Bearer ${PocketBaseService.authStore.token}', }, ); print('NAVuserDetails: $userDetailsResponse'); @@ -762,7 +763,7 @@ class _BaseScaffoldState extends ConsumerState { } Future fetchNotifications(locale) async { - final baseUrl = apiUrl + '/api/getNotification'; + final baseUrl = apiUrl + 'api/getNotification'; try { final response = await http.get(Uri.parse('$baseUrl?language=$locale'), headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'});