Compare commits
2 Commits
250c453413
...
12bd70479c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12bd70479c | ||
|
|
e62c466155 |
68
docs/payment.sh
Normal file
68
docs/payment.sh
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#get list payments
|
||||||
|
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.payment.get_list' \
|
||||||
|
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
|
||||||
|
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"limit_page_length" : 0,
|
||||||
|
"limit_start" : 0
|
||||||
|
|
||||||
|
}'
|
||||||
|
#response
|
||||||
|
{
|
||||||
|
"message": [
|
||||||
|
{
|
||||||
|
"name": "ACC-PAY-2025-00020",
|
||||||
|
"posting_date": "2025-11-25",
|
||||||
|
"paid_amount": 1130365.328,
|
||||||
|
"mode_of_payment": null,
|
||||||
|
"invoice_id": null,
|
||||||
|
"order_id": "SAL-ORD-2025-00120"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ACC-PAY-2025-00019",
|
||||||
|
"posting_date": "2025-11-25",
|
||||||
|
"paid_amount": 1153434.0,
|
||||||
|
"mode_of_payment": "Chuyển khoản",
|
||||||
|
"invoice_id": "ACC-SINV-2025-00026",
|
||||||
|
"order_id": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ACC-PAY-2025-00018",
|
||||||
|
"posting_date": "2025-11-24",
|
||||||
|
"paid_amount": 2580258.0,
|
||||||
|
"mode_of_payment": null,
|
||||||
|
"invoice_id": "ACC-SINV-2025-00025",
|
||||||
|
"order_id": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ACC-PAY-2025-00017",
|
||||||
|
"posting_date": "2025-11-24",
|
||||||
|
"paid_amount": 1000000.0,
|
||||||
|
"mode_of_payment": null,
|
||||||
|
"invoice_id": "ACC-SINV-2025-00025",
|
||||||
|
"order_id": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
#get payment detail
|
||||||
|
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.payment.get_detail' \
|
||||||
|
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
|
||||||
|
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"name" : "ACC-PAY-2025-00020"
|
||||||
|
}'
|
||||||
|
|
||||||
|
#response
|
||||||
|
{
|
||||||
|
"message": {
|
||||||
|
"name": "ACC-PAY-2025-00020",
|
||||||
|
"posting_date": "2025-11-25",
|
||||||
|
"paid_amount": 1130365.328,
|
||||||
|
"mode_of_payment": null,
|
||||||
|
"invoice_id": null,
|
||||||
|
"order_id": "SAL-ORD-2025-00120"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -271,6 +271,18 @@ class ApiConstants {
|
|||||||
/// GET /payments/{paymentId}
|
/// GET /payments/{paymentId}
|
||||||
static const String getPaymentDetails = '/payments';
|
static const String getPaymentDetails = '/payments';
|
||||||
|
|
||||||
|
/// Get payment list (Frappe API)
|
||||||
|
/// POST /api/method/building_material.building_material.api.payment.get_list
|
||||||
|
/// Body: { "limit_start": 0, "limit_page_length": 0 }
|
||||||
|
static const String getPaymentList =
|
||||||
|
'/building_material.building_material.api.payment.get_list';
|
||||||
|
|
||||||
|
/// Get payment detail (Frappe API)
|
||||||
|
/// POST /api/method/building_material.building_material.api.payment.get_detail
|
||||||
|
/// Body: { "name": "ACC-PAY-2025-00020" }
|
||||||
|
static const String getPaymentDetail =
|
||||||
|
'/building_material.building_material.api.payment.get_detail';
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Project Endpoints (Frappe ERPNext)
|
// Project Endpoints (Frappe ERPNext)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -350,14 +350,9 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
name: RouteNames.paymentQr,
|
name: RouteNames.paymentQr,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
final orderId = state.uri.queryParameters['orderId'] ?? '';
|
final orderId = state.uri.queryParameters['orderId'] ?? '';
|
||||||
final amountStr = state.uri.queryParameters['amount'] ?? '0';
|
|
||||||
final amount = double.tryParse(amountStr) ?? 0.0;
|
|
||||||
return MaterialPage(
|
return MaterialPage(
|
||||||
key: state.pageKey,
|
key: state.pageKey,
|
||||||
child: PaymentQrPage(
|
child: PaymentQrPage(orderId: orderId),
|
||||||
orderId: orderId,
|
|
||||||
amount: amount,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ class AppTheme {
|
|||||||
/// Light theme configuration
|
/// Light theme configuration
|
||||||
/// [seedColor] - Optional custom seed color, defaults to AppColors.defaultSeedColor
|
/// [seedColor] - Optional custom seed color, defaults to AppColors.defaultSeedColor
|
||||||
static ThemeData lightTheme([Color? seedColor]) {
|
static ThemeData lightTheme([Color? seedColor]) {
|
||||||
|
final seed = seedColor ?? AppColors.defaultSeedColor;
|
||||||
final ColorScheme colorScheme = ColorScheme.fromSeed(
|
final ColorScheme colorScheme = ColorScheme.fromSeed(
|
||||||
seedColor: seedColor ?? AppColors.defaultSeedColor,
|
seedColor: seed,
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
);
|
).copyWith(primary: seed);
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
@@ -239,10 +240,11 @@ class AppTheme {
|
|||||||
/// Dark theme configuration
|
/// Dark theme configuration
|
||||||
/// [seedColor] - Optional custom seed color, defaults to AppColors.defaultSeedColor
|
/// [seedColor] - Optional custom seed color, defaults to AppColors.defaultSeedColor
|
||||||
static ThemeData darkTheme([Color? seedColor]) {
|
static ThemeData darkTheme([Color? seedColor]) {
|
||||||
|
final seed = seedColor ?? AppColors.defaultSeedColor;
|
||||||
final ColorScheme colorScheme = ColorScheme.fromSeed(
|
final ColorScheme colorScheme = ColorScheme.fromSeed(
|
||||||
seedColor: seedColor ?? AppColors.defaultSeedColor,
|
seedColor: seed,
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
);
|
).copyWith(primary: seed);
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/// Payment Remote Data Source
|
||||||
|
///
|
||||||
|
/// Handles API calls for payment-related data.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/core/constants/api_constants.dart';
|
||||||
|
import 'package:worker/core/network/dio_client.dart';
|
||||||
|
import 'package:worker/features/orders/data/models/payment_model.dart';
|
||||||
|
|
||||||
|
/// Payment Remote Data Source
|
||||||
|
class PaymentRemoteDataSource {
|
||||||
|
const PaymentRemoteDataSource(this._dioClient);
|
||||||
|
|
||||||
|
final DioClient _dioClient;
|
||||||
|
|
||||||
|
/// Get payments list
|
||||||
|
///
|
||||||
|
/// Calls: POST /api/method/building_material.building_material.api.payment.get_list
|
||||||
|
/// Returns: List of payments
|
||||||
|
Future<List<PaymentModel>> getPaymentsList({
|
||||||
|
int limitStart = 0,
|
||||||
|
int limitPageLength = 0,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final response = await _dioClient.post<Map<String, dynamic>>(
|
||||||
|
'${ApiConstants.frappeApiMethod}${ApiConstants.getPaymentList}',
|
||||||
|
data: {
|
||||||
|
'limit_start': limitStart,
|
||||||
|
'limit_page_length': limitPageLength,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
|
if (data == null) {
|
||||||
|
throw Exception('No data received from getPaymentsList API');
|
||||||
|
}
|
||||||
|
|
||||||
|
// API returns: { "message": [...] }
|
||||||
|
final message = data['message'];
|
||||||
|
if (message == null) {
|
||||||
|
throw Exception('No message field in getPaymentsList response');
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<dynamic> paymentsList = message as List<dynamic>;
|
||||||
|
return paymentsList
|
||||||
|
.map((json) => PaymentModel.fromJson(json as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get payments list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get payment detail
|
||||||
|
///
|
||||||
|
/// Calls: POST /api/method/building_material.building_material.api.payment.get_detail
|
||||||
|
/// Returns: Payment detail
|
||||||
|
Future<PaymentModel> getPaymentDetail(String name) async {
|
||||||
|
try {
|
||||||
|
final response = await _dioClient.post<Map<String, dynamic>>(
|
||||||
|
'${ApiConstants.frappeApiMethod}${ApiConstants.getPaymentDetail}',
|
||||||
|
data: {'name': name},
|
||||||
|
);
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
|
if (data == null) {
|
||||||
|
throw Exception('No data received from getPaymentDetail API');
|
||||||
|
}
|
||||||
|
|
||||||
|
// API returns: { "message": {...} }
|
||||||
|
final message = data['message'];
|
||||||
|
if (message == null) {
|
||||||
|
throw Exception('No message field in getPaymentDetail response');
|
||||||
|
}
|
||||||
|
|
||||||
|
return PaymentModel.fromJson(message as Map<String, dynamic>);
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get payment detail: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
92
lib/features/orders/data/models/payment_model.dart
Normal file
92
lib/features/orders/data/models/payment_model.dart
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/// Data Model: Payment Model
|
||||||
|
///
|
||||||
|
/// Model for payment data with API serialization.
|
||||||
|
/// Not stored in local database.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/features/orders/domain/entities/payment.dart';
|
||||||
|
|
||||||
|
/// Payment Model
|
||||||
|
///
|
||||||
|
/// Model for API parsing only (no Hive storage).
|
||||||
|
class PaymentModel {
|
||||||
|
/// Payment ID (e.g., "ACC-PAY-2025-00020")
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
/// Payment posting date (stored as ISO string)
|
||||||
|
final String postingDate;
|
||||||
|
|
||||||
|
/// Amount paid
|
||||||
|
final double paidAmount;
|
||||||
|
|
||||||
|
/// Payment method (e.g., "Chuyển khoản")
|
||||||
|
final String? modeOfPayment;
|
||||||
|
|
||||||
|
/// Related invoice ID
|
||||||
|
final String? invoiceId;
|
||||||
|
|
||||||
|
/// Related order ID
|
||||||
|
final String? orderId;
|
||||||
|
|
||||||
|
const PaymentModel({
|
||||||
|
required this.name,
|
||||||
|
required this.postingDate,
|
||||||
|
required this.paidAmount,
|
||||||
|
this.modeOfPayment,
|
||||||
|
this.invoiceId,
|
||||||
|
this.orderId,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Create from JSON (API response)
|
||||||
|
factory PaymentModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return PaymentModel(
|
||||||
|
name: json['name'] as String? ?? '',
|
||||||
|
postingDate: json['posting_date'] as String? ?? '',
|
||||||
|
paidAmount: (json['paid_amount'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
modeOfPayment: json['mode_of_payment'] as String?,
|
||||||
|
invoiceId: json['invoice_id'] as String?,
|
||||||
|
orderId: json['order_id'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert to JSON
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'name': name,
|
||||||
|
'posting_date': postingDate,
|
||||||
|
'paid_amount': paidAmount,
|
||||||
|
'mode_of_payment': modeOfPayment,
|
||||||
|
'invoice_id': invoiceId,
|
||||||
|
'order_id': orderId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert to domain entity
|
||||||
|
Payment toEntity() {
|
||||||
|
return Payment(
|
||||||
|
name: name,
|
||||||
|
postingDate: DateTime.tryParse(postingDate) ?? DateTime.now(),
|
||||||
|
paidAmount: paidAmount,
|
||||||
|
modeOfPayment: modeOfPayment,
|
||||||
|
invoiceId: invoiceId,
|
||||||
|
orderId: orderId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create from domain entity
|
||||||
|
factory PaymentModel.fromEntity(Payment entity) {
|
||||||
|
return PaymentModel(
|
||||||
|
name: entity.name,
|
||||||
|
postingDate: entity.postingDate.toIso8601String().split('T').first,
|
||||||
|
paidAmount: entity.paidAmount,
|
||||||
|
modeOfPayment: entity.modeOfPayment,
|
||||||
|
invoiceId: entity.invoiceId,
|
||||||
|
orderId: entity.orderId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'PaymentModel(name: $name, paidAmount: $paidAmount)';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/// Payment Repository Implementation
|
||||||
|
///
|
||||||
|
/// Implements the payment repository interface.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/features/orders/data/datasources/payment_remote_datasource.dart';
|
||||||
|
import 'package:worker/features/orders/domain/entities/payment.dart';
|
||||||
|
import 'package:worker/features/orders/domain/repositories/payment_repository.dart';
|
||||||
|
|
||||||
|
/// Payment Repository Implementation
|
||||||
|
class PaymentRepositoryImpl implements PaymentRepository {
|
||||||
|
const PaymentRepositoryImpl(this._remoteDataSource);
|
||||||
|
|
||||||
|
final PaymentRemoteDataSource _remoteDataSource;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Payment>> getPaymentsList({
|
||||||
|
int limitStart = 0,
|
||||||
|
int limitPageLength = 0,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final paymentsData = await _remoteDataSource.getPaymentsList(
|
||||||
|
limitStart: limitStart,
|
||||||
|
limitPageLength: limitPageLength,
|
||||||
|
);
|
||||||
|
// Convert Model → Entity
|
||||||
|
return paymentsData.map((model) => model.toEntity()).toList();
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get payments list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Payment> getPaymentDetail(String name) async {
|
||||||
|
try {
|
||||||
|
final paymentData = await _remoteDataSource.getPaymentDetail(name);
|
||||||
|
// Convert Model → Entity
|
||||||
|
return paymentData.toEntity();
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get payment detail: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
84
lib/features/orders/domain/entities/payment.dart
Normal file
84
lib/features/orders/domain/entities/payment.dart
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/// Domain Entity: Payment
|
||||||
|
///
|
||||||
|
/// Represents a payment transaction from the API.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
/// Payment Entity
|
||||||
|
///
|
||||||
|
/// Contains payment information from API:
|
||||||
|
/// - name: Payment ID (e.g., "ACC-PAY-2025-00020")
|
||||||
|
/// - posting_date: Payment date
|
||||||
|
/// - paid_amount: Amount paid
|
||||||
|
/// - mode_of_payment: Payment method (e.g., "Chuyển khoản")
|
||||||
|
/// - invoice_id: Related invoice ID (nullable)
|
||||||
|
/// - order_id: Related order ID (nullable)
|
||||||
|
class Payment extends Equatable {
|
||||||
|
/// Payment ID (e.g., "ACC-PAY-2025-00020")
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
/// Payment posting date
|
||||||
|
final DateTime postingDate;
|
||||||
|
|
||||||
|
/// Amount paid
|
||||||
|
final double paidAmount;
|
||||||
|
|
||||||
|
/// Payment method (e.g., "Chuyển khoản", null if not specified)
|
||||||
|
final String? modeOfPayment;
|
||||||
|
|
||||||
|
/// Related invoice ID (nullable)
|
||||||
|
final String? invoiceId;
|
||||||
|
|
||||||
|
/// Related order ID (nullable)
|
||||||
|
final String? orderId;
|
||||||
|
|
||||||
|
const Payment({
|
||||||
|
required this.name,
|
||||||
|
required this.postingDate,
|
||||||
|
required this.paidAmount,
|
||||||
|
this.modeOfPayment,
|
||||||
|
this.invoiceId,
|
||||||
|
this.orderId,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Get display payment method
|
||||||
|
String get displayPaymentMethod => modeOfPayment ?? 'Chuyển khoản';
|
||||||
|
|
||||||
|
/// Get description based on order/invoice
|
||||||
|
String get description {
|
||||||
|
if (orderId != null) {
|
||||||
|
return 'Thanh toán cho Đơn hàng #$orderId';
|
||||||
|
} else if (invoiceId != null) {
|
||||||
|
return 'Thanh toán hóa đơn #$invoiceId';
|
||||||
|
}
|
||||||
|
return 'Thanh toán #$name';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copy with method for immutability
|
||||||
|
Payment copyWith({
|
||||||
|
String? name,
|
||||||
|
DateTime? postingDate,
|
||||||
|
double? paidAmount,
|
||||||
|
String? modeOfPayment,
|
||||||
|
String? invoiceId,
|
||||||
|
String? orderId,
|
||||||
|
}) {
|
||||||
|
return Payment(
|
||||||
|
name: name ?? this.name,
|
||||||
|
postingDate: postingDate ?? this.postingDate,
|
||||||
|
paidAmount: paidAmount ?? this.paidAmount,
|
||||||
|
modeOfPayment: modeOfPayment ?? this.modeOfPayment,
|
||||||
|
invoiceId: invoiceId ?? this.invoiceId,
|
||||||
|
orderId: orderId ?? this.orderId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [name, postingDate, paidAmount, modeOfPayment, invoiceId, orderId];
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Payment(name: $name, paidAmount: $paidAmount, orderId: $orderId)';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/// Payment Repository Interface
|
||||||
|
///
|
||||||
|
/// Defines the contract for payment-related data operations.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/features/orders/domain/entities/payment.dart';
|
||||||
|
|
||||||
|
/// Payment Repository Interface
|
||||||
|
abstract class PaymentRepository {
|
||||||
|
/// Get list of payments
|
||||||
|
Future<List<Payment>> getPaymentsList({
|
||||||
|
int limitStart = 0,
|
||||||
|
int limitPageLength = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Get payment detail by ID
|
||||||
|
Future<Payment> getPaymentDetail(String name);
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:worker/core/constants/ui_constants.dart';
|
import 'package:worker/core/constants/ui_constants.dart';
|
||||||
import 'package:worker/core/enums/status_color.dart';
|
import 'package:worker/core/enums/status_color.dart';
|
||||||
|
import 'package:worker/core/router/app_router.dart';
|
||||||
import 'package:worker/core/theme/colors.dart';
|
import 'package:worker/core/theme/colors.dart';
|
||||||
import 'package:worker/core/utils/extensions.dart';
|
import 'package:worker/core/utils/extensions.dart';
|
||||||
import 'package:worker/features/account/domain/entities/address.dart';
|
import 'package:worker/features/account/domain/entities/address.dart';
|
||||||
@@ -38,8 +39,8 @@ class OrderDetailPage extends ConsumerWidget {
|
|||||||
onPopInvoked: (didPop) {
|
onPopInvoked: (didPop) {
|
||||||
if (didPop) {
|
if (didPop) {
|
||||||
// Dispose providers when leaving the page
|
// Dispose providers when leaving the page
|
||||||
ref.invalidate(updateOrderAddressProvider);
|
ref..invalidate(updateOrderAddressProvider)
|
||||||
ref.invalidate(cancelOrderProvider);
|
..invalidate(cancelOrderProvider);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -1411,11 +1412,9 @@ class OrderDetailPage extends ConsumerWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// TODO: Navigate to payment page
|
// Navigate to payment QR page
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
context.push(
|
||||||
const SnackBar(
|
'${RouteNames.paymentQr}?orderId=${orderDetail.order.name}',
|
||||||
content: Text('Chức năng thanh toán đang phát triển'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: const FaIcon(FontAwesomeIcons.creditCard, size: 18),
|
icon: const FaIcon(FontAwesomeIcons.creditCard, size: 18),
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ class _OrdersPageState extends ConsumerState<OrdersPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_searchController.removeListener(_onSearchChanged);
|
_searchController..removeListener(_onSearchChanged)
|
||||||
_searchController.dispose();
|
..dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +50,9 @@ class _OrdersPageState extends ConsumerState<OrdersPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final filteredOrdersAsync = ref.watch(filteredOrdersProvider);
|
final ordersAsync = ref.watch(ordersProvider);
|
||||||
final selectedStatus = ref.watch(selectedOrderStatusProvider);
|
final selectedStatus = ref.watch(selectedOrderStatusProvider);
|
||||||
|
final searchQuery = ref.watch(orderSearchQueryProvider);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF4F6F8),
|
backgroundColor: const Color(0xFFF4F6F8),
|
||||||
@@ -102,22 +103,49 @@ class _OrdersPageState extends ConsumerState<OrdersPage> {
|
|||||||
// Orders List
|
// Orders List
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
|
||||||
sliver: filteredOrdersAsync.when(
|
sliver: ordersAsync.when(
|
||||||
data: (orders) {
|
data: (orders) {
|
||||||
if (orders.isEmpty) {
|
// Filter by status
|
||||||
return _buildEmptyState();
|
var filtered = orders;
|
||||||
|
if (selectedStatus != null) {
|
||||||
|
filtered = filtered
|
||||||
|
.where((order) => order.status == selectedStatus)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter by search query
|
||||||
|
if (searchQuery.isNotEmpty) {
|
||||||
|
filtered = filtered
|
||||||
|
.where((order) => order.name
|
||||||
|
.toLowerCase()
|
||||||
|
.contains(searchQuery.toLowerCase()))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by transaction date (newest first)
|
||||||
|
filtered.sort((a, b) {
|
||||||
|
try {
|
||||||
|
final aDate = DateTime.parse(a.transactionDate);
|
||||||
|
final bDate = DateTime.parse(b.transactionDate);
|
||||||
|
return bDate.compareTo(aDate);
|
||||||
|
} catch (e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (filtered.isEmpty) {
|
||||||
|
return _buildEmptyState();
|
||||||
|
}
|
||||||
return SliverList(
|
return SliverList(
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
final order = orders[index];
|
final order = filtered[index];
|
||||||
return OrderCard(
|
return OrderCard(
|
||||||
order: order,
|
order: order,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push('/orders/${order.name}');
|
context.push('/orders/${order.name}');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}, childCount: orders.length),
|
}, childCount: filtered.length),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
loading: () => _buildLoadingState(),
|
loading: () => _buildLoadingState(),
|
||||||
@@ -149,11 +177,14 @@ class _OrdersPageState extends ConsumerState<OrdersPage> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Mã đơn hàng',
|
hintText: 'Mã đơn hàng',
|
||||||
hintStyle: const TextStyle(color: AppColors.grey500, fontSize: 14),
|
hintStyle: const TextStyle(color: AppColors.grey500, fontSize: 14),
|
||||||
prefixIcon: const FaIcon(
|
prefixIcon: const Padding(
|
||||||
|
padding: EdgeInsets.all(14),
|
||||||
|
child: FaIcon(
|
||||||
FontAwesomeIcons.magnifyingGlass,
|
FontAwesomeIcons.magnifyingGlass,
|
||||||
color: AppColors.grey500,
|
color: AppColors.grey500,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
suffixIcon: _searchController.text.isNotEmpty
|
suffixIcon: _searchController.text.isNotEmpty
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: const FaIcon(
|
icon: const FaIcon(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
///
|
///
|
||||||
/// QR code payment screen with bank transfer information.
|
/// QR code payment screen with bank transfer information.
|
||||||
/// Features:
|
/// Features:
|
||||||
/// - Payment amount display with minimum payment warning
|
|
||||||
/// - QR code for quick payment
|
/// - QR code for quick payment
|
||||||
/// - Bank transfer information with copy buttons
|
/// - Bank transfer information with copy buttons
|
||||||
/// - Payment confirmation and proof upload buttons
|
/// - Payment confirmation and proof upload buttons
|
||||||
@@ -31,12 +30,10 @@ import 'package:worker/features/orders/presentation/providers/order_repository_p
|
|||||||
/// Displays QR code and bank transfer information for payment.
|
/// Displays QR code and bank transfer information for payment.
|
||||||
class PaymentQrPage extends HookConsumerWidget {
|
class PaymentQrPage extends HookConsumerWidget {
|
||||||
final String orderId;
|
final String orderId;
|
||||||
final double amount;
|
|
||||||
|
|
||||||
const PaymentQrPage({
|
const PaymentQrPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.orderId,
|
required this.orderId,
|
||||||
required this.amount,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -126,14 +123,8 @@ class PaymentQrPage extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
const SizedBox(height: AppSpacing.md),
|
const SizedBox(height: AppSpacing.md),
|
||||||
|
|
||||||
// Payment Amount Card
|
|
||||||
_buildAmountCard(amount),
|
|
||||||
|
|
||||||
const SizedBox(height: AppSpacing.md),
|
|
||||||
|
|
||||||
// QR Code Card
|
// QR Code Card
|
||||||
_buildQrCodeCard(
|
_buildQrCodeCard(
|
||||||
amount,
|
|
||||||
orderId,
|
orderId,
|
||||||
qrCodeData.value?['qr_code'] as String?,
|
qrCodeData.value?['qr_code'] as String?,
|
||||||
isLoadingQr.value,
|
isLoadingQr.value,
|
||||||
@@ -187,70 +178,8 @@ class PaymentQrPage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build payment amount card
|
|
||||||
Widget _buildAmountCard(double amount) {
|
|
||||||
return Container(
|
|
||||||
margin: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
|
|
||||||
padding: const EdgeInsets.all(AppSpacing.md),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(AppRadius.card),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withValues(alpha: 0.05),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_formatCurrency(amount),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 28,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: AppColors.primaryBlue,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
const Text(
|
|
||||||
'Số tiền cần thanh toán',
|
|
||||||
style: TextStyle(fontSize: 14, color: AppColors.grey500),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFFFFF8E1),
|
|
||||||
borderRadius: BorderRadius.circular(AppRadius.card),
|
|
||||||
border: Border.all(color: const Color(0xFFFFD54F)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const FaIcon(FontAwesomeIcons.circleInfo, color: AppColors.warning, size: 18),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'Thanh toán không dưới 20%',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.orange[900],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build QR code card
|
/// Build QR code card
|
||||||
Widget _buildQrCodeCard(
|
Widget _buildQrCodeCard(
|
||||||
double amount,
|
|
||||||
String orderId,
|
String orderId,
|
||||||
String? qrCodeData,
|
String? qrCodeData,
|
||||||
bool isLoading,
|
bool isLoading,
|
||||||
@@ -956,7 +885,6 @@ class PaymentQrPage extends HookConsumerWidget {
|
|||||||
RouteNames.orderSuccess,
|
RouteNames.orderSuccess,
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'orderNumber': orderId,
|
'orderNumber': orderId,
|
||||||
'total': amount.toString(),
|
|
||||||
'isNegotiation': 'false',
|
'isNegotiation': 'false',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -985,9 +913,4 @@ class PaymentQrPage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format currency
|
|
||||||
String _formatCurrency(double amount) {
|
|
||||||
return '${amount.toStringAsFixed(0).replaceAllMapped(RegExp(r'(\d)(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]}.')}₫';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:worker/core/constants/ui_constants.dart';
|
import 'package:worker/core/constants/ui_constants.dart';
|
||||||
import 'package:worker/core/database/models/enums.dart';
|
|
||||||
import 'package:worker/core/theme/colors.dart';
|
|
||||||
import 'package:worker/core/utils/extensions.dart';
|
import 'package:worker/core/utils/extensions.dart';
|
||||||
import 'package:worker/features/orders/data/models/invoice_model.dart';
|
import 'package:worker/features/orders/domain/entities/payment.dart';
|
||||||
import 'package:worker/features/orders/presentation/providers/invoices_provider.dart';
|
import 'package:worker/features/orders/presentation/providers/payments_provider.dart';
|
||||||
|
|
||||||
/// Payments Page
|
/// Payments Page
|
||||||
///
|
///
|
||||||
@@ -27,97 +25,101 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final invoicesAsync = ref.watch(invoicesProvider);
|
final paymentsAsync = ref.watch(paymentsProvider);
|
||||||
|
final colorScheme = context.colorScheme;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF8FAFC),
|
backgroundColor: colorScheme.surfaceContainerLowest,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
icon: Icon(Icons.arrow_back, color: colorScheme.onSurface),
|
||||||
onPressed: () => context.pop(),
|
onPressed: () => context.pop(),
|
||||||
),
|
),
|
||||||
title: const Text(
|
title: Text(
|
||||||
'Lịch sử Thanh toán',
|
'Lịch sử Thanh toán',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: colorScheme.onSurface,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
elevation: AppBarSpecs.elevation,
|
elevation: AppBarSpecs.elevation,
|
||||||
backgroundColor: AppColors.white,
|
backgroundColor: colorScheme.surface,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: const [SizedBox(width: AppSpacing.sm)],
|
actions: const [SizedBox(width: AppSpacing.sm)],
|
||||||
),
|
),
|
||||||
body: invoicesAsync.when(
|
body: paymentsAsync.when(
|
||||||
data: (invoices) {
|
data: (payments) {
|
||||||
// Sort by issue date (newest first)
|
if (payments.isEmpty) {
|
||||||
final sortedInvoices = List<InvoiceModel>.from(invoices)
|
return _buildEmptyState(context, ref);
|
||||||
..sort((a, b) => b.issueDate.compareTo(a.issueDate));
|
|
||||||
|
|
||||||
if (sortedInvoices.isEmpty) {
|
|
||||||
return _buildEmptyState(ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await ref.read(invoicesProvider.notifier).refresh();
|
await ref.read(paymentsProvider.notifier).refresh();
|
||||||
},
|
},
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
itemCount: sortedInvoices.length,
|
itemCount: payments.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final invoice = sortedInvoices[index];
|
final payment = payments[index];
|
||||||
return _TransactionCard(
|
return _TransactionCard(
|
||||||
invoice: invoice,
|
payment: payment,
|
||||||
onTap: () => _showTransactionDetail(context, invoice),
|
onTap: () => _showTransactionDetail(context, payment),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
loading: () => const Center(child: CircularProgressIndicator()),
|
loading: () => const Center(child: CircularProgressIndicator()),
|
||||||
error: (error, stack) => Center(
|
error: (error, stack) => _buildErrorState(context, ref, error),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build error state
|
||||||
|
Widget _buildErrorState(BuildContext context, WidgetRef ref, Object error) {
|
||||||
|
final colorScheme = context.colorScheme;
|
||||||
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
FaIcon(
|
FaIcon(
|
||||||
FontAwesomeIcons.circleExclamation,
|
FontAwesomeIcons.circleExclamation,
|
||||||
size: 64,
|
size: 64,
|
||||||
color: AppColors.danger.withValues(alpha: 0.7),
|
color: colorScheme.error.withValues(alpha: 0.7),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
const Text(
|
Text(
|
||||||
'Có lỗi xảy ra',
|
'Có lỗi xảy ra',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppColors.grey900,
|
color: colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
error.toString(),
|
error.toString(),
|
||||||
style: const TextStyle(fontSize: 14, color: AppColors.grey500),
|
style: TextStyle(fontSize: 14, color: colorScheme.onSurfaceVariant),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => ref.invalidate(invoicesProvider),
|
onPressed: () => ref.invalidate(paymentsProvider),
|
||||||
child: const Text('Thử lại'),
|
child: const Text('Thử lại'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build empty state
|
/// Build empty state
|
||||||
Widget _buildEmptyState(WidgetRef ref) {
|
Widget _buildEmptyState(BuildContext context, WidgetRef ref) {
|
||||||
|
final colorScheme = context.colorScheme;
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await ref.read(invoicesProvider.notifier).refresh();
|
await ref.read(paymentsProvider.notifier).refresh();
|
||||||
},
|
},
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
@@ -131,7 +133,7 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
FaIcon(
|
FaIcon(
|
||||||
FontAwesomeIcons.receipt,
|
FontAwesomeIcons.receipt,
|
||||||
size: 64,
|
size: 64,
|
||||||
color: AppColors.grey500.withValues(alpha: 0.5),
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(
|
Text(
|
||||||
@@ -139,13 +141,16 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppColors.grey900.withValues(alpha: 0.8),
|
color: colorScheme.onSurface.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
const Text(
|
Text(
|
||||||
'Hiện tại không có giao dịch nào trong danh mục này',
|
'Hiện tại không có giao dịch nào trong danh mục này',
|
||||||
style: TextStyle(fontSize: 14, color: AppColors.grey500),
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -158,22 +163,23 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Show transaction detail modal
|
/// Show transaction detail modal
|
||||||
void _showTransactionDetail(BuildContext context, InvoiceModel invoice) {
|
void _showTransactionDetail(BuildContext context, Payment payment) {
|
||||||
|
final colorScheme = context.colorScheme;
|
||||||
final currencyFormatter = NumberFormat.currency(
|
final currencyFormatter = NumberFormat.currency(
|
||||||
locale: 'vi_VN',
|
locale: 'vi_VN',
|
||||||
symbol: 'đ',
|
symbol: 'đ',
|
||||||
decimalDigits: 0,
|
decimalDigits: 0,
|
||||||
);
|
);
|
||||||
final dateTimeFormatter = DateFormat('dd/MM/yyyy - HH:mm');
|
final dateTimeFormatter = DateFormat('dd/MM/yyyy');
|
||||||
|
|
||||||
showModalBottomSheet<void>(
|
showModalBottomSheet<void>(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
builder: (context) => Container(
|
builder: (context) => Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: colorScheme.surface,
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -181,20 +187,20 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
// Header
|
// Header
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: AppColors.grey100),
|
bottom: BorderSide(color: colorScheme.outlineVariant),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'Chi tiết giao dịch',
|
'Chi tiết giao dịch',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: AppColors.grey900,
|
color: colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
@@ -202,11 +208,11 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: 32,
|
width: 32,
|
||||||
height: 32,
|
height: 32,
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.grey100,
|
color: colorScheme.surfaceContainerHighest,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.close, size: 18),
|
child: Icon(Icons.close, size: 18, color: colorScheme.onSurfaceVariant),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -220,48 +226,52 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
_DetailRow(
|
_DetailRow(
|
||||||
label: 'Mã giao dịch:',
|
label: 'Mã giao dịch:',
|
||||||
value: '#${invoice.invoiceNumber}',
|
value: '#${payment.name}',
|
||||||
),
|
),
|
||||||
_DetailRow(
|
_DetailRow(
|
||||||
label: 'Loại giao dịch:',
|
label: 'Loại giao dịch:',
|
||||||
value: _getTransactionType(invoice),
|
value: 'Tiền ra (Thanh toán)',
|
||||||
),
|
),
|
||||||
_DetailRow(
|
_DetailRow(
|
||||||
label: 'Thời gian:',
|
label: 'Ngày thanh toán:',
|
||||||
value: dateTimeFormatter.format(invoice.issueDate),
|
value: dateTimeFormatter.format(payment.postingDate),
|
||||||
),
|
),
|
||||||
_DetailRow(
|
_DetailRow(
|
||||||
label: 'Phương thức:',
|
label: 'Phương thức:',
|
||||||
value: _getPaymentMethod(invoice),
|
value: payment.displayPaymentMethod,
|
||||||
),
|
),
|
||||||
_DetailRow(
|
_DetailRow(
|
||||||
label: 'Mô tả:',
|
label: 'Mô tả:',
|
||||||
value: invoice.orderId != null
|
value: payment.description,
|
||||||
? 'Thanh toán cho Đơn hàng #${invoice.orderId}'
|
|
||||||
: 'Thanh toán hóa đơn',
|
|
||||||
),
|
),
|
||||||
|
if (payment.invoiceId != null)
|
||||||
_DetailRow(
|
_DetailRow(
|
||||||
label: 'Mã tham chiếu:',
|
label: 'Mã hóa đơn:',
|
||||||
value: invoice.erpnextInvoice ?? invoice.invoiceId,
|
value: payment.invoiceId!,
|
||||||
|
),
|
||||||
|
if (payment.orderId != null)
|
||||||
|
_DetailRow(
|
||||||
|
label: 'Mã đơn hàng:',
|
||||||
|
value: payment.orderId!,
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'Số tiền:',
|
'Số tiền:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: AppColors.grey500,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
currencyFormatter.format(invoice.amountPaid),
|
currencyFormatter.format(payment.paidAmount),
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: Color(0xFFdc2626),
|
color: colorScheme.error,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -278,40 +288,29 @@ class PaymentsPage extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getTransactionType(InvoiceModel invoice) {
|
|
||||||
if (invoice.status == InvoiceStatus.refunded) {
|
|
||||||
return 'Tiền vào (Hoàn tiền)';
|
|
||||||
}
|
|
||||||
return 'Tiền ra (Thanh toán)';
|
|
||||||
}
|
|
||||||
|
|
||||||
String _getPaymentMethod(InvoiceModel invoice) {
|
|
||||||
// Default to bank transfer, can be enhanced based on actual payment data
|
|
||||||
return 'Chuyển khoản';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transaction Card Widget
|
/// Transaction Card Widget
|
||||||
class _TransactionCard extends StatelessWidget {
|
class _TransactionCard extends StatelessWidget {
|
||||||
const _TransactionCard({
|
const _TransactionCard({
|
||||||
required this.invoice,
|
required this.payment,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
final InvoiceModel invoice;
|
final Payment payment;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final dateTimeFormatter = DateFormat('dd/MM/yyyy - HH:mm');
|
final dateFormatter = DateFormat('dd/MM/yyyy');
|
||||||
final isRefund = invoice.status == InvoiceStatus.refunded;
|
final colorScheme = context.colorScheme;
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
elevation: 3,
|
elevation: 2,
|
||||||
shadowColor: Colors.black.withValues(alpha: 0.08),
|
shadowColor: colorScheme.shadow,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
color: colorScheme.surface,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@@ -325,18 +324,18 @@ class _TransactionCard extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'#${invoice.invoiceNumber}',
|
'#${payment.name}',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: AppColors.grey900,
|
color: colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
dateTimeFormatter.format(invoice.issueDate),
|
dateFormatter.format(payment.postingDate),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColors.grey500.withValues(alpha: 0.8),
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -346,12 +345,10 @@ class _TransactionCard extends StatelessWidget {
|
|||||||
|
|
||||||
// Description
|
// Description
|
||||||
Text(
|
Text(
|
||||||
invoice.orderId != null
|
payment.description,
|
||||||
? 'Thanh toán cho Đơn hàng #${invoice.orderId}'
|
style: TextStyle(
|
||||||
: 'Thanh toán hóa đơn #${invoice.invoiceNumber}',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: AppColors.grey500,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -360,28 +357,28 @@ class _TransactionCard extends StatelessWidget {
|
|||||||
// Footer: method and amount
|
// Footer: method and amount
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: 8),
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(color: AppColors.grey100),
|
top: BorderSide(color: colorScheme.outlineVariant),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
// Payment method
|
// Payment method
|
||||||
const Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
FaIcon(
|
FaIcon(
|
||||||
FontAwesomeIcons.buildingColumns,
|
FontAwesomeIcons.buildingColumns,
|
||||||
size: 14,
|
size: 14,
|
||||||
color: AppColors.grey500,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
'Chuyển khoản',
|
payment.displayPaymentMethod,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: AppColors.grey500,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -389,15 +386,11 @@ class _TransactionCard extends StatelessWidget {
|
|||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
Text(
|
Text(
|
||||||
isRefund
|
payment.paidAmount.toVNCurrency,
|
||||||
? '+${invoice.amountPaid.toVNCurrency}'
|
|
||||||
: invoice.amountPaid.toVNCurrency,
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: isRefund
|
color: colorScheme.error,
|
||||||
? const Color(0xFF059669)
|
|
||||||
: const Color(0xFFdc2626),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -423,11 +416,12 @@ class _DetailRow extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = context.colorScheme;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: AppColors.grey100),
|
bottom: BorderSide(color: colorScheme.outlineVariant),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -436,19 +430,19 @@ class _DetailRow extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: AppColors.grey500,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
value,
|
value,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppColors.grey900,
|
color: colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -91,55 +91,6 @@ class OrderSearchQuery extends _$OrderSearchQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Filtered Orders Provider
|
|
||||||
///
|
|
||||||
/// Filters orders by selected status and search query.
|
|
||||||
@riverpod
|
|
||||||
Future<List<Order>> filteredOrders(Ref ref) async {
|
|
||||||
final ordersAsync = ref.watch(ordersProvider);
|
|
||||||
final selectedStatus = ref.watch(selectedOrderStatusProvider);
|
|
||||||
final searchQuery = ref.watch(orderSearchQueryProvider);
|
|
||||||
|
|
||||||
return ordersAsync.when(
|
|
||||||
data: (orders) {
|
|
||||||
var filtered = orders;
|
|
||||||
|
|
||||||
// Filter by status
|
|
||||||
if (selectedStatus != null) {
|
|
||||||
filtered = filtered
|
|
||||||
.where((order) => order.status == selectedStatus)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by search query
|
|
||||||
if (searchQuery.isNotEmpty) {
|
|
||||||
filtered = filtered
|
|
||||||
.where(
|
|
||||||
(order) => order.name.toLowerCase().contains(
|
|
||||||
searchQuery.toLowerCase(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort by transaction date (newest first)
|
|
||||||
filtered.sort((a, b) {
|
|
||||||
try {
|
|
||||||
final aDate = DateTime.parse(a.transactionDate);
|
|
||||||
final bDate = DateTime.parse(b.transactionDate);
|
|
||||||
return bDate.compareTo(aDate);
|
|
||||||
} catch (e) {
|
|
||||||
return 0; // Keep original order if parsing fails
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return filtered;
|
|
||||||
},
|
|
||||||
loading: () => [],
|
|
||||||
error: (error, stack) => [],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Orders Count by Status Provider
|
/// Orders Count by Status Provider
|
||||||
///
|
///
|
||||||
/// Returns count of orders for each status.
|
/// Returns count of orders for each status.
|
||||||
|
|||||||
@@ -205,56 +205,6 @@ abstract class _$OrderSearchQuery extends $Notifier<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Filtered Orders Provider
|
|
||||||
///
|
|
||||||
/// Filters orders by selected status and search query.
|
|
||||||
|
|
||||||
@ProviderFor(filteredOrders)
|
|
||||||
const filteredOrdersProvider = FilteredOrdersProvider._();
|
|
||||||
|
|
||||||
/// Filtered Orders Provider
|
|
||||||
///
|
|
||||||
/// Filters orders by selected status and search query.
|
|
||||||
|
|
||||||
final class FilteredOrdersProvider
|
|
||||||
extends
|
|
||||||
$FunctionalProvider<
|
|
||||||
AsyncValue<List<Order>>,
|
|
||||||
List<Order>,
|
|
||||||
FutureOr<List<Order>>
|
|
||||||
>
|
|
||||||
with $FutureModifier<List<Order>>, $FutureProvider<List<Order>> {
|
|
||||||
/// Filtered Orders Provider
|
|
||||||
///
|
|
||||||
/// Filters orders by selected status and search query.
|
|
||||||
const FilteredOrdersProvider._()
|
|
||||||
: super(
|
|
||||||
from: null,
|
|
||||||
argument: null,
|
|
||||||
retry: null,
|
|
||||||
name: r'filteredOrdersProvider',
|
|
||||||
isAutoDispose: true,
|
|
||||||
dependencies: null,
|
|
||||||
$allTransitiveDependencies: null,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String debugGetCreateSourceHash() => _$filteredOrdersHash();
|
|
||||||
|
|
||||||
@$internal
|
|
||||||
@override
|
|
||||||
$FutureProviderElement<List<Order>> $createElement(
|
|
||||||
$ProviderPointer pointer,
|
|
||||||
) => $FutureProviderElement(pointer);
|
|
||||||
|
|
||||||
@override
|
|
||||||
FutureOr<List<Order>> create(Ref ref) {
|
|
||||||
return filteredOrders(ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _$filteredOrdersHash() => r'04c5c87d7138b66987c8b45f878d445026ec8e19';
|
|
||||||
|
|
||||||
/// Orders Count by Status Provider
|
/// Orders Count by Status Provider
|
||||||
///
|
///
|
||||||
/// Returns count of orders for each status.
|
/// Returns count of orders for each status.
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/// Payments Provider
|
||||||
|
///
|
||||||
|
/// Riverpod providers for managing payments state.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:worker/core/network/dio_client.dart';
|
||||||
|
import 'package:worker/features/orders/data/datasources/payment_remote_datasource.dart';
|
||||||
|
import 'package:worker/features/orders/data/repositories/payment_repository_impl.dart';
|
||||||
|
import 'package:worker/features/orders/domain/entities/payment.dart';
|
||||||
|
import 'package:worker/features/orders/domain/repositories/payment_repository.dart';
|
||||||
|
|
||||||
|
part 'payments_provider.g.dart';
|
||||||
|
|
||||||
|
/// Payment Repository Provider
|
||||||
|
@riverpod
|
||||||
|
Future<PaymentRepository> paymentRepository(Ref ref) async {
|
||||||
|
final dioClient = await ref.watch(dioClientProvider.future);
|
||||||
|
final remoteDataSource = PaymentRemoteDataSource(dioClient);
|
||||||
|
return PaymentRepositoryImpl(remoteDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Payments Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all payments from repository.
|
||||||
|
@riverpod
|
||||||
|
class Payments extends _$Payments {
|
||||||
|
@override
|
||||||
|
Future<List<Payment>> build() async {
|
||||||
|
try {
|
||||||
|
final repository = await ref.read(paymentRepositoryProvider.future);
|
||||||
|
final payments = await repository.getPaymentsList(
|
||||||
|
limitStart: 0,
|
||||||
|
limitPageLength: 0, // 0 = get all
|
||||||
|
);
|
||||||
|
// Sort by posting date (newest first)
|
||||||
|
payments.sort((a, b) => b.postingDate.compareTo(a.postingDate));
|
||||||
|
return payments;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to load payments: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Refresh payments
|
||||||
|
Future<void> refresh() async {
|
||||||
|
state = const AsyncValue.loading();
|
||||||
|
state = await AsyncValue.guard(() async {
|
||||||
|
final repository = await ref.read(paymentRepositoryProvider.future);
|
||||||
|
final payments = await repository.getPaymentsList(
|
||||||
|
limitStart: 0,
|
||||||
|
limitPageLength: 0,
|
||||||
|
);
|
||||||
|
// Sort by posting date (newest first)
|
||||||
|
payments.sort((a, b) => b.postingDate.compareTo(a.postingDate));
|
||||||
|
return payments;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Payment Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides payment detail by ID.
|
||||||
|
@riverpod
|
||||||
|
Future<Payment> paymentDetail(Ref ref, String name) async {
|
||||||
|
final repository = await ref.watch(paymentRepositoryProvider.future);
|
||||||
|
return await repository.getPaymentDetail(name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'payments_provider.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint, type=warning
|
||||||
|
/// Payment Repository Provider
|
||||||
|
|
||||||
|
@ProviderFor(paymentRepository)
|
||||||
|
const paymentRepositoryProvider = PaymentRepositoryProvider._();
|
||||||
|
|
||||||
|
/// Payment Repository Provider
|
||||||
|
|
||||||
|
final class PaymentRepositoryProvider
|
||||||
|
extends
|
||||||
|
$FunctionalProvider<
|
||||||
|
AsyncValue<PaymentRepository>,
|
||||||
|
PaymentRepository,
|
||||||
|
FutureOr<PaymentRepository>
|
||||||
|
>
|
||||||
|
with
|
||||||
|
$FutureModifier<PaymentRepository>,
|
||||||
|
$FutureProvider<PaymentRepository> {
|
||||||
|
/// Payment Repository Provider
|
||||||
|
const PaymentRepositoryProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'paymentRepositoryProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$paymentRepositoryHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
$FutureProviderElement<PaymentRepository> $createElement(
|
||||||
|
$ProviderPointer pointer,
|
||||||
|
) => $FutureProviderElement(pointer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaymentRepository> create(Ref ref) {
|
||||||
|
return paymentRepository(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$paymentRepositoryHash() => r'974dad2e275b274b5dc7af5db883706706bda301';
|
||||||
|
|
||||||
|
/// Payments Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all payments from repository.
|
||||||
|
|
||||||
|
@ProviderFor(Payments)
|
||||||
|
const paymentsProvider = PaymentsProvider._();
|
||||||
|
|
||||||
|
/// Payments Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all payments from repository.
|
||||||
|
final class PaymentsProvider
|
||||||
|
extends $AsyncNotifierProvider<Payments, List<Payment>> {
|
||||||
|
/// Payments Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all payments from repository.
|
||||||
|
const PaymentsProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'paymentsProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$paymentsHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
Payments create() => Payments();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$paymentsHash() => r'510832e6d296f7b4b151e90beeec0ca28153597f';
|
||||||
|
|
||||||
|
/// Payments Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all payments from repository.
|
||||||
|
|
||||||
|
abstract class _$Payments extends $AsyncNotifier<List<Payment>> {
|
||||||
|
FutureOr<List<Payment>> build();
|
||||||
|
@$mustCallSuper
|
||||||
|
@override
|
||||||
|
void runBuild() {
|
||||||
|
final created = build();
|
||||||
|
final ref = this.ref as $Ref<AsyncValue<List<Payment>>, List<Payment>>;
|
||||||
|
final element =
|
||||||
|
ref.element
|
||||||
|
as $ClassProviderElement<
|
||||||
|
AnyNotifier<AsyncValue<List<Payment>>, List<Payment>>,
|
||||||
|
AsyncValue<List<Payment>>,
|
||||||
|
Object?,
|
||||||
|
Object?
|
||||||
|
>;
|
||||||
|
element.handleValue(ref, created);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Payment Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides payment detail by ID.
|
||||||
|
|
||||||
|
@ProviderFor(paymentDetail)
|
||||||
|
const paymentDetailProvider = PaymentDetailFamily._();
|
||||||
|
|
||||||
|
/// Payment Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides payment detail by ID.
|
||||||
|
|
||||||
|
final class PaymentDetailProvider
|
||||||
|
extends $FunctionalProvider<AsyncValue<Payment>, Payment, FutureOr<Payment>>
|
||||||
|
with $FutureModifier<Payment>, $FutureProvider<Payment> {
|
||||||
|
/// Payment Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides payment detail by ID.
|
||||||
|
const PaymentDetailProvider._({
|
||||||
|
required PaymentDetailFamily super.from,
|
||||||
|
required String super.argument,
|
||||||
|
}) : super(
|
||||||
|
retry: null,
|
||||||
|
name: r'paymentDetailProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$paymentDetailHash();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return r'paymentDetailProvider'
|
||||||
|
''
|
||||||
|
'($argument)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
$FutureProviderElement<Payment> $createElement($ProviderPointer pointer) =>
|
||||||
|
$FutureProviderElement(pointer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<Payment> create(Ref ref) {
|
||||||
|
final argument = this.argument as String;
|
||||||
|
return paymentDetail(ref, argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is PaymentDetailProvider && other.argument == argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return argument.hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$paymentDetailHash() => r'b20c04bb5c7054cf5aec1da0da363c3a3c8635ba';
|
||||||
|
|
||||||
|
/// Payment Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides payment detail by ID.
|
||||||
|
|
||||||
|
final class PaymentDetailFamily extends $Family
|
||||||
|
with $FunctionalFamilyOverride<FutureOr<Payment>, String> {
|
||||||
|
const PaymentDetailFamily._()
|
||||||
|
: super(
|
||||||
|
retry: null,
|
||||||
|
name: r'paymentDetailProvider',
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
isAutoDispose: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Payment Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides payment detail by ID.
|
||||||
|
|
||||||
|
PaymentDetailProvider call(String name) =>
|
||||||
|
PaymentDetailProvider._(argument: name, from: this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => r'paymentDetailProvider';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user