merge with old code
This commit is contained in:
commit
128b0ea9e6
@ -898,6 +898,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
||||
plan.planId,
|
||||
plan.approverId,
|
||||
plan.delegaterId,
|
||||
plan.approver_status,
|
||||
isViewMode:
|
||||
false,
|
||||
isApprover:
|
||||
@ -1144,6 +1145,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
||||
plan.planId,
|
||||
plan.approverId,
|
||||
plan.delegaterId,
|
||||
plan.approver_status,
|
||||
isViewMode: false,
|
||||
isApprover: true,
|
||||
);
|
||||
|
||||
@ -125,6 +125,7 @@ class _LoginWidgetState extends State<LoginWidget> {
|
||||
final token = data['token']; // Assuming the token is in response
|
||||
// final userId = data['user_id'].toString();
|
||||
|
||||
print("Token - $token");
|
||||
await storeUserDetails(token);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -297,6 +297,11 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
errorMessages["end_date"] =
|
||||
"End date cannot be earlier than start date";
|
||||
;
|
||||
} else if (checkEndDate.isAtSameMomentAs(checkStartDate)) {
|
||||
setState(() {
|
||||
errorMessages["end_date"] =
|
||||
"Start and end dates cannot be the same";
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
errorMessages["end_date"] = "Invalid date format";
|
||||
@ -350,16 +355,6 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
final cash = data["deposit_on_cash"];
|
||||
print("card - $card");
|
||||
print("cash - $cash");
|
||||
// Call validations first (they populate errorMessages)
|
||||
_validateCardAmount(card);
|
||||
_validateCashAmount(cash);
|
||||
|
||||
// Now check if any errors exist
|
||||
if (errorMessages.isNotEmpty) {
|
||||
print("Validation Failed: ${errorMessages}");
|
||||
setState(() {}); // Refresh UI with error messages
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValidForexData(data)) {
|
||||
// && errorMessages.isNotEmpty) {
|
||||
@ -416,6 +411,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
textControllers["_forexStartDate"]?.addListener(_onFieldChanged);
|
||||
textControllers["_forexEndDate"]?.addListener(_onFieldChanged);
|
||||
|
||||
|
||||
flightFirstTripDateNotifier = ValueNotifier<String?>(null);
|
||||
flightLastTripDateNotifier = ValueNotifier<String?>(null);
|
||||
|
||||
@ -509,6 +505,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
// textControllers["_cardNumber"]!.text = userCardNumber ?? '';
|
||||
//
|
||||
// }
|
||||
|
||||
_onFieldChangedForOthers();
|
||||
setState(() {}); // Update the UI
|
||||
|
||||
@ -544,7 +541,6 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
|
||||
// Handle field changes
|
||||
void _onFieldChanged() {
|
||||
print("_on Field Changed Called");
|
||||
if (_isForexDataDurationComplete()) {
|
||||
print("Calculate 1");
|
||||
CalculateDuration();
|
||||
@ -581,7 +577,8 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
print("Calculate 4");
|
||||
|
||||
// Calculate difference
|
||||
final durationInDays = endDate.difference(startDate).inDays ; // +1 to include both days
|
||||
final durationInDays =
|
||||
endDate.difference(startDate).inDays; // +1 to include both days
|
||||
|
||||
// You can now use durationInDays however you want:
|
||||
print("Duration: $durationInDays days");
|
||||
@ -763,9 +760,6 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
for (var controller in textControllers.values) {
|
||||
controller.dispose();
|
||||
}
|
||||
// textControllers["_forexStartDate"]?.removeListener(_onFieldChanged);
|
||||
// textControllers["_forexEndDate"]?.removeListener(_onFieldChanged);
|
||||
// textControllers.forEach((_, controller) => controller.dispose());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -1021,18 +1015,36 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
textControllers["_forexEndDate"]!.text,
|
||||
);
|
||||
|
||||
if (startDate != null &&
|
||||
endDate != null &&
|
||||
endDate.isBefore(startDate)) {
|
||||
setState(() {
|
||||
errorMessages["end_date"] =
|
||||
"End date cannot be earlier than start date";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
errorMessages.remove("end_date");
|
||||
});
|
||||
if (startDate != null && endDate != null) {
|
||||
if (endDate.isBefore(startDate)) {
|
||||
setState(() {
|
||||
errorMessages["end_date"] =
|
||||
"End date cannot be earlier than start date";
|
||||
});
|
||||
} else if (endDate.isAtSameMomentAs(startDate)) {
|
||||
setState(() {
|
||||
errorMessages["end_date"] =
|
||||
"Start and end dates cannot be the same";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
errorMessages.remove("end_date");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// if (startDate != null &&
|
||||
// endDate != null &&
|
||||
// endDate.isBefore(startDate)) {
|
||||
// setState(() {
|
||||
// errorMessages["end_date"] =
|
||||
// "End date cannot be earlier than start date";
|
||||
// });
|
||||
// } else {
|
||||
// setState(() {
|
||||
// errorMessages.remove("end_date");
|
||||
// });
|
||||
// }
|
||||
}
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
@ -1108,6 +1120,11 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
errorMessages["end_date"] =
|
||||
"End date cannot be earlier than start date";
|
||||
});
|
||||
} else if (endDate!.isAtSameMomentAs(startDate!)) {
|
||||
setState(() {
|
||||
errorMessages["end_date"] =
|
||||
"Start and end dates cannot be the same";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
errorMessages.remove("end_date");
|
||||
|
||||
@ -124,6 +124,7 @@ class _CreatePlansState extends State<CreatePlan> {
|
||||
final bool isApprover = args?['isApprover'] ?? false;
|
||||
final String approverId = args['approverId'] ?? "";
|
||||
final String delegaterId = args['delegaterId'] ?? "";
|
||||
final String approverStatus = args['approver_status'] ?? "";
|
||||
|
||||
final Map<String, dynamic> planData =
|
||||
args['planData'] as Map<String, dynamic>? ?? {};
|
||||
@ -216,6 +217,7 @@ class _CreatePlansState extends State<CreatePlan> {
|
||||
isApprover: isApprover,
|
||||
approverId: approverId,
|
||||
delegaterId: delegaterId,
|
||||
approverStatus: approverStatus,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -325,6 +327,7 @@ class CreateNewPlan extends StatefulWidget {
|
||||
final bool isDesktop;
|
||||
final bool isViewMode;
|
||||
final bool isApprover;
|
||||
final String? approverStatus;
|
||||
final Color? bodyColor;
|
||||
final Color? layoutColor;
|
||||
|
||||
@ -341,6 +344,7 @@ class CreateNewPlan extends StatefulWidget {
|
||||
required this.selectedPlanData,
|
||||
required this.isViewMode,
|
||||
required this.isApprover,
|
||||
required this.approverStatus,
|
||||
required this.approverId,
|
||||
required this.delegaterId,
|
||||
});
|
||||
@ -375,6 +379,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
bool isStatusExpanded = false;
|
||||
bool isShowApprovalAction = false;
|
||||
String? selectedPlanId;
|
||||
String? approverStatus;
|
||||
|
||||
String? userDetails;
|
||||
String? userName;
|
||||
@ -502,7 +507,11 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print("approverStatus - ${widget.approverStatus}");
|
||||
|
||||
if (widget.approverStatus == "Approval pending") {
|
||||
print("Status approver - Approval Pending");
|
||||
}
|
||||
flightTripTypeNotifier = ValueNotifier(null);
|
||||
|
||||
fetchUserDetails();
|
||||
@ -1169,6 +1178,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
data['plan_id'],
|
||||
data['approverId'],
|
||||
data['delegaterId'],
|
||||
data['approver_status'],
|
||||
|
||||
isViewMode: false,
|
||||
isApprover: true,
|
||||
);
|
||||
@ -1295,366 +1306,373 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
),
|
||||
);
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInfo) {
|
||||
bool isMobile = sizingInfo.isMobile;
|
||||
bool isDesktop =
|
||||
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||
return FocusTraversalGroup(
|
||||
policy: OrderedTraversalPolicy(), // 👈 more predictable tab order
|
||||
descendantsAreFocusable: true,
|
||||
child: ResponsiveBuilder(
|
||||
builder: (context, sizingInfo) {
|
||||
bool isMobile = sizingInfo.isMobile;
|
||||
bool isDesktop =
|
||||
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ResponsiveBuilder(
|
||||
builder: (context, sizingInfo) {
|
||||
bool isDesktop =
|
||||
sizingInfo.deviceScreenType ==
|
||||
DeviceScreenType.desktop;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ResponsiveBuilder(
|
||||
builder: (context, sizingInfo) {
|
||||
bool isDesktop =
|
||||
sizingInfo.deviceScreenType ==
|
||||
DeviceScreenType.desktop;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child:
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildTripName(isDesktop),
|
||||
if (isDesktop) Spacer(),
|
||||
..._buildApproverControls(isDesktop),
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child:
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildTripName(isDesktop),
|
||||
if (isDesktop) Spacer(),
|
||||
..._buildApproverControls(isDesktop),
|
||||
|
||||
// Text(
|
||||
// widget.isViewMode
|
||||
// ? "View Plan"
|
||||
// : (selectedPlanId != null &&
|
||||
// selectedPlanId!.isNotEmpty
|
||||
// ? "Update Plan"
|
||||
// : "New Plan"),
|
||||
// style: TextStyle(fontSize: 18),
|
||||
// ),
|
||||
// Spacer(),
|
||||
if (statusValue != "")
|
||||
..._buildPlanPdf(isDesktop),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
..._buildApproverControls(
|
||||
isDesktop,
|
||||
),
|
||||
if (statusValue != "")
|
||||
..._buildPlanPdf(isDesktop),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [_buildTripName(isDesktop)],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// if (isStatusExpanded)
|
||||
// Container(
|
||||
// margin: isDesktop
|
||||
// ? const EdgeInsets.only(left: 0, top: 0)
|
||||
// : const EdgeInsets.only(left: 5, top: 2),
|
||||
// padding: const EdgeInsets.all(12),
|
||||
// width: isDesktop
|
||||
// ? MediaQuery.of(context).size.width * 0.2
|
||||
// : MediaQuery.of(context).size.width,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Color(0xFFF5F5F5),
|
||||
// border: Border.all(
|
||||
// // color: Colors.grey.shade300,
|
||||
// color: Colors.white,
|
||||
// width: 0.2),
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// // boxShadow: [
|
||||
// // BoxShadow(
|
||||
// // // color: Colors.grey.withAlpha(20),
|
||||
// // color: Colors.grey.withAlpha(20),
|
||||
// // spreadRadius: 1.5,
|
||||
// // blurRadius: 7,
|
||||
// // offset: Offset(0, 4), // shadow direction: bottom
|
||||
// // ),
|
||||
// // ],
|
||||
// ),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// if (!hasApprovals)
|
||||
// Center(
|
||||
// child: Text(
|
||||
// "--- No Approvals ---",
|
||||
// style: TextStyle(
|
||||
// fontFamily: "Archivo",
|
||||
// fontSize: 11,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: Colors.black87,
|
||||
// ),
|
||||
// )),
|
||||
// for (int i = 0; i < planStatusList.length; i++) ...[
|
||||
// if (planStatusList[i].entries.any((entry) =>
|
||||
// entry.key.contains('status') &&
|
||||
// entry.value != null &&
|
||||
// entry.value.toString().isNotEmpty)) ...[
|
||||
// _buildApprovalItem(
|
||||
// "Approver ${i + 1}",
|
||||
// planStatusList[i]
|
||||
// .entries
|
||||
// .firstWhere(
|
||||
// (entry) => entry.key.contains('status'),
|
||||
// orElse: () => MapEntry('', ''),
|
||||
// )
|
||||
// .value
|
||||
// .toString(),
|
||||
// ),
|
||||
// SizedBox(height: 6),
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
if (isApproverRejected)
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 4, left: 8),
|
||||
child: Text(
|
||||
"Remarks : ",
|
||||
style: TextStyle(
|
||||
fontFamily: "Archivo",
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
), // tweak if needed
|
||||
child: TextFormField(
|
||||
controller: _remarksController,
|
||||
// Text(
|
||||
// widget.isViewMode
|
||||
// ? "View Plan"
|
||||
// : (selectedPlanId != null &&
|
||||
// selectedPlanId!.isNotEmpty
|
||||
// ? "Update Plan"
|
||||
// : "New Plan"),
|
||||
// style: TextStyle(fontSize: 18),
|
||||
// ),
|
||||
// Spacer(),
|
||||
if (statusValue != "")
|
||||
..._buildPlanPdf(isDesktop),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
..._buildApproverControls(
|
||||
isDesktop,
|
||||
),
|
||||
if (statusValue != "")
|
||||
..._buildPlanPdf(isDesktop),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTripName(isDesktop),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// if (isStatusExpanded)
|
||||
// Container(
|
||||
// margin: isDesktop
|
||||
// ? const EdgeInsets.only(left: 0, top: 0)
|
||||
// : const EdgeInsets.only(left: 5, top: 2),
|
||||
// padding: const EdgeInsets.all(12),
|
||||
// width: isDesktop
|
||||
// ? MediaQuery.of(context).size.width * 0.2
|
||||
// : MediaQuery.of(context).size.width,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Color(0xFFF5F5F5),
|
||||
// border: Border.all(
|
||||
// // color: Colors.grey.shade300,
|
||||
// color: Colors.white,
|
||||
// width: 0.2),
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// // boxShadow: [
|
||||
// // BoxShadow(
|
||||
// // // color: Colors.grey.withAlpha(20),
|
||||
// // color: Colors.grey.withAlpha(20),
|
||||
// // spreadRadius: 1.5,
|
||||
// // blurRadius: 7,
|
||||
// // offset: Offset(0, 4), // shadow direction: bottom
|
||||
// // ),
|
||||
// // ],
|
||||
// ),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// if (!hasApprovals)
|
||||
// Center(
|
||||
// child: Text(
|
||||
// "--- No Approvals ---",
|
||||
// style: TextStyle(
|
||||
// fontFamily: "Archivo",
|
||||
// fontSize: 11,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: Colors.black87,
|
||||
// ),
|
||||
// )),
|
||||
// for (int i = 0; i < planStatusList.length; i++) ...[
|
||||
// if (planStatusList[i].entries.any((entry) =>
|
||||
// entry.key.contains('status') &&
|
||||
// entry.value != null &&
|
||||
// entry.value.toString().isNotEmpty)) ...[
|
||||
// _buildApprovalItem(
|
||||
// "Approver ${i + 1}",
|
||||
// planStatusList[i]
|
||||
// .entries
|
||||
// .firstWhere(
|
||||
// (entry) => entry.key.contains('status'),
|
||||
// orElse: () => MapEntry('', ''),
|
||||
// )
|
||||
// .value
|
||||
// .toString(),
|
||||
// ),
|
||||
// SizedBox(height: 6),
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
if (isApproverRejected)
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 4, left: 8),
|
||||
child: Text(
|
||||
"Remarks : ",
|
||||
style: TextStyle(
|
||||
fontFamily: "Archivo",
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 11,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: "Please enter remarks...",
|
||||
hintStyle: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
maxLines: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// if (widget.isApprover || isStatusExpanded)
|
||||
Divider(thickness: 0.1, color: Colors.blueGrey),
|
||||
if (widget.isApprover) SizedBox(height: 5),
|
||||
|
||||
Text(
|
||||
"Planning This Trip For*", // Your label
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF575A74),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
isDesktop
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(children: _buildPlanTrip(isDesktop)),
|
||||
)
|
||||
: Row(children: _buildPlanTrip(isDesktop)),
|
||||
SizedBox(height: 7),
|
||||
|
||||
// Text(
|
||||
// otherUserName ?? userName ?? " ", // Your label
|
||||
//
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 11,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// color: widget.layoutColor,
|
||||
// ),
|
||||
// ),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "Trip Planned User : ", // Static text
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF212121),
|
||||
// color: Color(0xFF575A74), // Default color
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text:
|
||||
otherUserName ??
|
||||
userName ??
|
||||
" ", // Dynamic username
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color:
|
||||
widget
|
||||
.layoutColor, // Change this to any color
|
||||
// color: Colors.blueAccent, // Change this to any color
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
), // tweak if needed
|
||||
child: TextFormField(
|
||||
controller: _remarksController,
|
||||
style: TextStyle(
|
||||
fontFamily: "Archivo",
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 11,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: "Please enter remarks...",
|
||||
hintStyle: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
maxLines: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
// if (widget.isApprover || isStatusExpanded)
|
||||
Divider(thickness: 0.1, color: Colors.blueGrey),
|
||||
if (widget.isApprover) SizedBox(height: 5),
|
||||
|
||||
Text(
|
||||
"Planning This Trip For*", // Your label
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF575A74),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
isDesktop
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(children: _buildPlanTrip(isDesktop)),
|
||||
)
|
||||
: Row(children: _buildPlanTrip(isDesktop)),
|
||||
SizedBox(height: 7),
|
||||
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Divider(
|
||||
// color: Color(0xFFE6E7F5), // Change color
|
||||
// thickness: 0.5,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(height: 10),
|
||||
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child:
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildTripRow(isMobile),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildTripRow(isMobile),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildCostCenter(isDesktop),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildCostCenter(isDesktop),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// _buildNonDescriptionColumn(),
|
||||
// SizedBox(width: 25),
|
||||
_buildDescriptionColumn(isDesktop),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// _buildNonDescriptionColumn(),
|
||||
// SizedBox(height: 15),
|
||||
_buildDescriptionColumn(isDesktop),
|
||||
],
|
||||
),
|
||||
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Divider(
|
||||
// color: Color(0xFFE6E7F5), // Change color
|
||||
// thickness: 0.5,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(height: 20),
|
||||
|
||||
if (temporaryMessage != null)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
// validationErrors["services"]!,
|
||||
temporaryMessage!,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.red,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
// Text(
|
||||
// otherUserName ?? userName ?? " ", // Your label
|
||||
//
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 11,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// color: widget.layoutColor,
|
||||
// ),
|
||||
// ),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "Trip Planned User : ", // Static text
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF212121),
|
||||
// color: Color(0xFF575A74), // Default color
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text:
|
||||
otherUserName ??
|
||||
userName ??
|
||||
" ", // Dynamic username
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color:
|
||||
widget
|
||||
.layoutColor, // Change this to any color
|
||||
// color: Colors.blueAccent, // Change this to any color
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (temporaryMessage != null) SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DynamicItinerary(
|
||||
key: dynamicItineraryKey,
|
||||
flightScreenKey: flightScreenKey,
|
||||
tripTypeNotifier: flightTripTypeNotifier,
|
||||
hasAction: hasAction,
|
||||
tripType: _selectedTripType,
|
||||
apiData: apiData,
|
||||
apiDataForClass: apiDataForClass,
|
||||
apiCountryData: apiCountryData,
|
||||
onItineraryUpdate: handleItineraryUpdate,
|
||||
loginUser: selfId,
|
||||
selectedPlanData: planData,
|
||||
isViewMode: widget.isViewMode,
|
||||
),
|
||||
), // Wrap with Expanded if needed
|
||||
],
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
],
|
||||
);
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Divider(
|
||||
// color: Color(0xFFE6E7F5), // Change color
|
||||
// thickness: 0.5,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(height: 10),
|
||||
|
||||
// Row(
|
||||
// children: [
|
||||
// isDesktop
|
||||
// ? Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: _buildSubmit(isDesktop),
|
||||
// )
|
||||
// : Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: _buildSubmit(isDesktop),
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
},
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child:
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildTripRow(isMobile),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildTripRow(isMobile),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildCostCenter(isDesktop),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildCostCenter(isDesktop),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
isDesktop
|
||||
? Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// _buildNonDescriptionColumn(),
|
||||
// SizedBox(width: 25),
|
||||
_buildDescriptionColumn(isDesktop),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// _buildNonDescriptionColumn(),
|
||||
// SizedBox(height: 15),
|
||||
_buildDescriptionColumn(isDesktop),
|
||||
],
|
||||
),
|
||||
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Divider(
|
||||
// color: Color(0xFFE6E7F5), // Change color
|
||||
// thickness: 0.5,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(height: 20),
|
||||
|
||||
if (temporaryMessage != null)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
// validationErrors["services"]!,
|
||||
temporaryMessage!,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.red,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (temporaryMessage != null) SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DynamicItinerary(
|
||||
key: dynamicItineraryKey,
|
||||
flightScreenKey: flightScreenKey,
|
||||
tripTypeNotifier: flightTripTypeNotifier,
|
||||
hasAction: hasAction,
|
||||
tripType: _selectedTripType,
|
||||
apiData: apiData,
|
||||
apiDataForClass: apiDataForClass,
|
||||
apiCountryData: apiCountryData,
|
||||
onItineraryUpdate: handleItineraryUpdate,
|
||||
loginUser: selfId,
|
||||
selectedPlanData: planData,
|
||||
isViewMode: widget.isViewMode,
|
||||
),
|
||||
), // Wrap with Expanded if needed
|
||||
],
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
],
|
||||
);
|
||||
|
||||
// Row(
|
||||
// children: [
|
||||
// isDesktop
|
||||
// ? Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: _buildSubmit(isDesktop),
|
||||
// )
|
||||
// : Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: _buildSubmit(isDesktop),
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
},
|
||||
),
|
||||
// replace with your full form column
|
||||
);
|
||||
}
|
||||
|
||||
@ -3132,7 +3150,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
// ],
|
||||
// ),
|
||||
const SizedBox(height: 10, width: 10),
|
||||
if (widget.isApprover)
|
||||
if (widget.isApprover && (widget.approverStatus == "Approval pending"))
|
||||
GestureDetector(
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
|
||||
@ -42,9 +42,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
final ApiService apiService = ApiService();
|
||||
|
||||
final GlobalKey<PersonalDetailsState> personalDetailsKey =
|
||||
GlobalKey<PersonalDetailsState>();
|
||||
GlobalKey<PersonalDetailsState>();
|
||||
final GlobalKey<TravellerDetailsState> travellerDetailsKey =
|
||||
GlobalKey<TravellerDetailsState>();
|
||||
GlobalKey<TravellerDetailsState>();
|
||||
|
||||
// late List<Map<String, dynamic>?> travelDetailsData;
|
||||
Map<String, dynamic>? travelDetailsData;
|
||||
@ -64,6 +64,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
final Map<String, TextEditingController> controllers = {};
|
||||
bool isViewMode = false;
|
||||
bool isEditProfile = false;
|
||||
|
||||
// late final List<dynamic>? apiCountryData ;
|
||||
|
||||
late List<dynamic>? apiCountryData;
|
||||
@ -86,6 +87,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
|
||||
String? selectedCountry;
|
||||
String? selectedGender;
|
||||
|
||||
// String? selectedGender = personalDetailsKey.currentState?.selectedGender;
|
||||
|
||||
String? selectedUserType;
|
||||
@ -299,7 +301,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
// Fix the invalid JSON (dangerous if the format changes)
|
||||
final fixedJson = raw.replaceAllMapped(
|
||||
RegExp(r'(\w+):'), // matches `service_id:`
|
||||
(match) => '"${match.group(1)}":',
|
||||
(match) => '"${match.group(1)}":',
|
||||
);
|
||||
|
||||
List<dynamic> decodedList = jsonDecode(fixedJson);
|
||||
@ -363,7 +365,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
// }
|
||||
|
||||
final extraData =
|
||||
GoRouterState.of(context).extra as Map<String, dynamic>?;
|
||||
GoRouterState.of(context).extra as Map<String, dynamic>?;
|
||||
|
||||
if (extraData != null) {
|
||||
print("extraData: ${extraData['selectedUser']}");
|
||||
@ -381,8 +383,8 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
|
||||
// Handle selectedUser as a Map (not a List)
|
||||
apiselectedUser =
|
||||
extraData['selectedUser']
|
||||
as Map<String, dynamic>?; // Cast it as a Map
|
||||
extraData['selectedUser']
|
||||
as Map<String, dynamic>?; // Cast it as a Map
|
||||
isViewMode = extraData['isViewMode'] ?? false;
|
||||
isEditProfile = extraData['isEditProfile'] ?? false;
|
||||
});
|
||||
@ -444,7 +446,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
userMap = {
|
||||
for (var user in userList)
|
||||
user['user_id'].toString():
|
||||
"${user['first_name']} ${user['last_name']}",
|
||||
"${user['first_name']} ${user['last_name']}",
|
||||
};
|
||||
userIdsApi = userMap.keys.toList();
|
||||
});
|
||||
@ -483,14 +485,14 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
|
||||
setState(() {
|
||||
layoutColor =
|
||||
layoutString != null
|
||||
? Color(int.parse(layoutString))
|
||||
: Colors.redAccent;
|
||||
layoutString != null
|
||||
? Color(int.parse(layoutString))
|
||||
: Colors.redAccent;
|
||||
|
||||
bodyColor =
|
||||
bodyStringColor != null
|
||||
? Color(int.parse(bodyStringColor))
|
||||
: Colors.white;
|
||||
bodyStringColor != null
|
||||
? Color(int.parse(bodyStringColor))
|
||||
: Colors.white;
|
||||
});
|
||||
}
|
||||
|
||||
@ -654,11 +656,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
void handleSubmit() async {
|
||||
print("USR Detail Submit");
|
||||
// printFormData();
|
||||
|
||||
print("travel validation");
|
||||
bool isValid = travellerDetailsKey.currentState?.boolValidation() ?? false;
|
||||
if (selectedTab == "travel" ||
|
||||
selectedRole == "5" ||
|
||||
setSelectesUserType == true) {
|
||||
if (selectedRole == "5" || setSelectesUserType == true) {
|
||||
print("NO validation");
|
||||
|
||||
Map<String, dynamic> data = userDetials;
|
||||
@ -702,30 +702,64 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
|
||||
// block-submit-here
|
||||
|
||||
// Additional validation starts - travelDetailsData passport
|
||||
DateTime? start_Date = travelDetailsData?['date_of_issue'];
|
||||
DateTime? end_Date = travelDetailsData?['date_of_expiry'];
|
||||
final format = DateFormat("dd-MM-yyyy");
|
||||
|
||||
if (start_Date != null && end_Date != null && start_Date.toString().isNotEmpty && end_Date.toString().isNotEmpty) {
|
||||
try {
|
||||
final format = DateFormat("dd-MM-yyyy");
|
||||
final checkStartDate = format.parse("$start_Date");
|
||||
final checkEndDate = format.parse("$end_Date");
|
||||
DateTime? start_Date;
|
||||
DateTime? end_Date;
|
||||
|
||||
if (checkEndDate.isBefore(checkStartDate)) {
|
||||
// return "End date cannot be earlier than start date";;
|
||||
return ;
|
||||
}
|
||||
} catch (e) { // return "End date cannot be earlier than start date";
|
||||
return ;
|
||||
// errorMessages["end_date"] = "Invalid date format";
|
||||
try {
|
||||
if (travelDetailsData?['date_of_issue'] != null &&
|
||||
travelDetailsData!['date_of_issue'].toString().isNotEmpty) {
|
||||
start_Date = format.parse(travelDetailsData!['date_of_issue']);
|
||||
}
|
||||
if (travelDetailsData?['date_of_expiry'] != null &&
|
||||
travelDetailsData!['date_of_expiry'].toString().isNotEmpty) {
|
||||
end_Date = format.parse(travelDetailsData!['date_of_expiry']);
|
||||
}
|
||||
|
||||
if (start_Date != null &&
|
||||
end_Date != null &&
|
||||
end_Date.isBefore(start_Date)) {
|
||||
print("End date cannot be earlier than start date");
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Invalid passport date format");
|
||||
return;
|
||||
}
|
||||
|
||||
// Additional validation starts - travelDetailsData passport
|
||||
// DateTime? start_Date = travelDetailsData?['date_of_issue'];
|
||||
// DateTime? end_Date = travelDetailsData?['date_of_expiry'];
|
||||
//
|
||||
// if (start_Date != null &&
|
||||
// end_Date != null &&
|
||||
// start_Date.toString().isNotEmpty &&
|
||||
// end_Date.toString().isNotEmpty) {
|
||||
// try {
|
||||
// final format = DateFormat("dd-MM-yyyy");
|
||||
// final checkStartDate = format.parse("$start_Date");
|
||||
// final checkEndDate = format.parse("$end_Date");
|
||||
//
|
||||
// if (checkEndDate.isBefore(checkStartDate)) {
|
||||
// // return "End date cannot be earlier than start date";;
|
||||
// return;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// // return "End date cannot be earlier than start date";
|
||||
// return;
|
||||
// // errorMessages["end_date"] = "Invalid date format";
|
||||
// }
|
||||
// }
|
||||
|
||||
// valid_from: 20-06-2025, valid_upto: 19-06-2025
|
||||
DateTime? valid_from = data?['valid_from'];
|
||||
DateTime? valid_upto = data?['valid_upto'];
|
||||
|
||||
if (valid_from != null && valid_upto != null && valid_from.toString().isNotEmpty && valid_upto.toString().isNotEmpty) {
|
||||
if (valid_from != null &&
|
||||
valid_upto != null &&
|
||||
valid_from.toString().isNotEmpty &&
|
||||
valid_upto.toString().isNotEmpty) {
|
||||
try {
|
||||
final format = DateFormat("dd-MM-yyyy");
|
||||
final checkValidFrom = format.parse("$valid_from");
|
||||
@ -733,10 +767,11 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
|
||||
if (checkValidUpto.isBefore(checkValidFrom)) {
|
||||
// return "valid upto cannot be earlier than valid from";
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
} catch (e) { // return "valid upto cannot be earlier than valid from";
|
||||
return ;
|
||||
} catch (e) {
|
||||
// return "valid upto cannot be earlier than valid from";
|
||||
return;
|
||||
// errorMessages["end_date"] = "Invalid date format";
|
||||
}
|
||||
}
|
||||
@ -785,7 +820,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
if (data["mobile_no"] != null && data["mobile_no"].toString().isNotEmpty) {
|
||||
if (!RegExp(r"^\d{10}$").hasMatch(data["mobile_no"].toString())) {
|
||||
errorMessages["mobile_no"] =
|
||||
"Enter 10 digits"; // Invalid mobile number format
|
||||
"Enter 10 digits"; // Invalid mobile number format
|
||||
}
|
||||
}
|
||||
|
||||
@ -795,7 +830,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
r"^\d{10}$",
|
||||
).hasMatch(data["alternate_mobile_no"].toString())) {
|
||||
errorMessages["alternate_mobile_no"] =
|
||||
"Enter 10 digits"; // Invalid mobile number format
|
||||
"Enter 10 digits"; // Invalid mobile number format
|
||||
}
|
||||
}
|
||||
|
||||
@ -985,7 +1020,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
// ✅ Ensure UI updates
|
||||
if (isMatch) {
|
||||
errorMessages["password"] =
|
||||
"New password is not similar to old password";
|
||||
"New password is not similar to old password";
|
||||
print(" Password match!");
|
||||
} else {
|
||||
print(" Password NOT match!");
|
||||
@ -1014,16 +1049,16 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
drawer: CustomDrawer(isDesktop: false),
|
||||
body: Padding(
|
||||
padding:
|
||||
isDesktop
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
MediaQuery.of(context).size.width *
|
||||
0.1, // 30% of screen width as horizontal padding
|
||||
vertical:
|
||||
MediaQuery.of(context).size.height *
|
||||
0, // 5% of screen height as vertical padding
|
||||
)
|
||||
: EdgeInsets.all(0),
|
||||
isDesktop
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
MediaQuery.of(context).size.width *
|
||||
0.1, // 30% of screen width as horizontal padding
|
||||
vertical:
|
||||
MediaQuery.of(context).size.height *
|
||||
0, // 5% of screen height as vertical padding
|
||||
)
|
||||
: EdgeInsets.all(0),
|
||||
child: Row(
|
||||
children: [Expanded(child: buildData(isDesktop, context))],
|
||||
),
|
||||
@ -1045,9 +1080,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
Expanded(
|
||||
child: Container(
|
||||
height:
|
||||
isDesktop
|
||||
? MediaQuery.of(context).size.height * 0.98
|
||||
: MediaQuery.of(context).size.height,
|
||||
isDesktop
|
||||
? MediaQuery.of(context).size.height * 0.98
|
||||
: MediaQuery.of(context).size.height,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
child: _buildUserDetails(isDesktop),
|
||||
@ -1059,39 +1094,39 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child:
|
||||
isDesktop
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (selectedTab != "personal")
|
||||
..._buildBack(isDesktop, layoutColor!),
|
||||
Spacer(), // spacing between buttons
|
||||
// Next or Submit based on role or user type
|
||||
if (selectedTab == "travel" ||
|
||||
selectedRole == "5" ||
|
||||
setSelectesUserType == true)
|
||||
..._buildSubmit(isDesktop, layoutColor!)
|
||||
else
|
||||
..._buildNext(isDesktop, layoutColor!),
|
||||
// (selectedTab == "travel" ||
|
||||
// selectedRole == "5" ||
|
||||
// setSelectesUserType == true)
|
||||
// ? _buildSubmit(isDesktop, layoutColor!)
|
||||
// : _buildNext(
|
||||
// isDesktop,
|
||||
// layoutColor!,
|
||||
// ), // _buildGoBack(isDesktop, layoutColor!),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children:
|
||||
(selectedTab == "travel" ||
|
||||
selectedRole == "5" ||
|
||||
setSelectesUserType == true)
|
||||
? _buildSubmit(isDesktop, layoutColor!)
|
||||
: _buildNext(isDesktop, layoutColor!),
|
||||
),
|
||||
isDesktop
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (selectedTab != "personal")
|
||||
..._buildBack(isDesktop, layoutColor!),
|
||||
Spacer(), // spacing between buttons
|
||||
// Next or Submit based on role or user type
|
||||
if (selectedTab == "travel" ||
|
||||
selectedRole == "5" ||
|
||||
setSelectesUserType == true)
|
||||
..._buildSubmit(isDesktop, layoutColor!)
|
||||
else
|
||||
..._buildNext(isDesktop, layoutColor!),
|
||||
// (selectedTab == "travel" ||
|
||||
// selectedRole == "5" ||
|
||||
// setSelectesUserType == true)
|
||||
// ? _buildSubmit(isDesktop, layoutColor!)
|
||||
// : _buildNext(
|
||||
// isDesktop,
|
||||
// layoutColor!,
|
||||
// ), // _buildGoBack(isDesktop, layoutColor!),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children:
|
||||
(selectedTab == "travel" ||
|
||||
selectedRole == "5" ||
|
||||
setSelectesUserType == true)
|
||||
? _buildSubmit(isDesktop, layoutColor!)
|
||||
: _buildNext(isDesktop, layoutColor!),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -1136,9 +1171,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
isDesktop
|
||||
? buildTabsForUser()
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: buildTabsForUser(),
|
||||
),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: buildTabsForUser(),
|
||||
),
|
||||
Container(
|
||||
// color: Colors.yellow.shade50,
|
||||
height: MediaQuery.of(context).size.height * 0.64,
|
||||
@ -1241,8 +1276,8 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
);
|
||||
case "travel":
|
||||
final fullName =
|
||||
"${controllers["Fname"]?.text ?? ""} ${controllers["Lname"]?.text ?? ""}"
|
||||
.trim();
|
||||
"${controllers["Fname"]?.text ?? ""} ${controllers["Lname"]?.text ?? ""}"
|
||||
.trim();
|
||||
return TravellerDetails(
|
||||
key: travellerDetailsKey,
|
||||
isDesktop: isDesktop,
|
||||
@ -1301,69 +1336,69 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end, // important
|
||||
children:
|
||||
tabs.entries.map((entry) {
|
||||
final targetTab = entry.key;
|
||||
tabs.entries.map((entry) {
|
||||
final targetTab = entry.key;
|
||||
|
||||
print("TargetsTAb: $targetTab");
|
||||
print("TargetsTAb: $targetTab");
|
||||
|
||||
final isSelected = selectedTab == entry.key;
|
||||
print("isSelected: $isSelected");
|
||||
final isSelected = selectedTab == entry.key;
|
||||
print("isSelected: $isSelected");
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
bool isValid = false;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
bool isValid = false;
|
||||
|
||||
final currentTab = selectedTab;
|
||||
if (currentTab == "personal") {
|
||||
isValid = isValidData(userDetials);
|
||||
final currentTab = selectedTab;
|
||||
if (currentTab == "personal") {
|
||||
isValid = isValidData(userDetials);
|
||||
|
||||
if (isValid) {
|
||||
selectedTab = entry.key;
|
||||
}
|
||||
} else if (currentTab == "office" &&
|
||||
targetTab == "personal") {
|
||||
selectedTab = entry.key;
|
||||
} else if (currentTab == "office") {
|
||||
isValid = isValidDataTwo(userDetials);
|
||||
if (isValid) {
|
||||
selectedTab = entry.key;
|
||||
}
|
||||
} else {
|
||||
isValid =
|
||||
true; // Travel tab might not need validation at this point
|
||||
selectedTab = entry.key;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 24.0,
|
||||
), // space between tabs
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
entry.value,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color:
|
||||
isSelected ? Color(0xFF114D8B) : Color(0xFF475569),
|
||||
),
|
||||
if (isValid) {
|
||||
selectedTab = entry.key;
|
||||
}
|
||||
} else if (currentTab == "office" &&
|
||||
targetTab == "personal") {
|
||||
selectedTab = entry.key;
|
||||
} else if (currentTab == "office") {
|
||||
isValid = isValidDataTwo(userDetials);
|
||||
if (isValid) {
|
||||
selectedTab = entry.key;
|
||||
}
|
||||
} else {
|
||||
isValid =
|
||||
true; // Travel tab might not need validation at this point
|
||||
selectedTab = entry.key;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 24.0,
|
||||
), // space between tabs
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
entry.value,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color:
|
||||
isSelected ? Color(0xFF114D8B) : Color(0xFF475569),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
height: 2,
|
||||
width: isSelected ? 50 : 0, // small line
|
||||
color: Color(0xFF114D8B),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
height: 2,
|
||||
width: isSelected ? 50 : 0, // small line
|
||||
color: Color(0xFF114D8B),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1373,17 +1408,17 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
return [
|
||||
MouseRegion(
|
||||
cursor:
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
foregroundColor:
|
||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||
disabledBackgroundColor:
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
disabledForegroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@ -1402,17 +1437,17 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
return [
|
||||
MouseRegion(
|
||||
cursor:
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
foregroundColor:
|
||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||
disabledBackgroundColor:
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
disabledForegroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@ -1433,17 +1468,17 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
return [
|
||||
MouseRegion(
|
||||
cursor:
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
child: TextButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||
foregroundColor:
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
disabledBackgroundColor:
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
disabledForegroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@ -1481,19 +1516,19 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
if (!isViewMode)
|
||||
MouseRegion(
|
||||
cursor:
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||
foregroundColor:
|
||||
isViewMode
|
||||
? Colors.white
|
||||
: Colors.white, // Keep original color
|
||||
isViewMode
|
||||
? Colors.white
|
||||
: Colors.white, // Keep original color
|
||||
disabledBackgroundColor:
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
layoutColor, // Ensure color remains when disabled
|
||||
disabledForegroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@ -1502,7 +1537,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
),
|
||||
onPressed:
|
||||
isViewMode ? null : handleSubmit, // Disable when in view mode
|
||||
isViewMode ? null : handleSubmit, // Disable when in view mode
|
||||
child: Text("Submit"),
|
||||
),
|
||||
),
|
||||
|
||||
@ -155,6 +155,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
bool boolValidation() {
|
||||
print("travel validation start");
|
||||
print("visaEntries - $visaEntries");
|
||||
|
||||
final passportText = controllers["passportNumber"]?.text ?? "";
|
||||
|
||||
if (_selectedTripType == "Indian") {
|
||||
@ -173,6 +176,80 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
}
|
||||
|
||||
final format = DateFormat("dd-MM-yyyy");
|
||||
|
||||
DateTime? start_Date;
|
||||
DateTime? end_Date;
|
||||
|
||||
try {
|
||||
if (controllers["dateOfIssue"]?.text != null &&
|
||||
controllers["dateOfIssue"]!.text.isNotEmpty) {
|
||||
start_Date = format.parse(controllers["dateOfIssue"]!.text);
|
||||
}
|
||||
if (controllers["dateOfExpiry"]?.text != null &&
|
||||
controllers["dateOfExpiry"]!.text.isNotEmpty) {
|
||||
end_Date = format.parse(controllers["dateOfExpiry"]!.text);
|
||||
}
|
||||
|
||||
if (start_Date != null &&
|
||||
end_Date != null &&
|
||||
end_Date.isBefore(start_Date)) {
|
||||
setState(() {
|
||||
errorMessages["date_of_expiry"] = "End date cannot be earlier";
|
||||
});
|
||||
print("End date cannot be earlier than start date");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Invalid passport date format");
|
||||
}
|
||||
|
||||
// Additional validation starts - travelDetailsData passport
|
||||
// DateTime? start_Date = travelDetailsData?['date_of_issue'];
|
||||
// DateTime? end_Date = travelDetailsData?['date_of_expiry'];
|
||||
//
|
||||
// if (start_Date != null &&
|
||||
// end_Date != null &&
|
||||
// start_Date.toString().isNotEmpty &&
|
||||
// end_Date.toString().isNotEmpty) {
|
||||
// try {
|
||||
// final format = DateFormat("dd-MM-yyyy");
|
||||
// final checkStartDate = format.parse("$start_Date");
|
||||
// final checkEndDate = format.parse("$end_Date");
|
||||
//
|
||||
// if (checkEndDate.isBefore(checkStartDate)) {
|
||||
// // return "End date cannot be earlier than start date";;
|
||||
// return;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// // return "End date cannot be earlier than start date";
|
||||
// return;
|
||||
// // errorMessages["end_date"] = "Invalid date format";
|
||||
// }
|
||||
// }
|
||||
|
||||
// valid_from: 20-06-2025, valid_upto: 19-06-2025
|
||||
// DateTime? valid_from = data?['valid_from'];
|
||||
// DateTime? valid_upto = data?['valid_upto'];
|
||||
//
|
||||
// if (valid_from != null &&
|
||||
// valid_upto != null &&
|
||||
// valid_from.toString().isNotEmpty &&
|
||||
// valid_upto.toString().isNotEmpty) {
|
||||
// try {
|
||||
// final format = DateFormat("dd-MM-yyyy");
|
||||
// final checkValidFrom = format.parse("$valid_from");
|
||||
// final checkValidUpto = format.parse("$valid_upto");
|
||||
//
|
||||
// if (checkValidUpto.isBefore(checkValidFrom)) {
|
||||
// // return "valid upto cannot be earlier than valid from";
|
||||
// }
|
||||
// } catch (e) {
|
||||
// // return "valid upto cannot be earlier than valid from";
|
||||
//
|
||||
// // errorMessages["end_date"] = "Invalid date format";
|
||||
// }
|
||||
// }
|
||||
print("travel validation end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1355,30 +1432,34 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
DateTime? _selectedDateOfExpiry;
|
||||
|
||||
Widget buildDateOfIssue() {
|
||||
|
||||
Future<void> _selectCheckDateOfIssue(BuildContext context) async {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime today = DateTime(now.year, now.month, now.day);
|
||||
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today)
|
||||
? _selectedDateOfIssue!
|
||||
: today,
|
||||
initialDate:
|
||||
_selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today)
|
||||
? _selectedDateOfIssue!
|
||||
: today,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
// lastDate: DateTime(2100),
|
||||
lastDate: today,
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
);
|
||||
|
||||
if (pickedDate != null && pickedDate != _selectedDateOfIssue) {
|
||||
setState(() {
|
||||
_selectedDateOfIssue = pickedDate;
|
||||
controllers["dateOfIssue"]?.text = DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
controllers["dateOfIssue"]?.text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(pickedDate);
|
||||
|
||||
// Revalidate expiry
|
||||
if (_selectedDateOfExpiry != null &&
|
||||
_selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) {
|
||||
errorMessages["date_of_expiry"] = "Expiry date cannot be earlier than Issue date";
|
||||
errorMessages["date_of_expiry"] =
|
||||
"Expiry date cannot be earlier than Issue date";
|
||||
} else {
|
||||
errorMessages.remove("date_of_expiry");
|
||||
}
|
||||
@ -1400,25 +1481,25 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: GestureDetector(
|
||||
onTap:
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfIssue(context);
|
||||
if (controllers["dateOfIssue"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfIssue(context);
|
||||
if (controllers["dateOfIssue"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
child: TextField(
|
||||
controller: controllers["dateOfIssue"],
|
||||
@ -1449,9 +1530,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
Widget buildDateOfExpiry() {
|
||||
|
||||
Future<void> _selectCheckDateOfExpiry(BuildContext context) async {
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
DateTime today = DateTime(now.year, now.month, now.day);
|
||||
// DateTime firstDate = today;
|
||||
@ -1500,11 +1579,14 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
if (pickedDate != null) {
|
||||
setState(() {
|
||||
_selectedDateOfExpiry = pickedDate;
|
||||
controllers["dateOfExpiry"]?.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
controllers["dateOfExpiry"]?.text = DateFormat(
|
||||
"dd-MM-yyyy",
|
||||
).format(pickedDate);
|
||||
|
||||
if (_selectedDateOfIssue != null &&
|
||||
_selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) {
|
||||
errorMessages["date_of_expiry"] = "Expiry date cannot be earlier than Issue date";
|
||||
errorMessages["date_of_expiry"] =
|
||||
"Expiry date cannot be earlier than Issue date";
|
||||
} else {
|
||||
errorMessages.remove("date_of_expiry");
|
||||
}
|
||||
@ -1540,23 +1622,23 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: GestureDetector(
|
||||
onTap:
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfExpiry(context);
|
||||
if (controllers["dateOfExpiry"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfExpiry(context);
|
||||
if (controllers["dateOfExpiry"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
child: TextField(
|
||||
controller: controllers["dateOfExpiry"],
|
||||
@ -1588,7 +1670,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
errorMessages["date_of_expiry"]!,
|
||||
style: const TextStyle(color: Colors.red, fontSize: 10),
|
||||
maxLines: 2, // Allow it to wrap onto two lines
|
||||
overflow: TextOverflow.ellipsis, // Add ellipsis if it still overflows
|
||||
overflow:
|
||||
TextOverflow.ellipsis, // Add ellipsis if it still overflows
|
||||
),
|
||||
],
|
||||
],
|
||||
@ -4057,7 +4140,6 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
DateTime? _selectedCheckInDate;
|
||||
|
||||
Widget buildVisaValidFrom(Map<String, dynamic> entry) {
|
||||
|
||||
TimeOfDay? _selectedCheckOutTime;
|
||||
|
||||
Future<void> _selectValidFromDate(BuildContext context) async {
|
||||
@ -4078,19 +4160,23 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
// initialDate: initialDate,
|
||||
// firstDate: initialDate,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
// lastDate: DateTime(2100),
|
||||
lastDate: today,
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
);
|
||||
|
||||
if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
|
||||
setState(() {
|
||||
_selectedCheckInDate = pickedDate;
|
||||
entry["controller_valid_from"]?.text = DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
entry["controller_valid_from"]?.text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(pickedDate);
|
||||
|
||||
// Revalidate expiry
|
||||
if (_selectedCheckOutDate != null &&
|
||||
_selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) {
|
||||
errorMessages["valid_upto"] = "valid upto cannot be earlier than valid from";
|
||||
errorMessages["valid_upto"] =
|
||||
"valid upto cannot be earlier than valid from";
|
||||
} else {
|
||||
errorMessages.remove("valid_upto");
|
||||
}
|
||||
@ -4112,9 +4198,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
@ -4151,7 +4237,6 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
Widget buildVisaValidUpTo(Map<String, dynamic> entry) {
|
||||
|
||||
TimeOfDay? _selectedCheckOutTime;
|
||||
|
||||
Future<void> _selectValidUpToDate(BuildContext context) async {
|
||||
@ -4202,11 +4287,14 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
|
||||
setState(() {
|
||||
_selectedCheckOutDate = pickedDate;
|
||||
entry["controller_valid_upto"].text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
entry["controller_valid_upto"].text = DateFormat(
|
||||
"dd-MM-yyyy",
|
||||
).format(pickedDate);
|
||||
|
||||
if (_selectedCheckInDate != null &&
|
||||
_selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) {
|
||||
errorMessages["valid_upto"] = "valid upto cannot be earlier than valid from";
|
||||
errorMessages["valid_upto"] =
|
||||
"valid upto cannot be earlier than valid from";
|
||||
} else {
|
||||
errorMessages.remove("valid_upto");
|
||||
}
|
||||
@ -4228,9 +4316,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
@ -4269,7 +4357,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
errorMessages["valid_upto"]!,
|
||||
style: const TextStyle(color: Colors.red, fontSize: 10),
|
||||
maxLines: 2, // Allow it to wrap onto two lines
|
||||
overflow: TextOverflow.ellipsis, // Add ellipsis if it still overflows
|
||||
overflow:
|
||||
TextOverflow.ellipsis, // Add ellipsis if it still overflows
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@ -5,6 +5,7 @@ class Plan {
|
||||
final String tripTitle;
|
||||
final String tripType;
|
||||
final String status;
|
||||
final String approver_status;
|
||||
final String costCenter;
|
||||
final String functionalDepartment;
|
||||
final String purposeOfTravel;
|
||||
@ -23,6 +24,7 @@ class Plan {
|
||||
required this.planId,
|
||||
this.employeeCode,
|
||||
required this.tripTitle,
|
||||
required this.approver_status,
|
||||
required this.tripType,
|
||||
required this.status,
|
||||
required this.costCenter,
|
||||
@ -46,6 +48,7 @@ class Plan {
|
||||
employeeCode: json['employee_code'],
|
||||
tripTitle: json['trip_title'],
|
||||
tripType: json['trip_type_value'],
|
||||
approver_status: json['approver_status'],
|
||||
status: json['status'] == "0" ? "Inactive" : "Active",
|
||||
costCenter: json['cost_center_value'] ?? '',
|
||||
functionalDepartment: json['functional_department_value'] ?? '',
|
||||
|
||||
@ -4,6 +4,6 @@ import 'app.dart';
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
void main() {
|
||||
setUrlStrategy(PathUrlStrategy());
|
||||
// setUrlStrategy(PathUrlStrategy());
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
"name": "${userDetails["first_name"]} ${userDetails["last_name"]}",
|
||||
"email": userDetails["email"] ?? "",
|
||||
"role": userDetails["role"] ?? "",
|
||||
"last_login_at": userDetails["last_login_at"] ?? "",
|
||||
};
|
||||
} catch (e) {
|
||||
print("Error decoding user data: $e");
|
||||
@ -282,6 +283,18 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
// Clear localStorage
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.clear(); // Clears all keys
|
||||
|
||||
// Optional: clear sessionStorage if used
|
||||
// html.window.sessionStorage.clear();
|
||||
|
||||
// Navigate to login or home page
|
||||
context.go('/');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
@ -431,7 +444,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
actions: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||
horizontal: MediaQuery.of(context).size.width * 0.055,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@ -478,7 +491,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
},
|
||||
);
|
||||
case '/logout':
|
||||
context.go('/');
|
||||
logout(context);
|
||||
// context.go('/');
|
||||
break;
|
||||
}
|
||||
},
|
||||
@ -523,6 +537,15 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Last Login: ${userData?["last_login_at"]}" ??
|
||||
'',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 8.5,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const Divider(), // 👈 Divider after role
|
||||
],
|
||||
),
|
||||
|
||||
@ -102,6 +102,7 @@ class ApiService {
|
||||
throw Exception('Failed to load country list');
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<dynamic>> fetchAirlineList() async {
|
||||
final String apiUrldata = '$apiUrl/api/getAirlineMaster';
|
||||
final token = await getToken();
|
||||
@ -617,6 +618,7 @@ class ApiService {
|
||||
BuildContext context,
|
||||
String planId,
|
||||
String? approverId,
|
||||
String? approver_status,
|
||||
String? delegaterId, {
|
||||
bool isViewMode = false,
|
||||
bool isApprover = true,
|
||||
@ -629,6 +631,7 @@ class ApiService {
|
||||
'/approver/plans',
|
||||
extra: {
|
||||
'planData': planData,
|
||||
'approver_status': approver_status,
|
||||
'approverId': approverId,
|
||||
'delegaterId': delegaterId,
|
||||
'isViewMode': isViewMode,
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
This is a placeholder for base href that will be replaced by the value of
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
-->
|
||||
<base href="$FLUTTER_BASE_HREF">
|
||||
<base href="/tstat/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user