import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
import 'package:flutter/material.dart';

class SalesOrderInformation extends StatelessWidget {
  final Order? 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?.orderNumber}",
          ),
          _item(
            title: 'Tanggal',
            value: (order?.createdAt ?? DateTime.now()).toFormattedDate2(),
          ),
          _item(
            title: 'No. Meja',
            value: order?.tableNumber ?? "-",
          ),
          _item(
            title: 'Jenis Order',
            value: order?.orderType ?? "-",
          ),
        ],
      ),
    );
  }

  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,
            ),
          ),
        ],
      ),
    );
  }
}
