apskel-pos-flutter/lib/presentation/sales/widgets/sales_order_information.dart

132 lines
3.9 KiB
Dart
Raw Normal View History

2025-08-08 10:29:17 +07:00
import 'package:enaklo_pos/core/components/spaces.dart';
2025-08-02 10:50:48 +07:00
import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
2025-08-03 14:39:15 +07:00
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
2025-08-02 10:50:48 +07:00
import 'package:flutter/material.dart';
class SalesOrderInformation extends StatelessWidget {
2025-08-03 14:39:15 +07:00
final Order? order;
2025-08-02 10:50:48 +07:00
const SalesOrderInformation({super.key, this.order});
@override
Widget build(BuildContext context) {
return Container(
2025-08-08 10:29:17 +07:00
width: double.infinity,
2025-08-02 10:50:48 +07:00
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
2025-08-08 10:29:17 +07:00
color: AppColors.primary,
2025-08-02 10:50:48 +07:00
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2025-08-08 10:29:17 +07:00
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
order?.orderNumber ?? "",
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
_buildStatus(),
],
2025-08-02 10:50:48 +07:00
),
2025-08-08 10:29:17 +07:00
const SizedBox(height: 8),
Row(
children: [
if (order?.orderType == 'dineIn') ...[
_buildRowItem(Icons.table_restaurant_outlined,
'Meja ${order?.tableNumber}'),
const SizedBox(width: 16),
],
_buildRowItem(Icons.restaurant_outlined, '${order?.orderType}'),
],
2025-08-02 10:50:48 +07:00
),
2025-08-08 10:29:17 +07:00
const SizedBox(height: 8),
Text(
'Pelanggan: ${order?.metadata?['customer_name'] ?? ""}',
style: const TextStyle(color: Colors.white, fontSize: 14),
2025-08-02 10:50:48 +07:00
),
2025-08-08 10:29:17 +07:00
Text(
'Dibuat: ${order?.createdAt?.toFormattedDate3() ?? ""}',
style: const TextStyle(color: Colors.white70, fontSize: 12),
2025-08-02 10:50:48 +07:00
),
],
),
);
}
2025-08-08 10:29:17 +07:00
Row _buildRowItem(IconData icon, String title) {
return Row(
children: [
Icon(
icon,
color: Colors.white70,
size: 16,
),
const SpaceWidth(4),
Text(
title,
style: const TextStyle(color: Colors.white70, fontSize: 14),
),
],
);
}
Container _buildStatus() {
switch (order?.status) {
case 'pending':
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(12),
),
child: Text(
(order?.status ?? "").toUpperCase(),
style: TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.bold,
2025-08-02 10:50:48 +07:00
),
),
2025-08-08 10:29:17 +07:00
);
case 'completed':
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: Colors.greenAccent,
borderRadius: BorderRadius.circular(12),
),
child: Text(
(order?.status ?? "").toUpperCase(),
style: TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.bold,
2025-08-02 10:50:48 +07:00
),
),
2025-08-08 10:29:17 +07:00
);
default:
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(12),
),
child: Text(
(order?.status ?? "").toUpperCase(),
style: TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
);
}
2025-08-02 10:50:48 +07:00
}
}