diff --git a/lib/controllers/providers/api/all_requests_provider.dart b/lib/controllers/providers/api/all_requests_provider.dart index e394c80a..3bbece0b 100644 --- a/lib/controllers/providers/api/all_requests_provider.dart +++ b/lib/controllers/providers/api/all_requests_provider.dart @@ -12,7 +12,7 @@ class AllRequestsProvider extends ChangeNotifier { bool isAllLoading = false; bool isOpenLoading = false; bool isInProgressLoading = false; - bool isCloseLoading = false; + bool isCompleteLoading = false; bool isOverdueLoading = false; bool isHighPriorityLoading = false; bool isCalendarLoading = false; @@ -22,7 +22,7 @@ class AllRequestsProvider extends ChangeNotifier { AllRequestsAndCount allRequestsAndCount; AllRequestsAndCount openRequests; AllRequestsAndCount inProgressRequests; - AllRequestsAndCount closeRequests; + AllRequestsAndCount completedRequests; AllRequestsAndCount overdueRequests; AllRequestsAndCount highPriorityRequests; AllRequestsAndCount calendarRequests; @@ -32,9 +32,8 @@ class AllRequestsProvider extends ChangeNotifier { getOverdueRequests(); getOpenRequests(); getInProgressRequests(); - getCloseRequests(); + getCompletedRequests(); } - Future getAllRequests(BuildContext context, {int typeTransaction, SearchAllRequestsModel search}) async { if (isAllLoading == true) return -2; isAllLoading = true; @@ -51,7 +50,7 @@ class AllRequestsProvider extends ChangeNotifier { "typeTransaction": type, "statusTransaction": status, "priority": [0, 1], - "displayData": status, + "displayData": [], if (search?.requestNumber?.value?.isNotEmpty ?? false) "requestNumber": search.requestNumber.value, if (search?.assetName?.value?.isNotEmpty ?? false) "assetName": search.assetName.value, if (search?.assetNo?.value?.isNotEmpty ?? false) "assetNumber": search.assetNo.value, @@ -230,15 +229,15 @@ class AllRequestsProvider extends ChangeNotifier { } } - Future getCloseRequests() async { - if (isCloseLoading == true) return -2; - isCloseLoading = true; - if (closeRequests == null) notifyListeners(); + Future getCompletedRequests() async { + if (isCompleteLoading == true) return -2; + isCompleteLoading = true; + if (completedRequests == null) notifyListeners(); Response response; try { Map body = { "typeTransaction": [1, 2, 3, 4], - "statusTransaction": [3], + "statusTransaction": [4], "priority": [], "displayData": [] }; @@ -246,17 +245,47 @@ class AllRequestsProvider extends ChangeNotifier { stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { - closeRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + completedRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); notifyListeners(); } - isCloseLoading = false; + isCompleteLoading = false; notifyListeners(); return response.statusCode; } catch (error) { - isCloseLoading = false; + isCompleteLoading = false; stateCode = -1; notifyListeners(); return -1; } } + + // Future getCloseRequests() async { + // if (isCloseLoading == true) return -2; + // isCloseLoading = true; + // if (closeRequests == null) notifyListeners(); + // Response response; + // try { + // Map body = { + // "typeTransaction": [1, 2, 3, 4], + // "statusTransaction": [4], + // "priority": [], + // "displayData": [] + // }; + // response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + // + // stateCode = response.statusCode; + // if (response.statusCode >= 200 && response.statusCode < 300) { + // closeRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + // notifyListeners(); + // } + // isCloseLoading = false; + // notifyListeners(); + // return response.statusCode; + // } catch (error) { + // isCloseLoading = false; + // stateCode = -1; + // notifyListeners(); + // return -1; + // } + // } } diff --git a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart index b248f2b9..8a956ce9 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart @@ -47,7 +47,7 @@ class ProgressFragment extends StatelessWidget { chartValueStyle: AppTextStyles.heading6.copyWith(color: AppColor.neutral20), showChartValuesOutside: true, ), - ).toShimmer(isShow: snapshot.isOpenLoading || snapshot.isInProgressLoading || snapshot.isCloseLoading, radius: 300).paddingAll(12).toShadowContainer(context), + ).toShimmer(isShow: snapshot.isOpenLoading || snapshot.isInProgressLoading || snapshot.isCompleteLoading, radius: 300).paddingAll(12).toShadowContainer(context), ).paddingOnly(start: 16, end: 16, bottom: 16), DefaultTabController( length: 3, @@ -80,7 +80,7 @@ class ProgressFragment extends StatelessWidget { children: [ RequestItemViewList(snapshot.openRequests?.requestsDetails ?? [], snapshot.isOpenLoading), RequestItemViewList(snapshot.inProgressRequests?.requestsDetails ?? [], snapshot.isInProgressLoading), - RequestItemViewList(snapshot.closeRequests?.requestsDetails ?? [], snapshot.isCloseLoading), + RequestItemViewList(snapshot.completedRequests?.requestsDetails ?? [], snapshot.isCompleteLoading), ], ).expanded, ], diff --git a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart index f4645ece..e5860326 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart @@ -26,7 +26,7 @@ class RequestsFragment extends StatelessWidget { gridItem(snapshot.highPriorityRequests?.total?.count?.toString() ?? "-", "high_priority", context.translation.highPriority, context, snapshot.isHighPriorityLoading, 0), gridItem(snapshot.overdueRequests?.total?.count?.toString() ?? "-", "overdue", context.translation.overdue, context, snapshot.isOverdueLoading, 1), gridItem(snapshot.openRequests?.total?.count?.toString() ?? "-", "new_request", context.translation.newR, context, snapshot.isOpenLoading, 2), - gridItem(snapshot.closeRequests?.total?.count?.toString() ?? "-", "complete_request", context.translation.completed, context, snapshot.isCloseLoading, 3), + gridItem(snapshot.completedRequests?.total?.count?.toString() ?? "-", "complete_request", context.translation.completed, context, snapshot.isCompleteLoading, 3), ], ), ), diff --git a/lib/new_views/pages/land_page/requests_list_page.dart b/lib/new_views/pages/land_page/requests_list_page.dart index 4ec67fbc..50308edc 100644 --- a/lib/new_views/pages/land_page/requests_list_page.dart +++ b/lib/new_views/pages/land_page/requests_list_page.dart @@ -34,7 +34,7 @@ class RequestsListPage extends StatelessWidget { : index == 2 ? snapshot.isOpenLoading : index == 3 - ? snapshot.isCloseLoading + ? snapshot.isCompleteLoading : false; List list = index == 0 @@ -44,7 +44,7 @@ class RequestsListPage extends StatelessWidget { : index == 2 ? snapshot.openRequests.requestsDetails : index == 3 - ? snapshot.closeRequests.requestsDetails + ? snapshot.completedRequests.requestsDetails : []; return RequestItemViewList(list, isLoading); })); diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index 1ee8f6f6..7f549493 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -58,7 +58,7 @@ class _GasRefillDetailsPageState extends State { builder: (context, snap) { if (snap.connectionState == ConnectionState.waiting) { return const ALoading(); - } else if (!snap.hasData) { + } else if (snap.hasData) { _model = snap.data; return Column( crossAxisAlignment: CrossAxisAlignment.start,