From 33185ab3b7243a705d43295d0240f58f35a5f741 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Thu, 29 May 2025 09:50:33 +0530 Subject: [PATCH] Travel Policy BugFix --- lib/Screens/approvals/approval_list.dart | 8 +++++ lib/Screens/plans/create_plans.dart | 37 ++++++++++++++++-------- lib/Screens/policy/policy.dart | 15 ++++++---- lib/Screens/policy/policyCriteria.dart | 11 +++++-- lib/data/models/plan.dart | 7 +++++ lib/routes/custom_appBar.dart | 3 +- lib/routes/custom_router.dart | 4 +++ lib/services/apiService.dart | 7 +++-- pubspec.lock | 14 +++++---- pubspec.yaml | 3 +- 10 files changed, 78 insertions(+), 31 deletions(-) diff --git a/lib/Screens/approvals/approval_list.dart b/lib/Screens/approvals/approval_list.dart index 0cda2f5..9a1a7f0 100644 --- a/lib/Screens/approvals/approval_list.dart +++ b/lib/Screens/approvals/approval_list.dart @@ -761,11 +761,17 @@ class _ApprovalListState extends State { width: 20, height: 15), onPressed: () { + print( + "Approver Edit : ${plan.approverId}"); + print( + "Approver Edit2 : ${plan.delegaterId}"); Navigator.pop(context); ApiService .viewPlanForApprover( context, plan.planId, + plan.approverId, + plan.delegaterId, isViewMode: false, isApprover: true); }, @@ -959,6 +965,8 @@ class _ApprovalListState extends State { .viewPlanForApprover( context, plan.planId, + plan.approverId, + plan.delegaterId, isViewMode: false, isApprover: true); }, diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index 52ee358..82c324c 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -104,6 +104,8 @@ class _CreatePlansState extends State { // final planData = args?['planData']; final bool isViewMode = args?['isViewMode'] ?? false; final bool isApprover = args?['isApprover'] ?? false; + final String approverId = args['approverId'] ?? ""; + final String delegaterId = args['delegaterId'] ?? ""; final Map planData = args['planData'] as Map? ?? {}; @@ -114,7 +116,8 @@ class _CreatePlansState extends State { // final planData = GoRouterState.of(context).extra as Map? ?? {}; print("RECived palndata"); - // print("RECived palndata - ${planData}"); + print("RECived approverId - $approverId"); + print("RECived delegateId - $delegaterId"); return Container( margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null, @@ -185,14 +188,15 @@ class _CreatePlansState extends State { child: Padding( padding: EdgeInsets.all(10.0), child: CreateNewPlan( - key: _createPlanKey, - bodyColor: bodyColor, - layoutColor: layoutColor, - isDesktop: isDesktop, - selectedPlanData: planData, - isViewMode: isViewMode, - isApprover: isApprover, - ), + key: _createPlanKey, + bodyColor: bodyColor, + layoutColor: layoutColor, + isDesktop: isDesktop, + selectedPlanData: planData, + isViewMode: isViewMode, + isApprover: isApprover, + approverId: approverId, + delegaterId: delegaterId), ), ), ), @@ -291,6 +295,10 @@ class CreateNewPlan extends StatefulWidget { final Color? layoutColor; final Map selectedPlanData; + + final String approverId; + + final String delegaterId; const CreateNewPlan({ super.key, required this.isDesktop, @@ -299,6 +307,8 @@ class CreateNewPlan extends StatefulWidget { required this.selectedPlanData, required this.isViewMode, required this.isApprover, + required this.approverId, + required this.delegaterId, }); @override @@ -1036,7 +1046,8 @@ class CreateNewPlansState extends State { endpoint: '/api/plans/approvePlan', data: { "plan_id": planId, - "user_id": userId, + "user_id": widget.approverId, + "delegater_id": widget.delegaterId, }, methodName: 'Plan Approval', ); @@ -1048,7 +1059,8 @@ class CreateNewPlansState extends State { endpoint: '/api/plans/rejectPlan', data: { "plan_id": planId, - "user_id": userId, + "user_id": widget.approverId, + "delegater_id": widget.delegaterId, "reason": remarks, }, methodName: 'Plan Rejection', @@ -1086,7 +1098,8 @@ class CreateNewPlansState extends State { print("ViewAAA - $planData"); print("Call viewPlanForApprover"); - ApiService.viewPlanForApprover(context, data['plan_id'], + ApiService.viewPlanForApprover( + context, data['plan_id'], data['approverId'], data['delegaterId'], isViewMode: false, isApprover: true); } else { print("$methodName failed. Status: ${response.statusCode}"); diff --git a/lib/Screens/policy/policy.dart b/lib/Screens/policy/policy.dart index 96e51f7..844ca65 100644 --- a/lib/Screens/policy/policy.dart +++ b/lib/Screens/policy/policy.dart @@ -52,6 +52,7 @@ class _PolicyState extends State { late String policyType = "domestic"; // int? selectedServiceIndex = 1; ValueNotifier selectedServiceIndex = ValueNotifier("1"); + ValueNotifier selectedServicePriorityIndex = ValueNotifier("1"); String selectedService = "train"; // ValueNotifier selectedService = ValueNotifier("Train"); bool isViewMode = false; @@ -295,7 +296,7 @@ class _PolicyState extends State { if (SelectedDomestic == "1") { _selectedTripType = "1"; } else if (SelectedInternational == "1") { - _selectedTripType = "1"; + _selectedTripType = "2"; } /// ✅ Load policy_details list safely @@ -621,7 +622,7 @@ class _PolicyState extends State { SizedBox(height: 5), // Space before error message Text( errorMessages["policy_details"]!, - style: TextStyle(color: Colors.red, fontSize: 12), + style: GoogleFonts.poppins(color: Colors.red, fontSize: 10), ), ], isDesktop @@ -747,7 +748,7 @@ class _PolicyState extends State { if (errorMessages["name"] != null) ...[ SizedBox(height: 5), Text(errorMessages["name"]!, - style: TextStyle(color: Colors.red, fontSize: 12)), + style: GoogleFonts.poppins(color: Colors.red, fontSize: 10)), ], ], ); @@ -770,7 +771,7 @@ class _PolicyState extends State { if (errorMessages["trip_type"] != null) ...[ SizedBox(height: 5), Text(errorMessages["trip_type"]!, - style: TextStyle(color: Colors.red, fontSize: 12)), + style: GoogleFonts.poppins(color: Colors.red, fontSize: 10)), ], ], ); @@ -876,13 +877,15 @@ class _PolicyState extends State { } Widget _buildServiceTile(Map service, String index) { - bool isSelected = selectedServiceIndex.value == index; + // bool isSelected = selectedServiceIndex.value == index; + bool isSelected = selectedServicePriorityIndex.value == index; String name = service['name']; // or 'service_id', as needed return GestureDetector( onTap: () { setState(() { - selectedServiceIndex.value = index; + // selectedServiceIndex.value = index; + selectedServicePriorityIndex.value = index; }); }, child: Container( diff --git a/lib/Screens/policy/policyCriteria.dart b/lib/Screens/policy/policyCriteria.dart index c3eddac..eb81378 100644 --- a/lib/Screens/policy/policyCriteria.dart +++ b/lib/Screens/policy/policyCriteria.dart @@ -172,8 +172,11 @@ class PolicyCriteriaState extends State { final a2 = SecondApproverAction[serviceId]; final a3 = ThirdApproverAction[serviceId]; - bool hasValue = cost.trim().isNotEmpty; - // bool hasValue = cost.trim().isNotEmpty || travelClass.trim().isNotEmpty; + // bool hasValue = cost.trim().isNotEmpty; + // bool hasValue = cost.trim().isNotEmpty || travelClass!.isNotEmpty; + bool hasValue = + cost.trim().isNotEmpty || (travelClass?.isNotEmpty ?? false); + bool allActionsNull = a1 == null && a2 == null && a3 == null; bool someActionsMissing = [a1, a2, a3].where((a) => a != null).length > 0 && [a1, a2, a3].where((a) => a == null).length > 0; @@ -380,7 +383,7 @@ class PolicyCriteriaState extends State { Row( children: [ Text(validationErrors[ServiceId]!, - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.red, fontSize: 10, fontWeight: FontWeight.bold)) @@ -961,6 +964,8 @@ class PolicyCriteriaState extends State { style: GoogleFonts.poppins(fontSize: 12), decoration: InputDecoration( + hintText: "Select", + hintStyle: GoogleFonts.poppins(fontSize: 12), border: InputBorder.none, contentPadding: EdgeInsets.symmetric( horizontal: 10), // Proper padding diff --git a/lib/data/models/plan.dart b/lib/data/models/plan.dart index 8ac57f5..4dc036d 100644 --- a/lib/data/models/plan.dart +++ b/lib/data/models/plan.dart @@ -1,5 +1,6 @@ class Plan { final String planId; + final String? employeeCode; final String tripTitle; final String tripType; @@ -15,6 +16,8 @@ class Plan { final String travellerName; final String statusValue; final String createdOn; + final String? approverId; + final String? delegaterId; Plan({ required this.planId, @@ -32,6 +35,8 @@ class Plan { required this.travellerName, required this.statusValue, required this.createdOn, + this.approverId, + this.delegaterId, }); factory Plan.fromJson(Map json) { @@ -52,6 +57,8 @@ class Plan { travellerName: json["traveller_name"] ?? '', statusValue: json["status_value"] ?? '', createdOn: json["created_on"] ?? '', + approverId: json['approver_id'], + delegaterId: json['delegater_id'], ); } } diff --git a/lib/routes/custom_appBar.dart b/lib/routes/custom_appBar.dart index a4e592a..fc5b47f 100644 --- a/lib/routes/custom_appBar.dart +++ b/lib/routes/custom_appBar.dart @@ -203,7 +203,8 @@ class _CustomAppBarState extends State { location.contains('/createPlan') || location.contains('/listTravelAgentPlan')) { selectedTab = TabSelection.myTrips; - } else if (location.contains('/ApprovalList')) { + } else if (location.contains('/ApprovalList') || + location.contains('/approver/plans')) { selectedTab = TabSelection.myApprovals; } else { selectedTab = TabSelection.allMenu; diff --git a/lib/routes/custom_router.dart b/lib/routes/custom_router.dart index e7d3c0c..487ff68 100644 --- a/lib/routes/custom_router.dart +++ b/lib/routes/custom_router.dart @@ -66,6 +66,10 @@ final GoRouter router = GoRouter( path: '/allTrips/trips', builder: (context, state) => CreatePlan(), ), + GoRoute( + path: '/approver/plans', + builder: (context, state) => CreatePlan(), + ), GoRoute( path: '/listUser', builder: (context, state) => UserListScreen(), diff --git a/lib/services/apiService.dart b/lib/services/apiService.dart index 52747ae..d391549 100644 --- a/lib/services/apiService.dart +++ b/lib/services/apiService.dart @@ -487,15 +487,18 @@ class ApiService { } static Future viewPlanForApprover(BuildContext context, String planId, + String? approverId, String? delegaterId, {bool isViewMode = false, bool isApprover = true}) async { try { Map planData = await getViewPlanEdit(planId); print("ViewAAA - $planData"); - context.replace('/createPlan', extra: { + context.replace('/approver/plans', extra: { 'planData': planData, + 'approverId': approverId, + 'delegaterId': delegaterId, 'isViewMode': isViewMode, - 'isApprover': isApprover + 'isApprover': isApprover, }); } catch (e) { print("Error fetching plan: $e"); diff --git a/pubspec.lock b/pubspec.lock index e0c379b..4e5e26c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -270,11 +270,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.2" - flutter_quill: - git: - url: https://github.com/singerdmx/flutter-quill.git - ref: v11.4.1 - flutter_localizations: dependency: transitive description: flutter @@ -288,7 +283,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.27" - + flutter_quill: + dependency: "direct main" + description: + name: flutter_quill + sha256: "7e60963632bbc8615627f0bae8e178515f69ecb378ad49fa68c43c2aabf33e21" + url: "https://pub.dev" + source: hosted + version: "11.4.1" flutter_quill_delta_from_html: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7429217..6ef992f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,8 @@ dependencies: flutter_quill_extensions: ^11.0.0 flutter_localization: ^0.3.2 reorderables: ^0.6.0 - html_editor_enhanced: ^1.8.0 + + dev_dependencies: