done with update Today's Planned count right after submit of assign task
This commit is contained in:
parent
c9f4795de6
commit
a95e0be48b
@ -12,7 +12,8 @@ class DailyTaskPlanningController extends GetxController {
|
||||
RxList<EmployeeModel> employees = <EmployeeModel>[].obs;
|
||||
RxList<EmployeeModel> selectedEmployees = <EmployeeModel>[].obs;
|
||||
List<EmployeeModel> allEmployeesCache = [];
|
||||
List<TaskPlanningDetailsModel> dailyTasks = [];
|
||||
RxList<TaskPlanningDetailsModel> dailyTasks =
|
||||
<TaskPlanningDetailsModel>[].obs;
|
||||
RxMap<String, RxBool> uploadingStates = <String, RxBool>{}.obs;
|
||||
|
||||
MyFormValidator basicValidator = MyFormValidator();
|
||||
@ -97,7 +98,6 @@ class DailyTaskPlanningController extends GetxController {
|
||||
if (response == true) {
|
||||
logSafe("Task assigned successfully", level: LogLevel.info);
|
||||
await fetchBuildingInfra(buildingId, projectId, serviceId);
|
||||
Get.back();
|
||||
|
||||
showAppSnackbar(
|
||||
title: "Success",
|
||||
@ -129,18 +129,17 @@ class DailyTaskPlanningController extends GetxController {
|
||||
final infraData = infraResponse?['data'] as List<dynamic>?;
|
||||
|
||||
if (infraData == null || infraData.isEmpty) {
|
||||
dailyTasks = [];
|
||||
dailyTasks.clear(); //reactive clear
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter buildings with 0 planned & completed work
|
||||
final filteredBuildings = infraData.where((b) {
|
||||
final planned = (b['plannedWork'] as num?)?.toDouble() ?? 0;
|
||||
final completed = (b['completedWork'] as num?)?.toDouble() ?? 0;
|
||||
return planned > 0 || completed > 0;
|
||||
}).toList();
|
||||
|
||||
dailyTasks = filteredBuildings.map((buildingJson) {
|
||||
final mapped = filteredBuildings.map((buildingJson) {
|
||||
final building = Building(
|
||||
id: buildingJson['id'],
|
||||
name: buildingJson['buildingName'],
|
||||
@ -163,14 +162,19 @@ class DailyTaskPlanningController extends GetxController {
|
||||
);
|
||||
}).toList();
|
||||
|
||||
dailyTasks.assignAll(mapped);
|
||||
|
||||
buildingLoadingStates.clear();
|
||||
buildingsWithDetails.clear();
|
||||
} catch (e, stack) {
|
||||
logSafe("Error fetching daily task data",
|
||||
level: LogLevel.error, error: e, stackTrace: stack);
|
||||
logSafe(
|
||||
"Error fetching daily task data",
|
||||
level: LogLevel.error,
|
||||
error: e,
|
||||
stackTrace: stack,
|
||||
);
|
||||
} finally {
|
||||
isFetchingTasks.value = false;
|
||||
update(); // dailyTasks is non-reactive
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
class ApiEndpoints {
|
||||
// static const String baseUrl = "https://stageapi.marcoaiot.com/api";
|
||||
static const String baseUrl = "https://stageapi.marcoaiot.com/api";
|
||||
// static const String baseUrl = "https://api.marcoaiot.com/api";
|
||||
// static const String baseUrl = "https://devapi.marcoaiot.com/api";
|
||||
// static const String baseUrl = "https://mapi.marcoaiot.com/api";
|
||||
static const String baseUrl = "https://api.onfieldwork.com/api";
|
||||
// static const String baseUrl = "https://api.onfieldwork.com/api";
|
||||
|
||||
|
||||
static const String getMasterCurrencies = "/Master/currencies/list";
|
||||
|
||||
@ -24,9 +24,11 @@ class AssignTaskBottomSheet extends StatefulWidget {
|
||||
final String buildingName;
|
||||
final String floorName;
|
||||
final String workAreaName;
|
||||
final String buildingId;
|
||||
|
||||
const AssignTaskBottomSheet({
|
||||
super.key,
|
||||
required this.buildingId,
|
||||
required this.buildingName,
|
||||
required this.workLocation,
|
||||
required this.floorName,
|
||||
@ -372,7 +374,7 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onAssignTaskPressed() {
|
||||
Future<void> _onAssignTaskPressed() async {
|
||||
final selectedTeam = controller.selectedEmployees;
|
||||
|
||||
if (selectedTeam.isEmpty) {
|
||||
@ -413,16 +415,20 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
||||
return;
|
||||
}
|
||||
|
||||
controller.assignDailyTask(
|
||||
final success = await controller.assignDailyTask(
|
||||
workItemId: widget.workItemId,
|
||||
plannedTask: target.toInt(),
|
||||
description: description,
|
||||
taskTeam: selectedTeam.map((e) => e.id).toList(),
|
||||
assignmentDate: widget.assignmentDate,
|
||||
buildingId: widget.buildingName,
|
||||
buildingId: widget.buildingId,
|
||||
projectId: selectedProjectId!,
|
||||
organizationId: selectedOrganization?.id,
|
||||
serviceId: selectedService?.id,
|
||||
);
|
||||
|
||||
if (success) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,6 +472,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
),
|
||||
builder: (context) =>
|
||||
AssignTaskBottomSheet(
|
||||
buildingId: building.id,
|
||||
buildingName:
|
||||
building.name,
|
||||
floorName:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user