API-SECURITY

This commit is contained in:
venbaittech 2025-09-03 10:02:29 +05:30
parent 6f251973a5
commit de7491cc6e
18 changed files with 347 additions and 666 deletions

View File

@ -221,6 +221,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
headers: { headers: {
'Authorization': 'Bearer $token', // Add token here 'Authorization': 'Bearer $token', // Add token here
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
); );
@ -253,6 +254,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
body: jsonEncode(planData), // Convert map to JSON body: jsonEncode(planData), // Convert map to JSON
); );
@ -308,6 +310,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
); );

View File

@ -26,21 +26,21 @@ class CommentModalList extends StatefulWidget {
class _CommentModalListState extends State<CommentModalList> { class _CommentModalListState extends State<CommentModalList> {
late Future<List<Map<String, dynamic>>> _commentsFuture; late Future<List<Map<String, dynamic>>> _commentsFuture;
Future<List<Map<String, dynamic>>> fetchComments1() async { // Future<List<Map<String, dynamic>>> fetchComments1() async {
final response = await http.get( // final response = await http.get(
Uri.parse( // Uri.parse(
'$apiUrl/api/plans/getRemarksByPlanId?plan_id=${widget.planId}', // '$apiUrl/api/plans/getRemarksByPlanId?plan_id=${widget.planId}',
), // ),
); // );
//
if (response.statusCode == 200) { // if (response.statusCode == 200) {
final jsonData = json.decode(response.body); // final jsonData = json.decode(response.body);
final List<dynamic> dataList = jsonData['data']; // final List<dynamic> dataList = jsonData['data'];
return dataList.cast<Map<String, dynamic>>(); // return dataList.cast<Map<String, dynamic>>();
} else { // } else {
throw Exception('Failed to load comments'); // throw Exception('Failed to load comments');
} // }
} // }
Future<List<Map<String, dynamic>>> fetchComments() async { Future<List<Map<String, dynamic>>> fetchComments() async {
// final String apiUrldata = // final String apiUrldata =

View File

@ -180,15 +180,9 @@ class _ApprovalListState extends State<ApprovalList> {
// Fetch API Data // Fetch API Data
Future<List<Plan>> fetchPlans() async { Future<List<Plan>> 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 = final String apiUrldata =
'$apiUrl/api/plans/findApprovalList?user_id=$userId&org_id=$orgId'; '$apiUrl/api/plans/findApprovalList?user_id=$userId&org_id=$orgId';
// api/plans?org_id=1&user_id=1
// final token = await getToken(); // final token = await getToken();
if (token == null) { if (token == null) {
@ -380,136 +374,6 @@ class _ApprovalListState extends State<ApprovalList> {
print("filteredPlans: $filteredPlans"); print("filteredPlans: $filteredPlans");
} }
// Future<void> _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<void> _showDetails(id) async { Future<void> _showDetails(id) async {
_dialogShown = true; _dialogShown = true;
final String apiUrldata = final String apiUrldata =

View File

@ -276,70 +276,6 @@ class _groupState extends State<Group> {
} }
} }
// Future<void> postGroupData(Map<String, dynamic> 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ResponsiveBuilder( return ResponsiveBuilder(

View File

@ -41,13 +41,15 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
String? bodyStringColor = await getBodyColor(); String? bodyStringColor = await getBodyColor();
setState(() { setState(() {
layoutColor = layoutString != null layoutColor =
? Color(int.parse(layoutString)) layoutString != null
: Colors.redAccent; ? Color(int.parse(layoutString))
: Colors.redAccent;
bodyColor = bodyStringColor != null bodyColor =
? Color(int.parse(bodyStringColor)) bodyStringColor != null
: Colors.white; ? Color(int.parse(bodyStringColor))
: Colors.white;
}); });
} }
@ -90,9 +92,10 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
body: jsonEncode({ body: jsonEncode({
"is_active": newStatus // Set new status dynamically "is_active": newStatus, // Set new status dynamically
}), }),
); );
@ -133,32 +136,38 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ResponsiveBuilder(builder: (context, sizingInfo) { return ResponsiveBuilder(
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; builder: (context, sizingInfo) {
bool isDesktop =
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
return Scaffold( return Scaffold(
// backgroundColor: Colors.white, // backgroundColor: Colors.white,
backgroundColor: Color(0xFFf5f5f5), backgroundColor: Color(0xFFf5f5f5),
appBar: CustomAppBar(isDesktop: isDesktop), appBar: CustomAppBar(isDesktop: isDesktop),
drawer: CustomDrawer(isDesktop: false), drawer: CustomDrawer(isDesktop: false),
body: Padding( body: Padding(
padding: isDesktop padding:
? EdgeInsets.symmetric( isDesktop
horizontal: MediaQuery.of(context).size.width * ? EdgeInsets.symmetric(
0.1, // 30% of screen width as horizontal padding horizontal:
vertical: MediaQuery.of(context).size.height * MediaQuery.of(context).size.width *
0, // 5% of screen height as vertical padding 0.1, // 30% of screen width as horizontal padding
) vertical:
: EdgeInsets.all(8), MediaQuery.of(context).size.height *
child: Row( 0, // 5% of screen height as vertical padding
children: [ )
// if (isDesktop) CustomDrawer(isDesktop: true), : EdgeInsets.all(8),
Expanded(child: buildGroupListLayout(isDesktop)) child: Row(
], children: [
// if (isDesktop) CustomDrawer(isDesktop: true),
Expanded(child: buildGroupListLayout(isDesktop)),
],
),
), ),
), );
); },
}); );
} }
Widget buildGroupListLayout(bool isDesktop) { Widget buildGroupListLayout(bool isDesktop) {
@ -192,9 +201,10 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
// ? EdgeInsets.all(10.0) // ? EdgeInsets.all(10.0)
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
// padding: const EdgeInsets.all(10), // padding: const EdgeInsets.all(10),
height: isDesktop height:
? MediaQuery.of(context).size.height * 0.98 isDesktop
: MediaQuery.of(context).size.height, ? MediaQuery.of(context).size.height * 0.98
: MediaQuery.of(context).size.height,
// decoration: BoxDecoration( // decoration: BoxDecoration(
// border: isDesktop // border: isDesktop
// ? Border.all( // ? Border.all(
@ -244,34 +254,26 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
// context.go('/CreateGroup'); // context.go('/CreateGroup');
showDialog( showDialog(
context: context, context: context,
builder: (context) => GroupData( builder:
isDesktop: isDesktop, (context) => GroupData(
groupId: null, isDesktop: isDesktop,
layoutColor: layoutColor!, groupId: null,
fetchGetGroup: refreshData layoutColor: layoutColor!,
), fetchGetGroup: refreshData,
),
); );
}, },
child: Row( child: Row(
children: [ children: [
Text('New Group', style: GoogleFonts.poppins(fontSize: 12)), Text('New Group', style: GoogleFonts.poppins(fontSize: 12)),
SizedBox( SizedBox(width: 5),
width: 5, Icon(Icons.add_circle_outline_rounded, color: Colors.white),
),
Icon(
Icons.add_circle_outline_rounded,
color: Colors.white,
),
], ],
), ),
), ),
], ],
), ),
SizedBox( SizedBox(height: 5),
height: 5,
),
Row( Row(
children: [ children: [
Expanded( Expanded(
@ -283,16 +285,12 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
// color: Colors.red.shade100, // color: Colors.red.shade100,
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
child: Column( child: Column(children: [buildGroupListView(isDesktop)]),
children: [
buildGroupListView(isDesktop),
],
),
), ),
), ),
), ),
], ],
) ),
], ],
), ),
); );
@ -309,124 +307,164 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
itemCount: apiAllGroups!.length, itemCount: apiAllGroups!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final group = apiAllGroups![index]; final group = apiAllGroups![index];
return Card( return Card(
// color: bodyColor, // color: bodyColor,
// color: Color(0xFFF5F5F5), // color: Color(0xFFF5F5F5),
color: Colors.white, color: Colors.white,
margin: EdgeInsets.symmetric(vertical: 6, horizontal: 10), margin: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Text("Group Name", child: Text(
style: GoogleFonts.poppins( "Group Name",
fontSize: 11.5, fontWeight: FontWeight.w400)), style: GoogleFonts.poppins(
fontSize: 11.5,
fontWeight: FontWeight.w400,
),
), ),
Expanded( ),
child: Text("Domestic Policy", Expanded(
style: GoogleFonts.poppins( child: Text(
fontSize: 11.5, fontWeight: FontWeight.w400)), "Domestic Policy",
style: GoogleFonts.poppins(
fontSize: 11.5,
fontWeight: FontWeight.w400,
),
), ),
Expanded( ),
child: Text("International Policy", Expanded(
style: GoogleFonts.poppins( child: Text(
fontSize: 11.5, fontWeight: FontWeight.w400)), "International Policy",
style: GoogleFonts.poppins(
fontSize: 11.5,
fontWeight: FontWeight.w400,
),
), ),
Expanded( ),
child: Text("Description", Expanded(
style: GoogleFonts.poppins( child: Text(
fontSize: 11.5, fontWeight: FontWeight.w400)), "Description",
style: GoogleFonts.poppins(
fontSize: 11.5,
fontWeight: FontWeight.w400,
),
), ),
], ),
), ],
SizedBox(height: 4), ),
Row( SizedBox(height: 4),
mainAxisAlignment: MainAxisAlignment.spaceBetween, Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expanded( children: [
child: Text("${group['name']}", Expanded(
style: GoogleFonts.poppins( child: Text(
fontSize: 13, fontWeight: FontWeight.w600)), "${group['name']}",
style: GoogleFonts.poppins(
fontSize: 13,
fontWeight: FontWeight.w600,
),
), ),
Expanded( ),
child: Text("${group['domestic_policy_name'] ?? 'N/A'}", Expanded(
style: GoogleFonts.poppins( child: Text(
fontSize: 13, fontWeight: FontWeight.w600)), "${group['domestic_policy_name'] ?? 'N/A'}",
style: GoogleFonts.poppins(
fontSize: 13,
fontWeight: FontWeight.w600,
),
), ),
Expanded( ),
child: Text("${group['international_policy_name']}", Expanded(
style: GoogleFonts.poppins( child: Text(
fontSize: 13, fontWeight: FontWeight.w600))), "${group['international_policy_name']}",
Expanded( style: GoogleFonts.poppins(
child: Text("${group['description'] ?? 'N/A'}", fontSize: 13,
style: GoogleFonts.poppins( fontWeight: FontWeight.w600,
fontSize: 13, fontWeight: FontWeight.w600))), ),
], ),
), ),
Row( Expanded(
mainAxisAlignment: MainAxisAlignment.end, child: Text(
children: [ "${group['description'] ?? 'N/A'}",
GestureDetector( style: GoogleFonts.poppins(
onTap: () async { fontSize: 13,
if (group['group_id'] != null) { fontWeight: FontWeight.w600,
final newGroupID = int.tryParse( ),
group['group_id'].toString()); ),
if (newGroupID != null) { ),
final data = await apiService.getGroupDetailsFind( ],
newGroupID); // Always an int ),
showDialog( Row(
context: context, mainAxisAlignment: MainAxisAlignment.end,
builder: (context) => children: [
GroupData( GestureDetector(
isDesktop: isDesktop, onTap: () async {
groupId: newGroupID, if (group['group_id'] != null) {
// Pass the ID final newGroupID = int.tryParse(
groupData: data, group['group_id'].toString(),
layoutColor: layoutColor!, );
fetchGetGroup: refreshData if (newGroupID != null) {
), final data = await apiService.getGroupDetailsFind(
); newGroupID,
} ); // Always an int
} else { showDialog(
print("something went wrong check properly"); 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: () { // onTap: () {
// context.go("/CreateGroup", extra: group); // context.go("/CreateGroup", extra: group);
// }, // },
child: Image.asset('assets/images/IconsImg/edit.png', child: Image.asset(
width: 20, height: 15), 'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
), ),
SizedBox( ),
width: 5, SizedBox(width: 5),
), GestureDetector(
GestureDetector( onTap: () {
onTap: () { final idStr = group['group_id'];
final idStr = group['group_id']; final id = int.tryParse(idStr.toString());
final id = int.tryParse(idStr.toString());
if (id == null) { if (id == null) {
print("group_id is null"); print("group_id is null");
return; return;
} }
final status = group['is_active']; final status = group['is_active'];
// print("GroupId : ${group['group_id']} "); // print("GroupId : ${group['group_id']} ");
deleteGroup(group, id, status); deleteGroup(group, id, status);
}, },
child: Image.asset('assets/images/IconsImg/delete.png', child: Image.asset(
width: 20, height: 15), 'assets/images/IconsImg/delete.png',
width: 20,
height: 15,
), ),
], ),
), ],
], ),
), ],
), ),
); ),
);
}, },
); );
} }

