import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:kasy_kit/components/components.dart';
import 'package:kasy_kit/core/states/user_state_notifier.dart';
import 'package:kasy_kit/core/theme/theme.dart';
import 'package:kasy_kit/i18n/translations.g.dart';

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

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return KasyButton(
      label: t.settings.delete_account.button,
      variant: KasyButtonVariant.ghost,
      foregroundColor: context.colors.muted,
      onPressed: () => showKasyConfirmDialog(
        context,
        title: t.settings.delete_account.title,
        message: t.settings.delete_account.content,
        cancelLabel: t.settings.delete_account.cancel,
        confirmLabel: t.settings.delete_account.confirm,
        destructive: true,
        onConfirm: () => ref.read(userStateNotifierProvider.notifier).deleteAccount(),
      ),
    );
  }
}
