@page
@model UnclaimedPhoneNumbersModel
@{
    ViewData["Title"] = "Unclaimed Phone Numbers";

    var codeService = HttpContext.RequestServices.GetService<PhoneClaimCodeProviderService>();
    var codeGenerated = codeService.IsCodeGeneratedForUser(User.Identity.Name);
}

<div class="text-left">
    <table>
        <tr>
            <th>Phone Number</th>
            <th>Claim</th>
        </tr>
        @foreach (var user in @Model.UnclaimedUsers)
        {
            var phone = user.SignalMemberId; var userId = user.UserId;
            <tr>
                <td>@phone</td>
                <td>
                    <form method="post">
                        <input name="userIndex" value="@userId" type="hidden" /> 
                        <input type="submit" title="Claim" value="Claim" disabled="@codeGenerated" />
                    </form>
                </td>
            </tr>
        }
    </table>   
    @if(codeGenerated)
    {
        <form method="post">
            <label for="code">Verification code:</label>
            <input type="text" id="code" name="code" />
            <input type="submit" title="Verify" value="Verify" asp-page-handler="SubmitCode" />
        </form>
    } 
</div>