View File

@ -66,7 +66,6 @@ class TemplateState extends State<Template> {
Map<String, bool> focusStates = {}; Map<String, bool> focusStates = {};
bool isDisable = false; bool isDisable = false;
late QuillController _controller = QuillController.basic(); late QuillController _controller = QuillController.basic();
final FocusNode _focusNode = FocusNode(); final FocusNode _focusNode = FocusNode();
@ -109,8 +108,8 @@ class TemplateState extends State<Template> {
void initState() { void initState() {
super.initState(); super.initState();
_checkAuthAndLoadData(); _checkAuthAndLoadData();
focusNodes["subjectFocusNode"] = FocusNode(); focusNodes["subjectFocusNode"] = FocusNode();
focusStates["subjectFocused"] = false; focusStates["subjectFocused"] = false;
for (var key in focusNodes.keys) { for (var key in focusNodes.keys) {
_addFocusListener(focusNodes[key]!, (focus) { _addFocusListener(focusNodes[key]!, (focus) {
setState(() { setState(() {
@ -166,6 +165,7 @@ class TemplateState extends State<Template> {
}); });
}); });
} }
void loadinitializeData() async { void loadinitializeData() async {
orgId = await getOrgId(); orgId = await getOrgId();
userId = await getUserId(); userId = await getUserId();
@ -475,6 +475,7 @@ class TemplateState extends State<Template> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
body: jsonEncode(policyData), // Convert map to JSON body: jsonEncode(policyData), // Convert map to JSON
); );
@ -483,18 +484,21 @@ class TemplateState extends State<Template> {
print("policyData submitted successfully!"); print("policyData submitted successfully!");
print("Response: ${response.body}"); print("Response: ${response.body}");
setState(() { setState(() {
isDisable = false; }); isDisable = false;
});
context.go('/templateList'); context.go('/templateList');
} else { } else {
print("Failed to submit policyData. Status: ${response.statusCode}"); print("Failed to submit policyData. Status: ${response.statusCode}");
print("Error: ${response.body}"); print("Error: ${response.body}");
setState(() { setState(() {
isDisable = false; }); isDisable = false;
});
} }
} catch (e) { } catch (e) {
print(" Error submitting policyData: $e"); print(" Error submitting policyData: $e");
setState(() { setState(() {
isDisable = false; }); isDisable = false;
});
} }
} }
@ -571,22 +575,20 @@ class TemplateState extends State<Template> {
isDesktop: isDesktop, isDesktop: isDesktop,
breadcrumbItems: [ breadcrumbItems: [
BreadcrumbItem( BreadcrumbItem(
title: 'Org Settings', title: 'Org Settings',
tooltip: 'Go To Organization Settings', tooltip: 'Go To Organization Settings',
onTap: (context) { onTap: (context) {
context.go("/OrganizationSettings"); context.go("/OrganizationSettings");
} },
), ),
BreadcrumbItem( BreadcrumbItem(
title: 'Templates', title: 'Templates',
tooltip: 'Go To Templates', tooltip: 'Go To Templates',
onTap: (context) { onTap: (context) {
context.go("/templateList"); context.go("/templateList");
} },
),
BreadcrumbItem(
title: formatTemplateName(templateName),
), ),
BreadcrumbItem(title: formatTemplateName(templateName)),
], ],
), ),
], ],
@ -771,17 +773,18 @@ class TemplateState extends State<Template> {
SizedBox(width: 10), SizedBox(width: 10),
SizedBox( SizedBox(
child: ElevatedButton( child: ElevatedButton(
onPressed: isDisable onPressed:
? null isDisable
: () async { ? null
setState(() { : () async {
isDisable = true; setState(() {
}); isDisable = true;
});
await handleSubmit(); await handleSubmit();
// You can get text from commentController.text // You can get text from commentController.text
// Navigator.of(context).pop(); // Close the modal // Navigator.of(context).pop(); // Close the modal
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: layoutColor, backgroundColor: layoutColor,
// backgroundColor: widget.layoutColor, // backgroundColor: widget.layoutColor,

View File

@ -451,7 +451,10 @@ class TemplateForexState extends State<TemplateForex> {
final response = await http.get( final response = await http.get(
uri, uri,
headers: {'Authorization': 'Bearer $token'}, headers: {
'Authorization': 'Bearer $token',
'app-signature': 'ts-traveltool-2025-signature-123456',
},
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -589,6 +592,7 @@ class TemplateForexState extends State<TemplateForex> {
// Add auth header // Add auth header
request.headers['Authorization'] = 'Bearer $token'; request.headers['Authorization'] = 'Bearer $token';
request.headers['app-signature'] = 'ts-traveltool-2025-signature-123456';
// Add the image as multipart with the key "signature" // Add the image as multipart with the key "signature"
request.files.add( request.files.add(

View File

@ -12,9 +12,9 @@ import 'package:flutter_quill/quill_delta.dart' as quill;
import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart'; import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart'; import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
import 'package:frontend/Screens/myTemplates/templateForex.dart' import 'package:frontend/Screens/myTemplates/templateForex.dart'
as _editorFocusNode; as _editorFocusNode;
import 'package:frontend/Screens/myTemplates/templateForex.dart' import 'package:frontend/Screens/myTemplates/templateForex.dart'
as _editorScrollController; as _editorScrollController;
import 'package:frontend/Screens/myTemplates/templateForex.dart' as _controller; import 'package:frontend/Screens/myTemplates/templateForex.dart' as _controller;
import 'package:html2md/html2md.dart' as html2md; import 'package:html2md/html2md.dart' as html2md;
import 'package:http_parser/http_parser.dart'; import 'package:http_parser/http_parser.dart';
@ -196,14 +196,14 @@ class TemplateForexState extends State<TemplateForex> {
setState(() { setState(() {
layoutColor = layoutColor =
layoutString != null layoutString != null
? Color(int.parse(layoutString)) ? Color(int.parse(layoutString))
: Colors.redAccent; : Colors.redAccent;
bodyColor = bodyColor =
bodyStringColor != null bodyStringColor != null
? Color(int.parse(bodyStringColor)) ? Color(int.parse(bodyStringColor))
: Colors.white; : Colors.white;
}); });
} }
@ -351,10 +351,10 @@ class TemplateForexState extends State<TemplateForex> {
.split('_') // split by underscore .split('_') // split by underscore
.map( .map(
(word) => (word) =>
word.isNotEmpty word.isNotEmpty
? '${word[0].toUpperCase()}${word.substring(1)}' ? '${word[0].toUpperCase()}${word.substring(1)}'
: '', : '',
) )
.join(' '); .join(' ');
} }
@ -410,7 +410,7 @@ class TemplateForexState extends State<TemplateForex> {
print("Fetched template_name: $templateName"); print("Fetched template_name: $templateName");
final rawPlaceholder = final rawPlaceholder =
widget.templateData?["templateData"]?["placeholder"]; widget.templateData?["templateData"]?["placeholder"];
if (rawPlaceholder is String) { if (rawPlaceholder is String) {
// If it's a JSON string, decode it first // If it's a JSON string, decode it first
@ -429,10 +429,10 @@ class TemplateForexState extends State<TemplateForex> {
templateId = templateId =
int.tryParse( int.tryParse(
widget.templateData?["templateData"]?["template_id"] widget.templateData?["templateData"]?["template_id"]
?.toString() ?? ?.toString() ??
'0', '0',
) ?? ) ??
0; 0;
print("Fetched template_id: $templateId"); print("Fetched template_id: $templateId");
fetchSignature(); fetchSignature();
// if (widget.group?["international_policy_id"] != null) { // if (widget.group?["international_policy_id"] != null) {
@ -451,7 +451,10 @@ class TemplateForexState extends State<TemplateForex> {
final response = await http.get( final response = await http.get(
uri, uri,
headers: {'Authorization': 'Bearer $token'}, headers: {
'Authorization': 'Bearer $token',
'app-signature': 'ts-traveltool-2025-signature-123456',
},
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -522,7 +525,7 @@ class TemplateForexState extends State<TemplateForex> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'app-signature': 'ts-traveltool-2025-signature-123456', 'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
body: jsonEncode(policyData), // Convert map to JSON body: jsonEncode(policyData), // Convert map to JSON
); );
@ -589,6 +592,7 @@ class TemplateForexState extends State<TemplateForex> {
// Add auth header // Add auth header
request.headers['Authorization'] = 'Bearer $token'; request.headers['Authorization'] = 'Bearer $token';
request.headers['app-signature'] = 'ts-traveltool-2025-signature-123456';
// Add the image as multipart with the key "signature" // Add the image as multipart with the key "signature"
request.files.add( request.files.add(
@ -627,16 +631,16 @@ class TemplateForexState extends State<TemplateForex> {
drawer: CustomDrawer(isDesktop: false), drawer: CustomDrawer(isDesktop: false),
body: Padding( body: Padding(
padding: padding:
isDesktop isDesktop
? EdgeInsets.symmetric( ? EdgeInsets.symmetric(
horizontal: horizontal:
MediaQuery.of(context).size.width * MediaQuery.of(context).size.width *
0.1, // 30% of screen width as horizontal padding 0.1, // 30% of screen width as horizontal padding
vertical: vertical:
MediaQuery.of(context).size.height * MediaQuery.of(context).size.height *
0, // 5% of screen height as vertical padding 0, // 5% of screen height as vertical padding
) )
: EdgeInsets.all(0), : EdgeInsets.all(0),
child: Row( child: Row(
children: [ children: [
// if (isDesktop) CustomDrawer(isDesktop: true), // if (isDesktop) CustomDrawer(isDesktop: true),
@ -657,11 +661,11 @@ class TemplateForexState extends State<TemplateForex> {
} }
Widget buildUserTable( Widget buildUserTable(
bool isDesktop, bool isDesktop,
context, context,
Color? bodyColor, Color? bodyColor,
Color layoutColor, Color layoutColor,
) { ) {
return Container( return Container(
margin: isDesktop ? const EdgeInsets.only(top: 5.0, bottom: 10.0) : null, margin: isDesktop ? const EdgeInsets.only(top: 5.0, bottom: 10.0) : null,
padding: const EdgeInsets.all(28), padding: const EdgeInsets.all(28),
@ -847,7 +851,7 @@ class TemplateForexState extends State<TemplateForex> {
context: context, context: context,
builder: builder:
(context) => (context) =>
PlaceholdersModal(placeholders: placeholderList), PlaceholdersModal(placeholders: placeholderList),
); );
if (selected != null) { if (selected != null) {
@ -940,40 +944,40 @@ class TemplateForexState extends State<TemplateForex> {
onTap: _pickImage, onTap: _pickImage,
child: child:
_imageBytes != null _imageBytes != null
? ClipOval( ? ClipOval(
child: Image.memory( child: Image.memory(
_imageBytes!, _imageBytes!,
// width: 50, // width: 50,
// height: 50, // height: 50,
width: 50, // Use responsive width width: 50, // Use responsive width
height: 50, height: 50,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
) )
: selectedOrglogo != null : selectedOrglogo != null
? ClipRect( ? ClipRect(
child: Image.network( child: Image.network(
selectedOrglogo!, selectedOrglogo!,
width: 50, // Use responsive width width: 50, // Use responsive width
height: 50, height: 50,
// width: 250, // width: 250,
// height: 55, // height: 55,
fit: BoxFit.contain, fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) { errorBuilder: (context, error, stackTrace) {
return const CircleAvatar( return const CircleAvatar(
radius: 20, radius: 20,
backgroundColor: Colors.redAccent, backgroundColor: Colors.redAccent,
child: Icon(Icons.error, size: 10), child: Icon(Icons.error, size: 10),
); );
}, },
), ),
) )
: const CircleAvatar( : const CircleAvatar(
radius: 20, radius: 20,
backgroundColor: Colors.amber, backgroundColor: Colors.amber,
child: Icon(Icons.add_a_photo, size: 10), child: Icon(Icons.add_a_photo, size: 10),
), ),
), ),
], ],
), ),
@ -1017,17 +1021,17 @@ class TemplateForexState extends State<TemplateForex> {
SizedBox( SizedBox(
child: ElevatedButton( child: ElevatedButton(
onPressed: onPressed:
isDisable isDisable
? null ? null
: () async { : () async {
setState(() { setState(() {
isDisable = true; isDisable = true;
}); });
await handleSubmit(); await handleSubmit();
// You can get text from commentController.text // You can get text from commentController.text
// Navigator.of(context).pop(); // Close the modal // Navigator.of(context).pop(); // Close the modal
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: layoutColor, backgroundColor: layoutColor,
// backgroundColor: widget.layoutColor, // backgroundColor: widget.layoutColor,
@ -1082,4 +1086,4 @@ class TimeStampEmbedBuilder extends EmbedBuilder {
], ],
); );
} }
} }

View File

@ -153,8 +153,6 @@ class _MailSettingState extends State<MailSetting> {
} }
Future<void> sendTestMail(Map<String, dynamic> mailData) async { Future<void> sendTestMail(Map<String, dynamic> mailData) async {
// final String apiUrldata = '$apiUrl/api/groups/create';
final token = await getToken(); // Fetch token final token = await getToken(); // Fetch token
// Build correct API URL // Build correct API URL

View File

@ -278,9 +278,6 @@ class ForexDataState extends State<ForexData> {
print("Remarks Data - remarksData"); print("Remarks Data - remarksData");
// final String apiUrldata = '$apiUrl/api/createForexPerdiem';
// api/updateForexPerdiem/39
final token = await getToken(); // Fetch token final token = await getToken(); // Fetch token
if (token == null) { if (token == null) {

View File

@ -249,6 +249,7 @@ class ForexDataListState extends State<ForexDataList> {
// Use MultipartRequest (POST only) // Use MultipartRequest (POST only)
final request = http.MultipartRequest('POST', uri); final request = http.MultipartRequest('POST', uri);
request.headers['Authorization'] = 'Bearer $token'; request.headers['Authorization'] = 'Bearer $token';
request.headers['app-signature'] = 'ts-traveltool-2025-signature-123456';
// If updating, spoof the method Laravel-style // If updating, spoof the method Laravel-style
@ -310,29 +311,6 @@ class ForexDataListState extends State<ForexDataList> {
print("STatus 1 - $newStatus"); print("STatus 1 - $newStatus");
createUserData(userData, userId, newStatus); createUserData(userData, userId, 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) {
// print("User status updated successfully to $newStatus!");
// refreshUserList(); // 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");
// }
} }
// Refresh user list after update // Refresh user list after update

View File

@ -283,13 +283,7 @@ class _ListPlansState extends State<ListPlans> {
// Fetch API Data // Fetch API Data
Future<List<Plan>> fetchPlans() async { Future<List<Plan>> fetchPlans() async {
// return [];
// 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?org_id=$orgId&user_id=$userId';
// api/plans?org_id=1&user_id=1
// final token = await getToken();
if (token == null) { if (token == null) {
throw Exception('Token not found. Please log in.'); throw Exception('Token not found. Please log in.');
@ -351,44 +345,6 @@ class _ListPlansState extends State<ListPlans> {
} }
} }
// Future<Map<String, dynamic>> getViewPlan(String planId) async {
// final String apiUrldata = '$apiUrl/api/plans/find/$planId';
// print("API URL: $apiUrldata");
// // final token = await getToken();
//
// if (token == null) {
// throw Exception('Token not found. Please log in.');
// }
//
// final response = await http.put(
// Uri.parse(apiUrldata),
// headers: {
// 'Authorization': 'Bearer $token', // Add token here
// 'Content-Type': 'application/json',
// },
// );
//
// if (response.statusCode == 200) {
// final Map<String, dynamic>? resData = json.decode(response.body);
//
// return resData?["data"];
// } else {
// throw Exception('Failed to load plans');
// }
// }
//
// void viewPlan(String planId, {bool isViewMode = false}) async {
// try {
// Map<String, dynamic> planData = await getViewPlan(planId);
// print("ViewAAA - $planData");
//
// context.go('/createPlan',
// extra: {'planData': planData, 'isViewMode': isViewMode});
// } catch (e) {
// print("Error fetching plan: $e");
// }
// }
void deletePlan(String planId) async { void deletePlan(String planId) async {
// try { // try {
// Map<String, dynamic> planData = await ApiService.getViewPlan(planId); // Map<String, dynamic> planData = await ApiService.getViewPlan(planId);

View File

@ -412,51 +412,6 @@ class PolicyCriteriaState extends State<PolicyCriteria> {
print("📋 policyData - $policyData"); print("📋 policyData - $policyData");
} }
// Future<void> fetchTrainFlightClass(int tripId) async {
// // final String apiUrldata = '$apiUrl/api/getDropdownMaster';
//
// // final String apiUrldata =
// // '$apiUrl/api/getFlightAndTrainClass?user_id=${widget.userId}&trip_type=tripId';
// final String apiUrldata = await apiService.fetchMasterDropdown();
//
// 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);
// print(data);
//
// if (!data.containsKey('data') || data['data'] is! Map) {
// throw Exception(
// "Invalid response format: 'data' field is missing or not a Map");
// }
//
// Map<String, dynamic> plansJson =
// data['data']; // 'data' is a Map, not a List
// setState(() {
// apiDataForClass = plansJson; // Store API response in state
// isLoading = false;
// });
// } catch (e) {
// throw Exception('Error parsing response: $e');
// }
// } else {
// throw Exception('Failed to load plans');
// }
// }
Future<void> fetchTrainFlightClass() async { Future<void> fetchTrainFlightClass() async {
print("ftech api"); print("ftech api");
try { try {

View File

@ -112,35 +112,6 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
return prefs.getString('auth_token'); return prefs.getString('auth_token');
} }
// Future<List<dynamic>> fetchSingleUsers(userId) async {
// orgId = await getOrgId();
// final String apiUrlData = '$apiUrl/api/users/find/$userId';
//
// final String? token = await getToken();
//
// print("Fetch Users");
// print("TOEKRWE: $token");
//
// 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) {
// final data = json.decode(response.body);
// return data['data']; // Returning raw JSON list
// } else {
// throw Exception('Failed to load users');
// }
// }
Future<List<dynamic>> fetchUsers() async { Future<List<dynamic>> fetchUsers() async {
// return []; // return [];
orgId = await getOrgId(); orgId = await getOrgId();
@ -162,6 +133,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
); );
@ -189,6 +161,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
}, },
); );
@ -243,6 +216,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
// Use MultipartRequest (POST only) // Use MultipartRequest (POST only)
final request = http.MultipartRequest('POST', uri); final request = http.MultipartRequest('POST', uri);
request.headers['Authorization'] = 'Bearer $token'; request.headers['Authorization'] = 'Bearer $token';
request.headers['app-signature'] = 'ts-traveltool-2025-signature-123456';
// If updating, spoof the method Laravel-style // If updating, spoof the method Laravel-style

View File

@ -114,35 +114,6 @@ class _UserListScreenState extends State<UserListScreen> {
return prefs.getString('auth_token'); return prefs.getString('auth_token');
} }
// Future<List<dynamic>> fetchSingleUsers(userId) async {
// orgId = await getOrgId();
// final String apiUrlData = '$apiUrl/api/users/find/$userId';
//
// final String? token = await getToken();
//
// print("Fetch Users");
// print("TOEKRWE: $token");
//
// 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) {
// final data = json.decode(response.body);
// return data['data']; // Returning raw JSON list
// } else {
// throw Exception('Failed to load users');
// }
// }
Future<List<dynamic>> fetchUsers() async { Future<List<dynamic>> fetchUsers() async {
// return []; // return [];
orgId = await getOrgId(); orgId = await getOrgId();

View File

@ -5,13 +5,14 @@
* File : web/index.html - change below * File : web/index.html - change below
* <base href="/adfactor/"> (or) <base href="/adfactor/"> replaced to <base href="/tstat/"> * <base href="/adfactor/"> (or) <base href="/adfactor/"> replaced to <base href="/tstat/">
* Check File : App.dart -> line 37 need to uncomment it "SemanticsBinding" **/ * Check File : App.dart -> line 37 need to uncomment it "SemanticsBinding" **/
const String apiUrl = 'https://apitest.tripapprovaltool.com/tstat_be'; // const String apiUrl = 'https://apitest.tripapprovaltool.com/tstat_be';
/** Note : TSTAT UAT BE URL /** Note : TSTAT UAT BE URL
* incase "adfactor" or "aujas" href means changed to "tstat" * incase "adfactor" or "aujas" href means changed to "tstat"
* File : web/index.html - change below * File : web/index.html - change below
* <base href="/adfactor/"> (or) <base href="/adfactor/"> replaced to <base href="/tstat/"> * <base href="/adfactor/"> (or) <base href="/adfactor/"> replaced to <base href="/tstat/">
* Check File : App.dart -> line 37 need to comment it "SemanticsBinding" **/ * Check File : App.dart -> line 37 need to comment it "SemanticsBinding" **/
// const String apiUrl = 'https://uat.tripapprovaltool.com/tstat_be'; // const String apiUrl = 'https://uat.tripapprovaltool.com/tstat_be';
/** Note : Adfactor UAT BE URL /** Note : Adfactor UAT BE URL
@ -32,4 +33,4 @@ const String apiUrl = 'https://apitest.tripapprovaltool.com/tstat_be';
* incase "tstat" or "adfactor" href means changed to "aujas" * incase "tstat" or "adfactor" href means changed to "aujas"
* File : web/index.html - change below * File : web/index.html - change below
* <base href="/tstat/"> (or) <base href="/adfactor/"> replaced to <base href="/aujas/"> **/ * <base href="/tstat/"> (or) <base href="/adfactor/"> replaced to <base href="/aujas/"> **/
// const String apiUrl = 'https://tripapprovaltool.com/aujas_be' ; const String apiUrl = 'https://tripapprovaltool.com/aujas_be';

View File

@ -170,7 +170,6 @@ class CommentModalState extends State<CommentModal> {
print("Remarks Data - remarksData"); print("Remarks Data - remarksData");
final String apiUrldata = '$apiUrl/api/plans/addOrEditPlanRemark'; final String apiUrldata = '$apiUrl/api/plans/addOrEditPlanRemark';
// final String apiUrldata = '$apiUrl/api/plans/createOrEditPlan';
final token = await getToken(); // Fetch token final token = await getToken(); // Fetch token

View File

@ -14,7 +14,7 @@
This is a placeholder for base href that will be replaced by the value of This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`. the `--base-href` argument provided to `flutter build`.
--> -->
<base href="/tstat/"> <base href="/aujas/">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta content="IE=Edge" http-equiv="X-UA-Compatible">