import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:kasy_kit/features/authentication/providers/models/signin_state.dart';
import 'package:kasy_kit/features/authentication/providers/signin_state_provider.dart';
import 'package:kasy_kit/features/authentication/ui/widgets/round_signin.dart';

class FacebookSigninComponent extends ConsumerWidget {
  const FacebookSigninComponent({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    // watch keeps the provider alive during async sign-in
    final state = ref.watch(signinStateProvider);
    final isSending = state is SigninStateSending;
    return SocialSigninButton.facebook(
      () { if (!isSending) ref.read(signinStateProvider.notifier).signinWithFacebook(); },
    );
  }
}
