import 'package:flutter/material.dart';

import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart';
import '../../../../domain/order/order.dart';
import '../../../components/border/dashed_border.dart';
import '../../../components/spaces/space.dart';

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

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            'Ringkasan Pembayaran',
            style: AppStyle.lg.copyWith(
              fontWeight: FontWeight.bold,
              color: AppColor.primary,
            ),
          ),
          const SpaceHeight(12),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                'Subtotal',
                style: AppStyle.md.copyWith(color: Colors.grey.shade700),
              ),
              Text((order?.subtotal ?? 0).currencyFormatRpV2),
            ],
          ),
          const SpaceHeight(4),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                'Tax',
                style: AppStyle.md.copyWith(color: Colors.grey.shade700),
              ),
              Text((order?.taxAmount ?? 0).currencyFormatRpV2),
            ],
          ),
          const SpaceHeight(4),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                'Discount',
                style: AppStyle.md.copyWith(color: Colors.grey.shade700),
              ),
              Text((order?.discountAmount ?? 0).currencyFormatRpV2),
            ],
          ),
          const SpaceHeight(8),
          const DashedDivider(color: AppColor.border),
          const SpaceHeight(8),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const Text(
                'Total',
                style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
              ),
              Text(
                (order?.totalAmount ?? 0).currencyFormatRpV2,
                style: AppStyle.lg.copyWith(
                  fontWeight: FontWeight.bold,
                  color: AppColor.primary,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
