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: {
'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<ListAllPlans> {
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<ListAllPlans> {
headers: {
'Authorization': 'Bearer $token',
'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> {
late Future<List<Map<String, dynamic>>> _commentsFuture;
Future<List<Map<String, dynamic>>> 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<dynamic> dataList = jsonData['data'];
return dataList.cast<Map<String, dynamic>>();
} else {
throw Exception('Failed to load comments');
}
}
// Future<List<Map<String, dynamic>>> 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<dynamic> dataList = jsonData['data'];
// return dataList.cast<Map<String, dynamic>>();
// } else {
// throw Exception('Failed to load comments');
// }
// }
Future<List<Map<String, dynamic>>> fetchComments() async {
// final String apiUrldata =

View File

@ -180,15 +180,9 @@ class _ApprovalListState extends State<ApprovalList> {
// Fetch API Data
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 =
'$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<ApprovalList> {
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 {
_dialogShown = true;
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
Widget build(BuildContext context) {
return ResponsiveBuilder(

View File

@ -41,13 +41,15 @@ class _GroupListBackUpState extends State<GroupListBackUp> {
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<GroupListBackUp> {
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<GroupListBackUp> {
@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<GroupListBackUp> {
// ? 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<GroupListBackUp> {
// 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<GroupListBackUp> {
// 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<GroupListBackUp> {
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,
),
],
),
],
),
),
],
),
],
),
);
),
);
},
);
}

View File

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

View File

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

View File

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

View File

@ -249,6 +249,7 @@ class ForexDataListState extends State<ForexDataList> {
// Use MultipartRequest (POST only)
final request = http.MultipartRequest('POST', uri);
request.headers['Authorization'] = 'Bearer $token';
request.headers['app-signature'] = 'ts-traveltool-2025-signature-123456';
// If updating, spoof the method Laravel-style
@ -310,29 +311,6 @@ class ForexDataListState extends State<ForexDataList> {
print("STatus 1 - $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

View File

@ -283,13 +283,7 @@ class _ListPlansState extends State<ListPlans> {
// Fetch API Data
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';
// api/plans?org_id=1&user_id=1
// final token = await getToken();
if (token == null) {
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 {
// try {
// Map<String, dynamic> planData = await ApiService.getViewPlan(planId);

View File

@ -412,51 +412,6 @@ class PolicyCriteriaState extends State<PolicyCriteria> {
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 {
print("ftech api");
try {

View File

@ -112,35 +112,6 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
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 {
// return [];
orgId = await getOrgId();
@ -162,6 +133,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
headers: {
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
},
);
@ -189,6 +161,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
headers: {
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
'app-signature': 'ts-traveltool-2025-signature-123456',
},
);
@ -243,6 +216,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
// Use MultipartRequest (POST only)
final request = http.MultipartRequest('POST', uri);
request.headers['Authorization'] = 'Bearer $token';
request.headers['app-signature'] = 'ts-traveltool-2025-signature-123456';
// If updating, spoof the method Laravel-style

View File

@ -114,35 +114,6 @@ class _UserListScreenState extends State<UserListScreen> {
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 {
// return [];
orgId = await getOrgId();

View File

@ -5,13 +5,14 @@
* File : web/index.html - change below
* <base href="/adfactor/"> (or) <base href="/adfactor/"> replaced to <base href="/tstat/">
* 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
* incase "adfactor" or "aujas" href means changed to "tstat"
* File : web/index.html - change below
* <base href="/adfactor/"> (or) <base href="/adfactor/"> replaced to <base href="/tstat/">
* Check File : App.dart -> line 37 need to comment it "SemanticsBinding" **/
// const String apiUrl = 'https://uat.tripapprovaltool.com/tstat_be';
/** 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"
* File : web/index.html - change below
* <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");
final String apiUrldata = '$apiUrl/api/plans/addOrEditPlanRemark';
// final String apiUrldata = '$apiUrl/api/plans/createOrEditPlan';
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
the `--base-href` argument provided to `flutter build`.
-->
<base href="/tstat/">
<base href="/aujas/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">