import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
import 'package:flutter/material.dart';

class SalesOrderInformation extends StatelessWidget {
  final OrderModel? order;
  const SalesOrderInformation({super.key, this.order});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: AppColors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            'Informasi Pesanan',
            style: TextStyle(
              color: AppColors.black,
              fontSize: 16,
              fontWeight: FontWeight.w600,
            ),
          ),
          _item(
            title: 'No. Order',
            value: "${order?.id}",
          ),
          _item(
            title: 'Tanggal',
            value:
                DateTime.parse(order?.transactionTime ?? "").toFormattedDate3(),
          ),
          _item(
            title: 'Kasir',
            value: order?.namaKasir ?? "-",
          ),
          _item(
            title: 'Jenis Order',
            value: order?.orderType.value ?? "-",
          ),
        ],
      ),
    );
  }

  Padding _item({
    required String title,
    required String value,
  }) {
    return Padding(
      padding: const EdgeInsets.only(top: 12),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            title,
            style: const TextStyle(
              fontSize: 14,
            ),
          ),
          Text(
            value,
            style: const TextStyle(
              fontSize: 14,
            ),
          ),
        ],
      ),
    );
  }
}
