diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c29f86c..88adec2 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,7 +5,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - cheminova + Territory Manager CFBundlePackageType APPL CFBundleShortVersionString diff --git a/lib/provider/attendance_provider.dart b/lib/provider/attendance_provider.dart index bea137b..fbca9b6 100644 --- a/lib/provider/attendance_provider.dart +++ b/lib/provider/attendance_provider.dart @@ -1,12 +1,9 @@ import 'package:cheminova/services/api_client.dart'; import 'package:cheminova/services/api_urls.dart'; -import 'package:cheminova/services/secure__storage_service.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; class AttendanceProvider extends ChangeNotifier { - final _storageService = SecureStorageService(); - final _apiClient = ApiClient(); bool _isLoading = false; @@ -34,6 +31,15 @@ class AttendanceProvider extends ChangeNotifier { } else { return (false, response.data['message'].toString()); } + } on DioException catch (e) { + setLoading(false); + if (e.response != null && e.response?.data != null) { + // Extracting the error message from the Dio response + return (false, e.response!.data['message'].toString()); + } else { + // When no response or response data is available + return (false, 'Something went wrong'); + } } catch (e) { setLoading(false); return (false, 'Something want wrong'); diff --git a/lib/provider/mark_leave_provider.dart b/lib/provider/mark_leave_provider.dart new file mode 100644 index 0000000..6eb3f70 --- /dev/null +++ b/lib/provider/mark_leave_provider.dart @@ -0,0 +1,91 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../services/api_client.dart'; +import '../services/api_urls.dart'; + +class MarkLeaveProvider extends ChangeNotifier { + final _apiClient = ApiClient(); + bool _isLoading = false; + + bool get isLoading => _isLoading; + + void setLoading(bool loading) { + _isLoading = loading; + notifyListeners(); + } + + final dateController = TextEditingController( + text: DateFormat('dd/MM/yyyy').format(DateTime.now())); + + final timeController = + TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); + + final locationController = TextEditingController(); + final notesController = TextEditingController(); + + String selectedLeaveType = 'Sick'; + + void onLeaveTypeSelected(String leaveType) { + selectedLeaveType = leaveType; + notifyListeners(); + } + + Widget buildLeaveTypeOption(String leaveType) { + bool isSelected = leaveType == selectedLeaveType; + return GestureDetector( + onTap: () => onLeaveTypeSelected(leaveType), + child: Container( + margin: const EdgeInsets.only(bottom: 10), + width: 120, + padding: const EdgeInsets.symmetric(vertical: 5.0), + decoration: BoxDecoration( + color: isSelected ? Colors.blue : Colors.white, + borderRadius: BorderRadius.circular(10.0), + ), + child: Center( + child: Text( + leaveType, + style: TextStyle( + color: isSelected ? Colors.white : Colors.black, + fontSize: 16.0, + ), + ), + ), + ), + ); + } + + Future<(bool, String)> markLeave(String date, String time, String location, + String reason, String leaveType) async { + setLoading(true); + try { + Response response = await _apiClient.post(ApiUrls.markLeaveUrl, data: { + "date": date, + "time": time, + "reason": reason, + "leaveType": '$leaveType Leave', + "location": location + }); + setLoading(false); + if (response.statusCode == 200) { + return (true, response.data['message'].toString()); + } else { + return (false, response.data['message'].toString()); + } + } on DioException catch (e) { + setLoading(false); + if (e.response != null && e.response?.data != null) { + // Extracting the error message from the Dio response + return (false, e.response!.data['message'].toString()); + } else { + // When no response or response data is available + return (false, 'Something went wrong'); + } + } catch (e) { + setLoading(false); + return (false, 'Something want wrong'); + } + } +} diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 05592fc..190dbe7 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -43,6 +43,7 @@ class UserProvider extends ChangeNotifier { Future clearUserProfile() async { _user = null; + await SecureStorageService().delete(key: 'user'); notifyListeners(); } } diff --git a/lib/screens/assign_task_screen.dart b/lib/screens/assign_task_screen.dart new file mode 100644 index 0000000..c43c1c3 --- /dev/null +++ b/lib/screens/assign_task_screen.dart @@ -0,0 +1,155 @@ +import 'package:cheminova/widgets/common_app_bar.dart'; +import 'package:cheminova/widgets/common_background.dart'; +import 'package:cheminova/widgets/common_drawer.dart'; +import 'package:cheminova/widgets/common_elevated_button.dart'; +import 'package:flutter/material.dart'; + +class AssignTaskScreen extends StatefulWidget { + const AssignTaskScreen({super.key}); + + @override + State createState() => _AssignTaskScreenState(); +} + +class _AssignTaskScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + extendBodyBehindAppBar: true, + appBar: CommonAppBar( + backgroundColor: Colors.transparent, + elevation: 0, + actions: [ + IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Image.asset('assets/Back_attendance.png'), + padding: const EdgeInsets.only(right: 20), + ), + ], + title: const Center( + child: Text( + 'Assign Tasks', + style: TextStyle(color: Colors.black87, fontSize: 20), + ), + ), + ), + drawer: const CommonDrawer(), + body: CommonBackground( + child: SafeArea( + child: Container( + padding: const EdgeInsets.all(20.0).copyWith(top: 15, bottom: 30), + margin: const EdgeInsets.symmetric(horizontal: 30.0) + .copyWith(bottom: 50), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + color: const Color(0xffB4D1E5).withOpacity(0.5), + borderRadius: BorderRadius.circular(26.0), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Assign Tasks', + style: TextStyle( + fontSize: 24, + color: Colors.white, + fontWeight: FontWeight.bold, + fontFamily: 'Anek', + ), + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + SizedBox( + height: 200, + width: MediaQuery.of(context).size.width / 4.2, + child: _customCard(title: "Total Tasks", subtitle: "100"), + ), + SizedBox( + height: 200, + width: MediaQuery.of(context).size.width / 4.2, + child: + _customCard(title: "Tasks Pending", subtitle: "100"), + ), + SizedBox( + height: 200, + width: MediaQuery.of(context).size.width / 4.2, + child: _customCard( + title: "Reports Submitted", subtitle: "100"), + ), + ], + ), + CommonElevatedButton( + backgroundColor: const Color(0xff004791), + borderRadius: 30, + width: double.infinity, + height: kToolbarHeight - 10, + text: 'ASSIGN TASKS', + onPressed: () {}, + ), + const SizedBox(height: 15), + CommonElevatedButton( + backgroundColor: const Color(0xff004791), + borderRadius: 30, + width: double.infinity, + height: kToolbarHeight - 10, + text: 'VIEW TASK STATUS', + onPressed: () {}, + ), + const SizedBox(height: 15), + CommonElevatedButton( + backgroundColor: const Color(0xff004791), + borderRadius: 30, + width: double.infinity, + height: kToolbarHeight - 10, + text: 'MANAGE SCs', + onPressed: () {}, + ), + ], + ), + ), + ), + ), + ); + } + + Widget _customCard({required String title, required String subtitle}) { + return Container( + padding: const EdgeInsets.all(8.0).copyWith(top: 15, bottom: 30), + margin: const EdgeInsets.all(4).copyWith(bottom: 30), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + color: const Color(0xffB4D1E5).withOpacity(0.6), + borderRadius: BorderRadius.circular(16.0), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 14, + color: Colors.white, + fontWeight: FontWeight.bold, + fontFamily: 'Anek', + ), + ), + const SizedBox(height: 10), + Text( + subtitle, + style: const TextStyle( + fontSize: 34, + color: Colors.white, + fontWeight: FontWeight.bold, + fontFamily: 'Anek', + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index fc2d474..c36159d 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -1,4 +1,5 @@ import 'package:cheminova/provider/user_provider.dart'; +import 'package:cheminova/screens/assign_task_screen.dart'; import 'package:cheminova/screens/calendar_screen.dart'; import 'package:cheminova/screens/collect_kyc_screen.dart'; import 'package:cheminova/screens/mark_attendence_screen.dart'; @@ -8,7 +9,6 @@ import 'package:cheminova/screens/summary_screen.dart'; import 'package:cheminova/screens/product_sales_data.dart'; import 'package:cheminova/screens/update_inventory_screen.dart'; import 'package:cheminova/screens/display_sales_screen.dart'; -import 'package:cheminova/widgets/common_app_bar.dart'; import 'package:cheminova/widgets/common_drawer.dart'; import 'package:flutter/material.dart'; import 'package:cheminova/widgets/common_background.dart'; @@ -43,7 +43,7 @@ class _HomePageState extends State { // backgroundImage: AssetImage( // 'assets/profile.png'), // Replace with actual user image // ), - const SizedBox(width: 10), + // const SizedBox(width: 10), Consumer( builder: (context, userProvider, child) { return Column( @@ -107,7 +107,13 @@ class _HomePageState extends State { const SizedBox( height: 5, ), - _buildCustomCard('Assign Tasks', '', onTap: () {}), + _buildCustomCard('Assign Tasks', '', onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const AssignTaskScreen(), + )); + }), const SizedBox( height: 5, ), diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index b9d627a..3285b37 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -1,7 +1,6 @@ import 'package:cheminova/provider/login_provider.dart'; import 'package:cheminova/screens/forgot_password_screen.dart'; import 'package:cheminova/screens/home_screen.dart'; -import 'package:cheminova/screens/verify_phone_screen.dart'; import 'package:cheminova/widgets/common_background.dart'; import 'package:cheminova/widgets/common_elevated_button.dart'; import 'package:cheminova/widgets/common_text_form_field.dart'; diff --git a/lib/screens/mark_attendence_screen.dart b/lib/screens/mark_attendence_screen.dart index 6430b0d..a1893f0 100644 --- a/lib/screens/mark_attendence_screen.dart +++ b/lib/screens/mark_attendence_screen.dart @@ -11,6 +11,7 @@ import 'package:geocoding/geocoding.dart'; import 'package:geolocator/geolocator.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; + class MarkAttendanceScreen extends StatefulWidget { const MarkAttendanceScreen({super.key}); @@ -21,7 +22,7 @@ class MarkAttendanceScreen extends StatefulWidget { class _MarkAttendanceScreenState extends State { late AttendanceProvider attendanceProvider; final dateController = TextEditingController( - text: DateFormat('dd/MM/yyyy').format(DateTime.now())); + text: DateFormat('yyyy/MM/dd').format(DateTime.now())); final timeController = TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); @@ -32,7 +33,7 @@ class _MarkAttendanceScreenState extends State { @override void initState() { super.initState(); - attendanceProvider=AttendanceProvider(); + attendanceProvider = AttendanceProvider(); _getCurrentLocation(); } @@ -65,7 +66,7 @@ class _MarkAttendanceScreenState extends State { Placemark place = placeMarks[0]; setState(() { - locationController.text = place.locality??''; + locationController.text = place.locality ?? ''; }); } @@ -74,7 +75,8 @@ class _MarkAttendanceScreenState extends State { return ChangeNotifierProvider( create: (_) => attendanceProvider, builder: (context, child) => CommonBackground( - child: Scaffold(backgroundColor: Colors.transparent, + child: Scaffold( + backgroundColor: Colors.transparent, appBar: CommonAppBar( actions: [ IconButton( @@ -90,7 +92,9 @@ class _MarkAttendanceScreenState extends State { fontSize: 28, color: Colors.black, fontWeight: FontWeight.w400, - fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0, + fontFamily: 'Anek')), + backgroundColor: Colors.transparent, + elevation: 0, ), drawer: const CommonDrawer(), body: Stack( @@ -105,8 +109,8 @@ class _MarkAttendanceScreenState extends State { children: [ const SizedBox(height: 16), Container( - padding: - const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30), + padding: const EdgeInsets.all(20.0) + .copyWith(top: 30, bottom: 30), margin: const EdgeInsets.symmetric(horizontal: 20.0), decoration: BoxDecoration( border: Border.all(color: Colors.white), @@ -149,7 +153,8 @@ class _MarkAttendanceScreenState extends State { AttendanceProvider value, Widget? child) => CommonElevatedButton( - backgroundColor: const Color(0xff004791), + backgroundColor: + const Color(0xff004791), borderRadius: 30, width: double.infinity, height: kToolbarHeight - 10, @@ -157,16 +162,22 @@ class _MarkAttendanceScreenState extends State { onPressed: () { value .markAttendance( - dateController.text.trim(), - timeController.text.trim(), - locationController.text.trim(), - notesController.text.trim()) + dateController.text + .trim(), + timeController.text + .trim(), + locationController.text + .trim(), + notesController.text + .trim()) .then( (result) { - var (status, message) = result; + var (status, message) = + result; ScaffoldMessenger.of(context) .showSnackBar(SnackBar( - content: Text(message))); + content: + Text(message))); if (status) { Navigator.pushReplacement( context, @@ -210,17 +221,18 @@ class _MarkAttendanceScreenState extends State { left: 0, right: 0, bottom: 0, - child: Consumer(builder: (context, value, child) { - if(value.isLoading){ - return - Container( + child: Consumer( + builder: (context, value, child) { + if (value.isLoading) { + return Container( color: Colors.black12, - child: const Center(child: CircularProgressIndicator())); - } - else{ - return const SizedBox(); - } - }, ), + child: + const Center(child: CircularProgressIndicator())); + } else { + return const SizedBox(); + } + }, + ), ) ], ), diff --git a/lib/screens/on_leave_screen.dart b/lib/screens/on_leave_screen.dart index 49b1820..8c97ca4 100644 --- a/lib/screens/on_leave_screen.dart +++ b/lib/screens/on_leave_screen.dart @@ -1,3 +1,4 @@ +import 'package:cheminova/provider/mark_leave_provider.dart'; import 'package:cheminova/screens/Attendance_success.dart'; import 'package:cheminova/widgets/common_drawer.dart'; import 'package:flutter/material.dart'; @@ -5,6 +6,7 @@ import 'package:cheminova/widgets/common_background.dart'; import 'package:geocoding/geocoding.dart'; import 'package:geolocator/geolocator.dart'; import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; import '../widgets/common_app_bar.dart'; import '../widgets/common_elevated_button.dart'; import '../widgets/common_text_form_field.dart'; @@ -17,11 +19,13 @@ class OnLeaveScreen extends StatefulWidget { } class _OnLeaveScreenState extends State { + late MarkLeaveProvider _markLeaveProvider; + final dateController = TextEditingController( - text: DateFormat('dd/MM/yyyy').format(DateTime.now())); + text: DateFormat('yyyy/MM/dd').format(DateTime.now())); final timeController = - TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); + TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); final locationController = TextEditingController(); final notesController = TextEditingController(); @@ -39,7 +43,8 @@ class _OnLeaveScreenState extends State { return GestureDetector( onTap: () => onLeaveTypeSelected(leaveType), - child: Container(margin: EdgeInsets.only(bottom: 10), + child: Container( + margin: const EdgeInsets.only(bottom: 10), width: 120, padding: const EdgeInsets.symmetric(vertical: 5.0), decoration: BoxDecoration( @@ -58,9 +63,11 @@ class _OnLeaveScreenState extends State { ), ); } + @override void initState() { super.initState(); + _markLeaveProvider = MarkLeaveProvider(); _getCurrentLocation(); } @@ -87,8 +94,8 @@ class _OnLeaveScreenState extends State { debugPrint('position--- $position'); List placeMarks = - await placemarkFromCoordinates(position.latitude, position.longitude) - .timeout(const Duration(seconds: 10)); + await placemarkFromCoordinates(position.latitude, position.longitude) + .timeout(const Duration(seconds: 10)); debugPrint('place mark--- $placeMarks'); Placemark place = placeMarks[0]; @@ -99,103 +106,140 @@ class _OnLeaveScreenState extends State { @override Widget build(BuildContext context) { - return CommonBackground( - child: Scaffold(backgroundColor: Colors.transparent, - appBar: CommonAppBar( - actions: [ - IconButton( - onPressed: () - { - Navigator.pop(context); - }, - icon: Image.asset('assets/Back_attendance.png'), padding: const EdgeInsets.only(right: 20), - ), - ], - title: const Text('On Leave', - style: TextStyle( - fontSize: 28, - color: Colors.black, - fontWeight: FontWeight.w400, - fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0, - ), - drawer: const CommonDrawer(), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: SingleChildScrollView( - physics: const BouncingScrollPhysics(), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(height: 16), - Container( - padding: - const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30), - margin: const EdgeInsets.symmetric(horizontal: 30.0), - decoration: BoxDecoration( - border: Border.all(color: Colors.white), - color: const Color(0xffB4D1E5).withOpacity(0.9), - borderRadius: BorderRadius.circular(26.0)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CommonTextFormField( - title: 'Date', - readOnly: true, - fillColor: Colors.white, - controller: dateController), - const SizedBox(height: 15), - CommonTextFormField( - title: 'Time', - readOnly: true, - fillColor: Colors.white, - controller: timeController), - const SizedBox(height: 15), - const Text('Leave type', - style: TextStyle( - fontSize: 15, - color: Colors.black, - fontWeight: FontWeight.w400, - fontFamily: 'Anek')), - const SizedBox(height:3 ), - Wrap(direction: Axis.horizontal, - children: [ - buildLeaveTypeOption('Sick'), - const SizedBox(width: 10), - buildLeaveTypeOption('Personal'), - const SizedBox(width: 10), - buildLeaveTypeOption('Privilege '), + return ChangeNotifierProvider( + create: (_) => _markLeaveProvider, + builder: (context, child) => CommonBackground( + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: CommonAppBar( + actions: [ + IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Image.asset('assets/Back_attendance.png'), + padding: const EdgeInsets.only(right: 20), + ), + ], + title: const Text('On Leave', + style: TextStyle( + fontSize: 28, + color: Colors.black, + fontWeight: FontWeight.w400, + fontFamily: 'Anek')), + backgroundColor: Colors.transparent, + elevation: 0, + ), + drawer: const CommonDrawer(), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 16), + Container( + padding: const EdgeInsets.all(20.0) + .copyWith(top: 30, bottom: 30), + margin: const EdgeInsets.symmetric(horizontal: 30.0), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + color: const Color(0xffB4D1E5).withOpacity(0.9), + borderRadius: BorderRadius.circular(26.0)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CommonTextFormField( + title: 'Date', + readOnly: true, + fillColor: Colors.white, + controller: dateController), + const SizedBox(height: 15), + CommonTextFormField( + title: 'Time', + readOnly: true, + fillColor: Colors.white, + controller: timeController), + const SizedBox(height: 15), + const Text('Leave type', + style: TextStyle( + fontSize: 15, + color: Colors.black, + fontWeight: FontWeight.w400, + fontFamily: 'Anek')), + const SizedBox(height: 3), + Wrap( + direction: Axis.horizontal, + children: [ + buildLeaveTypeOption('Sick'), + const SizedBox(width: 10), + buildLeaveTypeOption('Personal'), + const SizedBox(width: 10), + buildLeaveTypeOption('Privilege '), + ], + ), + const SizedBox(height: 15), + CommonTextFormField( + height: 100, + title: 'Reason', + fillColor: Colors.white, + maxLines: 4, + controller: notesController), + const SizedBox(height: 16), + Align( + alignment: Alignment.center, + child: Consumer( + builder: (context, value, child) => + CommonElevatedButton( + borderRadius: 30, + width: double.infinity, + height: kToolbarHeight - 10, + text: 'ON LEAVE', + backgroundColor: + const Color(0xff00784C), + onPressed: () { + value + .markLeave( + dateController.text + .trim(), + timeController.text + .trim(), + locationController.text + .trim(), + notesController.text + .trim(), + selectedLeaveType) + .then( + (result) { + var (status, message) = + result; + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar( + content: + Text(message))); + if (status) { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => + const AttendanceSuccess())); + } + }, + ); + + // Navigator.push(context, MaterialPageRoute(builder:(context) => const AttendanceSuccess(),)); + }), + )), + ], + ), + ), ], ), - const SizedBox(height: 15), - CommonTextFormField( - height: 100, - title: 'Reason', - fillColor: Colors.white, - maxLines: 4, - controller: notesController), - const SizedBox(height: 16), - Align( - alignment: Alignment.center, - child: CommonElevatedButton( - borderRadius: 30, - width: double.infinity, - height: kToolbarHeight - 10, - text: 'ON LEAVE', - backgroundColor: const Color(0xff00784C), - onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => const AttendanceSuccess())); - - }) - - ), - ], ), ), - ], - ), - ), - ),), - ); + ), + )); } -} \ No newline at end of file +} diff --git a/lib/services/api_client.dart b/lib/services/api_client.dart index 65ec84d..4e37514 100644 --- a/lib/services/api_client.dart +++ b/lib/services/api_client.dart @@ -8,25 +8,42 @@ class ApiClient { final SecureStorageService _storageService = SecureStorageService(); ApiClient({String? baseUrl}) - : _dio = Dio(BaseOptions( + : _dio = Dio( + BaseOptions( baseUrl: baseUrl ?? ApiUrls.baseUrl, connectTimeout: const Duration(seconds: 120), - receiveTimeout: const Duration(seconds: 120))) { + receiveTimeout: const Duration(seconds: 120), + ), + ) { + _dio.interceptors.add( + InterceptorsWrapper( + onRequest: (options, handler) async { + String? token = await _storageService.read(key: 'access_token'); + if (token != null) { + options.headers['Authorization'] = 'Bearer $token'; + } + return handler.next(options); + }, + onResponse: (response, handler) { + return handler.next(response); + }, + onError: (DioException e, handler) { + return handler.next(e); + }, + ), + ); + _dio.interceptors .add(LogInterceptor(responseBody: true, requestBody: true)); - _dio.interceptors.add(PrettyDioLogger()); - _dio.interceptors - .add(InterceptorsWrapper(onRequest: (options, handler) async { - String? token = await _storageService.read(key: 'access_token'); - if (token != null) { - options.headers['Authorization'] = 'Bearer $token'; - } - return handler.next(options); - }, onResponse: (response, handler) { - return handler.next(response); - }, onError: (DioException e, handler) { - return handler.next(e); - })); + _dio.interceptors.add(PrettyDioLogger( + requestHeader: true, + requestBody: true, + responseBody: true, + responseHeader: false, + error: true, + compact: true, + maxWidth: 90, + )); } Future get(String path, {Map? queryParameters}) { diff --git a/lib/services/api_urls.dart b/lib/services/api_urls.dart index fafec62..e182b29 100644 --- a/lib/services/api_urls.dart +++ b/lib/services/api_urls.dart @@ -2,7 +2,8 @@ class ApiUrls { static const String baseUrl = 'https://cheminova-api-2.onrender.com/api/'; static const String loginUrl = 'territorymanager/login'; static const String profileUrl = 'territorymanager/my-profile'; - static const String markAttendanceUrl = 'v1/markattendance/salescoordinator'; + static const String markAttendanceUrl = 'v1/markattendance/territorymanager'; + static const String markLeaveUrl = 'v1/markleave/territorymanager'; static const String forgetPasswordUrl = 'territorymanager/forgot-password'; static const String changePasswordUrl = 'territorymanager/password/update'; }