From de7491cc6eeea11a2a733212499163bdcf467bf6 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Wed, 3 Sep 2025 10:02:29 +0530 Subject: [PATCH] API-SECURITY --- .../allTrips/list_all_plans_24july2025.dart | 3 + lib/Screens/allTrips/remarks_list.dart | 30 +- lib/Screens/approvals/approval_list.dart | 136 ------- lib/Screens/group/group.dart | 64 --- lib/Screens/group/groupListBackUp.dart | 366 ++++++++++-------- lib/Screens/myTemplates/template.dart | 61 +-- lib/Screens/myTemplates/templateForex.dart | 6 +- lib/Screens/myTemplates/templateForexOld.dart | 160 ++++---- lib/Screens/organization/mailSettings.dart | 2 - lib/Screens/perdiem_amount/forexDetails.dart | 3 - lib/Screens/perdiem_amount/forex_list.dart | 24 +- lib/Screens/plans/list_plans.dart | 44 --- lib/Screens/policy/policyCriteria.dart | 45 --- .../listTravelAgent.dart | 32 +- lib/Screens/userManagement/user_List.dart | 29 -- lib/config/apiUrl.dart | 5 +- lib/utils/travelAgent_remarks.dart | 1 - web/index.html | 2 +- 18 files changed, 347 insertions(+), 666 deletions(-) diff --git a/lib/Screens/allTrips/list_all_plans_24july2025.dart b/lib/Screens/allTrips/list_all_plans_24july2025.dart index 7e25490..f3415df 100644 --- a/lib/Screens/allTrips/list_all_plans_24july2025.dart +++ b/lib/Screens/allTrips/list_all_plans_24july2025.dart @@ -221,6 +221,7 @@ class _ListAllPlansState extends State { headers: { 'Authorization': 'Bearer $token', // Add token here 'Content-Type': 'application/json', + 'app-signature': 'ts-traveltool-2025-signature-123456', }, ); @@ -253,6 +254,7 @@ class _ListAllPlansState extends State { headers: { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json', + 'app-signature': 'ts-traveltool-2025-signature-123456', }, body: jsonEncode(planData), // Convert map to JSON ); @@ -308,6 +310,7 @@ class _ListAllPlansState extends State { headers: { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json', + 'app-signature': 'ts-traveltool-2025-signature-123456', }, ); diff --git a/lib/Screens/allTrips/remarks_list.dart b/lib/Screens/allTrips/remarks_list.dart index 6a32f1d..e50c097 100644 --- a/lib/Screens/allTrips/remarks_list.dart +++ b/lib/Screens/allTrips/remarks_list.dart @@ -26,21 +26,21 @@ class CommentModalList extends StatefulWidget { class _CommentModalListState extends State { late Future>> _commentsFuture; - Future>> fetchComments1() async { - final response = await http.get( - Uri.parse( - '$apiUrl/api/plans/getRemarksByPlanId?plan_id=${widget.planId}', - ), - ); - - if (response.statusCode == 200) { - final jsonData = json.decode(response.body); - final List dataList = jsonData['data']; - return dataList.cast>(); - } else { - throw Exception('Failed to load comments'); - } - } + // Future>> fetchComments1() async { + // final response = await http.get( + // Uri.parse( + // '$apiUrl/api/plans/getRemarksByPlanId?plan_id=${widget.planId}', + // ), + // ); + // + // if (response.statusCode == 200) { + // final jsonData = json.decode(response.body); + // final List dataList = jsonData['data']; + // return dataList.cast>(); + // } else { + // throw Exception('Failed to load comments'); + // } + // } Future>> fetchComments() async { // final String apiUrldata = diff --git a/lib/Screens/approvals/approval_list.dart b/lib/Screens/approvals/approval_list.dart index f8fa76d..7b7d3b1 100644 --- a/lib/Screens/approvals/approval_list.dart +++ b/lib/Screens/approvals/approval_list.dart @@ -180,15 +180,9 @@ class _ApprovalListState extends State { // Fetch API Data Future> fetchPlans() async { - // final String apiUrldata = '$apiUrl/api/plans'; - // final String apiUrldata = '$apiUrl/api/plans?user_id=$userId'; - // final String apiUrldata = '$apiUrl/api/plans?user_id=$userId'; - // final String apiUrldata = '$apiUrl/api/plans?org_id=$orgId&user_id=$userId'; - final String apiUrldata = '$apiUrl/api/plans/findApprovalList?user_id=$userId&org_id=$orgId'; - // api/plans?org_id=1&user_id=1 // final token = await getToken(); if (token == null) { @@ -380,136 +374,6 @@ class _ApprovalListState extends State { print("filteredPlans: $filteredPlans"); } - // Future _showDetails(Id) async { - // _dialogShown = true; - // final String apiUrldata = '$apiUrl/api/plans/get_plan_approval_status?plan_id=$Id'; - // final String? token = await getToken(); - // - // if (token == null) { - // print('Token not found. Please log in.'); - // successList = { - // "model_heading": "Error - Token not found", - // "approver_data": [], - // }; - // } else { - // try { - // final response = await http.get( - // Uri.parse(apiUrldata), - // headers: { - // 'Authorization': 'Bearer $token', - // 'Content-Type': 'application/json', - // }, - // ); - // - // if (response.statusCode == 200) { - // final data = json.decode(response.body); - // print(data['data']); - // successList = data['data']; - // } else { - // print('Failed to load'); - // successList = { - // "model_heading": "Error - Failed to load data", - // "approver_data": [], - // }; - // } - // } catch (e) { - // print('Exception occurred: $e'); - // successList = { - // "model_heading": "Error - Something went wrong", - // "approver_data": [], - // }; - // } - // } - // - // showDialog( - // context: context, - // builder: (context) => AlertDialog( - // title: Text( - // successList["model_heading"] ?? '', - // style: GoogleFonts.poppins( - // fontSize: 18, - // fontWeight: FontWeight.w600, - // color: Colors.black, - // ), - // overflow: TextOverflow.ellipsis, - // ), - // content: SingleChildScrollView( - // child: Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // // Text( - // // successList["Trip Title"] ?? '', - // // style: TextStyle(fontWeight: FontWeight.bold), - // // ), - // const SizedBox(height: 8), - // (successList["approver_data"] != null && successList["approver_data"].isNotEmpty) - // ? SizedBox( - // height: 250, - // child: SingleChildScrollView( - // scrollDirection: Axis.horizontal, - // child: SingleChildScrollView( - // scrollDirection: Axis.vertical, - // child: DataTable( - // columns: [ - // DataColumn(label: Text('S.No', style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w600, color: Colors.black, - // ))), - // DataColumn(label: Text('ID', style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w600, color: Colors.black, - // ))), - // DataColumn(label: Text('Reason', style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w600, color: Colors.black, - // ))), - // ], - // rows: successList["approver_data"].asMap().entries.map((entry) { - // final index = entry.key + 1; - // final rawData = entry.value['a1_id']; - // final data = (rawData == null || rawData.toString().trim().isEmpty) ? '-' : rawData.toString(); - // final reason = entry.value['a1_status'] ?? 'Unknown'; - // - // return DataRow( - // cells: [ - // DataCell(Text('$index', style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w400, color: Colors.black, - // ))), - // DataCell(SizedBox( - // width: 180, - // child: Text(data, style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w400, color: Colors.black, - // ), overflow: TextOverflow.ellipsis), - // )), - // DataCell(SizedBox( - // width: 280, - // child: Text(reason, style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w400, color: Colors.black, - // ), overflow: TextOverflow.ellipsis), - // )), - // ], - // ); - // }).toList(), - // ), - // ), - // ), - // ) - // : Text("-- no data. --", style: GoogleFonts.poppins( - // fontSize: 14, fontWeight: FontWeight.w200, color: Colors.black, - // )), - // ], - // ), - // ), - // actions: [ - // TextButton( - // onPressed: () { - // Navigator.pop(context); - // _dialogShown = false; - // }, - // child: Text("Close"), - // ), - // ], - // ), - // ); - // } - Future _showDetails(id) async { _dialogShown = true; final String apiUrldata = diff --git a/lib/Screens/group/group.dart b/lib/Screens/group/group.dart index 5d8a252..dc2fd83 100644 --- a/lib/Screens/group/group.dart +++ b/lib/Screens/group/group.dart @@ -276,70 +276,6 @@ class _groupState extends State { } } - // Future postGroupData(Map groupData) async { - // // final String apiUrldata = '$apiUrl/api/groups/create'; - // - // final token = await getToken(); // Fetch token - // - // print("postGroupData- ${widget.group?['group_id']}"); - // - // if (selectedGroupId == null) { - // print("selectedGroupId is null. Cannot proceed."); - // return; - // } - // - // final int? groupId = int.tryParse(selectedGroupId!); - // if (groupId == null) { - // print("groupId is invalid. selectedGroupId = $selectedGroupId"); - // return; - // } - // - // final bool isEdit = widget.group != null && widget.group!.isNotEmpty; - // print("postGroupData1 - $selectedGroupId"); - // - // // Build correct API URL - // final String apiUrlData = isEdit - // ? '$apiUrl/api/groups/update/$groupId' // Update API - // : '$apiUrl/api/groups/create'; - // - // if (token == null) { - // throw Exception('Token not found. Please log in.'); - // } - // - // try { - // final response = await (isEdit - // ? http.put( - // // <-- Use PUT for update - // Uri.parse(apiUrlData), - // headers: { - // 'Authorization': 'Bearer $token', - // 'Content-Type': 'application/json', - // }, - // body: jsonEncode(groupData), - // ) - // : http.post( - // Uri.parse(apiUrlData), - // headers: { - // 'Authorization': 'Bearer $token', - // 'Content-Type': 'application/json', - // }, - // body: jsonEncode(groupData), // Convert map to JSON - // )); - // - // if (response.statusCode == 200 || response.statusCode == 201) { - // print("Plan submitted successfully!"); - // print("Response: ${response.body}"); - // - // context.go('/group'); - // } else { - // print("Failed to submit plan. Status: ${response.statusCode}"); - // print("Error: ${response.body}"); - // } - // } catch (e) { - // print(" Error submitting plan: $e"); - // } - // } - @override Widget build(BuildContext context) { return ResponsiveBuilder( diff --git a/lib/Screens/group/groupListBackUp.dart b/lib/Screens/group/groupListBackUp.dart index ab02409..5036d8b 100644 --- a/lib/Screens/group/groupListBackUp.dart +++ b/lib/Screens/group/groupListBackUp.dart @@ -41,13 +41,15 @@ class _GroupListBackUpState extends State { String? bodyStringColor = await getBodyColor(); setState(() { - layoutColor = layoutString != null - ? Color(int.parse(layoutString)) - : Colors.redAccent; + layoutColor = + layoutString != null + ? Color(int.parse(layoutString)) + : Colors.redAccent; - bodyColor = bodyStringColor != null - ? Color(int.parse(bodyStringColor)) - : Colors.white; + bodyColor = + bodyStringColor != null + ? Color(int.parse(bodyStringColor)) + : Colors.white; }); } @@ -90,9 +92,10 @@ class _GroupListBackUpState extends State { headers: { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json', + 'app-signature': 'ts-traveltool-2025-signature-123456', }, body: jsonEncode({ - "is_active": newStatus // Set new status dynamically + "is_active": newStatus, // Set new status dynamically }), ); @@ -133,32 +136,38 @@ class _GroupListBackUpState extends State { @override Widget build(BuildContext context) { - return ResponsiveBuilder(builder: (context, sizingInfo) { - bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; + 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)) - ], + 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) { @@ -192,9 +201,10 @@ class _GroupListBackUpState extends State { // ? 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, + height: + isDesktop + ? MediaQuery.of(context).size.height * 0.98 + : MediaQuery.of(context).size.height, // decoration: BoxDecoration( // border: isDesktop // ? Border.all( @@ -244,34 +254,26 @@ class _GroupListBackUpState extends State { // context.go('/CreateGroup'); showDialog( context: context, - builder: (context) => GroupData( - isDesktop: isDesktop, - groupId: null, - layoutColor: layoutColor!, - fetchGetGroup: refreshData - ), + 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(width: 5), + Icon(Icons.add_circle_outline_rounded, color: Colors.white), ], ), ), ], ), - SizedBox( - height: 5, - ), + SizedBox(height: 5), Row( children: [ Expanded( @@ -283,16 +285,12 @@ class _GroupListBackUpState extends State { // color: Colors.red.shade100, child: SingleChildScrollView( scrollDirection: Axis.vertical, - child: Column( - children: [ - buildGroupListView(isDesktop), - ], - ), + child: Column(children: [buildGroupListView(isDesktop)]), ), ), ), ], - ) + ), ], ), ); @@ -309,124 +307,164 @@ class _GroupListBackUpState extends State { 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)), + 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( + "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( + "International Policy", + style: GoogleFonts.poppins( + fontSize: 11.5, + fontWeight: FontWeight.w400, + ), ), - Expanded( - child: Text("Description", - 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)), + ), + ], + ), + 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['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"); + ), + 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), + // 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()); + ), + 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), + 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, ), - ], - ), - ], - ), + ), + ], + ), + ], ), - ); + ), + ); }, ); } diff --git a/lib/Screens/myTemplates/template.dart b/lib/Screens/myTemplates/template.dart index 6a0a5ec..cae70e0 100644 --- a/lib/Screens/myTemplates/template.dart +++ b/lib/Screens/myTemplates/template.dart @@ -66,7 +66,6 @@ class TemplateState extends State