fix: ui refund and sales page

This commit is contained in:
efrilm 2025-08-07 20:11:57 +07:00
parent e3da008a9a
commit 49fef5afb2
3 changed files with 75 additions and 66 deletions

View File

@ -113,6 +113,7 @@ class Order {
final DateTime? createdAt;
final DateTime? updatedAt;
final List<OrderItem>? orderItems;
final bool? isRefund;
Order({
this.id,
@ -131,6 +132,7 @@ class Order {
this.createdAt,
this.updatedAt,
this.orderItems,
this.isRefund,
});
factory Order.fromMap(Map<String, dynamic> json) => Order(
@ -147,6 +149,7 @@ class Order {
totalAmount: json["total_amount"],
notes: json["notes"],
metadata: json["metadata"] ?? {},
isRefund: json["is_refund"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
@ -175,6 +178,7 @@ class Order {
"metadata": metadata,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
"is_refund": isRefund,
"order_items": orderItems == null
? []
: List<dynamic>.from(orderItems!.map((x) => x.toMap())),

View File

@ -39,7 +39,11 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
late Animation<double> _scaleAnimation;
final List<Map<String, dynamic>> refundReasons = [
{'value': 'Barang Rusak', 'icon': Icons.broken_image, 'color': Colors.red},
{
'value': 'Barang Rusak',
'icon': Icons.broken_image,
'color': AppColors.primary
},
{'value': 'Salah Item', 'icon': Icons.swap_horiz, 'color': Colors.orange},
{
'value': 'Tidak Sesuai Pesanan',
@ -56,7 +60,11 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
'icon': Icons.thumb_down,
'color': Colors.purple
},
{'value': 'Lainnya', 'icon': Icons.more_horiz, 'color': Colors.grey},
{
'value': 'Lainnya',
'icon': Icons.more_horiz,
'color': Colors.red,
},
];
@override
@ -201,13 +209,6 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 30,
offset: Offset(0, 15),
),
],
),
child: Padding(
padding: EdgeInsets.all(20),
@ -220,16 +221,12 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.green[400]!, Colors.green[600]!],
colors: [
const Color.fromARGB(255, 96, 56, 148),
AppColors.primary
],
),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.green.withOpacity(0.3),
blurRadius: 15,
offset: Offset(0, 8),
),
],
),
child: Icon(
Icons.receipt_long,
@ -327,13 +324,6 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 30,
offset: Offset(0, 15),
),
],
),
child: Padding(
padding: EdgeInsets.all(20),
@ -345,12 +335,17 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.amber.withOpacity(0.2),
gradient: LinearGradient(
colors: [
const Color.fromARGB(255, 96, 56, 148),
AppColors.primary
],
),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
Icons.account_balance_wallet,
color: Colors.amber[700],
Icons.account_balance_wallet_outlined,
color: AppColors.white,
size: 24,
),
),
@ -402,13 +397,6 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 30,
offset: Offset(0, 15),
),
],
),
child: Padding(
padding: EdgeInsets.all(20),
@ -421,19 +409,15 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.red[400]!, Colors.red[600]!],
colors: [
const Color.fromARGB(255, 96, 56, 148),
AppColors.primary
],
),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.red.withOpacity(0.3),
blurRadius: 15,
offset: Offset(0, 8),
),
],
),
child: Icon(
Icons.assignment_return,
Icons.assignment_return_outlined,
color: Colors.white,
size: 24,
),
@ -655,14 +639,14 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
orElse: () => false,
);
return Container(
return SizedBox(
width: double.infinity,
height: 64,
child: ElevatedButton(
onPressed:
isLoading ? null : () => _processRefund(context),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red[600],
backgroundColor: AppColors.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),

View File

@ -29,20 +29,39 @@ class SalesCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerRight,
child: Text(
'${order.orderNumber}',
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
Row(
children: [
Expanded(
child: Text(
'${order.orderNumber}',
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
),
if (order.isRefund == true)
Container(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.red.withOpacity(0.15),
borderRadius: BorderRadius.circular(16),
),
child: Text(
'Refund',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.w600,
fontSize: 10,
letterSpacing: 0.5,
),
),
),
],
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 22,
@ -63,17 +82,19 @@ class SalesCard extends StatelessWidget {
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Row(
children: [
Icon(Icons.table_bar, size: 16, color: Colors.grey),
const SizedBox(width: 4),
Text(
'Meja ${order.tableNumber}',
style: TextStyle(color: Colors.grey[600]),
),
],
),
if (order.orderType == "dineIn") ...[
const SizedBox(height: 4),
Row(
children: [
Icon(Icons.table_bar, size: 16, color: Colors.grey),
const SizedBox(width: 4),
Text(
'Meja ${order.tableNumber}',
style: TextStyle(color: Colors.grey[600]),
),
],
),
]
],
),
),