completed migrating data scope from user to workspace
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:qpay/http/http.dart';
|
||||
@@ -6,6 +7,8 @@ import 'package:qpay/screens/home/home_controller.dart' as hc;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:qpay/screens/transaction_controller.dart';
|
||||
|
||||
import '../../models/pageable_model.dart';
|
||||
|
||||
part 'recipients_controller.freezed.dart';
|
||||
part 'recipients_controller.g.dart';
|
||||
|
||||
@@ -56,18 +59,25 @@ class RecipientsController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
List<dynamic> response = await http.get(
|
||||
'/public/recipients/search?${buildQueryParameters(params ?? {})}',
|
||||
final response = await http.get(
|
||||
'/public/recipients?${buildQueryParameters(params ?? {})}',
|
||||
);
|
||||
final page = PageableModel.fromJson(response as Map<String, dynamic>);
|
||||
model.recipients.clear();
|
||||
model.recipients.addAll(response.map((e) => Recipient.fromJson(e)));
|
||||
model.recipients.addAll(
|
||||
page.content.map((e) => Recipient.fromJson(e)).toList(),
|
||||
);
|
||||
model.isLoading = false;
|
||||
notifyListeners();
|
||||
return ApiResponse.success(List<Recipient>.from(model.recipients));
|
||||
} catch (e) {
|
||||
return ApiResponse.success(model.recipients);
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
logger.e(e);
|
||||
logger.e(s);
|
||||
}
|
||||
|
||||
model.errorMessage = e.toString();
|
||||
model.recipients = [];
|
||||
logger.e(e);
|
||||
model.isLoading = false;
|
||||
notifyListeners();
|
||||
return ApiResponse.failure(
|
||||
|
||||
Reference in New Issue
Block a user