feat: Refactor code structure and optimize performance across multiple modules

This commit is contained in:
Achintha Isuru
2025-11-17 23:29:28 -05:00
parent 831570f2e0
commit a64cbd9edf
1508 changed files with 105319 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import 'package:injectable/injectable.dart';
import 'package:krow/core/application/clients/api/api_client.dart';
import 'package:krow/core/data/models/staff/bank_acc.dart';
import 'package:krow/features/profile/bank_account/data/gql.dart';
@injectable
class BankAccountApiProvider {
final ApiClient _apiClient;
BankAccountApiProvider(this._apiClient);
Stream<BankAcc?> getStaffBankAcc() async* {
await for (var response
in _apiClient.queryWithCache(schema: staffBankAccount)) {
if (response == null || response.data == null) {
continue;
}
if (response.hasException) {
throw Exception(response.exception.toString());
}
final bankAcc =
BankAcc.fromJson(response.data?['me']?['bank_account'] ?? {});
yield bankAcc;
}
}
Future<void> putBunkAccount(BankAcc bankAcc) async {
final Map<String, dynamic> variables = {
'input': bankAcc.toJson(),
};
var result =
await _apiClient.mutate(schema: updateBankAccount, body: variables);
if (result.hasException) {
throw Exception(result.exception.toString());
}
}
}

View File

@@ -0,0 +1,7 @@
import 'package:krow/core/data/models/staff/bank_acc.dart';
abstract class BankAccountRepository {
Stream<BankAcc?> getStaffBankAcc();
Future<void> putBankAcc(BankAcc address);
}

View File

@@ -0,0 +1,28 @@
const String staffBankAccount = r'''
query staffAddress {
me {
id
bank_account {
id
holder_name
bank_name
number
routing_number
country
state
city
street
building
zip
}
}
}
''';
const String updateBankAccount = r'''
mutation updateBankAccount($input: UpdateStaffBankAccountInput!) {
update_staff_bank_account(input: $input) {
}
}
''';