import 'package:flutter/material.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:niogu_app/core/utils/currency_format.dart';
import 'package:niogu_app/features/report/transaction/domain/entities/transaction_report.dart';
import 'package:niogu_app/features/report/transaction/presentation/widgets/summary_row.dart';
import 'package:sizer/sizer.dart';

class PaymentOrderSummary extends StatelessWidget {
  final OrderDetail orderDetail;
  const PaymentOrderSummary({super.key, required this.orderDetail});

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w > 600;
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.h),
      child: Column(
        children: [
          SummaryRow(
            label: "Subtotal",
            value: CurrencyFormat.formatToIdr(orderDetail.totalOrder, 0),
          ),
          if (orderDetail.discount > 0)
            SummaryRow(
              label: "Diskon",
              value: CurrencyFormat.formatToIdr(-orderDetail.discount, 0),
              color: Colors.red,
            ),
          if (orderDetail.tax > 0)
            SummaryRow(
              label: "Pajak",
              value: "+" + CurrencyFormat.formatToIdr(orderDetail.tax, 0),
              color: Colors.green,
            ),

          Divider(height: 3.h, color: Colors.grey.shade200),

          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                "TOTAL",
                style: TextStyle(
                  fontSize: isTablet
                      ? AppFontSize.medium.sp
                      : AppFontSize.small.sp,
                  fontWeight: FontWeight.bold,
                ),
              ),
              Text(
                CurrencyFormat.formatToIdr(orderDetail.totalAmount, 0),
                style: TextStyle(
                  fontSize: isTablet
                      ? AppFontSize.medium.sp
                      : AppFontSize.small.sp,
                  fontWeight: FontWeight.bold,
                  color: AppColor.primaryColor,
                ),
              ),
            ],
          ),

          SizedBox(height: 2.h),

          SummaryRow(
            label: "Bayar Tunai",
            value: CurrencyFormat.formatToIdr(orderDetail.payAmount, 0),
          ),
          SizedBox(height: 0.5.h),
          SummaryRow(
            label: "Kembali",
            value: CurrencyFormat.formatToIdr(orderDetail.changeAmount, 0),
            isBold: true,
          ),
        ],
      ),
    );
  }
}
