redesigned payment page + a lot of fixes
This commit is contained in:
4
frontend/pweb/lib/models/account/account_loader.dart
Normal file
4
frontend/pweb/lib/models/account/account_loader.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
enum AccountLoaderAction {
|
||||
goToLogin,
|
||||
showErrorAndGoToLogin,
|
||||
}
|
||||
77
frontend/pweb/lib/models/dashboard/quote_status_data.dart
Normal file
77
frontend/pweb/lib/models/dashboard/quote_status_data.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
import 'package:pshared/models/auto_refresh_mode.dart';
|
||||
import 'package:pshared/models/payment/quote/status_type.dart';
|
||||
|
||||
import 'package:pweb/controllers/payouts/quotation.dart';
|
||||
import 'package:pweb/utils/quote_duration_format.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class QuoteStatusData {
|
||||
final QuoteStatusType statusType;
|
||||
final String statusText;
|
||||
final String? helperText;
|
||||
final bool isLoading;
|
||||
final bool canRefresh;
|
||||
final bool showPrimaryRefresh;
|
||||
final AutoRefreshMode autoRefreshMode;
|
||||
|
||||
const QuoteStatusData({
|
||||
required this.statusType,
|
||||
required this.statusText,
|
||||
required this.helperText,
|
||||
required this.isLoading,
|
||||
required this.canRefresh,
|
||||
required this.showPrimaryRefresh,
|
||||
required this.autoRefreshMode,
|
||||
});
|
||||
|
||||
static QuoteStatusData resolve({
|
||||
required QuotationController controller,
|
||||
required AppLocalizations loc,
|
||||
}) {
|
||||
final timeLeft = controller.timeLeft;
|
||||
final isLoading = controller.isLoading;
|
||||
final statusType = controller.quoteStatus;
|
||||
final autoRefreshMode = controller.autoRefreshMode;
|
||||
|
||||
String statusText;
|
||||
String? helperText;
|
||||
switch (statusType) {
|
||||
case QuoteStatusType.loading:
|
||||
statusText = loc.quoteUpdating;
|
||||
break;
|
||||
case QuoteStatusType.error:
|
||||
statusText = loc.quoteErrorGeneric;
|
||||
break;
|
||||
case QuoteStatusType.missing:
|
||||
statusText = loc.quoteUnavailable;
|
||||
break;
|
||||
case QuoteStatusType.expired:
|
||||
statusText = loc.quoteExpired;
|
||||
helperText = loc.quoteRefreshRequired;
|
||||
break;
|
||||
case QuoteStatusType.active:
|
||||
statusText = timeLeft == null
|
||||
? loc.quoteActive
|
||||
: loc.quoteExpiresIn(formatQuoteDuration(timeLeft));
|
||||
break;
|
||||
}
|
||||
|
||||
final canRefresh = controller.canRefresh && !isLoading;
|
||||
final showPrimaryRefresh = canRefresh &&
|
||||
(statusType == QuoteStatusType.expired ||
|
||||
statusType == QuoteStatusType.error ||
|
||||
statusType == QuoteStatusType.missing);
|
||||
|
||||
return QuoteStatusData(
|
||||
statusType: statusType,
|
||||
statusText: statusText,
|
||||
helperText: helperText,
|
||||
isLoading: isLoading,
|
||||
canRefresh: canRefresh,
|
||||
showPrimaryRefresh: showPrimaryRefresh,
|
||||
autoRefreshMode: autoRefreshMode,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
class PaymentSummaryValues {
|
||||
final String sentAmount;
|
||||
final String fee;
|
||||
final String recipientReceives;
|
||||
final String total;
|
||||
|
||||
const PaymentSummaryValues({
|
||||
required this.sentAmount,
|
||||
required this.fee,
|
||||
required this.recipientReceives,
|
||||
required this.total,
|
||||
62
frontend/pweb/lib/models/recipient/method_snapshot.dart
Normal file
62
frontend/pweb/lib/models/recipient/method_snapshot.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:pshared/data/mapper/payment/method.dart';
|
||||
import 'package:pshared/models/payment/methods/data.dart';
|
||||
import 'package:pshared/models/payment/type.dart';
|
||||
import 'package:pshared/models/recipient/payment_method_draft.dart';
|
||||
|
||||
|
||||
class RecipientMethodSnapshot {
|
||||
final PaymentType type;
|
||||
final String? existingId;
|
||||
final Map<String, dynamic>? data;
|
||||
final Map<String, String>? metadata;
|
||||
|
||||
static final DeepCollectionEquality _mapEquality =
|
||||
const DeepCollectionEquality();
|
||||
|
||||
const RecipientMethodSnapshot({
|
||||
required this.type,
|
||||
required this.existingId,
|
||||
required this.data,
|
||||
required this.metadata,
|
||||
});
|
||||
|
||||
factory RecipientMethodSnapshot.fromDraft(RecipientMethodDraft draft) {
|
||||
return RecipientMethodSnapshot(
|
||||
type: draft.type,
|
||||
existingId: draft.existing?.id,
|
||||
data: _dataToSnapshot(draft.data),
|
||||
metadata: _metadataToSnapshot(draft.data),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is RecipientMethodSnapshot &&
|
||||
other.type == type &&
|
||||
other.existingId == existingId &&
|
||||
_mapEquality.equals(other.data, data) &&
|
||||
_mapEquality.equals(other.metadata, metadata);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
type,
|
||||
existingId,
|
||||
_mapEquality.hash(data),
|
||||
_mapEquality.hash(metadata),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic>? _dataToSnapshot(PaymentMethodData? data) {
|
||||
if (data == null) return null;
|
||||
return data.toJsonMap();
|
||||
}
|
||||
|
||||
Map<String, String>? _metadataToSnapshot(PaymentMethodData? data) {
|
||||
final metadata = data?.metadata;
|
||||
if (metadata == null) return null;
|
||||
return Map<String, String>.from(metadata);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
class RoleDraft {
|
||||
final String name;
|
||||
final String description;
|
||||
|
||||
const RoleDraft({
|
||||
required this.name,
|
||||
required this.description,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user