Bug Fix
This commit is contained in:
parent
335fbacede
commit
1a568f6878
BIN
lib-jun6-9:03.zip
Normal file
BIN
lib-jun6-9:03.zip
Normal file
Binary file not shown.
@ -208,6 +208,7 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
// List<dynamic> plansJson = [];
|
||||
List<dynamic> plansJson = data['data'];
|
||||
return plansJson.map((json) => Plan.fromJson(json)).toList();
|
||||
} else {
|
||||
@ -580,6 +581,8 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
||||
} else if (snapshot.hasError ||
|
||||
!snapshot.hasData ||
|
||||
snapshot.data!.isEmpty) {
|
||||
final adjHgt = MediaQuery.of(context).size.height;
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@ -597,25 +600,16 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
||||
// color: Colors.redAccent),
|
||||
//
|
||||
// ),
|
||||
const SizedBox(height: 15),
|
||||
SizedBox(height: adjHgt / 4),
|
||||
Text(
|
||||
"No Trips",
|
||||
" No Trips Found",
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Please Create Trip",
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -43,8 +43,6 @@ class _ApprovalListState extends State<ApprovalList> {
|
||||
List<Plan> filteredPlans = [];
|
||||
TextEditingController searchController = TextEditingController();
|
||||
|
||||
late List<dynamic> plansJson;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -188,7 +186,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
plansJson = data['data'];
|
||||
List<dynamic> plansJson = data['data'];
|
||||
return plansJson.map((json) => Plan.fromJson(json)).toList();
|
||||
} else {
|
||||
throw Exception('Failed to load plans');
|
||||
@ -608,7 +606,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 20,
|
||||
// fontFamily: "Inter",
|
||||
fontWeight: FontWeight.w600,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
|
||||
@ -881,7 +881,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
final data = json.decode(response.body);
|
||||
print(data);
|
||||
print("CostCenterdropdoen - $data");
|
||||
|
||||
if (!data.containsKey('data') || data['data'] is! List) {
|
||||
throw Exception(
|
||||
@ -905,13 +905,13 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
apiCostData = plansJson;
|
||||
costCenterMap = {
|
||||
for (var item in apiCostData!)
|
||||
item['department_id'].toString(): item['name'].toString(),
|
||||
item['cost_center_id'].toString(): item['name'].toString(),
|
||||
};
|
||||
costCenterIds = costCenterMap.keys.toList();
|
||||
|
||||
// Optionally auto-select the first item if not already selected
|
||||
// selectedCostCenterId ??=
|
||||
// costCenterIds.isNotEmpty ? costCenterIds.first : null;
|
||||
selectedCostCenterId ??=
|
||||
costCenterIds.isNotEmpty ? costCenterIds.first : null;
|
||||
});
|
||||
|
||||
print('plansJSON');
|
||||
@ -1630,18 +1630,13 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
);
|
||||
}
|
||||
|
||||
String? getSelectedCostCenterName() {
|
||||
if (selectedCostCenterId == null || apiCostData == null) return null;
|
||||
return apiCostData!.firstWhere(
|
||||
(item) => item['department_id'] == selectedCostCenterId,
|
||||
orElse: () => null,
|
||||
)?['name'];
|
||||
}
|
||||
|
||||
/// Extracted helper function
|
||||
///
|
||||
///
|
||||
///
|
||||
// String? getSelectedCostCenterName() {
|
||||
// if (selectedCostCenterId == null || apiCostData == null) return null;
|
||||
// return apiCostData!.firstWhere(
|
||||
// (item) => item['department_id'] == selectedCostCenterId,
|
||||
// orElse: () => null,
|
||||
// )?['name'];
|
||||
// }
|
||||
|
||||
final List<Map<String, dynamic>> allTripTypes = [
|
||||
{"dropdown_key": "1", "dropdown_value": "Domestic"},
|
||||
|
||||
@ -2,7 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
// import 'package:flutter/rendering.dart';
|
||||
import 'dart:html' as html;
|
||||
import 'package:frontend/config/apiUrl.dart'; // 1 newly added
|
||||
import 'package:frontend/services/apiService.dart';
|
||||
@ -31,7 +31,7 @@ class _MyAppState extends State<MyApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||
// SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||
if (kIsWeb) {
|
||||
final uri = Uri.parse(html.window.location.href);
|
||||
if (uri.path == '/authredirection' &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user