import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../../application/auth/auth_bloc.dart';
import '../../../../../router/app_router.gr.dart';
import 'feature_card.dart';

class HomeFeatureSection extends StatelessWidget {
  const HomeFeatureSection({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<AuthBloc, AuthState>(
      builder: (context, state) {
        return Container(
          padding: const EdgeInsets.all(16),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              HomeFeatureCard(
                icon: Icons.card_giftcard,
                title: 'Reward',
                iconColor: const Color(0xFF1976D2),
                onTap: () => context.router.push(RewardRoute()),
              ),
              HomeFeatureCard(
                icon: Icons.casino,
                title: 'Undian',
                iconColor: const Color(0xFF7B1FA2),
                onTap: () => context.router.push(DrawRoute()),
              ),
              HomeFeatureCard(
                icon: Icons.store,
                title: 'Merchant',
                iconColor: const Color(0xFF388E3C),
                onTap: () => context.router.push(MerchantRoute()),
              ),
              HomeFeatureCard(
                icon: Icons.blur_circular,
                title: 'Wheels',
                iconColor: const Color(0xFF388E3C),
                onTap: () => state.isAuthenticated
                    ? context.router.push(FerrisWheelRoute())
                    : context.router.push(OnboardingRoute()),
              ),
            ],
          ),
        );
      },
    );
  }
}
