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) {
|
if (response.statusCode == 200) {
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
|
// List<dynamic> plansJson = [];
|
||||||
List<dynamic> plansJson = data['data'];
|
List<dynamic> plansJson = data['data'];
|
||||||
return plansJson.map((json) => Plan.fromJson(json)).toList();
|
return plansJson.map((json) => Plan.fromJson(json)).toList();
|
||||||
} else {
|
} else {
|
||||||
@ -580,6 +581,8 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
} else if (snapshot.hasError ||
|
} else if (snapshot.hasError ||
|
||||||
!snapshot.hasData ||
|
!snapshot.hasData ||
|
||||||
snapshot.data!.isEmpty) {
|
snapshot.data!.isEmpty) {
|
||||||
|
final adjHgt = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
@ -597,25 +600,16 @@ class _ListAllPlansState extends State<ListAllPlans> {
|
|||||||
// color: Colors.redAccent),
|
// color: Colors.redAccent),
|
||||||
//
|
//
|
||||||
// ),
|
// ),
|
||||||
const SizedBox(height: 15),
|
SizedBox(height: adjHgt / 4),
|
||||||
Text(
|
Text(
|
||||||
"No Trips",
|
" No Trips Found",
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.black54,
|
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 = [];
|
List<Plan> filteredPlans = [];
|
||||||
TextEditingController searchController = TextEditingController();
|
TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
late List<dynamic> plansJson;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -188,7 +186,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
plansJson = data['data'];
|
List<dynamic> plansJson = data['data'];
|
||||||
return plansJson.map((json) => Plan.fromJson(json)).toList();
|
return plansJson.map((json) => Plan.fromJson(json)).toList();
|
||||||
} else {
|
} else {
|
||||||
throw Exception('Failed to load plans');
|
throw Exception('Failed to load plans');
|
||||||
@ -608,7 +606,7 @@ class _ApprovalListState extends State<ApprovalList> {
|
|||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
// fontFamily: "Inter",
|
// fontFamily: "Inter",
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -881,7 +881,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
print(data);
|
print("CostCenterdropdoen - $data");
|
||||||
|
|
||||||
if (!data.containsKey('data') || data['data'] is! List) {
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
@ -905,13 +905,13 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
apiCostData = plansJson;
|
apiCostData = plansJson;
|
||||||
costCenterMap = {
|
costCenterMap = {
|
||||||
for (var item in apiCostData!)
|
for (var item in apiCostData!)
|
||||||
item['department_id'].toString(): item['name'].toString(),
|
item['cost_center_id'].toString(): item['name'].toString(),
|
||||||
};
|
};
|
||||||
costCenterIds = costCenterMap.keys.toList();
|
costCenterIds = costCenterMap.keys.toList();
|
||||||
|
|
||||||
// Optionally auto-select the first item if not already selected
|
// Optionally auto-select the first item if not already selected
|
||||||
// selectedCostCenterId ??=
|
selectedCostCenterId ??=
|
||||||
// costCenterIds.isNotEmpty ? costCenterIds.first : null;
|
costCenterIds.isNotEmpty ? costCenterIds.first : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
print('plansJSON');
|
print('plansJSON');
|
||||||
@ -1630,18 +1630,13 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String? getSelectedCostCenterName() {
|
// String? getSelectedCostCenterName() {
|
||||||
if (selectedCostCenterId == null || apiCostData == null) return null;
|
// if (selectedCostCenterId == null || apiCostData == null) return null;
|
||||||
return apiCostData!.firstWhere(
|
// return apiCostData!.firstWhere(
|
||||||
(item) => item['department_id'] == selectedCostCenterId,
|
// (item) => item['department_id'] == selectedCostCenterId,
|
||||||
orElse: () => null,
|
// orElse: () => null,
|
||||||
)?['name'];
|
// )?['name'];
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// Extracted helper function
|
|
||||||
///
|
|
||||||
///
|
|
||||||
///
|
|
||||||
|
|
||||||
final List<Map<String, dynamic>> allTripTypes = [
|
final List<Map<String, dynamic>> allTripTypes = [
|
||||||
{"dropdown_key": "1", "dropdown_value": "Domestic"},
|
{"dropdown_key": "1", "dropdown_value": "Domestic"},
|
||||||
|
|||||||
@ -2,7 +2,7 @@ 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:frontend/services/apiService.dart';
|
||||||
@ -31,7 +31,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
@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' &&
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user