completed migrating data scope from user to workspace

This commit is contained in:
2026-06-22 22:10:38 +02:00
parent 62c7f53de0
commit ae2705363a
37 changed files with 918 additions and 221 deletions

View File

@@ -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(

View File

@@ -13,7 +13,7 @@ part of 'recipients_controller.dart';
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$Recipient {
mixin _$Recipient implements DiagnosticableTreeMixin {
@JsonKey(includeIfNull: false) String? get uid;@JsonKey(includeIfNull: false) String? get name;@JsonKey(includeIfNull: false) String? get email;@JsonKey(includeIfNull: false) String? get phoneNumber;@JsonKey(includeIfNull: false) String? get address;@JsonKey(includeIfNull: false) String? get account;@JsonKey(includeIfNull: false) String? get initials;@JsonKey(includeIfNull: false) String? get latestProviderLabel;
/// Create a copy of Recipient
@@ -25,6 +25,12 @@ $RecipientCopyWith<Recipient> get copyWith => _$RecipientCopyWithImpl<Recipient>
/// Serializes this Recipient to a JSON map.
Map<String, dynamic> toJson();
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'Recipient'))
..add(DiagnosticsProperty('uid', uid))..add(DiagnosticsProperty('name', name))..add(DiagnosticsProperty('email', email))..add(DiagnosticsProperty('phoneNumber', phoneNumber))..add(DiagnosticsProperty('address', address))..add(DiagnosticsProperty('account', account))..add(DiagnosticsProperty('initials', initials))..add(DiagnosticsProperty('latestProviderLabel', latestProviderLabel));
}
@override
bool operator ==(Object other) {
@@ -36,7 +42,7 @@ bool operator ==(Object other) {
int get hashCode => Object.hash(runtimeType,uid,name,email,phoneNumber,address,account,initials,latestProviderLabel);
@override
String toString() {
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
return 'Recipient(uid: $uid, name: $name, email: $email, phoneNumber: $phoneNumber, address: $address, account: $account, initials: $initials, latestProviderLabel: $latestProviderLabel)';
}
@@ -215,7 +221,7 @@ return $default(_that.uid,_that.name,_that.email,_that.phoneNumber,_that.address
/// @nodoc
@JsonSerializable()
class _Recipient implements Recipient {
class _Recipient with DiagnosticableTreeMixin implements Recipient {
const _Recipient({@JsonKey(includeIfNull: false) this.uid, @JsonKey(includeIfNull: false) this.name, @JsonKey(includeIfNull: false) this.email, @JsonKey(includeIfNull: false) this.phoneNumber, @JsonKey(includeIfNull: false) this.address, @JsonKey(includeIfNull: false) this.account, @JsonKey(includeIfNull: false) this.initials, @JsonKey(includeIfNull: false) this.latestProviderLabel});
factory _Recipient.fromJson(Map<String, dynamic> json) => _$RecipientFromJson(json);
@@ -238,6 +244,12 @@ _$RecipientCopyWith<_Recipient> get copyWith => __$RecipientCopyWithImpl<_Recipi
Map<String, dynamic> toJson() {
return _$RecipientToJson(this, );
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'Recipient'))
..add(DiagnosticsProperty('uid', uid))..add(DiagnosticsProperty('name', name))..add(DiagnosticsProperty('email', email))..add(DiagnosticsProperty('phoneNumber', phoneNumber))..add(DiagnosticsProperty('address', address))..add(DiagnosticsProperty('account', account))..add(DiagnosticsProperty('initials', initials))..add(DiagnosticsProperty('latestProviderLabel', latestProviderLabel));
}
@override
bool operator ==(Object other) {
@@ -249,7 +261,7 @@ bool operator ==(Object other) {
int get hashCode => Object.hash(runtimeType,uid,name,email,phoneNumber,address,account,initials,latestProviderLabel);
@override
String toString() {
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
return 'Recipient(uid: $uid, name: $name, email: $email, phoneNumber: $phoneNumber, address: $address, account: $account, initials: $initials, latestProviderLabel: $latestProviderLabel)';
}

View File

@@ -66,7 +66,7 @@ class _RecipientsScreenState extends State<RecipientsScreen>
Future<void> setupData() async {
prefs = await SharedPreferences.getInstance();
_queryParams['userId'] = prefs.getString("userId")!;
_queryParams['workspaceId'] = prefs.getString("workspaceId")!;
controller.getRecipients(_queryParams);
}
@@ -268,7 +268,7 @@ class _RecipientsScreenState extends State<RecipientsScreen>
_queryParams['email'] = _accountController.text;
_queryParams['phoneNumber'] = _accountController.text;
_queryParams['name'] = _accountController.text;
_queryParams['userId'] = prefs.getString("userId")!;
_queryParams['workspaceId'] = prefs.getString("workspaceId")!;
controller.getRecipients(_queryParams);
});