import 'package:flutter/material.dart';
import 'package:line_icons/line_icons.dart';

import '../../../../common/theme/theme.dart';
import '../../../../domain/analytic/analytic.dart';
import '../../../components/spacer/spacer.dart';
import 'stats_tile.dart';
import 'title.dart';

class HomeStats extends StatelessWidget {
  final DashboardOverview overview;
  const HomeStats({super.key, required this.overview});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(
        vertical: 24,
        horizontal: AppValue.padding,
      ).copyWith(bottom: 0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          HomeTitle(title: 'Ringkasan Hari Ini'),
          const SpaceHeight(20),
          Row(
            children: [
              Expanded(
                child: HomeStatsTile(
                  title: 'Pesanan',
                  value: overview.totalOrders.toString(),
                  icon: Icons.receipt_long_rounded,
                  color: AppColor.info,
                  subtitle: 'Hari ini',
                ),
              ),

              const SpaceWidth(16),
              Expanded(
                child: HomeStatsTile(
                  title: 'Pelanggan Baru',
                  value: overview.totalCustomers.toString(),
                  icon: Icons.person_add_outlined,
                  color: AppColor.primary,
                  subtitle: overview.totalCustomers < 1
                      ? 'Hari ini'
                      : 'bertambah',
                ),
              ),
            ],
          ),
          const SizedBox(height: 16),
          Row(
            children: [
              Expanded(
                child: HomeStatsTile(
                  title: 'Refund',
                  value: overview.refundedOrders.toString(),
                  icon: LineIcons.alternateExchange,
                  color: AppColor.warning,
                  subtitle: 'Hari ini',
                ),
              ),
              const SpaceWidth(16),
              Expanded(
                child: HomeStatsTile(
                  title: 'Void',
                  value: overview.voidedOrders.toString(),
                  icon: Icons.cancel_rounded,
                  color: AppColor.error,
                  subtitle: 'Hari ini',
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
