merge
This commit is contained in:
commit
3104812979
@ -83,6 +83,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
|
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
|
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredPlans: $filteredPlans");
|
print("filteredPlans: $filteredPlans");
|
||||||
}
|
}
|
||||||
@ -276,41 +277,34 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
bool isDesktop =
|
bool isDesktop =
|
||||||
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
return MainLayout(
|
return Scaffold(
|
||||||
isDesktop: isDesktop,
|
backgroundColor: Color(0xFFf5f5f5),
|
||||||
child: Row(
|
// backgroundColor: Color(0xFFFCFCFC),
|
||||||
children: [
|
|
||||||
// if (isDesktop) CustomDrawer(isDesktop: true),
|
// appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
|
||||||
Expanded(child: buildGroupListLayout(isDesktop)),
|
// drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
|
||||||
],
|
appBar: CustomAppBar(isDesktop: isDesktop),
|
||||||
|
drawer: CustomDrawer(isDesktop: false),
|
||||||
|
body: Padding(
|
||||||
|
padding:
|
||||||
|
isDesktop
|
||||||
|
? EdgeInsets.symmetric(
|
||||||
|
horizontal:
|
||||||
|
MediaQuery.of(context).size.width *
|
||||||
|
0.1, // 30% of screen width as horizontal padding
|
||||||
|
vertical:
|
||||||
|
MediaQuery.of(context).size.height *
|
||||||
|
0, // 5% of screen height as vertical padding
|
||||||
|
)
|
||||||
|
: EdgeInsets.all(0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
|
Expanded(child: buildGroupListLayout(isDesktop)),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// return Scaffold(
|
|
||||||
// backgroundColor: Color(0xFFf5f5f5),
|
|
||||||
// // backgroundColor: Color(0xFFFCFCFC),
|
|
||||||
// appBar: CustomAppBar(isDesktop: isDesktop),
|
|
||||||
// drawer: CustomDrawer(isDesktop: false),
|
|
||||||
// body: Padding(
|
|
||||||
// padding:
|
|
||||||
// isDesktop
|
|
||||||
// ? EdgeInsets.symmetric(
|
|
||||||
// horizontal:
|
|
||||||
// MediaQuery.of(context).size.width *
|
|
||||||
// 0.1, // 30% of screen width as horizontal padding
|
|
||||||
// vertical:
|
|
||||||
// MediaQuery.of(context).size.height *
|
|
||||||
// 0, // 5% of screen height as vertical padding
|
|
||||||
// )
|
|
||||||
// : EdgeInsets.all(0),
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// // if (isDesktop) CustomDrawer(isDesktop: true),
|
|
||||||
// Expanded(child: buildGroupListLayout(isDesktop)),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -866,7 +860,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
tooltip:
|
tooltip:
|
||||||
'View Trips',
|
'View The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context,
|
context,
|
||||||
@ -885,6 +879,8 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
width: 20,
|
width: 20,
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
|
tooltip:
|
||||||
|
'Edit The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context,
|
context,
|
||||||
@ -904,7 +900,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
tooltip:
|
tooltip:
|
||||||
'Cancellation Trips',
|
'Cancellation The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context,
|
context,
|
||||||
@ -923,7 +919,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
tooltip:
|
tooltip:
|
||||||
'Download Trips Detials',
|
'Download The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context,
|
context,
|
||||||
@ -943,7 +939,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
size: 11,
|
size: 11,
|
||||||
),
|
),
|
||||||
tooltip:
|
tooltip:
|
||||||
'Trips Comments',
|
'Trip Comments',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context:
|
context:
|
||||||
|
|||||||
@ -324,6 +324,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
|
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
|
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredPlans: $filteredPlans");
|
print("filteredPlans: $filteredPlans");
|
||||||
}
|
}
|
||||||
@ -747,6 +748,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
color:
|
color:
|
||||||
Color(0xFF475569),
|
Color(0xFF475569),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'View The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context); // Close popup manually
|
context); // Close popup manually
|
||||||
@ -760,6 +762,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15),
|
||||||
|
tooltip: 'Edit The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
print(
|
print(
|
||||||
"Approver Edit : ${plan.approverId}");
|
"Approver Edit : ${plan.approverId}");
|
||||||
@ -780,6 +783,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.cancel_rounded,
|
Icons.cancel_rounded,
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Cancellation The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
deletePlan(plan.planId);
|
deletePlan(plan.planId);
|
||||||
@ -789,6 +793,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
icon: Icon(Icons.download,
|
icon: Icon(Icons.download,
|
||||||
color: Color(0xFF114D8B),
|
color: Color(0xFF114D8B),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Download The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
apiService.getPdfDownload(
|
apiService.getPdfDownload(
|
||||||
@ -801,6 +806,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
size: 11,
|
size: 11,
|
||||||
),
|
),
|
||||||
|
tooltip: 'Approver Comment',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -946,6 +952,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
color:
|
color:
|
||||||
Color(0xFF475569),
|
Color(0xFF475569),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'View The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context); // Close popup manually
|
context); // Close popup manually
|
||||||
@ -959,6 +966,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15),
|
||||||
|
tooltip: 'Edit The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ApiService
|
ApiService
|
||||||
@ -975,6 +983,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.cancel_rounded,
|
Icons.cancel_rounded,
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Cancellation The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
deletePlan(plan.planId);
|
deletePlan(plan.planId);
|
||||||
@ -984,6 +993,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
icon: Icon(Icons.download,
|
icon: Icon(Icons.download,
|
||||||
color: Color(0xFF114D8B),
|
color: Color(0xFF114D8B),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Download The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
apiService.getPdfDownload(
|
apiService.getPdfDownload(
|
||||||
@ -996,6 +1006,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
size: 11,
|
size: 11,
|
||||||
),
|
),
|
||||||
|
tooltip: 'Trip Comments',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
@ -153,6 +153,7 @@ class CostCenterListState extends State<CostCenterList> {
|
|||||||
(object['description']?.toLowerCase().contains(lowerQuery) ?? false) ||
|
(object['description']?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
(isActiveStatus.contains(lowerQuery));
|
(isActiveStatus.contains(lowerQuery));
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredCostCenter: $filteredCostCenter");
|
print("filteredCostCenter: $filteredCostCenter");
|
||||||
|
|
||||||
@ -535,10 +536,14 @@ class CostCenterListState extends State<CostCenterList> {
|
|||||||
// apiService.getSingleUser(id),
|
// apiService.getSingleUser(id),
|
||||||
// ),
|
// ),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset(
|
child: Tooltip(
|
||||||
|
message: 'Edit CostCenter Details',
|
||||||
|
child: Image.asset(
|
||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// final userId = getUserId(user['user_id']);
|
// final userId = getUserId(user['user_id']);
|
||||||
// final usersData = await getUserDetails(userId);
|
// final usersData = await getUserDetails(userId);
|
||||||
@ -611,10 +616,14 @@ class CostCenterListState extends State<CostCenterList> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset(
|
child: Tooltip(
|
||||||
|
message: 'Edit CostCenter Details',
|
||||||
|
child: Image.asset(
|
||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// final userId = getUserId(user['user_id']);
|
// final userId = getUserId(user['user_id']);
|
||||||
// final usersData = await getUserDetails(userId);
|
// final usersData = await getUserDetails(userId);
|
||||||
|
|||||||
@ -151,6 +151,7 @@ class DepartmentListState extends State<DepartmentList> {
|
|||||||
false) ||
|
false) ||
|
||||||
(isActiveStatus.contains(lowerQuery));
|
(isActiveStatus.contains(lowerQuery));
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredDepartment: $filteredDepartment");
|
print("filteredDepartment: $filteredDepartment");
|
||||||
}
|
}
|
||||||
@ -619,10 +620,14 @@ class DepartmentListState extends State<DepartmentList> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset(
|
child: Tooltip(
|
||||||
|
message: 'Edit Department Details',
|
||||||
|
child: Image.asset(
|
||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// final userId = getUserId(user['user_id']);
|
// final userId = getUserId(user['user_id']);
|
||||||
// final usersData = await getUserDetails(userId);
|
// final usersData = await getUserDetails(userId);
|
||||||
|
|||||||
@ -295,6 +295,7 @@ class ForexDataListState extends State<ForexDataList> {
|
|||||||
(forex['perdiem_amount']?.toLowerCase().contains(lowerQuery) ??
|
(forex['perdiem_amount']?.toLowerCase().contains(lowerQuery) ??
|
||||||
false);
|
false);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredPlans: $filteredForex");
|
print("filteredPlans: $filteredForex");
|
||||||
}
|
}
|
||||||
@ -722,10 +723,14 @@ class ForexDataListState extends State<ForexDataList> {
|
|||||||
// apiService.getSingleUser(id),
|
// apiService.getSingleUser(id),
|
||||||
// ),
|
// ),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset(
|
child: Tooltip(
|
||||||
|
message: 'Edit ForEx Details',
|
||||||
|
child: Image.asset(
|
||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// final userId = getUserId(user['user_id']);
|
// final userId = getUserId(user['user_id']);
|
||||||
// final usersData = await getUserDetails(userId);
|
// final usersData = await getUserDetails(userId);
|
||||||
@ -798,10 +803,14 @@ class ForexDataListState extends State<ForexDataList> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset(
|
child: Tooltip(
|
||||||
|
message: 'Edit Forex Details',
|
||||||
|
child: Image.asset(
|
||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// final userId = getUserId(user['user_id']);
|
// final userId = getUserId(user['user_id']);
|
||||||
// final usersData = await getUserDetails(userId);
|
// final usersData = await getUserDetails(userId);
|
||||||
@ -1040,4 +1049,6 @@ class ForexDataListState extends State<ForexDataList> {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
433
lib/Screens/group/groupListBackUp.dart
Normal file
433
lib/Screens/group/groupListBackUp.dart
Normal file
@ -0,0 +1,433 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:frontend/Screens/group/group.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
|
import '../../config/apiUrl.dart';
|
||||||
|
import '../../routes/custom_appBar.dart';
|
||||||
|
import '../../routes/custom_drawer.dart';
|
||||||
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
import 'groupDetails.dart';
|
||||||
|
|
||||||
|
class GroupListBackUp extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_GroupListBackUpState createState() => _GroupListBackUpState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GroupListBackUpState extends State<GroupListBackUp> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
|
|
||||||
|
List<dynamic>? apiAllGroups;
|
||||||
|
Color? layoutColor;
|
||||||
|
Color? bodyColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
loadAllGroups();
|
||||||
|
loadInitialData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadInitialData() async {
|
||||||
|
String? layoutString = await getLayoutColor();
|
||||||
|
String? bodyStringColor = await getBodyColor();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
layoutColor = layoutString != null
|
||||||
|
? Color(int.parse(layoutString))
|
||||||
|
: Colors.redAccent;
|
||||||
|
|
||||||
|
bodyColor = bodyStringColor != null
|
||||||
|
? Color(int.parse(bodyStringColor))
|
||||||
|
: Colors.white;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadAllGroups() async {
|
||||||
|
try {
|
||||||
|
final result = await apiService.fetchAllGroup();
|
||||||
|
setState(() {
|
||||||
|
apiAllGroups = result;
|
||||||
|
});
|
||||||
|
print("Fetched services: $apiAllGroups");
|
||||||
|
} catch (e) {
|
||||||
|
print('Error fetching role list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleActiveStatus(
|
||||||
|
Map<String, dynamic> groupData,
|
||||||
|
String groupId,
|
||||||
|
String currentStatus,
|
||||||
|
) async {
|
||||||
|
print("Toggling user status - $groupId (Current: $currentStatus)");
|
||||||
|
|
||||||
|
final String apiUrlData =
|
||||||
|
'$apiUrl/api/groups/update/$groupId'; // API for updating user
|
||||||
|
final String? token = await getToken();
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
print("Error: Token not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle status: If active ("1"), set to inactive ("0"); otherwise, activate ("1")
|
||||||
|
String newStatus = (currentStatus == "1") ? "0" : "1";
|
||||||
|
|
||||||
|
print("STatus 1 - $newStatus");
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await http.put(
|
||||||
|
Uri.parse(apiUrlData),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: jsonEncode({
|
||||||
|
"is_active": newStatus // Set new status dynamically
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||||
|
print("User status updated successfully to $newStatus!");
|
||||||
|
loadAllGroups(); // Refresh users list after update
|
||||||
|
} else {
|
||||||
|
print("Failed to update user status. Status: ${response.statusCode}");
|
||||||
|
print("Error: ${response.body}");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Error updating user status: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void deleteGroup(Map<String, dynamic> groupdata, groupId, status) {
|
||||||
|
print("GroupId : $groupId");
|
||||||
|
print("Groupstatus: $status");
|
||||||
|
print("GroupsData: $groupdata");
|
||||||
|
|
||||||
|
// handleActiveStatus(groupdata, groupId, status);
|
||||||
|
print("Calling handleActiveStatus with: id=$groupId, status=$status");
|
||||||
|
handleActiveStatus(groupdata, groupId.toString(), status.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
loadAllGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future<void> deleteGroupFromApi(int groupId) async {
|
||||||
|
// try {
|
||||||
|
// await apiService.deleteGroup(groupId); // your delete API call
|
||||||
|
// deleteGroup(groupId); // remove from UI list
|
||||||
|
// } catch (e) {
|
||||||
|
// print('Error deleting group: $e');
|
||||||
|
// }
|
||||||
|
// }'
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ResponsiveBuilder(builder: (context, sizingInfo) {
|
||||||
|
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
// backgroundColor: Colors.white,
|
||||||
|
backgroundColor: Color(0xFFf5f5f5),
|
||||||
|
appBar: CustomAppBar(isDesktop: isDesktop),
|
||||||
|
drawer: CustomDrawer(isDesktop: false),
|
||||||
|
body: Padding(
|
||||||
|
padding: isDesktop
|
||||||
|
? EdgeInsets.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width *
|
||||||
|
0.1, // 30% of screen width as horizontal padding
|
||||||
|
vertical: MediaQuery.of(context).size.height *
|
||||||
|
0, // 5% of screen height as vertical padding
|
||||||
|
)
|
||||||
|
: EdgeInsets.all(8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
|
Expanded(child: buildGroupListLayout(isDesktop))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildGroupListLayout(bool isDesktop) {
|
||||||
|
return Container(
|
||||||
|
margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null,
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
|
||||||
|
),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// // color: Colors.amber,
|
||||||
|
// // color: bodyColor,
|
||||||
|
// color: Color(0xFFE1F5FE),
|
||||||
|
// border: Border.all(
|
||||||
|
// color: Colors.white,
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
// width: 3.5)),
|
||||||
|
child: buildGroupData(isDesktop),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Widget buildGroupListView(bool isDesktop) {
|
||||||
|
// return Container(
|
||||||
|
// child: Text("DAta"),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
Widget buildGroupData(isDesktop) {
|
||||||
|
return Container(
|
||||||
|
// margin: isDesktop
|
||||||
|
// ? EdgeInsets.all(10.0)
|
||||||
|
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
|
||||||
|
// padding: const EdgeInsets.all(10),
|
||||||
|
height: isDesktop
|
||||||
|
? MediaQuery.of(context).size.height * 0.98
|
||||||
|
: MediaQuery.of(context).size.height,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: isDesktop
|
||||||
|
// ? Border.all(
|
||||||
|
// width: 2,
|
||||||
|
// color: Colors.white,
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
// )
|
||||||
|
// : null,
|
||||||
|
// color: Colors.white,
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
//
|
||||||
|
// // color: Colors.amber,
|
||||||
|
// ),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Group List',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: isDesktop ? 16 : 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
backgroundColor: Color(0xFF114D8B),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
// side: BorderSide(color: , width: 1),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
// List<dynamic> users = await futureUsers;
|
||||||
|
// context.go('/CreateGroup');
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => GroupData(
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
groupId: null,
|
||||||
|
layoutColor: layoutColor!,
|
||||||
|
fetchGetGroup: refreshData
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text('New Group', style: GoogleFonts.poppins(fontSize: 12)),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.add_circle_outline_rounded,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.75,
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
// margin: const EdgeInsets.only(bottom: 10),
|
||||||
|
color: Colors.white,
|
||||||
|
// color: Colors.red.shade100,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
buildGroupListView(isDesktop),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildGroupListView(bool isDesktop) {
|
||||||
|
if (apiAllGroups == null || apiAllGroups!.isEmpty) {
|
||||||
|
return Center(child: Text("No groups found."));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: apiAllGroups!.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final group = apiAllGroups![index];
|
||||||
|
return Card(
|
||||||
|
// color: bodyColor,
|
||||||
|
// color: Color(0xFFF5F5F5),
|
||||||
|
color: Colors.white,
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text("Group Name",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11.5, fontWeight: FontWeight.w400)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text("Domestic Policy",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11.5, fontWeight: FontWeight.w400)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text("International Policy",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11.5, fontWeight: FontWeight.w400)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text("Description",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11.5, fontWeight: FontWeight.w400)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text("${group['name']}",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13, fontWeight: FontWeight.w600)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text("${group['domestic_policy_name'] ?? 'N/A'}",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13, fontWeight: FontWeight.w600)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text("${group['international_policy_name']}",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13, fontWeight: FontWeight.w600))),
|
||||||
|
Expanded(
|
||||||
|
child: Text("${group['description'] ?? 'N/A'}",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13, fontWeight: FontWeight.w600))),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
if (group['group_id'] != null) {
|
||||||
|
final newGroupID = int.tryParse(
|
||||||
|
group['group_id'].toString());
|
||||||
|
if (newGroupID != null) {
|
||||||
|
final data = await apiService.getGroupDetailsFind(
|
||||||
|
newGroupID); // ✅ Always an int
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) =>
|
||||||
|
GroupData(
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
groupId: newGroupID,
|
||||||
|
// Pass the ID
|
||||||
|
groupData: data,
|
||||||
|
layoutColor: layoutColor!,
|
||||||
|
fetchGetGroup: refreshData
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("something went wrong check properly");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// onTap: () {
|
||||||
|
// context.go("/CreateGroup", extra: group);
|
||||||
|
// },
|
||||||
|
child: Image.asset('assets/images/IconsImg/edit.png',
|
||||||
|
width: 20, height: 15),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
final idStr = group['group_id'];
|
||||||
|
final id = int.tryParse(idStr.toString());
|
||||||
|
|
||||||
|
if (id == null) {
|
||||||
|
print("group_id is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final status = group['is_active'];
|
||||||
|
// print("GroupId : ${group['group_id']} ");
|
||||||
|
deleteGroup(group, id, status);
|
||||||
|
},
|
||||||
|
child: Image.asset('assets/images/IconsImg/delete.png',
|
||||||
|
width: 20, height: 15),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -200,6 +200,7 @@ class HotelsDataListState extends State<HotelsDataList> {
|
|||||||
false) ||
|
false) ||
|
||||||
(isActiveStatus.contains(lowerQuery));
|
(isActiveStatus.contains(lowerQuery));
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredHotels: $filteredHotels");
|
print("filteredHotels: $filteredHotels");
|
||||||
}
|
}
|
||||||
@ -603,10 +604,14 @@ class HotelsDataListState extends State<HotelsDataList> {
|
|||||||
// apiService.getSingleUser(id),
|
// apiService.getSingleUser(id),
|
||||||
// ),
|
// ),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset(
|
child: Tooltip(
|
||||||
'assets/images/IconsImg/edit.png',
|
message: 'Delete Hotel Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// final userId = getUserId(user['user_id']);
|
// final userId = getUserId(user['user_id']);
|
||||||
// final usersData = await getUserDetails(userId);
|
// final usersData = await getUserDetails(userId);
|
||||||
|
|||||||
@ -245,14 +245,26 @@ class AccomodationListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Accomodation"),
|
onTap: () => onOpen(true, item, "Accomodation"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Accomodation Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteAccommodation(item),
|
onTap: () => onDeleteAccommodation(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Accommodation Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -224,14 +224,26 @@ class BusListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Bus"),
|
onTap: () => onOpen(true, item, "Bus"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Edit Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteBus(item),
|
onTap: () => onDeleteBus(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Bus Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -290,14 +290,26 @@ class _FlightListWidgetState extends State<FlightListWidget> {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => widget.onOpen(true, item, "Flight"),
|
onTap: () => widget.onOpen(true, item, "Flight"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Flight Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => widget.onDeleteFlight(item),
|
onTap: () => widget.onDeleteFlight(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Flight Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -261,14 +261,26 @@ class ForexListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Forex"),
|
onTap: () => onOpen(true, item, "Forex"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Forex Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteForex(item),
|
onTap: () => onDeleteForex(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Forex Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
item['forex_id'] != null
|
item['forex_id'] != null
|
||||||
? IconButton(
|
? IconButton(
|
||||||
|
|||||||
@ -202,14 +202,26 @@ class InsuranceListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Insurance"),
|
onTap: () => onOpen(true, item, "Insurance"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Insurance Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteInsurance(item),
|
onTap: () => onDeleteInsurance(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Insurance Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -445,14 +457,26 @@ class InsuranceListWidget extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Insurance"),
|
onTap: () => onOpen(true, item, "Insurance"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Insurance Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteInsurance(item),
|
onTap: () => onDeleteInsurance(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Insurance Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.keyboard_arrow_down_outlined,
|
icon: Icon(Icons.keyboard_arrow_down_outlined,
|
||||||
|
|||||||
@ -162,14 +162,26 @@ class MiscellaneousListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Miscellaneous"),
|
onTap: () => onOpen(true, item, "Miscellaneous"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Miscellaneous Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Miscellaneous"),
|
onTap: () => onOpen(true, item, "Miscellaneous"),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Miscellaneous Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -246,14 +246,26 @@ class TaxiListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Taxi"),
|
onTap: () => onOpen(true, item, "Taxi"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Taxi Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => (item),
|
onTap: () => (item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Taxi Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -333,14 +333,26 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => widget.onOpen(true, item, "Train"),
|
onTap: () => widget.onOpen(true, item, "Train"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Train Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => widget.onDeleteTrain(item),
|
onTap: () => widget.onDeleteTrain(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Train Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -301,14 +301,26 @@ class VisaListWidget extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Visa"),
|
onTap: () => onOpen(true, item, "Visa"),
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit Visa Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteMiscellaneous(item),
|
onTap: () => onDeleteMiscellaneous(item),
|
||||||
child: Image.asset('assets/images/IconsImg/delete.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Delete Visa Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -106,6 +106,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
|
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
|
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredPlans: $filteredPlans");
|
print("filteredPlans: $filteredPlans");
|
||||||
}
|
}
|
||||||
@ -827,6 +828,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
Icons.remove_red_eye,
|
Icons.remove_red_eye,
|
||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'View The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context); // Close popup manually
|
context); // Close popup manually
|
||||||
@ -845,6 +847,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15),
|
||||||
|
tooltip: 'Edit Trip/Plans Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ApiService.viewPlan(
|
ApiService.viewPlan(
|
||||||
@ -857,6 +860,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.cancel_rounded,
|
Icons.cancel_rounded,
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Cancellation The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
deletePlan(plan.planId);
|
deletePlan(plan.planId);
|
||||||
@ -866,6 +870,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
icon: Icon(Icons.download,
|
icon: Icon(Icons.download,
|
||||||
color: Color(0xFF114D8B),
|
color: Color(0xFF114D8B),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Download The Trip Comments',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
apiService.getPdfDownload(
|
apiService.getPdfDownload(
|
||||||
@ -878,6 +883,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
size: 11,
|
size: 11,
|
||||||
),
|
),
|
||||||
|
tooltip: 'Trip Comments',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -1023,6 +1029,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
Icons.remove_red_eye,
|
Icons.remove_red_eye,
|
||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'View The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(
|
Navigator.pop(
|
||||||
context); // Close popup manually
|
context); // Close popup manually
|
||||||
@ -1041,6 +1048,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15),
|
height: 15),
|
||||||
|
tooltip: 'Edit Trip/plan Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ApiService.viewPlan(
|
ApiService.viewPlan(
|
||||||
@ -1053,6 +1061,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.cancel_rounded,
|
Icons.cancel_rounded,
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Cancellation The Trip Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
deletePlan(plan.planId);
|
deletePlan(plan.planId);
|
||||||
@ -1062,6 +1071,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
icon: Icon(Icons.download,
|
icon: Icon(Icons.download,
|
||||||
color: Color(0xFF114D8B),
|
color: Color(0xFF114D8B),
|
||||||
size: 18),
|
size: 18),
|
||||||
|
tooltip: 'Download The Trip Comments',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
apiService.getPdfDownload(
|
apiService.getPdfDownload(
|
||||||
@ -1074,6 +1084,7 @@ class _ListPlansState extends State<ListPlans> {
|
|||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
size: 11,
|
size: 11,
|
||||||
),
|
),
|
||||||
|
tooltip: 'Trip Comments',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
428
lib/Screens/policy/policyListBackup.dart
Normal file
428
lib/Screens/policy/policyListBackup.dart
Normal file
@ -0,0 +1,428 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:frontend/Screens/group/group.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
|
import '../../config/apiUrl.dart';
|
||||||
|
import '../../routes/custom_appBar.dart';
|
||||||
|
import '../../routes/custom_drawer.dart';
|
||||||
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
|
||||||
|
class PolicyListBackup extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_PolicyListBackupState createState() => _PolicyListBackupState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PolicyListBackupState extends State<PolicyListBackup> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
|
|
||||||
|
List<dynamic>? apiAllGroups;
|
||||||
|
Color? layoutColor;
|
||||||
|
Color? bodyColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
loadAllGroups();
|
||||||
|
loadInitialData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadInitialData() async {
|
||||||
|
String? layoutString = await getLayoutColor();
|
||||||
|
String? bodyStringColor = await getBodyColor();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
layoutColor =
|
||||||
|
layoutString != null
|
||||||
|
? Color(int.parse(layoutString))
|
||||||
|
: Colors.redAccent;
|
||||||
|
|
||||||
|
bodyColor =
|
||||||
|
bodyStringColor != null
|
||||||
|
? Color(int.parse(bodyStringColor))
|
||||||
|
: Colors.white;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadAllGroups() async {
|
||||||
|
try {
|
||||||
|
final result = await apiService.fetchAllPolicy();
|
||||||
|
|
||||||
|
// Sort by policy_id descending (latest first)
|
||||||
|
result.sort((a, b) {
|
||||||
|
int idA = int.tryParse(a['policy_id'].toString()) ?? 0;
|
||||||
|
int idB = int.tryParse(b['policy_id'].toString()) ?? 0;
|
||||||
|
return idB.compareTo(idA); // latest first
|
||||||
|
});
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
apiAllGroups = result;
|
||||||
|
});
|
||||||
|
print("Fetched services: $apiAllGroups");
|
||||||
|
} catch (e) {
|
||||||
|
print('Error fetching role list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleActiveStatus(
|
||||||
|
Map<String, dynamic> policyData,
|
||||||
|
String policyId,
|
||||||
|
String currentStatus,
|
||||||
|
) async {
|
||||||
|
print("Toggling user status - $policyId (Current: $currentStatus)");
|
||||||
|
|
||||||
|
final String apiUrlData =
|
||||||
|
'$apiUrl/api/policy/createOrUpdate'; // API for updating user
|
||||||
|
final String? token = await getToken();
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
print("Error: Token not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle status: If active ("1"), set to inactive ("0"); otherwise, activate ("1")
|
||||||
|
String newStatus = (currentStatus == "1") ? "0" : "1";
|
||||||
|
|
||||||
|
print("STatus 1 - $newStatus");
|
||||||
|
|
||||||
|
final int? selectedPolicyId;
|
||||||
|
|
||||||
|
if (policyId.isNotEmpty) {
|
||||||
|
selectedPolicyId = int.tryParse(policyId);
|
||||||
|
policyData['policy_id'] = selectedPolicyId; // Add only if updating
|
||||||
|
policyData['is_active'] = newStatus; // Add only if updating
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await http.post(
|
||||||
|
Uri.parse(apiUrlData),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: jsonEncode(policyData), // Convert map to JSON
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
print("policyData submitted successfully!");
|
||||||
|
print("Response: ${response.body}");
|
||||||
|
|
||||||
|
loadAllGroups();
|
||||||
|
} else {
|
||||||
|
print("Failed to submit policyData. Status: ${response.statusCode}");
|
||||||
|
print("Error: ${response.body}");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print(" Error submitting policyData: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void deletePolicy(Map<String, dynamic> policydata, policyId, status) {
|
||||||
|
print("policyId : $policyId");
|
||||||
|
print("policystatus: $status");
|
||||||
|
print("policysData: $policydata");
|
||||||
|
|
||||||
|
// handleActiveStatus(groupdata, groupId, status);
|
||||||
|
print("Calling handleActiveStatus with: id=$policyId, status=$status");
|
||||||
|
handleActiveStatus(policydata, policyId.toString(), status.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future<void> deleteGroupFromApi(int groupId) async {
|
||||||
|
// try {
|
||||||
|
// await apiService.deleteGroup(groupId); // your delete API call
|
||||||
|
// deleteGroup(groupId); // remove from UI list
|
||||||
|
// } catch (e) {
|
||||||
|
// print('Error deleting group: $e');
|
||||||
|
// }
|
||||||
|
// }'
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ResponsiveBuilder(
|
||||||
|
builder: (context, sizingInfo) {
|
||||||
|
bool isDesktop =
|
||||||
|
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Color(0xFFf5f5f5),
|
||||||
|
appBar: CustomAppBar(isDesktop: isDesktop),
|
||||||
|
drawer: CustomDrawer(isDesktop: false),
|
||||||
|
body: Padding(
|
||||||
|
padding:
|
||||||
|
isDesktop
|
||||||
|
? EdgeInsets.symmetric(
|
||||||
|
horizontal:
|
||||||
|
MediaQuery.of(context).size.width *
|
||||||
|
0.1, // 30% of screen width as horizontal padding
|
||||||
|
vertical:
|
||||||
|
MediaQuery.of(context).size.height *
|
||||||
|
0, // 5% of screen height as vertical padding
|
||||||
|
)
|
||||||
|
: EdgeInsets.all(0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
|
Expanded(child: buildGroupList(isDesktop)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildGroupList(bool isDesktop) {
|
||||||
|
return Container(
|
||||||
|
margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null,
|
||||||
|
padding: const EdgeInsets.only(left: 10, right: 10, top: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
|
||||||
|
),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// // color: Colors.amber,
|
||||||
|
// color: Color(0xFFE1F5FE),
|
||||||
|
// // color: bodyColor,
|
||||||
|
// border: Border.all(
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
// color: Colors.white,
|
||||||
|
// width: 3.5)),
|
||||||
|
child: buildGroupListLayout(isDesktop),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildGroupListLayout(bool isDesktop) {
|
||||||
|
return Container(
|
||||||
|
// margin: isDesktop
|
||||||
|
// ? EdgeInsets.all(10.0)
|
||||||
|
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
|
||||||
|
// padding: const EdgeInsets.all(10),
|
||||||
|
height:
|
||||||
|
isDesktop
|
||||||
|
? MediaQuery.of(context).size.height * 0.98
|
||||||
|
: MediaQuery.of(context).size.height,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: isDesktop
|
||||||
|
// ? Border.all(
|
||||||
|
// width: 2,
|
||||||
|
// color: Colors.white,
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
// )
|
||||||
|
// : null,
|
||||||
|
// color: Colors.white,
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
//
|
||||||
|
// // color: Colors.amber,
|
||||||
|
// ),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Policy List',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: isDesktop ? 16 : 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
backgroundColor: Color(0xFF114D8B),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
// side: BorderSide(color: , width: 1),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
// List<dynamic> users = await futureUsers;
|
||||||
|
context.go('/Policy');
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'New Policy',
|
||||||
|
style: GoogleFonts.poppins(fontSize: 12),
|
||||||
|
),
|
||||||
|
SizedBox(width: 5),
|
||||||
|
Icon(Icons.add_circle_outline_rounded, color: Colors.white),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.8,
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
// margin: const EdgeInsets.only(bottom: 10),
|
||||||
|
color: Colors.white,
|
||||||
|
// color: Colors.red.shade100,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
child: Column(children: [buildGroupListView(isDesktop)]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Widget buildGroupListView(bool isDesktop) {
|
||||||
|
// return Container(
|
||||||
|
// child: Text("DAta"),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
Widget buildGroupListView(bool isDesktop) {
|
||||||
|
if (apiAllGroups == null || apiAllGroups!.isEmpty) {
|
||||||
|
return Center(child: Text("No Policy Found."));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: apiAllGroups!.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final policy = apiAllGroups![index];
|
||||||
|
return Card(
|
||||||
|
// color: bodyColor,
|
||||||
|
// color: Color(0xFFF5F5F5),
|
||||||
|
color: Colors.white,
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Text(
|
||||||
|
"Policy Name",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11.5,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Text(
|
||||||
|
"Policy Type",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11.5,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Expanded(flex: 1, child: Text("${policy['created_by']}")),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 4),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Text(
|
||||||
|
"${policy['name']}",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Text(
|
||||||
|
policy['domestic'] == "1"
|
||||||
|
? "Domestic"
|
||||||
|
: "International",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Expanded(flex: 1, child: Text("${policy['created_by']}")),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
final rawId = policy['policy_id'];
|
||||||
|
final intPolicyId =
|
||||||
|
rawId is int
|
||||||
|
? rawId
|
||||||
|
: int.tryParse(rawId.toString()) ?? 0;
|
||||||
|
|
||||||
|
Map<String, dynamic> policyData = await apiService
|
||||||
|
.getSinglePolicy(intPolicyId);
|
||||||
|
|
||||||
|
print("PolicyDATa: $policyData");
|
||||||
|
|
||||||
|
context.go("/Policy", extra: policyData);
|
||||||
|
},
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 5),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
final idStr = policy['policy_id'];
|
||||||
|
final id = int.tryParse(idStr.toString());
|
||||||
|
|
||||||
|
if (id == null) {
|
||||||
|
print("group_id is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final status = policy['is_active'];
|
||||||
|
|
||||||
|
deletePolicy(policy, id, status);
|
||||||
|
},
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/delete.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -153,6 +153,7 @@ class TravellerListState extends State<TravellerList> {
|
|||||||
false) ||
|
false) ||
|
||||||
(isActiveStatus.contains(lowerQuery));
|
(isActiveStatus.contains(lowerQuery));
|
||||||
}).toList();
|
}).toList();
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredTraveller: $filteredTraveller");
|
print("filteredTraveller: $filteredTraveller");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1012,6 +1012,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
return OfficeDetails(
|
return OfficeDetails(
|
||||||
isDesktop: isDesktop, // pass isDesktop as a named argument
|
isDesktop: isDesktop, // pass isDesktop as a named argument
|
||||||
isViewMode: isViewMode,
|
isViewMode: isViewMode,
|
||||||
|
userIdApi:userIdApi,
|
||||||
controllers: controllers,
|
controllers: controllers,
|
||||||
errorMessages: errorMessages,
|
errorMessages: errorMessages,
|
||||||
selectedLevel: selectedLevel,
|
selectedLevel: selectedLevel,
|
||||||
@ -1062,12 +1063,14 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
errorMessages: errorMessages,
|
errorMessages: errorMessages,
|
||||||
travelDetails: travelDetailsDataFromAPI, // 👈 Pass this down
|
travelDetails: travelDetailsDataFromAPI, // 👈 Pass this down
|
||||||
passportFileUrlFromApi: passportFileUrlFromApi,
|
passportFileUrlFromApi: passportFileUrlFromApi,
|
||||||
|
userIdApi:userIdApi,
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return PersonalDetails(
|
return PersonalDetails(
|
||||||
personalDetailsKey: personalDetailsKey,
|
personalDetailsKey: personalDetailsKey,
|
||||||
isDesktop: isDesktop, // pass isDesktop as a named argument
|
isDesktop: isDesktop, // pass isDesktop as a named argument
|
||||||
isViewMode: isViewMode,
|
isViewMode: isViewMode,
|
||||||
|
userIdApi:userIdApi,
|
||||||
controllers: controllers,
|
controllers: controllers,
|
||||||
errorMessages: errorMessages,
|
errorMessages: errorMessages,
|
||||||
selectedGender: selectedGender,
|
selectedGender: selectedGender,
|
||||||
|
|||||||
@ -15,6 +15,8 @@ class OfficeDetails extends StatefulWidget {
|
|||||||
final Map<String, String> errorMessages;
|
final Map<String, String> errorMessages;
|
||||||
final bool isDesktop;
|
final bool isDesktop;
|
||||||
final bool isViewMode;
|
final bool isViewMode;
|
||||||
|
final String? userIdApi;
|
||||||
|
|
||||||
|
|
||||||
final ValueChanged<String?>? onLevelChanged;
|
final ValueChanged<String?>? onLevelChanged;
|
||||||
final ValueChanged<String?>? onDepartmentChanged;
|
final ValueChanged<String?>? onDepartmentChanged;
|
||||||
@ -48,6 +50,7 @@ class OfficeDetails extends StatefulWidget {
|
|||||||
this.onThirdApproverChanged,
|
this.onThirdApproverChanged,
|
||||||
this.selectedSubstituteApprover,
|
this.selectedSubstituteApprover,
|
||||||
this.onFirstSubsApproverChanged,
|
this.onFirstSubsApproverChanged,
|
||||||
|
this.userIdApi,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -154,6 +157,28 @@ class _OfficeDetailsState extends State<OfficeDetails> {
|
|||||||
fetchFindGroup();
|
fetchFindGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> apiCheckDuplicate(String label, String field, String value, String? userId) async {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (field == "employeeCode") {
|
||||||
|
field = "employee_code";
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await apiService.CheckDuplicate(label, field, value, userId);
|
||||||
|
if (response.isNotEmpty) {
|
||||||
|
_clearError(field);
|
||||||
|
widget.errorMessages[field] = response['message'] ?? "$label already exists";
|
||||||
|
print("Duplicate found: ${response['message']}");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_clearError(field);
|
||||||
|
print("No duplicates found.");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Error in checkDuplicate: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _clearError(String field) {
|
void _clearError(String field) {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.errorMessages.remove(field);
|
widget.errorMessages.remove(field);
|
||||||
@ -401,6 +426,7 @@ class _OfficeDetailsState extends State<OfficeDetails> {
|
|||||||
enabled: !widget.isViewMode,
|
enabled: !widget.isViewMode,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
_clearError("employeeCode");
|
_clearError("employeeCode");
|
||||||
|
apiCheckDuplicate("Employee Code", "employeeCode",value,widget.userIdApi);
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: "Employee Code",
|
labelText: "Employee Code",
|
||||||
|
|||||||
@ -157,6 +157,34 @@ class PersonalDetailsState extends State<PersonalDetails> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> apiCheckDuplicate(String label, String field, String value, String? userId) async {
|
||||||
|
try {
|
||||||
|
// Basic validation: Check mobile number length
|
||||||
|
if (field == "mobile_no" && value.length != 10) {
|
||||||
|
_clearError(field);
|
||||||
|
widget.errorMessages[field] = "$label is invalid";
|
||||||
|
print("Validation failed: $label is too short.");
|
||||||
|
return; // Skip the API call if input is invalid
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await apiService.CheckDuplicate(label, field, value, userId);
|
||||||
|
if (response.isNotEmpty) {
|
||||||
|
_clearError(field);
|
||||||
|
widget.errorMessages[field] = response['message'] ?? "$label already exists";
|
||||||
|
print("Duplicate found: ${response['message']}");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_clearError(field);
|
||||||
|
print("No duplicates found.");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Error in checkDuplicate: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _clearError(String field) {
|
void _clearError(String field) {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.errorMessages.remove(field);
|
widget.errorMessages.remove(field);
|
||||||
@ -1004,6 +1032,7 @@ class PersonalDetailsState extends State<PersonalDetails> {
|
|||||||
controller: widget.controllers["email"],
|
controller: widget.controllers["email"],
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
_clearError("email");
|
_clearError("email");
|
||||||
|
apiCheckDuplicate("Email", "email",value,widget.userIdApi);
|
||||||
},
|
},
|
||||||
enabled: !widget.isViewMode,
|
enabled: !widget.isViewMode,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -1054,6 +1083,7 @@ class PersonalDetailsState extends State<PersonalDetails> {
|
|||||||
enabled: !widget.isViewMode,
|
enabled: !widget.isViewMode,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
_clearError("mobile_no");
|
_clearError("mobile_no");
|
||||||
|
apiCheckDuplicate("Mobile Number", "mobile_no",value,widget.userIdApi);
|
||||||
},
|
},
|
||||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
|
|||||||
@ -31,6 +31,8 @@ class TravellerDetails extends StatefulWidget {
|
|||||||
final bool isViewMode;
|
final bool isViewMode;
|
||||||
final Map<String, dynamic>? travelDetails;
|
final Map<String, dynamic>? travelDetails;
|
||||||
final String? passportFileUrlFromApi;
|
final String? passportFileUrlFromApi;
|
||||||
|
final String? userIdApi;
|
||||||
|
|
||||||
|
|
||||||
const TravellerDetails({
|
const TravellerDetails({
|
||||||
Key? key,
|
Key? key,
|
||||||
@ -40,6 +42,7 @@ class TravellerDetails extends StatefulWidget {
|
|||||||
required this.isViewMode,
|
required this.isViewMode,
|
||||||
this.travelDetails,
|
this.travelDetails,
|
||||||
this.passportFileUrlFromApi,
|
this.passportFileUrlFromApi,
|
||||||
|
this.userIdApi,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
TravellerDetailsState createState() => TravellerDetailsState();
|
TravellerDetailsState createState() => TravellerDetailsState();
|
||||||
@ -146,6 +149,26 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> apiCheckDuplicate(String label, String field, String value, String? userId) async {
|
||||||
|
try {
|
||||||
|
if(field == "forex_card_num"){
|
||||||
|
field = "forex_pre_paid_card_number";
|
||||||
|
}
|
||||||
|
final response = await apiService.CheckDuplicate(label, field, value, userId);
|
||||||
|
if (response.isNotEmpty) {
|
||||||
|
_clearError(field);
|
||||||
|
widget.errorMessages[field] = response['message'] ?? "$label already exists";
|
||||||
|
print("Duplicate found: ${response['message']}");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_clearError(field);
|
||||||
|
print("No duplicates found.");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Error in checkDuplicate: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _clearError(String field) {
|
void _clearError(String field) {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.errorMessages.remove(field);
|
widget.errorMessages.remove(field);
|
||||||
@ -2308,6 +2331,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
enabled: !widget.isViewMode,
|
enabled: !widget.isViewMode,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
_clearError("forex_card_num");
|
_clearError("forex_card_num");
|
||||||
|
apiCheckDuplicate("Forex Pre-Paid Card Number", "forex_card_num",value,widget.userIdApi);
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: "Card Number",
|
labelText: "Card Number",
|
||||||
@ -2439,14 +2463,24 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
SizedBox(width: 25),
|
SizedBox(width: 25),
|
||||||
buildFrequentFlierInformation(entry),
|
buildFrequentFlierInformation(entry),
|
||||||
SizedBox(width: 15),
|
SizedBox(width: 15),
|
||||||
IconButton(
|
SizedBox(
|
||||||
icon: Icon(Icons.cancel, color: Colors.red, size: 15),
|
height: 60,
|
||||||
onPressed: () {
|
child: Center(
|
||||||
setState(() {
|
child: Padding(
|
||||||
removeFrequentFlierEntry(entry);
|
padding: EdgeInsets.only(top: 20, left: 8), // 👈 Add top padding here
|
||||||
});
|
child: IconButton(
|
||||||
},
|
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||||
|
tooltip: 'Cancel the Details',
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
removeFrequentFlierEntry(entry);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
@ -2457,7 +2491,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
buildFrequentFlierInformation(entry),
|
buildFrequentFlierInformation(entry),
|
||||||
SizedBox(width: 15),
|
SizedBox(width: 15),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.cancel, color: Colors.red, size: 15),
|
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||||
|
tooltip: 'Cancel the Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
removeFrequentFlierEntry(entry);
|
removeFrequentFlierEntry(entry);
|
||||||
@ -2738,22 +2773,30 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
child:
|
child:
|
||||||
widget.isDesktop
|
widget.isDesktop
|
||||||
? Row(
|
? Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
buildHotel(entry),
|
buildHotel(entry),
|
||||||
SizedBox(width: 25),
|
SizedBox(width: 25),
|
||||||
buildHotelMembershipNum(entry),
|
buildHotelMembershipNum(entry),
|
||||||
IconButton(
|
SizedBox(
|
||||||
icon: Icon(Icons.cancel, color: Colors.red, size: 15),
|
height: 60,
|
||||||
onPressed: () {
|
child: Center(
|
||||||
setState(() {
|
child: Padding(
|
||||||
// removeHotelLoyaltyEntry(localId);
|
padding: EdgeInsets.only(top: 20, left: 8), // 👈 Add top padding here
|
||||||
removeHotelLoyaltyEntry(entry);
|
child: IconButton(
|
||||||
});
|
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||||
},
|
tooltip: 'Cancel the Details',
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
removeHotelLoyaltyEntry(entry);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
)
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
: Column(
|
: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -2761,7 +2804,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
buildHotelMembershipNum(entry),
|
buildHotelMembershipNum(entry),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.cancel, color: Colors.red, size: 15),
|
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||||
|
tooltip: 'Cancel the Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
// removeHotelLoyaltyEntry(localId);
|
// removeHotelLoyaltyEntry(localId);
|
||||||
@ -2987,13 +3031,22 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
buildVisaValidFrom(entry),
|
buildVisaValidFrom(entry),
|
||||||
SizedBox(width: 15),
|
SizedBox(width: 15),
|
||||||
buildVisaValidUpTo(entry),
|
buildVisaValidUpTo(entry),
|
||||||
IconButton(
|
SizedBox(
|
||||||
icon: Icon(Icons.cancel, color: Colors.red, size: 15),
|
height: 60,
|
||||||
onPressed: () {
|
child: Center(
|
||||||
setState(() {
|
child: Padding(
|
||||||
removeVisaEntry(entry);
|
padding: EdgeInsets.only(top: 20, left: 8), // 👈 Add top padding here
|
||||||
});
|
child: IconButton(
|
||||||
},
|
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||||
|
tooltip: 'Cancel the Details',
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
removeVisaEntry(entry);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -3008,7 +3061,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
buildVisaValidUpTo(entry),
|
buildVisaValidUpTo(entry),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.cancel, color: Colors.red, size: 15),
|
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||||
|
tooltip: 'Cancel the Details',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
// visaRowIds.remove(id);
|
// visaRowIds.remove(id);
|
||||||
|
|||||||
@ -88,9 +88,9 @@ class OrganizationSettingState extends State<OrganizationSetting> {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'value': '/forexTexmplate',
|
'value': '/forexTexmplate',
|
||||||
'icon': Icons.group_add_outlined,
|
'icon': Icons.attach_money,
|
||||||
'label': 'Forex Template',
|
'label': 'Forex Template',
|
||||||
'description': 'Create and Edit Template',
|
'description': 'Edit Template',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'value': '/templateList',
|
'value': '/templateList',
|
||||||
|
|||||||
@ -1355,4 +1355,55 @@ class ApiService {
|
|||||||
throw Exception('Failed to load Hotel details');
|
throw Exception('Failed to load Hotel details');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------- User Management - CheckDuplicate ---------------
|
||||||
|
Future<Map<String, dynamic>> CheckDuplicate(
|
||||||
|
String label,
|
||||||
|
String field,
|
||||||
|
String value,
|
||||||
|
String? userId,
|
||||||
|
) async {
|
||||||
|
String apiUrldata;
|
||||||
|
if (userId == null || userId.isEmpty) {
|
||||||
|
apiUrldata = '$apiUrl/api/checkDuplicate?$field=$value';
|
||||||
|
} else {
|
||||||
|
apiUrldata = '$apiUrl/api/checkDuplicate?$field=$value&user_id=$userId';
|
||||||
|
}
|
||||||
|
|
||||||
|
final token = await getToken();
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse(apiUrldata),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
try {
|
||||||
|
final data = json.decode(response.body);
|
||||||
|
|
||||||
|
// Updated to match actual response structure
|
||||||
|
if (data['status'] == "exists") {
|
||||||
|
print("${data['field']} - $value already exists");
|
||||||
|
return {"message": "$label already exists", "field": data['field']};
|
||||||
|
} else {
|
||||||
|
print("$label - $value is a new value");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Error parsing response: $e');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw Exception(
|
||||||
|
'Failed to load checkDuplicate data. Status code: ${response.statusCode}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------- User Management - CheckDuplicate end here ----------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,13 @@ class UserActionsMenu extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Icon(Icons.remove_red_eye,
|
child: Tooltip(
|
||||||
color: Color(0xFF475569), size: 18),
|
message: 'View User Details',
|
||||||
|
child: Icon(Icons.remove_red_eye,
|
||||||
|
color: Color(0xFF475569), size: 18)
|
||||||
|
),
|
||||||
|
// child: Icon(Icons.remove_red_eye,
|
||||||
|
// color: Color(0xFF475569), size: 18,),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.pop(context); // Close the menu
|
Navigator.pop(context); // Close the menu
|
||||||
final userId = getUserId(user['user_id']);
|
final userId = getUserId(user['user_id']);
|
||||||
@ -55,8 +60,14 @@ class UserActionsMenu extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Image.asset('assets/images/IconsImg/edit.png',
|
child: Tooltip(
|
||||||
width: 20, height: 15),
|
message: 'Edit User Details',
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.pop(context); // Close the menu
|
Navigator.pop(context); // Close the menu
|
||||||
final userId = getUserId(user['user_id']);
|
final userId = getUserId(user['user_id']);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user