import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:staff_authentication/src/presentation/widgets/common/auth_trouble_link.dart';
import 'package:staff_authentication/staff_authentication.dart';

/// A widget that displays the primary action button and trouble link for Phone Input.
class PhoneInputActions extends StatelessWidget {
  /// Whether the sign-in process is currently loading.
  final bool isLoading;

  /// Callback for when the Send Code button is pressed.
  final VoidCallback? onSendCode;

  /// Creates a [PhoneInputActions].
  const PhoneInputActions({
    super.key,
    required this.isLoading,
    this.onSendCode,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(UiConstants.space6),
      decoration: const BoxDecoration(
        border: Border(top: BorderSide(color: UiColors.separatorSecondary)),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          isLoading
              ? UiButton.secondary(
                  onPressed: null,
                  child: const SizedBox(
                    width: 20,
                    height: 20,
                    child: CircularProgressIndicator(strokeWidth: 2),
                  ),
                )
              : UiButton.primary(
                  text: t
                      .staff_authentication
                      .phone_verification_page
                      .send_code_button,
                  onPressed: onSendCode,
                ),
          const SizedBox(height: UiConstants.space4),
          const AuthTroubleLink(),
        ],
      ),
    );
  }
}
