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

/// A widget that displays the primary action button and trouble link for OTP verification.
class OtpVerificationActions extends StatelessWidget {
  /// Whether the verification process is currently loading.
  final bool isLoading;

  /// Whether the submit button should be enabled.
  final bool canSubmit;

  /// Callback for when the Continue button is pressed.
  final VoidCallback? onContinue;

  /// Creates an [OtpVerificationActions].
  const OtpVerificationActions({
    super.key,
    required this.isLoading,
    required this.canSubmit,
    this.onContinue,
  });

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