Merge
This commit is contained in:
parent
41ed141e13
commit
dbe248195d
@ -1047,7 +1047,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
data: {
|
||||
"plan_id": planId,
|
||||
"user_id": widget.approverId,
|
||||
"delegater_id": widget.delegaterId,
|
||||
"delegation_user_id": widget.delegaterId,
|
||||
},
|
||||
methodName: 'Plan Approval',
|
||||
);
|
||||
@ -1060,7 +1060,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
data: {
|
||||
"plan_id": planId,
|
||||
"user_id": widget.approverId,
|
||||
"delegater_id": widget.delegaterId,
|
||||
"delegation_user_id": widget.delegaterId,
|
||||
"reason": remarks,
|
||||
},
|
||||
methodName: 'Plan Rejection',
|
||||
|
||||
@ -217,7 +217,7 @@ class _OfficeDetailsState extends State<OfficeDetails> {
|
||||
|
||||
Future<void> fetchDepartment() async {
|
||||
try {
|
||||
List<dynamic> department = await apiService.fetchCostCenter();
|
||||
List<dynamic> department = await apiService.fetchDepartmentCostCenter();
|
||||
setState(() {
|
||||
apiCostData = department;
|
||||
});
|
||||
|
||||
@ -162,6 +162,60 @@ class ApiService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List> fetchDepartmentCostCenter() async {
|
||||
final String apiUrldata = '$apiUrl/api/getDepartmentList';
|
||||
|
||||
final token = await getToken();
|
||||
|
||||
final userId = await getUserId();
|
||||
|
||||
// print("SUSRTRT- $userId");
|
||||
//
|
||||
if (token == null) {
|
||||
throw Exception('Token not found. Please log in.');
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(apiUrldata),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
final data = json.decode(response.body);
|
||||
print(data);
|
||||
|
||||
if (!data.containsKey('data') || data['data'] is! List) {
|
||||
throw Exception(
|
||||
"Invalid response format: 'data' field is missing or not a List");
|
||||
}
|
||||
|
||||
List<dynamic> plansJson = data['data']; // 'data' is a Map, not a List
|
||||
// setState(() {
|
||||
// apiCostData = plansJson; // Store API response in state
|
||||
// if(apiCostData!.isNotEmpty){
|
||||
// selectedCostCenterId =apiCostData?.first['department_id'];
|
||||
// }
|
||||
|
||||
// if (apiCostData != null && apiCostData!.isNotEmpty) {
|
||||
// selectedCostCenterId ??= apiCostData!.first['department_id']?.toString();
|
||||
// }
|
||||
// });
|
||||
|
||||
print('plansJSON');
|
||||
|
||||
return plansJson;
|
||||
} catch (e) {
|
||||
throw Exception('Error parsing response: $e');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Failed to load plans');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchMasterDropdown() async {
|
||||
final String apiUrldata = '$apiUrl/api/getDropdownMaster';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user