Travel Policy BugFix

This commit is contained in:
venbaittech 2025-05-29 09:50:33 +05:30
parent a1837db9fe
commit 33185ab3b7
10 changed files with 78 additions and 31 deletions

View File

@ -761,11 +761,17 @@ class _ApprovalListState extends State<ApprovalList> {
width: 20, width: 20,
height: 15), height: 15),
onPressed: () { onPressed: () {
print(
"Approver Edit : ${plan.approverId}");
print(
"Approver Edit2 : ${plan.delegaterId}");
Navigator.pop(context); Navigator.pop(context);
ApiService ApiService
.viewPlanForApprover( .viewPlanForApprover(
context, context,
plan.planId, plan.planId,
plan.approverId,
plan.delegaterId,
isViewMode: false, isViewMode: false,
isApprover: true); isApprover: true);
}, },
@ -959,6 +965,8 @@ class _ApprovalListState extends State<ApprovalList> {
.viewPlanForApprover( .viewPlanForApprover(
context, context,
plan.planId, plan.planId,
plan.approverId,
plan.delegaterId,
isViewMode: false, isViewMode: false,
isApprover: true); isApprover: true);
}, },

View File

@ -104,6 +104,8 @@ class _CreatePlansState extends State<CreatePlan> {
// final planData = args?['planData']; // final planData = args?['planData'];
final bool isViewMode = args?['isViewMode'] ?? false; final bool isViewMode = args?['isViewMode'] ?? false;
final bool isApprover = args?['isApprover'] ?? false; final bool isApprover = args?['isApprover'] ?? false;
final String approverId = args['approverId'] ?? "";
final String delegaterId = args['delegaterId'] ?? "";
final Map<String, dynamic> planData = final Map<String, dynamic> planData =
args['planData'] as Map<String, dynamic>? ?? {}; args['planData'] as Map<String, dynamic>? ?? {};
@ -114,7 +116,8 @@ class _CreatePlansState extends State<CreatePlan> {
// final planData = GoRouterState.of(context).extra as Map<String, dynamic>? ?? {}; // final planData = GoRouterState.of(context).extra as Map<String, dynamic>? ?? {};
print("RECived palndata"); print("RECived palndata");
// print("RECived palndata - ${planData}"); print("RECived approverId - $approverId");
print("RECived delegateId - $delegaterId");
return Container( return Container(
margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null, margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null,
@ -192,7 +195,8 @@ class _CreatePlansState extends State<CreatePlan> {
selectedPlanData: planData, selectedPlanData: planData,
isViewMode: isViewMode, isViewMode: isViewMode,
isApprover: isApprover, isApprover: isApprover,
), approverId: approverId,
delegaterId: delegaterId),
), ),
), ),
), ),
@ -291,6 +295,10 @@ class CreateNewPlan extends StatefulWidget {
final Color? layoutColor; final Color? layoutColor;
final Map<String, dynamic> selectedPlanData; final Map<String, dynamic> selectedPlanData;
final String approverId;
final String delegaterId;
const CreateNewPlan({ const CreateNewPlan({
super.key, super.key,
required this.isDesktop, required this.isDesktop,
@ -299,6 +307,8 @@ class CreateNewPlan extends StatefulWidget {
required this.selectedPlanData, required this.selectedPlanData,
required this.isViewMode, required this.isViewMode,
required this.isApprover, required this.isApprover,
required this.approverId,
required this.delegaterId,
}); });
@override @override
@ -1036,7 +1046,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
endpoint: '/api/plans/approvePlan', endpoint: '/api/plans/approvePlan',
data: { data: {
"plan_id": planId, "plan_id": planId,
"user_id": userId, "user_id": widget.approverId,
"delegater_id": widget.delegaterId,
}, },
methodName: 'Plan Approval', methodName: 'Plan Approval',
); );
@ -1048,7 +1059,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
endpoint: '/api/plans/rejectPlan', endpoint: '/api/plans/rejectPlan',
data: { data: {
"plan_id": planId, "plan_id": planId,
"user_id": userId, "user_id": widget.approverId,
"delegater_id": widget.delegaterId,
"reason": remarks, "reason": remarks,
}, },
methodName: 'Plan Rejection', methodName: 'Plan Rejection',
@ -1086,7 +1098,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
print("ViewAAA - $planData"); print("ViewAAA - $planData");
print("Call viewPlanForApprover"); print("Call viewPlanForApprover");
ApiService.viewPlanForApprover(context, data['plan_id'], ApiService.viewPlanForApprover(
context, data['plan_id'], data['approverId'], data['delegaterId'],
isViewMode: false, isApprover: true); isViewMode: false, isApprover: true);
} else { } else {
print("$methodName failed. Status: ${response.statusCode}"); print("$methodName failed. Status: ${response.statusCode}");

View File

@ -52,6 +52,7 @@ class _PolicyState extends State<Policy> {
late String policyType = "domestic"; late String policyType = "domestic";
// int? selectedServiceIndex = 1; // int? selectedServiceIndex = 1;
ValueNotifier<String> selectedServiceIndex = ValueNotifier("1"); ValueNotifier<String> selectedServiceIndex = ValueNotifier("1");
ValueNotifier<String> selectedServicePriorityIndex = ValueNotifier("1");
String selectedService = "train"; String selectedService = "train";
// ValueNotifier<String> selectedService = ValueNotifier("Train"); // ValueNotifier<String> selectedService = ValueNotifier("Train");
bool isViewMode = false; bool isViewMode = false;
@ -295,7 +296,7 @@ class _PolicyState extends State<Policy> {
if (SelectedDomestic == "1") { if (SelectedDomestic == "1") {
_selectedTripType = "1"; _selectedTripType = "1";
} else if (SelectedInternational == "1") { } else if (SelectedInternational == "1") {
_selectedTripType = "1"; _selectedTripType = "2";
} }
/// Load policy_details list safely /// Load policy_details list safely
@ -621,7 +622,7 @@ class _PolicyState extends State<Policy> {
SizedBox(height: 5), // Space before error message SizedBox(height: 5), // Space before error message
Text( Text(
errorMessages["policy_details"]!, errorMessages["policy_details"]!,
style: TextStyle(color: Colors.red, fontSize: 12), style: GoogleFonts.poppins(color: Colors.red, fontSize: 10),
), ),
], ],
isDesktop isDesktop
@ -747,7 +748,7 @@ class _PolicyState extends State<Policy> {
if (errorMessages["name"] != null) ...[ if (errorMessages["name"] != null) ...[
SizedBox(height: 5), SizedBox(height: 5),
Text(errorMessages["name"]!, 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<Policy> {
if (errorMessages["trip_type"] != null) ...[ if (errorMessages["trip_type"] != null) ...[
SizedBox(height: 5), SizedBox(height: 5),
Text(errorMessages["trip_type"]!, 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<Policy> {
} }
Widget _buildServiceTile(Map<String, dynamic> service, String index) { Widget _buildServiceTile(Map<String, dynamic> 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 String name = service['name']; // or 'service_id', as needed
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
setState(() { setState(() {
selectedServiceIndex.value = index; // selectedServiceIndex.value = index;
selectedServicePriorityIndex.value = index;
}); });
}, },
child: Container( child: Container(

View File

@ -172,8 +172,11 @@ class PolicyCriteriaState extends State<PolicyCriteria> {
final a2 = SecondApproverAction[serviceId]; final a2 = SecondApproverAction[serviceId];
final a3 = ThirdApproverAction[serviceId]; final a3 = ThirdApproverAction[serviceId];
bool hasValue = cost.trim().isNotEmpty; // bool hasValue = cost.trim().isNotEmpty;
// bool hasValue = cost.trim().isNotEmpty || travelClass.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 allActionsNull = a1 == null && a2 == null && a3 == null;
bool someActionsMissing = [a1, a2, a3].where((a) => a != null).length > 0 && bool someActionsMissing = [a1, a2, a3].where((a) => a != null).length > 0 &&
[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<PolicyCriteria> {
Row( Row(
children: [ children: [
Text(validationErrors[ServiceId]!, Text(validationErrors[ServiceId]!,
style: TextStyle( style: GoogleFonts.poppins(
color: Colors.red, color: Colors.red,
fontSize: 10, fontSize: 10,
fontWeight: FontWeight.bold)) fontWeight: FontWeight.bold))
@ -961,6 +964,8 @@ class PolicyCriteriaState extends State<PolicyCriteria> {
style: GoogleFonts.poppins(fontSize: 12), style: GoogleFonts.poppins(fontSize: 12),
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Select",
hintStyle: GoogleFonts.poppins(fontSize: 12),
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric( contentPadding: EdgeInsets.symmetric(
horizontal: 10), // Proper padding horizontal: 10), // Proper padding

View File

@ -1,5 +1,6 @@
class Plan { class Plan {
final String planId; final String planId;
final String? employeeCode; final String? employeeCode;
final String tripTitle; final String tripTitle;
final String tripType; final String tripType;
@ -15,6 +16,8 @@ class Plan {
final String travellerName; final String travellerName;
final String statusValue; final String statusValue;
final String createdOn; final String createdOn;
final String? approverId;
final String? delegaterId;
Plan({ Plan({
required this.planId, required this.planId,
@ -32,6 +35,8 @@ class Plan {
required this.travellerName, required this.travellerName,
required this.statusValue, required this.statusValue,
required this.createdOn, required this.createdOn,
this.approverId,
this.delegaterId,
}); });
factory Plan.fromJson(Map<String, dynamic> json) { factory Plan.fromJson(Map<String, dynamic> json) {
@ -52,6 +57,8 @@ class Plan {
travellerName: json["traveller_name"] ?? '', travellerName: json["traveller_name"] ?? '',
statusValue: json["status_value"] ?? '', statusValue: json["status_value"] ?? '',
createdOn: json["created_on"] ?? '', createdOn: json["created_on"] ?? '',
approverId: json['approver_id'],
delegaterId: json['delegater_id'],
); );
} }
} }

View File

@ -203,7 +203,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
location.contains('/createPlan') || location.contains('/createPlan') ||
location.contains('/listTravelAgentPlan')) { location.contains('/listTravelAgentPlan')) {
selectedTab = TabSelection.myTrips; selectedTab = TabSelection.myTrips;
} else if (location.contains('/ApprovalList')) { } else if (location.contains('/ApprovalList') ||
location.contains('/approver/plans')) {
selectedTab = TabSelection.myApprovals; selectedTab = TabSelection.myApprovals;
} else { } else {
selectedTab = TabSelection.allMenu; selectedTab = TabSelection.allMenu;

View File

@ -66,6 +66,10 @@ final GoRouter router = GoRouter(
path: '/allTrips/trips', path: '/allTrips/trips',
builder: (context, state) => CreatePlan(), builder: (context, state) => CreatePlan(),
), ),
GoRoute(
path: '/approver/plans',
builder: (context, state) => CreatePlan(),
),
GoRoute( GoRoute(
path: '/listUser', path: '/listUser',
builder: (context, state) => UserListScreen(), builder: (context, state) => UserListScreen(),

View File

@ -487,15 +487,18 @@ class ApiService {
} }
static Future<void> viewPlanForApprover(BuildContext context, String planId, static Future<void> viewPlanForApprover(BuildContext context, String planId,
String? approverId, String? delegaterId,
{bool isViewMode = false, bool isApprover = true}) async { {bool isViewMode = false, bool isApprover = true}) async {
try { try {
Map<String, dynamic> planData = await getViewPlanEdit(planId); Map<String, dynamic> planData = await getViewPlanEdit(planId);
print("ViewAAA - $planData"); print("ViewAAA - $planData");
context.replace('/createPlan', extra: { context.replace('/approver/plans', extra: {
'planData': planData, 'planData': planData,
'approverId': approverId,
'delegaterId': delegaterId,
'isViewMode': isViewMode, 'isViewMode': isViewMode,
'isApprover': isApprover 'isApprover': isApprover,
}); });
} catch (e) { } catch (e) {
print("Error fetching plan: $e"); print("Error fetching plan: $e");

View File

@ -270,11 +270,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.2" version: "0.3.2"
flutter_quill:
git:
url: https://github.com/singerdmx/flutter-quill.git
ref: v11.4.1
flutter_localizations: flutter_localizations:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -288,7 +283,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.27" 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: flutter_quill_delta_from_html:
dependency: transitive dependency: transitive
description: description:

View File

@ -54,7 +54,8 @@ dependencies:
flutter_quill_extensions: ^11.0.0 flutter_quill_extensions: ^11.0.0
flutter_localization: ^0.3.2 flutter_localization: ^0.3.2
reorderables: ^0.6.0 reorderables: ^0.6.0
html_editor_enhanced: ^1.8.0
dev_dependencies: dev_dependencies: