using CMSMicroservice.Protobuf.Protos.User;
using Microsoft.AspNetCore.Components;
using MudBlazor;
using static FrontOffice.Main.Shared.AuthDialog;

namespace FrontOffice.Main.Shared;

public partial class PhoneVerifyForm
{
    // ── Step state ──
    [Parameter, EditorRequired] public AuthStep CurrentStep { get; set; }

    // ── Phone step ──
    [Parameter, EditorRequired] public CreateNewOtpTokenRequest PhoneRequest { get; set; } = default!;

    // ── Verify step ──
    [Parameter, EditorRequired] public VerifyOtpTokenRequest VerifyRequest { get; set; } = default!;

    // ── Captcha ──
    [Parameter] public string? CaptchaCode { get; set; }
    [Parameter] public string? CaptchaInput { get; set; }
    [Parameter] public EventCallback<string?> CaptchaInputChanged { get; set; }
    [Parameter] public EventCallback OnRefreshCaptcha { get; set; }

    // ── Shared state ──
    [Parameter] public bool IsBusy { get; set; }
    [Parameter] public string? ErrorMessage { get; set; }
    [Parameter] public string? InfoMessage { get; set; }
    [Parameter] public string? PhoneNumber { get; set; }
    [Parameter] public int ResendRemaining { get; set; }

    // ── Referral ──
    [Parameter] public string? ReferralCode { get; set; }
    [Parameter] public EventCallback<string?> ReferralCodeChanged { get; set; }

    // ── Verify actions ──
    [Parameter] public EventCallback OnChangePhone { get; set; }
    [Parameter] public EventCallback OnResendOtp { get; set; }

    // ── Internal form refs (exposed via public methods) ──
    private MudForm? _phoneForm;
    private MudForm? _verifyForm;

    public MudForm? GetPhoneForm() => _phoneForm;
    public MudForm? GetVerifyForm() => _verifyForm;
}
