Frontend first draft
This commit is contained in:
1
frontend/pshared/lib/models/recipient/filter.dart
Normal file
1
frontend/pshared/lib/models/recipient/filter.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum RecipientFilter { all, ready, registered, notRegistered }
|
||||
78
frontend/pshared/lib/models/recipient/recipient.dart
Normal file
78
frontend/pshared/lib/models/recipient/recipient.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'package:pshared/models/payment/methods/card.dart';
|
||||
import 'package:pshared/models/payment/methods/iban.dart';
|
||||
import 'package:pshared/models/payment/methods/russian_bank.dart';
|
||||
import 'package:pshared/models/payment/methods/wallet.dart';
|
||||
import 'package:pshared/models/recipient/status.dart';
|
||||
import 'package:pshared/models/recipient/type.dart';
|
||||
|
||||
|
||||
class Recipient {
|
||||
final String? avatarUrl; // network URL / local asset
|
||||
final String name;
|
||||
final String email;
|
||||
final RecipientStatus status;
|
||||
final RecipientType type;
|
||||
final CardPaymentMethod? card;
|
||||
final IbanPaymentMethod? iban;
|
||||
final RussianBankAccountPaymentMethod? bank;
|
||||
final WalletPaymentMethod? wallet;
|
||||
|
||||
const Recipient({
|
||||
this.avatarUrl,
|
||||
required this.name,
|
||||
required this.email,
|
||||
required this.status,
|
||||
required this.type,
|
||||
this.card,
|
||||
this.iban,
|
||||
this.bank,
|
||||
this.wallet,
|
||||
});
|
||||
|
||||
/// Convenience factory for quickly creating mock recipients.
|
||||
factory Recipient.mock({
|
||||
required String name,
|
||||
required String email,
|
||||
required RecipientStatus status,
|
||||
required RecipientType type,
|
||||
CardPaymentMethod? card,
|
||||
IbanPaymentMethod? iban,
|
||||
RussianBankAccountPaymentMethod? bank,
|
||||
WalletPaymentMethod? wallet,
|
||||
}) =>
|
||||
Recipient(
|
||||
avatarUrl: null,
|
||||
name: name,
|
||||
email: email,
|
||||
status: status,
|
||||
type: type,
|
||||
card: card,
|
||||
iban: iban,
|
||||
bank: bank,
|
||||
wallet: wallet,
|
||||
);
|
||||
|
||||
bool matchesQuery(String q) {
|
||||
final searchable = [
|
||||
name,
|
||||
email,
|
||||
card?.pan,
|
||||
card?.firstName,
|
||||
card?.lastName,
|
||||
iban?.iban,
|
||||
iban?.accountHolder,
|
||||
iban?.bic,
|
||||
iban?.bankName,
|
||||
bank?.accountNumber,
|
||||
bank?.recipientName,
|
||||
bank?.inn,
|
||||
bank?.kpp,
|
||||
bank?.bankName,
|
||||
bank?.bik,
|
||||
bank?.correspondentAccount,
|
||||
wallet?.walletId,
|
||||
];
|
||||
|
||||
return searchable.any((field) => field?.toLowerCase().contains(q) ?? false);
|
||||
}
|
||||
}
|
||||
22
frontend/pshared/lib/models/recipient/status.dart
Normal file
22
frontend/pshared/lib/models/recipient/status.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:pshared/generated/i18n/ps_localizations.dart';
|
||||
|
||||
|
||||
/// Possible payout readiness states.
|
||||
enum RecipientStatus { ready, registered, notRegistered }
|
||||
|
||||
extension RecipientStatusExtension on RecipientStatus {
|
||||
/// Human-readable, **localized** label for display in the UI.
|
||||
String label(BuildContext context) {
|
||||
final l10n = PSLocalizations.of(context)!;
|
||||
switch (this) {
|
||||
case RecipientStatus.ready:
|
||||
return l10n.statusReady;
|
||||
case RecipientStatus.registered:
|
||||
return l10n.statusRegistered;
|
||||
case RecipientStatus.notRegistered:
|
||||
return l10n.statusNotRegistered;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
frontend/pshared/lib/models/recipient/type.dart
Normal file
15
frontend/pshared/lib/models/recipient/type.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:pshared/generated/i18n/ps_localizations.dart';
|
||||
|
||||
|
||||
/// Indicates whether you (internal) or the other party (external) manage payout data.
|
||||
enum RecipientType { internal, external }
|
||||
|
||||
extension RecipientTypeExtension on RecipientType {
|
||||
/// Localized label – no opaque abbreviations.
|
||||
String label(BuildContext context) =>
|
||||
this == RecipientType.internal
|
||||
? PSLocalizations.of(context)!.typeInternal
|
||||
: PSLocalizations.of(context)!.typeExternal;
|
||||
}
|
||||
Reference in New Issue
Block a user