Page Shaking
This commit is contained in:
parent
b88973d43c
commit
3e3ef56694
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
Future<dynamic> showApprovalDialog(
|
Future<dynamic> showApprovalDialog(
|
||||||
BuildContext context, Color layoutColor) async {
|
BuildContext context,
|
||||||
|
Color layoutColor,
|
||||||
|
) async {
|
||||||
String selectedAction = ""; // "", "accept", "reject"
|
String selectedAction = ""; // "", "accept", "reject"
|
||||||
String remarks = "";
|
String remarks = "";
|
||||||
|
|
||||||
@ -24,13 +26,12 @@ Future<dynamic> showApprovalDialog(
|
|||||||
Text(
|
Text(
|
||||||
"To Approve or Reject Trip",
|
"To Approve or Reject Trip",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontFamily: "Inter", fontWeight: FontWeight.w500),
|
fontFamily: "Inter",
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(Icons.close, size: 15),
|
||||||
Icons.close,
|
|
||||||
size: 15,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context, null); // Close the dialog
|
Navigator.pop(context, null); // Close the dialog
|
||||||
},
|
},
|
||||||
@ -45,12 +46,14 @@ Future<dynamic> showApprovalDialog(
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: selectedAction == "accept"
|
backgroundColor:
|
||||||
? layoutColor
|
selectedAction == "accept"
|
||||||
: Colors.grey.shade200,
|
? Colors.green
|
||||||
foregroundColor: selectedAction == "accept"
|
: Colors.grey.shade200,
|
||||||
? Colors.white
|
foregroundColor:
|
||||||
: Colors.black,
|
selectedAction == "accept"
|
||||||
|
? Colors.white
|
||||||
|
: Colors.black,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
@ -68,12 +71,14 @@ Future<dynamic> showApprovalDialog(
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: selectedAction == "reject"
|
backgroundColor:
|
||||||
? Colors.redAccent
|
selectedAction == "reject"
|
||||||
: Colors.grey.shade200,
|
? Colors.redAccent
|
||||||
foregroundColor: selectedAction == "reject"
|
: Colors.grey.shade200,
|
||||||
? Colors.white
|
foregroundColor:
|
||||||
: Colors.black,
|
selectedAction == "reject"
|
||||||
|
? Colors.white
|
||||||
|
: Colors.black,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
@ -122,12 +127,16 @@ Future<dynamic> showApprovalDialog(
|
|||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderSide: const BorderSide(
|
borderSide: const BorderSide(
|
||||||
color: Colors.blueGrey, width: 0.5),
|
color: Colors.blueGrey,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.blueGrey, width: 0.5),
|
color: Colors.blueGrey,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@ -135,7 +144,7 @@ Future<dynamic> showApprovalDialog(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
actionsAlignment: MainAxisAlignment.center,
|
actionsAlignment: MainAxisAlignment.center,
|
||||||
@ -187,94 +196,14 @@ Future<dynamic> showApprovalDialog(
|
|||||||
Future<bool?> showApproveDialog1(BuildContext context, Color layoutColor) {
|
Future<bool?> showApproveDialog1(BuildContext context, Color layoutColor) {
|
||||||
return showDialog<bool>(
|
return showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder:
|
||||||
backgroundColor: Colors.white,
|
(context) => AlertDialog(
|
||||||
title: const Text(
|
|
||||||
"Confirm Approval",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
content: const Text("Are you sure you want to approve this plan?"),
|
|
||||||
actions: [
|
|
||||||
ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
foregroundColor: layoutColor,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: BorderSide(color: layoutColor, width: 2),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.pop(context, false),
|
|
||||||
child: const Text("Cancel"),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: layoutColor,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: BorderSide(color: layoutColor, width: 2),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.pop(context, true),
|
|
||||||
child: const Text("OK"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Show confirm dialog for rejection with remarks input
|
|
||||||
Future<String?> showRejectDialog1(
|
|
||||||
BuildContext context, Color layoutColor) async {
|
|
||||||
String remarks = "";
|
|
||||||
|
|
||||||
final confirmed = await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (context, setState) => AlertDialog(
|
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
contentPadding: const EdgeInsets.all(36),
|
title: const Text(
|
||||||
// title: const Text("Confirm Rejection"),
|
"Confirm Approval",
|
||||||
content: Column(
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
"Confirm Rejection",
|
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const Text("Please enter reason for rejection."),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
TextField(
|
|
||||||
maxLines: 3,
|
|
||||||
onChanged: (value) => remarks = value,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: "Remarks...",
|
|
||||||
hintStyle: TextStyle(
|
|
||||||
fontSize: 10, // 👈 Set your desired font size here
|
|
||||||
color: Colors.grey,
|
|
||||||
fontFamily: "Inter", // optional if you want consistent font
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.blueGrey, width: 0.5),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.blueGrey, width: 0.5),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
content: const Text("Are you sure you want to approve this plan?"),
|
||||||
actions: [
|
actions: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
@ -299,14 +228,102 @@ Future<String?> showRejectDialog1(
|
|||||||
),
|
),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () => Navigator.pop(context, true),
|
||||||
if (remarks.trim().isEmpty) return;
|
|
||||||
Navigator.pop(context, true);
|
|
||||||
},
|
|
||||||
child: const Text("OK"),
|
child: const Text("OK"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Show confirm dialog for rejection with remarks input
|
||||||
|
Future<String?> showRejectDialog1(
|
||||||
|
BuildContext context,
|
||||||
|
Color layoutColor,
|
||||||
|
) async {
|
||||||
|
String remarks = "";
|
||||||
|
|
||||||
|
final confirmed = await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder:
|
||||||
|
(context, setState) => AlertDialog(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
contentPadding: const EdgeInsets.all(36),
|
||||||
|
// title: const Text("Confirm Rejection"),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
"Confirm Rejection",
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
const Text("Please enter reason for rejection."),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
maxLines: 3,
|
||||||
|
onChanged: (value) => remarks = value,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: "Remarks...",
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
fontSize: 10, // 👈 Set your desired font size here
|
||||||
|
color: Colors.grey,
|
||||||
|
fontFamily:
|
||||||
|
"Inter", // optional if you want consistent font
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
foregroundColor: layoutColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(color: layoutColor, width: 2),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.pop(context, false),
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: layoutColor,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(color: layoutColor, width: 2),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (remarks.trim().isEmpty) return;
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
},
|
||||||
|
child: const Text("OK"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,7 @@ class _PlaceholdersModalState extends State<PlaceholdersModal> {
|
|||||||
content: Container(
|
content: Container(
|
||||||
width:
|
width:
|
||||||
isDesktop
|
isDesktop
|
||||||
? MediaQuery.of(context).size.width * 0.3
|
? MediaQuery.of(context).size.width * 0.4
|
||||||
: double.maxFinite,
|
: double.maxFinite,
|
||||||
// Set max height so ListView knows constraints
|
// Set max height so ListView knows constraints
|
||||||
height: 300,
|
height: 300,
|
||||||
|
|||||||
@ -642,7 +642,7 @@ class TemplateState extends State<Template> {
|
|||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
height: 200,
|
height: MediaQuery.of(context).size.height * 0.3,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
border: Border.all(color: Color(0xFFD6D5E6), width: 0.5),
|
border: Border.all(color: Color(0xFFD6D5E6), width: 0.5),
|
||||||
|
|||||||
830
lib/Screens/myTemplates/templateForex.dart
Normal file
830
lib/Screens/myTemplates/templateForex.dart
Normal file
@ -0,0 +1,830 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io' as io show Directory, File;
|
||||||
|
import 'package:delta_to_html/delta_to_html.dart';
|
||||||
|
import 'package:flutter/cupertino.dart' as dom;
|
||||||
|
import 'package:flutter_quill/flutter_quill.dart' hide Text;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_quill/flutter_quill.dart' hide Text;
|
||||||
|
import 'package:flutter_quill/quill_delta.dart';
|
||||||
|
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;
|
||||||
|
import 'package:frontend/Screens/myTemplates/templateForex.dart'
|
||||||
|
as _editorScrollController;
|
||||||
|
import 'package:frontend/Screens/myTemplates/templateForex.dart' as _controller;
|
||||||
|
import 'package:html2md/html2md.dart' as html2md;
|
||||||
|
import 'package:vsc_quill_delta_to_html/vsc_quill_delta_to_html.dart';
|
||||||
|
|
||||||
|
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
||||||
|
import 'package:html/parser.dart' show parse;
|
||||||
|
import 'package:html/dom.dart' as dom hide Element, Text;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_quill/flutter_quill.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
import 'package:flutter_quill/flutter_quill_internal.dart';
|
||||||
|
import 'package:flutter_quill/quill_delta.dart';
|
||||||
|
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
|
import '../../config/apiUrl.dart';
|
||||||
|
import '../../routes/custom_appBar.dart';
|
||||||
|
import '../../routes/custom_drawer.dart';
|
||||||
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
import '../../widgets/custom_user_travel.dart';
|
||||||
|
import 'dialog_placeholders.dart';
|
||||||
|
|
||||||
|
class TemplateForex extends StatefulWidget {
|
||||||
|
final Map<String, dynamic>? templateData;
|
||||||
|
|
||||||
|
const TemplateForex({super.key, required this.templateData});
|
||||||
|
|
||||||
|
static TemplateForex fromState(GoRouterState state) {
|
||||||
|
return TemplateForex(templateData: state.extra as Map<String, dynamic>?);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
TemplateForexState createState() => TemplateForexState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TemplateForexState extends State<TemplateForex> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
|
|
||||||
|
// final QuillController _controller = QuillController.basic();
|
||||||
|
String? orgId;
|
||||||
|
String? userId;
|
||||||
|
Color layoutColor = Colors.redAccent;
|
||||||
|
Color bodyColor = Colors.white;
|
||||||
|
final Map<String, TextEditingController> controllers = {};
|
||||||
|
List<String> dataHeader = ["subject"];
|
||||||
|
List<String> placeholders = [];
|
||||||
|
|
||||||
|
late QuillController _controller = QuillController.basic();
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
|
|
||||||
|
late int templateId = 0;
|
||||||
|
late String templateName = "";
|
||||||
|
late List<Map<String, dynamic>> placeholderList = [];
|
||||||
|
|
||||||
|
Map<String, dynamic> get TemplateData {
|
||||||
|
final data = {
|
||||||
|
"org_id": orgId,
|
||||||
|
|
||||||
|
// "template_id": templateId,
|
||||||
|
// "template_name": controllers["templateName"]?.text,
|
||||||
|
"template_id": templateId,
|
||||||
|
"template_name": templateName,
|
||||||
|
"subject": controllers["subject"]?.text,
|
||||||
|
"body_html": DeltaToHTML.encodeJson(
|
||||||
|
_controller.document.toDelta().toJson(),
|
||||||
|
),
|
||||||
|
// "body_html": jsonEncode(_controller.document.toDelta().toJson()),
|
||||||
|
|
||||||
|
// "body_html": _controller,
|
||||||
|
// "body_html": convertQuillDocToHtml(_controller.document),
|
||||||
|
// ✅ convert delta to HTML
|
||||||
|
"placeholder": jsonEncode(placeholderList),
|
||||||
|
// "created_by": userId
|
||||||
|
};
|
||||||
|
print('start 123');
|
||||||
|
print(jsonEncode(_controller.document.toDelta().toJson()));
|
||||||
|
// print(jsonEncode(_controller.document));
|
||||||
|
// Only add group_id if it's an edit operation
|
||||||
|
// if (widget.templateData != null && widget.templateData!.containsKey('group_id')) {
|
||||||
|
// data["template_id"] = templateData;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
for (var field in dataHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateData();
|
||||||
|
loadinitializeData();
|
||||||
|
loadInitialData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// void dispose() {
|
||||||
|
// // controllers.dispose();
|
||||||
|
// // _editorScrollController.dispose();
|
||||||
|
// _editorFocusNode.dispose();
|
||||||
|
// super.dispose();
|
||||||
|
// }
|
||||||
|
void loadinitializeData() async {
|
||||||
|
orgId = await getOrgId();
|
||||||
|
userId = await getUserId();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadInitialData() async {
|
||||||
|
String? layoutString = await getLayoutColor();
|
||||||
|
String? bodyStringColor = await getBodyColor();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
layoutColor =
|
||||||
|
layoutString != null
|
||||||
|
? Color(int.parse(layoutString))
|
||||||
|
: Colors.redAccent;
|
||||||
|
|
||||||
|
bodyColor =
|
||||||
|
bodyStringColor != null
|
||||||
|
? Color(int.parse(bodyStringColor))
|
||||||
|
: Colors.white;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String convertQuillDocToHtml(quill.Document doc) {
|
||||||
|
final buffer = StringBuffer();
|
||||||
|
|
||||||
|
print("convertQuillDocToHtml");
|
||||||
|
for (final op in doc.toDelta().toList()) {
|
||||||
|
final insert = op.data;
|
||||||
|
final attrs = op.attributes ?? {};
|
||||||
|
|
||||||
|
if (insert is String) {
|
||||||
|
var content = insert;
|
||||||
|
|
||||||
|
// Handle formatting (bold, italic, etc.)
|
||||||
|
if (attrs.containsKey('bold')) {
|
||||||
|
content = '<strong>$content</strong>';
|
||||||
|
}
|
||||||
|
if (attrs.containsKey('italic')) {
|
||||||
|
content = '<em>$content</em>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap each paragraph with <p>
|
||||||
|
if (content.trim().isNotEmpty) {
|
||||||
|
buffer.write('<p>${content.trim()}</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
String convertQuillDocToHtml2(quill.Document doc) {
|
||||||
|
final buffer = StringBuffer();
|
||||||
|
final lines = <String>[];
|
||||||
|
final delta = doc.toDelta();
|
||||||
|
|
||||||
|
String applyStyles(String text, Map<String, dynamic>? attrs) {
|
||||||
|
if (attrs == null) return text;
|
||||||
|
if (attrs.containsKey('bold')) {
|
||||||
|
text = '<strong>$text</strong>';
|
||||||
|
}
|
||||||
|
if (attrs.containsKey('italic')) {
|
||||||
|
text = '<em>$text</em>';
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final op in delta.toList()) {
|
||||||
|
final insert = op.data;
|
||||||
|
final attrs = op.attributes;
|
||||||
|
|
||||||
|
if (insert is String) {
|
||||||
|
final parts = insert.split('\n');
|
||||||
|
for (int i = 0; i < parts.length; i++) {
|
||||||
|
final part = applyStyles(parts[i], attrs);
|
||||||
|
lines.add(part);
|
||||||
|
|
||||||
|
if (i < parts.length - 1) {
|
||||||
|
// End of line: wrap accumulated content into <p>
|
||||||
|
final joined = lines.join('');
|
||||||
|
if (joined.trim().isNotEmpty) {
|
||||||
|
buffer.writeln('<p>${joined.trim()}</p>');
|
||||||
|
}
|
||||||
|
lines.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add remaining lines
|
||||||
|
final joined = lines.join('');
|
||||||
|
if (joined.trim().isNotEmpty) {
|
||||||
|
buffer.writeln('<p>${joined.trim()}</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
String extractPlainTextFromHtml(String html) {
|
||||||
|
final regex = RegExp(r'<p>(.*?)<\/p>', multiLine: true, dotAll: true);
|
||||||
|
final matches = regex.allMatches(html);
|
||||||
|
|
||||||
|
final buffer = StringBuffer();
|
||||||
|
for (final match in matches) {
|
||||||
|
final text = match.group(1)?.replaceAll(RegExp(r'<[^>]*>'), '') ?? '';
|
||||||
|
buffer.writeln(text.trim());
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
String decodeHtmlEntities(String text) {
|
||||||
|
return text
|
||||||
|
.replaceAll(' ', ' ')
|
||||||
|
.replaceAll('&', '&')
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
|
.replaceAll('"', '"')
|
||||||
|
.replaceAll(''', "'"); // add more as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
// quill.Document convertSimpleHtmlToQuill(String htmlString) {
|
||||||
|
// final delta = quill.Delta();
|
||||||
|
// final doc = html_parser.parse(htmlString);
|
||||||
|
// final body = doc.body;
|
||||||
|
//
|
||||||
|
// void walk(Node node) {
|
||||||
|
// if (node is Text) {
|
||||||
|
// delta.insert(node.text);
|
||||||
|
// } else if (node is Element) {
|
||||||
|
// switch (node.localName) {
|
||||||
|
// case 'p':
|
||||||
|
// node.nodes.forEach(walk);
|
||||||
|
// delta.insert('\n');
|
||||||
|
// break;
|
||||||
|
// case 'br':
|
||||||
|
// delta.insert('\n');
|
||||||
|
// break;
|
||||||
|
// case 'strong':
|
||||||
|
// case 'b':
|
||||||
|
// delta.insert(node.text, {'bold': true});
|
||||||
|
// break;
|
||||||
|
// case 'em':
|
||||||
|
// case 'i':
|
||||||
|
// delta.insert(node.text, {'italic': true});
|
||||||
|
// break;
|
||||||
|
// case 'a':
|
||||||
|
// delta.insert(node.text, {'link': node.attributes['href']});
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// node.nodes.forEach(walk);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (body != null) {
|
||||||
|
// walk(body);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return quill.Document.fromDelta(delta..insert('\n'));
|
||||||
|
// }
|
||||||
|
|
||||||
|
String formatTemplateName(String input) {
|
||||||
|
return input
|
||||||
|
.split('_') // split by underscore
|
||||||
|
.map(
|
||||||
|
(word) =>
|
||||||
|
word.isNotEmpty
|
||||||
|
? '${word[0].toUpperCase()}${word.substring(1)}'
|
||||||
|
: '',
|
||||||
|
)
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateData() async {
|
||||||
|
// Ensure apiselectedUser is not null before printing
|
||||||
|
if (widget.templateData != null) {
|
||||||
|
print("API Selected User Has Data - ${widget.templateData}");
|
||||||
|
print(
|
||||||
|
"API Selected User Has - ${widget.templateData?["templateData"]?["subject"]}",
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
// ✅ Wrap in setState to update the UI
|
||||||
|
controllers["templateName"]?.text =
|
||||||
|
widget.templateData?["templateData"]?["template_name"] ?? "";
|
||||||
|
|
||||||
|
controllers["subject"]?.text =
|
||||||
|
widget.templateData?["templateData"]?["subject"] ?? "";
|
||||||
|
final bodyHtml =
|
||||||
|
widget.templateData?["templateData"]?["body_html"] ?? "";
|
||||||
|
|
||||||
|
print("bodyHtml - $bodyHtml");
|
||||||
|
|
||||||
|
String html = widget.templateData?["templateData"]?["body_html"] ?? "";
|
||||||
|
|
||||||
|
final htmlToDelta = HtmlToDelta();
|
||||||
|
|
||||||
|
// Convert the HTML string to Quill Delta format
|
||||||
|
// This is where the magic happens, but also where complex HTML might be simplified
|
||||||
|
final quill.Delta initialDelta = htmlToDelta.convert(html);
|
||||||
|
|
||||||
|
// Create a Quill Document from the Delta
|
||||||
|
final quill.Document quillDoc = quill.Document.fromDelta(initialDelta);
|
||||||
|
|
||||||
|
// Initialize the QuillController with the converted document
|
||||||
|
_controller = quill.QuillController(
|
||||||
|
document: quillDoc,
|
||||||
|
selection: const TextSelection.collapsed(
|
||||||
|
offset: 0,
|
||||||
|
), // Cursor at the start
|
||||||
|
);
|
||||||
|
|
||||||
|
// final plainText = extractPlainTextFromHtml(bodyHtml);
|
||||||
|
// final decodedText = decodeHtmlEntities(plainText);
|
||||||
|
// final quillDoc = quill.Document()..insert(0, decodedText);
|
||||||
|
// _controller = quill.QuillController(
|
||||||
|
// document: quillDoc,
|
||||||
|
// selection: const TextSelection.collapsed(offset: 0),
|
||||||
|
// );
|
||||||
|
|
||||||
|
templateName =
|
||||||
|
widget.templateData?["templateData"]?["template_name"] ?? "";
|
||||||
|
|
||||||
|
print("Fetched template_name: $templateName");
|
||||||
|
|
||||||
|
final rawPlaceholder =
|
||||||
|
widget.templateData?["templateData"]?["placeholder"];
|
||||||
|
|
||||||
|
if (rawPlaceholder is String) {
|
||||||
|
// If it's a JSON string, decode it first
|
||||||
|
placeholderList = List<Map<String, dynamic>>.from(
|
||||||
|
jsonDecode(rawPlaceholder),
|
||||||
|
);
|
||||||
|
} else if (rawPlaceholder is List) {
|
||||||
|
// If it's already a list (ideal case)
|
||||||
|
placeholderList = List<Map<String, dynamic>>.from(rawPlaceholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Extracted placeholders: $placeholders");
|
||||||
|
|
||||||
|
print("Fetched placeholders: $placeholderList");
|
||||||
|
|
||||||
|
templateId =
|
||||||
|
int.tryParse(
|
||||||
|
widget.templateData?["templateData"]?["template_id"]
|
||||||
|
?.toString() ??
|
||||||
|
'0',
|
||||||
|
) ??
|
||||||
|
0;
|
||||||
|
print("Fetched template_id: $templateId");
|
||||||
|
|
||||||
|
// if (widget.group?["international_policy_id"] != null) {
|
||||||
|
// selectedInternational =
|
||||||
|
// widget.group!["international_policy_id"].toString();
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
print("API Selected User Has Data - No data available yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleSubmit() async {
|
||||||
|
Map<String, dynamic> data = TemplateData;
|
||||||
|
|
||||||
|
print('TemplateData - $data');
|
||||||
|
// final String deltaJsonString = TemplateData?["body_html"] ?? "[]";
|
||||||
|
//
|
||||||
|
// print('deltaJsonString $deltaJsonString');
|
||||||
|
//
|
||||||
|
// // Decode the JSON string into a list
|
||||||
|
// final List<dynamic> deltaJson = jsonDecode(deltaJsonString);
|
||||||
|
//
|
||||||
|
// print(DeltaToHTML.encodeJson(deltaJson));
|
||||||
|
//
|
||||||
|
// // Then convert it to a Quill document
|
||||||
|
// final doc = Document.fromJson(List<Map<String, dynamic>>.from(deltaJson));
|
||||||
|
//
|
||||||
|
// // Set it to the controller
|
||||||
|
// _controller = QuillController(
|
||||||
|
// document: doc,
|
||||||
|
// selection: const TextSelection.collapsed(offset: 0),
|
||||||
|
// );
|
||||||
|
// print('doc JSON: ${jsonEncode(doc.toDelta().toJson())}');
|
||||||
|
// print('doc plain text: ${doc.toPlainText()}');
|
||||||
|
// print('doc $doc');
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
updateTemplateData(data);
|
||||||
|
// This triggers UI rebuild with error messages
|
||||||
|
// if (validateData()) {
|
||||||
|
// postGroupData();
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateTemplateData(policyData) async {
|
||||||
|
final String apiUrldata = '$apiUrl/api/template/update/${templateId}';
|
||||||
|
final token = await getToken(); // Fetch token
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await http.put(
|
||||||
|
Uri.parse(apiUrldata),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: jsonEncode(policyData), // Convert map to JSON
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
print("policyData submitted successfully!");
|
||||||
|
print("Response: ${response.body}");
|
||||||
|
|
||||||
|
context.go('/templateList');
|
||||||
|
} else {
|
||||||
|
print("Failed to submit policyData. Status: ${response.statusCode}");
|
||||||
|
print("Error: ${response.body}");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print(" Error submitting policyData: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ResponsiveBuilder(
|
||||||
|
builder: (context, sizingInfo) {
|
||||||
|
bool isDesktop =
|
||||||
|
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: const Color(0xFFf5f5f5),
|
||||||
|
appBar: CustomAppBar(isDesktop: isDesktop),
|
||||||
|
drawer: CustomDrawer(isDesktop: false),
|
||||||
|
body: Padding(
|
||||||
|
padding:
|
||||||
|
isDesktop
|
||||||
|
? EdgeInsets.symmetric(
|
||||||
|
horizontal:
|
||||||
|
MediaQuery.of(context).size.width *
|
||||||
|
0.1, // 30% of screen width as horizontal padding
|
||||||
|
vertical:
|
||||||
|
MediaQuery.of(context).size.height *
|
||||||
|
0, // 5% of screen height as vertical padding
|
||||||
|
)
|
||||||
|
: EdgeInsets.all(0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
|
Expanded(
|
||||||
|
child: buildUserTable(
|
||||||
|
isDesktop,
|
||||||
|
context,
|
||||||
|
bodyColor,
|
||||||
|
layoutColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildUserTable(
|
||||||
|
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),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
formatTemplateName(templateName),
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// SizedBox(height: 10),
|
||||||
|
// buildTempalteSubject(isDesktop),
|
||||||
|
//
|
||||||
|
// SizedBox(height: 10),
|
||||||
|
buildTempalteBody(isDesktop),
|
||||||
|
Spacer(),
|
||||||
|
buildActions(isDesktop),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildTempalteSubject(bool isDesktop) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Subject",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
CustomTextFieldUserTravellerWrapper(
|
||||||
|
isFocused: false,
|
||||||
|
color: Colors.white,
|
||||||
|
width: isDesktop ? MediaQuery.of(context).size.width * 0.8 : null,
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
|
||||||
|
controller: controllers["subject"],
|
||||||
|
onChanged: (value) {
|
||||||
|
// _clearError("local_id_num");
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: "Enter the subject",
|
||||||
|
labelStyle: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildTempalteBody(bool isDesktop) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Text(
|
||||||
|
// "Content",
|
||||||
|
// style: GoogleFonts.poppins(
|
||||||
|
// fontSize: 12,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// color: Color(0xFF575A74),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Container(
|
||||||
|
color: Color(0xFFFFFEF0),
|
||||||
|
width: isDesktop ? MediaQuery.of(context).size.width * 0.8 : null,
|
||||||
|
child: IconTheme(
|
||||||
|
data: IconThemeData(size: 18), // Set icon size here
|
||||||
|
child: QuillSimpleToolbar(
|
||||||
|
controller: _controller,
|
||||||
|
config: QuillSimpleToolbarConfig(
|
||||||
|
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
|
||||||
|
showClipboardPaste: true,
|
||||||
|
customButtons: [
|
||||||
|
QuillToolbarCustomButtonOptions(
|
||||||
|
icon: const Icon(Icons.add_alarm_rounded),
|
||||||
|
onPressed: () {
|
||||||
|
_controller.document.insert(
|
||||||
|
_controller.selection.extentOffset,
|
||||||
|
TimeStampEmbed(DateTime.now().toString()),
|
||||||
|
);
|
||||||
|
|
||||||
|
_controller.updateSelection(
|
||||||
|
TextSelection.collapsed(
|
||||||
|
offset: _controller.selection.extentOffset + 1,
|
||||||
|
),
|
||||||
|
ChangeSource.local,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
buttonOptions: QuillSimpleToolbarButtonOptions(
|
||||||
|
base: QuillToolbarBaseButtonOptions(
|
||||||
|
afterButtonPressed: () {
|
||||||
|
final isDesktop = {
|
||||||
|
TargetPlatform.linux,
|
||||||
|
TargetPlatform.windows,
|
||||||
|
TargetPlatform.macOS,
|
||||||
|
}.contains(defaultTargetPlatform);
|
||||||
|
// if (isDesktop) {
|
||||||
|
// _editorFocusNode.requestFocus();
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
),
|
||||||
|
linkStyle: QuillToolbarLinkStyleButtonOptions(
|
||||||
|
validateLink: (link) {
|
||||||
|
// Treats all links as valid. When launching the URL,
|
||||||
|
// `https://` is prefixed if the link is incomplete (e.g., `google.com` → `https://google.com`)
|
||||||
|
// however this happens only within the editor.
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final selected = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder:
|
||||||
|
(context) =>
|
||||||
|
PlaceholdersModal(placeholders: placeholderList),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (selected != null) {
|
||||||
|
print("User selected placeholder: $selected");
|
||||||
|
// You can now insert into a controller or editor
|
||||||
|
// Ensure the editor is focused
|
||||||
|
FocusScope.of(context).requestFocus(_focusNode);
|
||||||
|
|
||||||
|
final selection = _controller.selection;
|
||||||
|
final position = selection.baseOffset;
|
||||||
|
|
||||||
|
// if (position >= 0) {
|
||||||
|
// final intPosition = position.toInt();
|
||||||
|
//
|
||||||
|
// _controller.document.insert(intPosition, selected);
|
||||||
|
//
|
||||||
|
// _controller.updateSelection(
|
||||||
|
// TextSelection.collapsed(
|
||||||
|
// offset: intPosition + selected.length,
|
||||||
|
// ),
|
||||||
|
// ChangeSource.local,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
foregroundColor: Colors.grey,
|
||||||
|
// padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Placeholders',
|
||||||
|
style: GoogleFonts.poppins(fontSize: 13, color: Colors.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
height: MediaQuery.of(context).size.height * 0.5,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: Color(0xFFD6D5E6), width: 0.5),
|
||||||
|
),
|
||||||
|
child: QuillEditor(
|
||||||
|
controller: _controller,
|
||||||
|
scrollController: ScrollController(),
|
||||||
|
|
||||||
|
focusNode: _focusNode,
|
||||||
|
config: QuillEditorConfig(
|
||||||
|
placeholder: 'Start writing your notes...',
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
embedBuilders: [
|
||||||
|
...FlutterQuillEmbeds.editorBuilders(
|
||||||
|
imageEmbedConfig: QuillEditorImageEmbedConfig(
|
||||||
|
imageProviderBuilder: (context, imageUrl) {
|
||||||
|
// https://pub.dev/packages/flutter_quill_extensions#-image-assets
|
||||||
|
if (imageUrl.startsWith('assets/')) {
|
||||||
|
return AssetImage(imageUrl);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
videoEmbedConfig: QuillEditorVideoEmbedConfig(
|
||||||
|
customVideoBuilder: (videoUrl, readOnly) {
|
||||||
|
// To load YouTube videos https://github.com/singerdmx/flutter-quill/releases/tag/v10.8.0
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TimeStampEmbedBuilder(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildActions(bool isDesktop) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.go('/OrganizationSettings');
|
||||||
|
// You can get text from commentController.text
|
||||||
|
Navigator.of(context).pop(); // Close the modal
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
foregroundColor: layoutColor,
|
||||||
|
// backgroundColor: widget.layoutColor,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(color: layoutColor, width: 2),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Cancel',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: layoutColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
SizedBox(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
handleSubmit();
|
||||||
|
// You can get text from commentController.text
|
||||||
|
// Navigator.of(context).pop(); // Close the modal
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: layoutColor,
|
||||||
|
// backgroundColor: widget.layoutColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Save',
|
||||||
|
style: GoogleFonts.poppins(fontSize: 14, color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
_editorScrollController.dispose();
|
||||||
|
_editorFocusNode.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TimeStampEmbed extends Embeddable {
|
||||||
|
const TimeStampEmbed(String value) : super(timeStampType, value);
|
||||||
|
|
||||||
|
static const String timeStampType = 'timeStamp';
|
||||||
|
|
||||||
|
static TimeStampEmbed fromDocument(Document document) =>
|
||||||
|
TimeStampEmbed(jsonEncode(document.toDelta().toJson()));
|
||||||
|
|
||||||
|
Document get document => Document.fromJson(jsonDecode(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
class TimeStampEmbedBuilder extends EmbedBuilder {
|
||||||
|
@override
|
||||||
|
String get key => 'timeStamp';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toPlainText(Embed node) {
|
||||||
|
return node.value.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, EmbedContext embedContext) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.access_time_rounded),
|
||||||
|
Text(embedContext.node.value.data as String),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,6 +10,7 @@ import 'package:http/http.dart' as http;
|
|||||||
import 'package:http_parser/http_parser.dart';
|
import 'package:http_parser/http_parser.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:responsive_builder/responsive_builder.dart';
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import '../../config/apiUrl.dart';
|
import '../../config/apiUrl.dart';
|
||||||
import '../../routes/custom_appBar.dart';
|
import '../../routes/custom_appBar.dart';
|
||||||
@ -66,13 +67,15 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +102,7 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
|
|
||||||
"created_by": null,
|
"created_by": null,
|
||||||
"updated_by": null,
|
"updated_by": null,
|
||||||
"is_active": 1
|
"is_active": 1,
|
||||||
|
|
||||||
// "org_id": orgId,
|
// "org_id": orgId,
|
||||||
// "created_by": userId,
|
// "created_by": userId,
|
||||||
@ -144,75 +147,92 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
try {
|
try {
|
||||||
print("getUpdatedServices");
|
print("getUpdatedServices");
|
||||||
|
|
||||||
final result = await apiService.fetchOrganization();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
print("UUPdatedServices - $result");
|
final String? orgDataString = prefs.getString('org_data');
|
||||||
setState(() {
|
|
||||||
selectedOrg = result;
|
|
||||||
|
|
||||||
String? rawLogoPath = selectedOrg?['logo'];
|
if (orgDataString != null) {
|
||||||
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
final Map<String, dynamic> orgData = jsonDecode(orgDataString);
|
||||||
const baseUrl = "https://apitest.tripapprovaltool.com";
|
print("UUPdatedServices - $orgData");
|
||||||
final assetPath = rawLogoPath.split('/assets').last;
|
setState(() {
|
||||||
selectedOrg!['logo'] = "$baseUrl/assets$assetPath";
|
selectedOrg = orgData;
|
||||||
}
|
|
||||||
|
|
||||||
_orgNameController.text = selectedOrg?['name'];
|
String? rawLogoPath = selectedOrg?['logo'];
|
||||||
|
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
||||||
|
const baseUrl = "https://apitest.tripapprovaltool.com";
|
||||||
|
final assetPath = rawLogoPath.split('/assets').last;
|
||||||
|
selectedOrg!['logo'] = "$baseUrl/assets$assetPath";
|
||||||
|
}
|
||||||
|
|
||||||
layoutColor = selectedOrg?['layout_color'] != null
|
_orgNameController.text = selectedOrg?['name'];
|
||||||
? Color(int.parse(
|
|
||||||
selectedOrg!['layout_color'].toString().replaceFirst('0x', ''),
|
|
||||||
radix: 16))
|
|
||||||
: Colors.white;
|
|
||||||
|
|
||||||
bodyColor = selectedOrg?['color'] != null
|
layoutColor =
|
||||||
? Color(int.parse(
|
selectedOrg?['layout_color'] != null
|
||||||
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
? Color(
|
||||||
radix: 16))
|
int.parse(
|
||||||
: Colors.blue;
|
selectedOrg!['layout_color'].toString().replaceFirst(
|
||||||
|
'0x',
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
radix: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Colors.white;
|
||||||
|
|
||||||
// Set mail config fields
|
bodyColor =
|
||||||
mailConfig['sender_email'] = selectedOrg?['sender_email'];
|
selectedOrg?['color'] != null
|
||||||
mailConfig['mail_user_name'] = selectedOrg?['mail_user_name'];
|
? Color(
|
||||||
mailConfig['mail_password'] = selectedOrg?['mail_password'];
|
int.parse(
|
||||||
mailConfig['mail_host'] = selectedOrg?['mail_host'];
|
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
||||||
mailConfig['mail_port'] = selectedOrg?['mail_port'];
|
radix: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Colors.blue;
|
||||||
|
|
||||||
// Set selected service IDs
|
// Set mail config fields
|
||||||
// final services = selectedOrg?['services_ids'] as List<dynamic>? ?? [];
|
mailConfig['sender_email'] = selectedOrg?['sender_email'];
|
||||||
// selectedServiceIds =
|
mailConfig['mail_user_name'] = selectedOrg?['mail_user_name'];
|
||||||
// services.map((item) => item['service_id'].toString()).toList();
|
mailConfig['mail_password'] = selectedOrg?['mail_password'];
|
||||||
//
|
mailConfig['mail_host'] = selectedOrg?['mail_host'];
|
||||||
|
mailConfig['mail_port'] = selectedOrg?['mail_port'];
|
||||||
|
|
||||||
final servicesRaw = selectedOrg?['services_ids'];
|
// Set selected service IDs
|
||||||
|
// final services = selectedOrg?['services_ids'] as List<dynamic>? ?? [];
|
||||||
|
// selectedServiceIds =
|
||||||
|
// services.map((item) => item['service_id'].toString()).toList();
|
||||||
|
//
|
||||||
|
|
||||||
List<dynamic> services;
|
final servicesRaw = selectedOrg?['services_ids'];
|
||||||
|
|
||||||
if (servicesRaw is String) {
|
List<dynamic> services;
|
||||||
try {
|
|
||||||
services = jsonDecode(servicesRaw);
|
if (servicesRaw is String) {
|
||||||
} catch (e) {
|
try {
|
||||||
print('❌ Failed to decode services_ids: $e');
|
services = jsonDecode(servicesRaw);
|
||||||
|
} catch (e) {
|
||||||
|
print('❌ Failed to decode services_ids: $e');
|
||||||
|
services = [];
|
||||||
|
}
|
||||||
|
} else if (servicesRaw is List) {
|
||||||
|
services = servicesRaw;
|
||||||
|
} else {
|
||||||
services = [];
|
services = [];
|
||||||
}
|
}
|
||||||
} else if (servicesRaw is List) {
|
|
||||||
services = servicesRaw;
|
|
||||||
} else {
|
|
||||||
services = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedServiceIds = services.map<Map<String, dynamic>>((item) {
|
selectedServiceIds =
|
||||||
// force cast or copy to a regular map
|
services.map<Map<String, dynamic>>((item) {
|
||||||
final map = Map<String, dynamic>.from(item);
|
// force cast or copy to a regular map
|
||||||
return {
|
final map = Map<String, dynamic>.from(item);
|
||||||
"service_id": map['service_id'].toString(),
|
return {"service_id": map['service_id'].toString()};
|
||||||
};
|
}).toList();
|
||||||
}).toList();
|
});
|
||||||
});
|
|
||||||
|
|
||||||
orgId = await getOrgId();
|
orgId = await getOrgId();
|
||||||
|
|
||||||
print("selectedOrg - $selectedOrg");
|
print("selectedOrg - $selectedOrg");
|
||||||
print("mailConfig - $mailConfig");
|
print("mailConfig - $mailConfig");
|
||||||
|
}
|
||||||
|
|
||||||
|
// final result = await apiService.fetchOrganization();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error fetching updatedServices list: $e');
|
print('Error fetching updatedServices list: $e');
|
||||||
}
|
}
|
||||||
@ -222,10 +242,7 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
errorMessages.clear(); // Reset errors
|
errorMessages.clear(); // Reset errors
|
||||||
|
|
||||||
// Required fields that must not be empty
|
// Required fields that must not be empty
|
||||||
List<String> requiredFields = [
|
List<String> requiredFields = ["name", "description"];
|
||||||
"name",
|
|
||||||
"description",
|
|
||||||
];
|
|
||||||
|
|
||||||
// Check validation for each field
|
// Check validation for each field
|
||||||
for (String field in requiredFields) {
|
for (String field in requiredFields) {
|
||||||
@ -298,7 +315,26 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
|
|
||||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||||
print("✅ User submitted successfully!");
|
print("✅ User submitted successfully!");
|
||||||
print("📨 Response: ${response.body}");
|
print("📨 Response Organizt Update: ${response.body}");
|
||||||
|
|
||||||
|
final data = json.decode(response.body);
|
||||||
|
|
||||||
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
|
throw Exception(
|
||||||
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure each item is a Map<String, dynamic>
|
||||||
|
final Map<String, dynamic> orgList = Map<String, dynamic>.from(
|
||||||
|
data['data'],
|
||||||
|
);
|
||||||
|
|
||||||
|
print(orgList);
|
||||||
|
await updateOrgDataWithNewValues(orgList);
|
||||||
|
print("📨 Response Organizt Update:");
|
||||||
|
// return orgList;
|
||||||
|
|
||||||
context.go('/listPlan');
|
context.go('/listPlan');
|
||||||
} else {
|
} else {
|
||||||
print("❌ Submission failed. Status: ${response.statusCode}");
|
print("❌ Submission failed. Status: ${response.statusCode}");
|
||||||
@ -309,6 +345,27 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> updateOrgDataWithNewValues(Map<String, dynamic> newData) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String? orgDataString = prefs.getString('org_data');
|
||||||
|
|
||||||
|
Map<String, dynamic> orgData = {};
|
||||||
|
if (orgDataString != null) {
|
||||||
|
try {
|
||||||
|
orgData = jsonDecode(orgDataString);
|
||||||
|
} catch (e) {
|
||||||
|
print('❌ Failed to decode org_data: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge in the new data
|
||||||
|
orgData.addAll(newData);
|
||||||
|
|
||||||
|
// Save back
|
||||||
|
await prefs.setString('org_data', jsonEncode(orgData));
|
||||||
|
print("✅ Updated org_data saved.");
|
||||||
|
}
|
||||||
|
|
||||||
void handleSubmit() {
|
void handleSubmit() {
|
||||||
print("HandleSubmiy - $orgData");
|
print("HandleSubmiy - $orgData");
|
||||||
createOrgData(orgData);
|
createOrgData(orgData);
|
||||||
@ -327,32 +384,38 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
|
|
||||||
@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(0),
|
MediaQuery.of(context).size.height *
|
||||||
child: Row(
|
0, // 5% of screen height as vertical padding
|
||||||
children: [
|
)
|
||||||
// if (isDesktop) CustomDrawer(isDesktop: true),
|
: EdgeInsets.all(0),
|
||||||
Expanded(child: buildOrganizationLayout(isDesktop))
|
child: Row(
|
||||||
],
|
children: [
|
||||||
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
|
Expanded(child: buildOrganizationLayout(isDesktop)),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildOrganizationLayout(isDesktop) {
|
Widget buildOrganizationLayout(isDesktop) {
|
||||||
@ -380,20 +443,28 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(5),
|
padding: const EdgeInsets.all(5),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: isDesktop
|
child:
|
||||||
? Row(
|
isDesktop
|
||||||
|
? Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
// children: [Text("Button")],
|
// children: [Text("Button")],
|
||||||
children:
|
children: _buildSubmit(
|
||||||
_buildSubmit(isDesktop, isViewMode, layoutColor),
|
isDesktop,
|
||||||
|
isViewMode,
|
||||||
|
layoutColor,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children:
|
children: _buildSubmit(
|
||||||
_buildSubmit(isDesktop, isViewMode, layoutColor),
|
isDesktop,
|
||||||
))
|
isViewMode,
|
||||||
|
layoutColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -402,8 +473,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
Widget buildOrgLayout(bool isDesktop) {
|
Widget buildOrgLayout(bool isDesktop) {
|
||||||
Future<void> _pickImage() async {
|
Future<void> _pickImage() async {
|
||||||
final picker = ImagePicker();
|
final picker = ImagePicker();
|
||||||
final XFile? pickedFile =
|
final XFile? pickedFile = await picker.pickImage(
|
||||||
await picker.pickImage(source: ImageSource.gallery);
|
source: ImageSource.gallery,
|
||||||
|
);
|
||||||
|
|
||||||
if (pickedFile != null && kIsWeb) {
|
if (pickedFile != null && kIsWeb) {
|
||||||
try {
|
try {
|
||||||
@ -424,9 +496,10 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
// margin: isDesktop
|
// margin: isDesktop
|
||||||
// ? 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),
|
||||||
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(
|
||||||
@ -446,7 +519,11 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 20, right: 20, bottom: 20, top: 5),
|
left: 20,
|
||||||
|
right: 20,
|
||||||
|
bottom: 20,
|
||||||
|
top: 5,
|
||||||
|
),
|
||||||
// height: MediaQuery.of(context).size.height * 0.8,
|
// height: MediaQuery.of(context).size.height * 0.8,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -463,7 +540,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
? "Update Organization"
|
? "Update Organization"
|
||||||
: "Create Organization",
|
: "Create Organization",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 15, fontWeight: FontWeight.w500),
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -472,16 +551,19 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center, // now -> .center , old -> .start
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment
|
||||||
|
.center, // now -> .center , old -> .start
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 1.0),
|
padding: const EdgeInsets.only(top: 1.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Name:",
|
"Name:",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF212121)),
|
color: Color(0xFF212121),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
@ -496,7 +578,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: "Enter Organization Name",
|
hintText: "Enter Organization Name",
|
||||||
hintStyle: GoogleFonts.poppins(
|
hintStyle: GoogleFonts.poppins(
|
||||||
fontSize: 14, color: Colors.grey),
|
fontSize: 14,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
floatingLabelBehavior:
|
floatingLabelBehavior:
|
||||||
FloatingLabelBehavior.never,
|
FloatingLabelBehavior.never,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
@ -510,84 +594,87 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: _pickImage,
|
onTap: _pickImage,
|
||||||
child: _imageBytes != null
|
child:
|
||||||
? ClipOval(
|
_imageBytes != null
|
||||||
child: Image.memory(
|
? ClipOval(
|
||||||
_imageBytes!,
|
child: Image.memory(
|
||||||
width: 50,
|
_imageBytes!,
|
||||||
height: 50,
|
width: 50,
|
||||||
fit: BoxFit.cover,
|
height: 50,
|
||||||
),
|
fit: BoxFit.cover,
|
||||||
)
|
|
||||||
: selectedOrg?['logo'] != null
|
|
||||||
? ClipRect(
|
|
||||||
child: Image.network(
|
|
||||||
selectedOrg!['logo'],
|
|
||||||
width: 250, // increased
|
|
||||||
height: 75, // increased
|
|
||||||
|
|
||||||
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),
|
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: selectedOrg?['logo'] != null
|
||||||
|
? ClipRect(
|
||||||
|
child: Image.network(
|
||||||
|
selectedOrg!['logo'],
|
||||||
|
width: 250, // increased
|
||||||
|
height: 75, // increased
|
||||||
|
|
||||||
|
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),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(height: 10),
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
"Services",
|
"Services",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF212121)),
|
color: Color(0xFF212121),
|
||||||
),
|
),
|
||||||
SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Color(0xFFF4F4FB)),
|
border: Border.all(color: Color(0xFFF4F4FB)),
|
||||||
borderRadius: BorderRadius.circular(1),
|
borderRadius: BorderRadius.circular(1),
|
||||||
// color: bodyColor,
|
// color: bodyColor,
|
||||||
// color: Color(0xFFF5F5F5),
|
// color: Color(0xFFF5F5F5),
|
||||||
color: Colors.white),
|
color: Colors.white,
|
||||||
padding:
|
),
|
||||||
EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 5),
|
padding: EdgeInsets.only(
|
||||||
child: isDesktop
|
left: 5,
|
||||||
? Row(
|
right: 5,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
top: 15,
|
||||||
// mainAxisSize: MainAxisSize.min,
|
bottom: 5,
|
||||||
children: _buildOptions(),
|
),
|
||||||
)
|
child:
|
||||||
: Expanded(
|
isDesktop
|
||||||
child: SingleChildScrollView(
|
? Row(
|
||||||
scrollDirection: Axis.horizontal,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
child: Row(
|
// mainAxisSize: MainAxisSize.min,
|
||||||
children: _buildOptions(),
|
children: _buildOptions(),
|
||||||
|
)
|
||||||
|
: Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(children: _buildOptions()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -595,9 +682,10 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
Text(
|
Text(
|
||||||
"Choose Theme",
|
"Choose Theme",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF212121)),
|
color: Color(0xFF212121),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -606,99 +694,106 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
// color: Color(0xFFF4F4FB),
|
// color: Color(0xFFF4F4FB),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 5, right: 5, top: 15, bottom: 5),
|
left: 5,
|
||||||
child: layoutColor != null && bodyColor != null
|
right: 5,
|
||||||
? ColorThemePickerWidget(
|
top: 15,
|
||||||
initialLayoutColor: layoutColor,
|
bottom: 5,
|
||||||
initialBodyColor: bodyColor,
|
),
|
||||||
onLayoutColorSelected:
|
child:
|
||||||
(Color selectedLayoutColor) {
|
layoutColor != null && bodyColor != null
|
||||||
setState(() {
|
? ColorThemePickerWidget(
|
||||||
layoutColor = selectedLayoutColor;
|
initialLayoutColor: layoutColor,
|
||||||
});
|
initialBodyColor: bodyColor,
|
||||||
},
|
onLayoutColorSelected: (
|
||||||
onBodyColorSelected: (Color selectedBodyColor) {
|
Color selectedLayoutColor,
|
||||||
setState(() {
|
) {
|
||||||
bodyColor = selectedBodyColor;
|
setState(() {
|
||||||
});
|
layoutColor = selectedLayoutColor;
|
||||||
},
|
});
|
||||||
)
|
},
|
||||||
: CircularProgressIndicator(),
|
onBodyColorSelected: (
|
||||||
|
Color selectedBodyColor,
|
||||||
|
) {
|
||||||
|
setState(() {
|
||||||
|
bodyColor = selectedBodyColor;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(height: 15),
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Container(
|
Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Mail Settings",
|
"Mail Settings",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF212121)),
|
color: Color(0xFF212121),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// GestureDetector(
|
// GestureDetector(
|
||||||
// onTap: () {
|
// onTap: () {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// showMail = !showMail;
|
// showMail = !showMail;
|
||||||
// });
|
// });
|
||||||
// },
|
// },
|
||||||
// child: Icon(
|
// child: Icon(
|
||||||
// Icons.keyboard_arrow_down_outlined,
|
// Icons.keyboard_arrow_down_outlined,
|
||||||
// color: Color(0xFF114D8B),
|
// color: Color(0xFF114D8B),
|
||||||
// size: 30,
|
// size: 30,
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// if (showMail)
|
|
||||||
|
|
||||||
SizedBox(
|
// if (showMail)
|
||||||
height: 10,
|
SizedBox(height: 10),
|
||||||
|
Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: Color(0xFFF5F5F5),
|
||||||
|
// color: bodyColor ?? Colors.grey,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
// color: bodyColor,
|
||||||
|
color: Colors.white70,
|
||||||
|
// color: Color(0xFFF5F5F5),
|
||||||
),
|
),
|
||||||
Container(
|
child: Row(
|
||||||
// width: double.infinity,
|
mainAxisAlignment:
|
||||||
decoration: BoxDecoration(
|
isDesktop
|
||||||
border: Border.all(
|
|
||||||
color: Color(0xFFF5F5F5),
|
|
||||||
// color: bodyColor ?? Colors.grey,
|
|
||||||
width: 1.5,
|
|
||||||
),
|
|
||||||
// color: bodyColor,
|
|
||||||
color: Colors.white70,
|
|
||||||
// color: Color(0xFFF5F5F5),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: isDesktop
|
|
||||||
? MainAxisAlignment.start
|
? MainAxisAlignment.start
|
||||||
: MainAxisAlignment.center,
|
: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
mailConfig['sender_email'] != null
|
mailConfig['sender_email'] != null
|
||||||
? MailSetting(
|
? MailSetting(
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
initialMailData: mailConfig,
|
initialMailData: mailConfig,
|
||||||
onMailDataChanged: (updatedData) {
|
onMailDataChanged: (updatedData) {
|
||||||
// You can setState here or do something else with updatedData
|
// You can setState here or do something else with updatedData
|
||||||
print(
|
print("Updated Mail Data: $updatedData");
|
||||||
"Updated Mail Data: $updatedData");
|
|
||||||
|
|
||||||
mailConfig = updatedData;
|
mailConfig = updatedData;
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: CircularProgressIndicator(),
|
: CircularProgressIndicator(),
|
||||||
],
|
],
|
||||||
))
|
),
|
||||||
],
|
),
|
||||||
)),
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
// isDesktop
|
// isDesktop
|
||||||
// ? Row(
|
// ? Row(
|
||||||
// mainAxisAlignment: MainAxisAlignment.end,
|
// mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@ -738,8 +833,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
|
|
||||||
String serviceId = service['service_id'].toString();
|
String serviceId = service['service_id'].toString();
|
||||||
// bool isSelected = selectedServiceIds.contains(serviceId);
|
// bool isSelected = selectedServiceIds.contains(serviceId);
|
||||||
bool isSelected =
|
bool isSelected = selectedServiceIds.any(
|
||||||
selectedServiceIds.any((item) => item["service_id"] == serviceId);
|
(item) => item["service_id"] == serviceId,
|
||||||
|
);
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -747,8 +843,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
String serviceId = service['service_id'].toString();
|
String serviceId = service['service_id'].toString();
|
||||||
|
|
||||||
// Check if already selected
|
// Check if already selected
|
||||||
int existingIndex = selectedServiceIds
|
int existingIndex = selectedServiceIds.indexWhere(
|
||||||
.indexWhere((item) => item["service_id"] == serviceId);
|
(item) => item["service_id"] == serviceId,
|
||||||
|
);
|
||||||
|
|
||||||
if (existingIndex != -1) {
|
if (existingIndex != -1) {
|
||||||
selectedServiceIds.removeAt(existingIndex);
|
selectedServiceIds.removeAt(existingIndex);
|
||||||
@ -757,54 +854,65 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Row(children: [
|
child: Row(
|
||||||
iconUrl.isNotEmpty
|
children: [
|
||||||
? Image.network(
|
iconUrl.isNotEmpty
|
||||||
|
? Image.network(
|
||||||
iconUrl,
|
iconUrl,
|
||||||
width: 18,
|
width: 18,
|
||||||
height: 18,
|
height: 18,
|
||||||
errorBuilder: (context, error, stackTrace) {
|
errorBuilder: (context, error, stackTrace) {
|
||||||
return Icon(fallbackIcon,
|
return Icon(
|
||||||
size: 18,
|
fallbackIcon,
|
||||||
color: isSelected == name
|
size: 18,
|
||||||
? Color(0xFF114D8B)
|
color:
|
||||||
: Color(0xFF475569));
|
isSelected == name
|
||||||
|
? Color(0xFF114D8B)
|
||||||
|
: Color(0xFF475569),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: Icon(fallbackIcon,
|
: Icon(
|
||||||
|
fallbackIcon,
|
||||||
size: 18,
|
size: 18,
|
||||||
color:
|
color:
|
||||||
isSelected == name ? Color(0xFF114D8B) : Color(0xFF475569)),
|
isSelected == name ? Color(0xFF114D8B) : Color(0xFF475569),
|
||||||
|
),
|
||||||
|
|
||||||
SizedBox(width: 2),
|
SizedBox(width: 2),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
name,
|
name,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: isSelected == name ? Color(0xFF114D8B) : Color(0xFF475569),
|
color: isSelected == name ? Color(0xFF114D8B) : Color(0xFF475569),
|
||||||
fontWeight:
|
fontWeight:
|
||||||
isSelected == name ? FontWeight.bold : FontWeight.w500),
|
isSelected == name ? FontWeight.bold : FontWeight.w500,
|
||||||
// fontWeight: selectedListOption == title ? FontWeight.bold : FontWeight.normal,)),
|
),
|
||||||
),
|
// fontWeight: selectedListOption == title ? FontWeight.bold : FontWeight.normal,)),
|
||||||
|
),
|
||||||
|
|
||||||
SizedBox(width: 2),
|
SizedBox(width: 2),
|
||||||
// if (selectedListOption == title && widget.isViewMode == false)
|
// if (selectedListOption == title && widget.isViewMode == false)
|
||||||
Container(
|
Container(
|
||||||
height: 15,
|
height: 15,
|
||||||
width: 15,
|
width: 15,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isSelected ? Colors.green : Colors.grey, width: 1),
|
color: isSelected ? Colors.green : Colors.grey,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.check_circle,
|
Icons.check_circle,
|
||||||
size: 10,
|
size: 10,
|
||||||
color: isSelected ? Colors.green : Colors.grey,
|
color: isSelected ? Colors.green : Colors.grey,
|
||||||
// color: Colors.grey,
|
// color: Colors.grey,
|
||||||
)),
|
),
|
||||||
]),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,25 +944,21 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
List<Widget> _buildSubmit(isDesktop, bool isViewMode, Color? layoutColor) {
|
List<Widget> _buildSubmit(isDesktop, bool isViewMode, Color? layoutColor) {
|
||||||
return [
|
return [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
foregroundColor: layoutColor,
|
foregroundColor: layoutColor,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
side: BorderSide(color: layoutColor ?? Colors.grey, width: 2),
|
side: BorderSide(color: layoutColor ?? Colors.grey, width: 2),
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
context.go('/listPlan');
|
),
|
||||||
},
|
onPressed: () {
|
||||||
child: Text(
|
context.go('/listPlan');
|
||||||
"Cancel",
|
},
|
||||||
style: GoogleFonts.poppins(fontSize: 12),
|
child: Text("Cancel", style: GoogleFonts.poppins(fontSize: 12)),
|
||||||
)),
|
|
||||||
SizedBox(
|
|
||||||
width: 20,
|
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 20),
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
// cursor: widget.isViewMode
|
// cursor: widget.isViewMode
|
||||||
// ? SystemMouseCursors.forbidden
|
// ? SystemMouseCursors.forbidden
|
||||||
@ -873,12 +977,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
|||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
onPressed: handleSubmit, // Disable when in view mode
|
onPressed: handleSubmit, // Disable when in view mode
|
||||||
child: Text(
|
child: Text("Submit", style: GoogleFonts.poppins(fontSize: 12)),
|
||||||
"Submit",
|
|
||||||
style: GoogleFonts.poppins(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -313,6 +313,8 @@ class _UserListScreenState extends State<UserListScreen> {
|
|||||||
(user['role_value']?.toLowerCase().contains(lowerQuery) ??
|
(user['role_value']?.toLowerCase().contains(lowerQuery) ??
|
||||||
false);
|
false);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
currentPage = 0;
|
||||||
});
|
});
|
||||||
print("filteredPlans: $filteredUsers");
|
print("filteredPlans: $filteredUsers");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,10 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
// import 'package:flutter/rendering.dart';
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
import 'package:frontend/config/apiUrl.dart'; // 1 newly added
|
import 'package:frontend/config/apiUrl.dart'; // 1 newly added
|
||||||
|
import 'package:frontend/services/apiService.dart';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
@ -23,13 +24,14 @@ class MyApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
String? _authCode;
|
String? _authCode;
|
||||||
String? userRole;
|
String? userRole;
|
||||||
bool _isAuthRedirect = false;
|
bool _isAuthRedirect = false;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
// SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
final uri = Uri.parse(html.window.location.href);
|
final uri = Uri.parse(html.window.location.href);
|
||||||
if (uri.path == '/authredirection' &&
|
if (uri.path == '/authredirection' &&
|
||||||
@ -119,6 +121,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
print("userData11 - ${userData['role']}");
|
print("userData11 - ${userData['role']}");
|
||||||
print("userData12 - $userRole");
|
print("userData12 - $userRole");
|
||||||
}
|
}
|
||||||
|
apiService.getOrganizationData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error decoding token: $e');
|
print('Error decoding token: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,13 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:frontend/config/apiUrl.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart'; // don't forget
|
import 'package:shared_preferences/shared_preferences.dart'; // don't forget
|
||||||
import '../services/apiService.dart';
|
import '../services/apiService.dart';
|
||||||
import '../utils/auth_utils.dart';
|
import '../utils/auth_utils.dart';
|
||||||
|
|
||||||
enum TabSelection {
|
enum TabSelection { dashboard, allTrips, myTrips, myApprovals, allMenu }
|
||||||
dashboard,
|
|
||||||
allTrips,
|
|
||||||
myTrips,
|
|
||||||
myApprovals,
|
|
||||||
allMenu,
|
|
||||||
}
|
|
||||||
|
|
||||||
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||||
final bool isDesktop;
|
final bool isDesktop;
|
||||||
@ -131,6 +126,64 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getOrganizationData() async {
|
Future<void> getOrganizationData() async {
|
||||||
|
try {
|
||||||
|
print("getUpdatedServices");
|
||||||
|
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String? orgDataString = prefs.getString('org_data');
|
||||||
|
|
||||||
|
if (orgDataString != null) {
|
||||||
|
// final result = await apiService.fetchOrganization();
|
||||||
|
|
||||||
|
final Map<String, dynamic> result = jsonDecode(orgDataString);
|
||||||
|
print("UUPdatedServices - $result");
|
||||||
|
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
print("UUPdatedServices - $result");
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
selectedOrg = result;
|
||||||
|
|
||||||
|
layoutColor =
|
||||||
|
selectedOrg?['layout_color'] != null
|
||||||
|
? Color(int.parse(selectedOrg!['layout_color']))
|
||||||
|
: Colors.white;
|
||||||
|
|
||||||
|
bodyColor =
|
||||||
|
selectedOrg?['color'] != null
|
||||||
|
? Color(
|
||||||
|
int.parse(
|
||||||
|
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
||||||
|
radix: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Colors.blue;
|
||||||
|
|
||||||
|
String? rawLogoPath = selectedOrg?['logo'];
|
||||||
|
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
||||||
|
const baseUrl = apiUrl;
|
||||||
|
|
||||||
|
// const baseUrl = "https://apitest.tripapprovaltool.com";
|
||||||
|
final assetPath = rawLogoPath.split('/assets').last;
|
||||||
|
selectedOrg!['logo'] = "$baseUrl/assets$assetPath";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save to SharedPreferences
|
||||||
|
await prefs.setString('layout_color', selectedOrg?['layout_color']);
|
||||||
|
await prefs.setString('body_color', selectedOrg?['color']);
|
||||||
|
await prefs.setString('body_color', selectedOrg?['plan_action']);
|
||||||
|
|
||||||
|
print(
|
||||||
|
"Layout Color- ${selectedOrg?['layout_color']} - $layoutColor ---------- bodyColor - $bodyColor",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Error : $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> getOrganizationData1() async {
|
||||||
try {
|
try {
|
||||||
print("getUpdatedServices");
|
print("getUpdatedServices");
|
||||||
|
|
||||||
@ -142,15 +195,20 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
selectedOrg = result;
|
selectedOrg = result;
|
||||||
|
|
||||||
layoutColor = selectedOrg?['layout_color'] != null
|
layoutColor =
|
||||||
? Color(int.parse(selectedOrg!['layout_color']))
|
selectedOrg?['layout_color'] != null
|
||||||
: Colors.white;
|
? Color(int.parse(selectedOrg!['layout_color']))
|
||||||
|
: Colors.white;
|
||||||
|
|
||||||
bodyColor = selectedOrg?['color'] != null
|
bodyColor =
|
||||||
? Color(int.parse(
|
selectedOrg?['color'] != null
|
||||||
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
? Color(
|
||||||
radix: 16))
|
int.parse(
|
||||||
: Colors.blue;
|
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
||||||
|
radix: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Colors.blue;
|
||||||
|
|
||||||
String? rawLogoPath = selectedOrg?['logo'];
|
String? rawLogoPath = selectedOrg?['logo'];
|
||||||
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
||||||
@ -166,22 +224,32 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
await prefs.setString('body_color', selectedOrg?['plan_action']);
|
await prefs.setString('body_color', selectedOrg?['plan_action']);
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"Layout Color- ${selectedOrg?['layout_color']} - $layoutColor ---------- bodyColor - $bodyColor");
|
"Layout Color- ${selectedOrg?['layout_color']} - $layoutColor ---------- bodyColor - $bodyColor",
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error : $e");
|
print("Error : $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void handleTabChange(TabSelection tab, String route) {
|
||||||
|
// final currentUri =
|
||||||
|
// GoRouterState.of(context).uri.toString(); // ✅ safer than `.location`
|
||||||
|
// print("currentUri - $currentUri");
|
||||||
|
//
|
||||||
|
// if (currentUri != route) {
|
||||||
|
// setState(() {
|
||||||
|
// selectedTab = tab;
|
||||||
|
// });
|
||||||
|
// context.go(route);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
void handleTabChange(TabSelection tab, String route) {
|
void handleTabChange(TabSelection tab, String route) {
|
||||||
final currentUri =
|
final currentUri = GoRouterState.of(context).uri.toString();
|
||||||
GoRouterState.of(context).uri.toString(); // ✅ safer than `.location`
|
|
||||||
print("currentUri - $currentUri");
|
|
||||||
|
|
||||||
if (currentUri != route) {
|
if (currentUri != route) {
|
||||||
setState(() {
|
context.go(route); // 🔄 Let navigation happen
|
||||||
selectedTab = tab;
|
// The tab selection will automatically be updated by didChangeDependencies
|
||||||
});
|
|
||||||
context.go(route);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,248 +293,266 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
|
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
|
|
||||||
title: !widget.isDesktop
|
title:
|
||||||
? Text('')
|
!widget.isDesktop
|
||||||
: Padding(
|
? Text('')
|
||||||
padding: EdgeInsets.symmetric(
|
: Padding(
|
||||||
horizontal: MediaQuery.of(context).size.width * 0.05),
|
padding: EdgeInsets.symmetric(
|
||||||
child: Row(
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
children: [
|
),
|
||||||
Padding(
|
child: Row(
|
||||||
padding: const EdgeInsets.all(10),
|
children: [
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
|
||||||
child: selectedOrg?['logo'] != null
|
// padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
|
||||||
? SizedBox(
|
child:
|
||||||
height: 60,
|
selectedOrg?['logo'] != null
|
||||||
child: ClipRect(
|
? SizedBox(
|
||||||
child: Image.network(
|
height: 60,
|
||||||
selectedOrg!['logo'],
|
child: ClipRect(
|
||||||
width: 130, //130
|
child: Image.network(
|
||||||
height: 80, //80
|
selectedOrg!['logo'],
|
||||||
fit: BoxFit.contain,
|
width: 130, //130
|
||||||
errorBuilder: (context, error, stackTrace) {
|
height: 80, //80
|
||||||
return const CircleAvatar(
|
fit: BoxFit.contain,
|
||||||
radius: 20,
|
errorBuilder: (context, error, stackTrace) {
|
||||||
backgroundColor: Colors.redAccent,
|
return const CircleAvatar(
|
||||||
child: Icon(Icons.error, size: 10),
|
radius: 20,
|
||||||
);
|
backgroundColor: Colors.redAccent,
|
||||||
},
|
child: Icon(Icons.error, size: 10),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const CircleAvatar(
|
||||||
|
radius: 20,
|
||||||
|
// backgroundColor: Colors.white,
|
||||||
|
child: Icon(
|
||||||
|
Icons.add_a_photo,
|
||||||
|
size: 10,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
))
|
|
||||||
: const CircleAvatar(
|
|
||||||
radius: 20,
|
|
||||||
// backgroundColor: Colors.white,
|
|
||||||
child: Icon(
|
|
||||||
Icons.add_a_photo,
|
|
||||||
size: 10,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width * 0.18,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.of(context).size.width * 0.35,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
if (userData?["role"] == "Org Admin" ||
|
|
||||||
userData?["role"] == "Travel Admin")
|
|
||||||
buildNavItem(
|
|
||||||
"Dashboard",
|
|
||||||
() => handleTabChange(
|
|
||||||
TabSelection.dashboard, '/StatusDashboard'),
|
|
||||||
layoutColor!,
|
|
||||||
isSelected: selectedTab == TabSelection.dashboard,
|
|
||||||
icon: Icons.dashboard,
|
|
||||||
// icon: Icons.insights_outlined,
|
|
||||||
),
|
|
||||||
if (userData?["role"] == "Org Admin" ||
|
|
||||||
userData?["role"] == "Travel Admin")
|
|
||||||
const SizedBox(width: 20),
|
|
||||||
if (userData?["role"] == "Org Admin" ||
|
|
||||||
userData?["role"] == "Travel Admin")
|
|
||||||
buildNavItem(
|
|
||||||
"All Trips",
|
|
||||||
() => handleTabChange(
|
|
||||||
TabSelection.allTrips, '/listAllPlan'),
|
|
||||||
layoutColor!,
|
|
||||||
isSelected: selectedTab == TabSelection.allTrips,
|
|
||||||
icon: Icons.format_list_bulleted_rounded,
|
|
||||||
// icon: Icons.insights_outlined,
|
|
||||||
),
|
|
||||||
if (userDetails["role"] != "Travel Agent")
|
|
||||||
const SizedBox(width: 20),
|
|
||||||
if (userData?["role"] == "Travel Agent")
|
|
||||||
buildNavItem(
|
|
||||||
"Trips",
|
|
||||||
() => handleTabChange(
|
|
||||||
TabSelection.myTrips, '/listTravelAgentPlan'),
|
|
||||||
layoutColor!,
|
|
||||||
// () => context.go('/listTravelAgentPlan'),
|
|
||||||
isSelected: selectedTab == TabSelection.myTrips,
|
|
||||||
icon: Icons.shopping_bag_outlined,
|
|
||||||
// icon: Icons.request_page_outlined,
|
|
||||||
),
|
|
||||||
if (userData?["role"] != "Travel Agent") // for others
|
|
||||||
buildNavItem(
|
|
||||||
"My Trips",
|
|
||||||
() => handleTabChange(
|
|
||||||
TabSelection.myTrips, '/listPlan'),
|
|
||||||
layoutColor!,
|
|
||||||
// () => context.go('/listPlan'),
|
|
||||||
isSelected: selectedTab == TabSelection.myTrips,
|
|
||||||
icon: Icons.shopping_bag_outlined,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 20),
|
|
||||||
if (userData?["role"] != "Travel Agent")
|
|
||||||
buildNavItem(
|
|
||||||
"My Approvals",
|
|
||||||
|
|
||||||
() => handleTabChange(
|
|
||||||
TabSelection.myApprovals, '/ApprovalList'),
|
|
||||||
layoutColor!,
|
|
||||||
// () => context.go('/ApprovalList'),
|
|
||||||
isSelected: selectedTab == TabSelection.myApprovals,
|
|
||||||
icon: Icons.verified_outlined,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(width: MediaQuery.of(context).size.width * 0.18),
|
||||||
Spacer(),
|
Container(
|
||||||
],
|
width: MediaQuery.of(context).size.width * 0.35,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
if (userData?["role"] == "Org Admin" ||
|
||||||
|
userData?["role"] == "Travel Admin")
|
||||||
|
buildNavItem(
|
||||||
|
"Dashboard",
|
||||||
|
() => handleTabChange(
|
||||||
|
TabSelection.dashboard,
|
||||||
|
'/StatusDashboard',
|
||||||
|
),
|
||||||
|
layoutColor!,
|
||||||
|
isSelected: selectedTab == TabSelection.dashboard,
|
||||||
|
icon: Icons.dashboard,
|
||||||
|
// icon: Icons.insights_outlined,
|
||||||
|
),
|
||||||
|
if (userData?["role"] == "Org Admin" ||
|
||||||
|
userData?["role"] == "Travel Admin")
|
||||||
|
const SizedBox(width: 20),
|
||||||
|
if (userData?["role"] == "Org Admin" ||
|
||||||
|
userData?["role"] == "Travel Admin")
|
||||||
|
buildNavItem(
|
||||||
|
"All Trips",
|
||||||
|
() => handleTabChange(
|
||||||
|
TabSelection.allTrips,
|
||||||
|
'/listAllPlan',
|
||||||
|
),
|
||||||
|
layoutColor!,
|
||||||
|
isSelected: selectedTab == TabSelection.allTrips,
|
||||||
|
icon: Icons.format_list_bulleted_rounded,
|
||||||
|
// icon: Icons.insights_outlined,
|
||||||
|
),
|
||||||
|
if (userDetails["role"] != "Travel Agent")
|
||||||
|
const SizedBox(width: 20),
|
||||||
|
if (userData?["role"] == "Travel Agent")
|
||||||
|
buildNavItem(
|
||||||
|
"Trips",
|
||||||
|
() => handleTabChange(
|
||||||
|
TabSelection.myTrips,
|
||||||
|
'/listTravelAgentPlan',
|
||||||
|
),
|
||||||
|
layoutColor!,
|
||||||
|
// () => context.go('/listTravelAgentPlan'),
|
||||||
|
isSelected: selectedTab == TabSelection.myTrips,
|
||||||
|
icon: Icons.shopping_bag_outlined,
|
||||||
|
// icon: Icons.request_page_outlined,
|
||||||
|
),
|
||||||
|
if (userData?["role"] != "Travel Agent") // for others
|
||||||
|
buildNavItem(
|
||||||
|
"My Trips",
|
||||||
|
() => handleTabChange(
|
||||||
|
TabSelection.myTrips,
|
||||||
|
'/listPlan',
|
||||||
|
),
|
||||||
|
layoutColor!,
|
||||||
|
// () => context.go('/listPlan'),
|
||||||
|
isSelected: selectedTab == TabSelection.myTrips,
|
||||||
|
icon: Icons.shopping_bag_outlined,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 20),
|
||||||
|
if (userData?["role"] != "Travel Agent")
|
||||||
|
buildNavItem(
|
||||||
|
"My Approvals",
|
||||||
|
|
||||||
|
() => handleTabChange(
|
||||||
|
TabSelection.myApprovals,
|
||||||
|
'/ApprovalList',
|
||||||
|
),
|
||||||
|
layoutColor!,
|
||||||
|
// () => context.go('/ApprovalList'),
|
||||||
|
isSelected:
|
||||||
|
selectedTab == TabSelection.myApprovals,
|
||||||
|
icon: Icons.verified_outlined,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
actions: [
|
actions: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: MediaQuery.of(context).size.width * 0.05),
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
// if (userData?["role"] != "User")
|
// if (userData?["role"] != "User")
|
||||||
Builder(
|
Builder(
|
||||||
builder: (context) => PopupMenuButton<String>(
|
builder:
|
||||||
color: Colors.white,
|
(context) => PopupMenuButton<String>(
|
||||||
padding: EdgeInsets.zero,
|
color: Colors.white,
|
||||||
offset: const Offset(0, 50), // 👈 shift it 50 pixels down
|
padding: EdgeInsets.zero,
|
||||||
onSelected: (String value) {
|
offset: const Offset(0, 50), // 👈 shift it 50 pixels down
|
||||||
switch (value) {
|
onSelected: (String value) {
|
||||||
case '/OrganizationSettings':
|
switch (value) {
|
||||||
context.go('/OrganizationSettings');
|
case '/OrganizationSettings':
|
||||||
break;
|
context.go('/OrganizationSettings');
|
||||||
// case '/OrganizationSetup':
|
break;
|
||||||
// context.go('/OrganizationSetup');
|
// case '/OrganizationSetup':
|
||||||
// break;
|
// context.go('/OrganizationSetup');
|
||||||
case '/listUser':
|
// break;
|
||||||
context.go('/listUser');
|
case '/listUser':
|
||||||
break;
|
context.go('/listUser');
|
||||||
// case '/group':
|
break;
|
||||||
// context.go('/group');
|
// case '/group':
|
||||||
// break;
|
// context.go('/group');
|
||||||
// case '/department':
|
// break;
|
||||||
// context.go('/department');
|
// case '/department':
|
||||||
// break;
|
// context.go('/department');
|
||||||
// case '/PolicyList':
|
// break;
|
||||||
// context.go('/PolicyList');
|
// case '/PolicyList':
|
||||||
// case '/getPerdiem':
|
// context.go('/PolicyList');
|
||||||
// context.go('/getPerdiem');
|
// case '/getPerdiem':
|
||||||
// case '/templateList':
|
// context.go('/getPerdiem');
|
||||||
// context.go('/templateList');
|
// case '/templateList':
|
||||||
// case '/template':
|
// context.go('/templateList');
|
||||||
// context.go('/template');
|
// case '/template':
|
||||||
|
// context.go('/template');
|
||||||
|
|
||||||
case '/CreateUserDetails':
|
case '/CreateUserDetails':
|
||||||
context.go(
|
context.go(
|
||||||
"/CreateUserDetails",
|
"/CreateUserDetails",
|
||||||
extra: {
|
extra: {
|
||||||
"selectedUser": profileUserDetails,
|
"selectedUser": profileUserDetails,
|
||||||
"isEditProfile": true,
|
"isEditProfile": true,
|
||||||
"isViewMode": false,
|
"isViewMode": false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case '/logout':
|
case '/logout':
|
||||||
context.go('/');
|
context.go('/');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// itemBuilder: (BuildContext context) =>
|
// itemBuilder: (BuildContext context) =>
|
||||||
// menuItems.map(buildMenuItem).toList(),
|
// menuItems.map(buildMenuItem).toList(),
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
// final isUser = userData?["role"] == "User";
|
||||||
|
final role = userData?["role"];
|
||||||
|
List<Map<String, dynamic>> filteredItems;
|
||||||
|
|
||||||
itemBuilder: (BuildContext context) {
|
if (role == "User") {
|
||||||
// final isUser = userData?["role"] == "User";
|
filteredItems =
|
||||||
final role = userData?["role"];
|
menuItems
|
||||||
List<Map<String, dynamic>> filteredItems;
|
.where(
|
||||||
|
(item) =>
|
||||||
|
item['value'] == '/CreateUserDetails' ||
|
||||||
|
item['value'] == '/logout',
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
} else if (role == "Travel Agent") {
|
||||||
|
filteredItems =
|
||||||
|
menuItems
|
||||||
|
.where((item) => item['value'] == '/logout')
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
filteredItems = menuItems;
|
||||||
|
}
|
||||||
|
|
||||||
if (role == "User") {
|
// Create a new list starting with role display and divider
|
||||||
filteredItems = menuItems
|
return [
|
||||||
.where((item) =>
|
PopupMenuItem<String>(
|
||||||
item['value'] == '/CreateUserDetails' ||
|
enabled: false, // ❌ Not clickable
|
||||||
item['value'] == '/logout')
|
child: Column(
|
||||||
.toList();
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
} else if (role == "Travel Agent") {
|
children: [
|
||||||
filteredItems = menuItems
|
Text(
|
||||||
.where((item) => item['value'] == '/logout')
|
userData?["role"] ?? '',
|
||||||
.toList();
|
style: GoogleFonts.poppins(
|
||||||
} else {
|
fontSize: 12,
|
||||||
filteredItems = menuItems;
|
fontWeight: FontWeight.bold,
|
||||||
}
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(), // 👈 Divider after role
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
...filteredItems
|
||||||
|
.map(buildMenuItem)
|
||||||
|
.toList(), // 👈 then normal items
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
// Create a new list starting with role display and divider
|
child: MouseRegion(
|
||||||
return [
|
cursor: SystemMouseCursors.click,
|
||||||
PopupMenuItem<String>(
|
child: Row(
|
||||||
enabled: false, // ❌ Not clickable
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
userData?["role"] ?? '',
|
userData?["name"] ?? "N/A",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w500,
|
||||||
|
// fontFamily: "Roboto",
|
||||||
|
// color: Colors.black,
|
||||||
|
// ),
|
||||||
|
),
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_drop_down,
|
||||||
|
size: 20,
|
||||||
|
color: Colors.black87,
|
||||||
),
|
),
|
||||||
const Divider(), // 👈 Divider after role
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
...filteredItems
|
|
||||||
.map(buildMenuItem)
|
|
||||||
.toList(), // 👈 then normal items
|
|
||||||
];
|
|
||||||
},
|
|
||||||
|
|
||||||
child: MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
userData?["name"] ?? "N/A",
|
|
||||||
style: GoogleFonts.poppins(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
// style: const TextStyle(
|
|
||||||
// fontSize: 14,
|
|
||||||
// fontWeight: FontWeight.w500,
|
|
||||||
// fontFamily: "Roboto",
|
|
||||||
// color: Colors.black,
|
|
||||||
// ),
|
|
||||||
),
|
|
||||||
const Icon(
|
|
||||||
Icons.arrow_drop_down,
|
|
||||||
size: 20,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
],
|
],
|
||||||
@ -497,12 +583,12 @@ final List<Map<String, dynamic>> menuItems = [
|
|||||||
{
|
{
|
||||||
'value': '/OrganizationSettings',
|
'value': '/OrganizationSettings',
|
||||||
'icon': Icons.business,
|
'icon': Icons.business,
|
||||||
'label': 'Org Management'
|
'label': 'Org Management',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'value': '/listUser',
|
'value': '/listUser',
|
||||||
'icon': Icons.manage_accounts,
|
'icon': Icons.manage_accounts,
|
||||||
'label': 'User Management'
|
'label': 'User Management',
|
||||||
},
|
},
|
||||||
|
|
||||||
// {'value': '/group', 'icon': Icons.group, 'label': 'Group'},
|
// {'value': '/group', 'icon': Icons.group, 'label': 'Group'},
|
||||||
@ -518,7 +604,7 @@ final List<Map<String, dynamic>> menuItems = [
|
|||||||
{
|
{
|
||||||
'value': '/CreateUserDetails',
|
'value': '/CreateUserDetails',
|
||||||
'icon': Icons.account_circle,
|
'icon': Icons.account_circle,
|
||||||
'label': 'My Profile'
|
'label': 'My Profile',
|
||||||
},
|
},
|
||||||
{'value': '/logout', 'icon': Icons.login_outlined, 'label': 'Logout'},
|
{'value': '/logout', 'icon': Icons.login_outlined, 'label': 'Logout'},
|
||||||
];
|
];
|
||||||
@ -527,12 +613,16 @@ PopupMenuItem<String> buildMenuItem(Map<String, dynamic> item) {
|
|||||||
return PopupMenuItem<String>(
|
return PopupMenuItem<String>(
|
||||||
height: 40, // 👈 reduce PopupMenuItem height
|
height: 40, // 👈 reduce PopupMenuItem height
|
||||||
value: item['value'],
|
value: item['value'],
|
||||||
padding:
|
padding: EdgeInsets.symmetric(
|
||||||
EdgeInsets.symmetric(horizontal: 12), // 👈 control left-right spacing
|
horizontal: 12,
|
||||||
|
), // 👈 control left-right spacing
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(item['icon'],
|
Icon(
|
||||||
size: 18, color: Colors.black87), // 👈 smaller, cleaner icon
|
item['icon'],
|
||||||
|
size: 18,
|
||||||
|
color: Colors.black87,
|
||||||
|
), // 👈 smaller, cleaner icon
|
||||||
SizedBox(width: 10), // 👈 small space between icon and text
|
SizedBox(width: 10), // 👈 small space between icon and text
|
||||||
Text(
|
Text(
|
||||||
item['label'],
|
item['label'],
|
||||||
@ -547,8 +637,13 @@ PopupMenuItem<String> buildMenuItem(Map<String, dynamic> item) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildNavItem(String label, VoidCallback onTap, Color? layoutColor,
|
Widget buildNavItem(
|
||||||
{bool isSelected = true, IconData? icon}) {
|
String label,
|
||||||
|
VoidCallback onTap,
|
||||||
|
Color? layoutColor, {
|
||||||
|
bool isSelected = true,
|
||||||
|
IconData? icon,
|
||||||
|
}) {
|
||||||
final effectiveColor =
|
final effectiveColor =
|
||||||
isSelected ? (layoutColor ?? Colors.blue) : Colors.black;
|
isSelected ? (layoutColor ?? Colors.blue) : Colors.black;
|
||||||
|
|
||||||
@ -587,9 +682,10 @@ Widget buildNavItem(String label, VoidCallback onTap, Color? layoutColor,
|
|||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
height: 2,
|
height: 2,
|
||||||
width: isSelected
|
width:
|
||||||
? 50
|
isSelected
|
||||||
: 0, // Animate width (make sure isSelected changes)
|
? 50
|
||||||
|
: 0, // Animate width (make sure isSelected changes)
|
||||||
color: effectiveColor,
|
color: effectiveColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -84,39 +84,53 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
try {
|
try {
|
||||||
print("getUpdatedServices");
|
print("getUpdatedServices");
|
||||||
|
|
||||||
final result = await apiService.fetchOrganization();
|
|
||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
print("UUPdatedServices - $result");
|
final String? orgDataString = prefs.getString('org_data');
|
||||||
|
|
||||||
setState(() {
|
if (orgDataString != null) {
|
||||||
selectedOrg = result;
|
// final result = await apiService.fetchOrganization();
|
||||||
|
|
||||||
layoutColor = selectedOrg?['layout_color'] != null
|
final Map<String, dynamic> result = jsonDecode(orgDataString);
|
||||||
? Color(int.parse(selectedOrg!['layout_color']))
|
print("UUPdatedServices - $result");
|
||||||
: Colors.white;
|
|
||||||
|
|
||||||
bodyColor = selectedOrg?['color'] != null
|
final prefs = await SharedPreferences.getInstance();
|
||||||
? Color(int.parse(
|
print("UUPdatedServices - $result");
|
||||||
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
|
||||||
radix: 16))
|
|
||||||
: Colors.blue;
|
|
||||||
|
|
||||||
String? rawLogoPath = selectedOrg?['logo'];
|
setState(() {
|
||||||
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
selectedOrg = result;
|
||||||
const baseUrl = "https://apitest.tripapprovaltool.com";
|
|
||||||
final assetPath = rawLogoPath.split('/assets').last;
|
|
||||||
selectedOrg!['logo'] = "$baseUrl/assets$assetPath";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save to SharedPreferences
|
layoutColor =
|
||||||
await prefs.setString('layout_color', selectedOrg?['layout_color']);
|
selectedOrg?['layout_color'] != null
|
||||||
await prefs.setString('body_color', selectedOrg?['color']);
|
? Color(int.parse(selectedOrg!['layout_color']))
|
||||||
await prefs.setString('body_color', selectedOrg?['plan_action']);
|
: Colors.white;
|
||||||
|
|
||||||
print(
|
bodyColor =
|
||||||
"Layout Color- ${selectedOrg?['layout_color']} - $layoutColor ---------- bodyColor - $bodyColor");
|
selectedOrg?['color'] != null
|
||||||
|
? Color(
|
||||||
|
int.parse(
|
||||||
|
selectedOrg!['color'].toString().replaceFirst('0x', ''),
|
||||||
|
radix: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Colors.blue;
|
||||||
|
|
||||||
|
String? rawLogoPath = selectedOrg?['logo'];
|
||||||
|
if (rawLogoPath != null && rawLogoPath.contains('/assets')) {
|
||||||
|
const baseUrl = "https://apitest.tripapprovaltool.com";
|
||||||
|
final assetPath = rawLogoPath.split('/assets').last;
|
||||||
|
selectedOrg!['logo'] = "$baseUrl/assets$assetPath";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save to SharedPreferences
|
||||||
|
await prefs.setString('layout_color', selectedOrg?['layout_color']);
|
||||||
|
await prefs.setString('body_color', selectedOrg?['color']);
|
||||||
|
await prefs.setString('body_color', selectedOrg?['plan_action']);
|
||||||
|
|
||||||
|
print(
|
||||||
|
"Layout Color- ${selectedOrg?['layout_color']} - $layoutColor ---------- bodyColor - $bodyColor",
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error : $e");
|
print("Error : $e");
|
||||||
}
|
}
|
||||||
@ -126,7 +140,6 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget drawerContent = Container(
|
Widget drawerContent = Container(
|
||||||
// color: Colors.white,
|
// color: Colors.white,
|
||||||
|
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.all(18),
|
margin: const EdgeInsets.all(18),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -141,57 +154,77 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
children: [
|
children: [
|
||||||
selectedOrg?['logo'] != null
|
selectedOrg?['logo'] != null
|
||||||
? ClipRect(
|
? ClipRect(
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
selectedOrg!['logo'],
|
selectedOrg!['logo'],
|
||||||
width: 100,
|
width: 100,
|
||||||
height: 50,
|
height: 50,
|
||||||
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(
|
|
||||||
radius: 20,
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
child: Icon(
|
|
||||||
Icons.add_a_photo,
|
|
||||||
size: 10,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: const CircleAvatar(
|
||||||
|
radius: 20,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
child: Icon(
|
||||||
|
Icons.add_a_photo,
|
||||||
|
size: 10,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// _buildDrawerItem(context, Icons.home_outlined, 'Home', '/home'),
|
// _buildDrawerItem(context, Icons.home_outlined, 'Home', '/home'),
|
||||||
|
if (userData?["role"] == "Org Admin" ||
|
||||||
|
userData?["role"] == "Travel Admin")
|
||||||
|
_buildDrawerItem(
|
||||||
|
context,
|
||||||
|
Icons.dashboard,
|
||||||
|
'Dashboard',
|
||||||
|
'/StatusDashboard',
|
||||||
|
),
|
||||||
|
|
||||||
if (userData?["role"] == "Org Admin" ||
|
if (userData?["role"] == "Org Admin" ||
|
||||||
userData?["role"] == "Travel Admin")
|
userData?["role"] == "Travel Admin")
|
||||||
_buildDrawerItem(context, Icons.dashboard, 'Dashboard',
|
_buildDrawerItem(
|
||||||
'/StatusDashboard'),
|
context,
|
||||||
|
Icons.insights_outlined,
|
||||||
if (userData?["role"] == "Org Admin" ||
|
'All Trips',
|
||||||
userData?["role"] == "Travel Admin")
|
'/listAllPlan',
|
||||||
_buildDrawerItem(context, Icons.insights_outlined, 'All Trips',
|
),
|
||||||
'/listAllPlan'),
|
|
||||||
|
|
||||||
if (userDetails["role"] == "Travel Agent")
|
if (userDetails["role"] == "Travel Agent")
|
||||||
_buildDrawerItem(context, Icons.assessment_outlined,
|
_buildDrawerItem(
|
||||||
'My Approvals', '/listTravelAgentPlan'),
|
context,
|
||||||
|
Icons.assessment_outlined,
|
||||||
|
'My Approvals',
|
||||||
|
'/listTravelAgentPlan',
|
||||||
|
),
|
||||||
|
|
||||||
if (userDetails["role"] != "Travel Agent")
|
if (userDetails["role"] != "Travel Agent")
|
||||||
_buildDrawerItem(context, Icons.request_page_outlined, 'My Trips',
|
_buildDrawerItem(
|
||||||
'/listPlan'),
|
context,
|
||||||
|
Icons.request_page_outlined,
|
||||||
|
'My Trips',
|
||||||
|
'/listPlan',
|
||||||
|
),
|
||||||
|
|
||||||
if (userDetails["role"] != "Travel Agent")
|
if (userDetails["role"] != "Travel Agent")
|
||||||
_buildDrawerItem(context, Icons.assessment_outlined,
|
_buildDrawerItem(
|
||||||
'My Approvals', '/ApprovalList'),
|
context,
|
||||||
|
Icons.assessment_outlined,
|
||||||
|
'My Approvals',
|
||||||
|
'/ApprovalList',
|
||||||
|
),
|
||||||
|
|
||||||
SizedBox(height: MediaQuery.of(context).size.height * 0.5),
|
SizedBox(height: MediaQuery.of(context).size.height * 0.5),
|
||||||
Container(
|
Container(
|
||||||
@ -206,8 +239,10 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Powered by",
|
"Powered by",
|
||||||
style:
|
style: TextStyle(
|
||||||
TextStyle(fontSize: 11, color: Color(0xFF212121)),
|
fontSize: 11,
|
||||||
|
color: Color(0xFF212121),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/images/login/logoNew.jpg',
|
'assets/images/login/logoNew.jpg',
|
||||||
@ -226,7 +261,8 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(padding: EdgeInsets.zero, children: [drawerContent]));
|
child: ListView(padding: EdgeInsets.zero, children: [drawerContent]),
|
||||||
|
);
|
||||||
|
|
||||||
// if (widget.isDesktop) {
|
// if (widget.isDesktop) {
|
||||||
// // Sidebar for Desktop (always visible)**
|
// // Sidebar for Desktop (always visible)**
|
||||||
@ -244,7 +280,11 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
|
|
||||||
/// **Reusable Drawer Item**
|
/// **Reusable Drawer Item**
|
||||||
Widget _buildDrawerItem(
|
Widget _buildDrawerItem(
|
||||||
BuildContext context, IconData icon, String title, String route) {
|
BuildContext context,
|
||||||
|
IconData icon,
|
||||||
|
String title,
|
||||||
|
String route,
|
||||||
|
) {
|
||||||
String selectedRoute = GoRouterState.of(context).uri.toString();
|
String selectedRoute = GoRouterState.of(context).uri.toString();
|
||||||
|
|
||||||
// return Container(
|
// return Container(
|
||||||
@ -287,36 +327,34 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
return Material(
|
return Material(
|
||||||
color: selectedRoute == route ? bodyColor : Colors.transparent,
|
color: selectedRoute == route ? bodyColor : Colors.transparent,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Icon(
|
leading: Icon(icon, size: 20),
|
||||||
icon,
|
title: Text(
|
||||||
size: 20,
|
title,
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
title,
|
|
||||||
|
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
),
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontSize: 12,
|
|
||||||
// fontWeight: FontWeight.w600,
|
|
||||||
// color: Color(0xFF475569),
|
|
||||||
// fontFamily: "Archivo"),
|
|
||||||
),
|
),
|
||||||
// tileColor: selectedRoute == route ? Colors.blue.shade50 : null,
|
// style: TextStyle(
|
||||||
|
// fontSize: 12,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// color: Color(0xFF475569),
|
||||||
|
// fontFamily: "Archivo"),
|
||||||
|
),
|
||||||
|
|
||||||
onTap: () async {
|
// tileColor: selectedRoute == route ? Colors.blue.shade50 : null,
|
||||||
if (route == '/') {
|
onTap: () async {
|
||||||
// Handle logout separately
|
if (route == '/') {
|
||||||
final pref = await SharedPreferences.getInstance();
|
// Handle logout separately
|
||||||
await pref.clear(); // Clear stored token or session data
|
final pref = await SharedPreferences.getInstance();
|
||||||
context.go("/"); // Redirect to login instead of home
|
await pref.clear(); // Clear stored token or session data
|
||||||
} else {
|
context.go("/"); // Redirect to login instead of home
|
||||||
context.go(route);
|
} else {
|
||||||
}
|
context.go(route);
|
||||||
}),
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,11 +376,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
tilePadding: EdgeInsets.symmetric(horizontal: 16),
|
tilePadding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
// childrenPadding: EdgeInsets.only(left: 36),
|
// childrenPadding: EdgeInsets.only(left: 36),
|
||||||
leading: Icon(
|
leading: Icon(icon, size: 20, color: Color(0xFF475569)),
|
||||||
icon,
|
|
||||||
size: 20,
|
|
||||||
color: Color(0xFF475569),
|
|
||||||
),
|
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
// You could manually build this instead of using `leading`, but it's simpler here
|
// You could manually build this instead of using `leading`, but it's simpler here
|
||||||
@ -378,11 +412,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 44.0, vertical: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 44.0, vertical: 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(Icons.circle_rounded, color: Color(0xFF475569), size: 6),
|
||||||
Icons.circle_rounded,
|
|
||||||
color: Color(0xFF475569),
|
|
||||||
size: 6,
|
|
||||||
),
|
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
@ -399,20 +429,22 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildExpandableItem1(BuildContext context, IconData icon,
|
Widget _buildExpandableItem1(
|
||||||
String title, List<Widget> children) {
|
BuildContext context,
|
||||||
|
IconData icon,
|
||||||
|
String title,
|
||||||
|
List<Widget> children,
|
||||||
|
) {
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
leading: Icon(
|
leading: Icon(icon, size: 20),
|
||||||
icon,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
title: Text(
|
title: Text(
|
||||||
title,
|
title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
fontFamily: "Archivo"),
|
fontFamily: "Archivo",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
collapsedBackgroundColor: Colors.transparent,
|
collapsedBackgroundColor: Colors.transparent,
|
||||||
shape: const Border(), // Removes top and bottom dividers
|
shape: const Border(), // Removes top and bottom dividers
|
||||||
@ -423,20 +455,20 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSubDrawerItem1(
|
Widget _buildSubDrawerItem1(
|
||||||
BuildContext context, String title, String route) {
|
BuildContext context,
|
||||||
|
String title,
|
||||||
|
String route,
|
||||||
|
) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(
|
leading: Icon(Icons.circle_rounded, color: Color(0xFF475569), size: 8),
|
||||||
Icons.circle_rounded,
|
|
||||||
color: Color(0xFF475569),
|
|
||||||
size: 8,
|
|
||||||
),
|
|
||||||
title: Text(
|
title: Text(
|
||||||
title,
|
title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
color: Color(0xFF475569),
|
color: Color(0xFF475569),
|
||||||
fontFamily: "Archivo"),
|
fontFamily: "Archivo",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.go(route);
|
context.go(route);
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import 'package:frontend/Screens/userManagement/create_user/create_user1.dart';
|
|||||||
import 'package:frontend/Screens/userManagement/user_List.dart';
|
import 'package:frontend/Screens/userManagement/user_List.dart';
|
||||||
import 'package:frontend/routes/organizationSetting.dart';
|
import 'package:frontend/routes/organizationSetting.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
import '../Screens/allTrips/list_all_plans.dart';
|
import '../Screens/allTrips/list_all_plans.dart';
|
||||||
import '../Screens/allTrips/travel_agent_list.dart';
|
import '../Screens/allTrips/travel_agent_list.dart';
|
||||||
@ -23,6 +24,7 @@ import '../Screens/approvals/approval_list.dart';
|
|||||||
import '../Screens/group/group.dart';
|
import '../Screens/group/group.dart';
|
||||||
import '../Screens/group/groupList.dart';
|
import '../Screens/group/groupList.dart';
|
||||||
import '../Screens/myTemplates/template.dart';
|
import '../Screens/myTemplates/template.dart';
|
||||||
|
import '../Screens/myTemplates/templateForex.dart';
|
||||||
import '../Screens/myTemplates/templateTest.dart';
|
import '../Screens/myTemplates/templateTest.dart';
|
||||||
import '../Screens/userManagement/create_user/create_user.dart';
|
import '../Screens/userManagement/create_user/create_user.dart';
|
||||||
import '../Screens/department/department_list.dart';
|
import '../Screens/department/department_list.dart';
|
||||||
@ -30,96 +32,213 @@ import '../Screens/costCenter/costCenter_list.dart';
|
|||||||
import '../Screens/dashboard/status_dashboard.dart';
|
import '../Screens/dashboard/status_dashboard.dart';
|
||||||
import '../Screens/hotels/hotels_list.dart';
|
import '../Screens/hotels/hotels_list.dart';
|
||||||
import '../Screens/traveller/travellerList.dart';
|
import '../Screens/traveller/travellerList.dart';
|
||||||
|
import 'mainLayout.dart';
|
||||||
|
|
||||||
final GoRouter router = GoRouter(
|
final GoRouter router = GoRouter(
|
||||||
routes: [
|
routes: [
|
||||||
|
// Public routes without app bar
|
||||||
GoRoute(path: '/', builder: (context, state) => LoginPage()),
|
GoRoute(path: '/', builder: (context, state) => LoginPage()),
|
||||||
// GoRoute(
|
|
||||||
// path: '/authredirection',
|
// Routes that share the app bar and layout (nested routes)
|
||||||
// builder: (context, state) {
|
ShellRoute(
|
||||||
// final code = state.uri.queryParameters['code'];
|
builder: (context, state, child) {
|
||||||
// return MicrosoftPage(code: code);
|
// Use ResponsiveBuilder here to detect isDesktop and pass to MainLayout
|
||||||
// },
|
return child;
|
||||||
// ),
|
// return ResponsiveBuilder(
|
||||||
GoRoute(path: '/home', builder: (context, state) => HomePage()),
|
// builder: (context, sizingInfo) {
|
||||||
GoRoute(path: '/listAllPlan', builder: (context, state) => ListAllPlans()),
|
// bool isDesktop =
|
||||||
GoRoute(
|
// sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
path: '/listTravelAgentPlan',
|
//
|
||||||
builder: (context, state) => TravelAgentListPlans(),
|
// return MainLayout(isDesktop: isDesktop, child: child);
|
||||||
),
|
// },
|
||||||
GoRoute(path: '/listPlan', builder: (context, state) => ListPlans()),
|
// );
|
||||||
GoRoute(path: '/createPlan', builder: (context, state) => CreatePlan()),
|
},
|
||||||
GoRoute(path: '/allTrips/trips', builder: (context, state) => CreatePlan()),
|
routes: [
|
||||||
GoRoute(path: '/approver/plans', builder: (context, state) => CreatePlan()),
|
GoRoute(path: '/home', builder: (context, state) => HomePage()),
|
||||||
GoRoute(path: '/listUser', builder: (context, state) => UserListScreen()),
|
GoRoute(
|
||||||
GoRoute(
|
path: '/listAllPlan',
|
||||||
path: '/CreateUserDetails',
|
builder: (context, state) => ListAllPlans(),
|
||||||
builder: (context, state) => CreateUserFormDetials(),
|
),
|
||||||
// builder: (context, state) {
|
GoRoute(
|
||||||
// final userParam = state.uri.queryParameters['user'];
|
path: '/listTravelAgentPlan',
|
||||||
//
|
builder: (context, state) => TravelAgentListPlans(),
|
||||||
// final isEditProfile =
|
),
|
||||||
// state.uri.queryParameters['isEditProfile'] == 'true';
|
GoRoute(path: '/listPlan', builder: (context, state) => ListPlans()),
|
||||||
// final isViewMode = state.uri.queryParameters['isViewMode'] == 'true';
|
GoRoute(path: '/createPlan', builder: (context, state) => CreatePlan()),
|
||||||
//
|
GoRoute(
|
||||||
// final user = userParam != null
|
path: '/allTrips/trips',
|
||||||
// ? jsonDecode(Uri.decodeComponent(userParam))
|
builder: (context, state) => CreatePlan(),
|
||||||
// : null;
|
),
|
||||||
//
|
GoRoute(
|
||||||
// return CreateUserForm(
|
path: '/approver/plans',
|
||||||
// apiselectedUser: user,
|
builder: (context, state) => CreatePlan(),
|
||||||
// isEditProfile: isEditProfile,
|
),
|
||||||
// isViewMode: isViewMode,
|
GoRoute(
|
||||||
// );
|
path: '/listUser',
|
||||||
// }
|
builder: (context, state) => UserListScreen(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/Policy',
|
path: '/CreateUserDetails',
|
||||||
// builder: (context, state) => Policy(),
|
builder: (context, state) => CreateUserFormDetials(),
|
||||||
pageBuilder:
|
),
|
||||||
(context, state) => MaterialPage(child: Policy.fromState(state)),
|
GoRoute(
|
||||||
),
|
path: '/Policy',
|
||||||
GoRoute(path: '/PolicyList', builder: (context, state) => PolicyList()),
|
pageBuilder:
|
||||||
GoRoute(
|
(context, state) => MaterialPage(child: Policy.fromState(state)),
|
||||||
path: '/OrganizationSetup',
|
),
|
||||||
builder: (context, state) => OrgSetUp(),
|
GoRoute(path: '/PolicyList', builder: (context, state) => PolicyList()),
|
||||||
),
|
GoRoute(
|
||||||
GoRoute(
|
path: '/OrganizationSetup',
|
||||||
path: '/OrganizationSettings',
|
builder: (context, state) => OrgSetUp(),
|
||||||
builder: (context, state) => OrganizationSetting(),
|
),
|
||||||
),
|
GoRoute(
|
||||||
GoRoute(path: '/group', builder: (context, state) => GroupList()),
|
path: '/OrganizationSettings',
|
||||||
GoRoute(path: '/getPerdiem', builder: (context, state) => ForexDataList()),
|
builder: (context, state) => OrganizationSetting(),
|
||||||
GoRoute(
|
),
|
||||||
path: '/templateList',
|
GoRoute(path: '/group', builder: (context, state) => GroupList()),
|
||||||
builder: (context, state) => TemplatesList(),
|
GoRoute(
|
||||||
),
|
path: '/getPerdiem',
|
||||||
// GoRoute(
|
builder: (context, state) => ForexDataList(),
|
||||||
// path: '/template',
|
),
|
||||||
// builder: (context, state) => MyHomePage(),
|
GoRoute(
|
||||||
// ),
|
path: '/templateList',
|
||||||
GoRoute(
|
builder: (context, state) => TemplatesList(),
|
||||||
path: '/template',
|
),
|
||||||
// builder: (context, state) => Template(),
|
GoRoute(
|
||||||
pageBuilder:
|
path: '/template',
|
||||||
(context, state) => MaterialPage(child: Template.fromState(state)),
|
pageBuilder:
|
||||||
),
|
(context, state) =>
|
||||||
GoRoute(path: '/approvallist', builder: (context, state) => ApprovalList()),
|
MaterialPage(child: Template.fromState(state)),
|
||||||
GoRoute(path: '/department', builder: (context, state) => DepartmentList()),
|
),
|
||||||
GoRoute(path: '/costcenter', builder: (context, state) => CostCenterList()),
|
GoRoute(
|
||||||
GoRoute(path: '/hotels', builder: (context, state) => HotelsDataList()),
|
path: '/templateForex',
|
||||||
GoRoute(
|
pageBuilder:
|
||||||
path: '/statusdashboard',
|
(context, state) =>
|
||||||
builder: (context, state) => StatusDashboard(),
|
MaterialPage(child: TemplateForex.fromState(state)),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/traveller',
|
path: '/approvallist',
|
||||||
builder: (context, state) => TravellerList(),
|
builder: (context, state) => ApprovalList(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/CreateGroup',
|
path: '/department',
|
||||||
pageBuilder:
|
builder: (context, state) => DepartmentList(),
|
||||||
(context, state) => MaterialPage(child: Group.fromState(state)),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/costcenter',
|
||||||
|
builder: (context, state) => CostCenterList(),
|
||||||
|
),
|
||||||
|
GoRoute(path: '/hotels', builder: (context, state) => HotelsDataList()),
|
||||||
|
GoRoute(
|
||||||
|
path: '/statusdashboard',
|
||||||
|
builder: (context, state) => StatusDashboard(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/traveller',
|
||||||
|
builder: (context, state) => TravellerList(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/CreateGroup',
|
||||||
|
pageBuilder:
|
||||||
|
(context, state) => MaterialPage(child: Group.fromState(state)),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// final GoRouter router = GoRouter(
|
||||||
|
// routes: [
|
||||||
|
// GoRoute(path: '/', builder: (context, state) => LoginPage()),
|
||||||
|
// // GoRoute(
|
||||||
|
// // path: '/authredirection',
|
||||||
|
// // builder: (context, state) {
|
||||||
|
// // final code = state.uri.queryParameters['code'];
|
||||||
|
// // return MicrosoftPage(code: code);
|
||||||
|
// // },
|
||||||
|
// // ),
|
||||||
|
// GoRoute(path: '/home', builder: (context, state) => HomePage()),
|
||||||
|
// GoRoute(path: '/listAllPlan', builder: (context, state) => ListAllPlans()),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/listTravelAgentPlan',
|
||||||
|
// builder: (context, state) => TravelAgentListPlans(),
|
||||||
|
// ),
|
||||||
|
// GoRoute(path: '/listPlan', builder: (context, state) => ListPlans()),
|
||||||
|
// GoRoute(path: '/createPlan', builder: (context, state) => CreatePlan()),
|
||||||
|
// GoRoute(path: '/allTrips/trips', builder: (context, state) => CreatePlan()),
|
||||||
|
// GoRoute(path: '/approver/plans', builder: (context, state) => CreatePlan()),
|
||||||
|
// GoRoute(path: '/listUser', builder: (context, state) => UserListScreen()),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/CreateUserDetails',
|
||||||
|
// builder: (context, state) => CreateUserFormDetials(),
|
||||||
|
// // builder: (context, state) {
|
||||||
|
// // final userParam = state.uri.queryParameters['user'];
|
||||||
|
// //
|
||||||
|
// // final isEditProfile =
|
||||||
|
// // state.uri.queryParameters['isEditProfile'] == 'true';
|
||||||
|
// // final isViewMode = state.uri.queryParameters['isViewMode'] == 'true';
|
||||||
|
// //
|
||||||
|
// // final user = userParam != null
|
||||||
|
// // ? jsonDecode(Uri.decodeComponent(userParam))
|
||||||
|
// // : null;
|
||||||
|
// //
|
||||||
|
// // return CreateUserForm(
|
||||||
|
// // apiselectedUser: user,
|
||||||
|
// // isEditProfile: isEditProfile,
|
||||||
|
// // isViewMode: isViewMode,
|
||||||
|
// // );
|
||||||
|
// // }
|
||||||
|
// ),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/Policy',
|
||||||
|
// // builder: (context, state) => Policy(),
|
||||||
|
// pageBuilder:
|
||||||
|
// (context, state) => MaterialPage(child: Policy.fromState(state)),
|
||||||
|
// ),
|
||||||
|
// GoRoute(path: '/PolicyList', builder: (context, state) => PolicyList()),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/OrganizationSetup',
|
||||||
|
// builder: (context, state) => OrgSetUp(),
|
||||||
|
// ),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/OrganizationSettings',
|
||||||
|
// builder: (context, state) => OrganizationSetting(),
|
||||||
|
// ),
|
||||||
|
// GoRoute(path: '/group', builder: (context, state) => GroupList()),
|
||||||
|
// GoRoute(path: '/getPerdiem', builder: (context, state) => ForexDataList()),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/templateList',
|
||||||
|
// builder: (context, state) => TemplatesList(),
|
||||||
|
// ),
|
||||||
|
// // GoRoute(
|
||||||
|
// // path: '/template',
|
||||||
|
// // builder: (context, state) => MyHomePage(),
|
||||||
|
// // ),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/template',
|
||||||
|
// // builder: (context, state) => Template(),
|
||||||
|
// pageBuilder:
|
||||||
|
// (context, state) => MaterialPage(child: Template.fromState(state)),
|
||||||
|
// ),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/templateForex',
|
||||||
|
// pageBuilder:
|
||||||
|
// (context, state) =>
|
||||||
|
// MaterialPage(child: TemplateForex.fromState(state)),
|
||||||
|
// ),
|
||||||
|
// GoRoute(path: '/approvallist', builder: (context, state) => ApprovalList()),
|
||||||
|
// GoRoute(path: '/department', builder: (context, state) => DepartmentList()),
|
||||||
|
// GoRoute(path: '/costcenter', builder: (context, state) => CostCenterList()),
|
||||||
|
// GoRoute(path: '/hotels', builder: (context, state) => HotelsDataList()),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/statusdashboard',
|
||||||
|
// builder: (context, state) => StatusDashboard(),
|
||||||
|
// ),
|
||||||
|
// GoRoute(path: '/traveller', builder: (context, state) => TravellerList()),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/CreateGroup',
|
||||||
|
// pageBuilder:
|
||||||
|
// (context, state) => MaterialPage(child: Group.fromState(state)),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
|||||||
33
lib/routes/mainLayout.dart
Normal file
33
lib/routes/mainLayout.dart
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
|
import 'custom_appBar.dart';
|
||||||
|
import 'custom_drawer.dart';
|
||||||
|
|
||||||
|
class MainLayout extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final bool isDesktop;
|
||||||
|
|
||||||
|
const MainLayout({required this.child, required this.isDesktop, Key? key})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: const Color(0xFFf5f5f5),
|
||||||
|
appBar: CustomAppBar(isDesktop: isDesktop),
|
||||||
|
drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
|
||||||
|
body: Padding(
|
||||||
|
padding:
|
||||||
|
isDesktop
|
||||||
|
? EdgeInsets.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width * 0.1,
|
||||||
|
vertical: 0,
|
||||||
|
)
|
||||||
|
: EdgeInsets.zero,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:responsive_builder/responsive_builder.dart';
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
|
import '../services/apiService.dart';
|
||||||
import 'custom_appBar.dart';
|
import 'custom_appBar.dart';
|
||||||
import 'custom_drawer.dart';
|
import 'custom_drawer.dart';
|
||||||
|
|
||||||
@ -15,6 +16,8 @@ class OrganizationSetting extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OrganizationSettingState extends State<OrganizationSetting> {
|
class OrganizationSettingState extends State<OrganizationSetting> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ResponsiveBuilder(
|
return ResponsiveBuilder(
|
||||||
@ -84,7 +87,7 @@ class OrganizationSettingState extends State<OrganizationSetting> {
|
|||||||
'description': 'Create and Edit Perdiem Amount',
|
'description': 'Create and Edit Perdiem Amount',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'value': '/department',
|
'value': '/forexTexmplate',
|
||||||
'icon': Icons.group_add_outlined,
|
'icon': Icons.group_add_outlined,
|
||||||
'label': 'Forex Template',
|
'label': 'Forex Template',
|
||||||
'description': 'Create and Edit Template',
|
'description': 'Create and Edit Template',
|
||||||
@ -244,9 +247,21 @@ class OrganizationSettingState extends State<OrganizationSetting> {
|
|||||||
child: Card(
|
child: Card(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
final route = item['value'] as String;
|
if (item['value'] as String ==
|
||||||
context.go(route);
|
"/forexTexmplate") {
|
||||||
|
final data =
|
||||||
|
await apiService.getForexTemplate();
|
||||||
|
print("ForexId -- $data");
|
||||||
|
|
||||||
|
context.go(
|
||||||
|
'/templateForex',
|
||||||
|
extra: {'templateData': data},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final route = item['value'] as String;
|
||||||
|
context.go(route);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
|
|||||||
@ -5,11 +5,32 @@ import 'package:frontend/utils/auth_utils.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
import 'package:universal_html/js.dart';
|
import 'package:universal_html/js.dart';
|
||||||
import '../../config/apiUrl.dart';
|
import '../../config/apiUrl.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class ApiService {
|
class ApiService {
|
||||||
|
Future<void> getOrganizationData() async {
|
||||||
|
try {
|
||||||
|
print("getUpdatedServices");
|
||||||
|
final result = await fetchOrganization();
|
||||||
|
print("UUPdatedServices - $result");
|
||||||
|
|
||||||
|
// ✅ Save to local storage
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final jsonString = jsonEncode(result);
|
||||||
|
await prefs.setString('org_data', jsonString);
|
||||||
|
print("✅ Organization data saved to SharedPreferences.");
|
||||||
|
|
||||||
|
print("selectedOrg - $result");
|
||||||
|
} catch (e) {
|
||||||
|
print('Error fetching updatedServices list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<dynamic>> fetchCountryList() async {
|
Future<List<dynamic>> fetchCountryList() async {
|
||||||
final String apiUrldata = '$apiUrl/api/getcountryMaster';
|
final String apiUrldata = '$apiUrl/api/getcountryMaster';
|
||||||
final token = await getToken();
|
final token = await getToken();
|
||||||
@ -33,7 +54,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data['data'];
|
return data['data'];
|
||||||
@ -68,7 +90,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data['data'];
|
return data['data'];
|
||||||
@ -136,7 +159,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<dynamic> plansJson = data['data']; // 'data' is a Map, not a List
|
List<dynamic> plansJson = data['data']; // 'data' is a Map, not a List
|
||||||
@ -190,7 +214,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<dynamic> plansJson = data['data']; // 'data' is a Map, not a List
|
List<dynamic> plansJson = data['data']; // 'data' is a Map, not a List
|
||||||
@ -239,7 +264,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> plansJson =
|
Map<String, dynamic> plansJson =
|
||||||
@ -277,7 +303,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return data['data'];
|
return data['data'];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -313,7 +340,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return data['data'];
|
return data['data'];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -349,7 +377,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return data['data'];
|
return data['data'];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -385,7 +414,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return data['data'];
|
return data['data'];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -419,7 +449,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> plansJson =
|
Map<String, dynamic> plansJson =
|
||||||
@ -460,7 +491,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure each item is a Map<String, dynamic>
|
// Make sure each item is a Map<String, dynamic>
|
||||||
@ -527,33 +559,47 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> viewPlan(BuildContext context, String planId,
|
static Future<void> viewPlan(
|
||||||
{bool isViewMode = false, bool isMyTrips = false}) async {
|
BuildContext context,
|
||||||
|
String planId, {
|
||||||
|
bool isViewMode = false,
|
||||||
|
bool isMyTrips = false,
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> planData = await getViewPlanEdit(planId);
|
Map<String, dynamic> planData = await getViewPlanEdit(planId);
|
||||||
print("ViewAAA - $planData");
|
print("ViewAAA - $planData");
|
||||||
|
|
||||||
context.go(isMyTrips ? '/createPlan' : '/allTrips/trips',
|
context.go(
|
||||||
extra: {'planData': planData, 'isViewMode': isViewMode});
|
isMyTrips ? '/createPlan' : '/allTrips/trips',
|
||||||
|
extra: {'planData': planData, 'isViewMode': isViewMode},
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error fetching plan: $e");
|
print("Error fetching plan: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> viewPlanForApprover(BuildContext context, String planId,
|
static Future<void> viewPlanForApprover(
|
||||||
String? approverId, String? delegaterId,
|
BuildContext context,
|
||||||
{bool isViewMode = false, bool isApprover = true}) async {
|
String planId,
|
||||||
|
String? approverId,
|
||||||
|
String? delegaterId, {
|
||||||
|
bool isViewMode = false,
|
||||||
|
bool isApprover = true,
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> planData = await getViewPlanEdit(planId);
|
Map<String, dynamic> planData = await getViewPlanEdit(planId);
|
||||||
print("ViewAAA - $planData");
|
print("ViewAAA - $planData");
|
||||||
|
|
||||||
context.replace('/approver/plans', extra: {
|
context.replace(
|
||||||
'planData': planData,
|
'/approver/plans',
|
||||||
'approverId': approverId,
|
extra: {
|
||||||
'delegaterId': delegaterId,
|
'planData': planData,
|
||||||
'isViewMode': isViewMode,
|
'approverId': approverId,
|
||||||
'isApprover': isApprover,
|
'delegaterId': delegaterId,
|
||||||
});
|
'isViewMode': isViewMode,
|
||||||
|
'isApprover': isApprover,
|
||||||
|
},
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error fetching plan: $e");
|
print("Error fetching plan: $e");
|
||||||
}
|
}
|
||||||
@ -589,7 +635,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure each item is a Map<String, dynamic>
|
// Make sure each item is a Map<String, dynamic>
|
||||||
@ -635,7 +682,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data['data'];
|
return data['data'];
|
||||||
@ -671,7 +719,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data['data'];
|
return data['data'];
|
||||||
@ -709,13 +758,14 @@ class ApiService {
|
|||||||
// Create a blob from the response body
|
// Create a blob from the response body
|
||||||
final blob = html.Blob([response.bodyBytes]);
|
final blob = html.Blob([response.bodyBytes]);
|
||||||
|
|
||||||
// Generate a download URL for the blob
|
// Generate a download URL for the blob
|
||||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||||
|
|
||||||
// Create a link element to trigger the download
|
// Create a link element to trigger the download
|
||||||
final anchor = html.AnchorElement(href: url)
|
final anchor =
|
||||||
..setAttribute('download', 'trip_plan_$planId.pdf')
|
html.AnchorElement(href: url)
|
||||||
..click();
|
..setAttribute('download', 'trip_plan_$planId.pdf')
|
||||||
|
..click();
|
||||||
|
|
||||||
// Revoke the download URL to free up resources
|
// Revoke the download URL to free up resources
|
||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
@ -772,13 +822,14 @@ class ApiService {
|
|||||||
// Create a blob from the response body
|
// Create a blob from the response body
|
||||||
final blob = html.Blob([response.bodyBytes]);
|
final blob = html.Blob([response.bodyBytes]);
|
||||||
|
|
||||||
// Generate a download URL for the blob
|
// Generate a download URL for the blob
|
||||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||||
|
|
||||||
// Create a link element to trigger the download
|
// Create a link element to trigger the download
|
||||||
final anchor = html.AnchorElement(href: url)
|
final anchor =
|
||||||
..setAttribute('download', 'Forex_$forexId.pdf')
|
html.AnchorElement(href: url)
|
||||||
..click();
|
..setAttribute('download', 'Forex_$forexId.pdf')
|
||||||
|
..click();
|
||||||
|
|
||||||
// Revoke the download URL to free up resources
|
// Revoke the download URL to free up resources
|
||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
@ -835,7 +886,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
print('Single USer 1');
|
print('Single USer 1');
|
||||||
|
|
||||||
@ -880,7 +932,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<dynamic> forexList = data['data'];
|
final List<dynamic> forexList = data['data'];
|
||||||
@ -925,7 +978,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Map<String, dynamic>> listData =
|
final List<Map<String, dynamic>> listData =
|
||||||
@ -984,7 +1038,62 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Map<String, dynamic>.from(data['data']);
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Error parsing response: $e');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load department details');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getForexTemplate() async {
|
||||||
|
final String apiUrldata =
|
||||||
|
'$apiUrl/api/getForexTemplate?template_name=forex';
|
||||||
|
|
||||||
|
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('findout the result');
|
||||||
|
// print(data.runtimeType);
|
||||||
|
print(data);
|
||||||
|
|
||||||
|
// if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
|
// throw Exception(
|
||||||
|
// "Invalid response format: 'data' field is missing or not a List");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final List<Map<String, dynamic>> listData =
|
||||||
|
// List<Map<String, dynamic>>.from(data['data']);
|
||||||
|
//
|
||||||
|
// if (listData.isEmpty) {
|
||||||
|
// throw Exception("No department found with ID $id");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return listData[0];
|
||||||
|
|
||||||
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
|
throw Exception(
|
||||||
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Map<String, dynamic>.from(data['data']);
|
return Map<String, dynamic>.from(data['data']);
|
||||||
@ -997,7 +1106,9 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> showCancelConfirmationDialog(
|
Future<bool> showCancelConfirmationDialog(
|
||||||
BuildContext context, Color? layoutColor) async {
|
BuildContext context,
|
||||||
|
Color? layoutColor,
|
||||||
|
) async {
|
||||||
return await showDialog<bool>(
|
return await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -1006,33 +1117,39 @@ class ApiService {
|
|||||||
title: Text(
|
title: Text(
|
||||||
'Cancel Confirmation',
|
'Cancel Confirmation',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 18, fontWeight: FontWeight.w500),
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
content: Text(
|
content: Text(
|
||||||
'Do you want to cancel?',
|
'Do you want to cancel?',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14.5, fontWeight: FontWeight.w500),
|
fontSize: 14.5,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
foregroundColor: layoutColor,
|
foregroundColor: layoutColor,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: layoutColor ?? Colors.grey, width: 2),
|
color: layoutColor ?? Colors.grey,
|
||||||
|
width: 2,
|
||||||
),
|
),
|
||||||
padding:
|
|
||||||
EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
Navigator.of(context).pop(false);
|
),
|
||||||
},
|
onPressed: () {
|
||||||
child: Text(
|
Navigator.of(context).pop(false);
|
||||||
"Cancel",
|
},
|
||||||
style: GoogleFonts.poppins(fontSize: 12),
|
child: Text(
|
||||||
)),
|
"Cancel",
|
||||||
|
style: GoogleFonts.poppins(fontSize: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: layoutColor, // Keep original color
|
backgroundColor: layoutColor, // Keep original color
|
||||||
@ -1043,16 +1160,17 @@ class ApiService {
|
|||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: layoutColor ?? Colors.grey, width: 1),
|
color: layoutColor ?? Colors.grey,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context)
|
onPressed:
|
||||||
.pop(true), // Disable when in view mode
|
() => Navigator.of(
|
||||||
child: Text(
|
context,
|
||||||
"OK",
|
).pop(true), // Disable when in view mode
|
||||||
style: GoogleFonts.poppins(fontSize: 12),
|
child: Text("OK", style: GoogleFonts.poppins(fontSize: 12)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -1087,7 +1205,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Map<String, dynamic>> listData =
|
final List<Map<String, dynamic>> listData =
|
||||||
@ -1132,7 +1251,8 @@ class ApiService {
|
|||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a List");
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Map<String, dynamic>> listData =
|
final List<Map<String, dynamic>> listData =
|
||||||
@ -1174,7 +1294,8 @@ class ApiService {
|
|||||||
print(data);
|
print(data);
|
||||||
if (!data.containsKey('data') || data['data'] is! Map) {
|
if (!data.containsKey('data') || data['data'] is! Map) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Invalid response format: 'data' field is missing or not a Map");
|
"Invalid response format: 'data' field is missing or not a Map",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
print('Single USer 1');
|
print('Single USer 1');
|
||||||
|
|
||||||
@ -1194,7 +1315,6 @@ class ApiService {
|
|||||||
Future<Map<String, dynamic>> getTravellerDetailsFind(int id) async {
|
Future<Map<String, dynamic>> getTravellerDetailsFind(int id) async {
|
||||||
final String apiUrldata = '$apiUrl/api/travellers/find?traveller_id=$id';
|
final String apiUrldata = '$apiUrl/api/travellers/find?traveller_id=$id';
|
||||||
|
|
||||||
|
|
||||||
//c
|
//c
|
||||||
final token = await getToken();
|
final token = await getToken();
|
||||||
|
|
||||||
@ -1215,11 +1335,13 @@ class ApiService {
|
|||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception("Invalid response format: 'data' field is missing or not a List");
|
throw Exception(
|
||||||
|
"Invalid response format: 'data' field is missing or not a List",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Map<String, dynamic>> listData =
|
final List<Map<String, dynamic>> listData =
|
||||||
List<Map<String, dynamic>>.from(data['data']);
|
List<Map<String, dynamic>>.from(data['data']);
|
||||||
|
|
||||||
if (listData.isEmpty) {
|
if (listData.isEmpty) {
|
||||||
throw Exception("No Traveller data found with ID $id");
|
throw Exception("No Traveller data found with ID $id");
|
||||||
@ -1233,5 +1355,4 @@ class ApiService {
|
|||||||
throw Exception('Failed to load Hotel details');
|
throw Exception('Failed to load Hotel details');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user