@page "/applications"
@using System.Net
@using System.Text
@using BlazorWebAssemblyVisaApiClient.Components.Auth
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
@using VisaApiClient
@inherits BlazorWebAssemblyVisaApiClient.Components.Base.VisaClientComponentBase
@(AuthComponent.CurrentRole ?? "bruh")
@((MarkupString)htmlMarkup)
@code {
private string htmlMarkup = "bruh";
protected override async Task OnInitializedAsync()
{
var stringBuilder = new StringBuilder();
try
{
switch (AuthComponent.CurrentRole)
{
case "Applicant":
var applications = await Client.GetForApplicantAsync();
stringBuilder.AppendLine("
| Destination Country | Visa Category | Request date | Days requested | Status |
");
foreach (var application in applications)
{
stringBuilder.AppendLine($"| {application.DestinationCountry} | {application.VisaCategory.GetDisplayName()} | {application.RequestDate.ToString("d")} | {application.ValidDaysRequested} | {application.Status.GetDisplayName()} |
");
}
stringBuilder.AppendLine("
");
htmlMarkup = stringBuilder.ToString();
break;
default:
htmlMarkup = AuthComponent.CurrentRole;
break;
}
}
catch (Exception e)
{
if (e is ApiException { Result.Status: (int)HttpStatusCode.Unauthorized } problemDetailsException)
{
htmlMarkup = problemDetailsException.Result.Detail!;
}
else
{
//ErrorHandler.Handle(e);
throw;
}
}
}
}