SEND063
This commit is contained in:
59
frontend/pweb/lib/utils/report/operations/title_mapper.dart
Normal file
59
frontend/pweb/lib/utils/report/operations/title_mapper.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:pweb/utils/payment/operation_code.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
String resolveOperationTitle(AppLocalizations loc, String? code) {
|
||||
final pair = parseOperationCodePair(code);
|
||||
if (pair == null) return '-';
|
||||
|
||||
final operation = _localizedOperation(loc, pair.operation);
|
||||
final action = _localizedAction(loc, pair.action);
|
||||
return loc.paymentOperationPair(operation, action);
|
||||
}
|
||||
|
||||
String _localizedOperation(AppLocalizations loc, String operation) {
|
||||
switch (operation) {
|
||||
case 'card_payout':
|
||||
return loc.paymentOperationCardPayout;
|
||||
case 'crypto':
|
||||
return loc.paymentOperationCrypto;
|
||||
case 'settlement':
|
||||
return loc.paymentOperationSettlement;
|
||||
case 'ledger':
|
||||
return loc.paymentOperationLedger;
|
||||
default:
|
||||
return _humanizeToken(operation);
|
||||
}
|
||||
}
|
||||
|
||||
String _localizedAction(AppLocalizations loc, String action) {
|
||||
switch (action) {
|
||||
case 'send':
|
||||
return loc.paymentOperationActionSend;
|
||||
case 'observe':
|
||||
return loc.paymentOperationActionObserve;
|
||||
case 'fx_convert':
|
||||
return loc.paymentOperationActionFxConvert;
|
||||
case 'credit':
|
||||
return loc.paymentOperationActionCredit;
|
||||
case 'block':
|
||||
return loc.paymentOperationActionBlock;
|
||||
case 'debit':
|
||||
return loc.paymentOperationActionDebit;
|
||||
case 'release':
|
||||
return loc.paymentOperationActionRelease;
|
||||
case 'move':
|
||||
return loc.paymentOperationActionMove;
|
||||
default:
|
||||
return _humanizeToken(action);
|
||||
}
|
||||
}
|
||||
|
||||
String _humanizeToken(String token) {
|
||||
final parts = token.split('_').where((part) => part.isNotEmpty).toList();
|
||||
if (parts.isEmpty) return token;
|
||||
return parts
|
||||
.map((part) => '${part[0].toUpperCase()}${part.substring(1)}')
|
||||
.join(' ');
|
||||
}
|
||||
Reference in New Issue
Block a user