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,
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<ApprovalList> {
.viewPlanForApprover(
context,
plan.planId,
plan.approverId,
plan.delegaterId,
isViewMode: false,
isApprover: true);
},

View File

@ -104,6 +104,8 @@ class _CreatePlansState extends State<CreatePlan> {
// 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<String, dynamic> planData =
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>? ?? {};
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<CreatePlan> {
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<String, dynamic> 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<CreateNewPlan> {
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<CreateNewPlan> {
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<CreateNewPlan> {
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}");

View File

@ -52,6 +52,7 @@ class _PolicyState extends State<Policy> {
late String policyType = "domestic";
// int? selectedServiceIndex = 1;
ValueNotifier<String> selectedServiceIndex = ValueNotifier("1");
ValueNotifier<String> selectedServicePriorityIndex = ValueNotifier("1");
String selectedService = "train";
// ValueNotifier<String> selectedService = ValueNotifier("Train");
bool isViewMode = false;
@ -295,7 +296,7 @@ class _PolicyState extends State<Policy> {
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<Policy> {
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<Policy> {
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<Policy> {
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<Policy> {
}
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
return GestureDetector(
onTap: () {
setState(() {
selectedServiceIndex.value = index;
// selectedServiceIndex.value = index;
selectedServicePriorityIndex.value = index;
});
},
child: Container(

View File

@ -172,8 +172,11 @@ class PolicyCriteriaState extends State<PolicyCriteria> {
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<PolicyCriteria> {
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<PolicyCriteria> {
style: GoogleFonts.poppins(fontSize: 12),
decoration: InputDecoration(
hintText: "Select",
hintStyle: GoogleFonts.poppins(fontSize: 12),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 10), // Proper padding

View File

@ -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<String, dynamic> 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'],
);
}
}

View File

@ -203,7 +203,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
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;

View File

@ -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(),

View File

@ -487,15 +487,18 @@ class ApiService {
}
static Future<void> viewPlanForApprover(BuildContext context, String planId,
String? approverId, String? delegaterId,
{bool isViewMode = false, bool isApprover = true}) async {
try {
Map<String, dynamic> 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");

View File

@ -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:

View File

@ -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: